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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ invoking it; `bin/pyauto-brain help <verb>` exposes its full contract.
| `bug` | Classify regressions and plan repairs | `bin/pyauto-brain bug` |
| `refactor` | Plan behavior-preserving restructuring | `bin/pyauto-brain refactor` |
| `workspace` | Plan or survey examples and tutorials | `bin/pyauto-brain workspace` |
| `docs` | Plan README, setup and Read the Docs pages; audit a page's style | `bin/pyauto-brain docs` |
| `eyes` | Survey figures and route accepted critiques | `bin/pyauto-brain eyes` |
| `profiling` | Plan campaigns; ingest results; triage profiling drift | `bin/pyauto-brain profiling` |
| `cortex` | Pull science runs and record human checkins | `bin/pyauto-brain cortex` |
Expand Down
56 changes: 49 additions & 7 deletions agents/conductors/batch/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ consulting a conductor. If a rule here starts needing to *judge* rather than
| **Review-minute budget** | the human's hour is the binding resource; see above |
| **One member per *library* repo per shift** | concurrent members do not collide at dispatch (separate worktrees) — they collide at **merge**, because the first `/prm` moves `main` and invalidates the others' test and smoke evidence. Workspace, docs and organ repos are exempt: two docs changes in one shift cost nothing. Work concentrates in four repos (PyAutoFit 118/332 August records, PyAutoArray 98, PyAutoGalaxy 82, PyAutoLens 78), so effective parallelism is two or three, not six. |
| **One slice per epic per batch** | epic phases are ordered, so two members could not run in parallel anyway — and this is what interleaves small pieces of long programmes with standalone work |
| **`Unattended: ready` only** | `needs-slicing` goes to the decomposition pass; `never` never enters a batch |
| **`Unattended: ready` only** | `needs-slicing` goes to the decomposition pass (`batch slice`); `never` never enters a batch |
| **Lane match** | a session detects its own lane and plans only that one |
| **Not `looks-shipped`** | a draft the close-out guard (`intake looks-shipped`) flagged with strong evidence that its work already shipped waits until a human closes it or lists it in `PyAutoMind/looks_shipped_dismissed.md`; the flags are read from `PyAutoMind/looks_shipped.json` at plan time, so a dismissal takes effect at once. The 2026-11-05-am batch proposed two shipped drafts. |
| **Backpressure** | see below |
| **Brief scope** | under a shift brief, only its named tasks and the backlog its dip policy covers run; anything else is a dispatch outside the launch, which "What a batch launch is" forbids (`AUTONOMY.md`, 2026-11-03) |
| **Merge cap** | unattended `glance` merges stop at the brief's `merge-cap:`; each merge moves `main` and stales the next member's evidence, and the cap bounds what one unread shift can change |
Expand Down Expand Up @@ -734,10 +735,51 @@ The extension point above (`KINDS`) is what made that possible and is kept: a
member kind is a scorer plus a block builder plus a claim, and nothing about
the record, the packet or the renderer has to learn its vocabulary.

## Not built yet
## Slicing a `needs-slicing` prompt (`slice`)

`slice` — the decomposition pass doctrine has named since inception — is the
conductor's one remaining verb; see the epic ledger,
`PyAutoMind/draft/feature/pyautomind/two_slot_batching_epic.md`. `plan` and
`collect` stand on their own in the meantime: plan a slot, dispatch by tapping
the dashboard's existing chips, collect what comes back.
```
pyauto-brain batch slice <prompt> # propose; writes nothing
pyauto-brain batch slice <prompt> --slices plan.md # cut from a plan file
pyauto-brain batch slice <prompt> --apply [--mind P] # write children + epics.md
```

A prompt too large for one unattended run is a decomposition problem, not a
scheduling one. `slice` proposes **two to four** children of a prompt grading
`Unattended: needs-slicing`, offline and stdlib-only.

**The cut is declared, never invented.** Where work divides is a semantic
judgement no stdlib heuristic makes honestly, so the candidate slices come from
the parent's own `## Slices` (or `## Phases`) section, or from an
agent-authored plan file passed with `--slices` (the same numbered items; the
heading optional). One numbered item per slice:

```
1. **Library core.** What it does. *Repos:* PyAutoFit
*Witness:* `pytest test_autofit/thing` passes. *Consequence:* glance.
2. **Workspace example.** ... *Witness:* the example runs in smoke. *Depends:* 1
```

`*Witness:*` is required; `*Repos:*`, `*Consequence:*`, `*Difficulty:*`,
`*Lane:*`, `*Review-minutes:*` and `*Depends:*` are optional (repos default to
the parent's repos the item names). The verb renders each child — the parent's
`Type`/`Autonomy`/`Priority`/`Themes`, `Epic:` + `Phase:`, and a `## Seam`
section naming what it owns and what comes before and after — and the sizing
faculty (`judge_slices`) judges it against the seam rules:

1. **one unattended run** — the child must grade `Unattended: ready`;
2. **its own witness** — none is refused as *a smaller judge task, not a
slice*;
3. **independently revertible** — it names a repo, and depends on no later
slice;
4. **repo-boundary seams, library before workspace** — warnings, not refusals.

Fewer than two or more than four slices is refused. Revertibility beyond rule 3
is the human's to read off the proposal.

Without `--apply` it only prints (`--json` too). `--apply` writes only a clean
proposal: the children beside the parent as `<parent>_s<N>_<title>.md`, never
overwriting, plus an `epics.md` entry with the parent as its **ledger** unless
the parent already is one. The parent is never renamed, retired or edited —
that is the human's call. `/intake` offers the verb when a freshly filed prompt
sizes `needs-slicing`. Exit: **0** proposed · **1** refused · **2** usage ·
**4** no Mind.
66 changes: 64 additions & 2 deletions agents/conductors/batch/_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@
sys.path.insert(0, str(Path(__file__).resolve().parent))
from _status import PENDING_RE, RULING_WORDS, freeze_line # noqa: E402
import _brief # noqa: E402
# The close-out guard's reader (intake `looks-shipped`): the live flags minus
# human dismissals. Loaded by path — a plain `import _shipped` would also work
# once intake's directory is on sys.path, but this keeps the batch planner from
# shadowing anything else of that name.
_shipped_spec = importlib.util.spec_from_file_location(
"_shipped_for_batch", BRAIN / "agents" / "conductors" / "intake" / "_shipped.py")
_shipped = importlib.util.module_from_spec(_shipped_spec)
_shipped_spec.loader.exec_module(_shipped)

# One slot's worth of the human's attention, and only the DEFAULT: the human
# sets it per slot with --budget, because they know whether the next one is a
Expand Down Expand Up @@ -159,11 +167,16 @@ def survey(mind: Path) -> list[dict]:
"""Grade every backlog prompt. Epic membership rides along for the
one-slice-per-epic rule."""
out = []
# Backpressure from the close-out guard: a draft with strong evidence that
# its work already shipped waits for a human to close or dismiss it. The
# 2026-11-05-am batch proposed two shipped tasks; this is the stop.
flagged = _shipped.flagged_paths(mind)
for f in sorted(mind.glob("draft/**/*.md")):
if f.name == "README.md":
continue
text = f.read_text(encoding="utf-8", errors="replace")
g = grade(f, mind)
g["looks_shipped"] = f.relative_to(mind).as_posix() in flagged
g["epic"] = _epic_of(text)
g["phase"] = _phase_of(text)
g["done"] = _is_done(text)
Expand Down Expand Up @@ -317,6 +330,9 @@ def plan(records: list[dict], *, budget: int = DEFAULT_REVIEW_BUDGET,
# which is the failure the whole epic exists to remove.
if r.get("done"):
rejected.append((r["path"], "Status: says the work is already done"))
elif r.get("looks_shipped"):
rejected.append((r["path"], "looks shipped — confirm (close) or "
f"dismiss it ({_shipped.DISMISS_FILE}) first"))
elif r.get("epic") and r.get("phase", float("inf")) > next_phase.get(
r["epic"], float("inf")):
rejected.append((r["path"],
Expand Down Expand Up @@ -2787,8 +2803,10 @@ def organ_for(kind: str, root: Path, slot: str) -> dict:

def main(argv=None) -> int:
ap = argparse.ArgumentParser(prog="batch")
ap.add_argument("verb", choices=["plan", "collect", "brief", "digest", "watch"], nargs="?",
default="plan")
ap.add_argument("verb", choices=["plan", "collect", "brief", "digest", "watch",
"slice"], nargs="?", default="plan")
ap.add_argument("prompt", nargs="?", default="",
help="slice: the needs-slicing prompt to decompose")
ap.add_argument("--mind", type=Path, default=BODY_MAP_PATH.parent)
ap.add_argument("--budget", type=int, default=DEFAULT_REVIEW_BUDGET,
help="review-minutes available in the slot")
Expand All @@ -2805,6 +2823,11 @@ def main(argv=None) -> int:
ap.add_argument("--brief", default="", metavar="FILE",
help="plan: compose inside this shift brief (named tasks "
"first, then its backlog policy)")
# slice
ap.add_argument("--slices", default="", metavar="FILE",
help="slice: an agent-authored slice plan (numbered items "
"with *Witness:* fields) instead of the parent's own "
"`## Slices`/`## Phases` section")
# digest
ap.add_argument("--record", default="", metavar="FILE",
help="digest / watch: the shift brief record (read-only — "
Expand Down Expand Up @@ -2845,7 +2868,15 @@ def main(argv=None) -> int:

lane = a.lane or detect_lane()
mind = a.mind.resolve()
if a.prompt and a.verb != "slice":
print(f"batch {a.verb}: unexpected argument {a.prompt!r}", file=sys.stderr)
return RC_USAGE
if a.slices and a.verb != "slice":
print("batch: --slices belongs to `batch slice`", file=sys.stderr)
return RC_USAGE
try:
if a.verb == "slice":
return _main_slice(mind, a)
if a.verb == "collect":
return _main_collect(mind, a)
if a.verb == "brief":
Expand All @@ -2860,6 +2891,37 @@ def main(argv=None) -> int:
return RC_USAGE


def _main_slice(mind: Path, a) -> int:
"""`batch slice <prompt> [--slices FILE] [--apply] [--json]` — propose the
children of a needs-slicing prompt; only `--apply` writes (`_slice`)."""
import _slice
if not a.prompt:
print("batch slice: name the needs-slicing prompt to slice",
file=sys.stderr)
return RC_USAGE
used = [f"--{f}" for f in COLLECT_ONLY if f != "apply" and getattr(a, f)]
if used:
print(f"batch slice: {', '.join(used)} belong(s) to `batch collect`",
file=sys.stderr)
return RC_USAGE
if not (mind / "draft").is_dir():
print(f"batch: no PyAutoMind backlog at {mind}", file=sys.stderr)
return RC_NO_MIND
try:
d = _slice.propose(mind, a.prompt, slices_file=a.slices)
written = _slice.apply(mind, d) if a.apply and d["ok"] else []
except _slice.SliceError as e:
print(e, file=sys.stderr)
return RC_USAGE
if a.as_json:
print(json.dumps({**d, "written": written}, indent=2))
else:
print(_slice.report(d, applied=written))
if a.apply and not d["ok"]:
print("(--apply refused: the proposal has refusals)")
return RC_OK if d["ok"] else RC_FINDINGS


def _main_digest(mind: Path, a) -> int:
"""`batch digest --record <file>` — print the shift's digest; writes nothing.

Expand Down
Loading
Loading