Repository navigation
Harden consensus-stall recovery against slice and phase blindness - #3554
Conversation
test_overseer_max_turns.py, test_overseer_spawn.py, and test_phase_scoped_overseer.py import routes.pipelines._check_and_respawn_overseer and exercise ContainerSpawner.spawn_overseer_container, both deliberately deleted by the #2270 slice-5 overseer-lifecycle overhaul (task-5-1), which folded the bespoke overseer respawn loop into the general agent-restart machinery. The sentinel contract tests (test_overseer_lifecycle.py, test_overseer_repo_resolution.py) pin that deletion as the shipped design. Since the fold landed, all three files skip unconditionally at module level via their ImportError guards, so they contribute zero coverage while masking real import regressions behind a generic "modules not available" skip. The files' own skip-guard comments already declared this outcome: once the machinery is folded, "these respawn-specific tests no longer apply (the path is exercised via the normal agent-spawn tests)." Also refresh the two prose references to the deleted modules in test_overseer_repo_resolution.py and test_overseer_model.py. The surviving overseer surface keeps its coverage in test_overseer_lifecycle.py, test_overseer_repo_resolution.py, test_corrective_executor.py, test_overseer_model.py, and test_restart_overseer.py (114 tests, all passing).
) Follow-ups to the merged message-fallback slice scoping (#3544): - Phase-scope the message fallback in ConsensusStallCheck and IncompleteConsensusStallCheck. Refine, plan, and implement share the default review graph, so an earlier phase's untagged CONSENSUS_CONFIRMED messages satisfy the current phase's role set verbatim; the same consensus-complete false positive that killed issue-3523, just sourced from a legitimately completed phase. Every confirm emitter sets Message.phase, so the fallback now filters on it (null phase conservatively matches, mirroring reconstruct_tracker_from_messages). - Make the monitor's Track 1 slice-aware. The bare-id get_peer_consensus_tracker lookup cannot see slice trackers registered under {pipeline_id}/{slice_id}; a live slice tracker means a slice round is in flight and the slice executor is driving it, so pipeline-level reconstruction (a cross-slice soup nothing consumes) and Track 2 aggressive recovery must not run. Also pass phase= to reconstruct_tracker_from_messages so restart-time reconstruction does not replay an earlier phase's round. Also fixes a pre-existing import-sort lint error in test_cli.py.
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.
Review: Harden consensus-stall recovery against slice and phase blindness
Verdict: Approve. No blocking issues. The two hardening changes are correct, well-scoped, and cover both remaining false-positive paths that the aggressive stall watchdog could use to kill a live phase. I traced the data flow across the changeset and ran the two modified test files (57 tests pass).
What I verified
1. Phase-scoped message fallback (_consensus_messages.py, consensus_stall.py, incomplete_consensus_stall.py)
pipeline_level_confirmed_roles(messages, phase=None)is backward-compatible — the new kwarg defaults toNoneand the only two callers are the two updated checks. Unscoped behavior is preserved when phase is omitted.- The filter
phase is None or message_phase(m) in (None, phase)is right: aNone-phase message conservatively counts (matches thereconstruct_tracker_from_messagesandroutes/signalsidempotency-probe convention), an off-phase message is dropped. message_phase()handles both thestrcase (production:Message.phase: str | None) and a stray enum viagetattr(phase, "value", phase).- Consistency check that matters: the confirm emitters set
Message.phasethrough_resolve_pipeline_phase()which returnspipeline.current_phase.value, and both checks filter onpipeline.current_phase.value. Same string on both sides, so phase-scoping never spuriously suppresses a legitimate current-phase confirmation.
2. Slice-aware Track 1 (kubernetes_monitor.py)
get_slice_trackers()and thephase=param onreconstruct_tracker_from_messages()both exist with the assumed signatures.- Ordering is correct: the bare-id
get_peer_consensus_tracker()lookup returnsNoneduring a slice-DAG implement phase (trackers live under{pid}/{slice_id}), so control reaches the newget_slice_trackers()guard, which reports "handled" and prevents Track 2 from flipping the phase COMPLETE over a live slice round.sorted(slice_trackers)correctly logs the slice-id keys.
3. Deleted overseer tests (#3513, bundled)
spawn_overseer_container/spawn_overseer_job/_check_and_respawn_overseerno longer exist anywhere outside tests, so all three deleted files were skipping unconditionally at module import — zero coverage, only masking real import regressions. Deletion is a net improvement. The surviving overseer surface keeps coverage in the files the commit lists. Prose-only edits totest_overseer_model.py/test_overseer_repo_resolution.pyare harmless.
Tests exercise the real production path (ConsensusStallCheck(...).run(ctx), IncompleteConsensusStallCheck, monitor._handle_consensus_stall_recovery(...)), not hand-built fixtures. Name-vs-behavior is consistent (test_null_phase_confirmations_still_count → counts → consensus complete → DEGRADED; test_prior_phase_confirmations_do_not_trigger_stall → plan confirms dropped → HEALTHY).
Non-blocking
-
Mixed concerns. This PR bundles the #3513 dead-test deletion (~3,100 deletions) with the #3542 hardening. CLAUDE.md prefers separate concerns in separate PRs. The commit history separates them cleanly and the deletion is well-justified, so this is a process nit, not a correctness issue — flagging only because the large deletion count could distract a merger from the substantive change.
-
Belt-and-suspenders vs. the real trigger.
_clear_concurrent_state()already clears the message bus and the bare tracker on every phase transition, so the "earlier-phase confirmations linger on the bus" scenario should be rare in the normal path. The phase-scoping is still correct and worth having (it survives cases where the transition-time clear is skipped or a best-effort Redis clear fails), but it may be worth a one-line comment noting the primary defense is the transition-time clear, so a future reader doesn't assume this filter is load-bearing on the happy path. -
Stale-slice-tracker edge (advisory, not confirmed). The
get_slice_trackers()guard treats any live in-memory slice tracker as "the slice executor is driving it." If a slice executor died leaving a stale tracker in the registry, pipeline-level recovery would be suppressed. I checked this is mitigated by the per-slice consensus timeout /handle_timeoutpath (slice-level recovery is the correct layer, and post-restart the in-memory registry is empty until reconstructed), so it's low-risk — but it does rest on the slice-level timeout actually firing. No change requested.
— Authored by egg
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Address review feedback: add a comment noting that the transition-time _clear_concurrent_state() is the load-bearing defense against earlier-phase confirmations lingering on the bus, and the phase filter is a belt-and-suspenders backstop for when that clear is skipped or a best-effort Redis clear fails.
|
Thanks for the thorough review and the approval. Dispositions for the three non-blocking items: 1. Mixed concerns (bundling #3513 dead-test deletion with #3542 hardening) — 2. Belt-and-suspenders vs. the real trigger (one-line comment) — 3. Stale-slice-tracker edge (advisory) —
— Authored by egg |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Re-review: Harden consensus-stall recovery against slice and phase blindness
Verdict: Approve. The only change since my prior review (985f92d) is commit 43f11bf, which adds the explanatory comment I requested in non-blocking suggestion #2. No behavior changed. I re-verified the delta and the disposition of all three prior items.
Delta reviewed
43f11bf adds a comment at both phase-scoping filter sites — consensus_stall.py:170-176 and incomplete_consensus_stall.py:262-266 — noting that the transition-time _clear_concurrent_state() is the load-bearing defense against earlier-phase confirmations lingering, and the phase filter is a belt-and-suspenders backstop for when that clear is skipped or a best-effort Redis clear fails.
I verified the comment's factual claim rather than taking it at face value: _clear_concurrent_state() (routes/phases/_transitions.py:56-73) does clear the message store (get_message_store().clear(pipeline_id)) and remove the bare peer-consensus tracker (remove_peer_consensus_tracker(pipeline_id)) on every phase transition. So the comment correctly describes the primary-defense/backstop relationship — a future reader will not mistake the filter for the happy-path guard. The wording is consistent across both sites.
Prior feedback dispositions confirmed
- Mixed concerns (#3513 bundled with #3542) — author disagreed; no change. Acceptable: it was a flagged process nit, not a correctness issue, and the commit boundary keeps the dead-test deletion auditable.
- Belt-and-suspenders comment — fixed in
43f11bf. Verified correct and accurate (above). - Stale-slice-tracker edge — I marked this advisory / no-change-requested originally; correctly left as-is.
The substantive hardening (phase-scoped message fallback + slice-aware Track 1) was already verified in my prior review and is unchanged in this delta. Comment-only change, no new code paths, nothing to re-test.
— Authored by egg
|
egg review completed. View run logs 5 previous review(s) hidden. |
Follow-ups to #3544 for #3542. Two remaining ways the consensus-stall watchdog could still kill a live phase:
1. Phase-scope the message fallback (both tier-1 checks)
Refine, plan, and implement share the default review graph, so an earlier phase's untagged
CONSENSUS_CONFIRMEDmessages satisfy the current phase's expected role set verbatim. #3544 scoped the fallback by slice tag only, so a legitimately completed refine/plan round on the bus could still make the fallback report "consensus complete" for the whole implement phase, and aggressive recovery would kill it (the same failure mode as issue-3523, different message source).Every confirm emitter sets
Message.phase(routes/signals), sopipeline_level_confirmed_rolesnow takes aphaseargument and bothConsensusStallCheckandIncompleteConsensusStallCheckpass the current phase. A confirmation with a null phase conservatively matches, mirroring the convention inreconstruct_tracker_from_messages.2. Slice-aware Track 1 in the monitor
KubernetesMonitor._attempt_tracker_reconstructionlooked up only the bare-pipeline-id tracker, which cannot see slice trackers registered under{pipeline_id}/{slice_id}. During a slice-DAG implement phase that lookup returns None, and Track 1 either reconstructs a pipeline-level cross-slice tracker nothing consumes or falls through to Track 2 aggressive recovery, which marks the phase COMPLETE over a live slice round (the issue-3523 14-hour stall; under the event-loop modelphase_exec.agentsis empty, so the #2441 sibling-slice guard cannot hold the phase open).Track 1 now consults
get_slice_trackers(): any live slice tracker means a slice round is in flight and the slice executor is driving it, so recovery reports "handled" and Track 2 never fires. Reconstruction also passesphase=(the parameter added for exactly this inreconstruct_tracker_from_messages) so restart-time replay cannot fold an earlier phase's round into the current phase's tracker.Not addressed here (still tracked in #3542)
Bridging agent-registered contract questions (
cq-N) into the decision queue mid-phase. #3374 already surfaces them inget_statusaspending_contract_decisionsand they are directly resolvable viaprovide_input; moving them into the queue proper changes the documented post-gate two-wave resolve flow, so it needs a design decision.Testing
get_slice_trackerson the mock registry,phaseon mock messages).make lintclean (includes a drive-by import-sort fix intest_cli.pythat was failing on main);make testgreen (152 tests across the touched files).Refs #3542