Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 25 additions & 16 deletions docs/architecture/orchestrator.md
Original file line number Diff line number Diff line change
Expand Up @@ -822,22 +822,31 @@ re-derives `next-action` once before invoking the agent so a pod spawned
against an event that another actor has already superseded falls through to
a no-op rather than acting on stale state.

**First-propose gate ([#3478](https://github.com/jwbron/egg/issues/3478)):**
a dual-role producer builds on the artifacts of the producers it reviews.
This is phase-agnostic — in the default implement graph it is the `tester`
(producer of tests, reviewer of the `coder`); in the default plan graph it
is the `risk_analyst` (producer of the risk register, reviewer of
`architect` + `task_planner`). While every one of those upstream producers
is still pre-first-propose (WORKING at proposal version 0), the derivation
returns `wait` instead of `propose`; spawning at
that state could only orient-and-exit, burning the #3425 no-op streak and
parking the arm. The gate lifts on the upstream's first proposal (the next
poll tick derives `propose`; the #2749 R11a propose-own-work-first ordering
is unchanged from that point). Wake-only edges are exempt (the de-roled
simplifier is deliberately woken by its own propose arm), and the gate only
engages when at least one upstream producer is terminal (reviews no
producers itself), so cyclic custom graphs cannot mutually `wait` into a
deadlock. See `_pre_propose_upstream_producers` in
**First-propose gate ([#3478](https://github.com/jwbron/egg/issues/3478),
[#3603](https://github.com/jwbron/egg/issues/3603)):** a producer that sits
downstream of another producer builds on that producer's artifact. This is
phase-agnostic — in the default implement graph it is the `tester` (producer
of tests, gated on the `coder`); in the default plan graph the `risk_analyst`
(producer of the risk register, gated on `architect` + `task_planner`) and the
`simplifier` (producer of the human companion, gated on `task_planner`); in
the default refine graph the `simplifier` again (gated on the `refiner`).
While every one of those upstream producers is still pre-first-propose
(WORKING at proposal version 0), the derivation returns `wait` instead of
`propose`; spawning at that state could only orient-and-exit, burning the
#3425 no-op streak and parking the arm. The gate lifts on the upstream's
first proposal (the next poll tick derives `propose`; the #2749 R11a
propose-own-work-first ordering is unchanged from that point).

The upstream set is every producer edge the role has, **including `wake_only`
edges**: `wake_only` means "casts no verdict" (#3381), not "no dependency".
#3478 originally exempted them, leaving the de-roled `simplifier` to poll —
re-deriving `propose` every tick and orienting-and-exiting until the upstream
draft appeared — which is exactly what the #3425 park counts; #3595 root cause
2 reproduced the resulting mis-park 4/4 across the refine and plan phases,
alerting `[high]` at the correctly-behaving agent. The gate only engages when
at least one upstream producer is terminal (has no upstream producers itself),
judged over that same edge set, so cyclic custom graphs cannot mutually `wait`
into a deadlock. See `_pre_propose_upstream_producers` in
`orchestrator/routes/consensus.py`.

**No-op park release delta ([#3537](https://github.com/jwbron/egg/issues/3537)):**
Expand Down
2 changes: 1 addition & 1 deletion docs/reference/agent-roles.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ The label↔hook match is a single source of truth (`FIRST_PRINCIPLES_*_OPTION`

**Purpose**: Produce a **human-focused companion** to the agent draft — a plain-language summary for a **broad audience (engineers, PMs, and managers)**, readable by a non-engineer, free of egg-internal jargon and implementation minutiae (no `file:line` refs or code identifiers). It **summarises** the draft — it does not review or critique it (no ACK/NACK or constraint-list framing in the companion). Runs in **both** the refine and plan phases. The agent-focused drafts (`-analysis.md` / `-plan.md`) are unchanged; the companion is an additional, mandatory artifact.

**Producer only** (#3381): the simplifier produces its companion and casts no verdict on anyone. It retains a **wake-only** advisory edge over the upstream producer (`refiner` in refine, `task_planner` in plan) as a structural marker — this edge carries no review obligation and is excluded from pending-review derivation and the reviewer confirm guards. The simplifier is woken to write the companion by the ordinary producer propose-arm (it self-gates on the upstream draft existing, orienting-and-exiting until the upstream proposes); it never issues an ACK or NACK on the upstream draft. The companion is reviewed CRITICAL by `reviewer_refine` (refine) / `reviewer_plan` (plan).
**Producer only** (#3381): the simplifier produces its companion and casts no verdict on anyone. It retains a **wake-only** advisory edge over the upstream producer (`refiner` in refine, `task_planner` in plan) — this edge carries no review obligation and is excluded from pending-review derivation and the reviewer confirm guards, so the simplifier never issues an ACK or NACK on the upstream draft. It *is* honoured as an ordering dependency: the first-propose gate (#3478/#3603) derives `wait` for the simplifier until that upstream producer has proposed, and the first poll after the proposal spawns its propose arm. Before #3603 the wake was instead a poll loop of clean orient-and-exit invocations, which the [no-op-streak park](../architecture/orchestrator.md) counted as a wedge and parked (#3595 root cause 2). The companion is reviewed CRITICAL by `reviewer_refine` (refine) / `reviewer_plan` (plan).

**File access**:
- Allowed writes: `.egg-state/drafts/`, `.egg-state/agent-outputs/`
Expand Down
64 changes: 34 additions & 30 deletions orchestrator/review_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,25 @@ class ReviewEdge:
# human-focused companion that retains an advisory edge over the
# upstream refine/plan producer but issues no ACK/NACK on it.
#
# It does NOT drive the wake. The simplifier is woken to write its
# companion by the ordinary producer **propose-arm**: a WORKING
# producer re-derives ``propose`` on every event-loop poll, and a clean
# orient-and-exit is a *legitimate* outcome that frees the spawn-dedupe
# key, so the orchestrator re-spawns it until it proposes (see
# ``test_event_loop.py::test_stale_exit_is_a_non_trigger_through_loop``).
# The simplifier self-gates on the upstream draft existing, so it
# orients-and-exits until the draft is committed, then proposes.
# ``wake_only`` NEUTRALIZES the review obligation, not the dependency.
# It is excluded from pending-review derivation (so the de-roled
# reviewer is never assigned a spawn-able ``ack`` it cannot satisfy —
# the regression #3381 fixed) and from the reviewer confirm guards (so
# it can confirm without a verdict it will never cast). A wake-only
# edge is always ADVISORY.
#
# ``wake_only`` exists only to NEUTRALIZE the residual advisory edge so
# it carries no review obligation: it is excluded from pending-review
# derivation (so the de-roled reviewer is never assigned a spawn-able
# ``ack`` it cannot satisfy — the regression #3381 fixed) and from the
# reviewer confirm guards (so it can confirm without a verdict it will
# never cast). A wake-only edge is always ADVISORY.
# It IS honoured as an ordering dependency: the edge exists precisely
# because the companion is written against the upstream producer's
# draft, so ``_pre_propose_upstream_producers`` (#3478) gates the
# simplifier's first ``propose`` on that producer having proposed
# (#3603). Until #3603 the wake was instead a poll loop — the WORKING
# simplifier re-derived ``propose`` every event-loop tick and
# oriented-and-exited until the draft appeared — but those clean exits
# are exactly what the #3425 no-op park counts, so the simplifier was
# parked with a ``[high]`` wedge alert for correct behaviour in 4/4
# assessment runs across both the refine and plan phases (#3595 root
# cause 2). The wake is now the derivation itself: the first poll that
# sees the upstream's proposal derives ``propose`` and spawns the arm.
wake_only: bool = False

def to_dict(self) -> dict[str, Any]:
Expand Down Expand Up @@ -259,16 +263,16 @@ def get_default_refine_graph() -> ReviewGraph:
ReviewEdge("first_principles_reviewer", "refiner", ReviewCriticality.CRITICAL),
# The simplifier produces the human-focused analysis companion
# (faithful + jargon-free), gated CRITICAL by reviewer_refine.
# It is a PRODUCER ONLY (#3381): the propose-arm wakes it to
# write the companion (it self-gates on the refiner's draft
# existing), and it casts no verdict on anyone. It retains a
# WAKE-ONLY advisory edge over the refiner only as a structural
# marker; wake_only carries no review obligation — it excludes
# the edge from pending-review derivation and the confirm guards
# so the simplifier is never derived a spawn-able ``ack`` it
# cannot satisfy and can confirm its own companion without ever
# voting on the refiner. (See the ReviewEdge.wake_only docstring
# for why the propose-arm, not this edge, is the wake.)
# It is a PRODUCER ONLY (#3381): it writes the companion against
# the refiner's draft and casts no verdict on anyone. Its
# WAKE-ONLY advisory edge over the refiner carries no review
# obligation — it is excluded from pending-review derivation and
# the confirm guards, so the simplifier is never derived a
# spawn-able ``ack`` it cannot satisfy and can confirm its own
# companion without ever voting on the refiner — but it IS the
# dependency the first-propose gate orders on: the simplifier
# derives ``wait`` until the refiner proposes (#3478/#3603).
# (See the ReviewEdge.wake_only docstring.)
ReviewEdge("reviewer_refine", "simplifier", ReviewCriticality.CRITICAL),
ReviewEdge("simplifier", "refiner", ReviewCriticality.ADVISORY, wake_only=True),
]
Expand Down Expand Up @@ -314,12 +318,12 @@ def get_default_plan_graph() -> ReviewGraph:
ReviewEdge("risk_analyst", "task_planner", ReviewCriticality.CRITICAL),
# The simplifier produces the human-focused plan companion,
# gated CRITICAL by reviewer_plan. Wake-only like the refine-phase
# simplifier: a PRODUCER ONLY (#3381) woken to write the companion
# by the propose-arm (self-gating on task_planner's draft), casting
# no verdict. It retains a WAKE-ONLY advisory edge over task_planner
# only as a structural marker; wake_only excludes it from
# pending-review derivation and the confirm guards (see the refine
# graph above and the ReviewEdge.wake_only docstring).
# simplifier: a PRODUCER ONLY (#3381) that writes the companion
# against task_planner's draft and casts no verdict. Its WAKE-ONLY
# advisory edge over task_planner is excluded from pending-review
# derivation and the confirm guards, and is the dependency the
# first-propose gate orders on (#3478/#3603) — see the refine
# graph above and the ReviewEdge.wake_only docstring.
ReviewEdge("reviewer_plan", "simplifier", ReviewCriticality.CRITICAL),
ReviewEdge("simplifier", "task_planner", ReviewCriticality.ADVISORY, wake_only=True),
]
Expand Down
Loading
Loading