← Back to Pull requests

fix(ops): claiming and starting sweep expired leases #296

Closed
unknown closed this pull request without merging on Oct 30, 2026 15:59 UTC
View on GitHub
unknown unknown commented on Oct 29, 2026 21:26 UTC
Author

Plan: live finding from 5-sci-onboarding/03 (gate G3 — SCI's runner pool, consuming traust-sdk#44)

What

OpsService.requeue_expired existed but nothing called it in a deployed server: no REST door, no background loop — only tests swept. Found live: SCI's runner pool was killed mid-run on the dev cluster, the order's lease expired 4 minutes prior, and every subsequent claim returned an empty queue because claim only takes state == QUEUED.

Claim now re-queues expired leases in the same transaction as the claim itself — every pool's poll is the reaper. No timer infrastructure, no new endpoint, and a dead runner's order returns to the queue on the next claim from anyone.

Test: a dead runner's expired lease is re-queued and claimed by the next runner (test_claim_sweeps_a_dead_runners_expired_lease, with the live-finding context in a comment). Full suite: 7897 passed, 0 new failures (the pre-existing tree-sitter route and cosign-ledger failures on this laptop are unchanged).

Jira: XWING-2438 (SCI consumer)

---

Update: starting sweeps too (48ade88)

Shaun and Gurney's call after the live finding: requeue on start. The recording lane's start door had the same gap from the other side — a dead scan goroutine strands its order for the whole lease (start keeps the subject's open order and 409s while it is leased; nothing ever claims a recording order, so the claim sweep never sees it). start() now requeues expired leases in the same transaction, symmetric with claim(): every door sweeps, and either a claim or a start recovers a dead runner's order.

New test: test_start_takes_over_a_dead_runners_expired_lease.

Changed tests (sign-off wanted): test_start_never_steals_an_active_lease_or_bypasses_approval[leased] seeded its "active" lease from the fixed T0 (2026-10-05) while the context's clock is live — the lease was expired all along and the test passed vacuously (start never looked at expiry). It now seeds a genuinely-active expiry computed from now. The strict model-equality needed the microsecond field rounded (the column truncates to milliseconds). No assertion weakened: a genuinely-active lease still 409s and stays untouched.

Full suite: 7898 passed (one more than before — the new test); the pre-existing tree-sitter/cosign/tonic failures unchanged.

Diff: 291 lines (+218 / -73) across 3 files Reviewer: gurnben Review duration: 1112m
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.45 · 291 lines diff across 3 files
0.45
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.340
Shallow Review Depth shallow_review_depth
0.289
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #296"
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: 44.9% (MEDIUM) · Higher = larger blast radius
44.9%
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: 17.7% · Safe to merge
17.7%