Repository navigation
fix(xtask): report cargo lock wait as infrastructure state in file-policy enumeration (#8793) - #8905
Conversation
…licy enumeration (#8793) A covered_by enumeration spawn that times out while cargo is blocked on a lock held by another build is retried (bounded) instead of consuming the list budget, a persistent lock wait is reported as the distinct covered_by_lock_wait_timeout instrument failure, and precommit now runs its remaining checks after a file-policy instrument failure and still fails. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KJRFj19yBcxVrsuTFe4Y2
|
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 12 minutes. View limit details
Comment |
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
… checks running (#8793) Only a lock line that is cargo's last stderr output counts as a lock wait (a stale line before compile output is a real timeout, not retried), retry history is recorded in the report text, and a deferred file-policy instrument failure is carried as an infrastructure outcome through precommit_policy and precommit-v2 without hiding later failures. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KJRFj19yBcxVrsuTFe4Y2
|
Source/state-machine review receipt for the requested historical head Observed on that head: Currentness: this PR advanced to Disposition: requested old head |
There was a problem hiding this comment.
Confirmed findings
- validate_test_covered_by_with is exercised through an injected capture returning a fixed COVERED_BY_LOCK_WAIT_PREFIX string; the test does not exercise the actual capture_past_lock_wait wrapper inside the validator path, so the integration between the two helpers is asserted only at the prefix-string level.
- is_covered_by_instrument_failure matches on the substring 'instrument timeout, not an unresolved pointer'. Any future message reword (e.g. 'timed out, not a pointer') silently breaks precommit's infrastructure classification; consider a tagged enum or const-prefixed error type instead of string matching.
- xtask/src/policy/file_policy.rs:56 — capture_past_lock_wait's retry-history rewrite uses
format!("xtask: retried N time(s) ...\n{stderr}"); the test asserts the banner by feeding a capture that always returns a lock-wait-timeout, so the rewrite branch (attempts > 0) is exercised but the last attempt's stderr is identical to the first. There is no test that verifies a non-final-attempt stderr (e.g., a lock line that cleared mid-run followed by a real lock wait) preserves the original ordering and does not double-prepend banners. Add a case where attempts==2 with stderr A then stderr B (last is lock-wait); assert final.stderr contains the banner exactly once and ends with stderr B's content.
Verification questions
- Confirm check_file_policy_deferring wrapper has no direct unit test; coverage depends on transitive tests of check_file_policy and finish_precommit_policy arms.
- Confirm precommit_v2 deferred_instrument path writes report then returns Err without calling fail_with_report; the report status is overwritten to Infrastructure and report.failure_kind is set. Sibling write_report call sites in run_composition use the same fn; no other Infrastructure-classification path exists to risk double-classification, but no parallel write-then-Err surface was found.
- Confirm finish_precommit_policy test covers alone/both/plain matrix but does not exercise publish_precommit_policy_report path on None+Ok;.
- Confirm catalogue/sibling gap:
precommit_source_oraclerecognises thecheck_file_policy_deferringline by exact string equality (line == "check_file_policy_deferring(&mut deferred)?;"). Any future internal refactor (whitespace, extra arg, different variable name) silently drops the catalogue mapping without compile error; this is a sibling-route fragility rather than a current bug. - Confirm precommit_v2 driver test asserts classification but no test exercises the full run_composition path with deferred_instrument surfaced via report and Infrastructure status.
- Confirm finish_precommit_policy re-applies PRECOMMIT_INSTRUMENT_PREFIX to a string that already contains it when the diff checks also fail: main wraps with '{error}; also check-file-policy hit an instrument failure: {deferred}' so no double prefix, but the run_composition record_failure uses the pre-wrapped error as
limitations.push(error)after the prefix is in place. Check whether record_failure/limitations duplicate the prefix label for human readers. - Confirm precommit_v2 detects deferred failure by string prefix PRECOMMIT_INSTRUMENT_PREFIX; coupling is brittle if message format drifts.
Evidence gaps
- local precommit-v2 driver run not performed; CI is the only end-to-end witness.
- Model proof intent was rejected by deterministic validation.
…ator's own line (#8793) Embedded cargo output can no longer make a genuine failure read as an infrastructure one; add a spoofed-phrase negative test and document that the remaining precommit gates stop at the first genuine policy error. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KJRFj19yBcxVrsuTFe4Y2
|
Anchored Generated by Claude Code |
There was a problem hiding this comment.
Confirmed findings
- Retry bound caps attempts, not wall-clock: a held cargo lock that idles just under per-spawn timeout up to LOCK_WAIT_RETRIES+1 times can still consume ~LOCK_WAIT_RETRIES * spawn_timeout before failing. Under shared-target-dir contention this is a self-inflicted DoS amplifier rather than an exploit primitive, but a fork that pins spawn timeout and bounds total lock-wait wall-clock would be safer. Not a security blocker; PR's claim boundary excludes lock-free enumeration.
capture_past_lock_waitretries whenever the LAST non-empty stderr line isBlocking waiting for file lock on build directory, but cargo emitsBlocking waiting for file lock(noon build directory) when blocked on~/.cargo/.package-cache. Such a stale state therefore yieldsattempt<=6, exhausts the budget, and is mislabeled ascovered_by_lock_wait_timeoutinstead of the package-cache stall;--target-dirdifferences across sessions can reproduce #8793 via the package-cache path while yielding wrong classification. (xtask/src/policy/file_policy.rs:52).- ub-worker-handoff lane is not applicable to this PR: the changed code is synchronous Rust in xtask using std::process::Command; there are no JS workers, no async tasks crossing thread boundaries, no transferable/SharedArrayBuffer, and no detach semantics. No worker-handoff UB observation can be substantiated.
- xtask/src/policy/file_policy.rs:13 —
LOCK_WAIT_RETRIES=6plus per-spawnTEST_COVERED_BY_BUILD_TIMEOUT=Duration::from_mins(30)allows up to ~7*30 min of wall time per slow covered_by entry. Withenumeration_spawnsproducing N parallel/list candidates this can extend precommit by hours in adversarial lock contention. PR text bounds the retry count but omits an aggregate wall-clock ceiling; recommend a single-attempt ceiling that returns once lock waits dominate. - xtask/src/policy/file_policy.rs:585 —
validate_test_covered_byandvalidate_test_covered_by_withcallenumerationdirectly, bypassingcapture_past_lock_wait. A regression of the last-line anchor inside the wrapper would not surface in their tests. Consider routing these helpers through the same wrapper or adding a sibling test that drivesvalidate_test_covered_by_withwith a stale-lock-line stderr to lock the invariant across both routes.
Verification questions
- Confirm finish_precommit_policy has three matrix cells tested (instrument alone, instrument+later error, plain error); run_composition end-to-end still not driven.
- Confirm
capture_past_lock_waitonly wraps the recorded branch (validate_test_covered_by_recorded_with); direct callersvalidate_test_covered_by/validate_test_covered_by_withstill callenumerationraw and bypass the retry. - Confirm precommit_policy_remaining stops at first genuine policy error via
?; finish_precommit_policy joins a later real error with the deferred instrument error rather than dropping it. precommit-v2 driver end-to-end not exercised locally.
Refuted
- Could Deferred String from check_file_policy_deferring outlive the local
deferredslot such that finish_precommit_policy's format! extends its lifetime past run_composition's report push?; refuted because:deferredis a local Option inside precommit_policy; run_composition only ever sees an owned String passed through crate::PRECOMMIT_INSTRUMENT_PREFIX (a&'static str) plus a cloned error stored indeferred_instrument. Both Err returns in finish_precommit_policy build a fresh owned String via format! and never hand a borrowed &str out. - An alternate enumeration-target-directory sibling helper should have been added alongside capture_past_lock_wait (parked alternative from #8793).; refuted because: PR Scope Non-goals explicitly lists 'separate enumeration target dir' as not taken; reviewed mentions only seed acceptance claims 1-4. No code path in file_policy.rs enumerates to a non-default target_dir; the parking is consistent and reviewer should not infer scope drift from silence.
- capture_past_lock_wait could lose or duplicate state across a worker handoff because retry-history is prepended to stderr; refuted because: rejected: capture is synchronous; TimedOutput is owned and returned by value on a single thread. No message channel, transferable, or worker boundary is crossed, so there is no detach or transfer UB. Prepending is in-place string mutation before return.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
EffortlessSteven
left a comment
There was a problem hiding this comment.
Targeted retry-oracle review of d43a6a624f81056aeedb6928a8aaa586d39c1ca4 (base reported by the PR: ea9629748e63fcf0f7c6ffb0a1532cda7aba272b). Disposition: REVIEW_INCOMPLETE, with one verified diagnostic-accounting repair below. This supplements the earlier retry-history discussion with an executable discriminator; it is not merge clearance.
Observed in a native Windows, std-only harness compiled with rustc 1.98.1 (x86_64-pc-windows-msvc):
- The retained
validate_test_covered_by_recorded_withpath, its retry loop, enumeration/parser/cache functions and realCommandDiagnostic::capturedwere extracted from this exact head. Only serde imports/Serialize derives were removed from the diagnostic module; the capture seam is the existing injected production seam. - Four fixture children have independently pinned durations 1100, 2200, 3300, 4400 ms: two lock timeouts, successful build, successful listing. The existing retry test passes, but the new report-accounting regression fails behaviorally: diagnostics contain only
[3300, 4400], total 7700 ms, versus the literal 11000 ms supplied by the children. Compilation exit 0; tests exit 101 (2 passed, 1 failed). - Moving diagnostic recording into the per-attempt capture closure makes all three tests pass (compile/test exits 0/0). This is a review-isolated experiment, not a change to the owned branch.
- A separate literal-argv regression passes on current source, retaining each selector's own selected tests after a retry. Deliberately changing
first_casetosecond_caseonly on a retry is rejected with the unexpected full argv (compile exit 0; tests exit 101). No current cross-command qualification bug was found in this bounded path.
The proposed owner contribution is one recording-site change plus two tests. Preserve per-child durations/scopes by recording inside the capture passed to capture_past_lock_wait; keep final output/classification behavior unchanged. This does not propose a new aggregate timeout ceiling: current policy bounds attempts, and the missing evidence here is elapsed accounting.
Currentness/limits:
- Head re-read before submission; all existing submitted reviews, Conversation comments and five inline threads were inspected. Existing owner/branch untouched; no competing PR or commit.
- Exact-head check inventory: 21 runs, 8 success and 13 skipped. The Rust test and Windows lanes are skipped; those success states are not execution proof for this claim.
- No full xtask build, full original test binary, real Cargo contention, native Git/Clippy, timeout cleanup or
run_compositiondeferred-report execution was performed. The repo pins rustc 1.95.0; 1.98.1 harness execution is not MSRV proof. - Source blobs were verified against the connector's Git blob SHAs. Local source/evidence and all three distinct test executables remain in the review-owned task directory under the 128 MiB cap. No denied gh configuration, WSL, CIM, local Git ownership path or Git Bash startup was retried.
Next transition remains with the existing PR repair owner: apply/adjust the narrow recording-and-regression contribution, run it in the actual xtask test binary, and obtain the separately missing native composition/required CI evidence.
…tics (#8793) Push one command diagnostic per capture attempt so the time spent in earlier lock-wait retries is not lost, and add a regression with literal argv, durations summing to 11000 ms and a second-selector identity control. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019KJRFj19yBcxVrsuTFe4Y2
There was a problem hiding this comment.
Confirmed findings
- Diff is synchronous std Rust with no JS-backed worker/transfer/GC/detach boundary; the lane's focus surfaces are absent. PR-thread 'lane not applicable' note is corroborated.
- Stage-flow duplication: both legacy precommit and v2 run_composition independently classify the same infrastructure error by string prefix. A typed enum exposed from policy:: (Infrastructure vs SourceOrPolicy) would remove the string contract across two call sites.
Verification questions
- Confirm sibling scan confirmed: no other precommit entry point invokes
check_file_policydirectly (grep limited to xtask crate; callers outside xtask usecargo xtask precommit). No otherwait for file lockmatcher exists in the codebase. No remaining sibling paths. Lock markerwaiting for file lockis the only cargo-side pattern matched; cargo's shorterBlocking waiting for file lock(package-cache path) is acknowledged in claim boundary. - Confirm precommit_source_oracle accept-list updated for the renamed wrapper call; risk of future drift between source-oracle pattern and actual calls is unchanged.
- Confirm deferred file-policy instrument failure crosses only the synchronous main.rs -> precommit_v2::run_composition boundary via a typed prefix string and is_finalised by finish_precommit_policy; no shared mutable state escapes the thread.
Refuted
- capture_past_lock_wait retries by re-borrowing
output.stderrafter format! rewrite while still inside the closure scope, risking aliasing of the owned String across spawn args.; refuted because:outputis local ownedTimedOutput; closure ends beforeformat!rebindsoutput.stderr; subsequent uses read ownedString. No aliasing, no UB. - cargo spawn retry loop (capture_past_lock_wait) could leak a stale stderr slice if it retained a partial capture between attempts.; refuted because: Each iteration allocates a fresh TimedOutput from the injected closure; only the final output is returned after attempts>0 banner prepend, and lock_wait_note operates on owned String. No borrowed slice survives across iterations.
- Other xtask cargo spawns (e.g., precommit-v2 diff checks, github-utility wrappers) might ship their own divergent lock-wait retry seam that mislabels or double-classifies infrastructure state.; refuted because: rg over xtask/src for CARGO_LOCK_WAIT_MARKER, capture_past_lock_wait, COVERED_BY_LOCK_WAIT_PREFIX, LOCK_WAIT_RETRIES, PRECOMMIT_INSTRUMENT_PREFIX, and is_covered_by_instrument_failure returns exactly the lines touched or referenced by this PR. The only cargo Command::spawn in the diff is validate_test_covered_by_recorded_with; PR body scopes to covered_by enumeration and precommit deferral, so no second seam exists to silence.
- retries cap attempts, not wall-clock; under shared-target-dir a near-idle holder could multiply spawn timeouts.; refuted because: true observation, not a test-oracle weakness; the bound LOCK_WAIT_RETRIES=6 plus spawn-timeout ceiling is itself a fail-closed gate. Capability is bounded; classification remains distinct. Out of scope for tests-oracle; belongs in ub-worker-handoff / architecture already flagged by prior github-actions review. Marking as false-premise for this lane.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Parked follow-ups
- LOCK_WAIT_RETRIES=6 caps attempts, not wall-clock; github-actions[bot] flagged this as self-inflicted DoS amplifier under shared-target-dir contention. PR claim boundary already excludes lock-free enumeration, so this is a parked hardening, not a blocker.
- No other xtask cargo spawn site uses CARGO_LOCK_WAIT_MARKER, capture_past_lock_wait, or COVERED_BY_LOCK_WAIT_PREFIX; sibling helper set is the single new function plus 4 new consts in file_policy.rs. Precommit-v2's deferred-instrument branch in run_composition is the only consumer outside file_policy. Nothing to broaden in this PR; tracked follow-ups are wall-clock bound and oracle string brittleness.
Summary
check-file-policy's covered_by enumeration no longer spends its cap waiting on a cargo lock held by another build: a spawn that times out while cargo prints "waiting for file lock" is retried (bounded at 6), a persistent lock wait is reported as the distinctcovered_by_lock_wait_timeoutinstrument failure naming cargo's lock line, and a real timeout is unchanged.precommitdefers a file-policy instrument failure: the remaining checks run, then the run fails (no passing report is published).Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: n/a
Spec: n/a
ADR: n/a
Plan item: n/a
Governing issue or accepted claim: #8793
Acceptance delta (one sentence): Cargo lock wait no longer consumes the covered_by enumeration budget, is reported distinctly as infrastructure state, and no longer hides later precommit checks (acceptance 1-4 of #8793, with the separate-target-dir alternative not taken).
Candidate Relationships
Candidate branch: fix/8793-covered-by-lock-wait
Stack parent or prerequisite PR (if any): none
Proposed replacement of PR (if any; not yet accepted): none
Scope
xtask/src/policy/file_policy.rs,xtask/src/main.rs(precommit),xtask/src/policy/mod.rsre-export. Does not touch the parked xtask test split (refactor(xtask): split tests.rs into per-topic test modules #8408).Scope Classification
Production delta: lock-wait retry and distinct classification in covered_by enumeration; deferred instrument failure in precommit.
Evidence/support delta:
test_covered_by_lock_wait_does_not_consume_the_budget_but_stays_bounded.Single acceptance criterion: lock wait is infrastructure state, not budget or source failure.
Non-goals: separate enumeration target dir; the xtask test split; naming the lock holder beyond cargo's own line (cargo does not print a holder pid for build-directory locks).
Support-tier Impact
Policy Impact
Proof
Result, failures, or skipped proof: local
precommit/Clippy not run (shared target-dir lock was held by other sessions for 40+ minutes, which reproduced #8793 itself; tests were run in a private target dir). Hosted CI is the full proof. Retry loop is unit-tested via an injected capture, not by two real concurrent cargo builds. Negative experiments: persistent lock wait still fails (distinct prefix), a real timeout without a lock line is not retried, zero-test pointers stay non-instrument failures.Claim Boundary
May claim: lock-wait timeouts are retried boundedly and reported distinctly; precommit continues past a file-policy instrument failure and still fails. Must not claim: lock-free enumeration, or that a skipped check passed.
Rollback
Revert the commit.
Spec-Test-Code Traceability
policy::file_policy::tests::test_covered_by_lock_wait_does_not_consume_the_budget_but_stays_boundedxtask/src/policy/file_policy.rs,xtask/src/main.rsStatic 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.Generated by Claude Code