Repository navigation
Description
Overview
A shift holds a library from a task's start until its PR merges (#680), so a PR waiting for the human's /prm (decision-taken, judge, public name) stalls every later named task on that library for the rest of the shift — shifts 2026-11-18-pm (4 of 7 unstarted) and -pm2 (2 of 4 unstarted, ~1 h idle). This holds a library only while its worker runs and serialises the merges instead: later PRs wait behind earlier ones, are brought up to date from main once those merge, and merge on green CI at the new head.
Plan (approved by the human 2026-11-19, with rulings a–f all "yes")
Hold a library only while a worker on it is live; merge its PRs in order. Line numbers at PyAutoBrain f16c663 (B = organs/PyAutoBrain).
1. Start = live worker, not open PR
released_picks(_orchestrator.py:1572-1590): a pick indone/abandonedand inpicks, not inparked/pending_redispatch/inshift_pending, outcome withoutquestions→ released. Drop theprs and all(merged)condition. Also release a/dropped pick with no live lease (passlive=set(active_leases(slot));_tick_body.plan()callsactive_leases(slot)itself)._batch.plan(_batch.py:397-400, 514-551): mechanics unchanged; rewrite comment 514-519 (merges collide, starts do not; merge order is the close-out wait); reasons 536-540: named"{clash} held by {holder} — will start once {holder}'s worker ends", others"{clash} held by {holder} while its worker runs".on_origin(1593-1670): no code change (itsspentset followsreleased); docstring 1610-1616 → "finished, PR may still be open".- Sibling note: in the spawn loop (~2084-2087) compute this shift's not-yet-merged outcome PRs whose repo maps (via
_repo_key) to one of the member's library repos; passsiblings=[…]only when non-empty (theagainpattern) throughRealSpawner.spawn(492),FakeSpawner.spawn(246),session_command(392),worker_prompt(308); prependSIBLING_NOTE: listed PRs are open from this shift on the same repo and merge before yours; branch from main, never stack; readgh pr diff <url> --name-only; if a sibling already fixes your task endobsoletenaming it; if you must touch the same lines keep it minimal and say so in the PR body and proof packet — the close-out updates from main after they merge and refuses on conflict; aworktree_check_conflicthit naming only a listed sibling's slug is not a conflict (ruling e).
2. Close-out ordering + update from main
- Watcher side,
_start_closeouts(3700-3807): after the dropped/tier/carried-OPEN checks (3712-3739), beforehealth(pr)(3740). New_merge_blockers(counters, pr, pr_state, cache): earlier = anycounters["outcomes"][*]["prs"](carried included, plus a carriedo["behind"]) with the same canonical owner/repo (_merge_slots.pr_key), lower PR number, repo in LIBRARY_REPOS (ruling f). Blocks unless recorded merged orpr_state(url)says MERGED or CLOSED; unreadable → blocks (ruling c); cache per tick (ruling b). - Blocked: no closeouts entry, no slot, no refusal;
counters["merge_waits"][pr] = {task, behind, since}rebuilt each tick;eventswaitingonly whenbehindchanges. - Workspace PR of task T waits (not refused) while a library PR of T is waiting /
updated/ running; when that reaches a final state it proceeds as today (/prm's gate decides). - Update needed when a blocker merged after B's first worker spawn (
counters["workers"]); carried PRs: treat every merged earlier PR as "after". Then (guards: health HEALTHY, review-at cutoff, budget) take B's merge slot (_merge_slots.take, idempotent) andspawner.spawn_closeout(..., update_after=[A…]);RealSpawner.spawn_closeout(509-531) runs the public-name gate first. Newcloseout_update_template.md: check<task>.dropped; noteheadRefOid;gh pr update-branch <pr>(merge commit, never rebase/force — ruling a); conflict → refusalconflicts with main after <A> merged → your /prm; unchanged head →{"result":"current"}; else{"result":"updated","head":<sha>}; end, never wait. reap_closeouts(3561-3697, ~3607):updated→co.update(state="updated", head, updated, after, updates=n+1), slot kept;current→state="current"; neither counts as merge/refusal; GitHub MERGED → today's merged-outside logic.- Next ticks: the skip at 3709 re-examines
updated/current: RUNNING → continue; NO-CHECKS withinUPDATE_CHECKS_GRACE_S= 600 s ofupdated→ continue; FAILED → refuseCI FAILED on the updated head → your /prm, release slot; HEALTHY → normal close-out withafterpassed in.UPDATE_LIMIT = 2, then refusemain kept moving → your /prm. closeout_template.md+closeout_prompt(333-353):{after_step}(empty by default): each listed PR's merge commit must be an ancestor of head (gh pr view <A> --json mergeCommit,gh api …/compare/<mergeCommit>...<head>→ahead/identical) else refusebranch not updated after <A>; any{before}still OPEN refuses. Step 1 already re-runs the witness on the head.- review-at:
CLOSEOUT_CUTOFF_S(3748-3757) applies to update sessions; a waiting/updatedPR at review-at is not refused, the digest reports it.carry_in(1376-1426, condition 1408-1412) also carriesupdated/currentPRs and copiesmerge_waits[pr]["behind"]into the carried outcome aso["behind"]so a carried B never merges ahead of a non-carried A. - Digest (
_digest240-270):waits behind <A> (<A's state/refusal class>) — merge <A> first;updated→branch updated from main after <A>; CI on new head <health>; a per-library "Merge order" block in PR-number order, ▶ on the PR needing /prm now._events._closeouts(315-350):waitingevent (not needs-you); A's "Left for your /prm" gains "; N later PR(s) wait behind it"._status.py: show waits.
3. Interactions
merge-cap: waiting takes no slot; slot taken once before the update session, held through updated to merge/refusal; cap refusal (3784-3789) unchanged. decision-taken/judge/public-name A still refused → human /prm; later PRs wait, never refused for waiting; A merged → B updates then closes out; A closed → B freed. /kill → pending_redispatch holds the library; re-dispatch reuses its PR. /drop: dropped A blocks while OPEN (ruling c); dropped B refused at 3712 first; update session checks .dropped; never-started dropped pick frees its library. Pause/shadow unchanged (3532-3533). Parks keep holding (ruling d).
4. Risks
B built on main without A's fix → sibling note + update-and-refuse-on-conflict; count conflict refusals in the digest. Extra cost: one short session per update + CI re-run, skipped when B started after A merged.
5. Tests (each fails on today's main) + docs
tests/test_batch_named_tasks.py: second task spawns when the first is done with PR open / refused decision-taken / public-name / judge; question, park, pending_redispatch, inshift_pending hold;test_679_1new reason; three tasks (A done PR open, B live → C not spawned, reason names B); dropped never-started A frees;released_picks({done a, PR open}) == {"a"}; B's spawn argv contains SIBLING_NOTE naming PR1;test_679_5with PR still open.tests/test_orchestrator_closeout.py: address Copilot review from #6 #7 refused decision-taken + OPEN, PyAutoBrain: full Stages 0-3 release-validation orchestrator (M4) #8 green same repo → no close-out for PyAutoBrain: full Stages 0-3 release-validation orchestrator (M4) #8, no slot,merge_waits[#8].behind == [#7], nothing refused; different repo / lower MERGED or CLOSED → no wait; unreadable → waits; address Copilot review from #6 #7 MERGED after PyAutoBrain: full Stages 0-3 release-validation orchestrator (M4) #8's spawn → update session withupdate_after=[#7], prompt hasgh pr update-branch;updated→ state, slot held; RUNNING → nothing; NO-CHECKS in grace → nothing; HEALTHY → full close-out with after-step; FAILED → refused + slot released; conflict refused never retried; thirdupdatedrefused; workspace PR waits behind its waiting library PR; waiting within cutoff not refused, digest "waits behind";carry_incarriesupdated/waiting withbehind.tests/test_batch_plan.py:67text;tests/test_orchestrator_digest.py"Merge order" block.- Docs:
agents/conductors/batch/AGENTS.md:309-316(replace the feat(batch): a shift's library slot frees once its task's PR has merged #679 paragraph: "A library is held while its worker runs; merges wait in PR order (M3.6j)"; add the update step to the close-out description);skills/batch/batch.md:43-44reason text (≤ +3 lines, 200-line budget);AUTONOMY.mdunder "Unattended glance merges" (~864-880) and the network-surface paragraph (~966-975): record rulings a–f dated 2026-11-19.
Rulings (human, 2026-11-19: "approved, all six yes")
(a) an unattended update session may push a merge-from-main (gh pr update-branch, never force) to a shift PR branch, then must end; a later session merges only on CI green at the new head. (b) the watcher may gh pr view blocking PRs every tick while a later PR waits, incl. carried ones. (c) an earlier PR blocks until GitHub says MERGED or CLOSED, whatever its state (dropped, red, abandoned). (d) parks on a question keep holding the library start. (e) a worker may proceed past a worktree_check_conflict hit naming only a listed sibling slug. (f) library repos only, and only PRs this shift knows (its outcomes + carried behind).
Branch: feature/shift-merges-in-order · worktree ~/Code/PyAutoLabs-wt/shift-merges-in-order/
Tier + merge mode: effective level: supervised; merge mode: human /prm
Original Prompt
Click to expand
M3.6j A shift serialises library merges, not starts, so a PR awaiting /prm does not stall its library
Type: feature
Target: PyAutoBrain
Repos:
- PyAutoBrain
Difficulty: medium
Autonomy: supervised
Priority: high
Status: draft
Filed: 2026-11-18
Epic: autonomous-orchestrators
Consequence: judge
Witness:python -m pytest tests/test_batch_named_tasks.py tests/test_orchestrator_closeout.py -qpasses with new tests that fail on today's main: (1) two named glance tasks on one library — the second starts once the first's PR is open, even when the first's close-out was refused for a human /prm (decision-taken, public name, judge); (2) the second's close-out does not merge while the first's PR is open; (3) once the first merges, the second's close-out updates its branch from main and merges only on CI green at the new head; (4) never two workers live on one library at once
Lane: any
Unattended: ready
Request (verbatim)
Human, 2026-11-18, at the end of shift 2026-11-18-pm: "I think theres an issue where the
orchestator should not get stuck and unable to do follow up tasks cause it needs my prm"
Why
PyAutoBrain#679 (PR #680, merged 2026-11-18) frees a shift's library slot only once the task
holding it has all its PRs merged. In shift 2026-11-18-pm (7 named glance bugs, 5 on
PyAutoGalaxy, 2 on PyAutoFit) the first PyAutoGalaxy PR merged unattended (#722) and the next
started, but then PyAutoGalaxy#724 was refused for an unattended merge ("public name added or
renamed: a human /prm") and PyAutoFit#1783 likewise ("decision-taken label"). Both libraries
stayed held until review-at: 4 of 7 tasks never started, and the shift sat idle from ~16:36Z
to 17:30Z with no workers live and 3.9M of its 5M token budget unspent.
The one-per-library rule exists because concurrent library PRs collide at merge. Work does not
collide; merges do. Holding the start of the next task until a human /prm stalls the shift
on the one step the shift cannot do.
Proposed shape (to be planned)
- A library is held for starting only while a worker on it is live (never two workers on
one library at once). - A library is held for merging while any earlier PR of this shift on it is open: the next
task's close-out waits (no refusal, no slot taken) until that PR merges. - When it may merge, the close-out updates the branch from
mainand requires CI green on the
new head before merging; a conflict refuses and leaves it for /prm. - Each later PR's worktree branches from
main, not from the open PR (no stacked PRs). - The digest says which PRs wait behind which /prm, so the human merges in order.
- Consider whether the next task should instead branch from the open PR's branch when it
touches the same files — out of scope unless planning shows the update-from-main step
conflicts too often.
Not in scope
- Unattended merging of PRs that need a human /prm.
- Raising merge-cap or changing close-out guards other than the wait.
Activity
fix(batch): keep the merge order on every path (M3.6j review F1, F2, …
Jammy2211 commentedon Nov 19, 2026
Shipped: #684 merged by human /prm. A shift now holds a library only while its worker runs and merges that library's PRs in PR order (wait → gh pr update-branch → close-out on green at the new head). Independent review FINDINGS F1/F2/F5 fixed in b7c04fa; F3/F4/F6 listed as known on the PR. Rulings a–f recorded in AUTONOMY.md.