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
48 changes: 47 additions & 1 deletion AUTONOMY.md
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ never an assumption:
5. **Independent adversary** — **added 2026-08-30, required for a BATCH
launch** (below) and for any run counting toward the multi-repo autonomy
experiment; optional elsewhere. A second reading of the same diff by a
**different model from the one that wrote it**, whose job is not to review
**different model from the one that wrote it** (since 2026-11-22 an
independent Opus session by default: "Adversary model default —
2026-11-22" below), whose job is not to review
the change but to **falsify its claims — the `Witness:` first**. Run it as
`pyauto-brain review --task <name> --witness "<the prompt's Witness:>"
--adversary`.
Expand Down Expand Up @@ -819,6 +821,45 @@ 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.

## Adversary model default — 2026-11-22

Amends leg 5 of "The autonomous-ship gate" and extends the "Stage-2 adversary
amendment — 2026-11-04" above from the unattended close-out to every
adversary and independent-review pass the orchestrator starts. Ruled by the
human 2026-11-22, in the review of shifts 2026-11-19-pm, -pm2 and
2026-11-20-am: "I dont think I want fable used by orchestrator as default as
fable eats more usage. Opus review default is fine". This section is that
dated doctrine edit.

**The default reader is Opus.** The independent review (leg 3) and the
adversary (leg 5) of shift work run on **Opus, in a fresh session or
sub-agent that did not write the branch** and shares none of the author's
context. That covers the worker's own review, the close-out session, and the
adversary pass a cockpit or review chat runs before the human's `/prm`. A
chat whose own model is Fable still starts the pass as an Opus sub-agent; it
does not read the diff adversarially itself.

**Fable only when asked.** A more expensive model reads a branch as the
adversary only when the human asks for it, for that pass. Nothing in a brief,
a skill or a record makes it the default.

**What keeps it the leg.** Independence of session, as in the 2026-11-04
amendment: the reader did not write the PR, runs the `Witness:` itself and
tries to falsify the claims. **A self-run adversary leg is still an absent
leg**: the author's own session re-reading its diff is not this pass,
whatever model it is on. `batch collect` reads it so: an adversary row whose
`model` equals its `author_model` passes only with `independent_session:
true`.

**What is given up** is what the 2026-11-04 amendment names: two runs of one
model share blind spots. Its revert condition stands for unattended merges and
is not widened here.

*Revert condition:* a defect that reaches `main` through a PR whose only
adversary was a same-model session, and that the human judges a different
model would have caught, reopens this default by dated doctrine edit citing
the PR.

## Merge actor and random audit — 2026-11-12

Amends "The `glance` Shadow-window ruling — 2026-11-04" above: it puts that
Expand Down Expand Up @@ -1351,6 +1392,8 @@ run id beyond its tries retires the watcher to fake mode.

**Login probe — 2026-11-17.** The watcher runs `claude auth status --json` (local, no model call) on a shift's first tick and when a worker shows as blocked. `loggedIn: false`, or a `loginExpiresAt` already passed, is a `login-expired` event, never "blocked on a person", and no worker starts until it passes.

**RAL probe — 2026-11-22.** `batch brief --check`, for a brief whose `lanes:` include `ral`, runs one `ssh -o BatchMode=yes -o ConnectTimeout=10 <host> true` in the launch chat (`agents/conductors/batch/_ral.py`). It never prompts, sends nothing but `true`, and a failure is a warning, never a refusal. The watcher never runs it. The host comes from `PYAUTO_RAL_SSH_HOST` or the Mind's `policy/hpc_ral.md`; `PYAUTO_RAL_PROBE=off` skips it. Asked for by the human 2026-11-22 after shift 2026-11-20-am granted a lane its worker could not reach.

## Human override for Heart RED (development only)

Heart RED still parks every autonomous run and blocks every release. After the
Expand Down Expand Up @@ -1644,6 +1687,9 @@ Codex hook list.
need the adversary leg.
- `batch` (the close-out session) — "Stage-2 adversary amendment" (2026-11-04):
the independent close-out session is the adversary leg, same model allowed.
- `batch`, `cockpit`, `review`, `MODEL_DELEGATION.md` — "Adversary model
default" (2026-11-22): every review and adversary pass the orchestrator
starts is an independent Opus session; Fable only when the human asks.
- `batch` (the watcher) — "The watcher's network surface" (2026-11-03): what
the watcher may reach, and that it is opt-in, laptop-only and never writes;
amended 2026-11-12 (mentions, #611) and 2026-11-13 (the live status comment
Expand Down
33 changes: 25 additions & 8 deletions agents/conductors/batch/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,14 @@ a re-run never makes a second; `--issue <url>` names one by hand;
`PYAUTO_BRIEF_ISSUE=off` skips it. The issue is made last, just before the
write: if `gh` fails, no brief is written (exit 1), and if the write fails
after it, the URL is printed to re-run with `--issue <url>`.

**The RAL probe (2026-11-22).** For a live brief whose `lanes:` include `ral`,
`brief --check` runs one `ssh -o BatchMode=yes <host> true` (`_ral.py`) and
warns when unattended key auth fails — shift 2026-11-20-am granted `ral` and
its worker parked on "Too many authentication failures". A warning, never a
refusal; launch chat only, never the watcher. The host is
`PYAUTO_RAL_SSH_HOST`, else the "SSH alias" in the Mind's
`policy/hpc_ral.md`; `PYAUTO_RAL_PROBE=off` skips it.
`brief --check` then adds what only a launch needs (`_brief.launch_errors`,
`login_findings`): a live brief (not `shadow: yes`) without a GitHub issue URL
is refused (`issue: missing — …`), and so is a CLI login that has expired
Expand Down Expand Up @@ -706,7 +714,10 @@ interval.
tick takes the newest earlier slot's late `glance`/`notify` PRs (never closed
out, or refused only for going green too near `review-at:`) into its own
close-out path under its own grant, and the digest names them ("Carried over
from …"). A task this shift parked on a question restarts this shift when the
from …"). A carried PR the human merged between the shifts is settled: no
close-out, no entry, no proof packet, one line ("… PR(s) you had already
merged — nothing to do"), and it drops out of the merge order with any earlier
PR GitHub reads MERGED or CLOSED (2026-11-22). A task this shift parked on a question restarts this shift when the
inbox answers it with more than 30 minutes left (once per answer; a release
waits for its spawn, else the park stays for the next shift); the writer's
fetch repeats for that only while such a park is open, at most every 10 minutes.
Expand Down Expand Up @@ -748,7 +759,8 @@ stays for other triggers). The reap queues one `question-add` op per issue
(`land_question`): the task's prompt, the issue, `kind: question` (or
`blocked`, filed on the shift issue), the ask and options from the worker's
`{task}.question.json` sidecar (sanitised; `see the question on the issue`
without one), the shift, the time and the worker. The one Mind writer lands
without one; it sits in `leases/` and is never read as a lease — until
2026-11-22 each one held a worker slot to `review-at:`), the shift, the time and the worker. The one Mind writer lands
it in PyAutoMind `questions.md` through Mind's own `questions_edit.add_text`.
The digest gets one line under its heading (`Inbox: N questions added to your
inbox this shift (Q17, Q18), M open in all — <dashboard #inbox>`), and the
Expand Down Expand Up @@ -1020,8 +1032,10 @@ adversary (`AUTONOMY.md` leg 5). Run it before reading a PR:
pyauto-brain review --task <name> --witness "<the prompt's Witness:>" --adversary
```

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
in a session **that did not write the branch — by default a fresh Opus
session or sub-agent, even when your own chat is on Fable**; a more expensive
model reads only when the human asks (`AUTONOMY.md` "Adversary model default —
2026-11-22"). 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. The shift worker does not
Expand Down Expand Up @@ -1059,10 +1073,13 @@ is unobservable and its member reaches the human as SUSPECT. Inventing PASS
would be inventing evidence and FAIL would condemn healthy work — the same
choice the Cortex conductor makes for the `delivered:` legs it cannot see.

`adversary` is the leg with a rule of its own: it passes only when the read ran
under a model that is not the branch's author. **A self-run adversary leg is an
absent leg, not a weak one** (`AUTONOMY.md` leg 5), so an equal or missing
`author_model` is FAIL, not PASS.
`adversary` is the leg with a rule of its own: it passes only when the read was
independent of the branch's author. **A self-run adversary leg is an absent
leg, not a weak one** (`AUTONOMY.md` leg 5), so a missing `model` or
`author_model` is FAIL, and so is an equal one unless the row carries
`"independent_session": true` — the default Opus reader of an Opus branch, in
a session that did not write it (`AUTONOMY.md` "Adversary model default —
2026-11-22").

### Six health words, in the order the human reads them

Expand Down
18 changes: 14 additions & 4 deletions agents/conductors/batch/_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import _brief # noqa: E402
import _green # noqa: E402 — the keep-Heart-green lane (PyAutoBrain#625)
import _login # noqa: E402 — the CLI login probe (M3.6a, PyAutoBrain#659)
import _ral # noqa: E402 — the unattended-ssh probe for a granted `ral` lane
# The human's goals (goals.md, PyAutoMind#565): `brief --new` copies them.
from _steer import read_goals # noqa: E402,F401 — re-exported beside read_queue
# The close-out guard's reader (intake `looks-shipped`): the live flags minus
Expand Down Expand Up @@ -1516,13 +1517,17 @@ def leg_adversary(ev) -> tuple:
if not isinstance(row, dict) or not row.get("ran"):
return UNOBSERVABLE, "no adversary leg recorded"
model, author = (row.get("model") or ""), (row.get("author_model") or "")
if not model or not author or model == author:
# AUTONOMY.md leg 5, verbatim in intent: the leg is a reading by a
# DIFFERENT model from the one that wrote the diff.
# AUTONOMY.md leg 5: the leg is a reading independent of the author. A
# different model is one; so is the same model in a session that did not
# write the branch ("Adversary model default — 2026-11-22": Opus reads
# Opus by default), which the row must say — it is never assumed.
independent = row.get("independent_session") is True
if not model or not author or (model == author and not independent):
return FAIL, ("a self-run adversary leg is an absent leg, not a weak "
"one (AUTONOMY.md leg 5)"
+ (f" — model {model}" if model else " — no model named"))
return PASS, f"{model} vs author {author}: {row.get('verdict') or 'read'}"
how = "independent session" if model == author else f"vs author {author}"
return PASS, f"{model} {how}: {row.get('verdict') or 'read'}"


#: Health, in the order the packet shows members in: what failed, what did not
Expand Down Expand Up @@ -3922,6 +3927,11 @@ def _main_brief(mind: Path, a) -> int:
res["login"] = login
res["errors"] += errs
res["warnings"] += warns
# A granted `ral` lane a worker cannot reach (2026-11-20-am): one
# BatchMode ssh, a warning only. A shadow brief starts no worker.
if rec["brief"] is not None and not _brief.is_shadow(rec["brief"]):
res["ral"], warns = _ral.findings(_brief.lanes_of(rec["brief"]), mind)
res["warnings"] += warns
res["ok"] = not res["errors"]
warn = goal_one_warning(Path(a.check), mind)
if warn:
Expand Down
70 changes: 61 additions & 9 deletions agents/conductors/batch/_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,17 @@ def _task_state(task: str, counters: dict, health, *, live: bool = False,
return f"{word} — awaiting re-dispatch", True
return f"{NOT_REDISPATCHED}: {redispatch_why(task, counters)}", False
skipped = gate_why(task, counters)
return ("not started — skipped: " + skipped if skipped else "not started"), False
if skipped:
return "not started — skipped: " + skipped, False
# Neither claimed nor rejected, yet never started: the spawn gate
# refused it (2026-11-20-am: a named task waited on `max-workers`
# all shift and its entry said only "not started").
last = max((r for r in counters.get("refusals", []) if r.get("task") == task),
key=lambda r: r.get("last") or r.get("at") or "", default=None)
if last:
return (f"not started — refused: {last.get('why') or last.get('class') or '?'} "
f"(last {last.get('last') or last.get('at') or '?'})"), False
return "not started", False
urls = urls_of(out)
if not urls and "obsolete" in out:
return ("obsolete (premise check): "
Expand Down Expand Up @@ -268,6 +278,8 @@ def _task_state(task: str, counters: dict, health, *, live: bool = False,
state = wait_state(url, counters) # merge order (M3.6j, #683)
elif url in (counters.get("sweep_waits") or {}):
state = sweep_wait_state(url, counters) # unknown sweep (M3.7e, #694)
elif co.get("settled"):
state = co.get("why") or SETTLED
elif co.get("state") == "refused":
state = f"awaiting /prm — close-out refused: {co.get('why', '?')}"
elif co.get("state") == "running":
Expand All @@ -283,6 +295,26 @@ def _task_state(task: str, counters: dict, health, *, live: bool = False,
return "; ".join(parts), True


#: A carried-over PR the human merged between shifts: nothing is left to do.
SETTLED = "already merged"


def settled_prs(counters: dict) -> set[str]:
"""The carried-over PRs GitHub read MERGED when this shift first looked."""
return {u for u, co in (counters.get("closeouts") or {}).items()
if isinstance(co, dict) and co.get("settled")}


def is_settled(task: str, counters: dict) -> bool:
"""Whether a carried-over task has nothing left for anyone: every PR it
carried was already merged by the human. Such a task is named once, in
the carry-over line, and has no entry and no proof packet (its packet is
in the digest of the shift that ran it)."""
out = (counters.get("outcomes") or {}).get(task) or {}
urls = urls_of(out)
return bool(out.get("carried_from") and urls) and set(urls) <= settled_prs(counters)


#: A PR's states in the merge order (M3.6j, PyAutoBrain#683).
UPDATING = "close-out updating the branch from main"
UPDATED = "branch updated from main"
Expand All @@ -302,6 +334,8 @@ def _order_word(url: str, counters: dict) -> str:
co = (counters.get("closeouts") or {}).get(url) or {}
if url in (counters.get("merge_waits") or {}):
return "itself waiting"
if co.get("settled"):
return SETTLED
if co.get("state") == "refused":
return f"needs your /prm: {refusal_class(co.get('why') or '?')}"
if co.get("state") == "running":
Expand Down Expand Up @@ -339,6 +373,9 @@ def merge_order_lines(counters: dict) -> list[str]:
return []
merged = {u for o in (counters.get("outcomes") or {}).values() if isinstance(o, dict)
for u in o.get("merged") or []}
# A PR GitHub read MERGED or CLOSED is no longer in the order: one the
# human merged between shifts, or an earlier PR a carried one waited on.
merged |= settled_prs(counters) | set(counters.get("pr_gone") or {})
known = list(dict.fromkeys(
u for o in (counters.get("outcomes") or {}).values() if isinstance(o, dict)
for u in [*(o.get("prs") or []), *(o.get("behind") or [])]))
Expand Down Expand Up @@ -395,7 +432,8 @@ def waited_lines(counters: dict) -> list[str]:
a count; and how many PRs were refused because their labels could not be
read (S7). Empty when there is neither."""
cos = counters.get("closeouts") or {}
refused = {u: co for u, co in cos.items() if co.get("state") == "refused"}
refused = {u: co for u, co in cos.items()
if co.get("state") == "refused" and not co.get("settled")}
groups: dict[tuple, list[str]] = {}
for url, info in (counters.get("merge_waits") or {}).items():
bound = [b for b in info.get("behind") or [] if b in refused]
Expand Down Expand Up @@ -620,6 +658,7 @@ def label(task: str, pick: dict | None, url: str = "") -> str:
_PLAIN = (
(IN_TURN_NO_SLOT, "Merged with NO merge slot — needs you"),
("merged", "Merged"),
(SETTLED, "Already merged — nothing to do"),
("awaiting /prm — close-out refused: CI FAILED", "CI failed — needs you"),
("awaiting /prm — close-out refused: CI RED", "CI failed — needs you"),
("awaiting /prm", "Needs you — not merged unattended"),
Expand Down Expand Up @@ -693,10 +732,14 @@ def held_leases(slot: Path) -> dict[str, dict]:
because this module must not import the orchestrator."""
out = {}
for f in sorted((Path(slot) / "leases").glob("*.json")):
if f.name.endswith(_questions.SIDECAR_SUFFIX):
continue # a parked worker's question sidecar, never a lease
try:
out[f.stem] = json.loads(f.read_text())
lease = json.loads(f.read_text())
except (OSError, ValueError):
continue
if isinstance(lease, dict):
out[f.stem] = lease
return out


Expand Down Expand Up @@ -735,7 +778,9 @@ def build(brief: dict, slot: Path, counters: dict, *, tiers: dict | None = None,
pass
picks = counters.get("picks", {})
named = [Path(p).stem for p in _brief.tasks_of(brief)]
backlog = [t for t in picks if t not in named]
# A carried-over task the human already merged is named once, in the
# carry-over line, never as an entry or an empty proof packet.
backlog = [t for t in picks if t not in named and not is_settled(t, counters)]

lines = [DIGEST_HEADING, ""]
lines += closed_early_lines(counters)
Expand Down Expand Up @@ -957,11 +1002,18 @@ def names(paths):
f"`{t}` ({', '.join(v.get('ids') or [])} answered)"
for t, v in sorted(resumed.items())[:SUMMARY_NAMES]))
carried = counters.get("carried_in") or {}
if carried.get("prs"):
out.append(f"Carried over from {carried['from']}: {len(carried['prs'])} late PR(s) "
"closed out under this shift's grant — " + ", ".join(carried["prs"][:SUMMARY_NAMES])
+ (f" +{len(carried['prs']) - SUMMARY_NAMES} more"
if len(carried["prs"]) > SUMMARY_NAMES else ""))
done = [u for u in carried.get("prs") or [] if u in settled_prs(counters)]
left = [u for u in carried.get("prs") or [] if u not in done]

def names(urls):
return ", ".join(urls[:SUMMARY_NAMES]) + (
f" +{len(urls) - SUMMARY_NAMES} more" if len(urls) > SUMMARY_NAMES else "")
if left:
out.append(f"Carried over from {carried['from']}: {len(left)} late PR(s) "
"closed out under this shift's grant — " + names(left))
if done:
out.append(f"Carried over from {carried['from']}: {len(done)} PR(s) you had already "
"merged — nothing to do — " + names(done))
again = counters.get("inshift_released") or {}
if again:
out.append(f"Restarted in-shift after an answer: {len(again)} task(s) — "
Expand Down
Loading
Loading