8000 docs(storage): state where encode_value puts NaN (#688) — backport by adityamukho · Pull Request #705 · project-minigraf/minigraf · GitHub
[go: up one dir, main page]

Skip to content

docs(storage): state where encode_value puts NaN (#688) — backport - #705

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

adityamukho merged 2 commits into
mainfrom
docs/688-nan-encoding

Conversation

@adityamukho
Copy link
Copy Markdown
Collaborator

Doc-only fix for #688 on main, backport of the v3 PR. 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 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 main these bytes are the value_bytes of on-disk 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. The old test comment claiming NaN sorts above all positive floats is removed.
  • 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

@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 and others added 2 commits October 23, 2026 12:16
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). The bytes are v7 on-disk AVET
keys, so the encoding stays; the doc comment now says so, the old test
comment claiming NaN sorts last is gone, and a test pins the position.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0169pNQsLcCEn48te9X9WuZW
@adityamukho
adityamukho force-pushed the docs/688-nan-encoding branch from 4dad28d to 1f07cd4 Compare October 23, 2026 06:46
@adityamukho
adityamukho merged commit b64fe4f into main Oct 23, 2026
17 checks passed
@adityamukho
adityamukho deleted the docs/688-nan-encoding branch October 23, 2026 06:54
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

0