Repository navigation
Description
Part of #3200 (BRC context discipline). This is the authoritative layer of #3200's permanent protected root — the small, deterministic, always-resident block that keeps directives + review-state salient while the bulk history moves to a queryable environment the agent pulls from on demand. Deriving these facts from the message record (instead of transcribing them into a worktree file) is what lets the root stay authoritative and survive restarts. (Under the original reseed framing, preserved as #3200's fallback, this was the authoritative half of the cold seed; its role is the same either way — it is the most load-bearing piece in both directions.)
Goal
Make the factual layer of BRC memory deterministic: derived by the orchestrator/composer from the message record, rather than transcribed by agents into worktree files.
(Reframed from the original "reconstruct last_reviewed_commit_sha when the memory file is missing" — reconstruction-on-fallback is the timid version. If the facts are derivable, they should be derived always, not only when a file goes missing. This issue is one of three paths split out of the BRC-continuity discussion: deterministic memory (this issue), agent-authored enrichment (#3188), session resume (#3186).)
The observation
Most of the current BRC memory schema is facts the orchestrator already possesses:
last_reviewed_commit_sha— proposals carrycommit_shain their payload (brc_propose), and reviewer ACKs/NACKs reference them.- prior verdict, prior NACK reasons, conditional-ACK obligations — all present verbatim in the ACK/NACK messages themselves.
Today reviewers transcribe these facts into .egg-state/agent-outputs/<role>/brc-memory-<pipeline-id>.md via _record_review_memory (sandbox/egg_agent_tools/handlers/brc.py), and the composer (orchestrator/routes/event_prompt.py) reads the file back. Having an LLM copy facts the system already knows is redundant and fragile:
- Lifecycle fragility: the file lives in the worktree and dies with it — the restart_phase deletes per-role worktrees and with them durable BRC memory — restarts force full-context re-reviews; preserve continuity state #3183 restart incident (full-history re-reviews at 60–130k tokens/call, 14.7M prompt tokens/30min) was exactly this transcription store getting deleted.
- Transcription risk: an agent can record the wrong SHA or paraphrase a NACK reason; derived facts can't drift from the record.
- Trust: agent-authored memory must be treated as claims-to-verify; orchestrator-derived facts can be presented as authoritative. The poisoning concern then applies only to the enrichment layer (Agent-authored BRC memory enrichment for producers and reviewers: key findings, cited sources, SHA-pinned file/line references #3188).
reconstruct_tracker_from_messages is the in-repo precedent: consensus-tracker state is already rehydrated deterministically from the message record for orchestrator-restart recovery. This issue applies the same principle to the review-continuity facts that parameterise the composer's git-log delta.
Candidate directions (not pre-decided)
- Composer derives the per-producer factual block at event-prompt render time from the message record (live store and/or persisted
.egg-state/brc-history/), keeping the rendering deterministic (stable bytes for the cacheable prefix). - The agent-side writer stops carrying the factual fields; what remains agent-authored (change model, decision log, findings) migrates to the enrichment layer (Agent-authored BRC memory enrichment for producers and reviewers: key findings, cited sources, SHA-pinned file/line references #3188).
- Persistence timing must be addressed:
_write_brc_historypersists the transcript at phase transitions only, so mid-phase restarts need either the live Redis stream to surviverestart_phaseor a history-persist step added to the restart route (a natural addition — restart currently discards the phase's message record). - Derivation details: take the reviewer's latest verdict per producer (re-proposals bump
proposal_version); tolerate SHA-less proposals (no_changes_needed, BRC: a producer with no work in a slice has no accepted no-op path — empty proposal deadlocks against reviewer NACK + escalates to HITL (gap in #2581/#2444) #3027); the composer runs in the agent pod, so the data path must be reachable from there (served transcript route from #3076/Design: coordination state is served, not replicated — retire git/prompt choreography for agent state exchange #3077, on-disk history, or orchestrator-injected pre-resolved values).
Relationship to #3183
#3183's stash-and-reseed remains the tactical fix for the file-based store as it exists today. This issue is the structural fix for the factual layer: derived memory has no worktree lifecycle to survive. Enrichment-layer content (#3188) would still be file-carried and still benefits from #3183.
Related
- BRC consensus: replace agent-held waits with deterministic event-pump + durable agent memory (durable fix for #2906) #2908 — event-pump + memory architecture;
docs/architecture/brc-memory.mdalready designates message history as the durable backstop — this operationalizes it. - restart_phase deletes per-role worktrees and with them durable BRC memory — restarts force full-context re-reviews; preserve continuity state #3183 — restart incident and tactical preservation fix.
- Agent-authored BRC memory enrichment for producers and reviewers: key findings, cited sources, SHA-pinned file/line references #3188 — the agent-authored enrichment layer (the judgment half of the split).
- Session resume for event-pump agents: re-enter the prior conversation per event (opt-in rollout, default-on end-state) #3186 — session-resume path (orthogonal continuity mechanism).
- #3076 / Design: coordination state is served, not replicated — retire git/prompt choreography for agent state exchange #3077 — served transcript route (candidate pod-side data path).
Activity
[-]Composer degrades to full-history re-review when BRC memory is missing — reconstruct last_reviewed_commit_sha from message history instead[/-][+]Deterministic BRC memory: derive the factual layer (review anchors, verdicts, NACK reasons, obligations) from the message record instead of agent transcription[/+]plan: task decomposition for issue-3200 (full-context backstop)
plan: task decomposition for issue-3200 (full-context backstop)
feat(plan): architecture plan for full-context backstop (issue #3200)
plan: task decomposition for issue-3200 (full-context backstop)
feat(plan): architect-slices scaffold for issue-3200 (full-context ba…
Add risk analysis for #3200 plan phase (risk_analyst)
Reconcile #3200 risk analysis against merged task_planner plan
plan(architect): write architect-output to canonical gate path (#3200)
plan(#3200): v2 — build #3189 anchors + #3186 resume in-pipeline, Non…
implement(#3200): derive #3189 BRC anchors from the message record (s…
implement(#3200): test #3189 BRC anchor derivation (slice-3, task-3-2)
7 remaining items
Reconcile #3200 risk analysis against merged task_planner plan
plan(architect): write architect-output to canonical gate path (#3200)
plan(#3200): v2 — build #3189 anchors + #3186 resume in-pipeline, Non…
Add risk analysis for #3200 plan phase (risk_analyst)
Reconcile #3200 risk analysis against merged task_planner plan
plan(architect): write architect-output to canonical gate path (#3200)
plan(#3200): v2 — build #3189 anchors + #3186 resume in-pipeline, Non…
implement(#3200): queryable-environment JIT pull + SHA-stamped enrich…
implement(#3200): test mid-phase restart preserves BRC message record…
implement(#3200): test mid-phase restart preserves BRC message record…
implement(#3200): mid-phase BRC message-record survival (slice-7, tas…
docs: update egg_anchor README for BRC anchor derivation [doc-updater] (
implement(#3288): strip slice/task ledger tags from shared docstrings
jwbron commentedon Jul 6, 2026
Triage: delivered as #3200 slices: PR #3238 added shared/egg_anchor/brc_derive.py, mechanically deriving all four factual anchors (last-reviewed SHA per producer, latest verdict per edge, open NACK reasons, conditional-ACK obligations) from the message record; PR #3239 renders them as the authoritative section of the protected root; PR #3248 guarantees the message record survives restart so anchors re-derive. Agent-written memory is now framed as claims with the derived anchors authoritative. Closing as complete.