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
17 changes: 16 additions & 1 deletion AUTONOMY.md
Original file line number Diff line number Diff line change
Expand Up @@ -817,6 +817,18 @@ digest); `brief --new` with no goal epic or tag writes `backlog: scoped` with
tasks — refused when the prompt names the shift's own code (`_brief.SELF_PATHS`),
passed with a line when it names only other paths, a warning when it names none.

**Shift throughput — 2026-11-17 (M3.6c, PyAutoBrain#669), approved by the
human.** The first tick of a shift closes out the newest earlier slot's late
`glance`/`notify` PRs (never closed out, or refused only by the close-out
cutoff) under the new shift's grant; a PR refused for its tier, CI or `/drop`
stays the human's. A task an answer released is admitted whatever the brief's
backlog scope, and a task parked this shift restarts this shift when answered
with more than 30 minutes left. `first: glance` in a brief starts ready
`glance` work before named `judge` tasks (spawn order; the plan's selection is
unchanged), and a released or answered task counts as the human's pick. With no `max-sessions:` and a
`token-budget:`, the session cap is `max(2 × max-workers, ceil(token-budget /
150k))`; an explicit value wins.

**Launch preflight — 2026-11-17 (M3.6a, PyAutoBrain#659), approved by the
human.** A live brief (not `shadow: yes`) names its shift **`issue:`**: `batch
brief --new --out` creates it on PyAutoMind and writes it, and `batch brief
Expand Down Expand Up @@ -918,7 +930,10 @@ the exemption it runs under is `PyAutoMind/policy/shift_watcher.md`).
and **one comment per shift** on the brief's `issue:` (the digest, phase 3d);
and, inside "One Mind writer per shift", the writer's own `git fetch` of
PyAutoMind `main` — at each commit, and once per shift before its first plan
(2026-11-14, PyAutoBrain#632).
(2026-11-14, PyAutoBrain#632); and again, at most every 10 minutes, only
while a task of the shift is parked on a question and more than 30 minutes
remain before `review-at:`, so an answer given from the phone can restart it
in-shift (human-approved 2026-11-17, M3.6c, PyAutoBrain#669).
It starts worker sessions (`claude --bg`, phase 3b) — that is dispatch, ruled
by "Shift briefs and unattended `glance`", not a network read.
- **Opt-in and laptop-only.** It runs only from a systemd user timer the human
Expand Down
18 changes: 16 additions & 2 deletions agents/conductors/batch/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,10 @@ pin that and record every process a full brief run starts.
`bin/orchestrator_watch.py --mind <PyAutoMind>` finds the brief and runs **one
tick** of it (finding it is below, "Which brief"); `STOP` first, then the open-brief gate, the tick lock, the lease reap,
the plan inside the brief, the caps (`max-workers:`, default 4;
`max-sessions:`, default 8) and an exclusive-create lease per spawn. The plan
`max-sessions:`, default `max(2 × max-workers, ceil(token-budget / 150k))` when the
brief has a `token-budget:`, else 8 — M3.6c) and an exclusive-create lease per
spawn; `first: glance` starts ready glance work before named judge tasks (spawn
order only: what the plan selects is unchanged). The plan
is checked against Mind `origin/main` (#632): a draft not under its `draft/` or
claimed in its `active.md` is excluded unless this shift picked it, read from the
local `origin/main` ref after one `git fetch` per shift through the one Mind
Expand Down Expand Up @@ -528,6 +531,16 @@ watcher's own: one `claude agents --json` per refresh, only on a live shift
holding real worker leases, and `gh pr checks` for unmerged PRs, cached for the
interval.

**Carry-over and in-shift restart (M3.6c, PyAutoBrain#669).** A shift's first
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
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.
A task an answer released is admitted whatever the brief's backlog scope.

**Late arrivals (PyAutoBrain#594).** A worker may finish after `review-at:`,
once the digest is posted. A closed shift with a lease still held, a close-out
still running or a ledger op still queued runs `late_sweep` on each tick: it
Expand All @@ -538,7 +551,8 @@ commits the queued ops through the one Mind writer, and appends one
under `### Late arrivals`, amends the pilot line in place (`amended: true`) and
posts **one** correction comment for the shift (#610). It never spawns,
re-dispatches or starts a close-out, because the grant ended at `review-at:` and
what arrives late waits for `/prm`. It also runs while a failed digest or
what arrives late waits for `/prm` — or for the next shift's first tick, which
carries a late `glance`/`notify` PR over (M3.6c). It also runs while a failed digest or
correction post is due its retry.

**A blocked worker reaches the human (PyAutoBrain#611).** The human's channel
Expand Down
3 changes: 2 additions & 1 deletion agents/conductors/batch/_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,8 @@ def plan(records: list[dict], *, budget: int = DEFAULT_REVIEW_BUDGET,
for r in records:
# A brief's named task is the human's own pick, not a backlog dip:
# neither M2.3 gate below applies to it (the brief's `lanes:` still does).
backlog = Path(r["path"]).name not in named_names
# A task an answer released is the human's word too (M3.6c): no dip gate.
backlog = Path(r["path"]).name not in named_names and not r.get("resume")
why = pool_gate(r, next_phase)
if why:
rejected.append((r["path"], why))
Expand Down
39 changes: 36 additions & 3 deletions agents/conductors/batch/_brief.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
WORKER_MODES = ("auto", "dontAsk", "acceptEdits")
DEFAULT_WORKER_MODE = "auto"
SCOPED_KEYS = ("epics", "tags", "tiers")
#: `first:` values (M3.6c): `glance` sorts ready glance work first.
FIRST_VALUES = ("glance",)
#: The organs a shift runs on: its watcher and planner (Brain), its one Mind
#: writer (Mind) and its release path (Hands). A shift never changes them, so
#: the planner never dips a draft that targets one (PyAutoBrain#637, item 7).
Expand Down Expand Up @@ -142,10 +144,35 @@ def excluded_of(brief: dict) -> tuple[set[str], dict[str, list[str]]]:
return paths, keyed


#: Tokens one worker session is assumed to need at least, for a session cap
#: derived from the budget (M3.6c, human 2026-11-17): the cap is
#: `max(2 × max-workers, ceil(token-budget / SESSION_TOKEN_FLOOR))`, so the
#: token budget binds before the session count does.
SESSION_TOKEN_FLOOR = 150_000


def cap_of(brief: dict, key: str) -> int:
"""A usage cap from the brief, or its default when the brief omits it."""
"""A usage cap from the brief, or its default when the brief omits it.
With no `max-sessions:`, a brief with a `token-budget:` gets a cap derived
from it and `max-workers:` (M3.6c) — the fixed 8 stopped all new starts in
shift 2026-11-16-pm with 2.3M of 5M tokens unspent."""
value = _nonneg_int(brief.get(key, {}).get("value", ""))
return CAP_DEFAULTS[key] if value is None else value
if value is not None:
return value
if key == "max-sessions":
budget = _nonneg_int(brief.get("token-budget", {}).get("value", ""))
if budget:
return max(2 * cap_of(brief, "max-workers"), -(-budget // SESSION_TOKEN_FLOOR))
return CAP_DEFAULTS[key]


def cap_source(brief: dict, key: str) -> str:
"""Where `cap_of` took a cap from: `brief`, `from token-budget` or `default`."""
if _nonneg_int(brief.get(key, {}).get("value", "")) is not None:
return "brief"
if key == "max-sessions" and _nonneg_int(brief.get("token-budget", {}).get("value", "")):
return "from token-budget"
return "default"


#: The caps a `/cap` steering command may lower for one shift (#644).
Expand Down Expand Up @@ -334,6 +361,10 @@ def check(path: Path, mind: Path) -> dict:
+ ", ".join(WORKER_MODES)
+ (" (bypassPermissions is never a worker mode)"
if brief["worker-mode"]["value"] == "bypassPermissions" else ""))
# `first: glance` (M3.6c): ready glance work starts before named judge tasks.
if "first" in brief and brief["first"]["value"] not in FIRST_VALUES:
errors.append(f"brief.first: {brief['first']['value'] or 'empty'} — only "
+ " | ".join(FIRST_VALUES) + " (or leave the line out)")
for key in ("sandbox", "shadow"):
if key in brief and brief[key]["value"].lower() not in ("yes", "no"):
errors.append(f"brief.{key}: {brief[key]['value']} — yes or no")
Expand Down Expand Up @@ -601,7 +632,9 @@ def scope(records: list[dict], brief: dict) -> tuple[list[dict], list[tuple[str,
or themes & set(ex_keyed.get("tags", []))):
rejected.append((r["path"], "excluded by the brief"))
continue
if name not in named_names:
# A task an answer released (the inbox, M3.5) is the human's word, as
# naming it would be (M3.6c): no dip policy keeps it out.
if name not in named_names and not r.get("resume"):
if backlog == "none":
rejected.append((r["path"], "outside the brief (backlog: none)"))
continue
Expand Down
11 changes: 11 additions & 0 deletions agents/conductors/batch/_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,17 @@ def names(paths):
"their old standing — " + "; ".join(
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 ""))
again = counters.get("inshift_released") or {}
if again:
out.append(f"Restarted in-shift after an answer: {len(again)} task(s) — "
+ "; ".join(f"`{t}` ({', '.join(i for r in rs for i in r.get('ids') or [])})"
for t, rs in sorted(again.items())[:SUMMARY_NAMES]))
bare = gates.get("witness_absent") or []
if bare:
out.append(f"No Witness: {len(bare)} draft(s) not dipped — a shift dips only "
Expand Down
Loading
Loading