Skip to content

feat(analysis): transfer alternative-of-plain-literals match arms exactly - #10311

Closed
EffortlessSteven wants to merge 5 commits into
mainfrom
fix/rust-match-arm-or-transfer
Closed

EffortlessSteven wants to merge 5 commits into
mainfrom
fix/rust-match-arm-or-transfer

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 25, 2026 •

Copy link
Copy Markdown
Member

Problem

First lane of #10304. The bounded literal match-arm transfer (RIPR-SPEC-0164) refused any | alternative pattern, so a helper arm like "word" | "term" => "alpha" left the caller-side boundary input unresolved (infection_unknown) even though the runtime mutant truth for the corpus case says the pinned test discriminates. spec-b-0164-alternative-pattern sat at truth: discriminated / outcome: abstained (one of the 9 rows #10117 measured but did not earn).

Change

analysis/classify/match_transfer.rs: an arm pattern may now be an alternative of plain string literals. The arm matches when ANY constituent equals the scrutinee; first-match source order stays authoritative (an earlier arm shadowing one constituent of a later alternative still wins). Every |-component must pass the same conservative literal_string rule — a guard, binding, path, escape, computed value, or any non-literal component inside the alternative (wildcard, binding, escaped literal) refuses the whole match. Splitting cannot cut inside a literal: a | inside quotes yields fragments that fail the balanced-quote rule, so the arm refuses conservatively rather than mis-parsing.

The fail-closed unit test that pinned "alternative pattern refuses" is split: genuinely unresolved shapes (guard, bare binding, computed call argument, escaped literal) keep their fail-closed pins; the alternative shape gains positive resolution, source-order shadowing, and mixed-alternative refusal tests.

RIPR-SPEC-0164's acceptance example #3 is rewritten from Reject to Accept — the corpus case cites RIPR-SPEC-0164#3, and the example text now describes exactly what the case measures.

Evidence

  • cargo xtask verdict-corpus check --language rust --cases spec-b-0164-alternative-pattern: row drifted exactly as intended (observed_verdict limited → credited, classification infection_unknown → exposed, outcome abstained → ideal); row re-blessed, drift explanation stated here.
  • Full cargo xtask verdict-corpus check --language rust: 653 cases green, false verdicts at the pre-existing 3/653 baseline, zero contradictions.
  • Missed-credit count recomputed independently from the blessed rows: 145 = new ceiling (ratchet lowered 146 → 145 in spec-coverage.toml with a reason comment).
  • cargo xtask check-spec-format and check-spec-numbering: pass.
  • cargo clippy -p ripr --lib --tests -- -D warnings: clean (typechecks the new unit tests; execution rides hosted Rust gates).

Honesty notes

  • The promotion infection_unknown → exposed is warranted here because the corpus row's truth is a runtime mutant kill (tests_failed on the exact pinned test), i.e. the oracle provably observes the changed sink.
  • Non-literal alternatives remain refused — no guessed evidence.

Non-goals

Governing issue or accepted claim: #10304 (the 9 RIPR-SPEC-0164/0165 missed-credit rows), example RIPR-SPEC-0164#3.

Acceptance delta (one sentence): alternative-of-plain-literals match arms now transfer exactly, moving the spec-b-0164-alternative-pattern corpus row from abstained to ideal (exposed) and lowering the rust missed-credit ceiling 146 → 145.


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 17 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 173 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: cc4742a8-e5f3-4c48-b597-39992dd720c5
Commits

Reviewing files that changed from the base of the PR and between 9e2aee7 and 46ba6e3.

Files selected for processing: 5
  • changelog.d/rust-match-arm-or-pattern-transfer.md
  • crates/ripr/src/analysis/classify/match_transfer.rs
  • docs/specs/RIPR-SPEC-0164-literal-match-arm-transfer.md
  • fixtures/rust-verdict-corpus/expected/rows/spec-b-0164-alternative-pattern.json
  • fixtures/rust-verdict-corpus/spec-coverage.toml
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@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 1 potential issue.

Devin Review

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Self-review (author, COMMENT disposition: substantive self-check before merge; not independent review).

Surfaces and risks

  • analysis/classify/match_transfer.rs — the shape parser and evaluator. Risk class: false-positive exposure (crediting a test that cannot observe the change). Mitigation: the shape stays all-or-nothing; every |-component must pass the conservative literal_string rule; a | inside quotes yields unbalanced fragments that refuse, so no mis-parse path; wildcard/binding/escaped components inside an alternative refuse the whole arm (unit-pinned).
  • Spec contract: RIPR-SPEC-0164 example #3 changed Reject → Accept; the corpus case already cites #3 and now matches the example text. check-spec-format and check-spec-numbering pass.

Oracle challenge

  • The promoted row's truth is a runtime mutant kill on the exact pinned test (tests_failed), so exposed is warranted, not a self-confirming static guess.
  • Removal control: the pre-change analyzer scores the same case infection_unknown/limited (observed on main@894d639ac4 before the edit); the flip is attributable to this change, not environment.

Validation

  • verdict-corpus check (full rust, 653 cases) green with zero contradictions; missed-credit count recomputed independently (145) and pinned as the new ceiling.
  • clippy -p ripr --lib --tests -- -D warnings clean; unit-test execution rides the hosted Rust gates.

Residuals

  • The remaining 8 rows of #10304 are separate lanes; ranges/path patterns stay named limitations.

Copy link
Copy Markdown
Member Author

Ownership/integration reconciliation needed before treating this as an independent promotion. At the current heads, existing #10196 (f0148966f4a913da3033acc64503213c8a1443ca, canonical branch claude/project-thread-mtx5uo) already contains the same production mechanism in match_transfer.rs, RIPR-SPEC-0164 example 3, and the exact spec-b-0164-alternative-pattern expected-row promotion that this candidate (12f5d5493a039c2901b8ce8953a6911949716c4a) implements. The expected-row patch is identical. #10196 additionally owns escaped string patterns, char scrutinees and literal-tail helper transfer, with retained negative controls for guards, bindings, ranges/type mismatch, raw-string/early-return and block-comment fabricated values. Its masking repair passed 18 focused checks on reviewed head 73f89d89; that is historical scoped evidence, not clearance of the newer integrated head.

Please reconcile with the existing #10196 owner before further independent promotion: retain one canonical implementation/acceptance record for the overlapping alternative-pattern row, explicitly record any proposed split or replacement and preserve all broader #10196 acceptance and negative controls. No winner, closure, ownership transfer or merge is asserted by this comment. If this PR contributes incremental source-order tests or a materially distinct implementation advantage, identify that delta for the canonical owner rather than counting the row twice.

The #10304 investigation correctly describes its measured main snapshot, but it omits this already-open implementation: four of its listed 0164 rows are claimed by #10196, not unowned work. Please reconcile that plan before assigning further overlapping lanes. The 653-case/145-ceiling and 636-case/140-ceiling figures belong to different recorded bases; they are not additive and do not establish a combined-current-main result. Re-measure the chosen integrated candidate after ownership is reconciled. No new writer, qualification run, branch edit, Ready change, review resolution or merge was performed for this coordination.

@github-actions

Copy link
Copy Markdown
Contributor

merge-ready is set, but this PR conflicts with main (head 12f5d549), 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 ca479c17), 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 added a commit that referenced this pull request Oct 25, 2026
Same check-changelog-fragments rejection class as #10311: 'Improved'
is not a policy section.

Co-authored-by: Claude <noreply@anthropic.com>
@EffortlessSteven
EffortlessSteven force-pushed the fix/rust-match-arm-or-transfer branch from ca479c1 to 60cf509 Compare October 25, 2026 11:06
EffortlessSteven added a commit that referenced this pull request Oct 25, 2026
A pipe inside a string literal is content, not an alternative separator:
"a|b" stays one literal and keeps its exact-match credit instead of
refusing the arm. Devin review on #10311 flagged the regression; a
quote-aware split restores the credit with the same conservative
validation everywhere else. Regression tests pin both the lone
pipe-literal and a pipe inside one alternative.

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 b76303d9), 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 added a commit that referenced this pull request Oct 25, 2026
A pipe inside a string literal is content, not an alternative separator:
"a|b" stays one literal and keeps its exact-match credit instead of
refusing the arm. Devin review on #10311 flagged the regression; a
quote-aware split restores the credit with the same conservative
validation everywhere else. Regression tests pin both the lone
pipe-literal and a pipe inside one alternative.

Co-authored-by: Claude <noreply@anthropic.com>
@EffortlessSteven
EffortlessSteven force-pushed the fix/rust-match-arm-or-transfer branch from b76303d to 857e9cd Compare October 25, 2026 11:39

@github-actions github-actions 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.

Verification questions

  • Confirm the seeded thread reports overlapping production, spec, and corpus changes in #10196, so independent promotion should not proceed without canonical ownership reconciliation.

Refuted

  • The PR description and changelog claim a ceiling of 145, while the changed coverage comment says 148.
  • Splitting a pattern at every pipe could cut a Unicode literal at a byte boundary and cause undefined behavior.; refuted because: The implementation iterates Unicode scalar values and accumulates them in owned String buffers; no byte-index slicing or unsafe pointer arithmetic is used.
  • This change could corrupt evidence while crossing a worker/async/GC/detach/transfer boundary.; refuted because: No such boundary or code path is changed; parsing and arm selection remain synchronous, in-process Rust operations.
  • The PR body claims the missed-credit ceiling changed from 146 to 145, but the changed coverage file states 149 and its comment describes 148.
  • This PR duplicates a canonical implementation already owned by #10196 and therefore should not be independently promoted.; refuted because: That objection concerns branch ownership/integration rather than the changed code's sibling-path correctness; the current diff still needs canonical reconciliation, but no code defect on the RIGHT side was established here.
  • This lane should assess ArrayBuffer/TypedArray resize, detach, transfer, or stale length behavior in the changed production path.; refuted because: The change is entirely Rust string-pattern classification and has no active-view buffer or backing-store surface; the relevant analogous view concern is mutation of the parsed pattern set, which is avoided by immutable parsed arms.
  • The PR's missed-credit baseline is consistently 146 before and 145 after the change.; refuted because: The diff contradicts that premise: the file changes 149 and its comment says 148. This objection therefore still requires reconciliation and is reported as a public finding rather than a failed objection.

Evidence gaps

  • The corpus promotion and coverage-ceiling update depend on execution evidence whose receipt is scheduled but not yet available.
  • The rippr sensor failed with exit code 2, so the changed Rust route lacks a successful compiler/sensor receipt in this packet.
  • The coverage TOML removes the missed_credit_ceiling assignment without replacing it.
  • Model proof intent was rejected by deterministic validation.

EffortlessSteven added a commit that referenced this pull request Oct 25, 2026
…0321)

* fix(output): nest the context packet witness at the packet indent

The witness is a serde-owned DTO that rendered through
serde_json::to_string (compact), so  showed the whole
witness as one long line inside an otherwise expanded pretty-printed
packet — the worst-read field in the drill-down output for humans.
Render it with to_string_pretty and re-indent to the packet's
two-space base, matching the hand-rendered fields around it.

Whitespace-only change: the wire value is untouched (packet version
contract stays 1.1), and a unit test pins both the nested shape and
the JSON round-trip. Verified end-to-end against a real probe.

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

* docs(changelog): use the valid 'Changed' fragment section

Same check-changelog-fragments rejection class as #10311: 'Improved'
is not a policy section.

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

* changelog: name PR #10321 in the context witness fragment

check-changelog-fragments requires every entry to cite an issue or PR.

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

---------

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

@github-actions github-actions 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.

Confirmed findings

  • The coverage edit documents a ceiling of 148 but deletes the missed_credit_ceiling assignment, so the TOML table no longer declares the value required by the PR's stated 146 → 145 reduction.

Refuted

  • The alternative implementation duplicates an already accepted canonical change in #10196.; refuted because: The duplication concern is real but is an integration/ownership blocker rather than a defect local to the changed RIGHT-side lines; it is parked for maintainer reconciliation rather than duplicated as an inline finding.
  • Splitting at every pipe could corrupt a Unicode literal or cause undefined behavior.; refuted because: The implementation iterates Unicode scalar values and accumulates owned Strings without byte slicing or unsafe operations; quote-aware splitting also preserves pipes inside literals.
  • The production change needs parallel expansion into sibling pattern helpers to avoid incomplete transfer.; refuted because: The seeded scope and specification explicitly define this slice as plain-string alternatives only; other pattern families remain named limitations, so broadening them would expand risk rather than satisfy the current acceptance delta.
  • The change could introduce an ownership or aliasing hazard across an unsafe/native boundary.; refuted because: The touched path is safe, synchronous Rust code that creates and consumes owned Strings and Vec; no raw pointer, reference lifetime, shared mutation, thread, async, FFI, or unsafe boundary is added or changed.
  • The changed coverage file appears to omit the ratchet assignment after updating its explanatory comment.
  • The change could split a literal at a byte boundary and create an undefined-behavior-prone active view.; refuted because: The implementation iterates Unicode scalar values and accumulates owned String buffers; it performs no byte-index slicing, raw pointer arithmetic, or unsafe access.

Evidence gaps

  • The available packet lacks the late cargo-test receipt and does not independently attest the claimed full corpus execution.
  • The corpus promotion still depends on successful late cargo-test execution because the ripr sensor receipt failed.
  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • Other pattern classes such as ranges, paths, non-string scrutinees, and mixed alternatives containing bindings, wildcards, or escapes remain outside this lane rather than being broadened here.
  • This PR overlaps #10196's production, specification, and corpus promotion, so retaining two canonical implementations would create conflicting ownership and acceptance records.

@github-actions

Copy link
Copy Markdown
Contributor

merge-ready is set, but this PR conflicts with main (head 73ff734d), 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 4e79112b), 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-arm-or-transfer branch from 4e79112 to 8cbc237 Compare October 25, 2026 13:21
EffortlessSteven added a commit that referenced this pull request Oct 25, 2026
A pipe inside a string literal is content, not an alternative separator:
"a|b" stays one literal and keeps its exact-match credit instead of
refusing the arm. Devin review on #10311 flagged the regression; a
quote-aware split restores the credit with the same conservative
validation everywhere else. Regression tests pin both the lone
pipe-literal and a pipe inside one alternative.

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 8cbc2377), 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 5 commits October 25, 2026 09:24
…ctly

RIPR-SPEC-0164#3 (spec-b-0164-alternative-pattern, first lane of
alternative, so a helper arm like "word" | "term" => "alpha"
left the caller-side boundary input unresolved and the corpus row
abstained at infection_unknown even though the runtime mutant truth
says the test discriminates.

An alternative of plain string literals is statically exact: the arm
matches when ANY constituent equals the scrutinee, and first-match
source order stays authoritative. parse_arm now splits the pattern on
'|' and requires every component to pass the same conservative
literal_string rule; a guard, binding, path, escape, computed value,
or any non-literal component inside the alternative (wildcard,
binding, escaped literal) still refuses the whole match. Splitting
cannot cut inside a literal: a '|' inside quotes still yields
fragments that fail the balanced-quote rule, so the arm refuses
conservatively rather than mis-parsing.

- spec-b-0164-alternative-pattern row re-blessed: credited/exposed,
  outcome ideal; rust missed_credit_ceiling 146 -> 145 (ratchet)
- RIPR-SPEC-0164 acceptance example #3 rewritten from Reject to Accept
  (the corpus case cites #3); mixed-alternative refusal unit-pinned
- full rust verdict corpus check green; check-spec-format and
  check-spec-numbering pass

Co-authored-by: Claude <noreply@anthropic.com>
check-changelog-fragments rejected 'Improved'; the policy's section
list is Added / Changed / Deprecated / Removed / Fixed / Security /
Docs / Internal CI.

Co-authored-by: Claude <noreply@anthropic.com>
A pipe inside a string literal is content, not an alternative separator:
"a|b" stays one literal and keeps its exact-match credit instead of
refusing the arm. Devin review on #10311 flagged the regression; a
quote-aware split restores the credit with the same conservative
validation everywhere else. Regression tests pin both the lone
pipe-literal and a pipe inside one alternative.

Co-authored-by: Claude <noreply@anthropic.com>
The original substitution left BODY's "word" => "alpha" arm ahead of
the later alternative, so "word" resolved to "alpha" under the
first-match evaluator while the test expected "second" — Rust match
semantics agree with the evaluator, not the fixture. Replace both literal
arms so the earlier plain arm shadows only the alternative's "text"
constituent and "word" still reaches the alternative. Both gate runs
(#10143 lineage) had failed on this; the pipe-split fix is unrelated to
it.

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

Main's #6485 netted the ceiling to 147 (two grid rows recovered, one
bound-input abstention added); this branch resolves one more row
(spec-b-0164-alternative-pattern). Keep both reason comments.

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

Copy link
Copy Markdown
Member Author

Bounded shared-ledger coordination request for this existing candidate: can its owner explicitly agree to defer only the numeric-ceiling-changing landing while canonical #10317 completes ONE refreshed migration qualification and its immediate landing/abort disposition? Its previous complete qualification passed, then current ledger edits conflicted again; #10222 records the repeated cost.

Implementation, reviews and already-running checks can continue. No cancellation, general freeze, branch change or check waiver is requested. Please reply with agreement or identify a priority repair that must land first so it can be incorporated before the migration is frozen. Silence is not agreement; this request does not establish a hold by itself. Unrelated changes need not wait, and the window ends with that single attempt's landing/abort disposition. The separate existing #10196 ownership/overlap question remains unresolved; agreement here would not clear it.

Copy link
Copy Markdown
Member Author

New concrete state for the existing ownership reconciliation: canonical #10196 merged at14:25:02UTC. Please compare this candidate's alternative-pattern row, spec and boundary controls with the actual landed implementation before any independent promotion. Preserve any additive evidence, but do not restack solely to merge the same behavior or replay a duplicate full qualification. This follows the existing unanswered6396286776 coordination; it does not silently transfer ownership or erase distinct residual controls.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Closing as superseded, not merged.

While this PR was in its final gate cycle, main landed #10196 (be652c8, fix(analysis): resolve alternative, escaped and char match arms and literal-tail callees (#9637)), which delivers this PR's whole claim and more through the shared #3295 literal parser:

  • |-joined alternative patterns evaluate exactly (alternative_patterns_select_each_listed_literal), including source-order shadowing;
  • the pipe-in-literal case the devin review flagged here ("c|d" is string content, not an alternative separator) is already covered by escaped_patterns_decode_like_the_callers_literal;
  • escaped patterns, char scrutinees and literal-tail callees also resolve, where this PR refused them.

Verified on current main: the claimed corpus row spec-b-0164-alternative-pattern reads observed_verdict: credited, outcome: ideal, and the Rust missed-credit ceiling has fallen to 143. Nothing in this branch is unique anymore — the quote-aware split, the shadowing-fixture correction, and the ceiling ratchet are all subsumed. The gate run on 46ba6e3 went green, but rebasing a redundant semantic rewrite onto the new authority would only add review debt.

Disposition: lane 1 of #10304 (spec-b-0164-alternative-pattern) is delivered by #10196; remaining lanes stay queued there.

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