herdr-orchestra 5.8.1 → 5.9.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,21 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [5.9.0] - 2026-11-17
6
+
7
+ 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.
8
+
9
+ ### Added
10
+ - **`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`).
11
+ - 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`.
12
+ - 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.
13
+
14
+ ### Changed
15
+ - 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.
16
+ - 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.
17
+ - 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.
18
+ - Lead playbook, README and website docs (Commands, When a run needs you, Questions and how-tos) explain deferring.
19
+
5
20
  ## [5.8.1] - 2026-11-16
6
21
 
7
22
  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).
@@ -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.9.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,6 +3115,7 @@ 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
 
@@ -3143,7 +3154,10 @@ def cmd_write_task(args):
3143
3154
  contract = task_contract(st, tid)
3144
3155
  if contract["acceptance_criteria"]:
3145
3156
  parts += ["## Acceptance criteria ids (for your result file)",
3146
- *[f"- {c['id']}: {c['text']}" for c in contract["acceptance_criteria"]], ""]
3157
+ *[f"- {c['id']}: {c['text']}" + (f" — DEFERRED by the developer: don't build it in this milestone, "
3158
+ f"report it `met: false` (why: {c['deferred']['reason']})"
3159
+ if c.get("deferred") else "")
3160
+ for c in contract["acceptance_criteria"]], ""]
3147
3161
  if contract["previous_work"]:
3148
3162
  parts += ["## Earlier work", f"An earlier attempt ({contract['previous_work']['by'] or 'another coder'}) left "
3149
3163
  "work in this folder. Look at it first and continue from it unless it is wrong.", ""]
@@ -3173,7 +3187,11 @@ def task_contract(st, tid):
3173
3187
  return {
3174
3188
  "schema": 1, "task_id": tid, "title": t["title"], "kind": "task",
3175
3189
  "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)],
3190
+ "acceptance_criteria": [{"id": f"AC{i}", "text": c,
3191
+ **({"deferred": {"approved_by": "developer",
3192
+ "reason": deferred_of(t)[f"AC{i}"].get("reason", "")}}
3193
+ if f"AC{i}" in deferred_of(t) else {})}
3194
+ for i, c in enumerate(items("acceptance criteria"), 1)],
3177
3195
  "files_allowed": t.get("files") or [], "scope": st.get("scope", "warn"),
3178
3196
  "tier": t.get("tier"), "needs": t.get("needs") or [], "role": t.get("role") or None,
3179
3197
  "interfaces": items("interfaces"), "constraints": items("constraints"), "out_of_scope": items("out of scope"),
@@ -3251,6 +3269,7 @@ def cmd_dispatch(args):
3251
3269
  for tid in args:
3252
3270
  t = st["tasks"][tid]
3253
3271
  t["go"] = True
3272
+ t["go_ts"] = now()
3254
3273
  t.pop("ready_ts", None)
3255
3274
  if opts.get("--to"):
3256
3275
  t["assign"] = opts["--to"]
@@ -3277,10 +3296,111 @@ def cmd_dispatch(args):
3277
3296
  NOTES_RE = re.compile(r"(?mi)^Notes from user:[ \t]*")
3278
3297
 
3279
3298
 
3299
+ def plan_criteria(tid):
3300
+ """[(AC id, text)] of a milestone's acceptance criteria in plan.md, numbered the way task.json numbers them."""
3301
+ try:
3302
+ _, ptasks = parse_plan((ORCH / "plan.md").read_text())
3303
+ except OSError:
3304
+ return []
3305
+ pt = next((x for x in ptasks if x["id"] == tid), {"fields": {}})
3306
+ vals = [v.lstrip("- ").strip() for v in pt["fields"].get("acceptance criteria", [])]
3307
+ return [(f"AC{i}", v) for i, v in enumerate([v for v in vals if v and v.lower() != "none"], 1)]
3308
+
3309
+
3310
+ def deferred_of(t):
3311
+ """{AC id: {"text", "reason", "ts"}}: criteria the developer approved leaving undone in this milestone."""
3312
+ d = t.get("deferred")
3313
+ return d if isinstance(d, dict) else {}
3314
+
3315
+
3316
+ def parse_defer_ids(tid, raw):
3317
+ """'AC2,AC3' (or 'ac2 3') -> ['AC2', 'AC3'], each checked against the milestone's criteria in plan.md."""
3318
+ crit = dict(plan_criteria(tid))
3319
+ ids = []
3320
+ for p in re.split(r"[,\s]+", raw.strip()):
3321
+ if not p:
3322
+ continue
3323
+ cid = "AC" + p[2:] if p.upper().startswith("AC") else "AC" + p
3324
+ if cid not in crit:
3325
+ die(f"{tid} has no acceptance criterion {p!r} — its criteria: "
3326
+ + (", ".join(f"{k} ({v[:40]})" for k, v in crit.items()) or "none in plan.md"))
3327
+ if cid not in ids:
3328
+ ids.append(cid)
3329
+ return ids or die("name the criteria to defer, for example AC2 or AC2,AC3")
3330
+
3331
+
3332
+ def record_deferral(t, tid, ids, reason):
3333
+ """Remember, with the developer's reason, that these criteria are approved to stay undone in this milestone."""
3334
+ crit = dict(plan_criteria(tid))
3335
+ d = dict(deferred_of(t))
3336
+ for cid in ids:
3337
+ d[cid] = {"text": crit.get(cid, ""), "reason": reason, "ts": now()}
3338
+ t["deferred"] = d
3339
+
3340
+
3341
+ def add_plan_note(tid, text):
3342
+ """Add `- text` under the milestone's "Notes from user" in plan.md (the line is created when missing)."""
3343
+ plan = ORCH / "plan.md"
3344
+ lines, out, cur, done = plan.read_text().split("\n"), [], None, False
3345
+ note = f"- {text}"
3346
+ for line in lines:
3347
+ m = HEAD_RE.match(line)
3348
+ if (m or line.startswith("## ")) and cur == tid and not done: # section ended without a notes line
3349
+ while out and not out[-1].strip():
3350
+ out.pop()
3351
+ out += ["Notes from user:", note, ""]
3352
+ done = True
3353
+ if m or line.startswith("## "):
3354
+ cur = m.group(2) if m else None
3355
+ out.append(line)
3356
+ if cur == tid and not done and NOTES_RE.match(line):
3357
+ out.append(note)
3358
+ done = True
3359
+ if not done:
3360
+ if cur != tid:
3361
+ die(f"{tid} not found in plan.md")
3362
+ while out and not out[-1].strip():
3363
+ out.pop()
3364
+ out += ["Notes from user:", note, ""]
3365
+ plan.write_text("\n".join(out))
3366
+
3367
+
3368
+ def defer_note(t, ids, reason):
3369
+ return ("Deferred with the developer's approval (NOT built in this milestone, a follow-up): "
3370
+ + "; ".join(f"{c} \"{deferred_of(t).get(c, {}).get('text', '')}\"" for c in ids) + f". Why: {reason}")
3371
+
3372
+
3373
+ def cmd_defer(args):
3374
+ """orch defer Mn AC2[,AC3] <the developer's reason> -> the developer approved leaving these criteria undone in
3375
+ Mn. A coder that reports them `met: false` gets no fix round for them (so no escalation either), the reviewer
3376
+ does not block on them, and the summary lists them as NOT done, with a follow-up. Only with the developer's yes."""
3377
+ need(args, 3, "defer <Mn> <AC ids, e.g. AC2,AC3> <the developer's reason>")
3378
+ tid, raw, reason = args[0], args[1], " ".join(" ".join(args[2:]).split())
3379
+ with state_lock():
3380
+ st = load()
3381
+ t = task(st, tid)
3382
+ if t["status"] in ("merged", "skipped"):
3383
+ die(f"{tid} is {t['status']} — nothing left to defer (a later change: `orch fix {tid} \"<text>\"`)")
3384
+ ids = parse_defer_ids(tid, raw)
3385
+ record_deferral(t, tid, ids, reason)
3386
+ add_plan_note(tid, defer_note(t, ids, reason))
3387
+ save(st)
3388
+ print(f"DEFERRED {tid} {','.join(ids)}: no fix rounds for them; the summary lists them as not done "
3389
+ f"(follow-up). Why: {reason}")
3390
+ if t["status"] in ("paused", "failed"):
3391
+ print(f"NEXT {tid} is {t['status']}: `orch dispatch {tid}` sends it on with the rest of its criteria")
3392
+
3393
+
3280
3394
  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>")
3395
+ """orch answer Mn [--defer AC2,AC3] <the developer's answer> -> write it under the milestone's "Notes from user"
3396
+ in plan.md and send the milestone back to the SAME coder, which carries on from its saved work. --defer also
3397
+ records that the developer approved leaving those criteria undone (see `orch defer`)."""
3398
+ defer = None
3399
+ if "--defer" in args:
3400
+ i = args.index("--defer")
3401
+ defer = args[i + 1] if len(args) > i + 1 else die("--defer needs criteria ids, for example AC2 or AC2,AC3")
3402
+ del args[i:i + 2]
3403
+ need(args, 2, "answer <Mn> [--defer AC2,AC3] <answer text>")
3284
3404
  tid, text = args[0], " ".join(args[1:]).strip()
3285
3405
  with state_lock():
3286
3406
  st = load()
@@ -3288,37 +3408,23 @@ def cmd_answer(args):
3288
3408
  if t["status"] != "paused":
3289
3409
  die(f"{tid} is {t['status']}, not paused" + (
3290
3410
  " — 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))
3411
+ "`- none`, then `orch sync`" if t["status"] == "needs-answer" else "")
3412
+ + (f" (to record the approved deferral anyway: `orch defer {tid} {defer} \"<reason>\"`)" if defer else ""))
3413
+ ids = parse_defer_ids(tid, defer) if defer else []
3414
+ add_plan_note(tid, text)
3415
+ if ids:
3416
+ record_deferral(t, tid, ids, text)
3417
+ add_plan_note(tid, defer_note(t, ids, text))
3315
3418
  last = t.get("last_worker")
3316
3419
  t["go"] = True
3420
+ t["go_ts"] = now()
3317
3421
  if last in st["workers"]:
3318
3422
  t["assign"] = last
3319
- t.setdefault("answers", []).append({"ts": now(), "text": text})
3423
+ t.setdefault("answers", []).append({"ts": now(), "text": text, **({"deferred": ids} if ids else {})})
3320
3424
  _park(st, tid, "pending", f"answered: {text[:200]}")
3321
3425
  print(f"ANSWERED {tid}: written to plan.md; it goes back to {last or 'the next free coder'} with its work so far")
3426
+ if ids:
3427
+ print(f"DEFERRED {tid} {','.join(ids)}: no fix rounds for them; the summary lists them as not done (follow-up)")
3322
3428
  print(start_manager())
3323
3429
  print("You will be woken with `orch events` when something needs you. Stop here; do not poll.")
3324
3430
 
@@ -3389,11 +3495,11 @@ def cmd_fix(args):
3389
3495
 
3390
3496
  EVENT_HELP = {
3391
3497
  "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 "
3498
+ "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
3499
  "`orch dispatch {t}`.",
3394
3500
  "failed": "still failing after its rounds. Read the last report and check or review output, add the missing "
3395
3501
  "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).",
3502
+ "`--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
3503
  "held": "risky changes wait for the developer: show them the reasons; they run `orch approve {t}`. Never approve it yourself.",
3398
3504
  "needs-answer": "open questions in plan.md: ask the developer, write the answers under \"Notes from user\", set "
3399
3505
  "\"Open questions:\" to `- none`, `orch sync`, then `orch dispatch {t}`.",
@@ -3460,6 +3566,8 @@ def cmd_events(args):
3460
3566
  if not peek and new:
3461
3567
  for e in new:
3462
3568
  e["read"] = now()
3569
+ if st.get("lead_wake"):
3570
+ st["lead_wake"]["read_ts"] = now() # for the event manager's timing line
3463
3571
  save(st)
3464
3572
 
3465
3573
 
@@ -3538,11 +3646,35 @@ def auto_checked(st, final_ok):
3538
3646
  ev.append(f"coder: {'met' if c['met'] else 'NOT met'}" + (f" ({c['evidence']})" if c.get("evidence") else ""))
3539
3647
  if r and r.get("met") is not None:
3540
3648
  ev.append(f"reviewer: {'met' if r['met'] else 'NOT met'}" + (f" ({r['note']})" if r.get("note") else ""))
3649
+ dv = deferred_of(t).get(cid)
3650
+ if dv and not (c and c.get("met")):
3651
+ out.append(f" - {cid} {text} — DEFERRED, NOT done (approved by the developer: {dv.get('reason', '')}). "
3652
+ f"See \"Deferred: not done, follow-ups\"")
3653
+ continue
3541
3654
  out.append(f" - {cid} {text} — " + ("; ".join(ev) if ev else "no evidence recorded: the lead checks it, "
3542
3655
  "or it goes on the manual list"))
3543
3656
  return "\n".join(out)
3544
3657
 
3545
3658
 
3659
+ def deferred_lines(st):
3660
+ """The summary's list of criteria the developer approved leaving undone: each is NOT done and needs a follow-up.
3661
+ A deferred criterion the coder reports as met after all is left out (it was done)."""
3662
+ out = []
3663
+ for tid in st["order"]:
3664
+ t = st["tasks"][tid]
3665
+ dfr = deferred_of(t)
3666
+ if not dfr:
3667
+ continue
3668
+ res, _ = read_result(t.get("last_result"))
3669
+ met = {str(c.get("id")) for c in (res or {}).get("criteria", []) if isinstance(c, dict) and c.get("met")}
3670
+ for cid, v in dfr.items():
3671
+ if cid in met:
3672
+ continue
3673
+ out.append(f"- {tid} {cid} \"{v.get('text', '')}\": NOT done. Approved by the developer: "
3674
+ f"{v.get('reason', '')}. Follow-up: when it can be built, `orch fix {tid} \"{v.get('text', '')}\"`")
3675
+ return out
3676
+
3677
+
3546
3678
  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
3679
  re.I)
3548
3680
 
@@ -3730,7 +3862,10 @@ def _autopilot(args):
3730
3862
  if not un:
3731
3863
  if lw.get("n") and not lw.get("ack"):
3732
3864
  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")
3865
+ rt, first = lw.get("read_ts"), lw.get("first_ts") or lw.get("ts")
3866
+ say(f"the lead ({lead}) picked up its events" + (
3867
+ f" (read {max(0, rt - first)}s after the first wake-up, {max(0, rt - lw['oldest'])}s after the "
3868
+ f"oldest event; seen here {max(0, now() - rt)}s later)" if rt and first and lw.get("oldest") else ""))
3734
3869
  return
3735
3870
  newest = max(e["id"] for e in un)
3736
3871
  # a wake the lead has not acted on yet covers newer events too: it reads the whole queue when it comes
@@ -3765,14 +3900,18 @@ def _autopilot(args):
3765
3900
  patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": n, "wait": SEND_RETRY_S}))
3766
3901
  return
3767
3902
  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}))
3903
+ oldest = min(e["ts"] for e in un)
3904
+ first_ts = lw.get("first_ts", lw.get("ts")) if n else now()
3905
+ patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": n + 1, "wait": wait,
3906
+ "first_ts": first_ts, "oldest": oldest}))
3769
3907
  what = ", ".join(f"{e['kind']}{' ' + e['task'] if e.get('task') else ''}" for e in un[:6])
3770
3908
  if n:
3771
3909
  say(f"the lead ({lead}) did not pick up its wake-up (" + ("idle again, " if watch else "")
3772
3910
  + f"events still unread after {now() - lw.get('ts', now())}s) -> sent it again "
3773
3911
  f"({n + 1} of {LEAD_MAX_WAKES}): {len(un)} event(s) — {what}")
3774
3912
  else:
3775
- say(f"woke the lead ({lead}): {len(un)} event(s) — {what} (sent; it counts once the lead reads them)")
3913
+ say(f"woke the lead ({lead}): {len(un)} event(s) — {what} (sent; it counts once the lead reads them; "
3914
+ f"oldest event {max(0, now() - oldest)}s old)")
3776
3915
 
3777
3916
  def lead_ready():
3778
3917
  """Ready milestones the lead has not dispatched: tell it once per set; start them ourselves after LEAD_WAIT_S."""
@@ -3919,13 +4058,26 @@ def _autopilot(args):
3919
4058
  hot = [f for f in new if HOTSPOT_RE.search(f)]
3920
4059
  say(f"{tid} changed files outside its Likely files: {', '.join(new)}" +
3921
4060
  (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]
4061
+ # a criterion the developer approved leaving undone (`orch defer`, `orch answer --defer`) is not a failure:
4062
+ # no fix round, no escalation; the summary lists it as not done, with a follow-up
4063
+ dfr = deferred_of(load()["tasks"][tid])
4064
+ unmet_all = [c for c in (res or {}).get("criteria", []) if c.get("met") is False]
4065
+ unmet = [c for c in unmet_all if str(c.get("id")) not in dfr]
4066
+ skipped = [str(c["id"]) for c in unmet_all if str(c.get("id")) in dfr]
4067
+ if skipped:
4068
+ say(f"{tid}: {', '.join(skipped)} not met, deferred with the developer's approval -> no fix round for "
4069
+ f"{'it' if len(skipped) == 1 else 'them'} (listed as not done in the summary)")
3923
4070
  if unmet:
3924
4071
  say(f"{tid}: the coder reports {', '.join(str(c['id']) for c in unmet)} not met -> fix round")
3925
4072
  fix_round(tid, "criteria-fix", lambda n: (
3926
4073
  f"# {tid}: acceptance criteria not met yet (round {n})\n\nYour result says these are not met:\n"
3927
4074
  + "\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"),
4075
+ + (f"\n\nAlready deferred by the developer (leave them; keep them `met: false`): "
4076
+ f"{', '.join(skipped)}." if skipped else "")
4077
+ + f"\n\nFinish them (you decide how), run `{st['check']}`, and write a new result.\n"
4078
+ "If one truly can't be met in this repo (for example an outside API or service it needs does not "
4079
+ "exist), don't try again: set status `question`, say which criterion and why, and offer to "
4080
+ "build the rest and defer that one. The developer decides.\n"),
3929
4081
  f"acceptance criteria still not met after {MAX_FIX} fix rounds")
3930
4082
  return
3931
4083
  ok, tail = check(t["dir"], tid)
@@ -4001,7 +4153,11 @@ def _autopilot(args):
4001
4153
  code, out = run("send-job" if kind == "FIX" else "send", tid, *([] if kind == "FIX" else ["task.md"]),
4002
4154
  ok=(0, 5))
4003
4155
  if sent(code, out, tid, worker):
4004
- say(f"{tid} fix job -> {worker}" if kind == "FIX" else f"{tid} -> {worker}")
4156
+ go_ts = load()["tasks"][tid].get("go_ts")
4157
+ if go_ts:
4158
+ patch_state(lambda s_: s_["tasks"][tid].pop("go_ts", None))
4159
+ say(f"{tid} fix job -> {worker}" if kind == "FIX" else f"{tid} -> {worker}"
4160
+ + (f" ({max(0, now() - go_ts)}s after the lead's dispatch or answer)" if go_ts else ""))
4005
4161
 
4006
4162
  def on_event(ev):
4007
4163
  parts = ev.split()
@@ -4249,6 +4405,8 @@ def _autopilot(args):
4249
4405
  f"\n\n## Commits\n```\n{log_}```\n\n## Files changed\n```\n{stat}```\n\n"
4250
4406
  "## Changed outside Likely files\n" + ("\n".join(scope) or "none") + "\n\n"
4251
4407
  "## Reviewer suggestions not applied\n" + ("\n".join(sugg) or "none") + "\n\n"
4408
+ + ("## Deferred: not done, follow-ups\nThe developer approved leaving these out of this run. They were "
4409
+ "NOT built.\n" + "\n".join(deferred_lines(st)) + "\n\n" if deferred_lines(st) else "")
4252
4410
  + ("## Models: planned and actual\n| Milestone | Planned tier | Ran on | Escalated | Why this tier |\n"
4253
4411
  "|---|---|---|---|---|\n" + "\n".join(models) + "\n\n" if models else "") +
4254
4412
  f"## Time: estimate vs actual\n{timing}\n\n"
@@ -5113,12 +5271,13 @@ COMMANDS = {
5113
5271
  "write-task": cmd_write_task, "nudge": cmd_nudge, "autopilot": cmd_autopilot,
5114
5272
  "send-job": cmd_send_job, "handoff": cmd_handoff, "needs-fix": cmd_needs_fix, "review-ok": cmd_review_ok,
5115
5273
  "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,
5274
+ "report": cmd_report, "events": cmd_events, "dispatch": cmd_dispatch, "answer": cmd_answer, "defer": cmd_defer,
5117
5275
  "escalate": cmd_escalate, "fix": cmd_fix, "team": cmd_team, "bench": cmd_bench, "stop": cmd_stop,
5118
5276
  "doctor": lambda a: cmd_doctor_crash(a),
5119
5277
  }
5120
5278
  # 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"}
5279
+ UNLOCKED = {"autopilot", "poll", "events", "dispatch", "answer", "defer", "fix", "team", "resume", "bench", "stop",
5280
+ "doctor"}
5122
5281
 
5123
5282
  USAGE = """usage: orch <command> [args]
5124
5283
  version print the installed herdr-orchestra version
@@ -5138,7 +5297,10 @@ USAGE = """usage: orch <command> [args]
5138
5297
  work, re-send the tasks that were in progress and start the event manager
5139
5298
  events [--peek] (lead) what you were woken for; reading acknowledges it
5140
5299
  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
5300
+ answer <Mn> [--defer AC2,AC3] <text> (lead) the developer's answer: into plan.md, and back to the same coder;
5301
+ --defer records that the developer approved leaving those criteria undone
5302
+ defer <Mn> <AC2,AC3> <reason> (lead, only with the developer's yes) these criteria stay undone in Mn: no fix
5303
+ rounds or escalation for them; the summary lists them as NOT done, with a follow-up
5142
5304
  fix <Mn> <text> [--to <worker>] a change to something Mn already landed: a small follow-up milestone, sent
5143
5305
  straight to the coder who built Mn (no new plan; check, review and summary still apply)
5144
5306
  agents sync [kind...] install the orch-plan / orch-run skills so every installed agent sees each one exactly once,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "5.8.1",
3
+ "version": "5.9.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/run.md CHANGED
@@ -38,8 +38,9 @@ Run `orch events`. It lists the new events, the ones still open, the milestones
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`)