Skip to content

fix(mcp): conjoin the shared repair gate into MCP repair readiness (#8717) - #9105

Merged
EffortlessSteven merged 5 commits into
mainfrom
claude/mcp-prepare-repair-gate-parity
Oct 21, 2026
Merged

EffortlessSteven merged 5 commits into
mainfrom
claude/mcp-prepare-repair-gate-parity

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Requested by Steven · project thread
Governing issue or accepted claim: #8717
Acceptance delta (one sentence): ripr_prepare_repair, ripr_list_gaps and ripr_get_gap never report an item repair-ready (or create an awaiting_edit attempt) when the shared repair gate behind ripr repair <finding-id> refuses its seam, and return a typed refusal with repair_packet_ready: false instead.

Problem (reproduced on current main, binary built from 00c92f9c7)

Corpus shaped like the probe (c2: match k { Kind::A => 1, ... } changed on a branch, tests/t.rs asserting price(Kind::A) == 1):

surface before
ripr_prepare_repair for gap:rust:src/lib.rs:price:match_arm:match_arm:kind_a repair_packet_ready: true, attempt awaiting_edit
ripr repair probe:src_lib.rs:match_arm:c3088e73 refuses: "not repair-eligible: not a headline repair target: its existing tests already grip it (exposed)"
ripr check "no repair start offered: no seam in the finding's file binds this finding"
ripr_get_repair_card seam_not_found

Root cause

mcp::gaps::RepairReadiness::from_finding decides readiness from finding-level producer facts only (candidate actionability, discriminator, a strong related test on a test surface). The CLI gate is a seam-level decision: ripr repair <item> resolves the item to one seam and applies the repair-admission gate (repair_refusal: headline-eligible class, cross-language visibility, route readiness, brief policy). The producer's finding class (weakly_exposed) and the seam classifier (StronglyGripped) can disagree, and MCP never asked the seam validator, so it was a parallel and weaker authority. get_gap also contradicted itself (readiness block "established" versus the unconfirmed discriminator text) because both read the same finding-only projection.

Change

  • app::task_first: extract resolve_repair_subject_in(classified, policy, item) from resolve_repair_subject_outcome (same logic, no behaviour change for the CLI); RepairSubjectOutcome::Ineligible also carries the gate's RefusalKind.
  • New mcp/repair_admission.rs: at refresh, run that resolver once per committed finding over the refresh's diff-scoped seam inventory (gathered once and shared with the repair-card binder, so no second analysis) and produce a SeamVerdict per finding.
  • RepairReadiness::with_seam_verdict: the verdict is a conjunct of readiness, projected before the snapshot identity is computed, so list summary, get_gap readiness block, prepare_repair and the snapshot id carry one decision. Finding-level refusals remain the first failing gate. New typed reasons: seam_already_gripped, seam_gate_refused, seam_ambiguous, seam_not_found, each carrying the validator's own explanation. An evaluated admission fails closed for an uncovered finding.
  • ripr_prepare_repair for a refused item returns the existing isError: false document with repair_packet_ready: false, the typed ineligibility.reason/detail, and attempt: null.
  • RIPR-SPEC-0214 and a changelog fragment updated.

Relation to #8638

Re-driven on the same build: ripr_get_repair_card does not reproduce seam_not_found for repair-start seams on current main (the is_adult corpus binds both items: the card for gap:rust:src/lib.rs:is_adult:return_value:... returns seam f52426b80ce2c527). The remaining seam_not_found is for items whose seam is not headline-eligible (no canonical gap id, hence no card binding), which is the same fact the CLI states ("no seam ... binds this finding"). The shared root cause is MCP advertising readiness the seam layer does not support; after this change such an item is no longer called ready, so the two surfaces agree. Not closing #8638; it should be re-evaluated against the fixed behaviour. Also relates to #8717's proposed inversion fix: this PR addresses its exposed-item-is-ready half through the shared validator; the weak-item-with-named-missing-discriminator half (finding-level gates 2 and 3) is unchanged and still open there.

Evidence

  • Red (before): tools/p1.py driver on the base build over the c2 corpus: price ... kind_a prepare repair_packet_ready: True, CLI refusal as above. After: same corpus returns repair_packet_ready: False, ineligibility.reason: seam_already_gripped, detail "the shared repair gate (ripr repair) names seam 1ae02bb5ec445012 ... already grip it", attempt: null; the is_adult return-value item flips to seam_gate_refused ("repair route not ready"), matching ripr repair exit 3.
  • New real-stdio controls in crates/ripr/tests/mcp_stdio.rs: mcp_readiness_never_exceeds_the_cli_repair_gate (negative parity: every MCP item that ripr repair refuses is not ready on list, get_gap and prepare, with identical typed reason and no attempt; the gripped arm pins seam_already_gripped and the CLI text) and mcp_ready_item_is_the_item_the_cli_repair_gate_admits (positive parity on B4).
  • Unit: seam_verdict_is_a_conjunct_of_repair_readiness, evaluated_admission_refuses_an_uncovered_finding.
  • Pre-existing control corrected: refreshed_gap_filters_narrow_real_stdio_... pinned two exposed items as repair-ready; ripr repair refuses both (exit 3, "repair route not ready"), i.e. it pinned the inverted gate. Its fixture now gives each function the B4 three-input shape that the shared validator admits, keeping the filter assertions intact.
  • Verification run locally (Rust 1.95, Linux, CARGO_BUILD_JOBS=2, shared target): cargo test -p ripr --lib mcp:: 171 passed; cargo test -p ripr --test mcp_stdio 24 passed; mcp_sdk 4, agentic_bench_mcp 15 passed (before the fixture tweak, product code unchanged since); cargo xtask precommit exit 0 (after two retries where the covered_by instrument hit its 300 s timeout under cargo-lock contention; infrastructure, not a gate failure).

Not done / limits

  • Not re-run: full workspace tests, hosted CI. The goldens are CLI/LSP output and are not touched; wire changes are MCP-only.
  • Admission uses the diff-scoped seam inventory the card binder already uses; a bare probe: id with unchanged twin seams could resolve more ambiguously under the CLI's full inventory than here.
  • No merge-ready request; Draft only.

Generated by Claude Code

…8717)

ripr_prepare_repair, ripr_list_gaps and ripr_get_gap projected repair
readiness from finding-level producer facts alone, so an item whose seam
`ripr repair` refuses (for example a match arm its existing tests already
grip) came back repair_packet_ready:true with an awaiting_edit attempt.

The refresh now resolves every committed finding through the same resolver
`ripr repair <finding-id>` uses (resolve_repair_subject_in, extracted from
resolve_repair_subject_outcome) over its diff-scoped seam inventory, and the
verdict is a conjunct of readiness projected before the snapshot identity is
computed. A refused item returns repair_packet_ready:false, no attempt, and a
typed seam_already_gripped / seam_gate_refused / seam_ambiguous /
seam_not_found reason carrying the validator's own explanation.

Real-stdio parity controls compare MCP against `ripr repair` in both
directions. The gap-filter fixture pinned two exposed items as repair-ready
(the inverted gate); it now uses the B4 three-input shape that the shared
validator admits.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo
@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 21, 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 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 77 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
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 8a0864d2-bf65-4e68-a137-cc4f1aa91ca7
📥 Commits

Reviewing files that changed from the base of the PR and between 0d58bf7 and 1db0281.

📒 Files selected for processing: 12
  • .ripr/traceability.toml
  • changelog.d/8717-mcp-readiness-seam-gate-parity.md
  • crates/ripr/src/app/task_first.rs
  • crates/ripr/src/cli/commands/agent.rs
  • crates/ripr/src/mcp/gaps.rs
  • crates/ripr/src/mcp/mod.rs
  • crates/ripr/src/mcp/repair.rs
  • crates/ripr/src/mcp/repair_admission.rs
  • crates/ripr/src/mcp/repair_card.rs
  • crates/ripr/src/mcp/workspace.rs
  • crates/ripr/tests/mcp_stdio.rs
  • docs/specs/RIPR-SPEC-0214-mcp-repair-transaction-projection.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Copy link
Copy Markdown
Member Author

Red/green recorded on the new control: with the seam verdict neutralized (SeamAdmission::verdict returning None), mcp_readiness_never_exceeds_the_cli_repair_gate fails because MCP creates repair-attempt-05e2153b... for gap:rust:src/lib.rs:price:match_arm:match_arm:kind_a while ripr repair refuses it (exit 101). Restored, it passes (1 passed, 24 filtered out). The mutation is reverted; pushed head 62ef668e3 is the tested source.


Generated by Claude Code

Resolve the mcp_stdio.rs test-append conflict by keeping both the #8717 repair-parity test and the #8847 pre-cap related-test totals test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 21, 2026 05:46
@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!

Copy link
Copy Markdown
Member Author

Status on head 38af4418 (main merged in; the single conflict in mcp_stdio.rs kept both sides' tests). An independent fresh-agent source review found no blocking issues: the MCP verdict goes through the same resolve_repair_subject_in owner as the CLI and fails closed for uncovered findings, and CLI behaviour is unchanged. The new parity test discriminates, and the fixture change corrects the fixture rather than weakening any assertion. Local evidence is cargo test -p ripr --lib mcp:: at 174/174. The mcp_stdio integration tests compile but have not been executed locally, so hosted CI is their first run.

Known limits, not fixed here:

  • The CLI refuses with an error when the repo-wide seam inventory is truncated, but MCP uses the diff-scoped inventory and has no such check. Only repos large enough to hit the seam limit are affected.
  • Probe-id ambiguity is computed over the diff-scoped inventory.
  • RepairStartGate's start-time checks (recommended_test_is_repair_edit_target and held_inline_target) are not applied.
  • docs/interop/mcp.md doesn't list the four new ineligibility codes.

I'll file the first as a follow-up issue so it isn't lost.


Generated by Claude Code

@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

Comment thread crates/ripr/src/mcp/repair.rs Resolved
Comment thread crates/ripr/src/mcp/repair_admission.rs Resolved
…gate parity tests (#8717)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo

Copy link
Copy Markdown
Member Author

Rust-only feature lane on head 6084c28f (run 39552128831): the new parity tests mcp_readiness_never_exceeds_the_cli_repair_gate and mcp_ready_item_is_the_item_the_cli_repair_gate_admits pass, as does refreshed_gap_filters_narrow_real_stdio_and_replay_bound_continuation. The lane is red only on tests this diff does not touch, and the same failures appear on #9101:

Neither has a fix on main yet, because #9069 owns both. I'm leaving merge-ready on and will merge main in once the main fix lands. The earlier "Ripr Rust Small Result" failure on 38af4418 was only that head's run being cancelled by the label toggle after my push.


Generated by Claude Code

@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

  • Doc parity: docs/interop/mcp.md is not updated with the four new typed codes (seam_already_gripped, seam_gate_refused, seam_ambiguous, seam_not_found); the spec is updated, but caller-facing interop doc lists codes externally.
  • docs/interop/mcp.md was not updated to enumerate the four new typed seam reasons (seam_already_gripped, seam_gate_refused, seam_ambiguous, seam_not_found), so external MCP integrators have no canonical reference. Author flagged this as a known limit and committed only the SPEC-0214 update.

Verification questions

  • Confirm shared resolver is reused and verdict is conjunct; RefusalKind mapping covers the grip case but every non-grip Ineligible collapses to seam_gate_refused, losing visibility into route-not-ready vs policy omission in the readiness block.
  • Confirm mcp_readiness_never_exceeds_the_cli_repair_gate compares three MCP surfaces (list, get_gap, prepare) against CLI stdout/stderr strings. The CLI comparison parses human prose ('not repair-eligible', 'already grip'); if CLI text changes unrelatedly the test breaks despite parity holding.
  • Confirm gap filter fixture renames test fns to match B4 boundary shape; this could leak across sessions via temp_dir()/ripr-mcp-journey-pricing-* if dedup stamp drifts.
  • Confirm negative parity control proves refusal implies not-ready, but not that every MCP refusal is a CLI refusal.
  • Confirm negative parity test asserts cli_refusals>=2; fixture may pass via non-arm items, masking arm-specific regressions if items change.

Refuted

  • Fixture weakened to pass the new test; refuted because: Fixture rewrite adds B4 three-input shape (below/boundary/far-above), which is the exact shape the shared validator admits on a weak boundary; pre-existing filter assertions are preserved.
  • Extracting the shared resolver could silently change CLI route behavior.; refuted because: The CLI wrapper now calls the extracted core, and translate_agent_repair_seam_id retains the same seam id and reason; only the typed refusal kind was added.
  • MCP repair readiness runs a parallel validator that diverges from the CLI gate; refuted because: The diff extracts resolve_repair_subject_in (same logic, no behavior change for the CLI), threads a SeamInventory once per refresh through both SeamAdmission::evaluate and bind_snapshot_card_producers, and projects the verdict as a conjunct before snapshot id — there is no parallel validator; remaining scope surface (diff-scoped inventory vs repo-wide) is documented as a known limit, not a second gate.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • Diff-scoped MCP resolution may conservatively refuse an item admitted by the CLI's full inventory, contradicting the issue's parity claim but not the stated fail-closed limit.

@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

  • crates/ripr/src/mcp/repair_card.rs:119 — inventory_changed_files re-derives changed files from Finding::probe.location.file via finding_location_text, decoding the stable wire spelling. The previous caller passed GapItem.file (already decoded). Diff scope now depends on the producer's probe.location.file only; an item whose probe.location.file is empty or normalized differently loses its changed-file match and silently produces an empty candidate_seam inventory, yielding a fail-closed SEAM_NOT_FOUND for what the CLI gate would call seam-eligible.
  • RIPR-SPEC-0214 lists the four new refusal codes but the changelog fragment (changelog.d/8717-mcp-readiness-seam-gate-parity.md) enumerates only the four MCP reasons without naming the snapshot identity dependency added in workspace.rs:1336-1345 (inventory now feeds identity before snapshot id). Documentation parity drift between spec, interop doc, changelog, and source.

Verification questions

  • Confirm pre-existing control refreshed_gap_filters_narrow_real_stdio_... had its fixture mutated to B4 three-input shape so the shared validator admits the seams; the assertion list was preserved. Confirm the fix is fixture-only (no asset weakening). mcp_stdio fixture now writes pricing.rs with three pinned inputs per function; verify that no other control reading pricing.rs exhausts the new shape.

Refuted

  • The new controls are absent from the machine-readable spec-to-test graph.; refuted because: The RIGHT-side traceability diff adds all four new controls, and the spec now names the two real-stdio parity tests.
  • Finding-level readiness block and snapshot identity could disagree because seam verdict is folded after the hash bind point.; refuted because: Diff structures projection so seam verdict is conjoined into the RepairReadiness object used by gap_evidence_core before serialized_evidence_identity produces sha256; readiness detail drives the readiness block. Identity and readiness stay one decision.

Evidence gaps

  • Traceability registered both new parity stdio tests plus two gaps.rs unit tests under RIPR-SPEC-0214 in 6084c28; check-traceability not run locally so hosted CI is first execution.
  • Hosted execution of the Rust integration lane remains the final trust-affecting proof because the local mcp_stdio run was compile-only.
  • Model proof intent was rejected by deterministic validation.

Parked follow-ups

  • Caller-facing MCP interop documentation omits four newly emitted typed ineligibility codes.
  • MCP diff-scoped inventory can diverge from the CLI repository-wide inventory when that inventory is truncated or large.
  • Author admits RepairStartGate start-time checks (recommended_test_is_repair_edit_target, held_inline_target) and repo-wide seam truncation are not applied in MCP admission. Probe-id ambiguity only runs over diff-scoped inventory, smaller than CLI's repo-wide inventory.
  • Residual risk: MCP uses diff-scoped seam inventory while CLI uses repo-wide; author flagged known limit but didn't fix. For repos near the seam limit, MCP could resolve an item ambiguously that CLI pins uniquely. ARCHITECTURE-level: bounded diff-scoped inventory is intentional freshness scope, not an unbounded surface omission.

@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

  • crates/ripr/src/mcp/repair_card.rs:119 — inventory_changed_files now re-decodes Finding::probe.location.file via finding_location_text while the previous caller used GapItem.file (already decoded and the documented wire spelling). This widens the input dependency from GapItem to Finding; if probe.location.file is empty or differs from the item's wire file, diff scope silently narrows. Worth a one-line invariant comment or asserting the two strings agree.
  • The evaluated-admission fail-closed default (SEAM_NOT_FOUND when by_finding lacks the key) is only reachable from production if a finding is ever passed to verdict() outside the evaluate() map. from_output_admitted and GapItem::from_finding_admitted always feed the same &[Finding], so this rule guards a hypothetical non-refresh caller only. Document that explicitly, or remove the evaluated flag and the unevaluated() test-only path so production cannot call into a partially-evaluated admission. (crates/ripr/src/mcp/repair_admission.rs:102).
  • Documentation parity drift between RIPR-SPEC-0214 (updated), the changelog (only seams, omits snapshot-identity dependency), and the interop doc (unmentioned). Already in seeded reviews; not blocking for this PR.
  • docs/interop/mcp.md is not updated with the four new typed seam codes; SPEC-0214 and changelog are. Author flagged this as a known limit and committed only the SPEC-0214 update. External MCP integrators lack a canonical reference for the new refusal codes.
  • crates/ripr/src/mcp/gaps.rs:1202 — evaluated_admission_refuses_an_uncovered_finding only covers the empty-findings fallback. Add a case where evaluate() is called with a non-empty findings slice and verdict() is queried for a finding id not in by_finding; this is the production-shaped uncovered path and the only one the snapshot commit can hit when the inventory is non-empty.
  • verdict_for collapses every non-AlreadyGripped RefusalKind into SEAM_GATE_REFUSED. Callers can distinguish grip from gate-refusal but cannot distinguish route-not-ready from cross-language-visibility from policy omission within gate refusals. The PR narrative acknowledges the gate's typed coverage but the four-code contract is coarser than the underlying RefusalKind. Consider adding a sub-detail or per-kind mapping if external integrators need it. (crates/ripr/src/mcp/repair_admission.rs:114).

Verification questions

  • Confirm the positive parity test mcp_ready_item_is_the_item_the_cli_repair_gate_admits requires install_b4_repair_ready_fixture which is referenced but not in the diff; if that fixture is no longer in tree on the served head, the green proof depends on a pre-existing surface. Lane is not blocked — PR body says it is — but a hosted-CI proof receipt is missing for it.
  • Confirm mcp_readiness_never_exceeds_the_cli_repair_gate asserts the gripped arm refusal text contains both 'not repair-eligible' and 'already grip'. These are CLI prose fragments; any unrelated CLI reword makes the test fail despite parity still holding, breaking the proof's smallest-scope guarantee. Assert against the typed seam_already_gripped code and exit code only, or assert against a stable string constant. (crates/ripr/tests/mcp_stdio.rs:3540).
  • Confirm crates/ripr/src/mcp/gaps.rs:1145 — evaluated_admission_refuses_an_uncovered_finding constructs AgentBriefPolicy::from_config(&RiprConfig::default()) and asserts verdict("probe:uncovered") returns SEAM_NOT_FOUND. The fail-closed path through verdict() requires evaluated == true and a missing key; with an empty findings slice, by_finding is empty and the missing-key branch fires. This proves the missing-key branch but does not prove resolve_repair_subject_in returns Unknown for an arbitrary finding id over an empty inventory. Add an assertion that an empty inventory plus a finding whose id matches no seam yields the same code, to lock the route the production case actually exercises.
  • Confirm positive parity test asserts prepare["attempt"]["finding_id"] is the very id the CLI repair tool admits, but the attempt object schema is a RepairAttempt projection. If finding_id was renamed when serializing the attempt (e.g. the attempt uses the canonical gap id), the comparison silently falls through and the test passes against the wrong id. The negative parity test does not cross-check the attempt id.
  • Confirm evaluated_admission_refuses_an_uncovered_finding exercises a finding id the evaluate() loop never produced, proving the lookup fallback. It does not exercise a non-empty inventory with a finding id absent from inventory.
  • Confirm inventory_changed_files now uses finding.probe.location.file (decoded once) instead of already-decoded GapItem.file. If the producer leaves the file empty or uses a different relative spelling, the diff-scope becomes empty and admission becomes SEAM_NOT_FOUND fail-closed even when the seam exists in the workspace. The pre-existing test covers the in-root and encoded cases but not the empty/wrong-spelling case.

@EffortlessSteven
EffortlessSteven merged commit d5ede76 into main Oct 21, 2026
48 of 49 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/mcp-prepare-repair-gate-parity branch October 21, 2026 14:07
EffortlessSteven pushed a commit that referenced this pull request Oct 21, 2026
Resolve the squash-merge of #9105 by taking main's versions of the
overlapping MCP files and reapplying the #9108 truncation delta.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019ZHDKLVQqArSZrUFKSkREo
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.

2 participants