test(stall): measure the whole-tick session-rows pin with nothing else in the window (#4285 item 3) #4347
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.43) × (1 − Review Confidence (0.42)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 384 lines diff across 4 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 81% · 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.356
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #4347"
general
weight: 0.35
claude[bot]
Refs #4285. This PR builds item 3 only, the live main flake, first and alone as the gate allows (Xanthos, CHECKED, AT0.7838). Items 1, 2, 4 and 5 follow in a separate PR, so #4285 stays open. Test-only: one file,
src/lib/agentTasks/stallPassCost4273.test.ts, with no production change.Cause
The whole-tick pin ("a settled whole tick reads the same session rows with 10 ended sessions per worker as with 400") counts
sessionsreads inpg_stat_user_tables. That view covers every backend on the database, and a backend publishes its counters late: an idle one on a timer, an exiting one as it exits. The old check waited for "two equal reads 600 ms apart", which a late flush outlasts. So a read that one of the test's own pool connections made before the window could land inside it. Main's failures read 1484 (run 43859882551) and 1256 (run 43964497842).Reproduced, deterministically. A new pin makes the pool read all 1,200 history rows just before the window. With the pre-#4285 single measurement it fails 3 of 3, reading 1257 (1,200 history rows plus the tick's own reads, the same figure as run 43964497842). Main's current minimum-of-three (2eed1bc7d) masks this, which fits the fact that it hasn't failed since. It isn't safe either, though: a late flush also leaves its own window short, so the minimum can be wrongly low.
Fix
The window now holds exactly one tick's reads:
1. The shared pool (
db) is disconnected first, so its backends exit and publish what they read.2. The tick runs on its own client, tagged by
application_name, and is disconnected after.3. A raw
pgpoller, which reads onlypg_statviews and neversessions, waits until every other client backend has left the database and the counter holds still, before and after the tick. If a backend is still there, the measurement refuses and names it instead of counting it. That would also catch the tick reconnecting the shared pool.The minimum-of-three is removed, since each measurement is now exact. Vacuity guards (issue item 3): the whole-tick baseline must be above zero, and so must the two per-transaction pins' reads of the open set (task rows, and alarm-key rows).
Pins and mutants
| Pin | Old (single) | Old (min of 3, main) | This head |
|---|---|---|---|
| whole-history pool read just before the window is not counted | red 3/3, 1257 | green (masked) | green |
| a reader still connected makes the measurement refuse, by name | n/a | n/a | green |
Mutants, each killed:
52instead of refusing.Stability: the whole file passed 10 of 10 back-to-back runs locally (18/18 each).
check-loc-scopeis clean.— Byron, Server Engineer · Claude/Anthropic (Opus 5.5)
🤖 Generated with Claude Code