diff --git a/AUTONOMY.md b/AUTONOMY.md index e190d45e..d24829d1 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 | 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) | 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 human may separately invoke the corrective-PR exception (below), which is not an autonomy level | | Merge / close | human, always | human, always | human, always | @@ -236,15 +236,41 @@ otherwise. up per the prompt's fallback clause and the task parks as blocked; it never becomes a question for the human to answer. -Ship sign-off and merge park the *task*, never bypass the gate — -checkpoint-and-continue frees the human's session, not the checkpoint. - -### Decide-and-flag (batch launches only) — 2026-08-30 - -Park-and-ask is the right behaviour when a human is one message away. In a shift -it costs the whole shift: the run stops, the question waits until the slot, and -the task needs a second batch. So a run under a **batch launch** may, at a -judgement gate, take the more reversible option and record it instead of parking. +An interactive `supervised` run parks at ship sign-off exactly as above — +the human is one message away, so the round-trip is free. Under an explicit +`--auto` launch the ship checkpoint instead resolves to **decide-and-flag** +(next section, extended to it 2026-09-07): the run ships to an open PR and the +decision is flagged there. Merge stays a human act either way, and no run ever +bypasses the gate — checkpoint-and-continue frees the human's session, not the +checkpoint. + +### Decide-and-flag (`--auto` launches) — 2026-08-30, extended 2026-09-07 + +Park-and-ask is the right behaviour when a human is one message away. Under an +unattended launch it costs the whole run: the run stops, the question waits until +the human next comes in, and the task needs a second dispatch. So a run under an +explicit **`--auto` launch** — a batch launch included — may, at a judgement +gate, take the more reversible option and record it instead of parking. + +**Extended 2026-09-07 to every explicit `--auto` launch, and to the ship +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, 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 +judgement again at merge. The evidence, 2026-08-31: two supervised-capped +`--auto` runs took decide-and-flag (PyAutoFit#1554, PyAutoMemory#76) and gave +exactly one review surface; three took the park branch (PyAutoHands#272, +PyAutoFit#1552, euclid#47) and each needed a separate human judgement before a PR +existed. The scope is **explicit `--auto` launches only** — an interactive +`supervised` run keeps park-and-ask, because there the human is one message away +and the round-trip is free. `human-required`, `Unattended: never` and +`Blocked-by:` are unchanged and never run unattended. Every limit below is +unchanged, **including "never for a `judge`-tier task"**: a `supervised` run that +reaches a judge-tier gate other than ship sign-off still parks. **Narrowly**, because the agent deciding is the poorest available judge of its own decision's scope. The base rate is measured, not feared: **68 of 332 @@ -276,7 +302,9 @@ choice. The cap, the revert line and the tier exclusion are what keep that cost to one bounded item per PR rather than an unmarked scatter. *Revert condition:* two flagged decisions the human would not have taken retires -this section; it returns to park-and-ask. +this section; it returns to park-and-ask. Or one `supervised` `--auto` run +opening a PR the human would have wanted stopped before it existed — the ship +checkpoint returns to park-and-ask (2026-09-07). ## The autonomous-ship gate diff --git a/agents/conductors/batch/_batch.py b/agents/conductors/batch/_batch.py index 6a739787..a2abed57 100644 --- a/agents/conductors/batch/_batch.py +++ b/agents/conductors/batch/_batch.py @@ -272,8 +272,11 @@ def plan(records: list[dict], *, budget: int = DEFAULT_REVIEW_BUDGET, pool = [] for r in records: # Readiness says the work FITS one run; autonomy says the run may - # FINISH it. A batch that ignores the second fills a shift with tasks - # that all stop at the ship checkpoint and come back as questions — + # FINISH it. Under `--auto` a `supervised` run's ship checkpoint + # resolves to decide-and-flag (AUTONOMY.md, "Decide-and-flag", + # extended 2026-09-07): it ships to an open PR rather than parking, so + # it FINISHES and belongs in the pool. Only `human-required` would + # still stop at the ship checkpoint and come back as a question — # which is the failure the whole epic exists to remove. if r.get("done"): rejected.append((r["path"], "Status: says the work is already done")) @@ -281,7 +284,7 @@ def plan(records: list[dict], *, budget: int = DEFAULT_REVIEW_BUDGET, r["epic"], float("inf")): rejected.append((r["path"], f"epic {r['epic']} phase {r.get('phase')} is not next")) - elif r["autonomy"] != "safe": + elif r["autonomy"] == "human-required": rejected.append((r["path"], f"autonomy {r['autonomy']} — would park at ship")) elif r["unattended"] != "ready": @@ -387,7 +390,14 @@ def emit(d: dict) -> None: cost = 0 if r["consequence"] in CHEAP_TIERS else r["review_minutes"] rank = r.get("queue_rank", queued) mark = f"q{rank + 1}" if rank < queued else " " - print(f" {mark:<3}{cost:>3} min {r['consequence']:<7} {r['path']}") + # A `supervised` member ships under decide-and-flag rather than + # parking (AUTONOMY.md 2026-09-07); say so on the line, so the + # human approving the batch sees which members carry a flagged + # decision at review. + note = (" (supervised — decide-and-flag at ship)" + if r.get("autonomy") == "supervised" else "") + print(f" {mark:<3}{cost:>3} min {r['consequence']:<7} " + f"{r['path']}{note}") if not r["witness"]: print(" (no witness — reviewed as `judge`)") elif d["effective_budget"] == 0: diff --git a/skills/batch/batch.md b/skills/batch/batch.md index 681d2273..d57c6acc 100644 --- a/skills/batch/batch.md +++ b/skills/batch/batch.md @@ -31,10 +31,12 @@ task they named: - **taken** — with its tier and review-minutes; - **rejected, and why** — in the planner's own words. The reasons that come up - most: `autonomy supervised — would park at ship` (it will stop at the ship - checkpoint and come back as a question, which is the failure this workflow - exists to remove), `Status: says the work is already done`, `epic phase - N is not next`, ` already claimed this shift`, `would exceed the budget`. + most: `autonomy human-required — would park at ship` (it cannot run unattended + at all — it would stop at the ship checkpoint and come back as a question, + which is the failure this workflow exists to remove; `supervised` no longer + parks there, see AUTONOMY.md "Decide-and-flag"), `Status: says the work is + already done`, `epic phase N is not next`, ` already claimed this + shift`, `would exceed the budget`. If everything they named is rejected, **say so plainly and offer the planner's own proposal instead** — never hand back a batch they did not ask for as though diff --git a/skills/start_dev/start_dev.md b/skills/start_dev/start_dev.md index c1a0465e..1aae8224 100644 --- a/skills/start_dev/start_dev.md +++ b/skills/start_dev/start_dev.md @@ -56,9 +56,14 @@ activation rule in [`../../AUTONOMY.md`](../../AUTONOMY.md)): (step 5 below) and proceed straight through steps 4–7 and into `start_library`/`start_workspace` and implementation. The plan the human would have approved is on the issue for post-hoc validation. -3. **`supervised`** → judgment gates become batched issue questions and the - run advances (the contract's "Checkpoint-and-continue" section: question → - `awaiting-input` park → next independent step or task → resume from +3. **`supervised`** → the **ship checkpoint does not park**: it resolves to + decide-and-flag ([`../../AUTONOMY.md`](../../AUTONOMY.md), + "Decide-and-flag") — ship through the autonomous-ship gate, flag the + decision in the PR body, and **end at PR-open** (merge stays human). Every + *other* judgment gate — a scope/design fork the plan didn't settle, a second + flagged decision, a hard blocker — still becomes a batched issue question + with an `awaiting-input` park (the contract's "Checkpoint-and-continue" + section: question → park → next independent step or task → resume from `active.md`); mechanical stretches proceed. 4. **`human-required`** → `--auto` changes nothing; today's flow. 5. If the human acknowledged a Heart YELLOW reason set at launch, record that diff --git a/tests/test_autonomy_doctrine.py b/tests/test_autonomy_doctrine.py new file mode 100644 index 00000000..19b4a42c --- /dev/null +++ b/tests/test_autonomy_doctrine.py @@ -0,0 +1,87 @@ +"""Doc-contract tests for the 2026-09-07 decide-and-flag extension +(PyAutoBrain#363). + +Under an explicit `--auto` launch an effective-`supervised` run's ship +checkpoint no longer parks: it resolves to decide-and-flag and the run ends at +PR-open, where the PR review is the human approval the level exists to provide. +That is doctrine, not code, so it is pinned against the canonical text of +AUTONOMY.md — an edit that quietly drops the scope sentence or the revert +condition fails loudly here rather than leaving the planner admitting work the +contract no longer covers. +""" + +from pathlib import Path + +BRAIN_HOME = Path(__file__).resolve().parents[1] +AUTONOMY = (BRAIN_HOME / "AUTONOMY.md").read_text() + +SECTION_HEADER = "### Decide-and-flag" + + +def _norm(text): + """Lowercase, strip markdown emphasis, and collapse whitespace so assertions + ignore ``**``/``` ` ``` and line wrapping.""" + return " ".join(text.replace("*", "").replace("`", "").lower().split()) + + +def _heading(): + """The decide-and-flag heading line, verbatim.""" + for line in AUTONOMY.splitlines(): + if line.startswith(SECTION_HEADER): + return line + raise AssertionError("decide-and-flag heading not found in AUTONOMY.md") + + +def _section(): + """The decide-and-flag section body (header line to the next ``## ``).""" + head = _heading() + start = AUTONOMY.index(head) + rest = AUTONOMY[start + len(head):] + end = rest.find("\n## ") + return _norm(rest if end == -1 else rest[:end]) + + +def test_heading_records_the_extension_date(): + # The heading is the dated audit trail: the rule was born 2026-08-30 for + # batch launches and widened 2026-09-07 to every explicit --auto launch. + head = _norm(_heading()) + assert "extended 2026-09-07" in head + assert "--auto launches" in head + + +def test_section_carries_the_dated_extension_paragraph(): + sec = _section() + assert "extended 2026-09-07" in sec + assert "ship checkpoint" in sec + + +def test_extension_is_scoped_to_auto_launches_only(): + # Interactive supervised runs keep park-and-ask, and the levels that never + # run unattended are untouched. + sec = _section() + assert "explicit --auto launches only" in sec + for untouched in ("human-required", "unattended: never", "blocked-by:"): + assert untouched in sec, untouched + + +def test_the_judge_tier_limit_survives_the_extension(): + # The extension changes WHERE the ship checkpoint lands, never a limit. + sec = _section() + assert "never for a judge-tier task" in sec + + +def test_levels_table_supervised_ship_cell_names_decide_and_flag(): + row = next(line for line in AUTONOMY.splitlines() + if line.startswith("| Ship PR sign-off |")) + supervised = _norm(row.split("|")[3]) + assert "decide-and-flag" in supervised + assert "--auto" in supervised + assert "2026-09-07" in supervised + + +def test_revert_condition_returns_the_ship_checkpoint_to_park_and_ask(): + sec = _section() + assert "revert condition:" in sec + assert "park-and-ask" in sec + # the second, 2026-09-07 condition: one unwanted PR retires the extension + assert "would have wanted stopped before it existed" in sec diff --git a/tests/test_batch_plan.py b/tests/test_batch_plan.py index a7b71dd6..2e782491 100644 --- a/tests/test_batch_plan.py +++ b/tests/test_batch_plan.py @@ -134,17 +134,19 @@ def test_lane_detection_reads_the_environment_not_a_flag(): assert _batch.detect_lane() in ("local-dev", "web-github") -def test_only_safe_work_is_dispatched(): +def test_human_required_work_is_never_dispatched(): """Readiness says the work FITS one run; autonomy says the run may FINISH - it. A batch that reads only the first fills a shift with tasks that all - stop at the ship checkpoint and come back as questions — which is the - failure the epic exists to remove. Found by running the planner against the - live backlog and reading what it picked.""" + it. Under `--auto` a `supervised` run's ship checkpoint resolves to + decide-and-flag rather than parking (AUTONOMY.md, "Decide-and-flag", + extended 2026-09-07), so it finishes at an open PR and belongs in the pool. + Only `human-required` would still stop at the ship checkpoint and come back + as a question — which is the failure the epic exists to remove.""" d = _batch.plan([rec("a.md", autonomy="safe"), rec("b.md", autonomy="supervised"), rec("c.md", autonomy="human-required")], budget=100) - assert paths(d) == ["a.md"] - assert "would park at ship" in why(d, "b.md") + assert sorted(paths(d)) == ["a.md", "b.md"] + assert "would park at ship" in why(d, "c.md") + assert "human-required" in why(d, "c.md") def test_a_prompt_that_says_it_is_done_is_never_dispatched():