Repository navigation
feat: batch collect --integration — one merged worktree root per review slot - #338
Merged
Merged
Conversation
A batch record names members, never branches, and `active.md`'s PR field has four spellings — so a PR's own head is the only reliable member -> (repo, branch) map. `gh pr view` is now asked for `headRefName`/`headRefOid`/ `headRepository`/`headRepositoryOwner`, and `_head_of` splices `head_ref`, `head_sha` and `head_repo` onto every PR row. A fork or a deleted head repo reports an empty `head_repo` rather than being guessed as `origin`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NR2L4MT5kTP8Lu9eR7dPUP
`_worktree_add_one` hardcoded `feature/$task`, so every root worktree.sh builds claims to be feature work. The batch conductor's forthcoming `collect --integration` needs a throwaway review root named `integration/<slot>` instead — the one thing the helper could not say. The override is additive: unset, nothing changes, which the second test pins. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NR2L4MT5kTP8Lu9eR7dPUP
…ree (#337) One throwaway worktree root per slot: every member's head branch merged into `integration/<slot>`, per repo, off `origin/main`, so the human can RUN the whole batch before ruling on any of it — and so "how would these resolve at the end?" is answered by a merge rather than by reading diffs. Three properties, deliberately. It writes no remote: `git fetch origin` and local merges, no push and no PR. It resolves nothing: a member whose merge conflicts is left OUT and named with the conflicting paths, and that report is the product. And it is stdlib-only, importing nothing from `_batch`, so the conductor can load it lazily and this suite can drive it against throwaway repos with no Mind, no record and no packet in sight. The seam with `bin/worktree.sh` is that worktree.sh knows LAYOUT and this module knows MERGES. The root is built by shelling to `worktree_create` with `PYAUTO_WT_BRANCH=integration/<slot>`, because the value of that function is activate.sh's PYTHONPATH, the per-task caches and the symlink of every other top-level entry — re-deriving it here would fork the definition of "a PyAuto worktree root" into two places that would drift. The merges are plain git, because a shell helper would bury the exit code and the unmerged-path list the report needs. The branch is re-cut from `origin/main` every run: the merge result is a function of the current base and the current heads, so a second run that stacked onto the first would preview a base that no longer exists. That is only safe because a dirty integration worktree is refused outright — that refusal, not the branch policy, is the safety property, and it is what the re-run and dirty-worktree tests pin. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NR2L4MT5kTP8Lu9eR7dPUP
…amp (#337) `collect --integration` (or `- integration: yes` written into the record at dispatch) runs the merge leg and reports it in the three places collect already owns: the terminal report, the packet page, and the record's stamps. `collect()` now exposes `dispatch_order` — `d["members"]` is sorted by HEALTH, so it cannot drive a merge order, and the order the human listed the members in is the order the preview must merge them in. It also exposes `integration_requested`, read through a `_yes` helper from the record key. `load_evidence_doc` returns the whole evidence document alongside `load_evidence`'s members, because `integration` is slot-level rather than per member — a laptop's 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 file is an input, `--apply` writes exactly the packet and the record, and persisting the block is `--json > ev.json`'s job. The report puts the `source <root>/activate.sh` line at the TOP, right after the NOT-DELIVERED lede: the whole point of the leg is that the human can run the batch, and a source line five screens down is a line nobody sources. The packet's `pyauto:integration` sentinels ship even when the body is empty, so a later `--integration` refresh has somewhere to splice into, while the region is only re-rendered when this collect HAS a block — a plain refresh must not blank a preview that is still true. The panel carries no `data-*` hook and no second `<script>`: there is nothing to rule about a merge preview. `- integration-root:` is a separate key from the dispatch-time `- integration: yes`. That line is the human's request; overwriting it with a path would erase what they asked for and leave only what happened. Conflicts move no exit code and no member's health word. A member's health is about its own delivery; a merge collision is a property of the slot, and mixing them would make a green member read as SUSPECT because a sibling touched the same file. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NR2L4MT5kTP8Lu9eR7dPUP
The conductor's AGENTS.md gains a constraints row, a `## Running` line and an "Integration branches (`--integration`)" subsection: the block's JSON shape, the four skip reasons (merged, closed, fork, no `head_ref`), the dirty-worktree refusal, the re-cut policy and why the refusal rather than the policy is the safety property, and that conflicts change no exit code and no member's health word. The network line is said out loud, because `AUTONOMY.md`'s "the Brain reads no network except one opt-in flag" predates this one: `--integration` fetches and reads; it never pushes, opens a PR, or touches a remote ref. Like `--fetch` it is opt-in, non-default and laptop-only, and pushing `integration/<slot>` is a separate, later decision. Also documented so the next session does not "fix" it: **collect does not rewrite your `--evidence` file.** That file is an input; persisting the block is `--json > ev.json`'s job, and a block pasted back into an evidence file is how a cloud session renders one at all. The skill says where a member has to be RUN — a library change is live anywhere once `activate.sh` is sourced, a workspace member's script must be run from inside `<root>/<workspace>` — and adds the dispatch-time line: if the human says they will want to run the batch, write `- integration: yes` into the record. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NR2L4MT5kTP8Lu9eR7dPUP
`gh pr view --json merged` does not drop an unknown name, it rejects the WHOLE request: "Unknown JSON field: merged" (gh 2.98). So one wrong word in `GH_FIELDS` made every PR of every `--fetch` exit 1 and be scored UNOBSERVABLE — and the report blamed the PRs, not the field list. Found driving the `--integration` smoke, which cannot run without a working `--fetch`. `mergedAt` is the same fact and is a real field; the evidence row's `merged` stays a bool, derived from it, so nothing downstream changes shape. Pinned by a test that asserts both halves — that `mergedAt` is asked for and that no bare `merged,` remains in the field list — because the failure mode is silent at the call site and only visible as a note about a PR. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NR2L4MT5kTP8Lu9eR7dPUP
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.
Summary
Closes #337. The batch review packet lets the human rule on each member but not run the batch together. This adds an opt-in, laptop-only
batch collect --integrationleg: one throwaway worktree root per slot (~/Code/PyAutoLabs-wt/integration-<slot>/, built by the existingworktree_create, soactivate.sh+ PYTHONPATH + cache dirs come for free), withintegration/<slot>per affected repo cut fromorigin/mainand every member's PR head merged in dispatch order. A member whose merge conflicts is left out and named with the conflicting paths — that report is the answer to "how would this resolve at the end", not a failure (exit code unchanged). Nothing is pushed, no PR is opened, no remote ref is touched; pushing (--push, sweep expiry) is a deferred phase 3.Phase 1 first makes the member → (repo, branch) map reliable: the batch record stores no branch per member and
active.md'srepos:field has four dialects, so the evidence JSON now records each PR'shead_ref/head_sha/head_repofromgh.Also fixes a pre-existing break found by the end-to-end smoke:
GH_FIELDSaskedgh pr view --jsonformerged, which is not a field —ghfails the whole request, so every--fetchscored UNOBSERVABLE. NowmergedAt, withmergedderived.API Changes
pyauto-brain batch collect --integration(new flag, collect-only; also triggered by a- integration: yesline in the batch record at dispatch). Refuses non-local-devlanes with a pointer, like--fetch.head_ref,head_sha,head_repo;--jsonoutput and a pasted evidence doc gain a top-levelintegrationblock; collect never rewrites the--evidencefile.integrationregion (sentinels always emitted; body only when a block exists, so refreshes never blank it). Report:## Integration brancheswith thesource <root>/activate.shline first. Record:- integration-root:stamp (the human's- integration: yessurvives).bin/worktree.sh:PYAUTO_WT_BRANCHoverrides the per-task branch name (default unchanged:feature/<task>).git fetch origin(read-only), opt-in, documented in the batch AGENTS.md beside--fetch.See full details below.
Test Plan
tests/test_batch_integration.py(19 tests) — temp bare origin + clone, two members on the same file: alpha merged, beta left out withpaths == ["a.py"], canonical checkout untouched (the prompt's Witness); clean multi-member; idempotent re-run (same tree); dirty worktree skipped; fork / merged / missing-head reported not merged; root hasactivate.sh+ symlinks; branch override; packet region sentinelled + escaped; refresh preserves region; cloud lane pointer; recordintegration: yestriggers; apply stampsintegration-root;plan --integration→ rc 2.tests/test_batch_collect.py— head fields in the--jsonargv and the row; null owner →"";mergedAt→merged.test_cortex_conductor.py::test_a_fixture_tree_finds_the_schema_its_checkout_ships) that only fails inside a task worktree where PyAutoCortex is a symlink — passes on the canonical checkout, untouched here.collect --slot 2026-08-31-pm --fetch --integration(all PRs merged →nothing to integrate, no root built); with an evidence file naming four unmerged branches → PyAutoFit clean, PyAutoArray one merged + two conflicted with paths listed; second run reproduced identical trees; root andintegration/*branches removed afterwards, canonical repos onmainand clean.Full API Changes (for automation & release notes)
Added
agents/conductors/batch/_integration.py— stdlib-only, loaded lazily by_batch.load_integration():plan_jobs(members, order, notes),ensure_root(slot, repo_dirs, notes),integrate_repo(job, wt, slot, notes),run(members, order, slot, *, lane)._batch.py:_head_of(data, repo),_yes(values),load_evidence_doc(path),_integration_panel(d),_integration_report(d);collect()returnsdispatch_orderandintegration_requested;--integrationinCOLLECT_ONLY+ argparse;record_updatewritesintegration-root.GH_FIELDS+=headRefName,headRefOid,headRepository,headRepositoryOwner;merged→mergedAt.packet.css:ul.integrules. Nopacket.jschange.bin/worktree.sh:PYAUTO_WT_BRANCH.AGENTS.md(Running, constraints row, "Integration branches (--integration)", evidence keys, network sentence),batch.shusage,skills/batch/batch.md("I want to run the whole batch").Removed
Migration
- integration: yes/- integration-root:record keys tobatches/AGENTS.md.Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NR2L4MT5kTP8Lu9eR7dPUP