Skip to content

test: pin sourceCount(hex"00") == 0 explicitly - #118

Merged
thedavidmeister merged 1 commit into
mainfrom
2026-07-19-issue-115-sourcecount-zero-byte-pin
Jul 29, 2026
Merged

test: pin sourceCount(hex"00") == 0 explicitly#118
thedavidmeister merged 1 commit into
mainfrom
2026-07-19-issue-115-sourcecount-zero-byte-pin

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Closes #115

Summary

LibBytecode.sourceCount's NatSpec documents that 0x and 0x00 are equivalent, both having 0 sources. The empty case is pinned by testSourceCount0, but the single-byte hex"00" case was only covered incidentally by fuzzing (testSourceCount1 / testSourceCountReference include it in their input domain without naming it). This adds the dedicated, deterministic pin the issue asks for:

function testSourceCountSingleZeroByte() external pure {
    assertEq(LibBytecode.sourceCount(hex"00"), 0);
}

Test-only change; no source or bytecode is touched.

QA

  • Baseline: forge test --mc LibBytecodeSourceCountTest green on unmutated main-based branch — 4 passed / 0 failed (2048 fuzz runs each for the two fuzz tests).
  • Discriminating test, mutation-validated: mutating the covered line count := byte(0, mload(add(bytecode, 0x20)))add(1, byte(...)) fails the new test with assertion failed: 1 != 0; restoring the source returns the suite to 4/4 green.
  • Mutation matrix for the unit (whole-suite judgment):
    • empty → 0: mutant return 0return 1 killed by existing testSourceCount0 + testSourceCountReference (existing coverage validated).
    • first byte is the count: mutant add(1, byte(0, …)) killed by the new testSourceCountSingleZeroByte and testSourceCount1.
    • reads byte 0 specifically: mutant byte(0, …)byte(1, …) killed by existing testSourceCount1 + testSourceCountReference.
  • Adversarial pass: intent derived from the NatSpec oracle (empty → 0; else first byte = count; 0x0x00; integrity of sources explicitly NOT checked). Implementation matches on all points; the byte(0, …) read extracts only the first data byte, which exists for any length ≥ 1, and the differential fuzz against LibBytecodeSlow.sourceCountSlow guards the read shape. No candidate bugs; no scope beyond the named gap.
  • Oracle independence: the expected value (0) comes from the documented equivalence, not from the code's output.
  • Category check: issue test(LibBytecode): pin the documented sourceCount(hex"00") == 0 invariant explicitly #115 asks for exactly this one named assertion; fully covered, hence Closes.
  • forge fmt --check clean on the changed file.

Co-Authored-By: Claude noreply@anthropic.com

The NatSpec on LibBytecode.sourceCount documents 0x and 0x00 as equivalent,
both having 0 sources. testSourceCount0 pins the empty case; this adds the
named single-zero-byte pin so the documented equivalence has a dedicated,
deterministic assertion rather than only incidental fuzz coverage.

Closes #115

Co-Authored-By: Claude <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jul 19, 2026
@coderabbitai

coderabbitai Bot commented Jul 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@thedavidmeister, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 92d6f929-225b-445a-a995-51abf550ef64

📥 Commits

Reviewing files that changed from the base of the PR and between a0974b0 and 36c3b0d.

📒 Files selected for processing (1)
  • test/src/lib/bytecode/LibBytecode.sourceCount.t.sol
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-07-19-issue-115-sourcecount-zero-byte-pin

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 added the ai:ready AI vetter: passes review, ready for human decision label Jul 19, 2026
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

🤖 ai:vetter
Reviewed 36c3b0d: ready — closes #115 — exactly the named deterministic pin the issue asks for; QA block in body with mutation matrix (add-1 mutant killed by the new test), oracle from NatSpec equivalence; test-only
cost 45 — one-line deterministic test pin

@thedavidmeister

Copy link
Copy Markdown
Contributor Author

Reviewed 36c3b0d: ready — merging on the human's word.

mergeStateStatus CLEAN at this exact head, all four checks green (rainix-sol legal/static/test, CodeRabbit), and the vetter's ready verdict is pinned to this same sha so its reasoning still describes this code. No deploy-before-merge gate.

CodeRabbit reads Review completed here — real coverage rather than the rate-limited green most PRs carry while the org plan quota is exhausted — so the 0 unresolved threads is a clean count rather than a vacuous one.

@thedavidmeister
thedavidmeister merged commit 59e4e57 into main Jul 29, 2026
4 checks passed
@github-actions

Copy link
Copy Markdown

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ready AI vetter: passes review, ready for human decision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(LibBytecode): pin the documented sourceCount(hex"00") == 0 invariant explicitly

1 participant