Repository navigation
Description
Overview
The batch review packet lets a human rule on each member, but it gives them no way to run the batch — checking out "everything in the review" today means hand-checking-out several PR branches across several repos. This adds an opt-in batch collect --integration leg that builds one throwaway worktree root per review slot, with integration/<slot> cut fresh from origin/main per repo and every member's head branch merged in dispatch order, reporting clean/conflicted (with the colliding paths and member) per repo in the packet, the report and the record. Phase 1 first records each PR's head branch in the evidence JSON, which is the authoritative member → (repo, branch) map; phase 3 (--push, integration/* sweep expiry) is deferred to a later prompt — nothing here pushes, names a remote branch, or resolves a conflict.
Plan
- Phase 1 — evidence carries the head branch. Widen
GH_FIELDSwithheadRefName,headRefOid,headRepository,headRepositoryOwner, add a_head_ofhelper, and splicehead_ref/head_sha/head_repointo every PR row infetch_evidence. Unknown heads are reported empty, never guessed asorigin. - One override in
bin/worktree.sh(PYAUTO_WT_BRANCH, defaultfeature/$task) so the batch root reusesworktree_create— and with it the root layout (activate.shPYTHONPATH, per-taskNUMBA_CACHE_DIR/MPLCONFIGDIR, symlinks) — under branchintegration/<slot>instead of forking the definition of "a PyAuto worktree root". - New stdlib-only
_integration.py, loaded lazily likeload_cortex_conductor, owning the merges: plan jobs by repo in dispatch order (skipping merged / closed / fork / no-head members with a note), ensure the root idempotently, then per repo cutintegration/<slot>fromorigin/mainandmerge --no-ffeach member's head. - A conflicting member is left out and named, never resolved by the agent: capture
diff --name-only --diff-filter=Ubeforemerge --abort, then continue with the next member. Conflicts are the product — they do not change the exit code and do not touch any member's health word. - Opt-in, laptop-only, local.
--integrationoncollect, or- integration: yesin the batch record at dispatch; non-local-devlanes get a pointer, exactly like the existing--fetchleg. The only new network isgit fetch origin; nothing is pushed. - Safety property is the dirty-worktree refusal, not branch policy: the local branch is re-cut with
checkout -Bevery run (the preview is a function of current main + heads), but a worktree with uncommitted changes is skipped and said so in the packet. - Artifacts: a sentinel-bounded
integrationpacket region (always emitted, only re-rendered when a block exists, so a plain refresh cannot blank it), an "Integration branches" report section leading with the copy-pastesource <root>/activate.shline, and an- integration-root:record stamp that leaves the human's- integration: yesrequest line intact. - Docs + 13 tests, including the prompt's Witness (two members, one conflicting, in a temp bare-origin workspace).
Detailed implementation plan
Affected Repositories
- PyAutoBrain (primary)
- PyAutoMind (batches/AGENTS.md record schema)
Branch Survey
| Repository | Current Branch | Dirty? |
|---|---|---|
| ./PyAutoBrain | main | clean |
| ./PyAutoMind | main | epics.md (concurrent session) |
Suggested branch: feature/batch-review-integration
Worktree: ~/Code/PyAutoLabs-wt/batch-review-integration/
Claim note: PyAutoBrain also claimed by organ-board-github-link (PR #326, board/Pages files only) — disjoint files, parallel worktree approved.
Implementation Steps
Phase 1 — record member → (repo, branch) in the evidence
1.1 _batch.py GH_FIELDS (:619): add :636): returns headRefName,headRefOid,headRepository,headRepositoryOwner, with a comment that these four are the authoritative member → (repo, branch) map phase 2 drives from, and that the head repo is recorded because a fork's head is not on origin.
1.2 New _head_of(data, repo) -> dict beside _checks_from_rollup ({"head_ref", "head_sha", "head_repo"}, tolerating None/non-dict headRepository/headRepositoryOwner; head_repo falls back to "" (never to repo) so a caller can tell "same repo" from "unknown".
1.3 fetch_evidence (:706-716): add :290): extend the jsonc PR object with the three keys plus one sentence on why (**_head_of(data, repo) to the appended PR row. No other change; still writes nothing.
1.4 Doc agents/conductors/batch/AGENTS.md "The evidence JSON" (active.md's repos: field has four dialects; the PR's own head is the only reliable source; a head_repo != repo is a fork).
1.5 Test in tests/test_batch_collect.py: fake gh, assert the --json argv names headRefName and the row carries head_ref/head_sha/head_repo; null owner → "". Extend the shared pr() fixture with the three head keys.
Phase 2 — batch collect --integration
2.1 bin/worktree.sh _worktree_add_one (:84): :1079-1158): return local branch="${PYAUTO_WT_BRANCH:-feature/$task}", used in the worktree_add_repo echo too; documented in the header block. Backwards-compatible — unset, nothing changes.
2.2 New agents/conductors/batch/_integration.py (stdlib only, no _batch import, loaded lazily): workspace_root / task_name / branch_name / root_for, _git (GIT_TERMINAL_PROMPT=0, never raises), plan_jobs, ensure_root, integrate_repo, run. plan_jobs groups member PRs by repo in dispatch order and notes-and-skips merged / closed / fork-head / missing-head_ref / no-local-checkout. integrate_repo: merge --abort (stale run) → refuse dirty worktree → fetch origin → checkout -B integration/<slot> origin/main → per member merge --no-ff --no-edit origin/<head>; on conflict capture unmerged paths then merge --abort and continue. run(members, order, slot, *, lane) refuses non-local-dev lanes with a pointer and returns the block + notes.
2.3 load_evidence_doc(path) beside load_evidence — the whole evidence document, because integration is slot-level, not per member (and a laptop block pasted into a cloud session is how a non-laptop surface renders one at all). collect deliberately does not rewrite the human's --evidence file; that is --json > ev.json's job, documented so nobody "fixes" it.
2.4 collect() (dispatch_order (record order, not the health-sorted members) and integration_requested (via a small _yes() helper near _dash).
2.5 CLI: add "integration" to COLLECT_ONLY (so plan --integration is the usage error it should be) and an --integration store_true beside --fetch; _main_collect runs the leg when flagged or record-requested, else renders a pasted block from the evidence wrapper. --lane honoured. Exit codes unchanged.
2.6 collect_report: new _integration_report(d) inserted right after the NOT-DELIVERED lede so the source <root>/activate.sh line is at the top of a terminal run, then one line per repo (clean / conflicted with the colliding member and paths).
2.7 Packet: new _integration_panel(d) beside _rulings, every value through _e, no <script>; _fresh_packet always emits the pyauto:integration:begin/end sentinels (even empty) and packet_html appends the region only when a block exists, so a plain refresh cannot blank it.
2.8 record_update: after the packet line, stamp - integration-root: <root> — <branch>; N clean, M conflicted as a separate key — the dispatch-time - integration: yes is the human's request and must survive verbatim.
2.9 packet.css: three ul.integ rules mirroring ol.rulings; reuse .panel / .chip-healthy / .chip-failed. No packet.js change (the panel holds no review control).
2.10 Docs: batch AGENTS.md (Running line, constraints row, new "Integration branches" subsection, the git fetch/never-push sentence, the idempotence rationale), batch.sh usage, skills/batch/batch.md (dispatch line + "I want to run the whole batch" bullet), and PyAutoMind batches/AGENTS.md (- integration: yes / - integration-root: schema + the "easy to get wrong" paragraph).
2.11 Tests tests/test_batch_integration.py (13, on a temp bare-origin workspace with feature/alpha, conflicting feature/beta, clean feature/gamma): the Witness (alpha merged, beta left out with paths == ["a.py"], canonical checkout untouched), clean multi-member, re-run idempotent, dirty worktree skipped, fork/merged/missing-head reported, root carries activate.sh + symlinks, branch override honoured (and no regression without it), packet region sentinelled + escaped, refresh preserves the region, cloud lane pointer, record integration: yes triggers, apply stamps integration-root, plan --integration → rc 2.
2.12 Verify: python3 -m pytest -q -n auto PyAutoBrain/tests, then a manual laptop smoke pyauto-brain batch collect --slot <slot> --fetch --integration (no --apply, no remote writes) and inspect the root's git log.
Commit sequencing: (1) phase 1 + its test; (2) worktree.sh override + its test; (3) _integration.py + unit tests; (4) _batch.py wiring + packet.css; (5) docs (PyAutoMind batches/AGENTS.md rides its own PR, being the second repo on the prompt's Repos:).
Key Files
agents/conductors/batch/_batch.py— GH_FIELDS, _head_of, collect(), CLI, report, packet region, record stampagents/conductors/batch/_integration.py— NEW: plan_jobs / ensure_root / integrate_repo / runbin/worktree.sh— PYAUTO_WT_BRANCH overrideagents/conductors/batch/packet.css— ul.integagents/conductors/batch/AGENTS.md,batch.sh,skills/batch/batch.md— docstests/test_batch_integration.py— NEW;tests/test_batch_collect.py— head-field test- PyAutoMind
batches/AGENTS.md—integration:/integration-root:schema
Original Prompt
Click to expand starting prompt
Batch review: opt-in integration branches so a reviewer can run the whole batch together
Type: feature
Target: PyAutoBrain
Repos:
- PyAutoBrain
- PyAutoMind
Difficulty: large
Autonomy: supervised
Priority: medium
Status: formalised
Consequence: notify
Witness: a batch-conductor test builds a temp repo with two member branches, runscollect --integration, and assertsintegration/<slot>tree == merge of both heads plus a packet lineclean/conflicted: <path>per repo; evidence JSON carriesheadRefNamefor every member PR
Review-minutes: 0
Unattended: ready
Original request (verbatim, 2026-09-02)
For the PyAutoMind runs, I would like to be able to run the code representative of everythign in the review. This
is often require as I need to check if the outputs of a run are as expected and the like. Would it be possible
to make it so when the review is made, a single set of branches I can checkout locally and then created and
temporarily put on GitHub, which puts all changes together? I guess this could be problematic if PRs and changes
conflict, so I am happy to be told this cannot be done safely, but I guess it would also give me a sense of how
work would be resolved at the end. I dont necessarily always need this so it could also be something I can request
at the top of a review via a button, thus saving tokens when sensible.
Agreed design (assessment 2026-09-02, user: "yep sounds good")
Cheapest safe version is entirely local and needs no new credentials or doctrine change. Libraries are
imported via hardcoded PYTHONPATH (no editable installs), so checking out a merged branch per repo inside a
dedicated worktree root is enough to run everything. Never do this in the canonical checkouts: they feed
every other shell/agent and bin/morning.sh -> pull_all_main.sh flips them back to main.
Phase 1 — record member -> (repo, branch) reliably
- The batch record (
PyAutoMind/batches/<slot>.md) stores no repo/branch/PR per member;read_active/
active_forinPyAutoBrain/agents/conductors/batch/_batch.pyrecover PR URLs by regex over
active.md, whoserepos:field has four dialects. Do not parse those. - Add
headRefName(andheadRepository/repo name) toGH_FIELDS(_batch.py~632) and to the evidence
JSON schema inagents/conductors/batch/AGENTS.md("The evidence JSON"). This is the authoritative
member -> (repo, branch) map the later phases drive from.
Phase 2 — batch collect --integration (laptop lane, opt-in)
- New flag on
bin/pyauto-brain batch collect, off by default, laptop lane only (same precedent as the
opt-in--fetchleg that shells togh). Also honour anintegration: yesline in the batch record at
dispatch so the human can request it up front. - Creates one integration worktree root for the slot via the existing helper
(PyAutoBrain/bin/worktree.shworktree_create integration-<slot> <repos...>), which writes
activate.shwith its own PYTHONPATH and per-task NUMBA_CACHE_DIR / MPLCONFIGDIR. - Per affected repo: cut
integration/<slot>fromorigin/main, then realgit mergeof each member's
head branch in dispatch order (git 2.34.1 on this box has nomerge-tree --write-tree, so no dry-run
preview; the throwaway worktree is the preview). A conflicting member is left OUT of that repo's branch
(merge aborted), never resolved by the agent. - Packet reports per repo: clean / conflicted with the conflicting paths and which member collided. This
is the "how would this resolve at the end" signal the organism has never had; conflicts are the honest
output, not a blocker. Print one copy-pastesource <root>/activate.shline. - The packet page cannot be the button: it is static and credential-free (Submit is a link to GitHub's
new-file form). Opt-in lives in the record / the collect flag, not the page. Cost is git time, not model
tokens, so default-off is about clutter. - Regenerable packet region (sentinel-bounded, like
tiles/rulings) so refresh splices it.
Phase 3 (later, separate) — --push and expiry
--integration --pushpushesintegration/<slot>per repo from the laptop's own git auth. New network
leg in the Brain (stdlib-only/offline invariant,AUTONOMY.md~552-560): explicit, opt-in, laptop only.- Real branches only (GitHub accepts refs/heads/* and refs/tags/*). Refresh = new commit or
-2suffix,
never force-push (never rewrite pushed history). Never a PR, never a base for anything. PyAutoBrain/bin/branch_sweep.shwould classifyintegration/*as unmerged -> kept forever: ship an
expiry rule (record the branch names + asweep-afterdate in the batch record, which lives in a
LEDGER_DIRS auto-merging dir) so the sweep can void them after the review closes.
Constraints
- Batch planner already limits each shift to one member per library repo (members collide at merge), so
within-repo conflicts should be rare; cross-repo single-member cases (one member, five organ PRs) are the
common case. - Not the Gut organ: an integration ref is live work being previewed, not condemned material, and a Gut ref in
the Gut repo cannot be checked out as a library repo. Reuse only the pattern (prefix + manifest line + sweep-after).
Activity
Jammy2211 commentedon Sep 2, 2026
PRs Created (Brain library + Mind companion doc — no workspace leg)
Both PRs are open and labelled
pending-release, awaiting human merge inlibrary-first order (Brain before Mind).
feat: batch collect --integration — one merged worktree root per review slotdocs: batches — integration: / integration-root: record keysCommits
PyAutoBrain (
feature/batch-review-integration, headbf3e57b):dcd33e299e98c9PYAUTO_WT_BRANCHoverride for non-feature rootsf39230f_integration— merge every member's head into one review worktree68054fa--integrationwiring, report, packet region, record stamp7cdf59c--integrationin AGENTS.md, batch.sh, skills/batchbf3e57b--fetchasks gh formergedAt— there is nomergedfieldPyAutoMind (
feature/batch-review-integration, head3715b97a):3715b97aintegration:/integration-root:record keysAPI changes
pyauto-brain batch collect --integration— new opt-in, collect-only flag(also triggered by
- integration: yesin the batch record at dispatch).Builds one throwaway worktree root per slot,
~/Code/PyAutoLabs-wt/integration-<slot>/, withintegration/<slot>peraffected repo cut from
origin/mainand every member's PR head merged indispatch order. A conflicting member is left out and named with its
conflicting paths — that report is the deliverable, not a failure (exit code
unchanged). Nothing is pushed; no remote ref is touched. Refuses non-
local-devlanes with a pointer, like
--fetch.head_ref/head_sha/head_repo;--jsonoutput and pasted evidence docs gain a top-level
integrationblock; collectnever rewrites the
--evidencefile.integrationregion; report gains## Integration branches; record gains an- integration-root:stamp(the human's
- integration: yesrequest line survives).bin/worktree.sh:PYAUTO_WT_BRANCHoverrides the per-task branch name(default unchanged:
feature/<task>).git fetch origin, documentedin the batch
AGENTS.mdbeside--fetch.Also fixes a pre-existing break found by the end-to-end smoke:
GH_FIELDSasked
gh pr view --jsonformerged, which is not a field, soghfailed thewhole request and every
--fetchscored UNOBSERVABLE. NowmergedAt, withmergedderived.Tests
test_cortex_conductor.py::test_a_fixture_tree_finds_the_schema_its_checkout_ships,a known worktree-symlink artefact that passes on the canonical checkout and is
untouched by this change. No other exclusions.
tests/test_batch_integration.py(19 tests) and additions totests/test_batch_collect.py.second run reproduced identical trees, root and
integration/*branchesremoved afterwards, canonical repos left on
mainand clean.PyAutoHeart readiness
YELLOW (score 80) — acknowledged by the human at plan approval; both reasons
are unrelated to this change:
PyAutoArray: open PR 10d oldrelease validation incomplete: no rehearsal for current sourceNo RED reasons.
Not in this PR
Phase 3 (
--push, sweep expiry) deferred to a later prompt.🤖 Generated with Claude Code
https://claude.ai/code/session_01NR2L4MT5kTP8Lu9eR7dPUP
Jammy2211 commentedon Sep 2, 2026
Shipped
7a7c689)e869ce6)Batch review now has an opt-in integration leg:
batch collect --integrationbuilds one throwaway worktree root per slot, merging every member's head branch per repo, so the reviewer sees the members combined rather than one PR at a time. Conflicts are reported, not resolved — a conflicting merge is surfaced in the packet as a finding and left for a human — and nothing is ever pushed: the integration root is disposable and origin is untouched. Phase 1's head fields now flow through into the evidence packet, and the collector's fetch fix replaces the non-existentmergedfield withmergedAtso merged members are detected correctly.Phase 3 (the push leg) is filed as
draft/feature/pyautobrain/batch_review_integration_branches_p3_push.mdin PyAutoMind.