docs: checkCodeHash's rationale counts three entry points, not two - #121
Conversation
`checkCodeHash`'s NatSpec said "Both entry points check" and closed on "the two cannot drift into checking different things". All three of the library's entry points call it: `applied`, `head` and `applyMigration`. "Both" was also load-bearing in the sentence's own argument, enumerating a read and a write to justify one shared function. That flattened two distinct readers with distinct failure modes: `applied` answers a timestamp, `head` answers a value that can never legitimately be zero — which the file already documents separately in `head`'s own NatSpec. The rationale now enumerates all three entry points with the failure each would have against unknown code, and names why the guard is one function rather than a rule to remember at each call site. Comment only. No source, test, ABI or bytecode change. Closes #53 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 12 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
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. Comment |
|
Reviewed 187c8f6: ready — Closes #53. Comment-only, and I checked the count against the source rather than the PR body: The replacement names what each one would do wrong against unknown code, individually and correctly — CI green (rainix static/legal/test), 0 unresolved threads — vacuous rather than clean, since the CodeRabbit check reports |
Closes #53
What was wrong
checkCodeHash's NatSpec insrc/lib/LibMigrationRegistry.soldescribed its owncoverage as "Both entry points check" and closed on "the two cannot drift into
checking different things". The library has three entry points and all three call
it —
applied,headandapplyMigration.The count reads as left over from a version with one reader and one writer. In a
repo where the comment is the specification and the correctness of a guard is
argued from it, a doc that miscounts what it covers is the failure mode that lets
a fourth entry point be added later without anyone noticing the sentence stopped
describing the file.
The word "both" was also load-bearing in the sentence's own argument: it
enumerated a read and a write to justify one shared function, which flattened two
distinct readers with distinct failure modes.
appliedanswers a timestamp;headanswers a value that can never legitimately be zero — a failure modeneither of the two enumerated cases described, and one the file already documents
separately in
head's own NatSpec.What changed
Comment only. No source, no test, no ABI, no bytecode change.
The rationale now enumerates all three entry points with the failure each one
would have against unknown code, and states the drift argument over three rather
than two. It also names why the guard is one function rather than a rule at each
call site, so an entry point added later has one place to call.
Verification
forge fmt --check— passes.forge build— passes.checkCodeHashis defined at line 93 andcalled at exactly three sites —
applied(122),head(139),applyMigration(168).grep -rn checkCodeHash --include=*.solreturns thedefinition plus those three and nothing else.
claims are accurate as written and were left alone:
script/Build.solhasexactly two external entry points (
run,cutRelease), andMigrationRegistry.head's "the two" refers to a reader andapplyMigration,not to a call count. The miscount was isolated to this one block.
applied,headandapplyMigrationin the same file but does not touch thisblock. The wording here is framed on "unknown code" throughout, which stays
consistent with the sharpened rationale that PR lands — under it, a value that
is not a head is what occupying code returns, which is what this text says.
No test can cover comment text, so there is no test to add.
QA
src/lib/LibMigrationRegistry.sol. Solidity comments are not compiled, so no test can observe the change and none can be written that fails on base. The existing coverage of the code the comment describes was run and is green:LibMigrationRegistryTest(23),MigrationRegistryAppliedTest(11),MigrationRegistryHeadTest(9),MigrationRegistryApplyMigrationTest(25) — 68 passed, 0 failed.///comment;git difftouches nothing else.checkCodeHashis defined atsrc/lib/LibMigrationRegistry.sol:93andgrep -rn "checkCodeHash" --include=*.sol .returns exactly that definition plus three call sites —applied(122),head(139),applyMigration(168). Three, not the "both"/"two" the comment claimed. The per-entry-point failure modes now enumerated come from each function's own NatSpec and signature, not from the sentence being corrected:appliedreturns auint256timestamp, andhead's NatSpec (131-135) already states that zero is the one value a head can never hold.checkCodeHashrationale at lines 88-92 miscounting its own coverage — and that is fixed. Category swept rather than treating the cited line as exhaustive:grep -rn -iE "both entry|two entry|the two |entry point|three entry"over all*.soland*.mdfound two other entry-point count claims, both verified accurate and deliberately left alone —script/Build.solhas exactly two external entry points (run()at 96,cutRelease()at 114), andMigrationRegistry.sol:158's "the two" refers to a reader andapplyMigration, not to a call count. The miscount was isolated to this one block.Checks run
forge fmt --check— exit 0.forge build— exit 0.forge test --match-path "test/src/{lib,concrete}/*Migration*"— 68 passed, 0 failed.forge test --match-path "test/src/lib/*Snapshot*"— 25 passed, 0 failed. Run deliberately: this repo pins deployed addresses and code hashes, and these assert the generated snapshot shape and pins, so they are what would catch a comment edit somehow moving pinned bytecode. Nothing moved (bytecode_hash = "none",cbor_metadata = false).forge test— the only failures are 42 fork tests, allvm.createSelectFork: environment variable <NETWORK>_RPC_URL not found, from a fresh clone with no gitignored.env. EveryFAILline in the run names an_RPC_URL(42 of 42); there are zero failures of any other class. CI supplies these via rainix's rpc-preflight.