diff --git a/AUTONOMY.md b/AUTONOMY.md index 8c7480b..49e9ce0 100644 --- a/AUTONOMY.md +++ b/AUTONOMY.md @@ -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:` | @@ -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 @@ -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 ` 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 --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 @@ -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 --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 diff --git a/agents/conductors/batch/AGENTS.md b/agents/conductors/batch/AGENTS.md index 20faa37..d7215da 100644 --- a/agents/conductors/batch/AGENTS.md +++ b/agents/conductors/batch/AGENTS.md @@ -460,8 +460,8 @@ the prompt, its tier and **why the brief admitted it** (`_brief.pick_reason`: `named task`, `scoped epic|tag|tier `, 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` (``, or `merged ` for an in-turn tiered -merge), and `.proof.md` moves to `/proofs/`. The first tick after +lines go to `outcomes` (``; a `merged ` line, which no shift +worker writes since 2026-11-19, is still recorded as an in-turn merge), and `.proof.md` moves to `/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 @@ -526,7 +526,9 @@ ends at PR-open (`worker_template.md`). Each tick, `_closeouts` first reaps running close-outs — `.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"), @@ -534,8 +536,9 @@ 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: --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 --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 @@ -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 () — merge 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. diff --git a/agents/conductors/batch/_orchestrator.py b/agents/conductors/batch/_orchestrator.py index d39bc82..ed9fe85 100644 --- a/agents/conductors/batch/_orchestrator.py +++ b/agents/conductors/batch/_orchestrator.py @@ -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. """ @@ -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: @@ -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)) diff --git a/agents/conductors/batch/closeout_template.md b/agents/conductors/batch/closeout_template.md index 6e42a4d..e9876b8 100644 --- a/agents/conductors/batch/closeout_template.md +++ b/agents/conductors/batch/closeout_template.md @@ -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 + ` 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: → /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 ...` @@ -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 ` once your `drop-section active.md ` is queued — the stale-claim guard counts a claim release queued in {ledger_dir}/ — then `git -C branch -d feature/` 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": "", - "gate": "tests …/witness …/review …/heart …", + "gate": "tests …/witness …/review …/heart …/smoke …", "model": "", "cleanup": ""}} diff --git a/agents/conductors/batch/worker_template.md b/agents/conductors/batch/worker_template.md index 8494578..f85958b 100644 --- a/agents/conductors/batch/worker_template.md +++ b/agents/conductors/batch/worker_template.md @@ -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 --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 --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 && source activate.sh && pyauto-heart smoke --root "$PWD" --targeted --changed-files $(git -C diff --name-only origin/main...HEAD | sed 's|^|/|') + + 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 @@ -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 ` 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: ` when you parked with a question the human must answer, or `verdict: ` when you posted a verdict, your deliverable (the digest lists it). Nobody is @-mentioned diff --git a/skills/ship_library/ship_library.md b/skills/ship_library/ship_library.md index 0bb20bf..0a518a7 100644 --- a/skills/ship_library/ship_library.md +++ b/skills/ship_library/ship_library.md @@ -122,7 +122,8 @@ Analyse downstream workspace impact and present data-driven options — see - **(i)** new demos / **(ii)** API migration → `/start_workspace` next; post a "Library PR Created" progress comment, set `active.md` to `library-shipped, workspace-pending`, add `library-pr:`, push Mind. -- **(iii)** no workspace impact → run `/smoke_test` (with `activate.sh` sourced). +- **(iii)** no workspace impact → run `/smoke_test` (with `activate.sh` sourced; + a shift or `--auto` worker runs the targeted form, AUTONOMY.md leg 2). On pass — unless step 6's tiered merge applies, whose `/prm` close-out does all of this itself — offer to merge the library PR, post a "Shipped" comment, write the dated completion record (`lifecycle.py record` — also refreshes the index diff --git a/tests/test_orchestrator_merge_slots.py b/tests/test_orchestrator_merge_slots.py index 280737b..d9292a4 100644 --- a/tests/test_orchestrator_merge_slots.py +++ b/tests/test_orchestrator_merge_slots.py @@ -208,7 +208,10 @@ def test_a_notify_closeout_refuses_without_a_witness(): assert "merge-slot take " + PR + " --task t1" in text -def test_the_worker_names_its_task_on_every_merge_slot_call(): +def test_the_worker_makes_no_merge_slot_call_in_a_shift(): + """Ruling "ii" (2026-11-19, PyAutoHeart#352) replaced R3's in-turn path in + a shift: the worker ends at PR-open and only the close-out takes a slot.""" text = orch.worker_prompt("t1", "draft/bug/x/t1.md", Path("b.md"), Path("leases")) - assert "merge-slot take --task t1" in text - assert "merge-slot release --task t1" in text + assert "merge-slot take " not in text + assert "merge-slot release " not in text + assert "Never run `merge-slot take` or `gh pr merge`" in text diff --git a/tests/test_shift_smoke_split.py b/tests/test_shift_smoke_split.py new file mode 100644 index 0000000..9eafb27 --- /dev/null +++ b/tests/test_shift_smoke_split.py @@ -0,0 +1,95 @@ +"""The shift's smoke split (AUTONOMY.md leg 2, 2026-11-19, PyAutoHeart#352). + +A shift worker runs a targeted smoke only; the full affected smoke, three +workspaces at a time, runs in the close-out before an unattended merge, and +not at all for a PR bound for the human's /prm (the close-out refuses those +before it reaches the smoke step). +""" + +from __future__ import annotations + +import sys +from pathlib import Path + +BRAIN = Path(__file__).resolve().parents[1] +BATCH = BRAIN / "agents" / "conductors" / "batch" +sys.path.insert(0, str(BRAIN / "agents" / "faculties" / "sizing")) +sys.path.insert(0, str(BATCH)) +import _orchestrator as orch # noqa: E402 + +PR = "https://github.com/ExampleOrg/WidgetLib/pull/7" + + +def _closeout(pr_url=PR, tmp=Path("t")): + return orch.closeout_prompt("t1", pr_url, "draft/x/t1.md", tmp / "b.md", tmp / "leases") + + +def _step(text: str, n: int) -> str: + return text.split(f"\n{n}. ", 1)[1].split(f"\n{n + 1}. ", 1)[0] + + +def test_the_worker_runs_a_targeted_smoke_and_says_so_in_the_pr_body(): + prompt = orch.worker_prompt("t1", "draft/x/t1.md", Path("b.md"), Path("leases")) + assert "pyauto-heart smoke" in prompt and "--targeted --changed-files" in prompt + assert "never the full workspace sweep" in prompt + assert "PR body which smoke ran" in prompt + assert "PyAutoHeart#352" in prompt + + +def test_a_notify_worker_ends_at_pr_open_and_never_merges_in_turn(): + """Ruling "ii" (2026-11-19, PyAutoHeart#352): a shift `notify` worker ends + at PR-open like `glance`; the close-out merges after the affected smoke. + The watcher side is unchanged: test_orchestrator_closeout.py + test_a_notify_pr_left_open_is_closed_out_like_glance.""" + prompt = orch.worker_prompt("t1", "draft/x/t1.md", Path("b.md"), Path("leases")) + assert "`Consequence: glance` or `notify`, end at PR-open" in prompt + # No in-turn merge commands are handed to the worker any more. + assert "merge-slot take " not in prompt + assert "merge-slot release" not in prompt + assert "a bare `gh pr merge`" not in prompt + assert "merged in-turn under its tier" not in prompt + sib = orch.worker_prompt("t1", "draft/x/t1.md", Path("b.md"), Path("leases"), + siblings=["https://github.com/o/r/pull/1"]) + assert "Never merge in-turn ahead" not in sib and "End at PR-open" in sib + + +def test_the_watcher_still_closes_out_both_unattended_tiers(): + src = (BATCH / "_orchestrator.py").read_text() + gate = src.split("def _start_closeouts", 1)[1] + assert 'if tier not in ("glance", "notify"):' in gate + + +def test_autonomy_records_the_notify_ruling(): + text = (BRAIN / "AUTONOMY.md").read_text() + sec = text.split("### Shift `notify` workers end at PR-open — 2026-11-19", 1)[1].split("\n## ", 1)[0] + assert "notify workers no longer merge in-turn" in sec + assert '"ii"' in sec and "PyAutoHeart#352" in sec + agents = (BATCH / "AGENTS.md").read_text() + assert "Shift workers no\nlonger merge in-turn" in agents + + +def test_the_closeout_runs_the_affected_parallel_smoke_before_the_merge(): + text = _closeout() + smoke = _step(text, 5) + assert "--affected-by WidgetLib --jobs 3" in smoke + assert "resolve_heart" in smoke and '--root "$PWD"' in smoke + assert "headRefOid" in smoke and "--ff-only" in smoke + assert "smoke FAILED" in smoke and "/prm" in smoke + # The smoke comes after the refusal steps (tier, decision-taken, Heart, CI), + # so a PR bound for the human's /prm never reaches a full sweep... + assert text.index("decision-taken") < text.index("full affected smoke") + # ...and before the merge itself. + assert text.index("full affected smoke") < text.index("use the prm skill") + assert "/smoke …" in text # the verdict's gate field names it + + +def test_the_closeout_smoke_cannot_be_scoped_without_a_pr_repo(): + assert orch.smoke_command("") == "" + assert "not a GitHub PR URL — refuse" in _step(_closeout("not-a-pr"), 5) + + +def test_autonomy_leg_2_records_the_split(): + leg = (BRAIN / "AUTONOMY.md").read_text().split("2. **Smoke**", 1)[1].split("\n3. **Review**", 1)[0] + assert "2026-11-19" in leg and "PyAutoHeart#352" in leg and "approve C" in leg + assert "--targeted" in leg and "--affected-by" in leg and "--jobs 3" in leg + assert "/prm" in leg