Skip to content

test: pin mask constants by re-derivation, lone-high-bit case, relative src import#30

Open
thedavidmeister wants to merge 1 commit into
mainfrom
2026-07-18-test-hardening
Open

test: pin mask constants by re-derivation, lone-high-bit case, relative src import#30
thedavidmeister wants to merge 1 commit into
mainfrom
2026-07-18-test-hardening

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Closes #24
Closes #25
Closes #26

Three test-suite hardening items in one file-clustered PR:

Also appends the audit/mutation-test-scans.json scan record for this pass.

QA

  • Discriminating tests: testMaskConstantsRederived (exact-value assertion per constant, loop-derived — not code-mirroring) and testCtPopLoneHighBit (exact count 1), both added in this PR; full suite 8/8 green on the unmutated baseline (nix develop github:rainlanguage/rainix#sol-shell -c forge test).
  • Mutations applied (restore-verified after each):
    • CTPOP_M1 low nibble …55…54testMaskConstantsRederived FAILS with the exact corrupted value (deterministic kill); the fuzz/mutual-check tests also fail probabilistically because ctpop and ctpopSlow consume M1 through different formulas — the new pin makes the kill deterministic and value-level for all 9 constants, including M8–M128 which only ctpopSlow reads.
    • ctpop final shift >> 248>> 240testCtPopLoneHighBit FAILS (1 != 256), plus 4 pre-existing tests.
    • Restored → 8/8 PASS, clean tree.
  • Oracle: Hamming-weight definition (the file's own Wikipedia reference) — the expected mask patterns (width set bits alternating with width clear, byte-wise 0x01 for H01) and the lone-high-bit count of 1 are derived from the definition, independent of the constants under test.
  • Category check: [test-bare-src-import] [LOW] Test uses a bare src/ import (breaks when consumed as a soldeer dependency) #24 names the one bare src/ import in the repo's only test file (fixed); [unpinned-masks-shared-constant-blindspot] [LOW] Mask constants have no direct test pin; ctpop/ctpopSlow share M1/M2/M4 #25 asks for direct pins on the shared mask constants (all 9 pinned); [no-single-high-bit-test] [INFO] No deterministic lone-high-bit (1<<255) test #26 asks for the deterministic lone-high-bit case (added). Adversarial pass on the unit found no candidate bugs: the type(uint256).max special case is correct (the SWAR byte-sum overflows at count 256, which is exactly the excluded case).

🤖 Generated with Claude Code

…e relative src import

Each CTPOP mask constant is asserted against an independently loop-built
value so a corrupted constant cannot hide behind ctpop and ctpopSlow
sharing it; a deterministic 1<<255 case pins the top of the range; the
test imports src via a relative path so the suite survives consumption
as a soldeer dependency. Appends the adversarial-mutation-test scan
record.

Closes #24
Closes #25
Closes #26

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

coderabbitai Bot commented Jul 18, 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: 24 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 917394a6-9979-472c-9bee-42a2e6f87091

📥 Commits

Reviewing files that changed from the base of the PR and between 208336a and 5846438.

📒 Files selected for processing (2)
  • audit/mutation-test-scans.json
  • test/src/lib/LibCtPop.ctpop.t.sol
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-07-18-test-hardening

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 18, 2026
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

🤖 ai:vetter
Reviewed 5846438: ready — closes #24 #25 #26 — relative src import, all 9 mask constants pinned by independent loop re-derivation, deterministic lone-high-bit test; assertions hand-verified, mutation claims spot-checked
cost 212 — loop-derived mask pins, verify altMask math

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

1 participant