Skip to content

Put the cross-type counterexample into the LibHashNoAlloc NatSpec - #114

Merged
thedavidmeister merged 1 commit into
mainfrom
hash-113-natspec-counterexample
Sep 16, 2026
Merged

thedavidmeister merged 1 commit into
mainfrom
hash-113-natspec-counterexample

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

#113 cut the README's copy of the abi.encode argument on the ruling that the
LibHashNoAlloc title block is the single statement of it. Its own description
flagged one item that went with the prose and was not carried across: the
concrete illustration that abi.encode of uint8(1), uint256(1), true and
address(1) all produce the same 32 bytes. The claim it illustrates, that
abi.encode is not injective across types, survived in the NatSpec; the worked
example did not. This puts the example back, beside the claim.

The edit

src/lib/LibHashNoAlloc.sol title block only. The sentence that carried the
claim as a subordinate clause becomes a claim plus its demonstration:

/// `abi.decode` recovers the value. It is not injective across types:
/// `abi.encode(uint8(1))`, `abi.encode(uint256(1))`, `abi.encode(true)` and
/// `abi.encode(address(1))` are all the same 32 bytes. That is the same
/// restriction the composition below carries, and abi encoding is not efficient
/// either.

The two surviving predicates are unchanged in force: the cross-type restriction
is still stated as the one the composition below carries, and the efficiency
claim still hands off to the three bullets under it, which all open "Abi
encoding". it in the old tail bound to abi.encode; with a sentence boundary
now in front of it the referent is named rather than pronominalised.

Nothing else in the block moves, nothing is added to the README, and the
cross-type collision list under "Across types nothing is unambiguous" in the
README is untouched: it enumerates what THIS pattern collides on, not what
abi.encode does, so it is not a second copy of this example.

Verification

Not taken from the removed prose. Re-derived with cast abi-encode at
foundry 1.7.2-nightly (43923a4), the version in the repo's own dev shell:

value encoding
uint8(1) 0x0000000000000000000000000000000000000000000000000000000000000001
uint256(1) 0x0000000000000000000000000000000000000000000000000000000000000001
true 0x0000000000000000000000000000000000000000000000000000000000000001
address(1) 0x0000000000000000000000000000000000000000000000000000000000000001

Four identical words. The claim the NatSpec makes above them is exactly what
this shows.

QA

  • Discriminating tests: n/a - the diff is five /// lines in one title block.
    NatSpec is not compiled into behaviour, so no observable value can differ
    between base and branch, and git diff --name-only main is exactly
    src/lib/LibHashNoAlloc.sol. Inertness shown rather than asserted: the suite
    is 77 passed / 0 failed / 0 skipped across 9 suites on main and identical
    here.
  • Mutations applied: n/a - no executable line changed, so there is no line to
    mutate. The mutation-equivalent for added prose is whether the addition can be
    false: it is a statement about four specific abi.encode outputs, and it was
    checked against the encoder rather than against the text it was recovered
    from. Had the removed prose been wrong, the table above would have caught it.
  • Oracle: cast abi-encode for the four values, and src/lib/LibHashNoAlloc.sol
    read as a whole for placement, rather than [RLH-10] Cut the README's copy of the abi.encode argument #113's summary of what it says.
  • Category check: the ruling asks for (a) the counterexample in the NatSpec,
    (b) beside the claim it illustrates rather than appended to the block, (c) the
    four values verified with cast abi-encode rather than trusted from the
    removed prose, (d) no /// line referencing the README, no trailing-underscore
    identifiers, comments carrying only what code and git cannot show. Covered:
    (a) src L23-27; (b) it lands as the demonstration clause of the sentence that
    makes the claim, with the sentence's other two predicates intact; (c) the
    table above; (d) no README reference added, no identifier changed at all, and
    the addition earns its place because the claim above it is abstract without
    it.

Suite: 77 passed / 0 failed / 0 skipped across 9 suites. forge build clean,
forge lint -D warnings clean, forge fmt --check clean, pre-commit run --all-files passes and rewrites nothing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN

#113 cut the README's copy of the abi.encode argument and, with it, the one
concrete thing in that copy: abi.encode of uint8(1), uint256(1), true and
address(1) is the same 32 bytes in every case. The claim it illustrates, that
abi.encode is not injective across types, survived in the LibHashNoAlloc title
block without it, where the claim reads as an assertion rather than a
demonstration.

The four encodings are re-verified with cast abi-encode at foundry 1.7.2: each
is 0x00...01, one word.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
@coderabbitai

coderabbitai Bot commented Sep 16, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 11 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: a9fbfaba-49ed-41af-9fa0-22cadc5e8727

📥 Commits

Reviewing files that changed from the base of the PR and between 6afa299 and d6b68d3.

📒 Files selected for processing (1)
  • src/lib/LibHashNoAlloc.sol

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@thedavidmeister
thedavidmeister merged commit 092293e into main Sep 16, 2026
4 checks passed
thedavidmeister pushed a commit that referenced this pull request Sep 16, 2026
#114 landed on main after the record was written. It changes only /// lines in
LibHashNoAlloc, so no mutated line moved, but "src/ and test/ are byte-identical
to the scanned commit" is no longer literally true and the note now says what is.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
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