Repository navigation
fix: shift watcher — close four state-machine gaps (#603) - #604
Merged
Merged
Conversation
- CODE-1: every reap, park, crash, spawn and close-out start/settle is written to counters.json as it happens; a .done / .closeout file and a lease are deleted only after that write. A per-task spawn failure (or a close-out that cannot start) is recorded as a refusal and the tick carries on instead of raising. - CODE-2: a failed, timed-out or malformed `claude agents` read is unknown (AgentsView.known() False), not an empty list; every liveness decision is skipped that tick. A real worker is a crash only after UNLISTED_READS_FOR_CRASH=2 consecutive unlisted reads past the grace, or a positive ended/done state. LEASE_GRACE_S 120 -> 420 (>= 2 x the measured 184 s median tick). - ORCH-1: parking keeps the lease with state `parked` (holding no worker slot); the reaper and the late sweep consume a parked task's .done (outcome, tokens, late-arrival line) and release a parked session that ends without one (never a crash, never re-dispatched). - ORCH-3: before a finished close-out is counted merged or refused (which frees its merge-cap slot) the PR state is read from GitHub (gh_pr_state: `gh pr view --json state,mergedAt,mergedBy`, behind a pr_state seam on tick() and the spawners; FakeSpawner never calls gh). A GitHub-confirmed merge counts and writes its stage-2 row with or without a .closeout; an unreadable GitHub keeps the slot held. - main(): no KeyError on digest/late ticks that carry no `spawned`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- A `merged` .closeout counts only when GitHub says MERGED. GitHub OPEN (e.g. --auto pending) or unreadable: not counted, no stage-2 row, the cap slot stays held and is re-checked each tick. GitHub CLOSED: refused, "close-out said merged, GitHub closed". - A refused (non-merged) verdict on a PR GitHub shows MERGED was merged by someone else: never counted in glance_auto_merges, no stage-2 row, slot freed, recorded as "merged outside the close-out (mergedBy=...)" (event list `merged_outside`). - No .closeout + GitHub MERGED still counts as one unattended merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Programme task M1.1 (epic
autonomous-orchestrators, phase 8). This closes the four state-machine gaps in the shift watcher that the ecosystem review of 2026-11-10 confirmed. Fixes #603..done,.closeoutand lease files are deleted only after that write. A failed spawn becomes a refusal and the tick carries on.AgentsView.known()is False when theclaude agentsread fails, times out or returns bad JSON, and that tick then skips every liveness decision. A crash now needs two consecutive unlisted reads or a positive ended state.LEASE_GRACE_Sgoes from 120 to 420.state: parkedand excluded from the worker cap. The reaper and the late sweep consume its.doneand record the outcome, tokens and a late-arrival line.gh pr view --json state,mergedAt,mergedBy, behind apr_stateseam) now decides every merge count:.closeout.mergedverdict counts only when GitHub says MERGED. While the PR is OPEN or GitHub can't be read, the slot stays held. A CLOSED PR is a refusal.main()no longer raisesKeyError 'spawned'on digest ticks.API Changes
None public.
tick()gains an optionalpr_state=seam. Callers that don't pass it, and spawners without apr_statemethod, keep the old behaviour.Test plan
python -m pytest tests/test_orchestrator_*.py tests/test_batch_watch.py -q: 134 passed, 1 skipped (before this branch: 116 passed, 1 skipped).test_a_tick_that_raises_after_a_reap_keeps_the_outcome_and_never_redispatchestest_a_failing_claude_agents_read_leaves_live_workers_live[rc1|timeout|badjson]test_a_parked_worker_that_finishes_after_review_at_is_a_late_arrivaltest_a_github_merged_pr_with_no_closeout_file_counts_as_one_mergeevidence/orch_code/) reproduce each bug on the base and not on this branch.test_grouped_organ_consumers.py::test_hygiene_map_and_heart_board_find_grouped_checkouts, also fails on the base. It is caused by thePYAUTO_*variables thatactivate.shsets.ab48caa, with two must-fix items on ORCH-3, fixed in1898e11. Re-review: CLEAN.PyAutoMind/draft/bug/pyautobrain/shift_watcher_followups_after_state_gaps.md.Heart RED override (development only)
Authorization from the live human in the programme session, 2026-11-12: "Override + merge on green". This authorizes the development-only RED override for #603 and gives the merge command, conditional on every required check being green within the turn.
Heart verdict RED (
pyauto-heart readiness, ts 2026-11-12T16:29:40Z). The current RED reasons, verbatim:None of these reasons is in PyAutoBrain. Branch gates passed: tests (above), review CLEAN, smoke not applicable. This PR does not fix Heart, and Heart stays RED for release.
Tier: glance. Merge mode: auto-merge on green if the Witness passes, with a post-merge summary. A RED override additionally needs the human's merge command, which was given in the same turn.
🤖 Generated with Claude Code