Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion AUTONOMY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
<class>`, "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
Expand Down Expand Up @@ -600,6 +601,60 @@ 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 <class>` or
`shadow-row --actor <class>` 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. 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,
`<class> (mergedBy <login>)`, 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 <n>` 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
Expand Down
18 changes: 14 additions & 4 deletions agents/conductors/batch/_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) + " |"


Expand Down
11 changes: 8 additions & 3 deletions skills/prm/closeout.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ in step 6. Order is forced by the tooling, so do not reorder:
```bash
python3 scripts/lifecycle.py close <slug> --date <merge date> \
--from-file <body.md> --pr <Repo#N …> [--tier glance --gate "<cell>" \
--action <action> --stage <1|2>] # dry run: prints every step
--action <action> --stage <1|2> --actor <class>] # glance: all required
python3 scripts/lifecycle.py close … --apply # then does them
```

Expand Down Expand Up @@ -98,8 +98,13 @@ 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 "<cell>" --action <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 <class>` flags on the `close` verb above do it
(`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
Expand Down
14 changes: 9 additions & 5 deletions skills/prm/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand All @@ -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`, **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 <login>)` 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 <class> --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 <n>` (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,
Expand Down
10 changes: 7 additions & 3 deletions tests/test_orchestrator_closeout.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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")
Expand All @@ -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")
Loading