diff --git a/AUTONOMY.md b/AUTONOMY.md index d24829d1..ab4ae0ae 100644 --- a/AUTONOMY.md +++ b/AUTONOMY.md @@ -31,7 +31,7 @@ Where the dev workflow stops for a human today: | 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) | 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 | +| 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 | human, always | human, always | human, always | | Version ask | n/a — release stays `human-required` (sole exception: the scheduled-nightly standing grant, dated below) | n/a | ask | | Cleanup | proceed + log | proceed + log | confirm | @@ -443,6 +443,42 @@ 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. +## Human override for Heart RED (development only) + +Heart RED still parks every autonomous run and blocks every release. After the +agent has parked and reported — or at the equivalent gate in supervised or +human-required development — a **live human** may authorize a non-corrective +development branch to pass the RED gate. This is a development-shipping +override, not an acknowledgement that Heart is healthy, not an autonomy level, +and not evidence that the branch repairs Heart. + +- **Evidence before the ask** — the agent surfaces every exact RED reason + string from Heart's current verdict and shows that the branch has passed all + applicable tests, smoke, and review. A failed branch test, smoke leg, or + review cannot be overridden. +- **Authorization** — the live human names the specific task or issue and + authorizes that branch contemporaneously. It is recorded verbatim, or + faithfully quoted, on the issue. A standing, stored, batch, ambient, or + earlier-session grant does not count. +- **Permitted development actions** — commit, push, and opening the task's + pending-release PR. +- **Merge remains separate and checked** — merge requires a separate explicit + human merge command and every required GitHub check green. One live message + may explicitly authorize both development shipping and merge, but if the + turn ends before the checks are green, the merge grant expires: do not arm + auto-merge or a waiter; the human must invoke `/prm` again. +- **Forbidden** — release, release rehearsal, bypassing a failed test, smoke, + review, required GitHub check or branch protection, force merge, and any + claim that the branch fixes Heart. Heart remains RED for release purposes. +- **Recorded in four sinks** — the authorization, exact current RED reasons, + and passed branch gates are recorded on the **GitHub issue**; in the **PR + body**; in the task's **`PyAutoMind/active.md`** entry as a + `- heart-red-override:` block; and in the **first** table of + **`PyAutoMind/autonomy_log.md`** with outcome `red-override`. + +This override is never inferred or exercised by `--auto`: RED parks the run +first, and only the live human act above can resume development shipping. + ## Corrective-PR exception for Heart RED (human-authorized) Heart RED forbids commit, push and PR-open at every autonomy level (the levels @@ -450,8 +486,9 @@ table). But Heart cannot clear a RED until the fixing source reaches `main`, fresh wheels are built, and release-integration validation passes — so a source fix that directly repairs the exact defect named by the RED reason cannot be shipped, and recovery is impossible without violating policy. This section is -the **one** authorized way through that deadlock, and it is a **human act**, not -an autonomy level: it never fires under `--auto` (the hard invariant "Heart +the **narrow causal-fix path**, alongside the development-only human override +above, through that deadlock. It is a **human act**, not an autonomy level: it +never fires under `--auto` (the hard invariant "Heart YELLOW/RED is never acknowledged autonomously" stands verbatim — an unattended `--auto` run on RED still stops and reports). A human invokes it, live, per incident. @@ -521,11 +558,11 @@ at PR-open (or on parking): ``` Outcome ∈ `merged-unchanged` / `amended` / `rejected` / `rejected-at-review` / -`parked` / `corrective` (`corrective` records a use of the human-authorized -corrective-PR exception above — not an `--auto` run, but logged so the -exception's use is auditable alongside the autonomy rows). This is the evidence -base for raising or lowering caps — autonomy grows by demonstrated calibration, -not by optimism. +`parked` / `corrective` / `red-override`. `corrective` records the causal-fix +exception; `red-override` records the development-only human override. Neither +is an `--auto` run, but both are logged in this first table so their use is +auditable alongside the autonomy rows. This is the evidence base for raising or +lowering caps — autonomy grows by demonstrated calibration, not by optimism. **`rejected-at-review` — added 2026-08-30.** Stamped by the **human**, in their review slot, when they would not have merged what the run produced. It exists @@ -572,6 +609,10 @@ tier), never by weakening leg 4. - **Heart YELLOW/RED is never acknowledged autonomously.** A launch-time human acknowledgement of a named reason set is a human acknowledgement — it binds to that exact set, for that launch, and never extends to new reasons. +- **The development-only human override for Heart RED is a live human act** + after an autonomous run parks, never an autonomous acknowledgement. It can + open a development PR and, only with a separate current human merge command + plus green required checks, merge it; Heart remains RED for release. - **The corrective-PR exception for Heart RED is a contemporaneous human act** (the section above), never reachable under `--auto`. It permits only commit, push and opening one pending-release PR that repairs the named RED reason — @@ -612,6 +653,7 @@ tier), never by weakening leg 4. - `ship_library` / `ship_workspace` — the four-leg gate at step 4 (five under a batch launch), stop at PR-open, validation checklist, calibration append; the RED-handling step - points here for the human-authorized corrective-PR exception. + points here for both the development-only human override and the narrower + corrective-PR exception. Skills must link here rather than copying the tables. diff --git a/agents/conductors/intake/_intake.py b/agents/conductors/intake/_intake.py index ca42a7e8..77d989a4 100755 --- a/agents/conductors/intake/_intake.py +++ b/agents/conductors/intake/_intake.py @@ -1258,7 +1258,7 @@ def bundle_prompt(b: dict) -> str: `/prm` closes each member out unchanged. """ members = [m["path"] for m in b["members"]] - L = [f"You are the architect (Fable) for the PyAutoMind bundle " + L = [f"You are the judgment tier for the PyAutoMind bundle " f"'{b.get('title') or b['slug']}' — {len(members)} INDEPENDENT tasks " "run in one orchestrated session.", "", @@ -1281,11 +1281,14 @@ def bundle_prompt(b: dict) -> str: "branch at a time, so inside it members are worked one at a time, " "each on its own `feature/` branch cut from " "`origin/main`; members in different repos may run in parallel.", - "4. Delegate the implementation of each member to an Opus subagent " - "via the Agent tool (`Agent(model=\"opus\", …)`), one subagent per " - "member, with the member's issue plan, the worktree path and the " - "branch to use. You plan, judge and talk to the user; the subagents " - "edit, test and report back.", + "4. For each member, resolve the execution tier from " + "`PyAutoBrain/skills/WORKFLOW.md`, then delegate implementation " + "through the current harness's native subagent mechanism, one " + "execution delegate per member, with the member's issue plan, the " + "worktree path and the branch to use. If that mechanism is " + "unavailable, follow WORKFLOW's direct-execution fallback. The " + "current session plans, judges and talks to the user; the execution " + "delegate edits, tests and reports back.", "5. Ship each member on its own: `/ship_library` or " "`/ship_workspace`, ONE PR per task, so `/prm` closes each member out " "unchanged. Never one PR for the bundle.", diff --git a/skills/WORKFLOW.md b/skills/WORKFLOW.md index 4a0f5cf8..0665383e 100644 --- a/skills/WORKFLOW.md +++ b/skills/WORKFLOW.md @@ -259,13 +259,16 @@ pyauto-heart readiness --json # authoritative GREEN / YELLOW / RED verdict - **YELLOW** → surface the warnings; proceed only with explicit user acknowledgement (a human checkpoint at **every** autonomy level — [`../AUTONOMY.md`](../AUTONOMY.md)). -- **RED** → stop; report what failed. Do not ship — **unless** a human - authorizes the narrow corrective-PR exception naming the exact RED reason - ([`../AUTONOMY.md`](../AUTONOMY.md) "Corrective-PR exception for Heart RED"): - commit/push/PR-open of one reason-scoped fix only, never merge or release. - When that exception is in play, surface the exact RED reason string(s) - verbatim from `pyauto-heart readiness` so the human authorizes the quote the - agent provided rather than hunting for the wording. +- **RED** → stop and report what failed; an autonomous run parks before any + exception can be considered. After the exact current RED reasons and passed + applicable tests/smoke/review are surfaced, including the reason strings + verbatim from `pyauto-heart readiness`, a live human may authorize the + development-only override ([`../AUTONOMY.md`](../AUTONOMY.md) + "Human override for Heart RED (development only)"), or may authorize the + narrower causal-fix path ("Corrective-PR exception for Heart RED"). Follow + the selected canonical section's scope and record sinks exactly. Neither + path permits release or a CI bypass; merge requires its own current human + command and green required GitHub checks. Tests/smoke runs that feed the verdict are Heart's domain — invoke them through the vitals faculty rather than re-deriving pass/fail criteria in the skill. diff --git a/skills/prm/prm.md b/skills/prm/prm.md index 8a8ba16a..0eb4fd24 100644 --- a/skills/prm/prm.md +++ b/skills/prm/prm.md @@ -115,6 +115,15 @@ every run for the sha and every job in it, and treat anything not `completed` as Green on every leg → merge, in this order: +**PRs shipped under the Heart RED development override.** The shipping grant +alone is not merge authority. Require a separate explicit human merge command +and every required GitHub check green; never force, override protection, or +treat Heart RED as cleared. A live message may authorize both shipping and +merge, but that merge grant lasts only for the current turn. If the turn ends +before checks are green, it expires: arm no waiter or auto-merge, stop, and +require the human to invoke `/prm` again. This permission never reaches a +release or release rehearsal. + 1. **The Heart freeze window — library PRs only.** A release validation is a window in which the library `main`s must not move: a merge landing inside it invalidates the evidence and restales the rehearsal (~75 minutes, measured diff --git a/skills/ship_library/ship_library.md b/skills/ship_library/ship_library.md index 689ead80..eee55035 100644 --- a/skills/ship_library/ship_library.md +++ b/skills/ship_library/ship_library.md @@ -55,13 +55,14 @@ pyauto-heart readiness --json # authoritative GREEN / YELLOW / RED The library test suites are part of Heart's verdict — they run as the gate, not as an ad-hoc step the skill re-judges. **GREEN** → proceed to step 4. **YELLOW** → surface warnings, proceed only on explicit user acknowledgement. -**RED** → stop and report; do not ship — **unless** a human authorizes the -narrow corrective-PR exception naming the exact RED reason (`AUTONOMY.md` -"Corrective-PR exception for Heart RED"), which permits commit/push/PR-open of -one reason-scoped fix only, never merge or release. When that exception is in -play, **surface the exact RED reason string(s) verbatim from `pyauto-heart -readiness`** and the specific corrective request, so the human authorizes the -quote the agent provided rather than hunting for the wording. If `pyauto-brain`/`pyauto-heart` are +**RED** → stop and report; an autonomous run parks. After surfacing the exact +current RED reasons verbatim from `pyauto-heart readiness` and passed applicable +tests/smoke/review, a live human may authorize the canonical `AUTONOMY.md` +"Human override for Heart RED (development only)" or the narrower +"Corrective-PR exception for Heart RED" for a causal fix. Follow the selected +canonical section's scope and four record sinks exactly. Neither path permits +release or bypassing CI; merge requires its own current human command and green +required GitHub checks. If `pyauto-brain`/`pyauto-heart` are unavailable, run the per-repo `pytest / -x` inside the worktree as the gate and treat any failure as RED (WORKFLOW.md). Under `--auto`, this step is the four-leg **autonomous-ship gate** — tests (+ downstream dependents on diff --git a/skills/ship_workspace/ship_workspace.md b/skills/ship_workspace/ship_workspace.md index 2b237dfe..fec56c0d 100644 --- a/skills/ship_workspace/ship_workspace.md +++ b/skills/ship_workspace/ship_workspace.md @@ -52,14 +52,15 @@ pyauto-heart readiness --json # GREEN / YELLOW / RED ``` Workspace **smoke tests** are part of Heart's verdict. **GREEN** → execute. -**YELLOW** → proceed only on explicit acknowledgement. **RED** → stop — -**unless** a human authorizes the narrow corrective-PR exception naming the -exact RED reason (`AUTONOMY.md` "Corrective-PR exception for Heart RED"), which -permits commit/push/PR-open of one reason-scoped fix only, never merge or -release. When that exception is in play, **surface the exact RED reason -string(s) verbatim from `pyauto-heart readiness`** and the specific corrective -request, so the human authorizes the quote the agent provided rather than -hunting for the wording. If the +**YELLOW** → proceed only on explicit acknowledgement. **RED** → stop; an +autonomous run parks. After surfacing the exact current RED reasons and passed +applicable tests/smoke/review, including the reason strings verbatim from +`pyauto-heart readiness`, a live human may authorize the canonical +`AUTONOMY.md` "Human override for Heart RED (development only)" or the narrower +"Corrective-PR exception for Heart RED" for a causal fix. Follow the selected +canonical section's scope and four record sinks exactly. Neither path permits +release or bypassing CI; merge requires its own current human command and green +required GitHub checks. If the organism CLIs are unavailable, run `/smoke_test` (with `activate.sh` sourced) as the gate and treat any failure as RED. Under `--auto`, this step is the four-leg **autonomous-ship gate** (`AUTONOMY.md` "The autonomous-ship gate"); diff --git a/tests/test_corrective_red_exception.py b/tests/test_corrective_red_exception.py index c7510a43..117260dd 100644 --- a/tests/test_corrective_red_exception.py +++ b/tests/test_corrective_red_exception.py @@ -1,10 +1,10 @@ -"""Doc-contract tests for the human-authorized corrective-PR exception to -Heart RED (PyAutoBrain#112). +"""Doc-contract tests for the human-authorized development paths through +Heart RED (PyAutoBrain#112 and the development-only override). The exception is doctrine, not code, so its guardrails are pinned against the canonical text of AUTONOMY.md — a weakening edit (dropping a forbidden action, a record sink, or the human-only clause) fails loudly here rather than silently -widening the one authorized path through a RED gate. The seam tests also pin +widening either authorized path through a RED gate. The seam tests also pin the "link, don't duplicate policy" contract: the ship skills point at AUTONOMY.md and do not carry a second copy of the permitted/forbidden lists. """ @@ -16,8 +16,10 @@ SHIP_LIBRARY = (BRAIN_HOME / "skills" / "ship_library" / "ship_library.md").read_text() SHIP_WORKSPACE = (BRAIN_HOME / "skills" / "ship_workspace" / "ship_workspace.md").read_text() WORKFLOW = (BRAIN_HOME / "skills" / "WORKFLOW.md").read_text() +PRM = (BRAIN_HOME / "skills" / "prm" / "prm.md").read_text() SECTION_HEADER = "## Corrective-PR exception for Heart RED (human-authorized)" +OVERRIDE_HEADER = "## Human override for Heart RED (development only)" def _norm(text): @@ -26,10 +28,10 @@ def _norm(text): return " ".join(text.replace("*", "").replace("`", "").lower().split()) -def _section(): - """The corrective-PR exception section body (header to the next ``## ``).""" - start = AUTONOMY.index(SECTION_HEADER) - rest = AUTONOMY[start + len(SECTION_HEADER):] +def _section(header=SECTION_HEADER): + """One policy section body, from its header to the next ``## ``.""" + start = AUTONOMY.index(header) + rest = AUTONOMY[start + len(header):] end = rest.find("\n## ") return _norm(rest if end == -1 else rest[:end]) @@ -38,6 +40,69 @@ def test_section_exists(): assert SECTION_HEADER in AUTONOMY +def test_development_override_requires_live_human_and_passing_branch_gates(): + sec = _section(OVERRIDE_HEADER) + assert "non-corrective development branch" in sec + assert "live human" in sec + assert "every exact red reason string from heart's current verdict" in sec + assert "passed all applicable tests, smoke, and review" in sec + for stale_grant in ("standing", "stored", "batch", "ambient", + "earlier-session"): + assert stale_grant in sec + assert "specific task or issue" in sec + assert "verbatim, or faithfully quoted, on the issue" in sec + + +def test_development_override_scope_records_and_release_boundary(): + sec = _section(OVERRIDE_HEADER) + for permitted in ("commit", "push", "opening the task's pending-release pr"): + assert permitted in sec + for sink in ("github issue", "pr body", "pyautomind/active.md", + "- heart-red-override:", "pyautomind/autonomy_log.md", + "outcome red-override"): + assert _norm(sink) in sec, sink + assert "first table" in sec + for forbidden in ("release rehearsal", "force merge", + "claim that the branch fixes heart", + "bypassing a failed test", + "required github check or branch protection"): + assert forbidden in sec + assert "heart remains red for release purposes" in sec + + +def test_development_override_merge_grant_expires_and_never_bypasses_ci(): + sec = _section(OVERRIDE_HEADER) + assert "separate explicit human merge command" in sec + assert "every required github check green" in sec + assert "if the turn ends before the checks are green, the merge grant expires" in sec + assert "human must invoke /prm again" in sec + prm = _norm(PRM) + assert "merge grant lasts only for the current turn" in prm + assert "every required github check green" in prm + assert "invoke /prm again" in prm + + +def test_development_override_is_never_autonomous_and_has_log_schema(): + sec = _section(OVERRIDE_HEADER) + assert "never inferred or exercised by --auto" in sec + assert "red parks the run first" in sec + assert "red-override" in AUTONOMY + + +def test_both_ship_skills_link_the_development_override(): + marker = "Human override for Heart RED (development only)" + assert marker in SHIP_LIBRARY + assert marker in SHIP_WORKSPACE + assert marker in WORKFLOW + + +def test_corrective_path_coexists_with_the_development_override(): + sec = _section() + assert "narrow causal-fix path" in sec + assert "alongside the development-only human override" in sec + assert "one authorized way" not in sec + + def test_permitted_set_is_commit_push_pr_open_only(): sec = _section() for verb in ("commit", "push", "opening one"): diff --git a/tests/test_intake_dashboard.py b/tests/test_intake_dashboard.py index 2111bf4e..e8b7c8b7 100644 --- a/tests/test_intake_dashboard.py +++ b/tests/test_intake_dashboard.py @@ -1119,15 +1119,21 @@ def test_the_bundle_prompt_states_the_orchestration_contract(tmp_path): "feature/widgets/a.md": _prompt("Widget A"), "feature/widgets/b.md": _prompt("Widget B")}) prompt = _intake.bundle_prompt(_intake.auto_bundles(_intake.census(mind))[0]) - assert "architect (Fable)" in prompt + assert "judgment tier" in prompt assert "draft/feature/widgets/a.md" in prompt assert "/start_dev " in prompt assert "one issue" in prompt and "bulk issue queue" in prompt assert "One shared worktree per repo" in prompt - assert "Opus subagent" in prompt + assert "PyAutoBrain/skills/WORKFLOW.md" in prompt + assert "current harness's native subagent mechanism" in prompt + assert "one execution delegate per member" in prompt + assert "direct-execution fallback" in prompt assert "ONE PR per task" in prompt assert "/prm" in prompt assert "/ship_library" in prompt + assert "Fa" + "ble" not in prompt + assert "Op" + "us" not in prompt + assert "Agent(" + "model=" not in prompt def test_bundles_sit_between_backlog_and_recent_on_both_pages(tmp_path):