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 .claude/commands/questions.md
1 change: 1 addition & 0 deletions .claude/skills/questions
1 change: 1 addition & 0 deletions .codex/skills/questions
23 changes: 22 additions & 1 deletion AUTONOMY.md
Original file line number Diff line number Diff line change
Expand Up @@ -991,7 +991,7 @@ refuses the merge. A PR in any other repo makes no call at all. The revert
condition covers these the same way: any other call, or a repeat for the same
close-out, retires the watcher to fake mode.

**Amendment — 2026-11-16 (M3.4/M3.5; PyAutoBrain#644), approved by the human.**
**Amendment — 2026-11-16 (M3.4/M3.5; PyAutoBrain#644, #645), approved by the human.**
The shift cockpit's engine (DESIGN `m3_4_m3_5_design`, rulings H4b, H5a, H6a,
H8a/a, H10a). The watcher's surface gains, and only:

Expand Down Expand Up @@ -1022,6 +1022,27 @@ human named in `/kill`, a needs-you comment beyond 5 + 1 in a shift or one with
an `@`, and any network call from writing or reading `events.jsonl`: any of
these retires the watcher to fake mode.

The questions inbox (M3.5, PyAutoBrain#645) changes the watcher's surface by:

4. **Questions no longer @-mention the human.** A worker that parks with a
question, or is blocked on a person past the stall grace, gets no mention
comment. Its question lands in PyAutoMind `questions.md` through the one
Mind writer (a `question-add` op, no new network act), and the human's one
notice is a line in the digest at `review-at:` (Decision H7 a: "N
questions added to your inbox", with the dashboard link). The watcher's
comment count goes down; the status comment shows the count as an edit,
which notifies nobody.
5. **Reading `questions.md` from Mind `origin/main`** is a local `git show`
after the shift's existing once-per-shift fetch, never a pull or a second
fetch. An answered question releases its task's parked hold; the next
shift resumes it at its old standing (Decision H11 a), reusing a shift
worker's claim with the answer in its prompt. A dropped question shelves
the task (H9 a). An unreadable inbox keeps every hold.

The revert condition also covers these: an @mention for a parked question,
or any read of `questions.md` other than that local one, retires the watcher
to fake mode.

## Human override for Heart RED (development only)

Heart RED still parks every autonomous run and blocks every release. After the
Expand Down
24 changes: 24 additions & 0 deletions agents/conductors/batch/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,30 @@ trigger is durable state (a parked task or an un-verdicted issue in a `.done` wi
marker yet), so a tick that dies between parking and posting mentions on the
next; a failed mention is also retried by the late sweep.

**The questions inbox replaces those two mentions (M3.5, PyAutoBrain#645).**
A parked worker or a `.done` issue not marked `verdict:` no longer
@-mentions anyone (`_mention_triggers` returns neither; the machinery above
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
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
status comment a `- inbox:` count. Before planning, `_questions.read_origin`
reads `questions.md` from Mind origin/main (after the one fetch) and
`parked_elsewhere(slot, inbox, resumes)` rules on each earlier park: all its
entries answered → released and resumed at its old standing; one dropped →
shelved; one open or deferred → `waiting on Q<n> in your inbox`; none, or an
unreadable inbox → held as before. A released task a shift worker already
claimed (`- session: shift worker …`) is graded from `active/<task>.md` on
origin (`resume_records`), kept by `on_origin(…, resumes=)` (its own claim
does not hold its repos) and spawned with `RESUME_NOTE`; its pick's `why:`
starts `resumed after Q<n> was answered`. The human answers in a `/questions`
chat (`skills/questions`). `batch questions --backfill` prints the
`questions_edit.py add` lines that seed the inbox from today's holds.

**Watching and steering a shift from its issue (PyAutoBrain#622).** Each open
tick ends with the shift's **status comment** on the brief's `issue:`: the
`batch watch` snapshot as Markdown (`_watch.render_status`, no tick log),
Expand Down
22 changes: 21 additions & 1 deletion agents/conductors/batch/_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2927,7 +2927,7 @@ 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",
"slice", "premise", "green"], nargs="?",
"slice", "premise", "green", "questions"], nargs="?",
default="plan")
ap.add_argument("prompt", nargs="?", default="",
help="slice: the needs-slicing prompt to decompose; "
Expand Down Expand Up @@ -2984,6 +2984,11 @@ def main(argv=None) -> int:
ap.add_argument("--home", type=Path, default=None,
help="digest / watch: the watcher's state directory "
"(default: $PYAUTO_ORCHESTRATOR_HOME, else .orchestrator)")
# questions (M3.5, PyAutoBrain#645)
ap.add_argument("--backfill", action="store_true",
help="questions: print `questions_edit.py add` lines for every "
"task an earlier shift left parked and still held (reads "
"the watcher's slots and Mind origin/main; writes nothing)")
# watch
ap.add_argument("--once", action="store_true",
help="watch: print one snapshot and exit")
Expand Down Expand Up @@ -3062,12 +3067,27 @@ def main(argv=None) -> int:
return _main_watch(a)
if a.verb == "green":
return _main_green(mind, a)
if a.verb == "questions":
return _main_questions(mind, a)
return _main_plan(mind, a, lane)
except BatchUsageError as e:
print(e, file=sys.stderr)
return RC_USAGE


def _main_questions(mind: Path, a) -> int:
"""`batch questions --backfill` (M3.5, PyAutoBrain#645, Build B step 1):
the one-off seed of the inbox from the holds the watcher keeps today."""
if not a.backfill:
raise BatchUsageError("batch questions: only --backfill is a verb here; the inbox "
"is answered in a /questions chat")
import _orchestrator # noqa: E402
import _questions # noqa: E402
home = a.home or _orchestrator.orchestrator_home()
print("\n".join(_questions.backfill(home, mind)))
return 0


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`)."""
Expand Down
27 changes: 25 additions & 2 deletions agents/conductors/batch/_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
from pathlib import Path

import _brief # noqa: E402
import _questions # noqa: E402 — the inbox line (M3.5, #645)

# The one CI judgement (PyAutoBrain#628) lives in bin/, beside its CLI.
sys.path.insert(0, str(Path(__file__).resolve().parents[3] / "bin"))
Expand Down Expand Up @@ -539,7 +540,13 @@ def build(brief: dict, slot: Path, counters: dict, *, tiers: dict | None = None,
named = [Path(p).stem for p in _brief.tasks_of(brief)]
backlog = [t for t in picks if t not in named]

lines = [DIGEST_HEADING, "", "### Brief work"]
lines = [DIGEST_HEADING, ""]
# The one notice of the shift's parked questions (M3.5, #645, Decision
# H7 a): no @mention mid-shift, one line here; the asks live in the inbox.
inbox = [x for x in [_questions.inbox_line(counters, Path(slot).name, mind)]
+ _questions.unfiled_lines(counters) if x]
lines += inbox + [""] if inbox else []
lines += ["### Brief work"]
links = MindLinks(mind, issue)
# A worker still out at review-at keeps its lease (#634, N1).
held = {t: l for t, l in held_leases(slot).items() if l.get("state") != "parked"}
Expand Down Expand Up @@ -614,6 +621,10 @@ def identity_lines(counters: dict) -> list[str]:
f"{auth.get('last', '?')}: {auth['error']}"]


#: A question id in a hold's reason (`waiting on Q17 in your inbox`).
_QID_RE = re.compile(r"\bQ\d+\b")


def backlog_gate_lines(counters: dict) -> list[str]:
"""What the M2.3 gates kept out of the backlog dip (AUTONOMY.md "M2
rulings — 2026-11-12"), as of the watcher's last tick. Not bullets: a
Expand Down Expand Up @@ -645,9 +656,21 @@ def names(paths):
for p, w in sorted(repo_held.items())[:SUMMARY_NAMES]))
parked = gates.get("parked") or {}
if parked:
# The inbox's word on each, by Q-id (M3.5, #645), so "why wasn't X
# picked" answers itself; a park from before the inbox names none.
inboxed = {p: w for p, w in parked.items() if _QID_RE.search(w)}
out.append(f"Parked on a question by an earlier shift: {len(parked)} draft(s) not "
"startable until answered (name one in a brief to start it again): "
+ names(sorted(parked)))
+ ", ".join(f"`{Path(p).stem}`" + (f" ({inboxed[p]})" if p in inboxed else "")
for p in sorted(parked)[:SUMMARY_NAMES])
+ (f" +{len(parked) - SUMMARY_NAMES} more" if len(parked) > SUMMARY_NAMES
else ""))
resumed = gates.get("resumed") or {}
if resumed:
out.append(f"Released by an answer in your inbox: {len(resumed)} task(s) back at "
"their old standing — " + "; ".join(
f"`{t}` ({', '.join(v.get('ids') or [])} answered)"
for t, v in sorted(resumed.items())[:SUMMARY_NAMES]))
reach = gates.get("scoped_reach") or []
if reach:
out.append(f"Backlog reach (ruling 2026-11-16): {len(reach)} unqueued draft(s) not "
Expand Down
24 changes: 21 additions & 3 deletions agents/conductors/batch/_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,13 @@ def count(self, prefix: str) -> int:
return sum(1 for k in self.keys if (k or "").startswith(prefix))


def _inboxed(counters: dict, task: str, issue: str | None = None) -> bool:
"""Whether this tick's reap filed `task`'s question (on `issue`) in the
questions inbox (M3.5, PyAutoBrain#645: `counters["inbox"]`)."""
return any(q.get("task") == task and (issue is None or q.get("issue") == issue)
for q in counters.get("inbox") or [])


def _outcome(event: dict, counters: dict) -> dict:
"""A `done` reap's outcome: the event's own fields (#644 adds them), else
the task's outcome in `counters` (an old `tick.log` replay)."""
Expand Down Expand Up @@ -198,8 +205,11 @@ def _reaped(b: _Batch, result: dict, counters: dict) -> None:
task=task)
elif ev == "parked":
since = str(e.get("why") or "").replace("blocked since ", "")
filed = _inboxed(counters, task)
b.add("parked", f"parked:{task}:{run}",
f"{task} is stuck at a prompt (since {_hhmm(since)}).", task=task)
f"{task} is stuck at a prompt (since {_hhmm(since)})."
+ (" Added to your inbox." if filed else ""), task=task,
inbox=filed or None)
elif ev == "done":
o = _outcome(e, counters)
merged = list(o.get("merged") or [])
Expand All @@ -216,8 +226,13 @@ def _reaped(b: _Batch, result: dict, counters: dict) -> None:
f"{task} merged {ref(pr)} in-turn (notify).", task=task, pr=pr)
questions = [] if "obsolete" in o else list(o.get("questions") or [])
for q in questions:
# "Added to your inbox" only when the watcher filed it (#645):
# a merged task's question, or one it could not file, is not.
filed = _inboxed(counters, task, q)
b.add("question", f"question:{task}:{q}",
f"{task} parked with a question on {ref(q)}.", task=task, url=q)
f"{task} parked with a question on {ref(q)}."
+ (" Added to your inbox." if filed else ""), task=task, url=q,
inbox=filed or None)
if "obsolete" in o or o.get("verdicts") or not (o.get("prs") or questions):
if "obsolete" in o:
state = "obsolete (premise check)"
Expand Down Expand Up @@ -368,7 +383,10 @@ def _digest_event(b: _Batch, result: dict, counters: dict) -> None:
if isinstance(o, dict) and o.get("questions") and "obsolete" not in o
and not o.get("merged")]
parked += [t for t in counters.get("parked") or [] if t not in parked]
tail = (f" {len(parked)} task{'s' if len(parked) != 1 else ''} parked on a question."
filed = len(counters.get("inbox") or [])
tail = (f" {filed} question{'s' if filed != 1 else ''} added to your inbox."
if filed else
f" {len(parked)} task{'s' if len(parked) != 1 else ''} parked on a question."
if parked else "")
if post.get("url"):
b.add("digest", "digest", f"Shift closed. Digest: {post['url']}.{tail}", url=post["url"])
Expand Down
Loading
Loading