herdr-orchestra 5.8.1 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [5.10.0] - 2026-11-18
6
+
7
+ The lead reads less text, and coders get a cleaner task, with no change to how a feature is built or checked. Example: a quick run ("make the login button blue") used to read the whole 31 KB planning playbook; now it reads about 15 KB. A run with 15 wake-ups no longer has the lead print the 17 KB run playbook again on each one. The check command, acceptance criteria, reviews, risk hold, fix rounds and summary work exactly as before.
8
+
9
+ ### Changed
10
+ - **Wake-ups.** The orch-run skill and the `/orch-run` commands run only `orch events` when the lead is woken, not `orch lead run` again. `orch events` now prints, under `WHAT TO DO`, the lead's hard rules and the playbook's own rows for the events it shows, word for word (on ALL_DONE: all of section 3). So a lead whose conversation was compacted, or a fresh session, still has every rule it needs.
11
+ - **Planning in parts.** `orch lead plan` prints the start (role, preflight, research, quick or full, and the split test from step 4b). A quick run then runs `orch lead plan quick` (the tiers, estimate, check command and milestone rules, word for word from the full process); a full plan runs `orch lead plan full` (steps 3 to 10). Start + full is every line of the old playbook, so full plans read the same rules as before.
12
+ - **Coder task file.** `task.md` leaves out the lines only orch uses (`Depends on`, `Why separate`, `Prefer`, `Tier`, `Needs`, `Model why`, `Estimate`, `Review`, `Parallel`; `Role` stays at the top as the coder's role) and lists the acceptance criteria once, with their ids. "Notes from user", where the developer's answers go, is kept as written. All of it is still in `plan.md` and `task.json`.
13
+ - **herdr commands.** The plan playbook writes out the three herdr commands the lead uses (`herdr agent list`, `herdr agent rename <pane id> <name>`, `herdr agent read <name> --source recent-unwrapped --lines 60`) and loads the herdr skill only if one of them fails.
14
+
15
+ ### Added
16
+ - `orch lead plan quick|full` and `orch lead run --section <EVENT|ALL_DONE|rules>`.
17
+ - Tests: a developer's answer still reaches the coder's next `task.md`; a wake-up prints the hard rules and its events' rows; ALL_DONE prints the full summary steps; start + full hold every line of the plan playbook; task.md has no lead-only lines and lists each criterion once.
18
+
19
+ ## [5.9.0] - 2026-11-17
20
+
21
+ Fixes a bug where a criterion the developer had agreed to leave out kept being sent back for fixes. Example: M7 "the watch syncs with the phone API" can't be built because the API doesn't exist; you say "build the rest, sync later". Before, the coder honestly reported that criterion as `met: false`, and orch sent it back for fix round after fix round, then moved M7 to a stronger model. Your approval was only a note in the plan, and the check never read it.
22
+
23
+ ### Added
24
+ - **`orch answer Mn --defer AC2 "<your words>"`** and **`orch defer Mn AC2 "<reason>"`**: the developer's approval to leave a criterion undone is saved as data, with the reason and the time, in the run state, in `task.json` (`"deferred": {"approved_by": "developer", "reason": ...}`) and as a note in `plan.md`. `orch defer` also works on a milestone that is coding, paused or failed (then `orch dispatch Mn`).
25
+ - The summary has a new section, **"Deferred: not done, follow-ups"**: each deferred criterion is listed as NOT built, with your reason and a suggested `orch fix Mn "..."`. "Checked automatically" marks it `DEFERRED, NOT done`.
26
+ - Timing lines in `.orchestrate/autopilot.log` to diagnose slow event pick-up: how old the oldest event was at the wake-up, when the lead read its events (seconds after the first wake-up and after the oldest event), and seconds from the lead's dispatch or answer to the coder being prompted. Log text only; nothing in how a run behaves changed.
27
+
28
+ ### Changed
29
+ - A deferred criterion reported `met: false` starts no fix round, so it never uses up rounds or triggers a stronger model. Every other criterion is checked exactly as before.
30
+ - The reviewer is told which criteria are deferred; its `met: false` for one of them is not a blocker. Real problems in the work that was built are still blockers.
31
+ - Coders are told to ask (status `question`) instead of retrying when a criterion truly can't be met in the repo, and the criteria fix job says the same.
32
+ - Lead playbook, README and website docs (Commands, When a run needs you, Questions and how-tos) explain deferring.
33
+
5
34
  ## [5.8.1] - 2026-11-16
6
35
 
7
36
  A new docs page on the website, **Questions and how-tos** (`/docs/how-to/`): short answers in plain words, each with an example, to the questions people ask most. No change to how orch works.
package/README.md CHANGED
@@ -146,7 +146,7 @@ Version choice, first match wins: `--version` flag › `ORCH_VERSION` env › `.
146
146
  2. **Orchestration plan:** start the plan playbook in the lead's pane (see [Choose your lead](#choose-your-lead)). The lead researches, writes `.orchestrate/plan.md` and shows you the milestones, which coder and model each one goes to, and why. Edit the plan if you like: dependencies, tier, review yes/no, your answers to open questions.
147
147
  3. **Orchestration run:** tell the lead **go** (`/orch-run`). It dispatches the milestones (`orch dispatch M1 M2`), which starts the event manager, and pauses. From here the run looks after itself:
148
148
  - a milestone finishes → the event manager checks and merges it, then wakes the lead, which dispatches what that unlocked;
149
- - a coder asks a question → the lead is woken; if the plan or the code already answers it, it answers, otherwise it asks you in its pane. `orch answer M2 "<your answer>"` writes the answer into the plan and the **same coder** carries on with its work;
149
+ - a coder asks a question → the lead is woken; if the plan or the code already answers it, it answers, otherwise it asks you in its pane. `orch answer M2 "<your answer>"` writes the answer into the plan and the **same coder** carries on with its work; if a criterion can't be met (say an outside API is missing) and you agree to ship the rest, the lead runs `orch answer M2 --defer AC2 "<your words>"`: no fix rounds or stronger-model retries for AC2, and the summary lists it as **not done**, with a follow-up;
150
150
  - a risky change is **held** → you look and run `orch approve Mn`.
151
151
 
152
152
  You can also start the event manager yourself: `orch autopilot` in a spare terminal. It is the only driver of a run: while it runs, other `orch` commands that would change the run are refused (`orch status`, `orch report`, `orch approve` and the lead's `orch events` / `orch dispatch` / `orch answer` still work).
@@ -199,7 +199,7 @@ The agent whose pane you start the plan playbook in becomes the lead. It names i
199
199
  | Antigravity (`agy`) | "use the orch-plan skill: <feature>" |
200
200
  | **any agent** | "Run `orch lead plan` and follow it. Feature: <feature>" |
201
201
 
202
- The skills and slash commands are thin wrappers: the playbooks themselves live in `orch` (`orch lead plan`, `orch lead run`), so every agent follows the same, versioned instructions.
202
+ The skills and slash commands are thin wrappers: the playbooks themselves live in `orch` (`orch lead plan`, `orch lead run`), so every agent follows the same, versioned instructions. They are printed in parts so the lead reads only what it needs: `orch lead plan` prints research and the quick-or-full decision, then `orch lead plan quick` (a quick run's rules) or `orch lead plan full` (steps 3 to 10); on a wake-up, `orch events` prints the rules and steps for those events, so the run playbook is read once.
203
203
 
204
204
  ### Agent registry
205
205
  `orch agents` shows every known kind: installed or not, roles, whether herdr can watch it, and its launch command. Defaults ship in `agents.default.toml`; add or fix kinds in `~/.config/herdr-orchestra/agents.toml` (merged key by key):
@@ -323,7 +323,7 @@ Every status change is written to `.orchestrate/events.jsonl`, and `orch report
323
323
  Optional plan header lines: `Lead mode: events | off` (default `events` when the plan has a `Lead:` line) · `Scope: warn | strict` · `Risk hold: on | off` · `Budget: 3h` (autopilot stops when its running time is used up) · `Estimate: 1h30m` (the lead's estimate for the feature) · `Setup inputs: <globs>` (which files mean "run setup again"; default: lockfiles and manifests). Per milestone: `Why separate` (why it is its own milestone; needed when the plan has more than one) · `Tier`, `Needs`, `Model why` (see [Models and tiers](#models-and-tiers)) · `Estimate: 40m` (dispatch to landed if nothing goes wrong) · `Parallel: allow` lets it run next to a milestone that shares its `Likely files`.
324
324
 
325
325
  ### Commands
326
- `orch status` · `orch resume` · `orch report` · `orch approve Mn` · `orch models [show|check <id>]` · `orch events [--peek]` · `orch dispatch Mn... [--to <worker>] [--tier <tier>]` · `orch answer Mn "<answer>"` · `orch fix Mn "<change>" [--to <worker>]` · `orch doctor [kind]` · `orch ready` · `orch autopilot` · `orch lead plan|run|check|whoami` · `orch agents [launch <kind> [--model <id>]|sync|check]` · `orch handoff Mn` · `orch needs-fix Mn` · `orch set M3 pending` · `orch park M2 paused "why"` · `orch cooldown claude-1 60` · `orch bench claude-1 off|on` · `orch stop [--now]` · `orch doctor --crash` · `orch cleanup` · `orch finish [--no-push]` · `orch version` · `orch update [--check] [--version vX.Y.Z]` · `orch config [auto-update on|off]` · `orch` (full help)
326
+ `orch status` · `orch resume` · `orch report` · `orch approve Mn` · `orch models [show|check <id>]` · `orch events [--peek]` · `orch dispatch Mn... [--to <worker>] [--tier <tier>]` · `orch answer Mn [--defer AC2] "<answer>"` · `orch defer Mn AC2 "<reason>"` · `orch fix Mn "<change>" [--to <worker>]` · `orch doctor [kind]` · `orch ready` · `orch autopilot` · `orch lead plan|run|check|whoami` · `orch agents [launch <kind> [--model <id>]|sync|check]` · `orch handoff Mn` · `orch needs-fix Mn` · `orch set M3 pending` · `orch park M2 paused "why"` · `orch cooldown claude-1 60` · `orch bench claude-1 off|on` · `orch stop [--now]` · `orch doctor --crash` · `orch cleanup` · `orch finish [--no-push]` · `orch version` · `orch update [--check] [--version vX.Y.Z]` · `orch config [auto-update on|off]` · `orch` (full help)
327
327
 
328
328
  Tunables: `ORCH_CODER_BUDGET_MIN` (45) · `ORCH_REVIEW_BUDGET_MIN` (15) · `ORCH_CHECK_TIMEOUT_MIN` (30) · `ORCH_COOLDOWN_MIN` (60) · `ORCH_MAX_TASKS` (unset: no limit) · `ORCH_GONE_COOLDOWN_MIN` (10) · `ORCH_SEND_RETRY_S` (120) · `ORCH_HERDR_TIMEOUT_S` (30) · `ORCH_MAX_LOST` (4) · `ORCH_UNREACHABLE_MIN` (30) · `ORCH_CONFIRM_S` (30) · `ORCH_DOWN_MIN_S` (120: an event manager silent for longer was down, and that time is not counted) · `ORCH_RISK_MAX_LINES` (1500) · `ORCH_LEAD_WAIT_MIN` (15: ready work the lead hasn't dispatched starts by itself) · `ORCH_LEAD_CONFIRM_S` (30: a wake-up the lead did not pick up is sent again, doubling) · `ORCH_LEAD_REWAKE_S` (300) · `ORCH_LEAD_MAX_WAKES` (3) · `ORCH_LEAD_IDLE_MAX_MIN` (720: how long the event manager waits for an answer) · `ORCH_NO_AUTOSTART=1` (the lead's commands never start the event manager)
329
329
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.8.1
1
+ 5.10.0
Binary file
package/bin/orch CHANGED
@@ -161,8 +161,8 @@ def state_lock():
161
161
 
162
162
 
163
163
  # usable while autopilot drives: reads, and the lead's requests (the event manager carries them out)
164
- LEASE_FREE = {"status", "ready", "pick", "report", "approve", "autopilot", "events", "dispatch", "answer", "fix",
165
- "team", "resume", "bench", "stop", "doctor"}
164
+ LEASE_FREE = {"status", "ready", "pick", "report", "approve", "autopilot", "events", "dispatch", "answer", "defer",
165
+ "fix", "team", "resume", "bench", "stop", "doctor"}
166
166
  _LEASE = None
167
167
 
168
168
 
@@ -1606,8 +1606,12 @@ def review_findings(tid, k):
1606
1606
  if f.get("criterion"):
1607
1607
  line += f" ({f['criterion']})"
1608
1608
  (blockers if str(f.get("severity", "")).lower().startswith("block") else sugg).append(line)
1609
+ try:
1610
+ dfr = deferred_of(load()["tasks"].get(tid, {}))
1611
+ except (OSError, ValueError, KeyError, SystemExit):
1612
+ dfr = {}
1609
1613
  for c in d.get("criteria", []) if isinstance(d.get("criteria", []), list) else []:
1610
- if isinstance(c, dict) and c.get("met") is False:
1614
+ if isinstance(c, dict) and c.get("met") is False and str(c.get("id")) not in dfr:
1611
1615
  blockers.append(f"{c.get('id', '?')} not met — {c.get('note', '')}")
1612
1616
  return [f"BLOCKER: {b}" for b in blockers], [f"SUGGESTION: {s}" for s in sugg], True
1613
1617
  rp = rd / f"review-{k}.md"
@@ -2307,10 +2311,16 @@ def cmd_review(args):
2307
2311
  shutil.copy(task_json, rd / "task.json")
2308
2312
  k = t["review_round"] + 1
2309
2313
  rel = f".orchestrate/review/{tid}"
2314
+ dfr = deferred_of(t)
2315
+ deferred_txt = ("DEFERRED by the developer (approved; NOT part of this milestone): "
2316
+ + "; ".join(f"{c} \"{v.get('text', '')}\" (why: {v.get('reason', '')})" for c, v in dfr.items())
2317
+ + ". Report each as `met: false` with a note; it is not a blocker. Don't raise a blocker for the "
2318
+ "missing deferred part. Do review everything that WAS built, including partial work on it.\n\n"
2319
+ ) if dfr else ""
2310
2320
  (rd / f"review-task-{k}.md").write_text(
2311
2321
  f"# Review {tid}: {t['title']} (round {k})\n\n"
2312
2322
  f"Spec and acceptance criteria: {rel}/task.md (criteria ids AC1, AC2… in {rel}/task.json)\n"
2313
- f"Changes: {rel}/diff.patch\n\n" + resolution.replace("{rel}", rel) +
2323
+ f"Changes: {rel}/diff.patch\n\n" + resolution.replace("{rel}", rel) + deferred_txt +
2314
2324
  "Review for correctness against the acceptance criteria, API/contract consistency, UI/UX, security, "
2315
2325
  "edge cases and missing tests. Do NOT edit any code.\n"
2316
2326
  "Report PROBLEMS, not solutions: the coder decides how to fix. At most 15 findings. A `blocker` must be "
@@ -3105,10 +3115,32 @@ WORKER_RULES = """## Rules for you (the coder)
3105
3115
  - Finish with a result file (the prompt names it) in the `result_format` shape from task.json: `status` done / question / blocked, `commit`, `files_changed`, the `check` you ran, one entry per acceptance criterion (`id`, `met`, `evidence`), and `usage` if your tool shows tokens or cost. orch reads it, so keep it valid JSON.
3106
3116
  - The commit message (`commit` in the result, and the last report line `COMMIT: <commit message>`) says what changed, in the repo's commit style (for example `feat(api): add categories endpoint`). It becomes the commit message, so describe the change, not the milestone.
3107
3117
  - If anything is ambiguous, do not guess: set status `question`, put the question in `questions` and on a report line starting `QUESTION:`, finish the files and the done file, and stop.
3118
+ - If an acceptance criterion can't be met in this repo (it needs an outside API, service or account that doesn't exist), don't keep trying: ask (status `question`), name the criterion and why, and offer to build the rest. A criterion marked DEFERRED above was approved to stay undone: don't build it, and report it `met: false`.
3108
3119
  - Before finishing, run the check command below and record the result (pass/fail + the failing lines).
3109
3120
  """
3110
3121
 
3111
3122
 
3123
+ # plan.md lines that are for the lead and orch, not the coder: they stay in plan.md and task.json
3124
+ LEAD_ONLY_FIELDS = {"depends on", "why separate", "prefer", "tier", "needs", "model why", "estimate", "role",
3125
+ "review", "parallel"}
3126
+
3127
+
3128
+ def coder_section(text, drop_criteria):
3129
+ """A milestone's plan section as the coder sees it: without the lead-only fields (Role is shown above as
3130
+ "Your role"), and without the plain criteria list when the criteria are listed below with their ids.
3131
+ Everything from "Notes from user" on is kept as written: that is how the developer's answers reach the coder."""
3132
+ out, drop, notes = [], False, False
3133
+ for line in text.splitlines():
3134
+ fm = FIELD_RE.match(line.strip())
3135
+ if not notes and fm and not line.startswith((" ", "\t", "-")):
3136
+ key = fm.group(1).strip().lower()
3137
+ notes = bool(NOTES_RE.match(line))
3138
+ drop = not notes and (key in LEAD_ONLY_FIELDS or (drop_criteria and key == "acceptance criteria"))
3139
+ if not (drop and not notes):
3140
+ out.append(line)
3141
+ return "\n".join(out)
3142
+
3143
+
3112
3144
  def cmd_write_task(args):
3113
3145
  """orch write-task Mn -> generate TASKDIR/task.md from the plan (+ dependency reports)."""
3114
3146
  need(args, 1, "write-task <Mn>")
@@ -3126,7 +3158,9 @@ def cmd_write_task(args):
3126
3158
  "the patterns it already follows. Then build it to the standard that specialist would put their "
3127
3159
  "name on: \"the check passes\" is the floor, not the goal. Before you finish, look at your own "
3128
3160
  "result as that specialist reviewing someone else's work, and fix what they would send back.", ""]
3129
- parts += [secs[tid].replace(f"## [x] {tid}:", "Title:", 1), ""]
3161
+ contract = task_contract(st, tid)
3162
+ parts += [coder_section(secs[tid].replace(f"## [x] {tid}:", "Title:", 1),
3163
+ drop_criteria=bool(contract["acceptance_criteria"])), ""]
3130
3164
  if glob and glob.lower() not in ("none", "<empty — user may fill in>"):
3131
3165
  parts += ["## Global instructions", glob, ""]
3132
3166
  ctx = []
@@ -3140,10 +3174,12 @@ def cmd_write_task(args):
3140
3174
  "\n".join(lines[:25]), ""]
3141
3175
  if ctx:
3142
3176
  parts += ["## Context: what the tasks you depend on built", *ctx]
3143
- contract = task_contract(st, tid)
3144
3177
  if contract["acceptance_criteria"]:
3145
- parts += ["## Acceptance criteria ids (for your result file)",
3146
- *[f"- {c['id']}: {c['text']}" for c in contract["acceptance_criteria"]], ""]
3178
+ parts += ["## Acceptance criteria (ids for your result file)",
3179
+ *[f"- {c['id']}: {c['text']}" + (f" — DEFERRED by the developer: don't build it in this milestone, "
3180
+ f"report it `met: false` (why: {c['deferred']['reason']})"
3181
+ if c.get("deferred") else "")
3182
+ for c in contract["acceptance_criteria"]], ""]
3147
3183
  if contract["previous_work"]:
3148
3184
  parts += ["## Earlier work", f"An earlier attempt ({contract['previous_work']['by'] or 'another coder'}) left "
3149
3185
  "work in this folder. Look at it first and continue from it unless it is wrong.", ""]
@@ -3173,7 +3209,11 @@ def task_contract(st, tid):
3173
3209
  return {
3174
3210
  "schema": 1, "task_id": tid, "title": t["title"], "kind": "task",
3175
3211
  "goal": field(pt, "goal"), "why": field(pt, "why"),
3176
- "acceptance_criteria": [{"id": f"AC{i}", "text": c} for i, c in enumerate(items("acceptance criteria"), 1)],
3212
+ "acceptance_criteria": [{"id": f"AC{i}", "text": c,
3213
+ **({"deferred": {"approved_by": "developer",
3214
+ "reason": deferred_of(t)[f"AC{i}"].get("reason", "")}}
3215
+ if f"AC{i}" in deferred_of(t) else {})}
3216
+ for i, c in enumerate(items("acceptance criteria"), 1)],
3177
3217
  "files_allowed": t.get("files") or [], "scope": st.get("scope", "warn"),
3178
3218
  "tier": t.get("tier"), "needs": t.get("needs") or [], "role": t.get("role") or None,
3179
3219
  "interfaces": items("interfaces"), "constraints": items("constraints"), "out_of_scope": items("out of scope"),
@@ -3251,6 +3291,7 @@ def cmd_dispatch(args):
3251
3291
  for tid in args:
3252
3292
  t = st["tasks"][tid]
3253
3293
  t["go"] = True
3294
+ t["go_ts"] = now()
3254
3295
  t.pop("ready_ts", None)
3255
3296
  if opts.get("--to"):
3256
3297
  t["assign"] = opts["--to"]
@@ -3277,10 +3318,111 @@ def cmd_dispatch(args):
3277
3318
  NOTES_RE = re.compile(r"(?mi)^Notes from user:[ \t]*")
3278
3319
 
3279
3320
 
3321
+ def plan_criteria(tid):
3322
+ """[(AC id, text)] of a milestone's acceptance criteria in plan.md, numbered the way task.json numbers them."""
3323
+ try:
3324
+ _, ptasks = parse_plan((ORCH / "plan.md").read_text())
3325
+ except OSError:
3326
+ return []
3327
+ pt = next((x for x in ptasks if x["id"] == tid), {"fields": {}})
3328
+ vals = [v.lstrip("- ").strip() for v in pt["fields"].get("acceptance criteria", [])]
3329
+ return [(f"AC{i}", v) for i, v in enumerate([v for v in vals if v and v.lower() != "none"], 1)]
3330
+
3331
+
3332
+ def deferred_of(t):
3333
+ """{AC id: {"text", "reason", "ts"}}: criteria the developer approved leaving undone in this milestone."""
3334
+ d = t.get("deferred")
3335
+ return d if isinstance(d, dict) else {}
3336
+
3337
+
3338
+ def parse_defer_ids(tid, raw):
3339
+ """'AC2,AC3' (or 'ac2 3') -> ['AC2', 'AC3'], each checked against the milestone's criteria in plan.md."""
3340
+ crit = dict(plan_criteria(tid))
3341
+ ids = []
3342
+ for p in re.split(r"[,\s]+", raw.strip()):
3343
+ if not p:
3344
+ continue
3345
+ cid = "AC" + p[2:] if p.upper().startswith("AC") else "AC" + p
3346
+ if cid not in crit:
3347
+ die(f"{tid} has no acceptance criterion {p!r} — its criteria: "
3348
+ + (", ".join(f"{k} ({v[:40]})" for k, v in crit.items()) or "none in plan.md"))
3349
+ if cid not in ids:
3350
+ ids.append(cid)
3351
+ return ids or die("name the criteria to defer, for example AC2 or AC2,AC3")
3352
+
3353
+
3354
+ def record_deferral(t, tid, ids, reason):
3355
+ """Remember, with the developer's reason, that these criteria are approved to stay undone in this milestone."""
3356
+ crit = dict(plan_criteria(tid))
3357
+ d = dict(deferred_of(t))
3358
+ for cid in ids:
3359
+ d[cid] = {"text": crit.get(cid, ""), "reason": reason, "ts": now()}
3360
+ t["deferred"] = d
3361
+
3362
+
3363
+ def add_plan_note(tid, text):
3364
+ """Add `- text` under the milestone's "Notes from user" in plan.md (the line is created when missing)."""
3365
+ plan = ORCH / "plan.md"
3366
+ lines, out, cur, done = plan.read_text().split("\n"), [], None, False
3367
+ note = f"- {text}"
3368
+ for line in lines:
3369
+ m = HEAD_RE.match(line)
3370
+ if (m or line.startswith("## ")) and cur == tid and not done: # section ended without a notes line
3371
+ while out and not out[-1].strip():
3372
+ out.pop()
3373
+ out += ["Notes from user:", note, ""]
3374
+ done = True
3375
+ if m or line.startswith("## "):
3376
+ cur = m.group(2) if m else None
3377
+ out.append(line)
3378
+ if cur == tid and not done and NOTES_RE.match(line):
3379
+ out.append(note)
3380
+ done = True
3381
+ if not done:
3382
+ if cur != tid:
3383
+ die(f"{tid} not found in plan.md")
3384
+ while out and not out[-1].strip():
3385
+ out.pop()
3386
+ out += ["Notes from user:", note, ""]
3387
+ plan.write_text("\n".join(out))
3388
+
3389
+
3390
+ def defer_note(t, ids, reason):
3391
+ return ("Deferred with the developer's approval (NOT built in this milestone, a follow-up): "
3392
+ + "; ".join(f"{c} \"{deferred_of(t).get(c, {}).get('text', '')}\"" for c in ids) + f". Why: {reason}")
3393
+
3394
+
3395
+ def cmd_defer(args):
3396
+ """orch defer Mn AC2[,AC3] <the developer's reason> -> the developer approved leaving these criteria undone in
3397
+ Mn. A coder that reports them `met: false` gets no fix round for them (so no escalation either), the reviewer
3398
+ does not block on them, and the summary lists them as NOT done, with a follow-up. Only with the developer's yes."""
3399
+ need(args, 3, "defer <Mn> <AC ids, e.g. AC2,AC3> <the developer's reason>")
3400
+ tid, raw, reason = args[0], args[1], " ".join(" ".join(args[2:]).split())
3401
+ with state_lock():
3402
+ st = load()
3403
+ t = task(st, tid)
3404
+ if t["status"] in ("merged", "skipped"):
3405
+ die(f"{tid} is {t['status']} — nothing left to defer (a later change: `orch fix {tid} \"<text>\"`)")
3406
+ ids = parse_defer_ids(tid, raw)
3407
+ record_deferral(t, tid, ids, reason)
3408
+ add_plan_note(tid, defer_note(t, ids, reason))
3409
+ save(st)
3410
+ print(f"DEFERRED {tid} {','.join(ids)}: no fix rounds for them; the summary lists them as not done "
3411
+ f"(follow-up). Why: {reason}")
3412
+ if t["status"] in ("paused", "failed"):
3413
+ print(f"NEXT {tid} is {t['status']}: `orch dispatch {tid}` sends it on with the rest of its criteria")
3414
+
3415
+
3280
3416
  def cmd_answer(args):
3281
- """orch answer Mn <the developer's answer> -> write it under the milestone's "Notes from user" in plan.md and
3282
- send the milestone back to the SAME coder, which carries on from its saved work."""
3283
- need(args, 2, "answer <Mn> <answer text>")
3417
+ """orch answer Mn [--defer AC2,AC3] <the developer's answer> -> write it under the milestone's "Notes from user"
3418
+ in plan.md and send the milestone back to the SAME coder, which carries on from its saved work. --defer also
3419
+ records that the developer approved leaving those criteria undone (see `orch defer`)."""
3420
+ defer = None
3421
+ if "--defer" in args:
3422
+ i = args.index("--defer")
3423
+ defer = args[i + 1] if len(args) > i + 1 else die("--defer needs criteria ids, for example AC2 or AC2,AC3")
3424
+ del args[i:i + 2]
3425
+ need(args, 2, "answer <Mn> [--defer AC2,AC3] <answer text>")
3284
3426
  tid, text = args[0], " ".join(args[1:]).strip()
3285
3427
  with state_lock():
3286
3428
  st = load()
@@ -3288,37 +3430,23 @@ def cmd_answer(args):
3288
3430
  if t["status"] != "paused":
3289
3431
  die(f"{tid} is {t['status']}, not paused" + (
3290
3432
  " — its questions are in plan.md: answer them under \"Notes from user\", set \"Open questions:\" to "
3291
- "`- none`, then `orch sync`" if t["status"] == "needs-answer" else ""))
3292
- plan = ORCH / "plan.md"
3293
- lines, out, cur, done = plan.read_text().split("\n"), [], None, False
3294
- note = f"- {text}"
3295
- for i, line in enumerate(lines):
3296
- m = HEAD_RE.match(line)
3297
- if (m or line.startswith("## ")) and cur == tid and not done: # section ended without a notes line
3298
- while out and not out[-1].strip():
3299
- out.pop()
3300
- out += ["Notes from user:", note, ""]
3301
- done = True
3302
- if m or line.startswith("## "):
3303
- cur = m.group(2) if m else None
3304
- out.append(line)
3305
- if cur == tid and not done and NOTES_RE.match(line):
3306
- out.append(note)
3307
- done = True
3308
- if not done:
3309
- if cur != tid:
3310
- die(f"{tid} not found in plan.md")
3311
- while out and not out[-1].strip():
3312
- out.pop()
3313
- out += ["Notes from user:", note, ""]
3314
- plan.write_text("\n".join(out))
3433
+ "`- none`, then `orch sync`" if t["status"] == "needs-answer" else "")
3434
+ + (f" (to record the approved deferral anyway: `orch defer {tid} {defer} \"<reason>\"`)" if defer else ""))
3435
+ ids = parse_defer_ids(tid, defer) if defer else []
3436
+ add_plan_note(tid, text)
3437
+ if ids:
3438
+ record_deferral(t, tid, ids, text)
3439
+ add_plan_note(tid, defer_note(t, ids, text))
3315
3440
  last = t.get("last_worker")
3316
3441
  t["go"] = True
3442
+ t["go_ts"] = now()
3317
3443
  if last in st["workers"]:
3318
3444
  t["assign"] = last
3319
- t.setdefault("answers", []).append({"ts": now(), "text": text})
3445
+ t.setdefault("answers", []).append({"ts": now(), "text": text, **({"deferred": ids} if ids else {})})
3320
3446
  _park(st, tid, "pending", f"answered: {text[:200]}")
3321
3447
  print(f"ANSWERED {tid}: written to plan.md; it goes back to {last or 'the next free coder'} with its work so far")
3448
+ if ids:
3449
+ print(f"DEFERRED {tid} {','.join(ids)}: no fix rounds for them; the summary lists them as not done (follow-up)")
3322
3450
  print(start_manager())
3323
3451
  print("You will be woken with `orch events` when something needs you. Stop here; do not poll.")
3324
3452
 
@@ -3389,11 +3517,11 @@ def cmd_fix(args):
3389
3517
 
3390
3518
  EVENT_HELP = {
3391
3519
  "paused": "a coder's question, or an agent that stopped. A question only the developer can settle: ask them, "
3392
- "then `orch answer {t} \"<their answer>\"`. An agent problem: tell the developer what to look at, then "
3520
+ "then `orch answer {t} \"<their answer>\"`. If they approve building the rest and leaving a criterion undone, add `--defer AC<n>` so it costs no fix rounds. An agent problem: tell the developer what to look at, then "
3393
3521
  "`orch dispatch {t}`.",
3394
3522
  "failed": "still failing after its rounds. Read the last report and check or review output, add the missing "
3395
3523
  "FACT or constraint to the plan (never a how-to), then `orch dispatch {t}` (add `--tier high` or "
3396
- "`--to <worker>` to give it a stronger model).",
3524
+ "`--to <worker>` to give it a stronger model). If a criterion can't be met (a missing outside API) and the developer approves leaving it out: `orch defer {t} AC<n> \"<their reason>\"`, then `orch dispatch {t}`.",
3397
3525
  "held": "risky changes wait for the developer: show them the reasons; they run `orch approve {t}`. Never approve it yourself.",
3398
3526
  "needs-answer": "open questions in plan.md: ask the developer, write the answers under \"Notes from user\", set "
3399
3527
  "\"Open questions:\" to `- none`, `orch sync`, then `orch dispatch {t}`.",
@@ -3411,7 +3539,7 @@ EVENT_HELP = {
3411
3539
  "herdr-restart": "most agents vanished at once: herdr was probably restarted or closed. Tell the developer to "
3412
3540
  "run `orch resume` (it names the panes again and re-sends the work); then `orch team up` for "
3413
3541
  "any agent it reports LOST.",
3414
- "all_done": "every milestone landed. Finish .orchestrate/summary.md (see `orch lead run`, section ALL_DONE).",
3542
+ "all_done": "every milestone landed. Finish .orchestrate/summary.md: the steps (section 3, ALL_DONE) are printed below.",
3415
3543
  "stopped": "the event manager stopped. Tell the developer why; they run `orch resume` (or `orch autopilot`).",
3416
3544
  }
3417
3545
 
@@ -3455,11 +3583,24 @@ def cmd_events(args):
3455
3583
  + (" (work is in progress: run `orch resume` now)" if needs_manager(st) else "")))
3456
3584
  if not new and not old and not hold:
3457
3585
  print("Nothing needs you.")
3586
+ kinds = list(dict.fromkeys([e["kind"] for e in new + old] + (["ready"] if hold else [])))
3587
+ pb = asset("playbooks/run.md") if kinds else None
3588
+ if pb: # the playbook's own words for these events: a wake-up never needs
3589
+ text = pb.read_text() # `orch lead run` again, even after the lead's context was compacted
3590
+ print("\nWHAT TO DO (from `orch lead run`; you need no other part of the playbook for these events):")
3591
+ print(run_playbook_part(text, "rules"), end="")
3592
+ rows = "".join(run_playbook_part(text, k) for k in kinds if k != "all_done")
3593
+ if rows:
3594
+ print("| Event | What you do |\n|---|---|\n" + rows, end="")
3595
+ if "all_done" in kinds:
3596
+ print("\n" + run_playbook_part(text, "ALL_DONE"), end="")
3458
3597
  print("Handle each event above, then STOP: you are woken again when something else happens. Never prompt a "
3459
3598
  "coder yourself and never poll.")
3460
3599
  if not peek and new:
3461
3600
  for e in new:
3462
3601
  e["read"] = now()
3602
+ if st.get("lead_wake"):
3603
+ st["lead_wake"]["read_ts"] = now() # for the event manager's timing line
3463
3604
  save(st)
3464
3605
 
3465
3606
 
@@ -3538,11 +3679,35 @@ def auto_checked(st, final_ok):
3538
3679
  ev.append(f"coder: {'met' if c['met'] else 'NOT met'}" + (f" ({c['evidence']})" if c.get("evidence") else ""))
3539
3680
  if r and r.get("met") is not None:
3540
3681
  ev.append(f"reviewer: {'met' if r['met'] else 'NOT met'}" + (f" ({r['note']})" if r.get("note") else ""))
3682
+ dv = deferred_of(t).get(cid)
3683
+ if dv and not (c and c.get("met")):
3684
+ out.append(f" - {cid} {text} — DEFERRED, NOT done (approved by the developer: {dv.get('reason', '')}). "
3685
+ f"See \"Deferred: not done, follow-ups\"")
3686
+ continue
3541
3687
  out.append(f" - {cid} {text} — " + ("; ".join(ev) if ev else "no evidence recorded: the lead checks it, "
3542
3688
  "or it goes on the manual list"))
3543
3689
  return "\n".join(out)
3544
3690
 
3545
3691
 
3692
+ def deferred_lines(st):
3693
+ """The summary's list of criteria the developer approved leaving undone: each is NOT done and needs a follow-up.
3694
+ A deferred criterion the coder reports as met after all is left out (it was done)."""
3695
+ out = []
3696
+ for tid in st["order"]:
3697
+ t = st["tasks"][tid]
3698
+ dfr = deferred_of(t)
3699
+ if not dfr:
3700
+ continue
3701
+ res, _ = read_result(t.get("last_result"))
3702
+ met = {str(c.get("id")) for c in (res or {}).get("criteria", []) if isinstance(c, dict) and c.get("met")}
3703
+ for cid, v in dfr.items():
3704
+ if cid in met:
3705
+ continue
3706
+ out.append(f"- {tid} {cid} \"{v.get('text', '')}\": NOT done. Approved by the developer: "
3707
+ f"{v.get('reason', '')}. Follow-up: when it can be built, `orch fix {tid} \"{v.get('text', '')}\"`")
3708
+ return out
3709
+
3710
+
3546
3711
  RATE_RE = re.compile(r"usage limit|rate.?limit|quota|too many requests|\b429\b|limit reached|try again (in|at)|out of credits",
3547
3712
  re.I)
3548
3713
 
@@ -3730,7 +3895,10 @@ def _autopilot(args):
3730
3895
  if not un:
3731
3896
  if lw.get("n") and not lw.get("ack"):
3732
3897
  patch_state(lambda s2: s2.update(lead_wake={**(s2.get("lead_wake") or {}), "ack": True}))
3733
- say(f"the lead ({lead}) picked up its events")
3898
+ rt, first = lw.get("read_ts"), lw.get("first_ts") or lw.get("ts")
3899
+ say(f"the lead ({lead}) picked up its events" + (
3900
+ f" (read {max(0, rt - first)}s after the first wake-up, {max(0, rt - lw['oldest'])}s after the "
3901
+ f"oldest event; seen here {max(0, now() - rt)}s later)" if rt and first and lw.get("oldest") else ""))
3734
3902
  return
3735
3903
  newest = max(e["id"] for e in un)
3736
3904
  # a wake the lead has not acted on yet covers newer events too: it reads the whole queue when it comes
@@ -3765,14 +3933,18 @@ def _autopilot(args):
3765
3933
  patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": n, "wait": SEND_RETRY_S}))
3766
3934
  return
3767
3935
  wait = min(LEAD_REWAKE_S, LEAD_CONFIRM_S * 2 ** n) if watch else LEAD_REWAKE_S
3768
- patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": n + 1, "wait": wait}))
3936
+ oldest = min(e["ts"] for e in un)
3937
+ first_ts = lw.get("first_ts", lw.get("ts")) if n else now()
3938
+ patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": n + 1, "wait": wait,
3939
+ "first_ts": first_ts, "oldest": oldest}))
3769
3940
  what = ", ".join(f"{e['kind']}{' ' + e['task'] if e.get('task') else ''}" for e in un[:6])
3770
3941
  if n:
3771
3942
  say(f"the lead ({lead}) did not pick up its wake-up (" + ("idle again, " if watch else "")
3772
3943
  + f"events still unread after {now() - lw.get('ts', now())}s) -> sent it again "
3773
3944
  f"({n + 1} of {LEAD_MAX_WAKES}): {len(un)} event(s) — {what}")
3774
3945
  else:
3775
- say(f"woke the lead ({lead}): {len(un)} event(s) — {what} (sent; it counts once the lead reads them)")
3946
+ say(f"woke the lead ({lead}): {len(un)} event(s) — {what} (sent; it counts once the lead reads them; "
3947
+ f"oldest event {max(0, now() - oldest)}s old)")
3776
3948
 
3777
3949
  def lead_ready():
3778
3950
  """Ready milestones the lead has not dispatched: tell it once per set; start them ourselves after LEAD_WAIT_S."""
@@ -3919,13 +4091,26 @@ def _autopilot(args):
3919
4091
  hot = [f for f in new if HOTSPOT_RE.search(f)]
3920
4092
  say(f"{tid} changed files outside its Likely files: {', '.join(new)}" +
3921
4093
  (f" (shared hotspot files: {', '.join(hot)})" if hot else ""), bool(hot))
3922
- unmet = [c for c in (res or {}).get("criteria", []) if c.get("met") is False]
4094
+ # a criterion the developer approved leaving undone (`orch defer`, `orch answer --defer`) is not a failure:
4095
+ # no fix round, no escalation; the summary lists it as not done, with a follow-up
4096
+ dfr = deferred_of(load()["tasks"][tid])
4097
+ unmet_all = [c for c in (res or {}).get("criteria", []) if c.get("met") is False]
4098
+ unmet = [c for c in unmet_all if str(c.get("id")) not in dfr]
4099
+ skipped = [str(c["id"]) for c in unmet_all if str(c.get("id")) in dfr]
4100
+ if skipped:
4101
+ say(f"{tid}: {', '.join(skipped)} not met, deferred with the developer's approval -> no fix round for "
4102
+ f"{'it' if len(skipped) == 1 else 'them'} (listed as not done in the summary)")
3923
4103
  if unmet:
3924
4104
  say(f"{tid}: the coder reports {', '.join(str(c['id']) for c in unmet)} not met -> fix round")
3925
4105
  fix_round(tid, "criteria-fix", lambda n: (
3926
4106
  f"# {tid}: acceptance criteria not met yet (round {n})\n\nYour result says these are not met:\n"
3927
4107
  + "\n".join(f"- {c['id']}: {c.get('evidence', '')}" for c in unmet)
3928
- + f"\n\nFinish them (you decide how), run `{st['check']}`, and write a new result.\n"),
4108
+ + (f"\n\nAlready deferred by the developer (leave them; keep them `met: false`): "
4109
+ f"{', '.join(skipped)}." if skipped else "")
4110
+ + f"\n\nFinish them (you decide how), run `{st['check']}`, and write a new result.\n"
4111
+ "If one truly can't be met in this repo (for example an outside API or service it needs does not "
4112
+ "exist), don't try again: set status `question`, say which criterion and why, and offer to "
4113
+ "build the rest and defer that one. The developer decides.\n"),
3929
4114
  f"acceptance criteria still not met after {MAX_FIX} fix rounds")
3930
4115
  return
3931
4116
  ok, tail = check(t["dir"], tid)
@@ -4001,7 +4186,11 @@ def _autopilot(args):
4001
4186
  code, out = run("send-job" if kind == "FIX" else "send", tid, *([] if kind == "FIX" else ["task.md"]),
4002
4187
  ok=(0, 5))
4003
4188
  if sent(code, out, tid, worker):
4004
- say(f"{tid} fix job -> {worker}" if kind == "FIX" else f"{tid} -> {worker}")
4189
+ go_ts = load()["tasks"][tid].get("go_ts")
4190
+ if go_ts:
4191
+ patch_state(lambda s_: s_["tasks"][tid].pop("go_ts", None))
4192
+ say(f"{tid} fix job -> {worker}" if kind == "FIX" else f"{tid} -> {worker}"
4193
+ + (f" ({max(0, now() - go_ts)}s after the lead's dispatch or answer)" if go_ts else ""))
4005
4194
 
4006
4195
  def on_event(ev):
4007
4196
  parts = ev.split()
@@ -4249,6 +4438,8 @@ def _autopilot(args):
4249
4438
  f"\n\n## Commits\n```\n{log_}```\n\n## Files changed\n```\n{stat}```\n\n"
4250
4439
  "## Changed outside Likely files\n" + ("\n".join(scope) or "none") + "\n\n"
4251
4440
  "## Reviewer suggestions not applied\n" + ("\n".join(sugg) or "none") + "\n\n"
4441
+ + ("## Deferred: not done, follow-ups\nThe developer approved leaving these out of this run. They were "
4442
+ "NOT built.\n" + "\n".join(deferred_lines(st)) + "\n\n" if deferred_lines(st) else "")
4252
4443
  + ("## Models: planned and actual\n| Milestone | Planned tier | Ran on | Escalated | Why this tier |\n"
4253
4444
  "|---|---|---|---|---|\n" + "\n".join(models) + "\n\n" if models else "") +
4254
4445
  f"## Time: estimate vs actual\n{timing}\n\n"
@@ -5113,18 +5304,21 @@ COMMANDS = {
5113
5304
  "write-task": cmd_write_task, "nudge": cmd_nudge, "autopilot": cmd_autopilot,
5114
5305
  "send-job": cmd_send_job, "handoff": cmd_handoff, "needs-fix": cmd_needs_fix, "review-ok": cmd_review_ok,
5115
5306
  "requeue-review": cmd_requeue_review, "finish": cmd_finish, "resend": cmd_resend, "approve": cmd_approve,
5116
- "report": cmd_report, "events": cmd_events, "dispatch": cmd_dispatch, "answer": cmd_answer,
5307
+ "report": cmd_report, "events": cmd_events, "dispatch": cmd_dispatch, "answer": cmd_answer, "defer": cmd_defer,
5117
5308
  "escalate": cmd_escalate, "fix": cmd_fix, "team": cmd_team, "bench": cmd_bench, "stop": cmd_stop,
5118
5309
  "doctor": lambda a: cmd_doctor_crash(a),
5119
5310
  }
5120
5311
  # they lock per step instead of for the whole command (long-running, or they start the event manager after)
5121
- UNLOCKED = {"autopilot", "poll", "events", "dispatch", "answer", "fix", "team", "resume", "bench", "stop", "doctor"}
5312
+ UNLOCKED = {"autopilot", "poll", "events", "dispatch", "answer", "defer", "fix", "team", "resume", "bench", "stop",
5313
+ "doctor"}
5122
5314
 
5123
5315
  USAGE = """usage: orch <command> [args]
5124
5316
  version print the installed herdr-orchestra version
5125
5317
  update [--check] [--version vX.Y.Z] install the latest release (or that one) and show what is new
5126
5318
  config [auto-update on|off] this machine's settings: keep orch up to date by itself, or only be told
5127
5319
  lead plan|run print the lead playbook (any agent can lead: "Run `orch lead plan` and follow it")
5320
+ lead plan quick|full the rest of the plan playbook: a quick run's rules, or steps 3-10 of the full process
5321
+ lead run --section <EVENT|ALL_DONE|rules> one part of the run playbook (orch events prints these for you)
5128
5322
  lead check preflight: is this agent in a Herdr pane / can it reach herdr?
5129
5323
  lead whoami show the lead's own herdr pane and how to name it `lead`
5130
5324
  team <kind> [--coders N] [--models a,b] [--no-reviewer]
@@ -5138,7 +5332,10 @@ USAGE = """usage: orch <command> [args]
5138
5332
  work, re-send the tasks that were in progress and start the event manager
5139
5333
  events [--peek] (lead) what you were woken for; reading acknowledges it
5140
5334
  dispatch <Mn>... [--to <worker>] [--tier <tier>] (lead) start or restart milestones; starts the event manager
5141
- answer <Mn> <text> (lead) the developer's answer: into plan.md, and back to the same coder
5335
+ answer <Mn> [--defer AC2,AC3] <text> (lead) the developer's answer: into plan.md, and back to the same coder;
5336
+ --defer records that the developer approved leaving those criteria undone
5337
+ defer <Mn> <AC2,AC3> <reason> (lead, only with the developer's yes) these criteria stay undone in Mn: no fix
5338
+ rounds or escalation for them; the summary lists them as NOT done, with a follow-up
5142
5339
  fix <Mn> <text> [--to <worker>] a change to something Mn already landed: a small follow-up milestone, sent
5143
5340
  straight to the coder who built Mn (no new plan; check, review and summary still apply)
5144
5341
  agents sync [kind...] install the orch-plan / orch-run skills so every installed agent sees each one exactly once,
@@ -5215,15 +5412,84 @@ def lead_check():
5215
5412
  + hermes_fix)
5216
5413
 
5217
5414
 
5415
+ PB_MARK_RE = re.compile(r"^<!-- (/?)(full|start|quick)(?::\s*(.*?))?\s*-->$")
5416
+
5417
+
5418
+ def plan_playbook_part(text, part):
5419
+ """The plan playbook in parts, so a quick run doesn't read the whole full process:
5420
+ "" = the start (role, preflight, research, quick-or-full, plus the `<!-- start -->` blocks of the full part);
5421
+ "quick" = the `<!-- quick: title -->` blocks (rules a quick plan uses, word for word from the full process);
5422
+ "full" = steps 3 to 10. start + full is every line of the playbook exactly once."""
5423
+ lines = text.splitlines(keepends=True)
5424
+ cut = next((i for i, l in enumerate(lines) if l.strip() == "<!-- full -->"), len(lines))
5425
+ head, rest = lines[:cut], lines[cut + 1:]
5426
+ blocks, out, cur, title = {"start": [], "quick": []}, [], None, ""
5427
+ for l in rest:
5428
+ m = PB_MARK_RE.match(l.strip())
5429
+ if m and m.group(2) in ("start", "quick"):
5430
+ if not m.group(1):
5431
+ cur, title, buf = m.group(2), m.group(3) or "", []
5432
+ if cur == "start":
5433
+ out.append(f"({title}: printed at the start of this playbook by `orch lead plan`; apply it "
5434
+ f"here.)\n")
5435
+ else:
5436
+ blocks[cur].append((title, buf))
5437
+ cur = None
5438
+ continue
5439
+ if cur:
5440
+ buf.append(l)
5441
+ if cur != "start":
5442
+ out.append(l)
5443
+ if part == "full":
5444
+ return "".join(out)
5445
+ if part == "quick":
5446
+ return "".join(f"## {t}\n{''.join(b)}\n" for t, b in blocks["quick"])
5447
+ return "".join(head) + "".join(f"\n## {t} (from the full process)\n{''.join(b)}" for t, b in blocks["start"])
5448
+
5449
+
5450
+ # which rows of the run playbook's event table belong to each lead event kind
5451
+ EVENT_ROWS = {"ready": "READY", "merged": "MERGED", "paused": "PAUSED", "failed": "FAILED", "held": "HELD",
5452
+ "worker-lost": "WORKER-LOST", "herdr-restart": "HERDR-RESTART", "needs-answer": "NEEDS-ANSWER",
5453
+ "escalated": "ESCALATED", "auto-dispatched": "AUTO-DISPATCHED", "stopped": "STOPPED",
5454
+ "all_done": "ALL_DONE"}
5455
+
5456
+
5457
+ def run_playbook_part(text, name):
5458
+ """A piece of the run playbook: `rules` (the hard rules), `ALL_DONE` (section 3, whole) or an event kind (its
5459
+ rows of the event table, word for word). Lets the lead act on a wake-up without reading the whole playbook."""
5460
+ key = name.strip().lower()
5461
+ secs = re.split(r"(?m)^(?=## )", text)
5462
+ if key in ("rules", "hard rules"):
5463
+ return next((x for x in secs if x.startswith("## Hard rules")), "")
5464
+ if key in ("all_done", "all-done", "3"):
5465
+ return next((x for x in secs if x.startswith("## 3. ALL_DONE")), "")
5466
+ kind = EVENT_ROWS.get(key, key.upper())
5467
+ rows = [l for l in text.splitlines() if re.match(rf"^\| `{re.escape(kind)}\b", l)
5468
+ or (kind == "STOPPED" and l.startswith("| `STOPPED`"))]
5469
+ if kind == "STOPPED":
5470
+ rows += [l for l in text.splitlines() if l.startswith(("| `orch status` starts with", "**Red baseline.**",
5471
+ "**Why did the event manager stop?**"))]
5472
+ return "\n".join(rows) + ("\n" if rows else "")
5473
+
5474
+
5218
5475
  def cmd_lead(args):
5219
5476
  """orch lead plan|run -> print the lead playbook; orch lead whoami -> this pane + how to name it `lead`."""
5220
5477
  sub = args[0] if args else ""
5221
5478
  if sub in ("plan", "run"):
5222
5479
  pb = asset(f"playbooks/{sub}.md") or die(f"playbooks/{sub}.md not found next to orch or in the install")
5223
- if sub == "plan":
5480
+ part = args[1] if len(args) > 1 else ""
5481
+ if sub == "plan" and part not in ("", "quick", "full"):
5482
+ die("usage: orch lead plan [quick | full]")
5483
+ if sub == "run" and part not in ("", "--section"):
5484
+ die("usage: orch lead run [--section <EVENT | ALL_DONE | rules>]")
5485
+ if sub == "plan" and not part:
5224
5486
  auto_update_at_plan() # a new feature starts on the newest release (never during a run)
5225
- print(f"herdr-orchestra {installed_version()} — lead playbook: {sub}\n")
5226
- print(pb.read_text(), end="")
5487
+ if sub == "run" and part == "--section":
5488
+ print(run_playbook_part(pb.read_text(), args[2] if len(args) > 2 else ""), end="")
5489
+ return
5490
+ label = f"{sub} ({part})" if part else sub
5491
+ print(f"herdr-orchestra {installed_version()} — lead playbook: {label}\n")
5492
+ print(plan_playbook_part(pb.read_text(), part) if sub == "plan" else pb.read_text(), end="")
5227
5493
  return
5228
5494
  if sub == "check":
5229
5495
  lead_check()
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  description: "Orchestrator step 2 — start the run (dispatch, then pause), handle the events you are woken for, finish the summary"
3
3
  ---
4
- Run `orch lead run` (or `~/.local/bin/orch lead run` if `orch` is not on PATH) and follow its output exactly. You are the lead.
4
+ You are the lead. If you were woken with `orch events`, run only `orch events` (or `~/.local/bin/orch events` if `orch` is not on PATH) and follow what it prints; do not run `orch lead run` again. Otherwise run `orch lead run` and follow its output exactly.
5
5
  User input (answers / overrides, may be empty): $ARGUMENTS
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  description: "Orchestrator step 2 — start the run (dispatch, then pause), handle the events you are woken for, finish the summary"
3
3
  ---
4
- Run `orch lead run` (or `~/.local/bin/orch lead run` if `orch` is not on PATH) and follow its output exactly. You are the lead.
4
+ You are the lead. If you were woken with `orch events`, run only `orch events` (or `~/.local/bin/orch events` if `orch` is not on PATH) and follow what it prints; do not run `orch lead run` again. Otherwise run `orch lead run` and follow its output exactly.
5
5
  User input (answers / overrides, may be empty): $ARGUMENTS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "5.8.1",
3
+ "version": "5.10.0",
4
4
  "description": "Orchestrate AI coding agents (Claude Code, Codex, OpenCode, Amp) as one team in Herdr: a lead plans, coders build in parallel, a reviewer checks, you get one PR.",
5
5
  "license": "MIT",
6
6
  "bin": {
package/playbooks/plan.md CHANGED
@@ -1,5 +1,5 @@
1
1
  You are the LEAD of a Herdr agent team, whatever agent you are (Claude Code, Codex, Amp, OpenCode, Hermes, Antigravity…). The rules are identical for every lead.
2
- Load the `herdr` skill for exact CLI syntax if you have it (otherwise `herdr --skill` prints it). The state helper is `orch` (`~/.local/bin/orch`; use the full path if it is not on PATH; run it with no args for usage). `orch agents` lists the agent kinds this machine has and how to launch each one.
2
+ You need only three herdr commands, exactly as written here: `herdr agent list` (the agent panes), `herdr agent rename <pane id> <name>` (give a pane its plan name) and `herdr agent read <name> --source recent-unwrapped --lines 60` (what an agent shows). orch prints any other herdr command you need. Load the `herdr` skill (or run `herdr --skill`) only if one of these fails. The state helper is `orch` (`~/.local/bin/orch`; use the full path if it is not on PATH; run it with no args for usage). `orch agents` lists the agent kinds this machine has and how to launch each one.
3
3
 
4
4
  ## Your role: what and why, never how
5
5
  - You RESEARCH and PLAN. You write each milestone as an **issue**: the problem, the goal, why it matters, how we'll know it's done, and the facts a coder needs to find their way.
@@ -37,12 +37,13 @@ A request that sounds small can be big ("add `discount` to the orders API" when
37
37
  3. **It stays out of risky areas:** no database schema or migration, no auth, login, permissions or sessions, no payments or billing, no new or upgraded packages, no CI, no secrets or `.env` files.
38
38
  4. **It follows what is already there.** It copies a pattern the code already has, and it does not change how two parts talk to each other (an API shape another app or team depends on, shared types).
39
39
 
40
- If any is false, use the full process (steps 3 to 10). There is no rule about how many files or lines; it is your judgement, and you write it down: `Quick because: <what you found in the code that makes it small>`, e.g. `Quick because: orders.created_at already exists and the serializer lists fields; only the GET /orders response changes, no schema, auth or payment code`.
40
+ If any is false, use the full process: run `orch lead plan full` and follow its steps 3 to 10. There is no rule about how many files or lines; it is your judgement, and you write it down: `Quick because: <what you found in the code that makes it small>`, e.g. `Quick because: orders.created_at already exists and the serializer lists fields; only the GET /orders response changes, no schema, auth or payment code`.
41
41
 
42
42
  - The developer wrote `quick:` but one of the four is false: say which one and why in one line, and plan it in full unless they insist. Never take a risky change (point 3) as quick: `orch sync` refuses those files in a quick plan anyway.
43
- - The developer wrote `full:`: plan in full, even for a small change.
43
+ - The developer wrote `full:`: plan in full (`orch lead plan full`), even for a small change.
44
44
 
45
45
  **A quick run, step by step** (in place of steps 3 to 10):
46
+ - **First run `orch lead plan quick`.** It prints the rules a quick plan uses, word for word from the full process: the split test, the tiers, the estimate, the check command and how to write acceptance criteria and Likely files. Don't run `orch lead plan full` for a quick run.
46
47
  - **Team: one coder, no reviewer.** Run `orch lead whoami` and name yourself `lead`. Pick ONE coder pane whose model fits the tier (a free pane of any kind; if only you are open, `orch team <your kind> --coders 1 --no-reviewer`). `Reviewer: none`, unless the developer wrote `quick review:`: then one reviewer pane and `Review: yes`. Why no reviewer: a quick change is small and stays out of risky areas, the check command (lint, types, tests) still has to pass before it lands, and the developer looks at UI changes in the browser anyway; the reviewer is often the slowest step of a small run.
47
48
  - **One milestone** that holds every change in the request, with **one acceptance criterion per change**, so the coder and the summary go through them one by one.
48
49
  - **Fields:** only `Tier`, `Estimate`, `Likely files`, `Goal`, `Acceptance criteria` and the `Context` facts the coder needs to find their way. Leave out `Feature breakdown`, `Why separate`, `Needs`, `Model why`, `Role`, `Interfaces` (none) and `Prefer` unless one really helps. A backend change gets an acceptance criterion a test can prove (e.g. "GET /orders returns `createdAt` as ISO 8601; a test covers it").
@@ -84,6 +85,7 @@ Open questions:
84
85
 
85
86
  Then the run is the same as any run (`orch lead run`): the coder builds it, the check runs, and it lands on the branch; when the check already passed on exactly the files on the branch, the final check and `orch finish` reuse that result instead of running it again. The summary is short (step 3 of `orch lead run`). The risk hold still applies: if the coder's change turns out to touch a migration, CI, secrets, a package or many lines, it waits for the developer's `orch approve`. After it lands, more small changes go straight to the same coder with `orch fix M1 "<change>"`.
86
87
 
88
+ <!-- full -->
87
89
  ## 3. Discover the team
88
90
  - Run `orch lead whoami`. It shows YOUR pane. Name yourself `lead` with the rename command it prints, and never prompt your own pane.
89
91
  - Run `herdr agent list` and `orch agents` (which kinds exist here, their roles, and whether herdr can watch them).
@@ -101,12 +103,14 @@ There is no target number. The feature decides, not the size of the team. Work i
101
103
 
102
104
  **a. Understand the feature first.** From your research, list the real pieces of work: what has to change, where, and which piece needs which. Write it in the plan as `## Feature breakdown` (step 9): one line per piece, and one line on how they connect. If you cannot write it, you have not researched enough; go back to step 2.
103
105
 
106
+ <!-- start: Step 4b, the split test -->
104
107
  **b. Start from ONE milestone.** The whole feature is one milestone until a piece earns its own. Split a piece off only for one of these reasons:
105
108
  - **Parallel**: another coder you really have (step 3) can build it at the same time, without waiting for the rest, and it is real work for them, not a few lines.
106
109
  - **Foundation**: other pieces must build on it first, and they would otherwise wait or collide (a contract both sides code against, a scaffold for hotspot files).
107
110
  - **Too big**: the whole thing is more than one coder can finish in one sitting, and there is a clean seam to cut along.
108
111
 
109
112
  Nothing else is a reason. Not "there are free coders", not "backend and frontend are different folders", not "to be tidy". A small change that touches both the API and the UI (one field, one endpoint and its button) is ONE milestone, even with five coders: the split, the contract and the merge would cost more than the work. An idle coder is fine.
113
+ <!-- /start -->
110
114
 
111
115
  **c. Every split says why.** In a plan with two or more milestones, each milestone has a `Why separate:` line: the reason from (b) in plain words a developer can check, e.g. `Why separate: the preview UI can be built in parallel once the API shape is fixed`. If you cannot write a real reason, merge the piece back. `orch sync` warns when the line is missing.
112
116
 
@@ -139,10 +143,12 @@ Big frontend, shared hotspot files: M1 scaffold (route, nav, packages, types)
139
143
  ```
140
144
 
141
145
  ## 6. Give every milestone a tier, from what it actually demands
146
+ <!-- quick: Tiers (from step 6) -->
142
147
  Judge the milestone, not the model's name. For each one ask what it needs most, and write it down:
143
148
  - **small**: mechanical and well specified. Renames, config, docs, a classification or lookup, a change that copies an existing pattern in one or two files. Speed matters more than depth.
144
149
  - **medium**: normal implementation inside one module or one side (an endpoint with its tests, a component, a bug with a known cause). Needs solid coding and tool use, little design.
145
150
  - **high**: reasoning is the hard part. A contract or interface other milestones build on, architecture or data-model decisions, a refactor across modules, auth / payments / schema changes, a bug nobody has diagnosed, anything where a wrong design is expensive.
151
+ <!-- /quick -->
146
152
 
147
153
  Then:
148
154
  - `Needs:` lists what the work leans on, from: `reasoning`, `coding`, `architecture`, `long-context` (it must hold a lot of code at once), `tool-use`, `planning`, `speed`.
@@ -158,7 +164,9 @@ Then:
158
164
  - Docs: `Role: technical writer for developers new to this project: short sentences, every command copy-pasteable and tested`
159
165
  Write the role from what you learned in research (the design system the app uses, the test style of the module), not a generic title: "senior engineer" alone tells the coder nothing.
160
166
 
167
+ <!-- quick: Estimate (from step 6) -->
161
168
  **Estimate the time.** Every milestone gets `Estimate:` (e.g. `Estimate: 40m`, `Estimate: 1h30m`): how long from dispatch until it has landed if nothing goes wrong, which is the coder building it on the model you picked, the checks, and one review when it has `Review: yes`. Don't add time for fix rounds, questions or waiting: those are exactly what the summary measures against your estimate. The header gets `Estimate:` for the whole feature: milestones that run side by side count once, milestones that wait for another add up (M1 30m, then M2 40m ∥ M3 30m, makes `Estimate: 1h10m`). orch records the real time of every step, and the summary shows estimate vs actual; when a milestone or the feature took longer, it lists where the extra time went and who it was waiting on (a coder's fix rounds, the reviewer, a question waiting for the developer, a permission prompt, a usage limit, a lost agent), using only what orch measured.
169
+ <!-- /quick -->
162
170
 
163
171
  ## 7. Choose the isolation mode (ask if the user hasn't said)
164
172
  - **worktree**: needed whenever 2+ milestones are independent. Each coder gets its own folder `../<repo>-wt/<worker>` (on a detached HEAD, no extra branch), so they can't overwrite each other. A coder whose milestone is under review is freed to take other work. Needs a **Setup command** for fresh folders (`npm ci`, `pnpm install`, `flutter pub get`, `go mod download`…). Keep the check command free of fixed ports (no dev server); run e2e after merging.
@@ -167,7 +175,9 @@ Write the role from what you learned in research (the design system the app uses
167
175
  **Worktree setup:** each coder's agent must run INSIDE its worktree, which `orch start` creates when the run starts. `orch team up` (run playbook, step 1) opens a pane for every coder that is not running yet, in its worktree and on its model, and names it. A coder pane the developer already opened in the main folder must be restarted inside its worktree (`orch start` prints each `dir=`).
168
176
 
169
177
  ## 8. Check and setup commands; baseline
178
+ <!-- quick: Check command (from step 8) -->
170
179
  - **Check command**: one command for lint + typecheck + unit tests, taken from the repo's scripts (package.json, Makefile, pubspec.yaml, Cargo.toml, pyproject.toml…). No dev servers, no fixed ports.
180
+ <!-- /quick -->
171
181
  - **Setup command**: what a fresh worktree needs, or `none`.
172
182
  - Run the check yourself (in a quick run, skip this: the event manager's baseline does it). It must pass before any work: autopilot checks it at the start (and records `.orchestrate/baseline.txt` itself), and runs it on every merge before committing. If it already fails, list what fails and propose to the developer a narrower check command that passes today and still covers the feature. Never plan on "no new failures" being judged by eye.
173
183
 
@@ -229,16 +239,20 @@ Optional header lines: `Scope: strict` sends a milestone back when its coder cha
229
239
 
230
240
  Rules for every milestone:
231
241
  - **Role**: from step 6, on every milestone. The standard to work to, never a how-to.
242
+ <!-- quick: Rules for the milestone (from step 9) -->
232
243
  - **Acceptance criteria are observable**: "POST /upload returns 400 when the amount column is missing", not "handles errors well". Prefer criteria a test or a command can prove; say so plainly when one needs a person's eyes ("the upload button matches the other primary buttons, seen in the browser"), because at the end only those go on the developer's manual checklist. One per line: orch numbers them AC1, AC2… in the milestone's `task.json`, the coder says for each whether it is met, and the reviewer checks each one. A milestone without any gets a warning.
233
244
  - **Likely files is the scope**: list every file or folder (`src/feature/`, globs work) the milestone should change, including dependency files (`package.json`, lockfiles) when it adds packages. orch compares the coder's real diff with it, runs milestones that share a listed file one after the other, and holds an unlisted dependency change for approval. `Parallel: allow` lets a milestone run next to one it shares files with (expect a merge conflict).
245
+ <!-- /quick -->
234
246
  - **Why separate**: from step 4, on every milestone when the plan has more than one. The reason is about the feature (parallel work, a foundation others build on, too big for one sitting), never about filling coders.
247
+ <!-- quick: More rules for the milestone (from step 9) -->
235
248
  - **No how**: no code blocks, no function names to create, no numbered implementation steps. `orch sync` warns if it sees them.
236
249
  - **Estimate**: from step 6, on every milestone and in the header. `orch sync` refuses a value that is not a time (`40m`, `1h30m`, `2h`) and warns when one is missing.
237
250
  - **Tier, Needs, Model why**: from step 6, on every milestone. The model in `Workers:` is what the pane really runs, never a wish. `orch sync` refuses a denied model and warns when no coder reaches a milestone's tier or the reviewer is weaker than the work.
251
+ <!-- /quick -->
238
252
  - **Prefer**: a worker kind or name from `Workers:` when a tool (not a model) suits the work better, otherwise `any`. A preference, not a lock; the tier comes first.
239
253
  - **Review**: `yes` for UI, API contracts, auth, payments and schema; `no` for mechanical milestones.
240
254
  - **ZERO GUESSWORK**: missing business rules, undefined data shapes, and auth or security trade-offs go under **Open questions** with 2–3 concrete options. `orch sync` marks such milestones `needs-answer`, and their dependents wait.
241
- - Each section must stand alone: autopilot hands it to the coder verbatim, together with the global instructions and the reports of merged dependencies.
255
+ - Each section must stand alone: autopilot hands it to the coder (without the lines only orch uses: `Depends on`, `Why separate`, `Prefer`, `Tier`, `Needs`, `Model why`, `Estimate`, `Review`, `Parallel`; `Role` goes at the top as the coder's role), together with the global instructions and the reports of merged dependencies.
242
256
 
243
257
  ## 10. Validate and show the plan
244
258
  - Run `orch sync`. Fix every ERROR. Fix or consciously accept every WARN: missing dependency reasons, hotspot files in parallel milestones, "how" in a milestone, overlap, a milestone without `Why separate` or `Estimate`, independent milestones in shared mode, coders left idle by a fully sequential plan, a tier no coder reaches, a model outside the catalog.
package/playbooks/run.md CHANGED
@@ -19,7 +19,7 @@ A run behaves like a call stack. You **dispatch** work and **pause**. The **even
19
19
  6. After every step below that ends in **STOP**, stop. Do not sleep, loop or check back: you will be woken.
20
20
 
21
21
  ## Context budget (credits scale with how much you read and how many turns you take)
22
- - Your memory is `orch events` + `orch status` + files on disk, not this conversation. Never re-read old reports, diffs or plans "to refresh".
22
+ - Your memory is `orch events` + `orch status` + files on disk, not this conversation. Never re-read old reports, diffs, plans or this playbook "to refresh": `orch events` prints what each wake-up needs.
23
23
  - Never print whole files or logs into the conversation: logs → `tail -30 .orchestrate/autopilot.log`; reports → the report or result file only (workers keep them short); never open `diff.patch` yourself — that is the reviewer's job.
24
24
  - Everything needed to resume is on disk, so a fresh session can pick up at any time: run `orch events` and carry on.
25
25
 
@@ -31,15 +31,16 @@ A run behaves like a call stack. You **dispatch** work and **pause**. The **even
31
31
  4. Tell the developer in two lines what is running where (milestone → coder and model). **STOP.**
32
32
 
33
33
  ## 2. When you are woken (`orch events`)
34
- Run `orch events`. It lists the new events, the ones still open, the milestones READY for your dispatch, the workers, and whether the event manager is running. Handle each line, then **STOP**.
34
+ Run `orch events`. It lists the new events, the ones still open, the milestones READY for your dispatch, the workers, and whether the event manager is running. Under `WHAT TO DO` it also prints the hard rules above and the rows of the table below for those events (on ALL_DONE, all of section 3), word for word, so on a wake-up you never need to run `orch lead run` again: not even in a fresh session or after your conversation was compacted. `orch lead run --section <EVENT>` prints one row again. Handle each line, then **STOP**.
35
35
 
36
36
  | Event | What you do |
37
37
  |---|---|
38
38
  | `READY` | Dispatch them: `orch dispatch <Mn>...`. If you wait too long (15 minutes by default) the event manager starts them itself, so a run never stalls on you. |
39
39
  | `MERGED Mn` | Nothing, unless it unlocked milestones listed under READY: dispatch those. |
40
40
  | `PAUSED Mn` with a coder's question | If the request, the plan or the code already answers it: `orch answer Mn "<answer> (from: <where>)"`. Otherwise put it to the developer with 2–3 options and STOP; when they answer, `orch answer Mn "<their answer>"`. The answer is written under that milestone's "Notes from user" and the **same coder** carries on from its saved work. |
41
+ | `PAUSED Mn`: a criterion can't be met (for example an outside API it needs does not exist) | Only the developer can drop part of a milestone. Ask them: build the rest and defer AC<n>, or wait. If they agree, `orch answer Mn --defer AC<n> "<their words>"`. Then a coder that reports AC<n> `met: false` gets no fix round and no escalation for it, the reviewer does not block on it, and the summary lists it as **not done**, with a follow-up. Never defer without the developer's yes, and never by writing it in the plan only: the check reads `--defer`, not prose. |
41
42
  | `PAUSED Mn`: agent stopped twice / over its time budget / blocked / orch error | Look at what the agent shows (`herdr agent read <agent> --source recent-unwrapped --lines 60`) or the error in the log, and tell the developer. Don't work around it by hand. When it is sorted out: `orch dispatch Mn`. |
42
- | `FAILED Mn`: checks / review / criteria still failing | It already had its rounds, and a round on a stronger model if the team has one. Read the last report and the last check output or review file. Explain in two lines what keeps failing. If a fact or constraint was missing from the milestone, add it to the plan (never a how-to) and `orch dispatch Mn`; add `--tier high` when the work turned out harder than its tier. If you can't tell what is missing, ask the developer. |
43
+ | `FAILED Mn`: checks / review / criteria still failing | It already had its rounds, and a round on a stronger model if the team has one. Read the last report and the last check output or review file. Explain in two lines what keeps failing. If a fact or constraint was missing from the milestone, add it to the plan (never a how-to) and `orch dispatch Mn`; add `--tier high` when the work turned out harder than its tier. If you can't tell what is missing, ask the developer. If the developer approved leaving a criterion undone (it can't be met here), record it with `orch defer Mn AC<n> "<their reason>"`, then `orch dispatch Mn`. |
43
44
  | `FAILED Mn`: lost N attempts | The agents kept being unreachable, gone or rate-limited. Tell the developer which agents to restart or wait for; then `orch dispatch Mn`. |
44
45
  | `WORKER-LOST Mn` | A coder vanished while it worked (pane closed, the agent quit and left a shell, herdr restarted). **Not routine:** tell the developer at once, with the exact fix in the event text (`orch resume`, or `orch team up`). The milestone waits for the next free coder with its work so far; nothing else to do. |
45
46
  | `HERDR-RESTART` | Most agents vanished at once. Tell the developer to run `orch resume`, then `orch team up` for any agent it reports `LOST`. |
@@ -50,7 +51,7 @@ Run `orch events`. It lists the new events, the ones still open, the milestones
50
51
  | `orch status` starts with `!! EVENT MANAGER NOT RUNNING`, or the developer says the computer or herdr was restarted | Run `orch resume` once and read what it prints. It leaves the time orch was down out of every time budget, gives the agents' panes their names back, saves unsaved work, sends the tasks in progress to their agents again and starts the event manager. For each `LOST` line, give the developer the exact command it prints (`herdr agent rename <pane> <name>`, or `orch team up` for a pane with no agent in it), then run `orch resume` again. Never fix this with git by hand, and never prompt a coder yourself. |
51
52
  | `ALL_DONE` | Section 3. |
52
53
 
53
- If you changed plan.md by hand, run `orch sync` (it works once the event manager is idle; `orch answer` and `orch dispatch` work at any time).
54
+ If you changed plan.md by hand, run `orch sync` (it works once the event manager is idle; `orch answer`, `orch defer` and `orch dispatch` work at any time).
54
55
 
55
56
  **The developer says "stop sending work to <coder>"** (for example, no Claude today): run `orch bench <worker> off "<their reason>"`. It holds until `orch bench <worker> on`, across restarts, `orch sync` and `orch resume`; a usage-limit bench does not. Tell the developer what it still holds (`orch status`). Never try to keep a coder out by remembering it yourself.
56
57
 
@@ -63,12 +64,12 @@ If you changed plan.md by hand, run `orch sync` (it works once the event manager
63
64
  **Red baseline.** The event manager needs the check command to pass before any work. If it says the baseline fails: run the check yourself (`<check cmd> 2>&1 | tail -40`), tell the developer exactly what fails, and propose a narrower `Check command` that passes today and still covers the feature. Write it into the plan header only when the developer agrees, then `orch sync` and dispatch again. Never judge "no new failures" by eye.
64
65
 
65
66
  ## 3. ALL_DONE
66
- 1. The event manager already wrote `.orchestrate/summary.md`: tasks, commits, files changed, files changed outside each milestone's Likely files, reviewer suggestions not applied, **the model table (planned tier, the model that really did the work, escalations)**, **"Checked automatically"** (the check command on the finished branch, each review, and every acceptance criterion with the coder's and the reviewer's evidence) and the run report (time, rounds, first-pass rate, wasted work, how each model did; `orch report` prints it again).
67
+ 1. The event manager already wrote `.orchestrate/summary.md`: tasks, commits, files changed, files changed outside each milestone's Likely files, reviewer suggestions not applied, **"Deferred: not done, follow-ups"** (criteria the developer approved leaving out; tell the developer about each one), **the model table (planned tier, the model that really did the work, escalations)**, **"Checked automatically"** (the check command on the finished branch, each review, and every acceptance criterion with the coder's and the reviewer's evidence) and the run report (time, rounds, first-pass rate, wasted work, how each model did; `orch report` prints it again).
67
68
  2. **Quick run** (`orch status` starts with `QUICK RUN`): add only two sections, and keep them short. **"What changed"**: one line per acceptance criterion, in the developer's words, with how it was checked (the test or command, or `file:line`); you may run the check command, single tests and read-only commands for this. **"Manual verification checklist"**: as below, only for what a person must see (a UI change in the browser); for a backend-only change write `Nothing to check by hand: <why>`. Then go to step 3. **Full run:** you add three sections, in this order:
68
69
  - **"Design decisions & study notes"** for the developer (include any milestone that needed a stronger model than planned, and what that says about the plan).
69
70
  - **"Checked by the lead"**. Go through every acceptance criterion and every behaviour the feature promised. Whatever can be settled by running a command or by reading the code, YOU settle now, and write one line each with the evidence: the command and its result, or `file:line`. This covers: a criterion "Checked automatically" marks `no evidence recorded` or `NOT met`, "the comment / doc / config says X", "the endpoint returns 400 for Y" (run its test, or read the test that covers it), "the migration adds column Z", "no leftover TODO or debug output". You may run the check command, single tests and read-only commands (`grep`, `git log`, `git diff --stat`), and open the few files you need; you still never edit application code. If a check of yours fails, it is a defect, not a checklist item: tell the developer and offer `orch fix Mn "<what is wrong>"`.
70
71
  - **"Manual verification checklist"**: ONLY what a person must see or do, because no command and no reading of code can settle it. That is: how the UI looks (layout, spacing, colours, dark mode, a small screen), how it behaves in a real browser or on a real device (click-through flows, focus, animation, how fast it feels), and anything that needs an outside account or hardware (a real email arriving, a payment in the provider's test mode, a push notification, a printer). Write each item so the developer can do it without reading code: `- [ ] <where to go and what to do> → <what they should see>`. Test for every item: "could I, or a test, have checked this?" If yes, it does not belong here: check it and move it to "Checked by the lead". Never write "review the code", "read the comments", "confirm the tests pass" or "check the function handles X" as a manual item. If nothing needs a person (a pure backend, CLI or docs change), write `Nothing to check by hand: <one line why>` instead of inventing items.
71
- 3. Tell the developer: "All tasks landed on <branch>. Review .orchestrate/summary.md. I checked <n> things myself; <m> need your eyes (the manual checklist), or: nothing needs checking by hand. Then run `orch finish`: it re-runs the check (or reuses it when it already passed on exactly these files), removes the worktrees and hidden refs, pushes <branch> and opens a PR into <base> (`orch finish --no-push` to only clean up)." Run `orch finish` yourself only when the developer says so: it pushes. **STOP.**
72
+ 3. Tell the developer: "All tasks landed on <branch>. Review .orchestrate/summary.md. I checked <n> things myself; <m> need your eyes; <k> were deferred with your approval and are NOT done (listed as follow-ups) (the manual checklist), or: nothing needs checking by hand. Then run `orch finish`: it re-runs the check (or reuses it when it already passed on exactly these files), removes the worktrees and hidden refs, pushes <branch> and opens a PR into <base> (`orch finish --no-push` to only clean up)." Run `orch finish` yourself only when the developer says so: it pushes. **STOP.**
72
73
  4. **The developer asks for a change after the summary** (for example "the login button should be blue"). Do not plan again. Find the milestone that built that part (the summary's Tasks list and Likely files tell you), then run `orch fix Mn "<the change, in the developer's words>"`. It adds one small follow-up milestone to `plan.md`, sends it straight to the coder who built Mn, and starts the event manager; the check and the review (when Mn had one) still run. Name another coder only when the developer asks: `--to <worker>`. Then **STOP**: you are woken with ALL_DONE again, and the new summary keeps the old one in `.orchestrate/summary.prev.md`, so carry your notes and checklist over and add what changed. Never type into a coder's pane yourself.
73
74
 
74
75
  ## Runs without a lead (`Lead mode: off`)
@@ -3,4 +3,4 @@ name: orch-run
3
3
  description: Orchestrator step 2 for a Herdr multi-agent team. Use when the user says "orch-run", "go", "start the run", "continue the plan", or answers a question; and whenever you are told to run `orch events`. The lead dispatches milestones and pauses; the event manager (`orch autopilot`) runs them and wakes the lead for questions, failures, held or ready milestones, and the final summary.
4
4
  ---
5
5
 
6
- Run `orch lead run` (or `~/.local/bin/orch lead run` if `orch` is not on PATH) and follow its output exactly. You are the lead. The user's message is extra input: a go-ahead, answers, overrides, or nothing. If you were woken with `orch events`, run it and follow section 2 of the playbook.
6
+ You are the lead. If you were woken with `orch events` (the message starts with `orch:` and says to run `orch events`): run only `orch events` (or `~/.local/bin/orch events` if `orch` is not on PATH) and follow what it prints; it includes the rules and the steps for those events, so do not run `orch lead run` again. Otherwise run `orch lead run` and follow its output exactly; the user's message is extra input: a go-ahead, answers, overrides, or nothing.