diff --git a/AUTONOMY.md b/AUTONOMY.md index 49e9ce0..3d3750b 100644 --- a/AUTONOMY.md +++ b/AUTONOMY.md @@ -321,7 +321,10 @@ never an assumption: entries). The audit found the shipped-repos-only contract papers over 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. + dir (organism/doc repos): leg is n/a, stated in the PR body. Inside a + shift the worker runs the changed and covering test modules plus the + `Witness:` instead, and PR CI is the full-suite verdict: ruling S1 in + "Shift speed — 2026-11-19" below. 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 @@ -401,6 +404,10 @@ never an assumption: *Revert condition:* if the leg produces no finding across 30 runs it is ceremony, and this clause is removed rather than left as theatre. + Inside a shift the worker runs no adversary pass; the close-out session or + the human at `/prm` is the adversary: ruling S3 in "Shift speed — + 2026-11-19" below. + A failed leg downgrades the run to a human checkpoint: state written to the issue, nothing force-shipped, never modify code to make a leg pass. @@ -474,6 +481,37 @@ own `batches/AGENTS.md` drops both: the Heart gates releases, not runs), and **their absence there is never read as an unacknowledged RED** — the fields are not missing, they do not exist on that schema. +## Shift speed — 2026-11-19 + +The human's rulings, 2026-11-19, on the orchestrator speed review +(`Science/scratch/orchestrator_speed_review_2026-11-19/review.md`; M3.7a, +PyAutoBrain#686). They bring a shift worker's ship step close to a chat +build's loop. Measured over shifts 2026-11-18-pm, -pm2 and 2026-11-19-am +(7 workers), the real work took 10 to 16 minutes per task. The full local +unit suite added 5 to 19 minutes, and 10 to 15 more when laptop load caused +false failures and a rerun. PR CI runs the same suite on Python 3.12 and +3.13, and the merge reads that verdict. The worker's adversary pass cost 60 +to 130k tokens per task, while the close-out session (unattended) or the +human (`/prm`) already reads the PR a second time. + +- **S1, leg 1 in a shift.** The worker runs the test modules its diff + changes or that cover the changed code, plus the `Witness:`. PR CI is the + full-suite verdict for the shipped repo. The dependants' full suites still + run locally when the diff changes public API (they are not in the PR's + CI). A red CI after the worker has ended sends the PR to `/prm`, as now. +- **S3, leg 5 in a shift.** The worker runs one independent review (leg 3) + and no adversary pass. The adversary is the close-out session for an + unattended merge ("Stage-2 adversary amendment — 2026-11-04") and the + human at `/prm` for everything else. + +A worker caps any pytest it runs at `-n 4`. It starts the review beside the +tests and the targeted smoke (leg 2), and opens the PR as soon as they pass +(`agents/conductors/batch/worker_template.md`). + +Outside a shift (an `--auto` chat) nothing changes. + +Later rulings from the same review (S2, S4 to S7) are added to this section. + ## Merge authority follows Consequence — 2026-10-02 **Who merges is decided by the task's declared `Consequence:` tier** diff --git a/agents/conductors/batch/AGENTS.md b/agents/conductors/batch/AGENTS.md index d7215da..0fa1367 100644 --- a/agents/conductors/batch/AGENTS.md +++ b/agents/conductors/batch/AGENTS.md @@ -911,7 +911,9 @@ in a session **using a different model from the one that wrote the branch**. A self-run adversary leg is an absent leg, not a weak one. `collect` cannot run it for you and does not pretend to: with no `adversary` block in the evidence the leg is UNOBSERVABLE and the member reaches the human as SUSPECT — the -honest state, rather than a gap that closes itself. +honest state, rather than a gap that closes itself. The shift worker does not +run this pass (`AUTONOMY.md` "Shift speed — 2026-11-19", ruling S3): your read, +or the close-out session for an unattended merge, is the adversary. **What to expect from batch 1.** Small. The planner picks against a 45-minute review budget, and with almost no prompt carrying a `Witness:` nearly everything diff --git a/agents/conductors/batch/worker_template.md b/agents/conductors/batch/worker_template.md index f85958b..b9f5010 100644 --- a/agents/conductors/batch/worker_template.md +++ b/agents/conductors/batch/worker_template.md @@ -45,9 +45,29 @@ 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. +- At the ship step you run the loop a chat build runs (AUTONOMY.md "Shift + speed — 2026-11-19", rulings S1 and S3). Only legs 1 (tests) and 5 + (adversary) of the autonomous-ship gate change in a shift. The review + (leg 3), the targeted smoke (leg 2) and the Heart verdict (leg 4) apply as + before: + - **Tests (S1).** Run the test modules your diff changes or that cover the + changed code, plus the task's `Witness:`, not the full suite. PR CI is the + full-suite verdict for the repo you ship. When the review surface flags a + public API change (removed, renamed or changed-signature entries), still + run the dependants' full suites locally, because they are not in your + PR's CI. Cap any pytest you run at `-n 4` + (`python -m pytest -q -n 4 `). + - **Review (S3).** Start one independent review (AUTONOMY.md leg 3) beside + the tests and the targeted smoke, not after them. It must return verdict + CLEAN. + - **PR.** Open the PR as soon as the tests, the `Witness:`, the targeted + smoke and the review pass. Run no adversary pass: the close-out session + is the adversary for an unattended merge, and the human at `/prm` for + everything else. + - A red CI after you have ended sends the PR to `/prm`, as before. - 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 + PyAutoHeart#352). At the ship step run only this smoke, beside the tests + and the review above, 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|^|/|') diff --git a/skills/ship_library/reference.md b/skills/ship_library/reference.md index c3fab2d..24f47b4 100644 --- a/skills/ship_library/reference.md +++ b/skills/ship_library/reference.md @@ -97,7 +97,14 @@ Build/release step. Per repo, after the vitals faculty / Heart verdict is GREEN: 1. `source "$WT_ROOT/activate.sh"`; run `python -m pytest / -x` from inside `"$WT_ROOT/"` (skip only if the repo has no test dir). These tests feed Heart's verdict — a failure means **stop**, return the failing - names + traceback tail, do not commit, do not try to fix. + names + traceback tail, do not commit, do not try to fix. A shift worker + runs only the test modules its diff changes or that cover the changed + code, plus the `Witness:`, with `python -m pytest -q -n 4 `; PR CI + is the full-suite verdict. It still runs each dependant's full suite + (`-n 4`) when the review surface flags a public API change (ruling S1 in + `AUTONOMY.md` "Shift speed — 2026-11-19"). It starts its one independent + review beside these tests and the targeted smoke, runs no adversary pass + (ruling S3), and opens the PR as soon as they pass. 2. If the worktree is not on `feature/`, stop and report — never auto-switch branches. 3. `git -C "$WT_ROOT/" add -A && git commit -m "" && git push -u origin feature/`. diff --git a/skills/ship_library/ship_library.md b/skills/ship_library/ship_library.md index 0a518a7..fe40fc6 100644 --- a/skills/ship_library/ship_library.md +++ b/skills/ship_library/ship_library.md @@ -83,7 +83,8 @@ rules rather than weakening the gate: Under `--auto`, this step is the four-leg **autonomous-ship gate** — tests (+ downstream dependents on public-API changes), smoke, review-faculty CLEAN, Heart — per `AUTONOMY.md` "The autonomous-ship gate"; do not restate it here. -A same-conversation reread is not an independent review. +A same-conversation reread is not an independent review. Shift worker tests: +ruling S1, see [`reference.md`](reference.md) → "Execution contract" step 1. ### 4. Execute the ship (feature-dev) @@ -103,7 +104,8 @@ its cross-environment handoff rather than by provider-name conditionals. If any step or evidence leg fails, stop and report — do not proceed. **Under `--auto`:** all four legs of the autonomous-ship gate must pass — **five under a batch launch**, which adds the independent-adversary leg (`AUTONOMY.md` leg 5) — (step -3 note); then ship **without interactive sign-off** — the PR body additionally +3 note); a shift worker runs no adversary pass (ruling S3, `AUTONOMY.md` "Shift +speed — 2026-11-19"). Then ship **without interactive sign-off** — the PR body additionally carries the `## Validation checklist` section ([`reference.md`](reference.md) → "Validation checklist (--auto)"), the run **stops at PR-open** unless step 6's declared tier merges it, a calibration row is diff --git a/tests/test_shift_speed_worker_loop.py b/tests/test_shift_speed_worker_loop.py new file mode 100644 index 0000000..dfb16d6 --- /dev/null +++ b/tests/test_shift_speed_worker_loop.py @@ -0,0 +1,103 @@ +"""The shift worker runs the chat loop (M3.7a, PyAutoBrain#686). + +Rulings S1 and S3 of AUTONOMY.md "Shift speed — 2026-11-19": inside a shift +the worker runs the test modules its diff changes or that cover the changed +code, plus the `Witness:`, not the full suite (PR CI is the full-suite +verdict); the dependants' full suites still run on a public API change; one +independent review and the targeted smoke, then the PR opens; no adversary +pass (the close-out session or the human at `/prm` is the adversary). +""" + +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 + +SECTION = "## Shift speed — 2026-11-19" + + +def _flat(text: str) -> str: + """Prose wraps anywhere; compare phrases with whitespace collapsed.""" + return " ".join(text.split()) + + +def _prompt() -> str: + return _flat(orch.worker_prompt("t1", "draft/feature/widgetlib/t1.md", Path("b.md"), Path("leases"))) + + +def _autonomy() -> str: + return (BRAIN / "AUTONOMY.md").read_text(encoding="utf-8") + + +def test_the_worker_runs_the_changed_test_modules_and_the_witness_not_the_full_suite(): + prompt = _prompt() + assert "test modules your diff changes or that cover the changed code" in prompt + assert "the task's `Witness:`" in prompt + assert "not the full suite" in prompt + assert "PR CI is the full-suite verdict" in prompt + assert "-n 4" in prompt + # Only legs 1 and 5 change; the Heart leg is unchanged. + assert "Only legs 1 (tests) and 5 (adversary) of the autonomous-ship gate change in a shift" in prompt + assert "the Heart verdict (leg 4) apply as before" in prompt + assert "not the full gate" not in prompt + assert "S1" in prompt and "Shift speed — 2026-11-19" in prompt + + +def test_the_worker_runs_no_adversary_pass(): + prompt = _prompt() + assert "--adversary" not in prompt + assert "no adversary pass" in prompt + assert "S3" in prompt + + +def test_the_worker_still_runs_one_independent_review_and_the_targeted_smoke(): + prompt = _prompt() + assert "one independent review" in prompt + assert "verdict CLEAN" in prompt + assert "--targeted --changed-files" in prompt + # The review starts beside the tests and the smoke; the PR opens once all pass. + assert "beside the tests and the targeted smoke" in prompt + assert "Open the PR as soon as" in prompt + + +def test_the_worker_runs_the_dependants_suites_on_a_public_api_change(): + prompt = _prompt() + assert "dependants' full suites" in prompt + assert "public API change" in prompt + + +def test_autonomy_records_s1_and_s3_and_legs_1_and_5_point_to_them(): + text = _autonomy() + assert SECTION in text + sec = _flat(text.split(SECTION, 1)[1].split("\n## ", 1)[0]) + assert "**S1, leg 1 in a shift.**" in sec + assert "**S3, leg 5 in a shift.**" in sec + assert "PR CI is the full-suite verdict" in sec + assert "Outside a shift (an `--auto` chat) nothing changes." in sec + gate = text.split("## The autonomous-ship gate", 1)[1].split("\n### ", 1)[0] + leg1 = gate.split("1. **Tests**", 1)[1].split("\n2. **Smoke**", 1)[0] + leg5 = gate.split("5. **Independent adversary**", 1)[1].split("\nA failed leg", 1)[0] + leg1, leg5 = _flat(leg1), _flat(leg5) + assert "Shift speed — 2026-11-19" in leg1 and "S1" in leg1 + assert "Shift speed — 2026-11-19" in leg5 and "S3" in leg5 + + +def test_ship_library_follows_the_shift_rule(): + skill = _flat((BRAIN / "skills" / "ship_library" / "ship_library.md").read_text(encoding="utf-8")) + # Outside a shift a batch launch still needs leg 5; the shift worker is the exception. + assert "five under a batch launch" in skill + assert "a shift worker runs no adversary pass (ruling S3" in skill + assert "Shift speed — 2026-11-19" in skill + assert "Shift worker tests: ruling S1, see [`reference.md`]" in skill + ref = (BRAIN / "skills" / "ship_library" / "reference.md").read_text(encoding="utf-8") + step1 = _flat(ref.split("## Execution contract", 1)[1].split("\n2. ", 1)[0]) + assert "shift worker" in step1 and "-n 4" in step1 + assert "Shift speed — 2026-11-19" in step1 + assert "beside these tests and the targeted smoke" in step1 + assert "no adversary pass (ruling S3)" in step1