Skip to content

perf(stub): classify only the selected seam in the stub-route lookup (#13884) - #14850

Merged
EffortlessSteven merged 3 commits into
mainfrom
claude/13884-closure-chain-perf
Nov 16, 2026
Merged

EffortlessSteven merged 3 commits into
mainfrom
claude/13884-closure-chain-perf

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Summary

When ripr check selects 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 is typescript/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-seam evidence_for. #13913 (the #13868 masked-call-line cache) touches a different path and does not cover this one.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-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: new inventory_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.
  • Evidence is per seam, so the selected entry is the same as its whole-file entry. The existing staged-equality test already relies on this.
  • Repeat lookups reuse the result under perf(stub): reuse complete predicate-guidance inventory with content-bound invalidation #11358's exact-path, content-keyed rule. The reuse identity binds the file's native bytes plus the seam id, and is disjoint from the whole-file guidance identity.
  • The complete-scope reuse filter now also admits a staged caller, but only one that carries no reuse identity of its own.
  • app/test_stub.rs: inventory_entry_facts now uses the new lookup. This covers both ripr check stub routes and ripr agent stub --at. The ambiguous-narrowing and --seam-id paths keep the whole-file guidance inventory.
  • Merged with main (not rebased). The only conflict was main's perf(stub): reuse complete content-bound file guidance inventory (#11358, carrier for #12008) #13542 switch of this call site to inventory_file_guidance_at_with_config. Its reuse test, predicate_route_reuses_complete_inventory_and_refreshes_test_edits, still passes.

Scope Classification

  • One architectural seam

Production delta:

  • analysis/seam_inventory.rs (new lookup function, reuse identity, reuse filter) and app/test_stub.rs (one call site).

Evidence/support delta:

  • Counter tests in both files, a changelog fragment, and one #[cfg(test)] re-export of evaluation_probe.

Single acceptance criterion:

  • A by-id disclosure lookup evaluates 1 seam, however many seams the file holds, and its entry serializes byte-identically to the whole-file entry.

Non-goals:

Support-tier Impact

  • none

Policy Impact

  • none

Proof

Repro: base 5bf9e34 plus the #13884 chain in the mark_default_object_members owner loop, running ripr check --root . --base 5bf9e34e --format json. Release builds, fresh RIPR_CACHE_DIR per binary, run one after the other on a shared 4-core box.

binary wall user RSS
base: origin/main 60114de 396.1 s 823.7 s 1477 MB
fix: this head 5ebc8b1 97.6 s 172.1 s 1368 MB
(earlier pass) base faa1029 472.9 s 1374.6 s 1594 MB
(earlier pass) fix on faa1029 73.9 s 114.3 s 1357 MB

Current main still reproduces the issue: #13542's reuse does not help a cold first lookup.

Equality. cmp of the JSON output, base vs fix, finds them identical (sha256 8191fdd3…), 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-clock ripr progress: ... still active after 30s heartbeat.

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:
    • The whole-file path evaluates every seam.
    • The by-id lookup evaluates exactly 1, with unevaluated_seams = N-1.
    • Each seam's entry serializes byte-identically to its whole-file entry.
    • The fixture has more than one class.
    • Negative control: an unknown id evaluates 0 seams and returns no entry.
  • app::test_stub::tests::inventory_entry_facts_evaluates_only_the_selected_seam checks:
    • The whole-file path evaluates every seam (12).
    • The lookup evaluates 1 and returns the whole-file class and guidance.
    • An unchanged repeat evaluates 0.
    • Red check: reverting the call site to the whole-file inventory fails it with left: 12, right: 1.
cargo test -p ripr --lib -- app::test_stub:: analysis::seam_inventory:: file_guidance stub failed_evidence_warm   # 330 passed
cargo xtask precommit   # exit 0 (on 5ebc8b1a4f)

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

Rollback

  • Revert the merge-free commits. The whole-file guidance function is unchanged and remains available at the call site.

Spec-Test-Code Traceability

  • Spec: none (performance, output-preserving)
  • Tests: the two counter tests above
  • Code: crates/ripr/src/analysis/seam_inventory.rs, crates/ripr/src/app/test_stub.rs
  • Golden outputs: none (no drift)
  • Metrics: evaluation_probe evaluated-seam counts
  • ADR/learning: none

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.
  • Unknowns include stop reasons where applicable.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.
  • Errors are reported with actionable context.

Gates

  • cargo fmt --check
  • cargo xtask precommit
  • cargo test --workspace (hosted CI)
  • cargo clippy --workspace --all-targets -- -D warnings (hosted CI)

Generated by Claude Code


Devin Review

…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
@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 Nov 15, 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 47 seconds.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 146 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: f8b8aa53-ba41-4ef9-b9b1-bef334d83dc1
Commits

Reviewing files that changed from the base of the PR and between 9d46066 and 5ebc8b1.

Files selected for processing: 4

  • changelog.d/13884-classify-only-the-selected-stub-seam.md
  • crates/ripr/src/analysis/mod.rs
  • crates/ripr/src/analysis/seam_inventory.rs
  • crates/ripr/src/app/test_stub.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@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: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

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.

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.
  • EvidencePass evidence and classify_seam are each computed per seam, with no input from sibling seams.

Reuse identity.

  • The prefix file-seam-guidance-v1-lossless-key is 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: None and are unaffected.

Tests.

  • one_seam_inventory_evaluates_only_the_selected_seam fails 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_seam goes 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.

  1. 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.
  2. 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

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