Skip to content

fix(xtask): cap covered_by lock-wait retry by wall clock and prove v2 deferral end to end (#8939) - #8941

Merged
EffortlessSteven merged 2 commits into
mainfrom
fix/8939-covered-by-lock-wait-ceiling
Oct 20, 2026
Merged

EffortlessSteven merged 2 commits into
mainfrom
fix/8939-covered-by-lock-wait-ceiling

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Governing issue or accepted claim: #8939
Acceptance delta (one sentence): The covered_by lock-wait retry now has a documented 90-minute wall-clock ceiling that fails closed with the distinct covered_by_lock_wait_timeout instrument failure naming the ceiling, and precommit_v2::run_composition has end-to-end proof that a deferred instrument failure is infrastructure_failure (diff checks and selected Clippy still run, run returns Err) while a real policy failure plus an instrument failure is not infrastructure.

Follow-up to #8905.

Changes

  • xtask/src/policy/file_policy.rs: LOCK_WAIT_CEILING (90 min). capture_past_lock_wait sums the recorded durations of lock-wait attempts (no clock read, no sleeping). Once the sum reaches the ceiling it stops retrying even with attempts left, and prepends a history line that enumeration_result folds into the covered_by_lock_wait_timeout: message. The ceiling is checked after each attempt, so overshoot is at most one spawn timeout. Real non-lock timeouts and the attempt bound are unchanged.
  • xtask/src/precommit_v2.rs: run_composition now delegates to run_composition_in, which takes the policy gate and the command runner (diff checks, Clippy) as injected closures. Production passes precommit()/precommit_policy(true) and run_status; behavior is unchanged.
  • Tests: test_covered_by_lock_wait_ceiling_stops_retrying_and_names_the_ceiling, composition_with_deferred_instrument_failure_is_infrastructure_after_remaining_stages, composition_with_real_policy_failure_and_instrument_failure_is_not_infrastructure. The composition tests use a real temp git repo and real cargo metadata; only the policy gate and the runner are injected (Clippy is stood in for by a harmless git call).
  • changelog.d/8939-covered-by-lock-wait-ceiling.md.

Proof

  • Revert experiment (ceiling disabled): ceiling test fails (ceiling did not stop the retries: 7); restored, passes.
  • Revert experiment (deferral disabled): deferred-instrument composition test fails (report source_or_policy_failure); restored, passes.
  • Revert experiment (classifier widened to any error mentioning "instrument failure"): real-policy-failure composition test fails (classified infrastructure); restored, passes.
  • cargo fmt --check, cargo clippy --locked -p xtask --all-targets -- -D warnings, cargo test --locked -p xtask --bin xtask -- covered_by composition_with (40 passed), check-no-panic-family, check-allow-attributes, check-local-context all pass locally. Full cargo xtask precommit not run locally (shared disk nearly full); CI is the exact-head proof.

Not touched: ripr crate classification (#8600).


Generated by Claude Code

… deferral end to end (#8939)

Add a 90-minute total ceiling, summed from recorded attempt durations, to the
covered_by cargo lock-wait retry sequence. Exhausting it stops retrying and
reports the same covered_by_lock_wait_timeout instrument failure naming the
ceiling; a real non-lock timeout is unchanged.

Inject the policy gate and command runner into the precommit-v2 composition
(production passes the real ones) and add end-to-end tests: a deferred
instrument failure yields infrastructure_failure after the diff checks and
selected Clippy ran, and a real policy failure alongside it is not
classified as infrastructure.

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!

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

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 5 minutes.

Check out review usage here.

View limit details

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

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 7d61b252-0906-4a46-9ddb-d45c79697a20
📥 Commits

Reviewing files that changed from the base of the PR and between 7c770b1 and d0dac31.

📒 Files selected for processing: 2
  • xtask/src/policy/file_policy.rs
  • xtask/src/precommit_v2.rs

Summary by CodeRabbit

  • Bug Fixes

    • Lock-wait retries for file policy checks now stop after a 90-minute elapsed-time ceiling, in addition to the existing retry limit.
    • Timeout reporting now distinguishes lock-wait ceiling failures from other policy-check timeouts.
    • Infrastructure-related check failures are reported accurately while allowing remaining checks to run when appropriate.
  • Tests

    • Added coverage for lock-wait ceiling behavior, successful completion below the ceiling, timeout handling, and combined policy and infrastructure failures.

Walkthrough

The policy gate now limits cumulative covered-by lock-wait retries to 90 minutes and reports ceiling-triggered termination. Precommit composition now accepts injected policy and status runners. New tests cover how deferred instrument failures and combined policy and instrument failures affect execution and reporting.

Changes

Policy timeout and precommit classification

Layer / File(s) Summary
Cumulative lock-wait ceiling
xtask/src/policy/file_policy.rs, changelog.d/8939-covered-by-lock-wait-ceiling.md
Covered-by lock-wait retries stop at the existing six-attempt limit or the new 90-minute cumulative ceiling. Ceiling termination adds a diagnostic note and remains an instrument failure. Tests cover ceiling termination, completion below the ceiling, and unrelated timeouts.
Injected precommit composition and classification
xtask/src/precommit_v2.rs
run_composition delegates to run_composition_in with production dependencies. Policy, diff-check, and Clippy execution use injected callbacks. Tests verify that deferred instrument failures allow remaining checks to run and that combined policy and instrument failures stop later stages and remain source/policy failures.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Merge Risk: 🟡 Moderate · up to 7c770

The new precommit composition tests can fail on machines whose temp directory path contains a symlink, so they would not check the classification behavior there. Canonicalize the fixture root before merging.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description explains the implementation, tests, proof, and limitations, but it omits most required template sections, including scope classification, support-tier impact, policy impact, claim boun… Update the description to use the repository template. Add the missing required sections and complete each applicable field. Mark non-applicable sections explicitly, include the swarm/source-boundary confirmation, document scope and non-goa…
Docstring Coverage Warning Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 2 files. (1 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies both primary changes: the wall-clock cap for covered_by lock-wait retries and end-to-end proof for precommit-v2 deferral.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the implementation, tests, proof, and limitations, but it omits most required template sections, including scope classification, support-tier impact, policy impact, claim boundary, rollback, traceability, engineering checks, gates, and swarm/source-boundary details.

Resolution

Update the description to use the repository template. Add the missing required sections and complete each applicable field. Mark non-applicable sections explicitly, include the swarm/source-boundary confirmation, document scope and non-goals, provide rollback and traceability details, and list completed or skipped gates with results.

Full details: Docstring Coverage

Explanation

Docstring coverage is 73.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 2 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

A rabbit counts the lock-wait time,
Ninety minutes mark the line.
Notes record the ceiling reached,
Tests check each outcome preached.
Injected checks now run their part,
A carrot crowns the precommit chart.

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

coderabbitai[bot]

This comment was marked as resolved.

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

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • LOCK_WAIT_CEILING uses Duration::from_mins which is not a stable API in std; requires either the duration_from_mins unstable feature or Duration::from_secs(90*60) substitution. The diff is silent on the feature gate.

Verification questions

  • Confirm statusRunner<'a> lifetime ties the caller to a higher-ranked stack callback; verify no hidden ergonomic or ownership penalty beyond the two existing call paths.
  • Confirm codeRabbit flagged that fixture.path is not canonicalized before run_composition_in is invoked. drive_composition passes fixture.path directly, while production uses repository_root(). Risks symlink-relative path divergence in real check outputs.
  • Confirm duration::from_mins requires a type alias or import; the diff uses Duration::from_mins(90) at module scope without an explicit use. Need to confirm Duration is in scope or imported.
  • Confirm xtask/src/precommit_v2.rs:1973 — In drive_composition, call.starts_with("cargo clippy") shadows the closure binding calls because calls.iter().any(...) reads the outer calls Vec; verify the assertion sites (contains("-p a ") and the later-stage-any check) use the same calls Vec and not a different binding, otherwise the stand-in if program == "cargo" branch (which returns git --version) would skip recording the cargo clippy invocation entirely and 'cargo clippy' would never appear in calls.

Refuted

  • The composition-with-instrument-failure test might pass spuriously because the deferred result is reported even if the runner is never called (composition short-circuits on policy failure).; refuted because: Test pins diff_checks == 3 and calls.iter().any(c => c.starts_with("cargo clippy") && c.contains("-p a ")). With the runner injected only at the clippy slot and diff_checks assertion, a short-circuit would fail diff_checks == 3 and surface as a test failure, so this concern is refuted.
  • CodeRabbit suggested canonicalizing fixture.path before run_composition_in. The injected runner is the only filesystem-affecting dependency; root is read once and not used as a cwd by the runner closure. Real production path uses repository_root(). Source-route impact is null.
  • CodeRabbit finding at precommit_v2.rs:1967 claims root must be canonicalized before run_composition_in.; refuted because: In the new fixture, root is only used for path display strings through format_command; the injected status runner doesn't chdir or canonicalize. The documented fix would not change test behavior. Already answered in PR claims; current diff does not reopen.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • PR body states 'Full cargo xtask precommit not run locally; CI is the exact-head proof'; cargo-test receipt is still scheduled-late so exact-head CI witness is not yet on disk.

…tion fixture root (#8939)

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

Copy link
Copy Markdown
Member Author

Re the Duration::from_mins unstable claim: it has been stable since Rust 1.91, the repo MSRV is 1.95, and the change compiles and passes clippy/tests locally on 1.95.0. No change needed. Also in d0dac31: the >= ceiling comparison is now pinned by an exact-sum case (a > mutant fails it with "exact-ceiling sum was not exhausted: 4"), and the composition fixture root is canonicalized.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 20, 2026 03:04
@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!

@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 1 potential issue.

Devin Review

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