Repository navigation
Description
Overview
Phase 3 of the batch review integration branches adds an opt-in --push on top of --integration, publishing each integration/<slot> to origin as a throwaway review ref written with the laptop's own git auth, so a reviewer can check the merged state out on another machine or hand it to CI. It is never forced: a remote ref whose tree is identical to the local one is not re-pushed, a fast-forward is pushed plainly, and anything else is published under the first free integration/<slot>-N name while the earlier ref is left untouched. A sweep-after: date stamped on the batch record drives a new integration/* case in bin/branch_sweep.sh so these refs expire instead of sitting in the "unmerged, kept forever" bucket, AUTONOMY.md records the Brain's second network leg, and the first real push against PyAutoLabs repos stays the human's call.
Plan
_integration.pygainspush_repo(row, wt, slot, notes), called fromrun(..., push=)after the local merges — fetchorigin/integration/*, then decide per repo: no remote ref → push the base name; identical tree → not re-pushed; remote is an ancestor → plain push; otherwise first free-Nsuffix (2..20). No--forceor--force-with-leaseanywhere in the module.- A push failure is a note with
pushed=falseand never changesrow["status"]— the merge verdict is a fact about the merge, not about the network. - Non-laptop lanes refuse with a new
NOT_LOCAL_PUSHconstant pointing atskills/GITHUB_ACCESS.md; members are still scored. _batch.pygains the--pushflag (collect-only;plan --pushand--pushwithout--integrationare both usage errors, rc 2),sweep_after_default(review_at)= review-at + 7 days (unparsable → today + 7, said in a note), and stamps- integration-remote:(replace) and- sweep-after:(fill once, a human value wins).- The integration panel and the collect report name the remote branch, the expiry date, and state that a pushed conflicted branch carries only the members that merged.
bin/branch_sweep.shgains--records <dir>pointing at abatches/checkout and a newintegration/*case besidearchive/condemned/*: protected when no record names it or itssweep-afteris today or later, sweepable once past. Deletion stays on the existing workflow_dispatch-only path.- All three sweep workflows pass
--records; onlyPyAutoBrain/.github/workflows/branch_sweep.ymlneeds a new PyAutoMind checkout step (the org-wide one already checks out.mind, and the Mind's own sweep is the Mind). - Doctrine:
AUTONOMY.mdnetwork bullet gains the batch clause; batchAGENTS.md,batch.sh,skills/batch/batch.mdandPyAutoMind/batches/AGENTS.mddocument the flag and the two record keys. 18 new/updated tests acrosstest_batch_integration.pyandtest_branch_sweep.py.
Detailed implementation plan
Affected Repositories
- PyAutoBrain (primary) — the push leg, the conductor flag and record keys, the sweep case, the workflows, the doctrine, the tests.
- PyAutoMind —
batches/AGENTS.md(the two new record keys) and.github/workflows/branch_sweep.yml(pass--records).
Branch Survey
| Repo | Branch | State |
|---|---|---|
| PyAutoBrain | main |
clean, fast-forwarded to the #338 merge |
| PyAutoMind | main |
clean |
Suggested branch: feature/batch-review-integration-p3
Suggested worktree: ~/Code/PyAutoLabs-wt/batch-review-integration-p3/
Implementation Steps
0. Ground truth found while exploring (read before editing). The integration fixture in tests/test_batch_integration.py is named ws (not fake_workspace); _recorder stubs run(members, order, slot, *, lane) and adding a push= kwarg breaks it — update it in the same commit. branch_sweep.sh reads no manifest at all: archive/condemned/* is a hardcoded case arm, so integration/* is a new sibling arm. PyAutoMind/.github/workflows/branch_sweep.yml sweeps the repo it lives in, so batches/ is already in $GITHUB_WORKSPACE; branch_sweep_all.yml already checks the Mind out at .mind. The AUTONOMY.md network bullet currently names only intake reconcile --repo — neither --fetch nor --integration appears there yet. collect()'s return dict carries integration_requested but not review_at.
1. _integration.py — the push leg. New NOT_LOCAL_PUSH constant and MAX_SUFFIX = 20 beside NOT_LOCAL. New push_repo(row, wt, slot, notes) after integrate_repo, using _git exclusively (so it inherits GIT_TERMINAL_PROMPT=0 and never raises), setting remote_branch/pushed/push_note up front. Decision order: skipped status → note and return; fetch +refs/heads/integration/*; no remote ref → target is the base name; identical tree (rev-parse remote^{tree} == HEAD^{tree}) → not re-pushed and return; merge-base --is-ancestor → plain push of the base name; else first free -N, git branch -f <cand> HEAD (a local ref for a name proven absent on origin) and a note saying it was never force-pushed. Then git push origin <target>:refs/heads/<target>. run() takes push: bool = False, calls push_repo per job, and adds "pushed"/"sweep_after" to block. Module docstring's "It writes no remote" bullet becomes "unless --push is typed".
2. _batch.py — flag, sweep-after, record keys, panel, report. collect() returns review_at and sweep_after beside integration_requested. New SWEEP_DAYS = 7 and sweep_after_default(review_at, notes) (parses the date half of 2026-09-04T08:00Z). --push argparse flag; COLLECT_ONLY gains "push" so plan --push is rc 2 for free. _main_collect raises BatchUsageError when --push is passed without --integration, then passes push=a.push to integ.run and fills block["sweep_after"] from the record or the default. record_update _set_keys integration-remote (replace) and _fill_keys sweep-after (never overwrite a human's). _integ_detail appends the pushed/not-pushed clause once so the terminal and the page cannot disagree; _integration_report and _integration_panel state the expiry, that it is never a PR and never a base, and that a pushed branch carries only the members that merged.
3. branch_sweep.sh — the integration/* case. New --records <dir> flag (default empty, added to the arg loop and both usage strings) pointing at a checkout of PyAutoMind/batches/; absent or unreadable → integration branches are protected, never deleted. New TODAY and integration_sweep_after() beside merged_pr_for, grepping the records for - integration-remote: <Name>:<branch> and reading that file's - sweep-after:. New classify arm after archive/condemned/*: no date → protected as integration-no-sweep-after; date in the future → protected as integration-until-<d>; else safe as integration-expired-<d> (ISO dates compare as strings; d == TODAY is not expired). A fifth WHAT IT WILL NOT DO header bullet explains why the containment proof can never clear these refs. Workflows: PyAutoMind/.github/workflows/branch_sweep.yml → --records "$GITHUB_WORKSPACE/batches"; branch_sweep_all.yml → --records "$PWD/.mind/batches"; PyAutoBrain/.github/workflows/branch_sweep.yml → a new Mind checkout at .mind plus --records "$GITHUB_WORKSPACE/.mind/batches".
4. Doctrine. AUTONOMY.md network bullet gains the batch clause (fetch + push, opt-in, non-default, laptop-only, throwaway integration/* refs only, never main/release/PR/base, never forced, expires at sweep-after:). Batch AGENTS.md: amend "Pushing … is a separate, later decision", add a "Pushing the integration branch (--push)" subsection, extend the JSON block with remote_branch/pushed/push_note and block-level pushed/sweep_after, extend "What it stamps on the record", add a doctrine-table row. batch.sh usage line and paragraph; skills/batch/batch.md sentence ending "the first push of a slot is the human's call"; PyAutoMind/batches/AGENTS.md schema keys plus a paragraph in "The four fields that are easy to get wrong".
5. Tests (18). test_batch_integration.py, reusing ws/_seed/member/mini_mind/block_for/collected: origin equals the local branch (Witness 1); after main moves, the first ref is untouched and -2 appears (Witness 2); an unchanged refresh mints nothing; a conflicted repo publishes its partial branch; a failed push is a note and the merge verdict stands; --push without --integration rc 2; plan --push rc 2; the cloud lane says run it from the laptop; apply stamps the remotes and a default sweep-after; a human-written sweep-after is never overwritten; an unreadable review-at falls back to today + 7; the panel and report name the remote and the expiry; _recorder updated for the new kwarg. test_branch_sweep.py: extend the world fixture with two integration branches and a records/ dir, give _sweep a records parameter, then expired-is-sweepable, unexpired-is-protected, no-record-is-protected, and delete-removes-only-the-expired-one.
6. Trade-offs, decided. The push lives in _integration.py because that module is the git engine and imports nothing from _batch; _batch.py owns only what needs the record. -N beats a date suffix because the branch already carries the date and -2 says "second publication of this slot". The tree-equality arm is load-bearing: integrate_repo re-cuts with --no-ff merges whose SHAs differ every run, so comparing commits would suffix every refresh. The sweep reads records from a checkout rather than gh api over batches/, which would need paging, base64 decoding and a second failure mode for the same answer. Four commits in the Brain (push leg + tests; conductor + tests; sweep + workflows + tests; docs) and one in the Mind.
7. Verify. pytest tests/test_batch_integration.py, tests/test_branch_sweep.py tests/test_branch_sweep_targets.py, tests/test_batch_collect.py tests/test_batch_plan.py tests/test_batch_kinds.py, then the full tests suite (expect only the pre-existing test_cortex_conductor failure inside a task worktree); bash -n bin/branch_sweep.sh; YAML loads for all three workflows. Real-repo smoke runs --integration only — no real --push in this task; confirm git ls-remote origin 'refs/heads/integration/*' is empty afterwards. The first real --push against PyAutoLabs repos is the human's call, in front of the packet, with the sweep-after: date in view. Workflow-file pushes may be refused if the git credential lacks the workflow scope; report rather than work around.
Key Files
agents/conductors/batch/_integration.py—push_repo,NOT_LOCAL_PUSH,run(..., push=)agents/conductors/batch/_batch.py— flag, usage gate,sweep_after_default, record keys,_integ_detail,_integration_report,_integration_panelbin/branch_sweep.sh—--recordsflag,integration_sweep_after(),integration/*case.github/workflows/branch_sweep.yml,.github/workflows/branch_sweep_all.ymlAUTONOMY.md— the second network legagents/conductors/batch/AGENTS.md,agents/conductors/batch/batch.sh,skills/batch/batch.mdtests/test_batch_integration.py,tests/test_branch_sweep.py- PyAutoMind:
batches/AGENTS.md,.github/workflows/branch_sweep.yml
Original Prompt
PyAutoMind/active/batch_review_integration_branches_p3_push.md
# Batch review integration branches phase 3: --push, never-force refresh, sweep expiry
Type: feature
Target: PyAutoBrain
Repos:
- PyAutoBrain
- PyAutoMind
Difficulty: medium
Autonomy: safe
Priority: medium
Depends-on: shipped in complete/2026/09/batch-review-integration.md (PyAutoBrain#338, PyAutoMind#386 — phases 1-2, merged 2026-09-02)
Status: formalised
Consequence: notify
Witness: a test with a temp bare origin runs `collect --integration --push` and asserts origin carries `integration/<slot>` equal to the local branch; a second run after main moves lands as a new commit or an `integration/<slot>-2` branch and never force-updates the first; `branch_sweep.sh` classifies an `integration/*` branch whose record `sweep-after:` is past as sweepable and one that is not as kept
Review-minutes: 0
Unattended: ready
## Context
Phases 1-2 shipped as PyAutoBrain#338 (issue #337) + PyAutoMind#386: `batch collect --integration` builds
one throwaway worktree root per slot merging every member's head branch per repo, locally only. This phase
adds the "temporarily put on GitHub" half of the original request (2026-09-02), so the reviewer can check
the merged state out on another machine or hand it to CI.
## Scope
1. `--integration --push` (laptop lane only, opt-in on top of `--integration`): after the local merges,
`git push origin integration/<slot>` per repo from the laptop's own git auth. Real branches only
(GitHub accepts refs/heads/* and refs/tags/*). Never a PR, never a base for anything; the packet's
integration panel and the report gain the remote branch name per repo.
2. Never rewrite pushed history: if `origin/integration/<slot>` already exists and differs, push a NEW
commit on top when fast-forwardable, else push `integration/<slot>-2` (`-3`, ...) and say so; never
`--force`. Record the pushed branch names on the batch record (`- integration-remote:`), which lives in
a LEDGER_DIRS auto-merging dir.
3. Expiry: `- sweep-after: <YYYY-MM-DD>` on the batch record (default = review-at + 7 days, human may
override); `PyAutoBrain/bin/branch_sweep.sh` gains an `integration/*` case — kept while the record's
sweep-after is in the future or missing, sweepable after it (pattern borrowed from the Gut transit clock,
storage stays in each repo). Today the sweep would classify these as unmerged-and-kept forever.
4. Doctrine: `PyAutoBrain/AUTONOMY.md` "The Brain reads no network except one opt-in flag" gets an
explicit clause for `--integration --push` (opt-in, non-default, laptop only, push of throwaway
integration refs only, never main, never a PR); batch `AGENTS.md`, `batch.sh`, `skills/batch/batch.md`
and `PyAutoMind/batches/AGENTS.md` document the flag and keys.
5. Tests per the Witness plus: `--push` without `--integration` is a usage error; non-laptop lane refuses
with a pointer; a conflicted repo (member left out) still pushes the partial branch and the panel says
which members are missing from it.
## Constraints
- Builds on `_integration.py` and the record keys from phases 1-2 — PyAutoBrain#338 and
PyAutoMind#386 merged 2026-09-02 (`complete/2026/09/batch-review-integration.md`), so this is unblocked.
- Remote sessions have no usable push credential (GITHUB_ACCESS.md); this is a laptop leg like `--fetch`.
- `git merge-tree --write-tree` is unavailable (git 2.34.1 on the laptop); nothing here needs it.
<!-- formalised by the Intake (Conception) Agent on 2026-09-02 from file:/tmp/claude-1000/-home-jammy-Code-PyAutoLabs/c4232aa1-7376-4851-8e3f-29ef2f9e65cd/scratchpad/intake_phase3.md -->
Activity
Jammy2211 commentedon Sep 2, 2026
PRs Created (Brain library + Mind companion — no workspace leg)
Both carry
pending-release. Library-first: the Brain PR merges before the Mind companion, so the record keys the Mind documents are already real when its docs land. No workspace repo is touched, so there is no/start_workspaceleg.Commits
PyAutoBrain (
feature/batch-review-integration-p3, HEAD203d3ba):0a72cffbatch: --integration --push — publish the integration ref, never forced (feat: batch --integration --push — publish review refs, never forced, swept by sweep-after #339)a9b7b2ebatch: integration-remote and sweep-after on the record, remote in the packet (feat: batch --integration --push — publish review refs, never forced, swept by sweep-after #339)7afed66branch_sweep: integration/* expires at the record's sweep-after (feat: batch --integration --push — publish review refs, never forced, swept by sweep-after #339)203d3badocs: --push, sweep-after and the second network leg (feat: batch --integration --push — publish review refs, never forced, swept by sweep-after #339)PyAutoMind (
feature/batch-review-integration-p3, HEAD1c0ad77c):1c0ad77cbatches: integration-remote and sweep-after record keys; sweep reads batches/ (feat: batch --integration --push — publish review refs, never forced, swept by sweep-after #339)11 files changed in Brain (+803/-33); 2 files in Mind (+24).
API changes
pyauto-brain batch collect --integration --push— new flag, collect-only, requires--integration;--pushalone is rc 2, and non-laptop lanes refuse.--jsonintegration rows gainremote_branch,pushed,push_note; the block gainspushed,sweep_after.integration-remote:(rewritten every push) andsweep-after:(written once, defaultreview-at+ 7 days, a human value wins).bin/branch_sweep.sh --records <dir>plus anintegration/*classification:integration-no-sweep-afterandintegration-until-<d>protected,integration-expired-<d>sweepable.integration/<slot>-Nand leaves the earlier ref untouched. The module contains no force flag and a test pins that.Tests
tests/test_batch_integration.py— 31 tests.tests/test_branch_sweep.py— 14 tests.-n auto), with the single permitted deselecttest_cortex_conductor.py::test_a_fixture_tree_finds_the_schema_its_checkout_ships— a pre-existing Cortex worktree-symlink failure, filed asdraft/bug/pyautobrain/cortex_test_worktree_symlink.md.bash -nand YAML loads clean on all three sweep workflows.Heart
pyauto-heart readiness --json→ yellow (score 80), reasons verbatim:PyAutoArray: open PR 10d oldrelease validation incomplete: no rehearsal for current sourceBoth were acknowledged at plan approval; no RED reasons.
No real
--pushwas run in this task; the first push against PyAutoLabs repos is the human's call.branch_sweep: keep instance names out of the organ script's comments (#…
Jammy2211 commentedon Sep 2, 2026
Shipped
Phase 3 — the push leg of the batch/review integration branches — is merged.
fb82aab610a168b5dfdf4f02d977ff20d060f86b(headfc3c214; commits0a72cff a9b7b2e 7afed66 203d3ba fc3c214)7a71955010c3f5bce50feda80ea46d945155cb86(head1c0ad77c)What changed.
--integration --pushnow publishes the batch's integration trees as throwawayintegration/<slot>refs on each affected repo, so a reviewer can fetch a slot instead of rebuilding it locally. The push is never forced: a ref whose tree is identical to the remote's is left alone, a ref that fast-forwards is advanced, and anything else is reported rather than overwritten (-Ndry-run shows exactly what would move before the network leg runs). Each pushed slot is recorded in the batch record under the newintegration-remote:andsweep-after:keys, which give the refs a stated expiry rather than an implicit one.branch_sweep.shgrew a--recordsmode that reads those keys, and theintegration/*namespace was armed for expiry in all three sweep workflows, so the throwaway refs are collected on the same schedule as every other stale head.AUTONOMY.mdgained the second network leg so the autonomy contract names the push explicitly alongside the existing one.CI. The first CI wave tripped the tenant firewall on
branch_sweep.shcomments that carried instance names;fc3c214removes them and both legs are green (PyAutoBrain pytest 3.12 + 3.13 success; PyAutoMind privacy success, drift skipped). Locally, PyAutoBrain is 834 passed. PyAutoHeart is YELLOW, acknowledged:PyAutoArray: open PR 10d oldandrelease validation incomplete: no rehearsal for current source— neither touches this change.No real
--pushwas executed against any PyAutoLabs repo during development: the first push of anintegration/<slot>ref is the human's call.