Skip to content

batch: derive backpressure, honour queue.md, account outcomes, emit a merge order - #346

Merged
Jammy2211 merged 3 commits into
mainfrom
feature/mind-post-cortex-p4-batch-fidelity
Sep 3, 2026
Merged

Jammy2211 merged 3 commits into
mainfrom
feature/mind-post-cortex-p4-batch-fidelity

Conversation

@Jammy2211

Copy link
Copy Markdown
Contributor

Closes #345 — phase 4 of the mind-post-cortex epic (assessment gaps 3, 4, 5, 7).

Four gaps in the batch conductor, all the same shape: a stated contract nothing implemented.

What changed

1. --awaiting-review is derived (gap 4). It defaulted to 0 and nothing ever derived it, so every plan composed a shift as though the review queue were empty — the one input that can shrink a batch could only arrive by hand, and never did. derive_awaiting_review() reads active.md: a row naming an open PR (library-pr: / workspace-pr: — phase 3's keys) or whose status: says awaiting-merge / PR open (the fallback for rows written before that schema). The flag still overrides, including --awaiting-review 0, and the plan header prints which source was used. No gh call: a shift stays plannable offline.

2. queue.md order is honoured (gap 5). queue.md said the planner reads it; plan() did not. read_queue() parses the kind: prompt entries in file order (skipping the fenced schema example, retired entries and the kinds that name an epic or a theme), 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. An entry written against draft/… keeps matching after the prompt moves to active/. The Mind PR corrects queue.md to say exactly what is read.

3. Per-member ledger outcomes (gap 3). collect left every member on whatever the record said and the pm review file recorded decision: UNREVIEWED for all nine members — every one of which had merged. member_outcome() fills merged | rejected-at-review | carried | unreviewed from the ledger alone: a complete/ record naming the member (its - batch: line cites slot + slug, or the record is filed under the member's name) → merged; a review decision: rejecting it → rejected-at-review; a row still in active.md → carried; else unreviewed. In that order, because a rejected member is still in active.md. Written to the record as an outcomes: block, and plan now reports the previous slot's carried members first.

4. merge-order: in the packet and the record (gap 7). collect declined this outright ("members is sorted by HEALTH, so it cannot drive a merge order") — true of that list, not of the record. merge_order() uses dispatch_order with library repos first (the library-first gate) and same-repo members serialised (the first /prm 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. Rendered in the collect report and written to the record. Advice for the human's /prm sequence, never an action.

Both new blocks are rewritten on an open record and filled-once on a closed one, exactly as delivered: / packet: are, and the line-by-line rehearsal still guards the write. _set_block never deletes a line in place — the old body is marked and dropped in the final pass, so no index-based write in the module sees a list that changed length under it.

Tests

tests/test_batch_plan.py +11 (derived count, the flag override, read_queue, queue order, the basename match, carried report), tests/test_batch_collect.py +14 (each outcome, the ordering rule between them, library-first, same-repo serialisation, the report, both record blocks, re-apply idempotence, a closed record's blocks as history).

pytest -q: 883 passed, 1 failed — test_cortex_conductor.py::test_a_fixture_tree_finds_the_schema_its_checkout_ships, which fails in any task worktree (it asserts the fixture resolves the checkout's own scripts/cortex.py) and fails on main in a worktree too. The _batch substring trap in _cortex.py was watched for: the whole Cortex conductor suite is otherwise green.

git merge-tree against origin/feature/mind-post-cortex-p2-science-residue and origin/feature/mind-post-cortex-p3-pr-ledger: clean, both — neither sibling phase touches _batch.py.

Heart

pyauto-heart readiness --json was RED when this PR was opened (2026-09-03), with the same three reasons phases 2 and 3 recorded, verbatim:

  • PyAutoLens: CI failure
  • release validation FAILED (stage integrate)
  • PyAutoArray: open PR 11d old

None touches this diff — one Brain conductor, its doc and its tests; no library source, no release surface. The acknowledgement the human gave earlier today was scoped to other tasks and is not carried here: the RED is unacked for this task and merge needs the human's own call. Opened for review only.

🤖 Generated with Claude Code

https://claude.ai/code/session_013HsZA1ufn3msgPiDFxEXa6

Jammy2211 and others added 2 commits September 3, 2026 16:41
… merge order (#345)

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: #345

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013HsZA1ufn3msgPiDFxEXa6
…irewall)

The first CI run failed the tenant-firewall check: two comments and the merge-
order fixtures named real repositories, and `FIREWALL_ALLOWLIST` says never to
grow the list casually — an entry is a file an adopting fork must rewrite. The
comments now describe the shape rather than the instance, and the fixtures use
a bare short library name (which is what a prompt header carries anyway) and a
target nothing recognises for the member that must sort last.

`repos_sync.py --check --only "tenant firewall (organ code)"`: OK.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013HsZA1ufn3msgPiDFxEXa6
@Jammy2211
Jammy2211 merged commit d442df5 into main Sep 3, 2026
2 checks passed
@Jammy2211
Jammy2211 deleted the feature/mind-post-cortex-p4-batch-fidelity branch September 3, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

batch: derive backpressure, honour queue.md, emit merge order, check batch records

1 participant