From d97312085a1d5a92315e874a5955eff959afbace Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 3 Sep 2026 16:41:52 -0400 Subject: [PATCH 1/2] batch: derive backpressure, honour queue.md, account outcomes, emit a merge order (#345) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Four gaps in the batch conductor, all of them the same shape — a stated contract nothing implemented: - `--awaiting-review` defaulted to 0 and was never derived, so every plan composed a shift as though the review queue were empty. It is now read from `active.md`: a row naming an open PR (`library-pr:` / `workspace-pr:`, the phase-3 keys) or whose `status:` says `awaiting-merge` / `PR open`. The flag still overrides, including `0`; the header says which source was used. - `queue.md` says the planner reads it. It did not. `read_queue` parses the `kind: prompt` entries in file order and the pool sorts by queue rank first — a queued prompt outranks an unqueued one, file order wins among queued, and cheapest-first still governs below the queue. A queue entry keeps matching its prompt after it moves to `active/`. - `batch collect` left every member `UNREVIEWED`. It now fills a per-member ledger `outcome:` — merged / rejected-at-review / carried / unreviewed — from the completion records, the review file and `active.md`, offline. All nine members of the 2026-08-31-pm slot merged and every one was recorded `decision: UNREVIEWED`; the completion records knew and nothing read them. `plan` now reports the previous slot's carried members first. - `collect` declined a merge order because `members` is sorted by health. The record's dispatch order is not: `merge-order:` is that order with library repos first and same-repo members serialised, rendered in the report and written to the record. Advice for `/prm`, never an action. Both new record blocks are rewritten on an open record and filled once on a closed one, like `delivered:`/`packet:`. The write still goes through the line-by-line rehearsal. Issue: https://github.com/PyAutoLabs/PyAutoBrain/issues/345 Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_013HsZA1ufn3msgPiDFxEXa6 --- agents/conductors/batch/AGENTS.md | 65 +++++ agents/conductors/batch/_batch.py | 444 +++++++++++++++++++++++++++++- tests/test_batch_collect.py | 205 ++++++++++++++ tests/test_batch_plan.py | 129 +++++++++ 4 files changed, 829 insertions(+), 14 deletions(-) diff --git a/agents/conductors/batch/AGENTS.md b/agents/conductors/batch/AGENTS.md index 06be94a9..c9f4307e 100644 --- a/agents/conductors/batch/AGENTS.md +++ b/agents/conductors/batch/AGENTS.md @@ -63,6 +63,47 @@ teaches the human to distrust the number it reports. Counted in **tasks awaiting review**, never in PRs — 94 of 332 August records named two or more PRs, so a PR-count cap trips on a single healthy batch. +**Derived, not asked for.** The count is read from `PyAutoMind/active.md`: a +task counts when its row names an open PR (`library-pr:` / `workspace-pr:` — +the PR ledger, `PyAutoMind/REFERENCE.md` "The PR keys") or its `status:` says +`awaiting-merge` / `PR open` in words, which is how rows written before that +schema spelled it. `--awaiting-review ` still overrides, including `0` — a +human asserting the queue is empty outranks the derivation. Until 2026-09-03 +the flag defaulted to `0` and nothing derived it, so every plan composed a +shift as though nothing were waiting: the one input that can SHRINK a batch +could only arrive by hand, and never did. + +No `gh` call, here or anywhere in `plan`. `active.md` is the ledger and GitHub +is the truth about mergeability; a shift must be plannable offline +(`mind_post_cortex_epic.md`: no live PR state in Mind). + +## The queue is the order + +`PyAutoMind/queue.md` is the one file the human maintains by hand, and the only +statement of *importance* the planner has — everything else it reads is a +property of the work, not a preference about it. **Order is priority**: moving +an entry up *is* the act of prioritising it. + +`plan` reads exactly three things, and nothing live: + +1. `queue.md` — the `kind: prompt` entries, in file order; +2. the `draft/` backlog, graded through the sizing faculty; +3. the review-queue depth, derived from `active.md` as above. + +A queued prompt outranks an unqueued one; among queued ones the file's order +wins; below the queue the old rule stands — cheapest first, because that list +is read when there is a slot to fill and the question is what fits in it. A +queue entry written against `draft/…` still matches its prompt after it moves +to `active/` (matched on the basename), so an entry never silently loses its +priority. `retired`, `epic-slice` and `theme-sweep` entries are skipped rather +than resolved: resolving one is a decision (which phase? which chip?), and the +reader does not decide. + +`plan` also reports what the **previous slot carried**: the members its +`outcomes:` block marks `carried` are read first, because they are already +costing the human review-minutes in the slot being planned and a batch composed +as though they were not is over-sold by exactly that much. + - clear → the full budget; - above half the cap → the review-bearing half is **halved** (the fill is not: it does not touch the queue); @@ -472,6 +513,30 @@ are exactly the outcomes no word list would have protected. The write is rehearsed on a throwaway copy and refused if a member line or a key would be lost; the `notes: |` block is never touched. +Two **blocks** are stamped alongside those keys, both derived and both rewritten +on every apply of an open record (and filled once, then left, on a closed one — +its contents are history, like `delivered:`): + +- **`outcomes:`** — one `: ` per member. This is the *accounting*; the member line's outcome + column is the *evidence* ("PyAutoFit#1554, 4/4 checks green"). It is read + from the ledger and nothing else: a `complete/` record that names the member + (`- batch: — member ```, or a record filed under the member's + own name) → `merged`; a review `decision:` that rejected it → + `rejected-at-review`; a row still in `active.md` → `carried`; otherwise + `unreviewed`. In that order, because a rejected member is still in + `active.md` and a merged one may be too. All nine members of the + 2026-08-31-pm slot merged and every one of them was recorded + `decision: UNREVIEWED` — the completion records knew, and nothing read them. +- **`merge-order:`** — the `/prm` sequence, as advice and never an action: + dispatch order (the order the human listed the members in — the only stable + order there is, since `members` is sorted by health), with library repos + first (the library-first merge gate) and same-repo members serialised (the + first merge moves `main` and stales its siblings' evidence). Nothing is + filtered: a member with no PR is listed in its place with what it is waiting + on, because an order that silently omits a member is an order somebody merges + out of. It is rendered in the collect report's summary too. + ### The close leg **`dev` — collected once, reviewed once.** A review that has landed closes the diff --git a/agents/conductors/batch/_batch.py b/agents/conductors/batch/_batch.py index 08375897..020a64e2 100644 --- a/agents/conductors/batch/_batch.py +++ b/agents/conductors/batch/_batch.py @@ -45,7 +45,7 @@ from _sizing import ( # noqa: E402 BODY_MAP_PATH, LIBRARY_REPOS, effective_autonomy, effective_consequence, effective_difficulty, effective_review_minutes, effective_unattended, - parse_prompt, priority_rank, + normalise_repo, parse_prompt, priority_rank, ) # `_status` (same directory) is the one definition of this vocabulary — the # batch status box on both dashboards reads a record the same way this @@ -157,15 +157,96 @@ def survey(mind: Path) -> list[dict]: return out +#: A `queue.md` section heading — `## .