Skip to content

docs(storage): state where encode_value puts NaN (#688) - #704

Merged
adityamukho merged 2 commits into
v3from
docs/688-nan-encoding-v3
Oct 23, 2026
Merged

adityamukho merged 2 commits into
v3from
docs/688-nan-encoding-v3

Conversation

@adityamukho

Copy link
Copy Markdown
Collaborator

Doc-only fix for #688 on v3. Refs #688.

encode_value writes every NaN as 0x03 + 0x7FF8_0000_0000_0000, without the sign transform. So NaN:

  • sorts among the negative subnormals, before -0.0 and every positive float (Value::cmp and the v8 keys (keys::float_bits) puts it after +∞);
  • is byte-equal to f64::from_bits(0x8007_FFFF_FFFF_FFFF) (about -1.1125e-308). The issue didn't mention this.

The encoding stays as it is (spec 2026-10-22-kani-storage-encoding-design.md §6): on v3 the bytes are never stored, but they match v2's v7 AVET keys. Changes:

  • encode_value's doc comment and the inline NaN comment state the real position, and warn against value range scans or NaN/subnormal equality on these bytes.
  • New test test_encode_value_nan_sorts_among_negative_subnormals pins the bytes, the subnormal twin and the sort position.
  • Test counts in CLAUDE.md / docs/TEST_COVERAGE.md +1.

The equality collision has no visible effect: NaN can't be stored through Datalog (there's no NaN literal, and arithmetic that yields NaN fails). A prepared query that binds Value::Float(NaN) against a stored -1.1125e-308 returns no rows, because the matcher's float comparison rejects NaN.

🤖 Generated with Claude Code

https://claude.ai/code/session_0169pNQsLcCEn48te9X9WuZW

encode_value writes every NaN as 0x7FF8_0000_0000_0000 without the sign
transform, so NaN sorts among the negative subnormals and is byte-equal
to f64::from_bits(0x8007_FFFF_FFFF_FFFF), while Value::cmp and the v8
keys put it after +inf. The doc comment now says so and a test pins the
position; the encoding stays as on v2, where it is v7 on-disk AVET keys.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169pNQsLcCEn48te9X9WuZW
@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@adityamukho
adityamukho merged commit a49d703 into v3 Oct 23, 2026
24 of 25 checks passed
@adityamukho
adityamukho deleted the docs/688-nan-encoding-v3 branch October 23, 2026 06:45
adityamukho added a commit that referenced this pull request Oct 23, 2026
Each PR raised the count from 1,771 to 1,772; merged together they add two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169pNQsLcCEn48te9X9WuZW
adityamukho added a commit that referenced this pull request Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant