Repository navigation
feat: shift close-out at PR-open, merge on green CI (M3.7b) - #689
Merged
Merged
Conversation
…full smoke Rulings S2, S5, S6 of 2026-11-19 (AUTONOMY.md "Shift speed"), decisions A and B. PyAutoBrain#688. - S5: `_start_closeouts` starts a close-out when `gh pr checks` reads RUNNING or HEALTHY; FAILED/UNKNOWN refuse with no session; NO-CHECKS waits UPDATE_CHECKS_GRACE_S from when the watcher first saw the PR (`counters["pr_seen"]`), then refuses. The same rule applies to an updated PR: RUNNING on the verified new head starts the merge close-out, which waits in-turn; its NO-CHECKS grace and head check are kept. Every other guard and the merge order are unchanged. The close-out gets a CI deadline, min(start + CLOSEOUT_CI_WAIT_S (30 min), review-at). - Decision A: the watcher takes no merge slot for a merge close-out; it checks `_merge_slots.room` (read-only, counting merge close-outs already running without a slot, so the cap is not oversold) and refuses with no session when there is no room. The session runs `merge-slot take` as a bare call just before the merge. The reaper frees a refused close-out's slot whether the watcher or the session holds it for that task. The branch-update path keeps the watcher's take. - S6: a branch update is needed only when the PR's changed files overlap a PR of the shift merged ahead of it, a file list cannot be read, or GitHub reports the PR CONFLICTING (`mergeable`, now a field of `gh_pr_state`). New read-only `gh_pr_files` (once per PR per shift, cached in `counters["pr_files"]`; a list of 100+ files counts as unreadable). Disjoint PRs are named in step 4b, not compared. - S2: the close-out runs no full affected smoke (`smoke_command`, CLOSEOUT_SMOKE_JOBS removed). Template reordered: witness on the PR head (record headRefOid), diff + public names, label/tier, Heart, 4b, in-turn `ci-verdict --until`, head unchanged, .dropped, merge-slot take + /prm, cleanup, end. - `ci-verdict --until <iso>`: re-judges every 30 s while PENDING, at most 540 s per call; exit codes unchanged; a bad time is usage (64). - Docs: AUTONOMY.md S2/S5/S6 with revert conditions, leg 2, the glance merges and M3.6j (a) paragraphs, network-surface amendment (decision B); batch AGENTS.md; worker_template; prm reference; pyauto-brain help. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… pins - CI deadline = min(start + 30 min, review-at - CLOSEOUT_MERGE_MARGIN_S (300 s)), so a close-out started near review-at cannot merge after it (#632 F1). - `_pr_files_once` caches an unreadable read (None, also when the reader raises) as an overlap and never reads that PR again in the shift. - Template step 8: go on only when `merge-slot take` prints `taken: …`; `refused:`, `cannot tell:` or exit 0 `not in a shift` refuse `merge slot not taken: <first line> → /prm`. The merge is pinned with `gh pr merge --match-head-commit <the step-1 headRefOid>`. - `ci-verdict --until` bounds one call by wall time from its start, gh reads included (reads again only while sleep + longest read fits in 540 s), and re-checks the deadline after each sleep. Template: run it with a Bash timeout of 600000 ms. - AUTONOMY.md S5 and batch AGENTS.md mention the margin, the pin and the unreadable-list cache. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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
M3.7b of the autonomous-orchestrators epic (closes #688). Rulings S2, S5 and S6 (human, 2026-11-19) and the human's plan decisions A and B.
glance/notifyclose-out at PR-open. CI RUNNING or HEALTHY starts it; FAILED or UNKNOWN refuses with no session; NO-CHECKS waits 10 minutes from when the watcher first saw the PR, then refuses. The session runs the witness and reads the diff while CI runs, then waits in-turn (pyauto-brain ci-verdict <pr> --until <deadline>) and merges only on GREEN. The deadline is the earlier of start + 30 minutes and review-at minus 5 minutes.CONFLICTING. Merge order (M3.6j rulings b, c, f) is unchanged.merge-slot takeitself immediately before merging, and goes on only on ataken:line. The branch-update path keeps the watcher's take. A refused close-out's slot is freed whichever side took it.gh pr view --json filesfor a waiting library PR and the earlier shift PRs merged ahead of it, once per PR per shift (an unreadable list is cached too, never re-read);mergeablerides on the existinggh pr view.gh pr merge … --match-head-commit), and refuses if the head moved after the witness.API Changes
None to any library. Brain internals:
bin/ci_verdict.py(andpyauto-brain ci-verdict) gains--until <iso>, which re-judges every 30 seconds while PENDING, at most 540 seconds per call; exit codes are unchanged (0 GREEN, 1 RED, 2 PENDING; 64 for a bad time)._merge_slotsgains aSESSIONholder and a read-onlyroom(). See full details below.Risks
maintogether.mainCI and the shift-end sweep find it after the merge. Revert condition (S6): one redmainCI traced to two disjoint shift PRs merged this way restores the unconditional update.Test Plan
tests/test_closeout_at_pr_open.py(27 tests). 21 of them failed on the unmodified code (S5 start with CI pending, deadline and margin, NO-CHECKS grace, prompt order with no smoke, S6 disjoint with no update, unreadable-list cache, merge order with a running earlier close-out, decision A slot release,--untiltiming, AUTONOMY.md S2/S5/S6). The other 6 pin behaviour that stays (red CI refuses, overlap/conflict/unreadable gets the update, full cap refuses).bin/check_skill_line_counts.sh 200 PyAutoBrain: OK. Tenant firewall (organ code): OK.install.sh --check-project-discovery: OK.--untilcall could hit the tool timeout, the merge was not pinned to the witnessed head). All fixed; round 2 CLEAN.Full API Changes (for automation & release notes)
Removed
_orchestrator.smoke_command,_orchestrator.CLOSEOUT_SMOKE_JOBS— the close-out runs no smoke (S2).Added
bin/ci_verdict.py --until <iso8601>— poll while PENDING up to the deadline, at most 540 s per call._orchestrator.gh_pr_files(url, run=None)— read-only changed-file list._orchestrator.CLOSEOUT_CI_WAIT_S = 1800,CLOSEOUT_MERGE_MARGIN_S = 300._merge_slots.SESSION,_merge_slots.room(slot, pr, task, pending).Changed Behaviour
_start_closeouts: starts at PR-open (S5); overlap-only branch update (S6); no watcher slot take for a merge close-out (decision A).gh_pr_statealso returnsmergeable.closeout_prompt/closeout_command/spawn_closeouttakeci_untilanddisjoint.closeout_template.md: smoke step removed; witness → diff → label/Heart → merge order → in-turn CI wait → head check →.dropped→ own merge-slot take → pinned merge.🤖 Generated with Claude Code