test(worker): force the restart's reservation on its own lock turn #6037
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 324 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: 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.346
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #6037"
general
weight: 0.35
claude[bot]
Description
Problem
The KV event monitor's replacement-race test passed on the ordering it was written against. That ordering unlocked the slot and removed by URL on a later turn, which could take a stream another add started in between. One poll crossed both turns, so the old ordering reserved the slot too under the test's single poll.
Solution
The test holds the lock when the restart is first polled and queues a read of the slot behind the restart's turn. The lock is fair, so the read runs the moment that turn ends and finds the reservation. Under the old ordering it finds the stream still active. The race then runs to its end under timeout guards: a third object takes the stream while the restart waits, and the restart leaves it. Two doc lines read right again.
Changes
model_gateway/src/worker/kv_event_monitor.rs: the forcing test and a test-only slot reader usable under a held lock, moved belowstop.model_gateway/src/app_context.rs: the monitor's doc namesstart_kv_streamas the chooser of a worker's stream kind for both workflows.Test Plan
cargo test -p smg --lib worker::kv_event_monitor: 108 passed, three runs.cargo test -p smg --lib: 4571 passed. Clippy and rustdoc clean with warnings denied.Numbers
| mutant of the restart arm | before | after |
|---|---|---|
| unlock, then remove by URL on a later turn | none red | one test red |
| the registry read by URL, not by object | none red | one test red |
The module's tests under each mutant, on the old test and on the new one. No production code changes.
Release note
The KV event monitor's replacement-race regression test now fails on the ordering it guards against, and two doc lines read right.