Repository navigation
Gate the simplifier's first propose on its upstream producer (#3603) - #3607
Conversation
The #3478 first-propose gate defers a producer's first `propose` while every producer it depends on is still pre-first-propose, because spawning at that state can only orient-and-exit — and three such clean exits burn the #3425 no-op streak and park the arm. It exempted `wake_only` edges, on the theory that the de-roled simplifier (#3381) is woken by its own propose arm re-spawning until the upstream draft appears. That wake mechanism is a poll loop of clean no-op exits, which is exactly what the #3425 park counts. #3595 root cause 2 reproduced the resulting mis-park 4/4 across the assessment series, in both the refine and plan phases: the simplifier reported WAITING_ON_ROLE on its upstream, declined to fabricate a companion for a draft that did not exist, exited clean three times, and was parked with a [high] `agent-invocation-noop-streak` alert pointing at the correctly-behaving agent — while its own prompt tells it "you begin writing only once that producer issues CONSENSUS_PROPOSE ... do not race ahead before the draft exists". `wake_only` means "casts no verdict", not "no dependency": the edge exists precisely because the companion is written against the upstream producer's draft. So the gate now includes wake-only edges in the upstream set. The simplifier derives `wait` until its upstream proposes and is spawned by the first poll that sees the proposal, so there is no no-op streak to park and no wedge-shaped alert to mis-target. Nothing else about `wake_only` changes: it stays excluded from pending-review derivation and the confirm guards, so the simplifier is still never assigned an `ack` it cannot satisfy (#3381). Terminality (the acyclicity guard) is now judged over the same edge set the upstream computation uses. Judging it over review-bearing edges only would call each half of a mutual wake-only pair terminal, gate both, and wedge the phase — a deadlock the old exemption hid rather than solved. Behaviour change is confined to the simplifier: no other role in the default refine/plan/implement graphs has a wake-only edge, and the tester / risk_analyst gates are unaffected. Liveness is unchanged in kind: the gate holds only while an ungated terminal producer is pre-propose, lifts on its first proposal (current, withdrawn, or no-changes), and dissolves entirely when the upstream is excused (`excuse_producer` removes every edge targeting it, wake-only included) — now covered by a regression test, since before this change the simplifier polled regardless and could not be stranded.
There was a problem hiding this comment.
No agent-mode design concerns.
This change is confined to orchestrator scheduling logic — the BRC next-action derivation that gates the simplifier's first propose on its upstream producer (_pre_propose_upstream_producers in orchestrator/routes/consensus.py, the wake_only edge semantics in review_graph.py, and their tests/docs). It touches none of the agent-mode surfaces: no prompt assembly, no pre-fetched diffs/logs baked into a prompt (_prompt_phase.py is only cited in a comment, not modified), no human-facing structured-output requirement, no post-processing pipeline, no hardcoded model IDs, and no direct Anthropic API calls. The wait / waiting_on_producers payloads are orchestrator-to-orchestrator control flow, not agent output.
— Authored by egg
This comment has been minimized.
This comment has been minimized.
|
Follow-ups filed for the two parts of #3603 this PR deliberately leaves alone:
"Closes #3603" still stands: the reproduced 4/4 case is fixed here, and neither follow-up is a regression introduced by this PR. |
There was a problem hiding this comment.
Review: Gate the simplifier's first propose on its upstream producer (#3603)
Verdict: Approve. No blocking issues after tracing the change end-to-end across all three default graphs, the custom mutual-wake-only case, and the liveness/escalation paths. This is a tight, well-reasoned fix with strong test coverage.
What I verified
Core logic (_pre_propose_upstream_producers) is correct. The change makes wake_only edges count as ordering dependencies (included in the upstream set) while the terminal check (_reviews_peer_producers → _has_upstream_producers) is judged over the same edge set. I confirmed the internal consistency argument holds: a gated role always has ≥1 terminal (structurally ungated) upstream, so the waits-on relation stays acyclic and every gate lifts on the terminal's first proposal.
No regression to the pre-existing gates. I ran the old vs. new terminal determination over get_default_{refine,plan,implement}_graph(). The result is byte-identical for tester (gated on coder), risk_analyst (gated on architect+task_planner), and the terminals — the only newly-gated role is the simplifier (refine→refiner, plan→task_planner), exactly as claimed. The _reviews_peer_producers→_has_upstream_producers refactor is safe for the default graphs.
No re-roll of #3381. The wake-only exclusion is preserved where it must be: _has_pending_peer_proposals (consensus.py:191) and the confirm guard (action_guards.py:457) both still call wake_only_producers_for. I traced test_next_action_wake_only_edge_still_casts_no_verdict's claim through the PROPOSED branch → reviewer block → _has_pending_peer_proposals and confirmed the simplifier derives wait, never a spawn-able ack.
Liveness holds. excuse_producer (_recovery.py:208) removes edges via reviewers_for, which includes wake-only edges, so excusing refiner/task_planner genuinely dissolves the gate — the ..._gate_dissolves_when_upstream_excused test is load-bearing and correct.
No false wedge signal. wait is not in SPAWN_ACTIONS, so the gated simplifier neither counts toward _check_arms_parked (_loop.py:426) nor is flagged by _check_convergence_stall (_loop.py:878, explicit action == "wait" exemption). At phase start the terminal producer (refiner/architect+task_planner) still derives propose, so there is always a live arm — no all-arms-parked at t=0.
Tests exercise the production path. All new tests drive the real get_default_*_graph() through real handle_propose/handle_ack/handle_confirmed and the real /consensus/next-action route — no hand-built fixtures bypassing the derivation, no self-seeded goldens. The name↔behavior contracts match (e.g. ..._gates_first_propose asserts wait then propose-on-upstream-proposal).
Non-blocking observation
Plan companion is gated on task_planner only, not architect. test_next_action_plan_phase_simplifier_gated_on_task_planner correctly pins that architect's proposal alone does not lift the gate, and the PR body flags this as intentional (the wake-only edge models task_planner). This is a faithful continuation of the pre-existing graph modeling (the simplifier→task_planner wake-only edge predates this PR), so it's not a regression. Worth confirming the plan companion genuinely doesn't need architect's design draft to be meaningful — if it does, the fix is to add a second wake-only edge to architect, and the acyclicity/terminal machinery here already handles a multi-upstream gate correctly (as risk_analyst demonstrates). Not blocking; just flagging the design boundary for a future graph-modeling decision.
— Authored by egg
This comment has been minimized.
This comment has been minimized.
| egg is addressing review feedback... |
Review feedback dispositionsBoth automated reviews ( 1. 2. Confirmed — the plan companion does not need
No code changes were required; nothing to commit. Note (informational, not a review item): the two parts of #3603 this PR deliberately leaves alone are already tracked in #3608 and #3610, per the PR author's earlier comment. — Authored by egg |
|
egg feedback addressed. View run logs 2 previous review(s) hidden. |
What
Makes the #3478 first-propose gate honour
wake_onlyedges, so the de-roledsimplifierderiveswaituntil its upstream producer proposes instead of polling into the #3425 no-op park.Fixes the reproduced half of #3603 (= #3595 root cause 2). See "What this does not do" for the rest.
Why
The park's defect, stated precisely: repeated clean no-op exits are the simplifier's specified wake mechanism, and the park counts exactly those exits. Two subsystems contradict each other and the park wins.
ReviewEdge.wake_only(review_graph.py) documented the wake as "a WORKING producer re-derivesproposeon every event-loop poll, and a clean orient-and-exit ... frees the spawn-dedupe key, so the orchestrator re-spawns it until it proposes."JobSupervisor.record_success([orchestrator/event-loop] Unbounded agent re-spawns against a slice wedged on unresolved HITL (cq-N): successful no-op invocations never park (~50 spawns observed) #3425) parks an arm after 3 clean completions with no BRC progress and firesagent-invocation-noop-streak [high]._prompt_phase.py) tells it: "you begin writing only once that producer issuesCONSENSUS_PROPOSE... Do not race ahead before the draft exists."So the agent obeys its prompt, the derivation spawns it anyway, and the supervisor parks it for obeying. #3595 reproduced this 4/4, prompt-independent and phase-independent (5, ~13, ~14 min into three refine phases; ~3 min into a plan phase). The wedge precondition is satisfied by correct behaviour on the common path — the opening state of every BRC phase.
#3478 already built the right mechanism for this exact shape (
testergated oncoder,risk_analystgated onarchitect+task_planner) and its docstring names the failure it prevents: "three such no-ops burn the #3425 streak and park the arm". It exempted wake-only edges, so the one role whose entire job is "wait for the upstream draft" was the one role left polling.The change
wake_onlymeans "casts no verdict", not "no dependency". The edge exists precisely because the companion is written against the upstream producer's draft._pre_propose_upstream_producersnow includes wake-only edges in the upstream set:simplifierrefinersimplifiertask_plannerrisk_analystarchitect+task_planner(unchanged)testercoder(unchanged)The wake becomes level-triggered on the derivation: the first poll that sees the upstream's proposal derives
proposeand spawns the arm. No spawn before that → no no-op → no streak → no park → no mis-targeted alert.Everything else about
wake_onlyis untouched — still excluded from_has_pending_peer_proposalsand the reviewer confirm guards, so the simplifier is never assigned a spawn-ableackit cannot satisfy (the #3381 regression) and still confirms without ever voting. Pinned bytest_next_action_wake_only_edge_still_casts_no_verdict.Acyclicity guard fixed alongside. Terminality is now judged over the same edge set the upstream computation uses. Judging it over review-bearing edges only would call each half of a mutual wake-only pair terminal, gate both, and wedge the phase with no producer able to move — a deadlock the old exemption hid rather than solved. Pinned by
test_next_action_mutual_wake_only_producers_do_not_deadlock.Blast radius: the simplifier only. No other role in the default refine/plan/implement graphs carries a wake-only edge.
Liveness
Unchanged in kind from #3478 — the gate holds only while an ungated terminal producer is pre-propose:
excuse_producerremoves every edge targeting it, wake-only included. This is newly load-bearing (before, the simplifier polled regardless and could not be stranded), so it now has a regression test;testerandrisk_analystgates.Secondary effect, in the right direction: a
waitrole is exempt from_check_convergence_stall, so the simplifier also stops generatingstuck-phase-transitionanomalies that pointed at it while the upstream was the actual problem.What this does not do (#3603 remainder)
Suggested fix 1 — "do not park a role whose heartbeat names an unsatisfied upstream producer in
waiting_on." Fixed at the derivation layer instead of the supervisor layer, deliberately. Wiringwaiting_onheartbeat metadata into the park decision would invert_role_waiting_status's fail-safe direction: it is documented (#3520) so that a stale or unreadable self-report can only make the alert more alarming, never quieter, because a genuinely wedged-but-polite agent emits the sameWAITING_ON_ROLEheartbeat as a correctly-blocked one. As a spawn gate, a false or stale positive would suppress the park indefinitely and restore the ~50-pod respawn storm #3425 exists to stop. The tracker already holds the dependency deterministically, so the ordering fix needs no heuristic and costs zero pods.That leaves a residual: a role correctly blocked on a dependency the review graph does not model can still park. In the default graphs there is no such role — every downstream-producer relationship is an edge, and all three are now gated. A custom graph that omits an edge would still be exposed; the fix there is to model the edge.
Suggested fix 2 — "never park the sole remaining producer, or force an immediate probe plus escalation."
_check_arms_parked(BRC ack accepted but not visible in slice tracker; no-op-parked rounds stall silently; restart_agent delegated respawn never fires #3548) fires on the first poll where every derivable spawn arm is blocked with nothing in flight, and_handle_arms_parkedraises anevent-arms-parked [high]OVERSEER_ALERT and persists a HITL decision whose "Retry arms" option releases the parks in-band. That is ~5s after the wedge forms, not 1800s. Covered byorchestrator/tests/test_arms_parked_stall.py._live_keys, which clears the wedge condition, which resets the sticky latch, so the next no-op re-parks and re-triggers the forced probe — a 5s-cadence spawn loop. Bounding it needs a separate per-episode counter; that is a real design decision, not a drive-by, and the escalation above already gives the operator the signal within one poll.Happy to split either into its own issue if you'd rather have them tracked separately.
Testing
make test(full suite, 22,014 passed). 4 pre-existing local-environment failures, none reachable from this diff: twotests/scripts/test_reap_stale_egg_images.pycases (shell script exits 127 — missing container CLI in the sandbox) and twoWORKTREE_BASE_DIR/is_repos_parent_directorypath assertions ingateway/tests/test_git_client.py+orchestrator/tests/test_per_slice_brc_commit.py.make lintclean.New / revised tests in
orchestrator/tests/test_consensus_next_action.py:test_next_action_wake_only_upstream_gates_first_propose..._never_gates)test_wake_only_simplifier_woken_to_propose_by_upstream_proposalwait(was: staypropose)test_next_action_wake_only_edge_still_casts_no_verdictack, no verdicttest_next_action_mutual_wake_only_producers_do_not_deadlocktest_next_action_refine_phase_simplifier_gated_on_refinertest_next_action_plan_phase_simplifier_gated_on_task_plannerarchitect's proposal alone does not lift ittest_next_action_wake_only_gate_dissolves_when_upstream_excusedexcuse_producerDocs
docs/architecture/orchestrator.md(first-propose gate) anddocs/reference/agent-roles.md(simplifier) both described the old poll-loop wake; updated.Closes #3603