โ† Back to Pull requests

๐Ÿ› fix(manager): a gate pass longer than the lease keeps its task #175

Closed
unknown closed this pull request without merging on Oct 22, 2026 21:00 UTC
View on GitHub
unknown unknown commented on Oct 22, 2026 20:13 UTC
Author

Why

The first erp-backend night (S-0003, width 2) hit this. T-0001's gate pass ran 21 minutes on a cold seat: uv sync and image pulls in nested dind, then unit, quality and e2e. The pass records nothing between attempt.finished (18:37:38Z) and gates.evaluated (18:58:28Z). expired() counts only recorded facts against LEASE_SECONDS = 900, so at 18:52:44Z the second worker's pass:

1. released T-0001 (lease expired; last held by erp-1),
2. claimed it,
3. was refused (T-0001 has an existing run in state gated),
4. escalated it gate_infrastructure_failure.

The first worker then gated it green and landed it anyway, so the escalation needed a person to close it (manager resolve --resolution landed).

What

  • gates/runner.py: the gate list run_gates builds becomes battery(ctx, only). The new battery_budget(gates, ctx) is the pass's upper bound: each gate's timeout (600 s for a shell gate without one), twice because a failed command runs once more (run_command), and once per command for acceptance. A gate whose paths the attempt did not touch is left out, as run_gates skips it.

  • New fact gates.started (attempt, budget_s), written by the worker and relayed like the other attempt facts. The runner records it just before run_gates.

  • manager.py: TaskView.quiet_until holds the end of the silence a pass announced. Only the next change of state clears it, so a late burn or promotion cannot cut the pass short. The new lease_ends(view, window) counts from the later of the last fact and that end, and expired() and the night-opening report (S-0089/D-3) both use it. stalled() no longer marks a pass within its budget as wedged.

  • Docs authority table, changelog entry under Unreleased.
  • The lease still counts facts, not a heartbeat (S-0044/D-6, LOCKED): a worker that dies mid-pass loses the task once the budget has passed too.

    Tests

  • test_a_battery_budget_bounds_every_command_and_its_rerun

  • test_a_gate_pass_keeps_its_lease_for_the_budget_it_announced

  • test_a_gate_pass_within_its_budget_is_not_stalled

  • test_manager_e2e (real Postgres and Docker): each pass records gates.started before gates.evaluated, with a positive budget.

  • Full suite green locally; ruff check, ruff format --check and mypy src are clean.
  • ๐Ÿค– Generated with Claude Code

    https://claude.ai/code/session_01X5XatXv3dQLan6TyQoHFyF

    Diff: 303 lines (+227 / -76) across 3 files Reviewer: Misery7100 Review duration: 46m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) ร— (1 โˆ’ Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 ยท Change Risk (XGBoost)
    Score: 0.40 ยท 303 lines diff across 3 files
    0.40
    Model 2 ยท Review Depth (DistilBERT)
    Depth Score: 0.17 ยท 1 substantive comment(s)
    0.17
    Model 3 ยท Review Timing & Attention
    Session adequacy: 100% ยท Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 ยท Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 ยท Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.342
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #175"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk ยท Model 1 (XGBoost)
    Predicted defect probability (0.00โ€“1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 40.1% (MEDIUM) ยท Higher = larger blast radius
    40.1%
    Review Confidence
    Review Confidence ยท Models 2 & 3
    Scrutiny score (0.00โ€“1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% ยท Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk ยท Core Equation
    Residual = Change ร— (1 โˆ’ Confidence)
    Unmitigated risk surviving review. โ‰ฅ 0.65 triggers an automated re-queue to protect production.
    Score: 15.8% ยท Safe to merge
    15.8%