Repository navigation
perf(pilot): bound the default inventory cap by the pilot seam budget (#10726) - #11266
Conversation
…#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
|
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 minutes. View limit details
Comment |
EffortlessSteven
left a comment
There was a problem hiding this comment.
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_appliedtorepo_seam_limit_applied. - Control flips from
RIPR_PILOT_SEAM_BUDGETtoRIPR_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(sourceconfigured) and only comparesseam_limit, neverlimitations[]. Itssource == "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_varand no unsafe. The guard is astatic AtomicUsizewithRelaxedload and store. Dropresets it, and the binding islet _pilot_inventory_default(named, not_), so it lives to the end ofpilot()across every?return.- Residual:
Dropstores 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_LIMITdefault as10000with no pilot note. OUTPUT_SCHEMA.md has the stale text noted above. - The
analysis/mod.rsimport edits are fine:pilot_seam_budgetis still used insideseam_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
left a comment
There was a problem hiding this comment.
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 staysSomebecause analyzed < total. classified.len()is now 2000+added, soapply_pilot_seam_budget_innerreturnsSome{analyzed<=2000, total=2000+added}.pilot_budget_info.is_none()is false, soas_budget_cutis skipped and the inventory info is not used.limit_info = pilot_budget_info.or(..)makes the artifact limitationPilotBudget(total=2000+added). Onlysummary_limit(pilot.rs ~L407) takesinventory.total = T.- Before this PR the budget saw all T seams and reported
seams_total = T. The category and control are right, butlimitations[0].seams_totalin 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_feepast the cap) the default run's limitation is{seams_analyzed:1, seams_total:2}. TheRIPR_REPO_EXPOSURE_SEAM_LIMIT=0run's is{1, T}with T>=3. Theassert_eq!(limitation(&default.0), limitation(&full.0))inassert_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())isSome), taketotalfrom the inventory info for the budget disclosure even when a budget cut also fired, assummary_limitalready 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, soas_budget_cutrelabels to (2000, T, source from the budget env). Categorypilot_seam_budget_applied, controlRIPR_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 throughpilot_seam_budget()and is correct. Budget 0 or N>=10000 gives cap 0 or >=default, soNone. An explicitRIPR_REPO_EXPOSURE_SEAM_LIMITisConfigured, soNone.
3. Guard
swapon enter andstore(previous)on drop are correct for LIFO nesting and on the?early return, sinceentererrors 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 anOption-returning fn.inventory_limit_infoandpilot_budget_infoaremut.PilotInventoryDefaultis already exported fromanalysis. No unwrap, expect or panic in the delta. The test closures,Value == &strcomparisons andseam_id/owner/limitations/seam_limitkeys all check out against repo_exposure.rs (seam_id, notid).
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 alreadypilot_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_feeis last), so skipping the supplement would fail thehandling_feepresence assert. As noted in finding 1, it fails on the limitation equality before it can pass. Also unverified: thatkeeps_past_budgetkeepshandling_feefor this edit.
6. Snapshot identity
- This is consistent. A relabeled cut sets
pilot_budget_truncated, sosnapshot_contextisNone, as for any budget cut. The supplement case is covered bychange_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
There was a problem hiding this comment.
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 pilotshowing 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
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
CI note on bcecdae: the only failing step is 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
|
Decision recorded for review (head 8f02a3d): the Rust-only lane caught that pilot's classified-cache key encodes the effective seam limit, so with Generated by Claude Code |
Requested by Steven Zimmerman · project thread
Governing issue or accepted claim: #10726
Acceptance delta (one sentence): Default
ripr piloton 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 pilotranks and writes at mostDEFAULT_PILOT_SEAM_BUDGET(2000) seams, but withRIPR_REPO_EXPOSURE_SEAM_LIMITunset it classified up to 10,000 and discarded 8,000. A scoped guard (PilotInventoryDefault) sets the built-in default tomin(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.RIPR_REPO_EXPOSURE_SEAM_LIMIT(including0) still wins.ripr checkand the other consumers keep 10,000.pilot_seam_budget_applied, controlRIPR_PILOT_SEAM_BUDGET, and the budget repair route), as before this PR. Review rounds found and fixed a flip torepo_seam_limit_appliedand an understatedseams_totalwhen a changed seam sits past the cap.seams_totalin 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.ripr checkkeeps 10,000, a pilot snapshot cut by the lower default carries no comparable artifact identity, as with any budget-truncated snapshot.--helpenv text, RIPR-SPEC-0074, docs/CONFIGURATION.md.pilot_default_inventory_cap_follows_the_budget_without_moving_the_rankingand a changed-seam-past-the-cap case incli_smoke.rs(both assert same seam ids, same top actionable seams and equallimitations[0]between the default run andRIPR_REPO_EXPOSURE_SEAM_LIMIT=0), andbuilt_in_inventory_default_is_the_product_cap_without_a_pilot_guardinseam_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.RIPR_REPO_EXPOSURE_SEAM_LIMIT=2000pilot-summary.jsonidentical; onlyseams_totaldiffers (10000 to 12754)RIPR_REPO_EXPOSURE_SEAM_LIMIT=0(first head)The top pick is
tokio/src/doc/mod.rs:39in 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-architecturepasses.cargo build --release -p ripr: pass.cargo test -p ripr --lib, the new and existing pilotcli_smoketests,cargo test -p xtask,goldens checkon its own. Hosted CI is the first execution of those tests.🤖 Generated with Claude Code
https://claude.ai/code/session_01UNUoLUh82CsN5o9LMZnmZm