Repository navigation
Description
Summary
BRC producer (refiner role in this case) can deadlock when reviewer ACKs arrive in the window between a returning mcp__brc__wait_loop call and the subsequent mcp__brc__wait_loop call. The producer ends up waiting forever on events that have already fired.
Observed on pipeline issue-1973 (refine phase, v2 re-proposal), reproducible without any user intervention.
Concrete timeline
Pipeline: issue-1973, refine phase, v2 proposal.
| Time (UTC) | Event |
|---|---|
| 18:20:55 | refiner sends CONSENSUS_PROPOSE (v2), then immediately calls mcp__brc__wait_loop(for_types=[CONSENSUS_ACK, CONSENSUS_NACK, CONSENSUS_RE_REVIEW, OVERSEER_ALERT]) |
| 18:20:59 | wait_loop #1 begins blocking |
| 18:21:21 | reviewer_agent_design sends CONSENSUS_ACK |
| 18:21:21 | wait_loop #1 returns with the reviewer_agent_design ACK |
| 18:21:24 | reviewer_refine sends CONSENSUS_ACK (during the ~3 s window between calls) |
| 18:21:25 | refiner calls wait_loop #2 for the remaining ACK |
| 18:21:25+ | wait_loop #2 blocks — and never returns. The reviewer_refine ACK that landed 1 s earlier is not delivered |
| 18:20:00 | (earlier) reviewer_refine sent CONSENSUS_CONFIRMED |
| 18:18:14 | (earlier) reviewer_agent_design sent CONSENSUS_CONFIRMED |
| … | consensus view: both reviewers reviewer_phase=CONFIRMED, refiner stuck in producer_phase=PROPOSED |
| 18:26:54 | overseer raises `orchestrator-consensus-silent [medium]` |
| 18:29:33 | overseer escalates to `[high]` |
| 18:32:02 | manual send_message(type=STATUS, to=refiner) nudge from overseer role — ignored, since STATUS is not in the wait_loop filter set |
The consensus snapshot at the time of the nudge:
```json
{
"agents": {
"refiner": {"confirmed": false, "producer_phase": "PROPOSED"},
"reviewer_agent_design": {"confirmed": true, "reviewer_phase": "CONFIRMED"},
"reviewer_refine": {"confirmed": true, "reviewer_phase": "CONFIRMED"}
},
"blocking_agents": ["refiner"],
"is_complete": false,
"protocol": "brc"
}
```
Root cause (hypothesis)
mcp__brc__wait_loop appears to use a wait-start timestamp (or equivalent cursor snapshot taken at call time) as its lower bound for event matching, rather than threading a monotonic cursor across successive calls. Any event that fires in the gap between `wait_loop#N returns` and `wait_loop#(N+1) begins` is lost for that consumer.
This is the same class of bug that host-side wait_for_status_change already solved by having callers thread the returned cursor into the next call's since parameter (see docs/reference/agent-wait-patterns.md §7). The agent-side mcp__brc__wait_loop needs the same contract.
Impact
- Any BRC producer that re-enters
wait_loopafter a partial result (e.g. waiting for a subset of reviewers, then looping for the rest) is at risk. - More likely on re-review cycles (v2+) where reviewers often respond in quick succession because the diff is small.
- Deadlock is silent from the producer's perspective — the
consensusendpoint correctly shows `is_complete: false` but gives no hint the producer has lost events. - Overseer detects the symptom (`orchestrator-consensus-silent`) but cannot recover it:
STATUSnudges don't wake the stuck wait, and the producer never emitsCONSENSUS_CONFIRMEDon its own.
Reproduction
Happened unprompted on issue-1973 refine phase v2 with the default roster (refiner, reviewer_refine, reviewer_agent_design). Likely race-dependent but the gap is only ~3 s, so it is not rare.
Suggested fixes
- Cursor threading — have
mcp__brc__wait_loopreturn a cursor and accept asinceparameter, matching thewait_for_status_changecontract. Agents pass the previous response's cursor into the next call so no events can slip through the gap. - Alternative / complement: state snapshot at call time — when the agent calls
wait_loop, first check the consensus/message state synchronously and return immediately if the desired events have already occurred (i.e. don't block at all when the answer is already in the log). - Recovery path — add a
STATUSmessage type (or equivalent) to the wait_loop filter so an operator nudge can unblock a stuck producer without restarting the container.
(1) is the real fix; (2) is a defensive cheap win; (3) is a safety net.
Observability notes
get_container_logs(agent_role=refiner) shows the producer sitting in mcp__brc__wait_loop with no further tool calls after the bad wait started. A future improvement could be to log the since/cursor each wait_loop invocation sends, so this class of bug is trivial to spot from logs.
Related
docs/reference/agent-wait-patterns.md§7 — the host-sidewait_for_status_changealready uses cursor threading./.claude/skills/sdlcmonitoring logic explicitly mentions the "wait→wait race window" that cursor threading closes for host-side waits. The agent-sidemcp__brc__wait_loopcurrently lacks this.
Activity
Fix #1995: thread cursor through BRC wait endpoint to close wait→wait…
Fix #1995: thread cursor through BRC wait endpoint to close wait→wait…
Fix #1995: thread cursor through BRC wait endpoint to close wait→wait…
Fix #1995: thread cursor through BRC wait endpoint to close wait→wait…
Make `make test` changeset-aware via grimp + sidecar LKG (#2042)
Fix #1995: thread cursor through BRC wait endpoint to close wait→wait…
Make `make test` changeset-aware via grimp + sidecar LKG (#2042)
architect(plan #2908 v2): address reviewer_plan + risk_analyst NACKs