Skip to content

Design: coordination state is served, not replicated — retire git/prompt choreography for agent state exchange #3077

Closed

Description

@jwbron

The pattern

Laid end to end, a long lineage of incidents is one bug recurring: pipeline coordination state has one logical home but N physical replicas (orchestrator worktree, gateway worktree, per-agent worktrees, origin, per-role/slice branches), and the replicas are synchronized by ad-hoc git choreography and prompt prose.

Incident Replica failure
#3068 / #3073 Seeded drafts on the work branch, agent worktrees forked from base — state never reached agents
#3072 Narrow-refspec mirrors: fetch "succeeds," tracking refs stay stale — worktrees created behind the real tip
#3076 read_peer_artifact reads .egg-state/brc-history/ in the agent worktree; the file is only written at phase end, into the orchestrator's worktree — structurally empty mid-phase
#3033 Spawn prompt (the channel carrying task text) discarded by the event pump (del prompt_text, consensus_wrapper.py:748)
#3016 Canonical artifact paths live in prompt prose agents never reliably see — write-path drift (refiner; repeated by the architect's architect-plan.md in #3076)
#2629 populate_contract wrote the orchestrator worktree but didn't push — fresh spawns couldn't see it
#2626 / #2625 Plan-sync deleted drafts from the integration branch
#2972 / #2488 Post-phase _sync_worktree_with_remote hard-reset discarded committed HITL decisions
#3005 Gateway emptyDir wiped sessions → startup cleanup deleted live worktrees
#2548 / #2755 brc-history slice partitions vs work branch: add/add merge conflicts
#3117 Contract task-record mutations written only to the live worktree copy; the work-branch replica is frozen at init time — every task row reads pending forever (contributed to the #3114 misdiagnosis)

And there is a control group, which is the most useful fact in this history: the served channels have never produced one of these incidents. The contract API (agents call egg-contract show; the gateway reads its own authoritative worktree), consensus signals over HTTP, and message wait-loops appear nowhere in the lineage. #3033 already discovered this for task descriptions ("the contract is the only reliable channel"). We keep rediscovering it one channel at a time. (One honest caveat: the served channels have also historically carried less and lower-churn state — contracts are near-static, consensus signals are tiny. Part of the clean record is workload, not just architecture, which is why the durability dependency under Trade-offs matters before the pattern counts as proven at BRC-transcript volume.)

Proposed invariant

Coordination state is served from one authoritative source. Workspace synchronization is performed by the harness, deterministically. Prompts never carry protocol mechanics — only judgment.

Three clauses, each retiring a failure class:

  1. Served reads for everything an agent consumes but doesn't own. Peer proposals, drafts, reviews, transcripts, decisions: agents read these through the gateway/orchestrator, which reads its own authoritative copy (live message store for in-flight BRC; work-branch git show for committed artifacts — the Refactor: read purely-committed .egg-state artifacts via git show HEAD: instead of working tree (root-cause fix for #2626 / #2721 / #2992 class) #2723 idea). The agent worktree's job shrinks to: code at the right base, plus the agent's own outputs. The seams already exist — the brc handlers already HTTP to the orchestrator for propose/ack/nack/get_state (read_peer_artifact is the odd one out reading local disk), and the gateway contract API is the template for a thin git show <ref>:<path> artifact endpoint.
  2. Harness-performed sync where a real checkout is genuinely needed (tester/reviewer running the proposal). Today that sync is a sentence in a spawn prompt the event pump provably discards. Move it into the consensus wrapper: when the derived action is ack/nack, the wrapper syncs the worktree to the proposal's commit SHA before invoking the agent — deterministic bash, not a request to an LLM.
  3. One artifact spec, everything derives from it. Canonical-path drift recurs because "where does role X write artifact Y" lives in prose. The declarative phase abstraction (Genericize the SDLC pipeline into a declarative, config-driven workflow (custom phases + agents + per-phase slicing) #3017) is the right home: each phase/role declares its artifacts (name, path, producer, consumers); propose-time validation (feat(orchestrator): validate producer's phase draft at the canonical path on propose (deterministic refine/plan gate input) #3016 generalized to all producers), the served read API (resolve by artifact name, not path-guessing), and any remaining prompt text all derive from one table.

Direction (phased)

Non-goals / what not to do

  • No new sync mechanism (e.g. "orchestrator pushes brc-history mid-phase and agents fetch it") — that patches #3076 by adding a fourth replica path; more of the disease.
  • No shared worktree per phase. Per-role isolation earns its keep (crash isolation, push attribution, task_planner: same-worktree Write→Read→NotFound within ~90s, likely BRC state-sync stomping untracked files #1809-class stomps). The problem was never isolation; it's making isolated replicas responsible for coordination reads.
  • Don't try to make prompts reliable. The prose channel is lossy by design in the event-pump world; treat that as a feature that forces the protocol into code.

Trade-offs

Served reads put more load-bearing weight on the gateway/orchestrator and cost an HTTP hop where a file read used to be. The contract API already carries that weight without incident; handlers already have output caps and pagination. One phantom-NACK loop (~$0.5/reviewer invocation × four agents × cycles, per #3076) costs more than a year of HTTP hops.

The real dependency is durability, not capacity. Clause 1 makes the orchestrator's in-flight message store load-bearing: if the orchestrator restarts mid-phase, the live route's backing state must survive (or fail loudly), because the disk fallback is structurally empty mid-phase by construction — a mid-phase restart reproduces the original #3076 condition exactly when the fallback is needed. The design shifts the failure from "always empty mid-phase" to "empty mid-phase iff the orchestrator restarted," which is a big improvement but not closure. #3070 (prompt-driven state never committed; force_commit had zero callers) shows orchestrator-side durability across restart/redeploy is a known soft spot; message-store durability is a named prerequisite of this invariant, the same way gateway capacity is named above.

Related

#3076 (phase-1 trigger — issue since deleted from the tracker; the failure mode is described in the lineage table above and the fix is PR #3078 + PR #3083), #3068 #3072 #3073 (spawn-time state), #3033 (prompt discard), #3016 (write-path drift) → #3017 (phase abstraction, phase-2 home), #3002 (GKE — blocked on the gateway artifact-read endpoint, see phase 2), #3070 #3117 (state durability — prerequisite of clause 1; #3117 = the contract's durable work-branch copy frozen at init, fixed by boundary-commit snapshots for audit, not by reviving agent checkout reads), #2723 (read committed state via git show), #2629 #2626 #2972 #3005 #2548 #2755 (lineage), #3075 (orchestrator-side fetch staleness audit).

Activity

  1. jwbron commented on Jun 10, 2026

    @jwbron
    OwnerAuthor

    Phase-1 first slice is up: PR #3078 (SHA-scoped re-review deltas, concrete git show read commands in review event prompts, honest read_peer_artifact empties + description). It removes the #3076 failure mode without adding any new replication machinery — consistent with the non-goals here.

    Still open under phase 1: live-backed read_peer_artifact (message-store query for the in-flight phase), the gateway git show <ref>:<path> artifact-read endpoint, and wrapper-performed sync-to-proposal on review actions. Phases 2–3 (artifact spec in #3017, prompt-prose retirement / deletion list) unstarted.

  2. added
    p3
    on Jun 10, 2026
  3. jwbron commented on Jun 10, 2026

    @jwbron
    OwnerAuthor

    Phase-1 implementation status (trigger instance #3076):

  4. jwbron commented on Jun 11, 2026

    @jwbron
    OwnerAuthor

    Body revised after a code-level pass over what actually landed (PR #3078 + PR #3083):

  5. 38 remaining items

  6. added a commit that references this issue on Jun 12, 2026
  7. added a commit that references this issue on Jun 25, 2026
  8. added 2 commits that reference this issue on Jun 25, 2026
  9. added a commit that references this issue on Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    p3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions