Repository navigation
perf(stub): classify only the selected seam in the stub-route lookup (#13884) - #14850
Conversation
…13884) `ripr check` resolves a stub route for its selected predicate finding. When the resolved seam is a PredicateBoundary, `inventory_entry_facts` reads the seam's grip class and weak-oracle pointer from a diff-scoped inventory of the finding's file. That inventory classified every seam in the file only to pick one by id. A one-line change in a large file such as typescript/owners.rs (2,960 lines) therefore paid for re-classifying the whole file. gdb sampling of the #13884 repro put the main thread in check_stub_routes -> stub_route_for_finding -> inventory_entry_facts -> classify_scoped_seams, with the rayon workers in per-seam evidence_for. The closure chain matters only because its `!=` comparison becomes the selected predicate finding that takes this route. - New `inventory_diff_scoped_seam_at_with_config`: the same scope, seam walk and no-impact fast path as the whole-file inventory, but the existing first-stage filter evaluates only the seam with the requested id. Evidence is per seam, so the entry is the same as the whole-file entry, and an id the file does not hold yields no entry either way. - `inventory_entry_facts` (used by `ripr check` stub routes and `ripr agent stub --at`) calls it. Counter tests pin the evaluated-seam count to 1 at 3 and 9 functions (the whole-file path evaluates every seam), check that each seam's entry serializes byte-identically to its whole-file entry, and evaluate 0 seams for an unknown id. Reverting the call site fails the test_stub counter test with 12 evaluated against an expected 1. Repro (base 5bf9e34 plus the #13884 chain, `ripr check --root . --base 5bf9e34 --format json`, release, fresh cache, 4 shared cores): origin/main faa1029 took 472.9 s wall and 1374.6 s user; this change took 73.9 s wall and 114.3 s user. The JSON and stderr are byte-identical to the base binaries. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWvJLNTjPAkUKhsj5V
…chain-perf # Conflicts: # crates/ripr/src/analysis/seam_inventory.rs # crates/ripr/src/app/test_stub.rs
…nce rule (#13884) Main's #11358 made the stub-route disclosure lookup reuse its complete file-guidance result, and pinned that an unchanged repeat route does not rebuild the workspace index. The one-seam lookup now keeps that: it opts into the same exact-path, content-keyed result reuse with an identity that binds the file's native bytes and the selected seam id. A staged caller that carries its own reuse identity still never takes that route. The test_stub counter test also pins that a repeat lookup of the same seam evaluates no seam. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UNUoLWvJLNTjPAkUKhsj5V
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 47 seconds. View limit details
|
EffortlessSteven
left a comment
There was a problem hiding this comment.
SOURCE_REVIEW_READY
Head: 5ebc8b1. A fresh reviewer that did not write this code did a read-only review and returned no blocking findings.
Equivalence. The selected seam's entry matches its whole-file entry:
- The canonical scope inputs and the no-impact fast path are the same for both calls.
- Seam ids are deduplicated on (file, offset, kind, owner), so the filter selects 0 or 1 seam.
EvidencePassevidence andclassify_seamare each computed per seam, with no input from sibling seams.
Reuse identity.
- The prefix
file-seam-guidance-v1-lossless-keyis distinct from the whole-file and bound-seams prefixes, and the identity binds the file bytes and the seam id. - The workspace key binds both the corpus and the config.
- Results that fail closed are never stored.
- The MCP, bound and change routes pass
complete_scope_reuse: Noneand are unaffected.
Tests.
one_seam_inventory_evaluates_only_the_selected_seamfails in each of these cases: the filter is removed, the wrong seam is selected, or the seam id is dropped from the identity. In the last case the sequential lookups would get 0 instead of 1.inventory_entry_facts_evaluates_only_the_selected_seamgoes through the real call site and fails with 12 vs 1 when the change is reverted.- The counter sits in production
classify_scoped_seams.
Non-blocking notes.
- When one file has several findings, each now prepares its own one-seam lookup. Before, they shared one whole-file result, and these entries share the 4-entry store with MCP. This costs time only and does not change output, and the measured repro still drops from 396 s to 98 s.
- On files with at least 1,000 seams, the shared tables are no longer pre-built under
catch_unwind. The small stages already work this way.
Local proof: cargo xtask precommit exits 0, the 330 focused lib tests pass, and the JSON A/B is byte-identical. Not run locally: the full workspace tests and clippy, and Windows. Hosted CI covers those.
Generated by Claude Code
Summary
When
ripr checkselects a predicate finding, the stub-route disclosure lookup (inventory_entry_facts) classified every seam in the finding's file just to read one seam by id. It now classifies only that seam.In the #13884 repro, the closure chain's
!=becomes the selected predicate finding. Because the file istypescript/owners.rs(about 2,960 lines), the lookup re-classified the whole file and ran past 420 s.gdb sampling of the repro (release build with line tables) put the main thread in
check_stub_routes→stub_route_for_finding→inventory_entry_facts→classify_scoped_seams, with the rayon workers in per-seamevidence_for. #13913 (the #13868 masked-call-line cache) touches a different path and does not cover this one.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: none
Spec: none
ADR: none
Plan item: none
Governing issue or accepted claim: #13884
Acceptance delta (one sentence): The stub-route disclosure lookup evaluates exactly the selected seam instead of every seam in its file, with byte-identical check output and the evaluated-seam count pinned (1 at 3, 6 and 9 seams, 0 on an unchanged repeat).
Candidate Relationships
Candidate branch (GitHub PR head is authoritative after publication): claude/13884-closure-chain-perf
Stack parent or prerequisite PR (if any): none
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): none
Accepted winner and losing candidate disposition (when decided): n/a
Scope
analysis/seam_inventory.rs: newinventory_diff_scoped_seam_at_with_config. It uses the same canonical file scope, seam walk and no-impact fast path as the whole-file inventory. The existing first-stage filter (DiffScopeEvidenceStages) evaluates only the seam with the requested id.app/test_stub.rs:inventory_entry_factsnow uses the new lookup. This covers bothripr checkstub routes andripr agent stub --at. The ambiguous-narrowing and--seam-idpaths keep the whole-file guidance inventory.inventory_file_guidance_at_with_config. Its reuse test,predicate_route_reuses_complete_inventory_and_refreshes_test_edits, still passes.Scope Classification
Production delta:
analysis/seam_inventory.rs(new lookup function, reuse identity, reuse filter) andapp/test_stub.rs(one call site).Evidence/support delta:
#[cfg(test)]re-export ofevaluation_probe.Single acceptance criterion:
Non-goals:
ripr checkexceeds 1h on a ~160-line edit to a large Rust file (related_tests.rs) #13868 / perf(classify): mask each test file once per run for helper-entry call lines (#13868) #13913 (masked call lines).--seam-id).Support-tier Impact
Policy Impact
Proof
Repro: base 5bf9e34 plus the #13884 chain in the
mark_default_object_membersowner loop, runningripr check --root . --base 5bf9e34e --format json. Release builds, freshRIPR_CACHE_DIRper binary, run one after the other on a shared 4-core box.Current main still reproduces the issue: #13542's reuse does not help a cold first lookup.
Equality.
cmpof the JSON output, base vs fix, finds them identical (sha2568191fdd3…), and stderr is byte-identical too. In the earlier pass, JSON from faa1029 and from 669ccaa matched the fix byte for byte, and human-format stdout was identical. The only stderr difference in human format was a wall-clockripr progress: ... still active after 30sheartbeat.Counter tests (pinned counts, no wall-clock).
analysis::seam_inventory::tests::one_seam_inventory_evaluates_only_the_selected_seam, at 3 and 9 functions, checks:unevaluated_seams = N-1.app::test_stub::tests::inventory_entry_facts_evaluates_only_the_selected_seamchecks:left: 12, right: 1.Not run locally: the full workspace test suite, integration test binaries beyond the ones precommit builds, workspace Clippy, and a Windows run. Hosted CI owns those.
Claim Boundary
scoped_checkon init --agents: skip DETAIL only when missing= is one code value; rows count extra facts (#14298) #14536 or fix(typescript): credit each called member of a default-exported object when a test calls several (#6653) #13694 now fits its budget. Only the reduced repro was measured; other phases (perf: scopedripr checkexceeds 1h on a ~160-line edit to a large Rust file (related_tests.rs) #13868) may remain.Rollback
Spec-Test-Code Traceability
crates/ripr/src/analysis/seam_inventory.rs,crates/ripr/src/app/test_stub.rsevaluation_probeevaluated-seam countsStatic Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.Gates
cargo fmt --checkcargo xtask precommitcargo test --workspace(hosted CI)cargo clippy --workspace --all-targets -- -D warnings(hosted CI)Generated by Claude Code