fix(cleanup): cap history lookups per query and catch stalled loads #1798
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.37) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 239 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.328
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #1798"
general
weight: 0.35
cpanato
Related to #1075
Follow-up to two non-blocking review notes on #1796. Nothing calls this code yet.
Cap history lookups per query (note)
lastChangedbuilt one query per batch of 50 repos, with onehistory(path:)field per policy, so a few repos with hundreds of policies could produce a query large enough to time out, and fail the same way every month. The lookups are now split into queries of at most 100 (historyPerQuery), regardless of how they're spread across repos. Cost doesn't change, about 1 point per 100 lookups.Catch loads that stalled recently (note)
When today has no rows, the day walk starts at yesterday, so a load that stalled early yesterday went unnoticed. The days query now also returns each day's last exchange.
History.Latestholds the newest one, andHistory.Startstays zero, whichDeciderefuses, whenLatestis more thanMaxStaleness(6 hours) old. The recorder loads every 15 minutes and the prober exchanges every few minutes, so 6 hours of silence means events stopped arriving. On staging the latest exchange was 14 minutes old.What this still doesn't catch: the recorder loads each region separately, so a stall in one region still leaves fresh rows from the others.
Testing
pkg/cleanupand 96.9% for the BigQuery package, with-race. Lint is clean.🤖 Generated with Claude Code