Skip to content

perf(pilot): bound the default inventory cap by the pilot seam budget (#10726) - #11266

Merged
EffortlessSteven merged 5 commits into
mainfrom
claude/fix-10726-pilot-seam-limit
Oct 31, 2026
Merged

EffortlessSteven merged 5 commits into
mainfrom
claude/fix-10726-pilot-seam-limit

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven Zimmerman · project thread

Governing issue or accepted claim: #10726

Acceptance delta (one sentence): Default ripr pilot on tokio drops from about 48 s to about 15-17 s with byte-identical stdout, identical summary JSON and identical ranked seams, because pilot's built-in inventory cap now follows the 2,000-seam pilot budget instead of 10,000.

Change

ripr pilot ranks and writes at most DEFAULT_PILOT_SEAM_BUDGET (2000) seams, but with RIPR_REPO_EXPOSURE_SEAM_LIMIT unset it classified up to 10,000 and discarded 8,000. A scoped guard (PilotInventoryDefault) sets the built-in default to min(pilot budget, 10000) for the pilot run only, and restores the previous value on drop. pilot() is reached only from the CLI (cli/execute.rs); LSP and MCP never call it and xtask runs the pilot binary as a subprocess.

  • An explicit RIPR_REPO_EXPOSURE_SEAM_LIMIT (including 0) still wins. ripr check and the other consumers keep 10,000.
  • Seams of the current change past the cap are still classified by the existing change supplement.
  • Disclosure: a cut made by the pilot-scoped default is relabelled as the pilot-budget cut (pilot_seam_budget_applied, control RIPR_PILOT_SEAM_BUDGET, and the budget repair route), as before this PR. Review rounds found and fixed a flip to repo_seam_limit_applied and an understated seams_total when a changed seam sits past the cap.
  • seams_total in the artifacts is now the real inventory (for example 12754 on tokio, where it used to read 10000). That is a deliberate improvement and is called out in the CHANGELOG.
  • Because ripr check keeps 10,000, a pilot snapshot cut by the lower default carries no comparable artifact identity, as with any budget-truncated snapshot.
  • Docs: CHANGELOG, --help env text, RIPR-SPEC-0074, docs/CONFIGURATION.md.
  • Tests: pilot_default_inventory_cap_follows_the_budget_without_moving_the_ranking and a changed-seam-past-the-cap case in cli_smoke.rs (both assert same seam ids, same top actionable seams and equal limitations[0] between the default run and RIPR_REPO_EXPOSURE_SEAM_LIMIT=0), and built_in_inventory_default_is_the_product_cap_without_a_pilot_guard in seam_inventory.rs.

Measurements

tokio-rs/tokio at 6470b5e (12,754 seams), one-line edit, release build, 4 cores, fresh cache per row, ripr pilot --root . --timeout-ms 900000. Rows 1-4 and 6 were measured on the first head; the default row on the current logic was re-measured at 15.3 s.

Run Edit Wall Output vs base
Before, default (10,000) barrier.rs 48.0 s n/a
Before, RIPR_REPO_EXPOSURE_SEAM_LIMIT=2000 barrier.rs 15.3 s stdout identical
After, default barrier.rs 15.3 s stdout and pilot-summary.json identical; only seams_total differs (10000 to 12754)
After, RIPR_REPO_EXPOSURE_SEAM_LIMIT=0 (first head) barrier.rs 47.7 s stdout identical
Before, default wake.rs 40.5 s n/a
After, default (first head) wake.rs 13.3 s identical

The top pick is tokio/src/doc/mod.rs:39 in every run. Timings come from a shared sandbox; the ratio is about 3x.

Local checks

  • cargo xtask precommit: exit 0 on the current head; cargo xtask check-architecture passes.
  • cargo build --release -p ripr: pass.
  • Not run (sandbox OOMs on the lib-test target): cargo test -p ripr --lib, the new and existing pilot cli_smoke tests, cargo test -p xtask, goldens check on its own. Hosted CI is the first execution of those tests.
  • Two independent review rounds were done; their material findings are fixed above.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UNUoLUh82CsN5o9LMZnmZm

…#10726)

Pilot ranks and writes at most DEFAULT_PILOT_SEAM_BUDGET (2000) seams but the
built-in inventory cap was 10000, so it classified 8000 seams only to discard
them (tokio: ~48 s vs ~15 s, identical output). With RIPR_REPO_EXPOSURE_SEAM_LIMIT
unset, pilot now scopes the default cap to min(pilot budget, 10000). The source
stays "default", an explicit env var still wins, and a snapshot cut by the lower
default carries no comparable artifact identity because ripr check keeps 10000.

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

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 147 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: 0a2a1b41-3da6-434b-b361-22ff717a5d4f
Commits

Reviewing files that changed from the base of the PR and between aa87542 and f9ecaa8.

Files selected for processing: 9
  • CHANGELOG.md
  • crates/ripr/src/analysis/mod.rs
  • crates/ripr/src/analysis/seam_inventory.rs
  • crates/ripr/src/cli/commands/pilot.rs
  • crates/ripr/src/cli/help/core.rs
  • crates/ripr/tests/cli_smoke.rs
  • crates/ripr/tests/pilot_missing_changed_files.rs
  • docs/CONFIGURATION.md
  • docs/specs/RIPR-SPEC-0074-repo-exposure-run-status.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

Independent read-only review of head 3a8df59. Disposition: CHANGES NEEDED (one material finding; the rest is sound). Nothing was compiled or run; compile-correctness is by reading.

Material: the limitation disclosure changes, contradicting "identical pilot output". For a repo with 2,000 < total <= 10,000 seams and no change supplement, the pilot budget no longer fires, because apply_pilot_seam_budget_inner returns None when total <= limit. The inventory cap now fires at 2,000 instead. pilot.rs (~L410) then selects RepoExposureLimit::Inventory, not PilotBudget.

  • Category flips from pilot_seam_budget_applied to repo_seam_limit_applied.
  • Control flips from RIPR_PILOT_SEAM_BUDGET to RIPR_REPO_EXPOSURE_SEAM_LIMIT.
  • Repair route becomes "Set RIPR_REPO_EXPOSURE_SEAM_LIMIT=0 to analyze all seams" (repo_exposure.rs ~L254).
  • That route is misleading: with the limit at 0 the pilot budget still cuts to 2,000 and the ranking is the same, only slower. The accurate route is RIPR_PILOT_SEAM_BUDGET.
  • The same flip happens for total > 10,000 when no changed seam is added, since the budget then sees <= 2,000 seams.
  • The new test hides this. It sets RIPR_PILOT_SEAM_BUDGET=2 (source configured) and only compares seam_limit, never limitations[]. Its source == "default" assertion passes only because of this flip.

Fix: keep the pilot-budget category, control and repair route when the cut came from the pilot-scoped default. Alternatively, update OUTPUT_SCHEMA.md, SPEC-0091 and SPEC-0074, the CHANGELOG and the tests to state the new disclosure. Assert limitations[0].category/control/repair_route in the smoke test either way.

Rename. The diff contains no pilot_seam_budget_applied to repo_seam_limit_applied rename. Both categories already exist in repo_exposure.rs, pr_summary/json.rs, agent_seam_packets.rs and OUTPUT_SCHEMA.md. The only effect is the behavioral flip above. No schema or golden breaks from a rename, but docs/OUTPUT_SCHEMA.md (~L16481 and ~L17364) and SPEC-0091 describe the pilot-budget category for default cuts, so they would now be stale.

(1) Guard safety: sound.

  • There is no set_var and no unsafe. The guard is a static AtomicUsize with Relaxed load and store.
  • Drop resets it, and the binding is let _pilot_inventory_default (named, not _), so it lives to the end of pilot() across every ? return.
  • Residual: Drop stores 0 instead of restoring the prior value, so nested or concurrent guards in one process would clobber each other. The process-wide scope is also not documented.
  • In-process lib tests call pilot() (pilot.rs ~L1287 and ~L1298), but those refuse the root before any inventory work, so the parallel-test risk is negligible.
  • Cache key: seam_cache.rs ~L1650 encodes the effective limit, so pilot's 2,000-cap entries never collide with check's 10,000-cap entries.

(2) Late changed seam: not dropped, per code. classify_change_past_seam_limit runs whenever inventory_limit_info.is_some(). It calls classify_seams_in_files_at_with_config with with_repo_seam_limit: false, so the lowered cap does not apply to it, and it filters with change.touches_seam. The seams it adds are folded in and survive the budget via keeps_past_budget.

  • The budget keeps an inventory-order prefix plus the changed seams, so capping the inventory at 2,000 selects the same prefix. Ranking is unchanged.
  • No test covers a changed seam past the cap. The new smoke test's fixture has a clean tree after commit, so nothing is supplemented. Please add one.
  • Side effect: the extra classification pass and the "pilot hit the seam limit" stderr line now occur for repos with 2,000 to 10,000 seams.

(3) Snapshot identity: consistent. inventory_cut_below_check forces snapshot_context = None only when the cap is below 10,000 and the source is Default. An explicit limit and RIPR_PILOT_SEAM_BUDGET >= 10,000 are unaffected. The guard is still live when cut_below_check_default is called. No test asserts the artifact identity.

(4) Docs.

  • The CHANGELOG, help text and SPEC-0074 are mutually consistent but inherit the "identical output" overclaim.
  • docs/CONFIGURATION.md (~L258) still lists the RIPR_REPO_EXPOSURE_SEAM_LIMIT default as 10000 with no pilot note. OUTPUT_SCHEMA.md has the stale text noted above.
  • The analysis/mod.rs import edits are fine: pilot_seam_budget is still used inside seam_inventory.rs, and the only external caller was replaced.

(5) New smoke test. It would fail on pre-change code, at the source == "default" assertion. It does not discriminate on ranking, because a small fixture's top gap is identical either way. Helper signatures (run_command_with_env, init_producer_fixture_repo, commit_repair_fixture) match, and the ? conversions look correct. No unwrap, expect or panic in the production edits.

Not verified: compilation, clippy, test execution, whether the fixture's current change is empty, the goldens and docs checks, and the tokio timings.


Generated by Claude Code

…ault cap (#10726)

Re-label an inventory cut made by the pilot-scoped default as the pilot budget
cut (category, control, repair route, real inventory total), restore the prior
guard value on drop and document the process-wide scope, add a changed-seam-
past-the-cap smoke case that asserts limitations[0], and note the pilot scoping
in CONFIGURATION.md.

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

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

Re-review of delta b3255ab (read-only; nothing compiled or run). Disposition: CHANGES NEEDED, one material finding.

1. Changed seam past the cap: pilot-budget seams_total is understated, and the new second smoke case would fail.

  • Walk with 2000<T<=10000 and a changed seam beyond the cap. The inventory cuts at 2000 and the info is (2000, T, Default). fold_classified_change (current_change.rs ~L190) appends the changed seams and sets the info to (2000+added, T), which stays Some because analyzed < total.
  • classified.len() is now 2000+added, so apply_pilot_seam_budget_inner returns Some{analyzed<=2000, total=2000+added}.
  • pilot_budget_info.is_none() is false, so as_budget_cut is skipped and the inventory info is not used.
  • limit_info = pilot_budget_info.or(..) makes the artifact limitation PilotBudget(total=2000+added). Only summary_limit (pilot.rs ~L407) takes inventory.total = T.
  • Before this PR the budget saw all T seams and reported seams_total = T. The category and control are right, but limitations[0].seams_total in repo-exposure.json and the packets, and the "analyzed X of Y" markdown line, now say 2000+added instead of T. The same mismatch applies when total>10000 with a supplement.
  • In the new smoke case (budget=1, changed handling_fee past the cap) the default run's limitation is {seams_analyzed:1, seams_total:2}. The RIPR_REPO_EXPOSURE_SEAM_LIMIT=0 run's is {1, T} with T>=3. The assert_eq!(limitation(&default.0), limitation(&full.0)) in assert_same_result (cli_smoke.rs, around L17830-17845) therefore fails. Please confirm T by running it.
  • Suggested fix in pilot.rs: when the pilot-scoped default was the inventory cap (as_budget_cut(inventory_limit_info.as_ref()) is Some), take total from the inventory info for the budget disclosure even when a budget cut also fired, as summary_limit already does. Then the changed-seam case matches the full run.

2. Cases walked (static)

  • T<=2000: no cut anywhere, unchanged from before.
  • 2000<T<=10000, no changed seam past the cap, or all cut seams on the change: the inventory cut gives (2000, T, Default) and the budget returns None, so as_budget_cut relabels to (2000, T, source from the budget env). Category pilot_seam_budget_applied, control RIPR_PILOT_SEAM_BUDGET, and the repair route match the pre-PR output. The retained seam set is also the same (changed seams first, then prefix fill).
  • 2000<T<=10000 with a changed seam past the cap: the category and route are fine, but see finding 1 for the total.
  • T>10000: category and route match. The total is now the real T, where before it was 10000 (and 10000+added with a supplement). That is a deliberate improvement, but it is a behavior change; say so in the CHANGELOG.
  • Configured RIPR_PILOT_SEAM_BUDGET=N: the source is re-read through pilot_seam_budget() and is correct. Budget 0 or N>=10000 gives cap 0 or >=default, so None. An explicit RIPR_REPO_EXPOSURE_SEAM_LIMIT is Configured, so None.

3. Guard

  • swap on enter and store(previous) on drop are correct for LIFO nesting and on the ? early return, since enter errors before swapping. Relaxed ordering is fine here. Out-of-order drops would restore a stale value, which is acceptable for this single call site.
  • Nit (seam_inventory.rs ~L84-90): #[must_use] now sits between two /// blocks. It compiles, but move the attribute below the doc comment.

4. Compile and clippy by reading

  • let-chain if ... && let Some(info) = ... is fine on edition 2024. pilot_seam_budget().ok()?? is valid in an Option-returning fn. inventory_limit_info and pilot_budget_info are mut. PilotInventoryDefault is already exported from analysis. No unwrap, expect or panic in the delta. The test closures, Value == &str comparisons and seam_id/owner/limitations/seam_limit keys all check out against repo_exposure.rs (seam_id, not id).

5. Tests

  • The first (clean-tree) case is discriminating against the previous head 3a8df59 (it would have reported repo_seam_limit_applied). It would also pass on pre-PR code, since the budget cut was already pilot_seam_budget_applied. It is a regression pin, not proof of the speedup. No test observes that the inventory cap actually dropped to 2000.
  • The second case does exercise the supplement (the cap is 1 and handling_fee is last), so skipping the supplement would fail the handling_fee presence assert. As noted in finding 1, it fails on the limitation equality before it can pass. Also unverified: that keeps_past_budget keeps handling_fee for this edit.

6. Snapshot identity

  • This is consistent. A relabeled cut sets pilot_budget_truncated, so snapshot_context is None, as for any budget cut. The supplement case is covered by change_seams_added.

7. Docs

  • CHANGELOG and SPEC-0074 say "with the inventory's real total". That is false for the changed-seam case until finding 1 is fixed. Re-wrap the long CHANGELOG line.
  • The CONFIGURATION.md text is accurate.

Not verified: compilation, test execution, fixture seam count T, and keeps_past_budget behavior for the edited function.


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

  • PilotInventoryDefault is process-wide, so concurrent inventory consumers can observe the pilot-scoped default and change their behavior unexpectedly.
  • PilotInventoryDefault uses process-global atomic state, so overlapping pilot commands in one process can read or restore another command's scoped cap.
  • crates/ripr/src/analysis/seam_inventory.rs:76 — The pilot-scoped cap is process-wide but not serialized. Two concurrent pilot runs can swap this static, causing one run to use the other's budget and restoring a stale value when either guard drops. This can produce incorrect analysis limits or expose more than the intended population. Serialize pilot runs or replace the global override with explicit per-run configuration passed through inventory calls.
  • The pilot-specific default is process-global, so a concurrent check or repo-exposure analysis can observe the 2,000 cap instead of its documented 10,000 default.
  • The process-wide pilot inventory default is not protected by an exclusive-run lock, so concurrent pilot executions can interfere with each other's effective cap and disclosure state.
  • crates/ripr/tests/cli_smoke.rs:17776 — Add an oracle outside ripr pilot showing the built-in repo-exposure limit remains 10,000. The current test exercises only pilot and cannot detect a regression where the global default was changed or the guard leaked into another command.

Verification questions

  • Confirm the new smoke test exercises ranking and disclosure equivalence but does not run two pilots concurrently.
  • Confirm nested or concurrent guards restore the cap incorrectly when their lifetimes overlap.
  • Confirm the global inventory default is process-wide and overwritten by a nested or concurrent pilot guard.
  • Confirm explicit nonzero inventory-limit precedence is documented and implemented but is not directly asserted by the new test; only explicit zero and unset are compared.
  • Confirm the new smoke test does not exercise concurrent or nested guard behavior, leaving the global-state contract untested.
  • Confirm the new test covers ranking and disclosure equivalence but does not cover concurrent non-pilot consumers or nested/concurrent guard restoration.

…ms fold past the cap (#10726)

When the pilot-scoped default cap fired and current-change seams folded in past
it, the budget disclosure counted the capped inventory plus the folded seams.
Take the total from the inventory in that case, as the summary already does.
Also: must_use below the doc comment, guard scope documented (CLI-only caller),
a unit test that non-pilot callers keep the 10000 default, an explicit-limit
smoke assertion, and a re-wrapped CHANGELOG entry.

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

CI note on bcecdae: the only failing step is cargo xtask goldens check, with drift in fixture python_trailing_whitespace_in_multiline_string (Verify command line now Verify command (Bash): (cd -P ...). That fixture and its verify-command output are untouched by this PR (pilot cap, docs, tests only); the drift comes from the already-merged #11210 and is being re-blessed in open PR #11301. Everything else on this head, including compile, clippy and the test shards, ran; I will merge main in and re-apply merge-ready once #11301 lands rather than bless an unrelated fixture here.


Generated by Claude Code

…ed limit (#10726)

pilot_missing_changed_files tests assert that a pilot run hits the classified
cache entry an ordinary ripr check wrote. Pilot's built-in inventory cap now
follows its seam budget, so its default cache key (limit_2000) differs from
check's (limit_10000) and the first pilot run after a check run missed. The
helper now sets the product-default limit explicitly for uncapped fixtures so
both commands keep one key; pilot-to-pilot reuse is unchanged.

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

Copy link
Copy Markdown
Member Author

Decision recorded for review (head 8f02a3d): the Rust-only lane caught that pilot's classified-cache key encodes the effective seam limit, so with RIPR_REPO_EXPOSURE_SEAM_LIMIT unset, ripr check (limit 10000) and ripr pilot (now 2000) no longer share one classified-cache entry. Pilot-to-pilot reuse is unchanged, and for repos under 2,000 seams the results are identical. The cost is one extra cache entry and one cold pilot run after a check. I judged that acceptable against the roughly 3x pilot speedup and am not adding a two-key lookup scheme in this PR; if check-to-pilot cache sharing matters it should be its own slice. The affected test (pilot_missing_changed_files.rs) now pins the shared limit explicitly for its uncapped fixtures, with a comment saying why.


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