Repository navigation
Description
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:
- 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 showfor 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_artifactis the odd one out reading local disk), and the gateway contract API is the template for a thingit show <ref>:<path>artifact endpoint. - 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.
- 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)
- Phase 1 — tactical, the #3076 fix shaped as a down-payment: live-backed
read_peer_artifact(query the orchestrator message store for the current phase; the on-disk brc-history files remain what they really are — a PR-time audit artifact), commit-SHA-qualifiedartifact_refsin review event prompts + a gateway artifact-read endpoint, wrapper-side sync-to-proposal on review actions, and non-silent empty results (ahintfield instead of bareitems: []withok: true). The non-silence rule applies to clause-2 sync too: a failed sync-to-proposal (merge conflict, unresolvable SHA) must surface in the event prompt ("worktree NOT synced to<sha>; treat your local diff as unreliable"), not silently skip — a quiet skip is the retired failure mode wearing the new mechanism. (Status: landed via PR fix(brc): scope review deltas to the proposal SHA; make read_peer_artifact honest about mid-phase emptiness #3078 + PR feat(brc): live-backed read_peer_artifact + wrapper sync-to-proposal (#3076) #3083, except the gateway artifact-read endpoint — deferred, see below — and the sync-failure surfacing:sync_to_proposals()currently silent-skips, consensus_wrapper.py:532-533.) - Phase 2 — the artifact spec, with spec-derived propose validation replacing the bespoke feat(orchestrator): validate producer's phase draft at the canonical path on propose (deterministic refine/plan gate input) #3016 validator and the read API resolving by artifact name. 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, but it should consume the spec, not gate it: the artifact table itself (name, path, producer, consumers per phase/role) is small and can land standalone ahead of the broader genericization. Sequencing constraint: the gateway
git show <ref>:<path>artifact-read endpoint (deferred from phase 1) is a blocking prerequisite of Deploy egg on GKE (minimal first deploy): Terraform-provisioned cluster + GKE overlay + registry pull path #3002 — the renderedgit showcommands only resolve today because every per-role worktree shares the host repo's object store; on GKE's split object store they break and the #3076 failure mode returns on day one. - Phase 3 — the cleanup dividend. Deletable/demoted once 1–2 land: the reviewer SYNC prompt prose and the "fetch and read the diffs yourself" fallback; any expectation that brc-history reaches agent worktrees; per-incident prompt special-cases about where drafts live. The ratchet rule going forward: no new git distribution machinery for coordination state, ever. A rule stated in an issue has exactly the reliability this issue ascribes to prompts, so give it a mechanism: an invariant entry in docs/architecture, plus a test asserting prompt templates carry no sync mechanics (
git fetch/git mergeinstructions, brc-history paths) — which also locks in the cleanup so prose can't drift back. (fix(gateway): fork fresh worktrees from the assigned branch tip so seeded artifacts reach agents #3073 stays — fork-from-work-tip is still right for code and seeded state at spawn; #3075's audit still closes the orchestrator's own git-staleness holes.)
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
jwbron commentedon Jun 10, 2026
Phase-1 first slice is up: PR #3078 (SHA-scoped re-review deltas, concrete
git showread commands in review event prompts, honestread_peer_artifactempties + 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 gatewaygit 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.jwbron commentedon Jun 10, 2026
Phase-1 implementation status (trigger instance #3076):
/brc-transcriptroute + live-backedread_peer_artifact, SHA-scoped review deltas, wrapper sync-to-proposal on ack/nack.git show <ref>:<path>artifact-read endpoint listed in the phase-1 direction. On the current deploy every per-role worktree shares the host repo's object store, so the renderedgit show <sha>:<path>commands and the wrapper merge already provide the served-read behavior without a new gateway surface. The endpoint becomes load-bearing only on a split-object-store runtime (e.g. GKE, Deploy egg on GKE (minimal first deploy): Terraform-provisioned cluster + GKE overlay + registry pull path #3002) — it should land in phase 2 alongside the artifact spec (Genericize the SDLC pipeline into a declarative, config-driven workflow (custom phases + agents + per-phase slicing) #3017) so it can resolve by artifact name rather than path-guessing from day one.fix(brc): scope review deltas to the proposal SHA; make read_peer_art…
feat(brc): live-backed read_peer_artifact + wrapper sync-to-proposal …
feat(brc): live-backed read_peer_artifact + wrapper sync-to-proposal …
jwbron commentedon Jun 11, 2026
Body revised after a code-level pass over what actually landed (PR #3078 + PR #3083):
read_peer_artifact, wrappersync_to_proposals(), SHA-scoped deltas, and honest empties are in. One residual:sync_to_proposals()silently skips on merge failure / unresolvable SHA (consensus_wrapper.py:532-533) — that's the retired failure mode wearing the new mechanism, so the non-silence rule now explicitly covers clause-2 sync. Small follow-up fix: surface the failed sync in the event prompt._clear_concurrent_state()semantics across restart should be verified rather than assumed.git showcommands on day one. Cross-linked on Deploy egg on GKE (minimal first deploy): Terraform-provisioned cluster + GKE overlay + registry pull path #3002.Address review feedback on #3127
fix(orchestrator): commit+push contract statefiles at slice boundaries (
refine(issue-3077): analysis — served-not-replicated coordination sta…
refine(#3077): fix factual error on _clear_concurrent_state in durabi…
Initialize SDLC contract for issue #3077
refine(issue-3077): analysis — served-not-replicated coordination sta…
refine(#3077): fix factual error on _clear_concurrent_state in durabi…
plan(issue-3077): risk_analyst assessment — MEDIUM, proceed with miti…
38 remaining items
Merge pull request #3139 from jwbron/egg/issue-3077/work
Deploy Redis in k3s and pin the orchestrator to the Redis message sto…
Remove the in-memory message store backend (#3159) (#3170)
docs: mark #3077 slices 5-6 shipped in coordination-state
docs: update coordination-state for #3077 slices 2-4 [doc-updater] (#…
docs: document message_store component in /api/v1/health response (#3148
Merge origin/main into egg/doc-update-coordination-state-slice-3: res…
Merge origin/main into egg/doc-update-artifact-spec-slice2: resolve c…
docs: add artifact_spec to STRUCTURE, mark slice-2 shipped (#3151)
docs: update health endpoint and coordination-state for #3077 slice-6…
docs: sync-to-proposal failure banner docs [doc-updater] (#3147)
implement(#3200): test queryable-env JIT pull + SHA-stamp invalidatio…
implement(#3200): test queryable-env JIT pull + SHA-stamp invalidatio…
fix(#3302): guard against orphan test roots + stop lint short-circuit…
implement(#3288): de-ledger artifact_api strict-schema and jira multi…