Skip to content

Gate the simplifier's first propose on its upstream producer (#3603) - #3607

Merged
jwbron merged 1 commit into
mainfrom
egg/issue-3603/wake-only-first-propose-gate
Jul 25, 2026
Merged

jwbron merged 1 commit into
mainfrom
egg/issue-3603/wake-only-first-propose-gate

Conversation

@jwbron

@jwbron jwbron commented Jul 25, 2026

Copy link
Copy Markdown
Owner

What

Makes the #3478 first-propose gate honour wake_only edges, so the de-roled simplifier derives wait until 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.

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 (tester gated on coder, risk_analyst gated on architect + 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_only means "casts no verdict", not "no dependency". The edge exists precisely because the companion is written against the upstream producer's draft. _pre_propose_upstream_producers now includes wake-only edges in the upstream set:

Phase Role Gated on
refine simplifier refiner
plan simplifier task_planner
plan risk_analyst architect + task_planner (unchanged)
implement tester coder (unchanged)

The wake becomes level-triggered on the derivation: the first poll that sees the upstream's proposal derives propose and spawns the arm. No spawn before that → no no-op → no streak → no park → no mis-targeted alert.

Everything else about wake_only is untouched — still excluded from _has_pending_peer_proposals and the reviewer confirm guards, so the simplifier is never assigned a spawn-able ack it cannot satisfy (the #3381 regression) and still confirms without ever voting. Pinned by test_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:

  • lifts on the upstream's first proposal of any kind (current, withdrawn, or no-changes);
  • dissolves entirely when the upstream is excused — excuse_producer removes 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;
  • a crashed upstream resolves via supervision / HITL exactly as for the tester and risk_analyst gates.

Secondary effect, in the right direction: a wait role is exempt from _check_convergence_stall, so the simplifier also stops generating stuck-phase-transition anomalies 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. Wiring waiting_on heartbeat 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 same WAITING_ON_ROLE heartbeat 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."

  • Escalation already exists and is what produced the log line quoted in the issue: _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_parked raises an event-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 by orchestrator/tests/test_arms_parked_stall.py.
  • Not parking the sole producer would reinstate the unbounded respawn loop in the case where pods are most expensive, and the issue itself notes respawning unchanged cannot converge.
  • A forced immediate probe is not safely bounded by the existing latches: a probe spawn repopulates _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: two tests/scripts/test_reap_stale_egg_images.py cases (shell script exits 127 — missing container CLI in the sandbox) and two WORKTREE_BASE_DIR / is_repos_parent_directory path assertions in gateway/tests/test_git_client.py + orchestrator/tests/test_per_slice_brc_commit.py.

make lint clean.

New / revised tests in orchestrator/tests/test_consensus_next_action.py:

Test Pins
test_next_action_wake_only_upstream_gates_first_propose the gate fires and lifts on the upstream's proposal (replaces ..._never_gates)
test_wake_only_simplifier_woken_to_propose_by_upstream_proposal the revised wake: repeated pre-proposal derivations stay wait (was: stay propose)
test_next_action_wake_only_edge_still_casts_no_verdict #3381 not re-rolled — no spawn-able ack, no verdict
test_next_action_mutual_wake_only_producers_do_not_deadlock acyclicity under mutual wake-only edges
test_next_action_refine_phase_simplifier_gated_on_refiner the real refine graph — the 4/4 reproduced shape
test_next_action_plan_phase_simplifier_gated_on_task_planner the real plan graph; architect's proposal alone does not lift it
test_next_action_wake_only_gate_dissolves_when_upstream_excused liveness under excuse_producer

Docs

docs/architecture/orchestrator.md (first-propose gate) and docs/reference/agent-roles.md (simplifier) both described the old poll-loop wake; updated.

Closes #3603

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.

@egg-reviewer egg-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@james-in-a-box

This comment has been minimized.

@jwbron

jwbron commented Jul 25, 2026

Copy link
Copy Markdown
Owner Author

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.

@egg-reviewer egg-reviewer Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@james-in-a-box

This comment has been minimized.

@james-in-a-box

Copy link
Copy Markdown
Contributor
egg is addressing review feedback...

@james-in-a-box

Copy link
Copy Markdown
Contributor

Review feedback dispositions

Both automated reviews (agent-mode-design, review) approved with no NACKs, no line-level comments, and no change requests. There is exactly one substantive item to disposition.

1. agent-mode-design — "No agent-mode design concerns" (APPROVED) — disagree (nothing to action). No feedback to address.

2. review — non-blocking observation: "Plan companion is gated on task_planner only, not architect. Worth confirming the plan companion genuinely doesn't need architect's design draft to be meaningful." — disagree (confirmed correct; no change needed).

Confirmed — the plan companion does not need architect's design draft, so the single simplifier → task_planner wake-only edge is the right modeling and no second edge to architect is warranted:

  • The simplifier is a producer whose sole job is a plain-language, human-focused companion to the upstream producer's draft — for the plan phase that upstream draft is task_planner's plan (orchestrator/routes/pipelines/_prompt_phase.py:993-1015: "SYNC the worktree, read the draft, then write and PROPOSE the human-focused companion"). The artifact it summarizes is the plan, i.e. task_planner's output — so the gate correctly orders it on the exact producer whose draft it reads.
  • architect's design is upstream of task_planner's plan (the plan is authored against the design), so by the time task_planner has proposed a plan draft the design already exists in the worktree and is available to the simplifier for context. The companion needs task_planner's draft to exist before it can start; it does not need a separate ordering barrier on architect.
  • This is pre-existing modeling — the simplifier → task_planner wake-only edge predates this PR (the review itself notes it is "a faithful continuation of the pre-existing graph modeling … so it's not a regression"). This PR only changes how a wake-only edge gates first-propose; it does not introduce or alter which producer the plan simplifier is gated on.
  • The observation was explicitly flagged non-blocking and "for a future graph-modeling decision." Were a design need for architect to surface later, the acyclicity/terminal machinery here already handles a multi-upstream gate (as risk_analyst demonstrates), so adding a second wake-only edge would be a one-line change at that point — no groundwork is missing.

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

@james-in-a-box

Copy link
Copy Markdown
Contributor

egg feedback addressed. View run logs

2 previous review(s) hidden.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

noop-streak park fires on correctly-blocked agents and can starve the only path to progress

1 participant