Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 42 additions & 8 deletions AUTONOMY.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Where the dev workflow stops for a human today:
| Checkpoint | `safe` | `supervised` | `human-required` |
|------------|--------|--------------|------------------|
| Plan approval | write plan to the issue, proceed | write plan to the issue, proceed | present + wait |
| Ship PR sign-off | proceed through the autonomous-ship gate; end at PR-open | park (`awaiting-input`), question to the issue, continue elsewhere — except under an explicit `--auto` launch, where it resolves to decide-and-flag (below; 2026-09-07) (a `notify` task merges in-turn under R3, "`notify` merges under `--auto` and inside a shift — 2026-11-17") | present + wait |
| Ship PR sign-off | proceed through the autonomous-ship gate; end at PR-open | park (`awaiting-input`), question to the issue, continue elsewhere — except under an explicit `--auto` launch, where it resolves to decide-and-flag (below; 2026-09-07) (a `notify` task merges in-turn under R3, "`notify` merges under `--auto` and inside a shift — 2026-11-17"; inside a shift it ends at PR-open and the close-out merges, 2026-11-19) | present + wait |
| Heart YELLOW | park, unless the reason set was human-acknowledged at launch (see the autonomous-ship gate) | same as `safe` | present + wait |
| Heart RED | stop, report | stop, report | stop, report — a live human may separately invoke the development override or corrective-PR exception below; neither is an autonomy level |
| Merge / close | by declared `Consequence:` (2026-10-02 section) | by declared `Consequence:` | by declared `Consequence:` |
Expand Down Expand Up @@ -258,7 +258,7 @@ checkpoint of an effective-`supervised` run.** The human's direction
(2026-08-31): *"I dont really want these parked at ship judgements, ideally we
send off a batch and then dont think about it again, the parked thing is an
annoying middle ground which requires human time."* The argument: every
autonomous run already ends at PR-open with merge left to the human (a `notify` task merges in-turn under R3, "`notify` merges under `--auto` and inside a shift — 2026-11-17"), so **the PR
autonomous run already ends at PR-open with merge left to the human (a `notify` task merges in-turn under R3, "`notify` merges under `--auto` and inside a shift — 2026-11-17"; inside a shift the close-out merges it since 2026-11-19), so **the PR
review IS the approval the `supervised` level exists to provide**. A mid-run park
at ship sign-off is a redundant *second* checkpoint — it costs a GitHub-issue
round-trip before a PR even exists, and then asks the human for the same
Expand Down Expand Up @@ -322,12 +322,31 @@ never an assumption:
downstream breakage with human PR review — an autonomous run doesn't have
that reviewer, so it runs the dependents' suites too. Repos with no test
dir (organism/doc repos): leg is n/a, stated in the PR body.
2. **Smoke** — the curated `smoke_tests.txt` subsets (Heart's `smoke_test`
skill, all six workspaces by default) run with the task worktree's
`activate.sh` sourced, so they exercise the branch. Applies where the
changed repo has a downstream script surface; organism/doc-only changes:
n/a, stated in the PR body. Never grow the curated lists to make this leg
feel stronger.
2. **Smoke** — the curated `smoke_tests.txt` subsets, run with the task
worktree's `activate.sh` sourced so they exercise the branch. Applies
where the changed repo has a downstream script surface; organism/doc-only
changes: n/a, stated in the PR body. Never grow the curated lists to make
this leg feel stronger. **Split by who runs it (2026-11-19, PyAutoHeart#352,
the human's "approve C"):**
- *Worker (shift or `--auto`)* — a **targeted** smoke only, beside the
changed repo's unit tests and the task's `Witness:`:
`pyauto-heart smoke --targeted --changed-files <the diff's files>` runs
the curated scripts that reference the changed code (a changed module's
import path, or a public name the diff touches); none match → the
cheapest script of the changed repo's own workspace, as an import check.
The PR body says which smoke ran.
- *Before any unattended merge* — the **full affected** smoke on the PR
head: `pyauto-heart smoke --affected-by <the PR's repo> --jobs 3` (every
workspace whose install chain has the repo, three at a time,
thread-capped). The close-out runs it for a `glance` PR or a `notify` PR
(every `notify` PR in a shift, since its worker now ends at PR-open —
"Shift `notify` workers end at PR-open — 2026-11-19" below;
`agents/conductors/batch/closeout_template.md`). Any failure refuses the
merge → `/prm`.
- *PRs bound for the human's `/prm`* (`decision-taken`, `judge`, a
public-name hit, a refusal) — no automatic full sweep: the worker's
targeted smoke plus PR CI; the human runs `/smoke_test` if they want it.
A human `/smoke_test` with no flags still runs every workspace serially.
3. **Review** — review-faculty verdict **CLEAN**
(`agents/faculties/review/AGENTS.md`). FINDINGS → resolve and re-review, or
park to a human checkpoint; BLOCKED → park. When the surface lifted any
Expand Down Expand Up @@ -550,6 +569,21 @@ The human's ruling R3, 2026-11-17, from the review of shift 2026-11-16-pm. Two w

*Revert condition:* one in-shift merge past `merge-cap:` after this is built returns every in-shift `notify` merge to `/prm`.

### Shift `notify` workers end at PR-open — 2026-11-19

The human's ruling, 2026-11-19 (option "ii", PyAutoHeart#352), with the smoke
split of leg 2: **notify workers no longer merge in-turn; they end at PR-open
and the close-out merges after the affected smoke.** This replaces R3's
in-turn path inside a shift (its first two bullets): a shift worker never runs
`merge-slot take` or `gh pr merge`, whatever its tier. The watcher closes out
a green `notify` PR exactly as a `glance` one (R3's third bullet, unchanged),
and that close-out runs the witness and the full affected smoke
(`pyauto-heart smoke --affected-by <repo> --jobs 3`) before it merges. R3's
fourth bullet stands: these are `notify` merges, not stage-2 rows. Outside a
shift (an `--auto` chat, no close-out), R3's in-turn merge is unchanged.
`merge-slot take` keeps refusing an out-of-order in-turn merge as a backstop,
and the digest still flags any in-turn merge a worker makes.

## The `glance` Shadow-window ruling — 2026-11-04

**`glance` is confirmed, narrowed.** Ruled by the human 2026-11-04 under the
Expand Down
22 changes: 12 additions & 10 deletions agents/conductors/batch/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,8 @@ the prompt, its tier and **why the brief admitted it** (`_brief.pick_reason`:
`named task`, `scoped epic|tag|tier <x>`, or `backlog: fill-idle`) — at
dispatch, because by `review-at:` the prompt may have moved to `complete/`.
The reap keeps what the worker left before deleting its marker: the `.done`
lines go to `outcomes` (`<url>`, or `merged <url>` for an in-turn tiered
merge), and `<task>.proof.md` moves to `<slot>/proofs/`. The first tick after
lines go to `outcomes` (`<url>`; a `merged <url>` line, which no shift
worker writes since 2026-11-19, is still recorded as an in-turn merge), and `<task>.proof.md` moves to `<slot>/proofs/`. The first tick after
`review-at:` runs `finish_shift` once: `_digest.build` writes the `## Digest`
(`PyAutoMind/batches/AGENTS.md` format — brief work, backlog picks each with
its `why:`, one proof packet per started task or a stub that says none was
Expand Down Expand Up @@ -526,16 +526,19 @@ ends at PR-open (`worker_template.md`). Each tick, `_closeouts` first reaps
running close-outs — `<task>.closeout` (`merged` | `refused`, `why`, `gate`,
`model`), or a session gone without one, which is recorded refused — then, for
each PR a worker named, judges the guards it can see with its own reads: the
recorded tier is `glance` or `notify` (ruling R3, 2026-11-17), `gh pr checks` is green — at least one completed
recorded tier is `glance` or `notify` (ruling R3, 2026-11-17; since 2026-11-19
every `notify` PR comes here, its worker having ended at PR-open — ruling "ii",
PyAutoHeart#352), `gh pr checks` is green — at least one completed
check, all green (pending waits a tick; red, none or unknown is refused), the
shift is not shadow, `review-at:` is more than 20 minutes away, spend is
under 1.5× `token-budget:` (#632; AUTONOMY.md "Close-out budget — 2026-11-14"),
and — last — a merge slot is free under `merge-cap:` (`_merge_slots.py`; a
worker's in-turn merge takes from the same count). Then it starts **one** close-out session
(`closeout_template.md`; `claude --bg --name shift-close:<task> --model opus --effort medium`).
That session is the independent leg: it runs the `Witness:` itself, reviews the
diff adversarially, checks the `decision-taken` label and Heart, and only then
runs the `/prm` close-out — or refuses. A merge marks the PR merged; a `glance` one also bumps `glance_auto_merges`
diff adversarially, checks the `decision-taken` label and Heart, runs the full
affected smoke on the PR head (`pyauto-heart smoke --affected-by <repo> --jobs 3`,
PyAutoHeart#352), and only then runs the `/prm` close-out — or refuses. A merge marks the PR merged; a `glance` one also bumps `glance_auto_merges`
and queues a `table-append` op that lands one row in
`autonomy_log.md` "Unattended `glance` sub-window (stage 2)" through the one Mind
writer. Every refusal is final for the shift and named in the digest
Expand Down Expand Up @@ -566,11 +569,10 @@ merged one is in the branch. A PR needing a third update refuses (`main kept
moving`, `UPDATE_LIMIT` 2). A waiting or updated PR at `review-at:` is not
refused; the next shift carries it with what it waited behind. The digest says
`waits behind <A> (<A's state>) — merge <A> first` and lists a per-library
"Merge order" block, ▶ on the PR that needs your /prm now. The in-turn path
keeps the same order: `merge-slot take` (`bin/merge_slot.py`) refuses a
`notify` worker's in-turn merge while an earlier shift PR on the same library
is open (`in_turn_merge_blockers`, the close-out's rule), so that PR ends at
PR-open and merges through the wait above. An `updated` PR's CI is read only
"Merge order" block, ▶ on the PR that needs your /prm now. Shift workers no
longer merge in-turn (2026-11-19, ruling "ii"); as a backstop `merge-slot take`
(`bin/merge_slot.py`) still refuses an in-turn merge while an earlier shift PR
on the same library is open (`in_turn_merge_blockers`, the close-out's rule). An `updated` PR's CI is read only
once GitHub shows the head the update made; a head that moved since refuses.
The spawn loop also refuses a task whose library a live, parked or
re-dispatch-pending task holds, whatever the plan's order made of it.
Expand Down
21 changes: 19 additions & 2 deletions agents/conductors/batch/_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,8 @@ def pr_state(self, url: str) -> dict:
your proof packet: after a sibling merges, the close-out updates your branch
from main and refuses (leaving it for the human's /prm) on a conflict. A
`worktree_check_conflict` hit that names only a listed sibling's branch slug
is not a conflict (ruling e, 2026-11-19): go on. Never merge in-turn ahead
of a sibling: `merge-slot take` refuses while one is open, so end at PR-open.
is not a conflict (ruling e, 2026-11-19): go on. End at PR-open, as every
shift worker does.

"""

Expand Down Expand Up @@ -400,6 +400,22 @@ def update_prompt(task: str, pr_url: str, prompt_path: str, brief_path: Path,
lease_dir=lease_dir, after="\n".join(f"- {u}" for u in after))


#: Workspaces a close-out smokes at once (PyAutoHeart#352): laptop-safe, and
#: Heart caps each one's thread pools so the three share the cores.
CLOSEOUT_SMOKE_JOBS = 3


def smoke_command(repos: str) -> str:
"""The close-out's full affected smoke (AUTONOMY.md leg 2, split
2026-11-19, PyAutoHeart#352): every smoke workspace whose install chain
has the PR's repo, CLOSEOUT_SMOKE_JOBS at a time, against the task root
the close-out brought to the PR's head. Empty when the repo is unknown."""
if not repos:
return ""
return (f"bash -c 'source \"{COMMON_SH}\"; \"$(resolve_heart)\" smoke "
f"--root \"$PWD\" --affected-by {repos} --jobs {CLOSEOUT_SMOKE_JOBS}'")


def closeout_prompt(task: str, pr_url: str, prompt_path: str, brief_path: Path,
lease_dir: Path, after: list[str] | None = None,
before: list[str] | None = None) -> str:
Expand All @@ -421,6 +437,7 @@ def closeout_prompt(task: str, pr_url: str, prompt_path: str, brief_path: Path,
else "(not a GitHub PR URL — refuse)",
public_names_cmd=f"{BRAIN_CLI} public-names {pr_url}" if repos
else "(not a GitHub PR URL — refuse)",
smoke_cmd=smoke_command(repos) or "(not a GitHub PR URL — refuse)",
after_step=after_step(after, before))


Expand Down
28 changes: 23 additions & 5 deletions agents/conductors/batch/closeout_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,29 @@ outcome — the human merges by `/prm` at check-in.
reason line (`CI PENDING: …` / `CI RED: …`): no waiting, no re-run. A
`GREEN` that names a skipped **test** leg refuses too (a tiered merge
stops on a skipped test leg, `skills/prm/reference.md` "Tiered merge").
{after_step}5. Immediately before you merge — after every check above, and again right
{after_step}5. Run the full affected smoke on the PR's head (AUTONOMY.md leg 2, split
2026-11-19, PyAutoHeart#352). The worker ran only a targeted smoke; this
is the sweep, and it runs only here, before an unattended merge. Use the
task root the worker shipped from (the folder holding `.pyauto-root` and
its `{pr_repos}` worktree on the PR's branch, the one you clean up in
step 8): bring that worktree to the PR's head with `git fetch origin
<branch>` and `git merge --ff-only FETCH_HEAD`, and check `git rev-parse
HEAD` equals `gh pr view {pr_url} --json headRefOid`. No task root, a
dirty tree, or a head that will not match: refuse with why
`cannot smoke the PR head locally → /prm`. Then, from the task root with
its `activate.sh` sourced:

{smoke_cmd}

It runs every workspace whose install chain has the repo, three at a
time, and prints a per-workspace summary. Exit 0 passes ("nothing to run"
for a repo no workspace installs passes too). Any other exit refuses with
why `smoke FAILED: <the failing workspaces> → /prm`: no re-run, no fix.
6. Immediately before you merge — after every check above, and again right
before the merge command itself — look for {lease_dir}/{task}.dropped. If
it exists, the human dropped this task with `/drop` mid-shift: do not merge;
refuse with why `dropped by /drop`.
6. If everything passed, use the prm skill on {pr_url}: the full close-out,
7. If everything passed, use the prm skill on {pr_url}: the full close-out,
judged exactly as a human-typed `/prm`. Never commit to PyAutoMind yourself
— a hook refuses it; queue each Mind change with
`{shift_ledger} --task {task} append|write|edit|move|remove|drop-section ...`
Expand All @@ -74,20 +92,20 @@ outcome — the human merges by `/prm` at check-in.
The `/prm` merge slot take (reference.md "Tiered merge") is
`pyauto-brain merge-slot take {pr_url} --task {task}`; it succeeds for
this PR and task: the watcher took its slot before starting you.
7. After a merge, remove the task's worktree and local branch as `/prm` does
8. After a merge, remove the task's worktree and local branch as `/prm` does
(`skills/prm/closeout.md` steps 5–6): `worktree_remove <slug>` once your
`drop-section active.md <slug>` is queued — the stale-claim guard counts a
claim release queued in {ledger_dir}/ — then `git -C <repo> branch -d
feature/<slug>` for a local branch left in a canonical checkout. Never
`PYAUTO_WT_FORCE=1`, never `rm -rf`: a dirty tree or any other refusal
stays, and you say why in the verdict's `cleanup` field.
8. End at your deliverable. Never arm anything that outlives your turn.
9. End at your deliverable. Never arm anything that outlives your turn.

Last, write {lease_dir}/{task}.closeout as one JSON object:

{{"result": "merged" | "refused", "pr": "{pr_url}",
"why": "<one line — required when refused>",
"gate": "tests …/witness …/review …/heart …",
"gate": "tests …/witness …/review …/heart …/smoke …",
"model": "<your model id>",
"cleanup": "<after a merge: `worktree and branch removed`, or why not>"}}

Expand Down
35 changes: 19 additions & 16 deletions agents/conductors/batch/worker_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,24 @@ The terms of this shift (AUTONOMY.md "Shift briefs and unattended `glance`"):
It is the check the organ's PR CI runs. PyAutoHeart#347 failed CI on a
hard-coded repo name it would have caught. A finding outside your diff is
not yours: name it in your proof packet. Other repos skip this step.
- If the task is `Consequence: glance`, end at PR-open: do not wait for CI
and do not merge. Once CI lands, the watcher starts an independent close-out
session that runs the witness and merges, or refuses (AUTONOMY.md
"Unattended `glance` merges"). A `notify` task merges in-turn only after
`{brain_cli} merge-slot take <pr-url> --task {task}` exits 0, run as its own
bare call just
before a bare `gh pr merge` (ruling R3, AUTONOMY.md "`notify` merges under
`--auto` and inside a shift — 2026-11-17"). If it refuses, do not merge:
list the PR in your `.done` without `merged`, and it is left for `/prm`.
A refusal naming an earlier open sibling PR of this shift means end at
PR-open: the close-out merges yours after it, in order (M3.6j).
If the take succeeded but `gh pr merge` then fails, free the slot with
`{brain_cli} merge-slot release <pr-url> --task {task} --why "merge failed"`
and list the PR
without `merged`.
- Smoke is **targeted** in a shift (AUTONOMY.md leg 2, split 2026-11-19,
PyAutoHeart#352). At the ship step run the changed repo's unit tests, the
task's `Witness:`, and only this smoke, never the full workspace sweep
(not a bare `/smoke_test`), from your task root with `activate.sh` sourced:

cd <task root> && source activate.sh && pyauto-heart smoke --root "$PWD" --targeted --changed-files $(git -C <repo> diff --name-only origin/main...HEAD | sed 's|^|<repo>/|')

It runs the curated scripts that reference your change, or one cheap
import-check script when none do. Say in the PR body which smoke ran (the
scripts it picked, or the import check) and that the full affected smoke
runs in the close-out before an unattended merge. A failure is yours to fix like a test.
- If the task is `Consequence: glance` or `notify`, end at PR-open: do not
wait for CI and do not merge. Once CI lands, the watcher starts an
independent close-out session that runs the witness and the full affected
smoke and merges, or refuses (AUTONOMY.md "Unattended `glance` merges";
`notify` workers stopped merging in-turn on 2026-11-19, the human's ruling
"ii", PyAutoHeart#352). Never run `merge-slot take` or `gh pr merge`
yourself.
- Never commit to PyAutoMind yourself — a hook refuses it. Queue each Mind
change with `{shift_ledger} --task {task} append|write|edit|move|remove|drop-section ...`
(ops land in {ledger_dir}/) and the orchestrator commits them. This covers
Expand All @@ -86,7 +89,7 @@ The terms of this shift (AUTONOMY.md "Shift briefs and unattended `glance`"):
decide it. It goes into the shift digest verbatim; leave it out and the
digest says you wrote none.
- Then write {lease_dir}/{task}.done containing the URLs of the PRs you opened,
one per line — `merged <url>` for a PR you merged in-turn under its tier. An
one per line (a shift worker merges none; the close-out does). An
issue is marked by why you ended there: `question: <url>` when you parked
with a question the human must answer, or `verdict: <url>` when you posted
a verdict, your deliverable (the digest lists it). Nobody is @-mentioned
Expand Down
Loading
Loading