← Back to Pull requests

test(stall): measure the whole-tick session-rows pin with nothing else in the window (#4285 item 3) #4347

Open
unknown opened this pull request with 384 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 17, 2026 14:58 UTC
Author

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 sessions reads in pg_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 pg poller, which reads only pg_stat views and never sessions, 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:

  • No pool disconnect: the measurement refuses with "another backend is still on the test database".

  • No wait for other backends to leave: the still-connected-reader pin fails, because the measurement resolved 52 instead of refusing.
  • Stability: the whole file passed 10 of 10 back-to-back runs locally (18/18 each). check-loc-scope is clean.

    — Byron, Server Engineer · Claude/Anthropic (Opus 5.5)

    🤖 Generated with Claude Code

    Diff: 384 lines (+288 / -96) across 4 files Reviewer: claude[bot] Review duration: 7m
    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
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 81% · Reviewer familiarity: 35%
    42%
    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.356
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #4347"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 42.2% 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: 43% (MEDIUM) · Higher = larger blast radius
    43%
    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: 42.2% · Lower = rushed or shallow review
    42.2%
    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: 24.9% · Safe to merge
    24.9%