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
27 changes: 24 additions & 3 deletions agents/conductors/batch/AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,14 @@ a failed launch is one `launch-failed` record per task) with its blocked minutes
**One Mind writer (phase 3c).** Workers never commit to PyAutoMind. Each Mind
change — the `active.md` claim, the `draft/ → active/` move, the close-out — is
queued as an op file in `<slot>/ledger/` by `bin/shift_ledger.py`
(`append | write | move | remove | drop-section`; every path must be *ledger*
by PyAutoMind's own `scripts/ledger_merge.py`, default deny). Each tick, after
(`--task <task>` then `append | write | edit | move | remove | drop-section |
table-append | set-header | queue-retire`; every path must be *ledger* by
PyAutoMind's own `scripts/ledger_merge.py`, default deny). `write` only
creates; `edit` replaces an expected old text that must appear exactly once,
so it never clobbers a concurrent change. `shift_ledger.py` refuses at queue
time a `write` to a path already on Mind `origin/main` (or created by a queued
op), an `edit` whose base is not there, and a `table-append` whose `## `
heading or table is missing, so the worker can switch while it runs. Each tick, after
the reap, `_mind_writer.commit_ledger` applies all pending ops in a temporary
detached worktree on `origin/main`, commits once and pushes; if `main` moved it
replays the ops on the new `origin/main` (up to three tries). It never resets,
Expand All @@ -336,7 +342,22 @@ Committed op files move to `ledger/committed/`. One bad op never strands the
rest (#632): a re-dispatched task's repeat of a claim this shift already
committed, with main's content matching it, is a skipped note; the same shape
from anyone else is a conflict, set aside; any other worker op that is invalid
or cannot apply is set aside in `ledger/set_aside/` — and the rest commit. The
or cannot apply is set aside in `ledger/set_aside/` — and the rest commit. A
task's ops land together (#660): its closing ops (the `complete/` record,
`drop-section`, the `active/` prompt's `remove`, `queue-retire`,
`question-retire`) apply last, and are *withheld* — set aside, not retried —
when any op of that task was set aside for a human this shift, so Mind never
records it shipped with a change missing. They apply as one group per task: if
one fails for a human the group is rolled back and withheld; while a sibling
op is *held* (retried) the group stays pending beside it; an op on a path the
group creates (an edit of the `complete/` record) is part of the group. Two
limits: a `complete/` record committed in an earlier tick than a sibling that
fails later stays on main (the NEEDS YOU line and the digest say "already on
main"), and the block is sticky for the shift — a re-dispatched task's record
is withheld too, for the rest of the shift. An op that is already true on main
(an edit already applied, a write of the same text, a remove of a gone file) is
set aside as *mechanical*: a digest line, never a NEEDS YOU; a task's human
set-asides are one NEEDS YOU event naming the task. The
watcher's own ops (record appends, pilot row, live line, stage-2 rows) are never
set aside: they are held pending and retried. Every note, set-aside, conflict
and hold goes to `ledger/report.jsonl`, into the digest, and after `review-at:`
Expand Down
15 changes: 12 additions & 3 deletions agents/conductors/batch/_digest.py
Original file line number Diff line number Diff line change
Expand Up @@ -585,15 +585,24 @@ def build(brief: dict, slot: Path, counters: dict, *, tiers: dict | None = None,
"set-aside": "warning: Mind ledger op set aside, not committed",
"conflict": "warning: CONFLICT — Mind ledger op set aside, not committed",
"held": "warning: Mind ledger op held pending, retried every tick",
"withheld": "warning: Mind ledger op withheld with its task, not committed",
# A set-aside whose `needs` is mechanical (#660): already true on main.
"mechanical": "note: Mind ledger op set aside (mechanical — already true on main, "
"no action)",
}


def report_line(e: dict) -> str:
"""One `ledger/report.jsonl` entry as a digest or late line."""
head = _REPORT_WORDS.get(e.get("kind"), f"warning: Mind ledger {e.get('kind')}")
kind = "mechanical" if (e.get("kind") == "set-aside"
and e.get("needs") == "mechanical") else e.get("kind")
head = _REPORT_WORDS.get(kind, f"warning: Mind ledger {e.get('kind')}")
where = f" (`ledger/set_aside/{e.get('file')}`)" if e.get("kind") in (
"set-aside", "conflict") else ""
return f"- {head} — {e.get('op') or '?'} {e.get('path') or '?'}: {e.get('why')}{where}"
"set-aside", "conflict", "withheld") else ""
note = (f" — `{e.get('task')}`'s complete record is already on main"
if e.get("record") == "on-main" else "")
return (f"- {head} — {e.get('op') or '?'} {e.get('path') or '?'}: {e.get('why')}"
f"{where}{note}")


def report_lines(slot: Path) -> list[str]:
Expand Down
35 changes: 28 additions & 7 deletions agents/conductors/batch/_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,34 @@ def _impaired(b: _Batch, result: dict) -> None:
why = str(ledger["error"])[:160]
b.add("impaired", f"impaired:ledger-error:{why[:80]}",
f"Mind write failed: {why}.", needs_you=True)
for word, items in (("set aside", ledger.get("set_aside")), ("held", ledger.get("held"))):
for x in items or []:
op = x.get("op") if isinstance(x, dict) else str(x)
why = (x.get("why") if isinstance(x, dict) else "") or "?"
where = x.get("file") if isinstance(x, dict) else ""
b.add("impaired", f"impaired:ledger:{word}:{where or op}:{str(why)[:60]}",
f"Mind write {word}: {op}, {why}.", needs_you=True)
# A mechanical set-aside (already true on main) is a digest line only;
# a worker's human set-asides are one NEEDS YOU per task (#660).
by_task: dict = {}
per_op = []
for x in ledger.get("set_aside") or []:
if isinstance(x, dict) and x.get("needs") == "mechanical":
continue
if isinstance(x, dict) and isinstance(x.get("task"), str) and x["task"]:
by_task.setdefault(x["task"], []).append(x)
else:
per_op.append(("set aside", x))
for task, xs in sorted(by_task.items()):
paths = ", ".join(sorted({str(x.get("path") or x.get("op") or "?") for x in xs}))
n = len(xs)
tail = ("; its completion record is held — not shipped to Mind"
if any(x.get("kind") == "withheld" for x in xs) else
"; its completion record is already on main — check it"
if any(x.get("record") == "on-main" for x in xs) else "")
b.add("impaired", f"impaired:ledger:task:{task}",
f"Mind write set aside for `{task}`: {n} op{'s' if n != 1 else ''} "
f"({paths}){tail}.", needs_you=True, task=task)
per_op += [("held", x) for x in ledger.get("held") or []]
for word, x in per_op:
op = x.get("op") if isinstance(x, dict) else str(x)
why = (x.get("why") if isinstance(x, dict) else "") or "?"
where = x.get("file") if isinstance(x, dict) else ""
b.add("impaired", f"impaired:ledger:{word}:{where or op}:{str(why)[:60]}",
f"Mind write {word}: {op}, {why}.", needs_you=True)


def _late(b: _Batch, result: dict) -> None:
Expand Down
Loading
Loading