Skip to content

feat(analysis): evaluate exactly resolvable match guards (RIPR-SPEC-0164 guard-arm) - #10414

Merged
EffortlessSteven merged 4 commits into
mainfrom
fix/rust-match-guard-eval
Oct 25, 2026
Merged

EffortlessSteven merged 4 commits into
mainfrom
fix/rust-match-guard-eval

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Problem

Lane of #10304 (RIPR-SPEC-0164). The literal match-arm transfer refused any arm with an if guard, so a helper like label_guard(kind) with arm "word" if kind.len() > 2 => "alpha" left the caller-side boundary input unresolved (infection_unknown) even though the corpus row's runtime truth says the pinned test discriminates. spec-b-0164-guard-arm sat at truth: discriminated / outcome: abstained.

Change

analysis/classify/match_transfer.rs: an arm may now carry an if <expr> guard. split_guard separates the guard at if outside string/char literals; evaluate_guard evaluates it fail-closed over the exact bound inputs — one comparison whose operands each resolve through the shared #3295 evaluator (strings, chars, booleans, plain decimals) or str::len() (Rust byte length) on an exact string. Ordering comparisons are exact for indices only; equality for every scalar. Selection requires pattern match AND guard true (false falls through in source order); an unevaluable guard refuses the whole match, preserving the all-or-nothing Required shape.

Governing issue or accepted claim: #10304 (guard-arm lane; spec-b-0164-guard-arm).

Acceptance delta (one sentence): the guard-arm corpus row flips from abstained/limited to credited/exposed and the Rust missed-credit ceiling ratchets 143 -> 142, with the match_arm_controls guard-variant probe moving infection_unknown -> weakly_exposed (bare-identifier variant stays fail-closed).

Evidence

  • Full Rust verdict corpus green on the combined tree: 668 cases, false verdicts at baseline 3/668; only the intended row moved (blessed).
  • committed_ceilings_equal_the_blessed_missed_credit passes locally (ceiling 142 exact).
  • goldens check green after re-blessing match_arm_controls with a spec-cited reason (RIPR-SPEC-0164).
  • check-spec-format and check-spec-numbering pass.
  • Production lib typechecks clean (cargo check -p ripr --lib); the lib-test crate cannot link within a 300 s local window, so unit tests execute on hosted CI.

Spec and docs

Rollback

Revert the single commit; the blessed corpus row, golden, and ceiling line restore with it.

Non-goals

  • Bare-binding arms (spec Required + Example ci(routed-rust): add Ripr Rust Small routed result #4 pin refusal; needs a reviewed spec amendment first).
  • Boolean combinators, chained comparisons, or method calls beyond str::len() in guards.
  • The 0165 trio (nested/recursive helper evaluation bounds).

Devin Review

@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 36 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 181 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: a7bee58b-fe20-4ed0-b0fa-6f83b6bc4cdc
Commits

Reviewing files that changed from the base of the PR and between 2e954f8 and 9e6f485.

Files selected for processing: 10
  • changelog.d/rust-match-guard-evaluation.md
  • crates/ripr/src/analysis/classify/match_transfer.rs
  • docs/specs/RIPR-SPEC-0164-literal-match-arm-transfer.md
  • fixtures/match_arm_controls/expected/CHANGELOG.md
  • fixtures/match_arm_controls/expected/check.json
  • fixtures/match_arm_controls/expected/human.txt
  • fixtures/python_caplog_builtin_beside_fixtures/expected/CHANGELOG.md
  • fixtures/python_caplog_renamed_fixture/expected/CHANGELOG.md
  • fixtures/rust-verdict-corpus/expected/rows/spec-b-0164-guard-arm.json
  • fixtures/rust-verdict-corpus/missed-credit.toml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown
Contributor

merge-ready was requested, but this PR conflicts with main (head 9a1fd0fd), so GitHub creates no test-merge ref and no qualification run can start. Merge main into the branch and resolve the conflicts, then remove and re-apply merge-ready.

@github-actions

Copy link
Copy Markdown
Contributor

merge-ready was requested, but this PR conflicts with main (head 851eeb71), so GitHub creates no test-merge ref and no qualification run can start. Merge main into the branch and resolve the conflicts, then remove and re-apply merge-ready.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 3 potential issues.

Devin Review

@github-actions

Copy link
Copy Markdown
Contributor

merge-ready is set, but this PR conflicts with main (head 50334749), so GitHub creates no test-merge ref and no qualification run can start. Merge main into the branch and resolve the conflicts, then remove and re-apply merge-ready.

@github-actions

Copy link
Copy Markdown
Contributor

merge-ready is set, but this PR conflicts with main (head 8a3db6ca), so GitHub creates no test-merge ref and no qualification run can start. Merge main into the branch and resolve the conflicts, then remove and re-apply merge-ready.

@EffortlessSteven
EffortlessSteven force-pushed the fix/rust-match-guard-eval branch from 8a3db6c to 4762e45 Compare October 25, 2026 19:22
@EffortlessSteven
EffortlessSteven force-pushed the fix/rust-match-guard-eval branch from 4762e45 to f9a7081 Compare October 25, 2026 19:52
EffortlessSteven added a commit that referenced this pull request Oct 25, 2026
…ay exactly resolvable

Devin review on #10414: `if (kind.len() > 2)` left parens attached to
the operands, downgrading a resolvable match to unknown. Strip balanced
outer parens around the whole guard (repeatedly) and around each
operand, honoring quotes; unbalanced input stays fail-closed. Also
update the module overview, which still claimed every guard refuses.

Co-authored-by: Claude <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

merge-ready was requested, but this PR conflicts with main (head e4ef7306), so GitHub creates no test-merge ref and no qualification run can start. Merge main into the branch and resolve the conflicts, then remove and re-apply merge-ready.

EffortlessSteven and others added 3 commits October 25, 2026 17:02
A match arm guard now selects the arm when it evaluates to true over
the exact bound inputs and falls through when false, exactly like the
Rust match. The guard evaluator is fail-closed: one comparison whose
operands each resolve through the shared #3295 evaluator (strings,
chars, booleans, plain decimals) or str::len() on an exact string;
ordering comparisons are exact for indices only, equality for every
scalar. Anything else — boolean combinators, unsupported method
calls, unknown operands, mixed types — refuses the whole match rather
than guessing.

Earns the spec-b-0164-guard-arm corpus row (RIPR-SPEC-0164; lane of
match_arm_controls guard-variant probe moves infection_unknown ->
weakly_exposed, mirroring the #10196 literal-callee/char moves; the
bare-identifier variant stays fail-closed. Spec Behavior, Example #2,
controls-fixture note and Non-Goals updated; guards remain a named
limitation only in their unevaluable forms.

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
 wording

Inherited combined-tree drift: #10444's caplog-override analysis change
interacts with #10426's evidence-legend wording. The match-guard lane
cannot affect these fixtures (no match arms in their inputs); carrying
the re-bless so the merge gate sees a clean tree.

Co-authored-by: Claude <noreply@anthropic.com>
@EffortlessSteven
EffortlessSteven force-pushed the fix/rust-match-guard-eval branch from e4ef730 to 552f9a0 Compare October 25, 2026 21:12
EffortlessSteven added a commit that referenced this pull request Oct 25, 2026
…ay exactly resolvable

Devin review on #10414: `if (kind.len() > 2)` left parens attached to
the operands, downgrading a resolvable match to unknown. Strip balanced
outer parens around the whole guard (repeatedly) and around each
operand, honoring quotes; unbalanced input stays fail-closed. Also
update the module overview, which still claimed every guard refuses.

Co-authored-by: Claude <noreply@anthropic.com>
…ay exactly resolvable

Devin review on #10414: `if (kind.len() > 2)` left parens attached to
the operands, downgrading a resolvable match to unknown. Strip balanced
outer parens around the whole guard (repeatedly) and around each
operand, honoring quotes; unbalanced input stays fail-closed. Also
update the module overview, which still claimed every guard refuses.

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant