Repository navigation
batch: derive backpressure, honour queue.md, account outcomes, emit a merge order - #346
Merged
Merged
Conversation
… 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
…tex-p4-batch-fidelity
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.
Closes #345 — phase 4 of the
mind-post-cortexepic (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-reviewis derived (gap 4). It defaulted to0and 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()readsactive.md: a row naming an open PR (library-pr:/workspace-pr:— phase 3's keys) or whosestatus:saysawaiting-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. Noghcall: a shift stays plannable offline.2.
queue.mdorder is honoured (gap 5).queue.mdsaid the planner reads it;plan()did not.read_queue()parses thekind: promptentries 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 againstdraft/…keeps matching after the prompt moves toactive/. The Mind PR correctsqueue.mdto say exactly what is read.3. Per-member ledger outcomes (gap 3).
collectleft every member on whatever the record said and the pm review file recordeddecision: UNREVIEWEDfor all nine members — every one of which had merged.member_outcome()fillsmerged | rejected-at-review | carried | unreviewedfrom the ledger alone: acomplete/record naming the member (its- batch:line cites slot + slug, or the record is filed under the member's name) → merged; a reviewdecision:rejecting it → rejected-at-review; a row still inactive.md→ carried; else unreviewed. In that order, because a rejected member is still inactive.md. Written to the record as anoutcomes:block, andplannow reports the previous slot'scarriedmembers first.4.
merge-order:in the packet and the record (gap 7).collectdeclined this outright ("members is sorted by HEALTH, so it cannot drive a merge order") — true of that list, not of the record.merge_order()usesdispatch_orderwith library repos first (the library-first gate) and same-repo members serialised (the first/prmmovesmainand 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/prmsequence, 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_blocknever 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 ownscripts/cortex.py) and fails onmainin a worktree too. The_batchsubstring trap in_cortex.pywas watched for: the whole Cortex conductor suite is otherwise green.git merge-treeagainstorigin/feature/mind-post-cortex-p2-science-residueandorigin/feature/mind-post-cortex-p3-pr-ledger: clean, both — neither sibling phase touches_batch.py.Heart
pyauto-heart readiness --jsonwas RED when this PR was opened (2026-09-03), with the same three reasons phases 2 and 3 recorded, verbatim: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