From ab9b9f99feececfe6bd2a0ec83c1df0b47380800 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 12 Nov 2026 18:28:26 +0000 Subject: [PATCH 1/2] =?UTF-8?q?autonomy:=20merge=20actor=20and=20random=20?= =?UTF-8?q?audit=20=E2=80=94=202026-11-12=20(#606)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Programme M1.4, finding FLOW-2. Records the human's three decisions ("All three as recommended") as the dated AUTONOMY.md section "Merge actor and random audit — 2026-11-12", with a revert condition. - The watcher's stage-2 row now ends in `merge actor` and `read by human`: `unattended-watcher (mergedBy )` from the gh state it already reads, and an empty read-by-human cell. - prm close-out docs pass `--actor ` on `lifecycle.py close` and name the two new columns; audits draw `lifecycle.py audit-sample --seed `. Pairs with PyAutoMind feature/merge-actor-audit (lifecycle.py + ledger). Co-Authored-By: Claude Opus 5.5 --- AUTONOMY.md | 49 ++++++++++++++++++++++++ agents/conductors/batch/_orchestrator.py | 18 +++++++-- skills/prm/closeout.md | 10 +++-- skills/prm/reference.md | 14 ++++--- tests/test_orchestrator_closeout.py | 10 +++-- 5 files changed, 86 insertions(+), 15 deletions(-) diff --git a/AUTONOMY.md b/AUTONOMY.md index c7ee7c91..4a790b5b 100644 --- a/AUTONOMY.md +++ b/AUTONOMY.md @@ -600,6 +600,55 @@ ignored Heart state. The stage-2 window is how this is checked. `merged-after-substantive-change`, restores the different-model requirement for unattended merges at once, by dated doctrine edit citing the row. +## Merge actor and random audit — 2026-11-12 + +Amends "The `glance` Shadow-window ruling — 2026-11-04" above: it puts that +ruling's "Ledger accuracy" rule into code and replaces hand-picked audits. +Decided by the human 2026-11-12 in the programme session (task M1.4, +PyAutoBrain#606, finding FLOW-2 of the 2026-11-10 ecosystem review): "All three +as recommended". This section is that dated doctrine edit. The ruling itself, +its narrowing and the stage-2 adversary rules are unchanged. + +The three decisions, verbatim: + +1. **Merge-actor column**, tool-written, classes `human-/prm` | + `in-turn-human-commanded` | `in-turn-autonomous` | `unattended-watcher` | + `unknown`; the count **leaves out** `human-/prm` and + `in-turn-human-commanded`. +2. **Audits** of the glance window are a **seeded 1-in-5 random sample**, + audited within a week, instead of hand-picked rows. +3. A **`read-by-human` date column** is recorded but does **not** gate the + count yet (gating is a judge question after the recount). + +The stage-1 recount is printed only; if it changes what the 11-04 glance +ruling rests on, that is a separate judge question for the human. + +**How it runs.** Both tables in `PyAutoMind/autonomy_log.md` (stage 1 and the +stage-2 sub-window) end in `merge actor` and `read by human`. The class comes +from the writer's explicit flag — `lifecycle.py close … --actor ` or +`shadow-row --actor ` at `/prm` close-out, and `unattended-watcher` from +the shift watcher — because how a merge started is known only to the session +that started it. `gh pr view --json mergedBy,mergedAt` adds the evidence, +` (mergedBy )`, never the class. Rows written before this edit +stop at `stage` and read as `unknown`, which still counts; they are not +rewritten. `lifecycle.py shadow-recount` prints the window by actor and the +historical rows classified from their completion records by a printed keyword +rule; `lifecycle.py audit-sample --seed ` draws the audit sample. + +**The recount, as printed on 2026-11-12** (completion records, not re-marked): +of the 69 rows the 2026-11-04 ruling rested on, 31 human `/prm`, 10 automatic +or in-turn, 28 not stated. The three rows of 2026-11-12 — +`shift-watcher-state-gaps`, `prompt-sync-explicit-paths`, +`prompt-sync-detached-push`, merged in-turn on the human's explicit merge +command under a Heart RED override — are recorded `in-turn-human-commanded` +and left out of the count. + +*Revert condition:* an audit that finds a tool-written merge actor wrong on any +row suspends the actor rule — the count goes back to every in-window row, with +"Ledger accuracy" applied by hand — until the writer is fixed, by dated +doctrine edit citing the row. A `reverted` row still demotes `glance` as the +ruling says. + ## Shift briefs and unattended `glance` — 2026-11-03 Approved by the human 2026-11-03 as the rulings of the autonomous-orchestrators diff --git a/agents/conductors/batch/_orchestrator.py b/agents/conductors/batch/_orchestrator.py index cf9a6953..cb3578b3 100644 --- a/agents/conductors/batch/_orchestrator.py +++ b/agents/conductors/batch/_orchestrator.py @@ -984,7 +984,8 @@ def _closeouts(slot: Path, brief: dict, counters: dict, spawner, now: _dt.dateti out["merged"].append(pr) _mind_writer.queue_op(slot / _mind_writer.LEDGER_DIR, { "op": "table-append", "path": STAGE2_LOG, "heading": STAGE2_HEADING, - "row": stage2_row(now, co["task"], pr, slot.name, co["gate"], co["model"])}) + "row": stage2_row(now, co["task"], pr, slot.name, co["gate"], co["model"], + merged_by=(gh or {}).get("mergedBy") or "")}) events["merged"].append(pr) else: # Never retried: a close-out that ended without a verdict is the @@ -1045,14 +1046,23 @@ def _closeouts(slot: Path, brief: dict, counters: dict, spawner, now: _dt.dateti return events +#: The merge-actor class the watcher writes on every stage-2 row (AUTONOMY.md +#: "Merge actor and random audit — 2026-11-12"); the Mind's lifecycle.py holds +#: the full set. +STAGE2_ACTOR = "unattended-watcher" + + def stage2_row(now: _dt.datetime, task: str, pr: str, slot_name: str, gate: str, - model: str) -> str: + model: str, merged_by: str = "") -> str: """One row of autonomy_log.md's stage-2 table (its columns: date, task, brief, gate with the adversary leg, human action — `merged-unchanged` at - merge, amended by the human later).""" + merge, amended by the human later — merge actor, read by human). The actor + is always `unattended-watcher`, with GitHub's `mergedBy` as its evidence + when the watcher has it; `read by human` starts empty.""" + actor = STAGE2_ACTOR + (f" (mergedBy {merged_by})" if merged_by else "") cells = (now.strftime("%Y-%m-%d"), f"{task} ({pr})", slot_name, f"{gate} / adversary: independent close-out session ({model})", - "merged-unchanged") + "merged-unchanged", actor, "") return "| " + " | ".join(" ".join(str(c).replace("|", "/").split()) for c in cells) + " |" diff --git a/skills/prm/closeout.md b/skills/prm/closeout.md index 311e3f7c..052f3d0e 100644 --- a/skills/prm/closeout.md +++ b/skills/prm/closeout.md @@ -30,7 +30,7 @@ in step 6. Order is forced by the tooling, so do not reorder: ```bash python3 scripts/lifecycle.py close --date \ --from-file --pr [--tier glance --gate "" \ - --action --stage <1|2>] # dry run: prints every step + --action --stage <1|2> --actor ] # dry run: every step python3 scripts/lifecycle.py close … --apply # then does them ``` @@ -98,8 +98,12 @@ in step 6. Order is forced by the tooling, so do not reorder: `not-merged` is what gets recorded when `/prm` stopped on a guard (step 6) and never reached the merge — never a guess at what would have happened. 5. **Append** — the `--tier glance --gate "" --action - --stage <1|2>` flags on the `close` verb above do it (`shadow-row` is - the verb underneath). The dry run prints the row and the new count line + --stage <1|2> --actor ` flags on the `close` verb above do it + (`shadow-row` is the verb underneath). `--actor` is `human-/prm` if the + human typed `/prm`, `in-turn-human-commanded` if they told you to + merge, `in-turn-autonomous` for a tiered merge; the tool adds + `mergedBy`, and the first two are left out of the count + (reference.md). The dry run prints the row and the new count line before anything is written; the row rides the same commit and push as the record and the dashboard, never a commit of its own. 6. **Name it in the ledger** (sub-step 7): "shadow row appended, count diff --git a/skills/prm/reference.md b/skills/prm/reference.md index cd04e4ac..e3b088dc 100644 --- a/skills/prm/reference.md +++ b/skills/prm/reference.md @@ -151,7 +151,7 @@ clean, and the window re-scoped to `glance` auto-merges, counted to **20** clean rows (`AUTONOMY.md` "Merge authority follows Consequence — 2026-10-02"). ``` -| date | task | tier | gate (tests/smoke/review/heart/witness[/adversary]) | human action | stage | +| date | task | tier | gate (tests/smoke/review/heart/witness[/adversary]) | human action | stage | merge actor | read by human | ``` | cell | where it comes from | @@ -162,16 +162,20 @@ clean rows (`AUTONOMY.md` "Merge authority follows Consequence — 2026-10-02"). | `gate` | copied verbatim from the task's ship calibration row (written at PR-open by `ship_library` / `ship_workspace`); absent → the legs from the `/prm` step-2 judgement, same form | | `human action` | `merged-unchanged` / `merged-after-substantive-change` / `not-merged` / `reverted` — nothing else; an auto-merge records `merged-unchanged` at merge and the human amends it | | `stage` | `2` if an independent-model adversary leg ran, else `1`; never pooled | +| `merge actor` | `--actor`: `human-/prm` (the human typed `/prm`), `in-turn-human-commanded` (merged in-turn on the human's explicit command), `in-turn-autonomous` (a tiered merge the session made itself), `unattended-watcher` (the watcher writes it), else `unknown`; the tool adds `(mergedBy )` from `gh pr view`. The count leaves out the first two (`AUTONOMY.md` "Merge actor and random audit — 2026-11-12") | +| `read by human` | the date the human read the post-merge summary (`--read-by-human`), empty until then; recorded, does not gate the count | `not-merged` is for a close-out that stopped on a guard before the question was asked, never a guess at the answer. **Append only after every branch reads `MERGED`** (close-out sub-step 1): the row's subject is what the human did with the PR, so before the merge there is nothing to record. -`python3 scripts/lifecycle.py shadow-row … --apply` writes the row and rewrites -the section's `Count toward 20:` line from the table; without `--apply` it -prints both and writes nothing. The row rides the close-out's existing Mind -commit and push — never its own. +`python3 scripts/lifecycle.py shadow-row … --actor --apply` writes the +row and rewrites the section's `Count toward 20:` line from the table; without +`--apply` it prints both and writes nothing. The row rides the close-out's +existing Mind commit and push — never its own. Audits draw +`lifecycle.py audit-sample --seed ` (1 in 5, audited within a week), never +hand-picked rows; `lifecycle.py shadow-recount` prints the window by actor. **Substantive** is canonical in `autonomy_log.md`, which fixed it in advance — a change the human would have minded finding already merged: a changed default, diff --git a/tests/test_orchestrator_closeout.py b/tests/test_orchestrator_closeout.py index 8c9a8454..b208cf16 100644 --- a/tests/test_orchestrator_closeout.py +++ b/tests/test_orchestrator_closeout.py @@ -106,7 +106,7 @@ def test_a_merged_verdict_counts_and_queues_one_stage2_row(tmp_path): assert len(rows) == 1 and rows[0]["heading"] == orch.STAGE2_HEADING assert rows[0]["row"].startswith("| 2026-11-04 | named (" + PR1 + ") | shift |") assert "adversary: independent close-out session (claude-opus-5-5)" in rows[0]["row"] - assert rows[0]["row"].endswith("| merged-unchanged |") + assert rows[0]["row"].endswith("| merged-unchanged | unattended-watcher | |") d = _digest.build(_brief.parse(brief.read_text())["brief"], slot, c, health=t._health) assert "merged unattended (close-out, claude-opus-5-5)" in d assert "- glance-auto-merges: 1" in d and "- merges: 1" in d @@ -234,6 +234,8 @@ def test_a_github_merged_pr_with_no_closeout_file_counts_as_one_merge(tmp_path): rows = [o["row"] for o in ops if o["op"] == "table-append"] assert len(rows) == 1 and rows[0].startswith("| 2026-11-04 | named (" + PR1 + ") |") assert "merge confirmed on GitHub" in rows[0] and "(no .closeout)" in rows[0] + # the watcher writes the merge actor, with GitHub's mergedBy as evidence + assert rows[0].endswith("| unattended-watcher (mergedBy a-maintainer) | |") _gh_tick(brief, mind, home, sp, 3, _gh({PR1: "MERGED"})) assert orch.read_counters(slot)["glance_auto_merges"] == 1 # counted once @@ -384,8 +386,9 @@ def test_a_merged_closeout_lands_one_stage2_row_on_mind_main(tmp_path, monkeypat shutil.copy(t.LEDGER_MERGE, canon / "scripts" / "ledger_merge.py") (canon / "autonomy_log.md").write_text( "# Log\n\n## Shadow window\n\n| a |\n|---|\n\n" + orch.STAGE2_HEADING - + " — opened 2026-11-04\n\n| date | task | brief | gate | human action |\n" - "|---|---|---|---|---|\n\n## Later section\nkept\n") + + " — opened 2026-11-04\n\n| date | task | brief | gate | human action " + "| merge actor | read by human |\n" + "|---|---|---|---|---|---|---|\n\n## Later section\nkept\n") t.git(canon, "add", "-A") t.git(canon, "commit", "-q", "-m", "seed") t.git(canon, "push", "-q", "origin", "HEAD:main") @@ -404,4 +407,5 @@ def test_a_merged_closeout_lands_one_stage2_row_on_mind_main(tmp_path, monkeypat section = log[log.index(orch.STAGE2_HEADING):log.index("## Later section")] rows = [ln for ln in section.splitlines() if ln.startswith("| 2026-11-04 ")] assert len(rows) == 1 and "named (" + PR1 + ")" in rows[0] + assert rows[0].endswith("| merged-unchanged | unattended-watcher | |") assert log.rstrip().endswith("kept") From 8c4f973cebb256a9ddd8ad32525958930ea52649 Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Thu, 12 Nov 2026 18:43:58 +0000 Subject: [PATCH 2/2] docs: --actor is required on every glance shadow row (#606 review) Pairs with the Mind change that makes `close --tier glance` / `shadow-row` refuse without --actor. The prm close-out docs and AUTONOMY.md no longer show the flag as optional, and each says which class to pass: human-typed /prm -> human-/prm; in-turn merge on the human's explicit merge command -> in-turn-human-commanded; in-turn tiered merge with no human command -> in-turn-autonomous. Co-Authored-By: Claude Opus 5.5 --- AUTONOMY.md | 10 ++++++++-- skills/prm/closeout.md | 13 +++++++------ skills/prm/reference.md | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/AUTONOMY.md b/AUTONOMY.md index 4a790b5b..80f94b12 100644 --- a/AUTONOMY.md +++ b/AUTONOMY.md @@ -511,7 +511,8 @@ is the single `merge_pull_request` call, with the same rule. **The `glance` Shadow window.** Each auto-merged `glance` PR appends one row to `PyAutoMind/autonomy_log.md` "Shadow window" at close-out, recorded -`merged-unchanged` at merge (`lifecycle.py close … --tier glance`). The human +`merged-unchanged` at merge (`lifecycle.py close … --tier glance --actor +`, "Merge actor and random audit — 2026-11-12"). The human reads the post-merge summary and **amends the row** if they find something substantive (`merged-after-substantive-change`), or marks it `reverted`. `glance` is **confirmed at 20 clean rows**. **Any revert demotes that tier back @@ -628,7 +629,12 @@ stage-2 sub-window) end in `merge actor` and `read by human`. The class comes from the writer's explicit flag — `lifecycle.py close … --actor ` or `shadow-row --actor ` at `/prm` close-out, and `unattended-watcher` from the shift watcher — because how a merge started is known only to the session -that started it. `gh pr view --json mergedBy,mergedAt` adds the evidence, +that started it. The flag is **required** whenever a row is written — a +missing one refuses, so a forgotten flag can never land as a counted +`unknown`: a human-typed `/prm` → `human-/prm`; an in-turn merge on the +human's explicit merge command → `in-turn-human-commanded`; an in-turn tiered +merge with no human command → `in-turn-autonomous`; `unknown` only when passed +explicitly. `gh pr view --json mergedBy,mergedAt` adds the evidence, ` (mergedBy )`, never the class. Rows written before this edit stop at `stage` and read as `unknown`, which still counts; they are not rewritten. `lifecycle.py shadow-recount` prints the window by actor and the diff --git a/skills/prm/closeout.md b/skills/prm/closeout.md index 052f3d0e..ec7310e9 100644 --- a/skills/prm/closeout.md +++ b/skills/prm/closeout.md @@ -30,7 +30,7 @@ in step 6. Order is forced by the tooling, so do not reorder: ```bash python3 scripts/lifecycle.py close --date \ --from-file --pr [--tier glance --gate "" \ - --action --stage <1|2> --actor ] # dry run: every step + --action --stage <1|2> --actor ] # glance: all required python3 scripts/lifecycle.py close … --apply # then does them ``` @@ -99,11 +99,12 @@ in step 6. Order is forced by the tooling, so do not reorder: and never reached the merge — never a guess at what would have happened. 5. **Append** — the `--tier glance --gate "" --action --stage <1|2> --actor ` flags on the `close` verb above do it - (`shadow-row` is the verb underneath). `--actor` is `human-/prm` if the - human typed `/prm`, `in-turn-human-commanded` if they told you to - merge, `in-turn-autonomous` for a tiered merge; the tool adds - `mergedBy`, and the first two are left out of the count - (reference.md). The dry run prints the row and the new count line + (`shadow-row` is the verb underneath). `--actor` is required — a + missing one refuses: human-typed `/prm` → `human-/prm`; in-turn merge + on the human's explicit merge command → `in-turn-human-commanded`; + in-turn tiered merge with no human command → `in-turn-autonomous`. + The first two are left out of the count (reference.md); the tool adds + `mergedBy`. The dry run prints the row and the new count line before anything is written; the row rides the same commit and push as the record and the dashboard, never a commit of its own. 6. **Name it in the ledger** (sub-step 7): "shadow row appended, count diff --git a/skills/prm/reference.md b/skills/prm/reference.md index e3b088dc..f23ea6e3 100644 --- a/skills/prm/reference.md +++ b/skills/prm/reference.md @@ -162,7 +162,7 @@ clean rows (`AUTONOMY.md` "Merge authority follows Consequence — 2026-10-02"). | `gate` | copied verbatim from the task's ship calibration row (written at PR-open by `ship_library` / `ship_workspace`); absent → the legs from the `/prm` step-2 judgement, same form | | `human action` | `merged-unchanged` / `merged-after-substantive-change` / `not-merged` / `reverted` — nothing else; an auto-merge records `merged-unchanged` at merge and the human amends it | | `stage` | `2` if an independent-model adversary leg ran, else `1`; never pooled | -| `merge actor` | `--actor`: `human-/prm` (the human typed `/prm`), `in-turn-human-commanded` (merged in-turn on the human's explicit command), `in-turn-autonomous` (a tiered merge the session made itself), `unattended-watcher` (the watcher writes it), else `unknown`; the tool adds `(mergedBy )` from `gh pr view`. The count leaves out the first two (`AUTONOMY.md` "Merge actor and random audit — 2026-11-12") | +| `merge actor` | `--actor`, **required** (a missing one refuses, nothing written): `human-/prm` (a human-typed `/prm`), `in-turn-human-commanded` (an in-turn merge on the human's explicit merge command), `in-turn-autonomous` (an in-turn tiered merge with no human command), `unattended-watcher` (the watcher writes it), `unknown` only when passed explicitly; the tool adds `(mergedBy )` from `gh pr view`. The count leaves out the first two (`AUTONOMY.md` "Merge actor and random audit — 2026-11-12") | | `read by human` | the date the human read the post-merge summary (`--read-by-human`), empty until then; recorded, does not gate the count | `not-merged` is for a close-out that stopped on a guard before the question was