Skip to content

Mutation coverage: IMPL-div-extremes - #446

Merged
thedavidmeister merged 3 commits into
mainfrom
mutation-IMPL-div-extremes
Oct 12, 2026
Merged

thedavidmeister merged 3 commits into
mainfrom
mutation-IMPL-div-extremes

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Mutation campaign over the extreme branches of LibDecimalFloatImplementation.div at 886ca07: the exponentA floor clamp, the exponentB transfer, underflowExponentBy, the ExponentOverflow mirror, the 2^255 quotient revert, and the u > 76 and quotient-zero returns. 27 mutants, probed with mutation-probe against LibDecimalFloatImplementationDivTest, LibDecimalFloatImplementationMainEquivalenceTest and LibDecimalFloatDivTest.

Before this PR: 24 killed and 3 survived. All 3 survivors are equivalent:

  • M06 and M08 change the spill-overflow return. On that path exponentA is type(int256).min, so any exponentB above 76 gives u > 76 and the result is (0, 0) anyway.
  • M24 moves the zero-return threshold from u > 76 to u > 77. At u = 77, 10^77 < 2^256 and |q| <= 2^255 < 1e77, so q / 10^77 is 0 and the quotient-zero return gives (0, 0).

Changes:

  • testMainEquivalenceDivFloorExamples failed with MemoryOOG on unmodified 886ca07. It is also red in main's rainix-sol run 38170850977. Memory grew across the 76 test: equivalence-only coverage for implementation div, add, sub and inv #368 sheds in one call frame. Each shed now runs in its own external call, so the test passes at 184M gas and covers the u = 1..76 sheds deterministically again. It now kills M23 and M25.
  • Before this PR, only the testDivByOneAtFloor fuzz run killed the signedCoefficientA == type(int256).min conjunct of the 2^255 revert (M18). The new testDivNegativePowerOfTenDivisorAtMax kills it deterministically. Expected values: 1e76 10^(max-76) / (-1 10^-76) is exactly -1e76 10^max, and the same holds for the other signs and for type(int256).max.

Adversarial pass: a grid of 14 coefficients by 17 exponents for each operand, 56644 cases at the int256 extremes, compared against LibExactFloat.divPartsWide and isTruncatedQuotient. Every case matched. No bug candidates.

QA

Discriminating tests: testDivNegativePowerOfTenDivisorAtMax (kills M18 deterministically); testMainEquivalenceDivFloorExamples, repaired from MemoryOOG (kills M23 and M25)
Mutations applied: 27 mutants via mutation-probe, with forge test --mc limited to the three listed contracts. Pre-existing suite: 24 killed, 3 equivalent (M06, M08, M24). After this PR: M18, M23 and M25 are also killed by the tests above.
Oracle: exact maths of the NatSpec rule (a / b truncated toward zero at 10^(ua - lb), floor shed, 2^255 shed, ExponentOverflow above int256.max), as encoded by test/lib/LibExactFloat.sol and by the fixed examples' exact products
Category check: test-only. No src changes. One baseline-broken test repaired without weakening its assertions.

🤖 Generated with Claude Code

baku-ccron and others added 2 commits October 11, 2026 20:33
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- testMainEquivalenceDivFloorExamples ran out of memory (MemoryOOG) at
  886ca07: the 76 #368 sheds now each run in their own call frame.
- testDivNegativePowerOfTenDivisorAtMax pins that only a type(int256).min
  dividend has the 2^255 quotient at exponent type(int256).max; that
  conjunct was only killed by fuzz luck before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

Next included review available in 50 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: d228a6bd-c9b8-495b-affd-40c83bc5d70c

📥 Commits

Reviewing files that changed from the base of the PR and between cfa33af and baa09cc.


📒 Files selected for processing (2)
  • test/src/lib/implementation/LibDecimalFloatImplementation.div.t.sol
  • test/src/lib/implementation/LibDecimalFloatImplementation.mainEquivalence.t.sol

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@thedavidmeister
thedavidmeister merged commit c00b355 into main Oct 12, 2026
7 of 8 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

@linear

linear Bot commented Oct 12, 2026

Copy link
Copy Markdown

RAI-3237

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