Skip to content

fix(xtask): report cargo lock wait as infrastructure state in file-policy enumeration (#8793) - #8905

Merged
EffortlessSteven merged 5 commits into
mainfrom
fix/8793-covered-by-lock-wait
Oct 20, 2026
Merged

EffortlessSteven merged 5 commits into
mainfrom
fix/8793-covered-by-lock-wait

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

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 distinct covered_by_lock_wait_timeout instrument failure naming cargo's lock line, and a real timeout is unchanged.
  • precommit defers a file-policy instrument failure: the remaining checks run, then the run fails (no passing report is published).

Swarm / Source Boundary

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

Source-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

Scope Classification

  • One production behavior

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

  • none

Policy Impact

  • file policy

Proof

cargo test -p xtask --bin xtask covered_by   # 36 passed
cargo fmt --check
cargo xtask check-changelog-fragments / check-no-panic-family / check-allow-attributes

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

  • Tests: policy::file_policy::tests::test_covered_by_lock_wait_does_not_consume_the_budget_but_stays_bounded
  • Code: xtask/src/policy/file_policy.rs, xtask/src/main.rs

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.

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.

Generated by Claude Code

…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
@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!

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 19, 2026 20:38
@coderabbitai

coderabbitai Bot commented Oct 19, 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 12 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available. Your 34 included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 2a71f293-f006-49cf-9504-b91447b79357
📥 Commits

Reviewing files that changed from the base of the PR and between ea96297 and 2213497.

📒 Files selected for processing: 6
  • changelog.d/8793-covered-by-lock-wait.md
  • xtask/src/main.rs
  • xtask/src/policy/file_policy.rs
  • xtask/src/policy/mod.rs
  • xtask/src/precommit_source_oracle.rs
  • xtask/src/precommit_v2.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

Comment thread xtask/src/policy/file_policy.rs Resolved

@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 found 4 potential issues.

Devin Review

Comment thread xtask/src/main.rs Resolved
Comment thread xtask/src/policy/file_policy.rs Resolved
Comment thread xtask/src/main.rs Resolved
Comment thread xtask/src/policy/file_policy.rs Resolved
… 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

Copy link
Copy Markdown
Member Author

Source/state-machine review receipt for the requested historical head 077c53d7f378491f763fa6d39b349167720861fa (tree 1e57cd1837ef8955dd7de6589534aa024c8cd333; merge base 9c9c785a52683579f165a71b0ed2f2483b3fb17b). This is technical coordination, not merge clearance or a new automated-review finding.

Observed on that head: cargo test --locked -p xtask --bin xtask covered_by -- --test-threads=1 passed all 36 tests, exit 0, using a bounded private target. The existing retry test rejected a review-isolated old single-capture mutation after successful compilation (exit 101: lock wait was not retried to completion: 1). Synthetic deterministic controls plus the real timeout-capture path confirmed the existing stale-lock concern: seven captures after a lock line followed by compilation progress. Real capture preserved partial stdout/stderr. An injection at the actual precommit policy-result boundary confirmed source_or_policy_failure, omitted Git/Clippy execution, and replacement of a prior passing structured report with failure. Verbatim-policy controls confirmed that a later gate failure lost the deferred error. These synthetic inputs are controls, not claims of real Cargo contention or actual repository-policy defects. No real two-process lock fixture was duplicated.

Currentness: this PR advanced to 90dd5d1b953e5a39cf6af571aa03433a50c26435 during the review. Its source repairs stale-lock detection, outer instrument-only classification/continuation, and preservation of the deferred error alongside a later failure. All six extracted-helper controls pass on the successor bytes (exit 0). The revised native precommit composition was inspected but has not been executed by this review; the old-head failures must not be applied to the successor as current findings. precommit_policy_remaining still stops at the first genuine later policy error; preserve that continuation-policy distinction in acceptance. Retry count is bounded, but each attempt still gets a fresh timeout and only final-attempt duration is returned; the new retry-count text does not establish total elapsed accounting.

Disposition: requested old head REPAIR_REQUIRED; successor REVIEW_INCOMPLETE pending native proof of revised precommit behavior and the separately owned lock witness. Shared writer untouched; isolated checkout restored; all commands terminal. No hosted CI request, Ready/label transition, merge or release action performed.

@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

  • 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_oracle recognises the check_file_policy_deferring line 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

Copy link
Copy Markdown
Member Author

Anchored is_covered_by_instrument_failure to the validator's own first line (enumeration did not finish (instrument timeout, not an unresolved pointer)), so a phrase quoted in embedded cargo output cannot defer a genuine failure; spoofed-phrase negative test added. precommit_policy_remaining now documents that it stops at the first genuine policy error. Known gap: no test drives run_composition end to end (the v2 report status plus diff checks and Clippy still running after a deferred failure); only classification via finish_precommit_policy is unit-tested.


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

  • 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_wait retries whenever the LAST non-empty stderr line is Blocking waiting for file lock on build directory, but cargo emits Blocking waiting for file lock (no on build directory) when blocked on ~/.cargo/.package-cache. Such a stale state therefore yields attempt<=6, exhausts the budget, and is mislabeled as covered_by_lock_wait_timeout instead of the package-cache stall; --target-dir differences 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=6 plus per-spawn TEST_COVERED_BY_BUILD_TIMEOUT=Duration::from_mins(30) allows up to ~7*30 min of wall time per slow covered_by entry. With enumeration_spawns producing 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_by and validate_test_covered_by_with call enumeration directly, bypassing capture_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 drives validate_test_covered_by_with with 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_wait only wraps the recorded branch (validate_test_covered_by_recorded_with); direct callers validate_test_covered_by / validate_test_covered_by_with still call enumeration raw 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 deferred slot such that finish_precommit_policy's format! extends its lifetime past run_composition's report push?; refuted because: deferred is 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 in deferred_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 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.

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_with path, its retry loop, enumeration/parser/cache functions and real CommandDiagnostic::captured were 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_case to second_case only 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_composition deferred-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.

Comment thread xtask/src/policy/file_policy.rs Resolved
…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

@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

  • 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_policy directly (grep limited to xtask crate; callers outside xtask use cargo xtask precommit). No other wait for file lock matcher exists in the codebase. No remaining sibling paths. Lock marker waiting for file lock is the only cargo-side pattern matched; cargo's shorter Blocking 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.stderr after format! rewrite while still inside the closure scope, risking aliasing of the owned String across spawn args.; refuted because: output is local owned TimedOutput; closure ends before format! rebinds output.stderr; subsequent uses read owned String. 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.

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