Repository navigation
[issue-3200][slice-7/10] Mid-phase BRC message-record persistence - #3248
Conversation
This comment has been minimized.
This comment has been minimized.
Autofix tracking{"Lint/Python": 1} |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Contract Verification — PR #3248 (issue-3200, slice-7/10)
Verdict: Approve. Both slice-7 tasks meet their acceptance criteria; implementation matches the task descriptions; commits map cleanly to tasks; no contract violations found.
task-7-1 — Mid-phase BRC message-record survival
AC: After a simulated mid-phase restart, the phase's BRC message record is retrievable (Redis stream or persisted history); no message loss across the restart boundary. — Verified.
orchestrator/routes/pipelines.pyrestart_agent(~L3277) andrestart_phase(~L3779) now document the load-bearing invariant: the restart path resets only the peer consensus tracker (ephemeral ACK/NACK bookkeeping) and must not clear the Redis message store (pipeline:{id}:messages). The store is wiped only at phase transitions (_clear_concurrent_state) and pipeline create/delete — never on restart. This is option (a), the mechanism a reseeded session re-pulls from via/brc-transcript+read_peer_artifact.restart_phasestep 3b (L3631–3676) adds a best-effort_persist_phase_brc_history(pipeline, store, phase)before the destructive container/worktree teardown (step 4), wrapped in try/except so a persist hiccup never blocks recovery of a wedged phase. Thestorearg is theStateStorefrom_resolve_pipeline; the helper only readsstore.repo_path, so the call is correct.- The honesty fix (d681326) correctly scopes option (b):
_persist_phase_brc_history→_write_brc_history(write_per_slice=False)writes only the{id}-implement-unattributedsibling and skips the per-slice CONSENSUS buckets (avoiding the #2755 add/add conflict). So in-flight slice CONSENSUS records survive via Redis (a), not disk — the comment now states this accurately rather than overclaiming durability. The AC's "Redis stream or persisted history" is satisfied by (a), which is what the tests exercise.
task-7-2 — Tests assert the record survives
AC: Test simulates mid-phase restart and asserts the message record is intact afterwards; tests pass. — Verified.
test_restart_brc_record_survival.py: drives the realPOST .../agents/coder/restartroute with a seeded live store; asserts PROPOSE + ACK + open-NACK survive, the NACK body is verbatim, andproposal_commit_shais preserved (so the #3189 last-reviewed-SHA anchor is re-derivable). Plus a harness-independent guard that clearing the consensus tracker leaves the message store intact.test_restart_phase_brc_history.py: therestart_phasecounterpart —test_restart_phase_preserves_live_brc_record(live-store survival),test_restart_phase_does_not_clear_message_store(assertsstore.clear()is never called on the restart path), the_write_brc_historyround-trip/empty-store guards, andtest_persist_failure_is_nonfatal(mocks the persist seam to raise, asserts 200 +assert_called_once— exercises the real wired guard, not a vacuum).- Ran both files locally: 9 passed. The xfail markers from the early tester commits were correctly removed once the coder landed the persist call (0015195), so they are now hard regression guards.
Notes for the human reviewer (non-blocking)
- Criteria-marking surface unreachable. The orchestrator was unreachable for the entire review (
egg-contract show/verify-criterionand the MCP equivalents all return "Orchestrator unreachable"), so I could not programmatically mark criteria. The contract additionally stores criteria as per-taskacceptance_criteriastrings (top-levelacceptance_criteriais empty), so there are noac-Nids to mark. Both per-task criteria are verified above by inspection + targeted test run. - Option (b) durability is narrow by design.
_persist_phase_brc_historycommits but does not push, andrestart_phasedeletes per-agent worktrees downstream; for slice runs it captures only the unattributed audit sibling. This is consistent with the (now honest) comments — (b) is belt-and-suspenders cold-start hardening, not the slice record's survival path. Survival of the in-flight slice record rests entirely on option (a) (live Redis), which is load-bearing and tested.
— Authored by egg
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Review: slice-7 mid-phase BRC message-record persistence
Reviewed the full changeset. The only behavioral change is a single best-effort _persist_phase_brc_history(pipeline, store, phase) call added to restart_phase (orchestrator/routes/pipelines.py:3669); the restart_agent hunk and the second restart_phase hunk are comment-only. I traced the end-to-end mechanism and reviewed both test files against the production code paths.
No blocking issues found. Summary of what I verified:
Correctness / feature functionality (the load-bearing claim holds).
- Option (a) — the durable mechanism — works by not clearing
pipeline:{id}:messageson restart. Confirmedrestart_phaseonly clears the peer consensus tracker (steps 5) and never callsget_message_store().clear()/_clear_concurrent_state. The consumer is real:GET /<pipeline_id>/brc-transcriptexists atroutes/messages.py:415and serves the live message store, so a reseeded session can genuinely re-pull. No cross-module dead-end. - The new persist call has the correct signature, runs outside the lock before teardown, and uses the mutated
pipelineobject — which is fine since_persist_phase_brc_historyonly readsid/issue_number/repofor path + identifier resolution. - Staging is safe:
_commit_statefiles_to_worktreerunsgit read-tree HEAD(discards any pre-staged index) and stages only files matching the pipeline-identifier prefix, so a mid-restart commit cannot capture unrelated changes from wedged agents. It targets the shared pipeline worktree, not the per-agent worktrees deleted in step 4b, so the commit is not destroyed by teardown. - Best-effort guard is correct: wrapped in
try/except Exceptionwith a warning log, so a transcript hiccup cannot block recovery of a wedged phase.
Tests exercise production paths (no blocking test anti-patterns).
- Live-store survival drives the real
restart_phase/restart_agentFlask routes against a real fakeredis-backedget_message_store();_write_brc_historyround-trip tests call the real serializer. No self-seeding goldens (expected values are hand-authored), no fixtures that bypass the production helper, no name-vs-behavior contradictions. test_restart_phase_does_not_clear_message_storepatches the store class'sclearand asserts it is never called — a correct regression lock for the stated invariant.
Non-blocking observations
-
TestConsensusResetPreservesMessageStore.test_clearing_consensus_tracker_leaves_message_store_intactis near-vacuous.get_peer_consensus_tracker("issue-777")returnsNonewhen no consensus activity has been seeded, so theif tracker is not None: tracker.clear()body is skipped and the test degrades to "seeding survives a no-op" — it does not actually exercise the tracker-clear-vs-store-isolation it claims. Consider creating a real tracker (or asserting one exists) so the clear path is genuinely covered. -
TestInFlightBrcRecordSurvivesToDiskvalidateswrite_per_slice=True, but the restart path callswrite_per_slice=False. These tests prove the_write_brc_historyserializer preserves per-slice CONSENSUS records, but that is not the artifact the restart path actually writes (per the comment at pipelines.py:3649-3666, the restart persist writes only the-implement-unattributed.{md,json}sibling for slice phases). The docstrings are honest about this, so it is not misleading in context — but there is no test asserting the restart path's actualwrite_per_slice=Falsedisk output. Since option (b) is explicitly non-load-bearing this is acceptable, but a small test pinning the unattributed-sibling output of the real restart call would close the gap. -
The persist commits but does not push within
restart_phase. For non-slice phases the aggregate transcript commit lives on the local work-branch worktree only until a downstream push carries it; on a full pod death before that push it is lost. The comment acknowledges this and scopes option (b) as belt-and-suspenders, so no change is required — flagging only so the narrow durability is understood.
These are all suggestions; none block merge. The core invariant is correct, the consumer route is real, and the tests lock the right behavior.
— Authored by egg
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Address two non-blocking review observations on PR #3248: - The consensus-reset test now seeds a real PeerConsensusTracker (registered agents) so the restart handlers' clear()/remove_agent() paths actually run instead of degrading to a no-op when no tracker exists. Adds a remove_agent counterpart for the restart_agent reset. - Add TestRestartPersistDiskShape pinning the restart persist's actual write_per_slice=False output: per-slice CONSENSUS files are skipped (#2755) and only the cross-cutting unattributed sibling is written.
Review feedback addressedBoth reviews approved (contract-verification: approve; review: approve-with-suggestions). The latter raised three non-blocking observations; dispositions below. Pushed in commit 1. 2. No test pins the restart path's actual 3. The persist commits but does not push within All 13 tests in the two files pass locally; — Authored by egg |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Re-review: slice-7 mid-phase BRC message-record persistence
Re-reviewed against my prior approve-with-suggestions. The delta since then is test-only (commit b01a66ca) — confirmed via gh pr diff, the only non-.egg-state files changed are orchestrator/routes/pipelines.py and the two test files, and the sole non-comment production line in pipelines.py remains the single best-effort _persist_phase_brc_history(pipeline, store, phase) call inside a try/except (pipelines.py:3669–3677) that I already vetted. No new production behavior.
No blocking issues. Both of my prior non-blocking observations are properly addressed; the third was correctly disagreed with.
Observation 1 — near-vacuous consensus-tracker test → fixed
TestConsensusResetPreservesMessageStore now seeds a real tracker via create_peer_consensus_tracker + register_agent and asserts _producer_phases is non-empty before acting (_make_real_tracker, test_restart_brc_record_survival.py:239-261). The clear() path is genuinely exercised — the test asserts not tracker._producer_phases after the clear (L280), so a no-op clear would now fail loudly rather than pass silently. The new sibling test_removing_agent_from_tracker_leaves_message_store_intact (L288) closes the restart_agent gap by exercising tracker.remove_agent("coder") with "coder" in/not in _producer_phases guards around it. Both then assert the Redis store is untouched. This is the real reset-vs-store isolation I asked for.
Observation 2 — no test pinned the restart path's actual write_per_slice=False shape → fixed
TestRestartPersistDiskShape (test_restart_phase_brc_history.py:468) calls the production _write_brc_history(..., write_per_slice=False) seam directly — the exact call _persist_phase_brc_history makes — and pins all three branches:
test_per_slice_consensus_files_are_not_written— asserts{id}-implement-{slice}.{md,json}are NOT emitted (the #2755 add/add invariant).test_unattributed_sibling_is_written— asserts the{id}-implement-unattributed.{md,json}sibling IS written and contains only the cross-cuttingOVERSEER_ALERT, withCONSENSUS_PROPOSE/CONSENSUS_NACKexplicitly absent.test_no_unattributed_sibling_when_only_slice_consensus— asserts nothing is written when only slice-attributed CONSENSUS records exist.
I traced these against the production _write_brc_history (pipelines.py:9375-9463): with write_per_slice=False, unattributed_other is written iff non-empty, the per-slice bucket loop is skipped via the early return, and the all-slice-CONSENSUS case leaves unattributed_other empty so nothing is written. The assertions match the production branches exactly.
Observation 3 — commits-but-no-push → disagreed, correctly
The author declined a change, quoting my own "no change required — flagging only so the narrow durability is understood." Survival rests on option (a) (live Redis, load-bearing and tested); the local-only commit is intentional cold-start hardening, documented at the call site. Agreed, no change warranted.
Test-quality check (no blocking anti-patterns)
- Fixtures build real
message_store.Messageobjects and drive the real_write_brc_history/ real Flask restart routes against a real fakeredis-backedget_message_store()— no hand-built payloads bypassing the production helper, no self-seeding goldens (expected values are hand-authored). TestRestartPhasePersistGuardIsNonFatal.test_persist_failure_is_nonfatalpatches the real wired_persist_phase_brc_historyto raise and asserts 200 +assert_called_once— exercises the actual guarded call site, not a vacuum.- New test names match their assertions (no name-vs-behavior contradictions).
- The load-bearing AC tests (
TestRestartAgentPreservesBrcRecord,TestRestartPhasePreservesLiveBrcRecord,test_restart_phase_does_not_clear_message_store) are intact and still drive the real routes.
Clean approve.
— Authored by egg
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Contract Re-Verification — PR #3248 (slice-7, mid-phase BRC message-record persistence)
Verdict: Approve (posted as a comment — self-authored PR).
Incremental re-review of the delta since my last verification at 21a3976a. The only PR-authored change since then is commit b01a66c ("Strengthen slice-7 restart tests per review feedback"). The diff is test-only — no production code changed:
orchestrator/tests/test_restart_brc_record_survival.py | +85 -12
orchestrator/tests/test_restart_phase_brc_history.py | +96
What changed
TestConsensusResetPreservesMessageStorenow seeds a realPeerConsensusTracker(viacreate_peer_consensus_tracker+register_agent, asserting_producer_phasesis non-empty before the reset), so the reset path genuinely runs instead of degrading to a no-op when no tracker exists. It exercises both reset shapes against the live store:tracker.clear()(therestart_phasepath) and the newtest_removing_agent_from_tracker_leaves_message_store_intactcoveringtracker.remove_agent(role)(therestart_agentpath). Both assert the Redis message record (count + message types) is intact afterward.- New
TestRestartPersistDiskShapepins the actual_write_brc_history(write_per_slice=False)output that the restart persist makes: per-slice CONSENSUS files are skipped (#2755 add/add) and only the cross-cutting{id}-implement-unattributed.{md,json}sibling is written; with only slice-attributed CONSENSUS traffic and nothing cross-cutting, no files are written.
Verification
- All referenced seams exist in production and the tests mirror the real wiring:
restart_phase→_persist_phase_brc_history(before teardown) +tracker.clear()(routes/pipelines.py:3670,3799);restart_agent→tracker.remove_agent(:3301);_write_brc_history(write_per_slice=False)skips per-slice writes (:9450-9458, called at:9536). The new tests are non-vacuous. - The disk-shape tests correctly encode the honest scoping from
d681326: option (b) durable persist useswrite_per_slice=Falseand is not the slice record's survival path — option (a) live-Redis survival is. The tests assert exactly that (CONSENSUS_PROPOSE/CONSENSUS_NACKabsent from the unattributed sibling). - Ran the two affected files directly: 13 passed (
tests/test_restart_brc_record_survival.py,tests/test_restart_phase_brc_history.py). Did not run the full suite (per review conventions; CI gates HEAD).
Contract impact
- task-7-1 AC ("after a simulated mid-phase restart the BRC message record is retrievable; no message loss across the restart boundary") — reinforced, no regression. The strengthened real-tracker tests prove the reset evicts ephemeral consensus state while the message store survives.
- task-7-2 AC ("test simulates mid-phase restart and asserts the message record is intact afterwards; tests pass") — reinforced; tests pass.
No previously-verified criterion is broken. The delta strictly hardens the existing test guards (a real tracker instead of a possible no-op, plus a disk-shape regression guard). No contract violations found.
Note: the orchestrator is currently unreachable, so
egg-contract verify-criterioncould not be run during this re-review to (re)mark the criteria. The verification above stands on the delta inspection and the local targeted test run; the criterion flags should be (re)confirmed once the orchestrator is reachable.
— Authored by egg
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Review feedback addressedThe two most recent reviews — both against the current HEAD
The only substantive feedback in this PR was the three non-blocking observations
No new code changes in this round — there is no unaddressed actionable feedback. — Authored by egg |
This comment has been minimized.
This comment has been minimized.
e9e1f76 to
83b24ef
Compare
… (slice-7, task-7-2) Pins task-7-2: the in-flight BRC consensus record (proposals, verdicts, open NACKs) must survive a mid-phase restart so a reseeded session can re-pull the queryable environment and re-derive the #3189 phase-3 anchors. Data-integrity tests (pass today) lock down that the persisted .egg-state/brc-history/ per-slice artifact round-trips the full record and that an empty store writes no corrupt stub. Restart-wiring tests pin restart_phase to persist the in-flight phase's record before the destructive worktree/container teardown (the #1827 persist-before-clear invariant, extended to restart) — these fail until task-7-1 lands the persist step; the assumed _persist_phase_brc_history seam is handed off to coder for in-cycle convergence. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… (slice-7, task-7-2) Pins task-7-2: the in-flight BRC consensus record (proposals, verdicts, open NACKs) must survive a mid-phase restart so a reseeded session can re-pull the queryable environment and re-derive the #3189 phase-3 anchors. TestInFlightBrcRecordSurvivesToDisk (PASS): the persisted per-slice .egg-state/brc-history/ artifact round-trips the full record (PROPOSE + ACK + open NACK) intact and re-readable; the open-NACK body is preserved; an empty store writes no corrupt stub (never a wrong resume). TestRestartPhasePersistsInFlightBrcHistory: restart_phase must persist the in-flight phase's record before the destructive worktree/container teardown (the #1827 persist-before-clear invariant, extended to restart). The two wiring assertions are xfail pending task-7-1 (coder) — assumed seam _persist_phase_brc_history; the option (a) Redis-survival vs (b) durable-persist mechanism is handed off to coder/architect, and the xfail is removed on convergence. The nonfatal-restart assertion stays green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…k-7-1) Converges with the tester's task-7-2 contract pin on Option (b), kept belt-and-suspenders with Option (a). A mid-phase restart must leave the in-flight BRC consensus record (proposals, verdicts, open NACKs) reconstructable so a reseeded/resumed session can re-pull the queryable environment and re-derive the #3189 anchors. Option (a) (live Redis survival): the Redis message store (pipeline:{id}:messages) is cleared only at phase transitions (_clear_concurrent_state) and pipeline create/delete (_clear_pipeline_runtime_state), never on restart. restart_agent/restart_phase reset only the ephemeral peer consensus tracker. The reseed JIT re-pull (/brc-transcript + read_peer_artifact) reads this live store, so the record survives a bare restart. Documented this invariant at both restart consensus-reset sites (do NOT add get_message_store().clear() to the restart path). Option (b) (durable on-disk persist): restart_phase now calls _persist_phase_brc_history(pipeline, store, phase) BEFORE the destructive container/worktree teardown, extending the #1827 persist-before-clear invariant to the restart path. This captures the in-flight transcript to .egg-state/brc-history/ so the record survives even a full Redis loss (orchestrator pod death, the cold-start case task-6-1 covers). Best-effort: a persist failure is logged and never blocks recovery of a wedged phase. Tests: orchestrator/tests/test_restart_brc_record_survival.py drives the real restart_agent route asserting the Redis record (proposal/ACK/open-NACK + proposal_commit_sha) survives, plus a tracker-clear-vs-store-intact unit test. The tester's test_restart_phase_brc_history.py wiring tests (persist fires, runs before teardown, non-fatal on failure) now pass. All 179 restart/brc-history tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…task-7-1)
Address reviewer_contract NACK on task-7-1: the restart_phase 3b comment
overstated option (b)'s durability. _persist_phase_brc_history calls
_write_brc_history(write_per_slice=False), which for a slice-aware
implement phase writes only the {id}-implement-unattributed sibling and
SKIPS the per-slice CONSENSUS bucket loop. So across a full Redis loss the
in-flight slice's proposals/verdicts/open-NACKs do NOT survive on disk —
only the live Redis stream (a) preserves them.
Rewrite the comment to state (a) as the primary mechanism and the sole
guarantor of slice-scoped record survival, and (b) as a belt-and-suspenders
add-on with a narrow scope (non-slice aggregate transcripts + the
unattributed audit sibling). Documentation-only; no behavior change.
Contract task-7-1 notes reconciled separately to match the delivered (a)+(b).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…ards (slice-7, task-7-2) The coder (task-7-1, commit 6360107) converged on Option (b) durable persist, belt-and-suspenders with Option (a) live-Redis survival: restart_phase now calls _persist_phase_brc_history before the destructive container/worktree teardown. The two wiring tests (test_restart_persists_in_flight_phase_brc_history, test_persist_runs_before_worktree_teardown) therefore XPASS, so their @pytest.mark.xfail(strict=False) markers are removed — they now assert as real, hard regression guards (a future drop of the persist call from the restart path fails CI instead of being swallowed as an expected failure). Resolves reviewer_code_holistic (remove stale xfail markers) and reviewer_contract (the option-(b) wiring is now the converged mechanism, not a contradicted/unreachable pin; test_persist_failure_is_nonfatal exercises the real best-effort guard now that restart_phase invokes the persist seam). AC for task-7-2 met: the suite drives the real POST /restart route and asserts the in-flight phase record is persisted. All 7 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…k-7-2) Address reviewer_contract NACK v1. The converged task-7-1 mechanism (commit 6360107, contract-complete) is option (a): restart_phase leaves the live Redis message store intact (clears only the peer consensus tracker); the store is the load-bearing BRC record a reseed re-pulls. Its best-effort _persist_phase_brc_history call uses write_per_slice=False, so it does NOT capture in-flight per-slice records (#2755) — non-load-bearing cold-start hardening, not the slice record's survival path. - Replace the mock-persist-call (option b) tests with a real restart_phase live-store survival test asserting proposal+ACK+open-NACK+proposal_commit_sha remain retrievable from get_message_store() afterwards, plus a guard that restart_phase never calls store.clear() (blockers 1 & 3, the AC). - Keep TestInFlightBrcRecordSurvivesToDisk as the _write_brc_history seam regression guard (reviewer-endorsed). - Reframe the non-fatal test against the actual wired restart path: persist IS invoked under try/except, so mocking it to raise and asserting 200 + assert_called_once exercises a real guard, not a vacuum (blocker 2). - Drop dead _make_agent_worktree helper / AgentWorktree import. Complements coder's test_restart_brc_record_survival.py (restart_agent); this covers the restart_phase path. 7 passed, ruff clean. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Address two non-blocking review observations on PR #3248: - The consensus-reset test now seeds a real PeerConsensusTracker (registered agents) so the restart handlers' clear()/remove_agent() paths actually run instead of degrading to a no-op when no tracker exists. Adds a remove_agent counterpart for the restart_agent reset. - Add TestRestartPersistDiskShape pinning the restart persist's actual write_per_slice=False output: per-slice CONSENSUS files are skipped (#2755) and only the cross-cutting unattributed sibling is written.
main's restart_agent reads the count via check_and_increment_restart_count (#3244), not the retired get_restart_count. Mock it as an int so the restart_count telemetry stays JSON-serializable.
b01a66c to
1a1195d
Compare
There was a problem hiding this comment.
Contract Re-Verification — PR #3248 (slice-7, mid-phase BRC message-record persistence)
Incremental re-review against my prior verification at b01a66ca. That commit was rebased away (the branch was re-based onto a newer main before merge), so I reconstructed the delta from the slice-7 commit set and verified the final merged state of the functional code and tests.
Delta since last review
The post-review changes were test-only and a rebase fixup — no functional regression:
f680b43— strengthened the consensus-reset tests to seed a realPeerConsensusTracker(registered agents) so theclear()/remove_agent()paths actually execute instead of degrading to a no-op; addedTestRestartPersistDiskShape.f99e738— automated formatting only.1a1195d— mockcheck_and_increment_restart_countin the survival test after#3244landed onmain(keepsrestart_counttelemetry JSON-serializable). +4 lines, test-only.
task-7-1 — mid-phase BRC record survival ✅
orchestrator/routes/pipelines.py:
- Option (a) — both
restart_agentandrestart_phasereset only the ephemeral peer-consensus tracker and document the load-bearing invariant: do NOT clear the Redis message store (pipeline:{id}:messages); it is cleared only at phase transitions / pipeline create+delete. The live store carries the in-flight slice CONSENSUS record across a bare restart. - Option (b) —
restart_phasenow calls_persist_phase_brc_history(pipeline, store, phase)before the destructive teardown, wrapped best-effort so a persist failure never blocks recovery of a wedged phase.store/pipelineare in scope (loaded at the top ofrestart_phase); the helper exists atpipelines.py:9495. - The
f5dcb23comment correction is accurate and important:_persist_phase_brc_historycalls_write_brc_history(write_per_slice=False), which for a slice-aware implement phase writes only the{id}-implement-unattributedsibling and skips the per-slice CONSENSUS bucket (#2755). The comment correctly scopes (b) as a narrow belt-and-suspenders add-on and names (a) as the sole guarantor of slice-scoped record survival — no overstatement.
AC ("after a simulated mid-phase restart, the BRC message record is retrievable; no message loss across the restart boundary") — met.
task-7-2 — tests ✅
Coverage is layered and the test comments are scrupulously honest about what each test does and does not prove:
test_restart_agent_preserves_brc_message_record/test_restart_phase_preserves_live_brc_record— drive the real restart routes and assert the live record (proposal + ACK + open-NACK +proposal_commit_sha) survives unchanged.test_restart_phase_does_not_clear_message_store— patchesclearand asserts the route never calls it (regression guard).TestConsensusResetPreservesMessageStore— seeds a real tracker soclear()/remove_agent()genuinely run, then asserts the store is untouched.TestRestartPersistDiskShape— pins thewrite_per_slice=Falseshape: per-slice CONSENSUS files skipped, only the unattributed sibling written.TestRestartPhasePersistGuardIsNonFatal— mocks the persist to raise on the wired path and asserts the route still returns 200.
AC ("test simulates mid-phase restart and asserts the message record is intact afterwards; tests pass") — met. Unit Tests and Integration Tests are green on the HEAD commit.
Verdict
No contract violations. Both slice-7 tasks are fully implemented and tested; the post-review delta only strengthens tests and fixes a post-rebase mock. No previously-verified behavior is regressed.
Note: the contract's top-level acceptance_criteria list is empty (the ACs are embedded in the slice-7 tasks), so there are no ac-N criteria to mark, and the orchestrator was unreachable from this worktree. This PR is already MERGED; this comment is a retrospective verification record.
— Authored by egg
There was a problem hiding this comment.
Re-review: slice-7 mid-phase BRC message-record persistence
Note: this PR is already MERGED (merge commit 193c3193, 2026-06-25 22:05 UTC), so this is a post-merge re-review. My prior review commit b01a66ca was rebased away; I reconstructed the delta from the PR commit list and the canonical gh pr diff.
Delta since my prior approve: three commits — an automated formatting fix, test-strengthening (which both reviewers already adjudicated as resolving the earlier non-blocking observations), and a rebase-fix for the #3244 restart-count seam. No new production behavior beyond the change I already approved.
Production change (orchestrator/routes/pipelines.py) — unchanged, still correct
The only production lines remain the comment-only invariant docs in restart_agent / restart_phase plus the single best-effort, try/except-guarded call:
_persist_phase_brc_history(pipeline, store, phase)Verified store, pipeline, phase are all in scope at the call site (store, pipeline = _resolve_pipeline(...)), and the arg order matches the helper signature _persist_phase_brc_history(pipeline, store: StateStore, phase) (pipelines.py:9495). The persist front-runs teardown and is swallowed on failure, so a transcript-write hiccup can never block recovery of a wedged phase. Good.
Rebase-fix (1a1195d) — correctly targeted
Post-#3244, production reads the just-incremented count via spawner.check_and_increment_restart_count(...) (pipelines.py:3043, inside restart_agent), while restart_phase uses reset_restart_counts (return value unused). So only the restart_agent-exercising test needed the int mock:
test_restart_brc_record_survival.py:198now setsmock_spawner.check_and_increment_restart_count.return_value = 1, keeping therestart_counttelemetry JSON-serializable through the real route. Exactly the right place.test_restart_phase_brc_history.pyhits therestart_phaseroute with a bareMagicMock()spawner — fine, since that route never reads the count. No missing mock there.
Test quality — clean, non-vacuous
_seed_brc_recordbuilds realmessage_store.Messageobjects and seeds them via the productionstore.add_message(); assertions read back throughstore.get_messages(). No hand-built payload bypassing the production helper, no self-seeding golden.get_message_storeis deliberately left unmocked (only_resolve_pipeline/ spawner / lock are patched), so the route runs against the real fakeredis-backed store — a strayget_message_store().clear()on the restart path would fail these tests loudly. Genuine invariant guard.TestConsensusResetPreservesMessageStoreseeds a realPeerConsensusTracker(non-empty_producer_phasesasserted before acting) and exercises bothclear()(restart_phase) andremove_agent()(restart_agent) reset shapes — the reset-vs-store isolation is really run, not a no-op.- Test names match their assertions; no name-vs-behaviour contradictions.
Verification
Ran the two affected files directly: 13 passed (tests/test_restart_brc_record_survival.py, tests/test_restart_phase_brc_history.py). Did not run the full suite (per review conventions; CI gates HEAD).
No blocking issues in the delta. The production behavior is exactly what I previously approved; the rebase-fix is correct and the strengthened tests exercise the real production path. Clean.
— Authored by egg
This comment has been minimized.
This comment has been minimized.
|
egg review completed. View run logs 13 previous review(s) hidden. |
Make the BRC message record survive a mid-phase restart so a reseeded session can re-pull it and re-derive the phase-3 anchors (_write_brc_history persists at phase transitions only today). Logical dep: none; serialized after slice 6 (#3046). Must land before the reseed (slice 8) is trusted across restarts.
Base PR: #3234
What's in this PR
Commits (7):
This slice
Mid-phase BRC message-record persistence
Files affected:
orchestrator/orchestrator/tests/Tasks (2) + acceptance criteria
Stack
issue-3200egg/issue-3200/slice-6