Skip to content

test: mutation-harden LibOpConditions coverage#536

Open
thedavidmeister wants to merge 4 commits into
mainfrom
2026-06-15-libop-coverage
Open

test: mutation-harden LibOpConditions coverage#536
thedavidmeister wants to merge 4 commits into
mainfrom
2026-06-15-libop-coverage

Conversation

@thedavidmeister

Copy link
Copy Markdown
Contributor

Summary

Scoped adversarial mutation-testing pass on LibOpConditions (src/lib/op/logic/LibOpConditions.sol). Tests-only; no source changes. git diff src/ is empty.

LibOpConditions returns the value of the first nonzero condition in a pairwise condition/value list; if the input count is odd the trailing input is an error-reason string used when no condition is met. Its run has subtle odd/even handling (loop range, output placement, reason read, and a no-match revert).

Mutation matrix

Mutated each behavior in LibOpConditions.sol, ran LibOpConditionsTest, recorded SURVIVED/KILLED, restored after each.

# Mutation Before After
I1 integrity min-inputs floor KILLED KILLED
I2 integrity > 2 boundary KILLED KILLED
R1 oddInputs := mod(inputs, 2)mod(inputs, 3) KILLED KILLED
R2 end calc drops oddInputs (includes reason slot in loop) SURVIVED KILLED
R3 odd-input output placement sub(end, iszero(odd)*0x20)sub(end, 0x20) SURVIVED KILLED
R4 output placement → end KILLED KILLED
R5 reason read mload(end)mload(cursor) KILLED KILLED
R6 store condition instead of value KILLED KILLED
R7 pairwise stride +0x40+0x20 KILLED KILLED
R8 condition test !isZeroisZero KILLED KILLED
R9 remove no-match revert guard (if (conditionIsZero)if (false)) SURVIVED KILLED

8/11 killed by the existing suite. The three survivors all hid in the odd-input (reason-carrying) paths:

  • The reference-check fuzz test (testOpConditionsRun) truncates odd inputs to even, so the odd-input success path was never asserted — R2 and R3 hid there.
  • The no-match revert tests route through opReferenceCheck, whose reference implementation also reverts, masking a missing revert in run itself — R9 hid there.

New tests (all pass clean on baseline; each fails under its target mutant)

  • testOpConditionsEval3InputsTrueOddReason / testOpConditionsEval5InputsSecondTrueOddReason — eval of conditions with an odd input count where a condition is met; assert the matched value, trailing reason ignored. (kills R2)
  • testOpConditionsRunOddMatchStackTopPlacement — direct run() call asserting the output stack-top pointer (words consumed), not just the value, for an odd-input match. (kills R3)
  • testOpConditionsRunRevertsNoMatchEven / testOpConditionsRunRevertsNoMatchOddReason — call run() in isolation (new runExternal wrapper, no reference fn) and assert it reverts with the correct reason (empty for even, trailing reason for odd). (kills R9)

Remaining-gaps checklist

  • integrity in/out counts (fuzzed, existing)
  • run-vs-reference value (fuzzed, existing) + odd-input success value (new)
  • pairwise stride / condition test / value-vs-condition store (existing)
  • odd-input loop range and output placement (new)
  • no-condition-met revert, isolated from the reference fn, even + odd reason (new)
  • bad inputs / bad outputs / operand-disallowed (existing)

Verification

  • forge build: Compiler run successful (the boolean-cst lint warnings are pre-existing, unrelated to this diff).
  • forge fmt --check on the test file: clean.
  • LibOpConditionsTest: 20 passed, 0 failed.
  • Full logic-op suite subset (test/src/lib/op/logic/*): 181 passed, 0 failed.
  • No .gas-snapshot change (no new opcode / bytecode change), so no regen needed.

Conflict-avoidance with #535

Touches only test/src/lib/op/logic/LibOpConditions.t.sol. No overlap with #535's files (LibAllStandardOps.sol, LibOpPi.sol, src/generated/*.pointers.sol, parse-meta, LibOpE/LibOpPi). No .gas-snapshot edit.

🤖 Generated with Claude Code

Adversarial mutation testing of LibOpConditions surfaced three surviving
mutants, all in the odd-input (reason-carrying) code paths:

- end calc that ignores oddInputs (reason slot included in the loop range)
- output placement for odd inputs (sub(end, 0x20) instead of end)
- removal of the no-condition-met revert guard

The existing reference-check fuzz test truncates odd inputs to even, so the
odd-input success path was never asserted, and the no-condition-met revert was
masked by the reference implementation's own revert.

Add discriminating tests:
- eval of conditions with an odd number of inputs where a condition is met,
  asserting the matched value (3-input and 5-input cases)
- a direct run() call asserting the output stack-top placement for an odd-input
  match (pointer, not just value)
- direct run() revert tests (isolated from the reference implementation) for
  the no-condition-met case, both even (empty reason) and odd (trailing reason)

Tests-only; no source changes. All three mutants are now killed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@thedavidmeister thedavidmeister self-assigned this Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

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

More reviews will be available in 45 minutes and 40 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

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 credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

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, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a04c1ced-2963-46ef-94e2-bd058b2f35bb

📥 Commits

Reviewing files that changed from the base of the PR and between b3d5081 and 40e88cf.

📒 Files selected for processing (37)
  • test/src/abstract/BaseRainlangExtern.construction.t.sol
  • test/src/abstract/BaseRainlangExtern.ierc165.t.sol
  • test/src/abstract/BaseRainlangExtern.integrityOpcodeRange.t.sol
  • test/src/abstract/BaseRainlangSubParser.ierc165.t.sol
  • test/src/abstract/BaseRainlangSubParser.subParseLiteral2.t.sol
  • test/src/abstract/BaseRainlangSubParser.subParseWord2.t.sol
  • test/src/abstract/ChildRainlangExtern.sol
  • test/src/abstract/ChildRainlangSubParser.sol
  • test/src/abstract/EmptyPointersExtern.sol
  • test/src/abstract/EmptyWordParsersSubParser.sol
  • test/src/abstract/HappyPathLiteralSubParser.sol
  • test/src/abstract/MismatchedExternMoreIntegrity.sol
  • test/src/abstract/MismatchedExternMoreOpcodes.sol
  • test/src/abstract/MismatchedLiteralSubParser.sol
  • test/src/abstract/MismatchedWordSubParser.sol
  • test/src/abstract/NoMatchLiteralSubParser.sol
  • test/src/abstract/TestableExtern.sol
  • test/src/abstract/TwoOpExtern.sol
  • test/src/concrete/MockExternBadLiteralIndex.sol
  • test/src/concrete/ModifierTestParser.sol
  • test/src/concrete/RainlangInterpreter.zeroFunctionPointers.t.sol
  • test/src/concrete/RainlangParser.parseMemoryOverflow.t.sol
  • test/src/concrete/RainlangReferenceExtern.subParserIndexOutOfBounds.t.sol
  • test/src/concrete/ZeroFPRainlangInterpreter.sol
  • test/src/lib/integrity/IntegrityHighwater.sol
  • test/src/lib/integrity/IntegritySingleOp.sol
  • test/src/lib/integrity/LibIntegrityCheck.t.sol
  • test/src/lib/op/logic/LibOpConditions.t.sol
  • test/src/lib/parse/BadLengthSubParser.sol
  • test/src/lib/parse/ConstantReturningSubParser.sol
  • test/src/lib/parse/ContextReturningSubParser.sol
  • test/src/lib/parse/LibSubParse.badSubParserResult.t.sol
  • test/src/lib/parse/LibSubParse.constantAccumulation.t.sol
  • test/src/lib/parse/LibSubParse.subParseWords.t.sol
  • test/src/lib/parse/MultiConstantSubParser.sol
  • test/src/lib/state/LibInterpreterStateDataContract.t.sol
  • test/src/lib/state/LibInterpreterStateDataContractExtern.sol
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-06-15-libop-coverage

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 and usage tips.

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