herdr-orchestra 5.2.0 → 5.3.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,17 @@
2
2
 
3
3
  All notable changes. Versions follow [semantic versioning](https://semver.org).
4
4
 
5
+ ## [5.3.0] - 2026-11-13
6
+
7
+ ### Fixed
8
+ - **A wake-up that never became a turn is no longer lost.** In a real run the event manager logged `woke the lead` after a milestone merged, the lead never got a turn, and the run sat at ALL_DONE until the developer asked "status?". Two things in the code caused the silence. "Woke the lead" only meant the prompt was handed to herdr; nothing checked that the lead acted on it. And the only retry was after 5 minutes, by a process that exits at ALL_DONE: the ALL_DONE wake-up 4 seconds later was skipped because a wake-up for the same batch was "already pending", and then the event manager left, so nothing was ever sent again. (Why the first prompt did not become a turn could not be confirmed from the logs: most likely it landed in the pane's input box while the developer was typing there.) Now only the lead reading its events (`orch events`) counts. If the lead is idle again and the events are still unread, the wake-up is sent again after `ORCH_LEAD_CONFIRM_S` (30 seconds), then after twice that; after 3 wake-ups the developer gets a notification that says what to do. At ALL_DONE the event manager stays up until the lead has read the last events (at most `ORCH_LEAD_SETTLE_S`, 5 minutes, when the lead is busy). The log is honest about it: `woke the lead … (sent; it counts once the lead reads them)`, `the lead did not pick up its wake-up … -> sent it again (2 of 3)`, `the lead picked up its events`. `orch status` shows `wake-up sent 2x (last 0m40s ago), not picked up yet`. The lead's playbook also tells it to run `orch events` before it stops whenever the developer talks to it.
9
+
10
+ ### Changed
11
+ - **The manual checklist holds only what a person must check.** The summary used to ask the lead for a checklist "per user-facing behaviour", which filled it with things like reading code or comments. Now the summary has a "Checked automatically" section written by orch: the check command on the finished branch, each review, and every acceptance criterion with the coder's and the reviewer's recorded evidence. The lead then adds "Checked by the lead": whatever else a command or a look at the code can settle, it settles itself and writes the evidence (it may run the check command, single tests and read-only commands; it still never edits code; a check that fails is offered as an `orch fix`). The "Manual verification checklist" is left with what needs eyes or hands: how the UI looks and behaves in a real browser or on a real device, and anything that needs an outside account or hardware, each written as "where to go, what to do → what you should see". A change with nothing to look at says `Nothing to check by hand`. The plan playbook asks for acceptance criteria a test can prove, and to say plainly when one needs a person.
12
+
13
+ ### Added
14
+ - **A role for every coder.** Each milestone gets a `Role:` line from the lead: the specialist the work needs and what that specialist cares about in this milestone (for UI work: "senior frontend engineer with a designer's eye: matches the app's existing components and spacing, works on a small screen, has loading, empty and error states, usable by keyboard"). orch puts it at the top of the coder's task file ("For this task you are: …", work to that standard, review your own result as that specialist before finishing) and in `task.json` as `role`. An `orch fix` follow-up keeps the role of the milestone it fixes. The role sets the standard, never the method: the coder still owns the how. A plan without `Role:` works as before.
15
+
5
16
  ## [5.2.0] - 2026-11-13
6
17
 
7
18
  ### Added
package/README.md CHANGED
@@ -126,7 +126,7 @@ Version choice, first match wins: `--version` flag › `ORCH_VERSION` env › `.
126
126
 
127
127
  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).
128
128
  4. **If the lead is away** (its pane is closed, or it never reads its events): nothing is lost, the events wait in the queue. Ready work starts by itself after 15 minutes, you get a desktop notification, and `orch events --peek` shows what is open. With `Lead mode: off` in the plan header there is no lead in the run at all: `orch autopilot` dispatches by itself and stops (exit 3) when it needs you.
129
- 5. **When it's done:** read `.orchestrate/summary.md` and test it. Want a change? Tell the lead (for example "the login button should be blue"). It runs `orch fix M1 "the login button should be blue"`: one small follow-up job goes straight to the coder who built M1, with the check and review as before, and no new plan. You can run `orch fix` yourself too. When you are happy, run `orch finish`. It re-runs the check, removes the worktrees, pushes `feature/<name>` and opens a PR into `main` (with `gh`, or prints the compare link).
129
+ 5. **When it's done:** read `.orchestrate/summary.md` and do its manual checklist. It holds only what needs your eyes or hands (how the UI looks and behaves, a real device); whatever a command or a look at the code can settle, the run and the lead have already checked and listed with the evidence. Want a change? Tell the lead (for example "the login button should be blue"). It runs `orch fix M1 "the login button should be blue"`: one small follow-up job goes straight to the coder who built M1, with the check and review as before, and no new plan. You can run `orch fix` yourself too. When you are happy, run `orch finish`. It re-runs the check, removes the worktrees, pushes `feature/<name>` and opens a PR into `main` (with `gh`, or prints the compare link).
130
130
 
131
131
  ### Git: one branch per run, real commits, one PR
132
132
  Planning touches no git at all. `orch start` creates the plan's `Branch:` (`feature/<slug>`) and that is the only branch a run makes: coders work on detached worktrees, and a milestone's work in progress (under review, parked, waiting for a fix) lives in hidden refs under `refs/orch/`, which `git branch` doesn't list and `git push` doesn't send. Each milestone lands as **one commit whose message says what changed** (the coder's `COMMIT:` line, e.g. `feat(api): add categories endpoint`, with a `Milestone: M2` trailer). `Commits: single` in the plan header squashes the run into one commit at finish.
@@ -157,6 +157,7 @@ Model why: one module, a clear contract, an existing endpoint to copy; no design
157
157
  - **One escalation.** A milestone that runs out of fix or review rounds gets one fresh round on a stronger model, with the work so far, before it fails.
158
158
  - **Policy.** Ultra-premium models (`*fable*`, `*astra*`) are kept out of runs: `orch sync` refuses a plan that names one. Everything else your agents reach is allowed, open-weight models included. Edit `[policy] deny` to change the list.
159
159
  - **Checked against reality.** `summary.md` has a table of planned tier against the model that really did each milestone, and `orch report` shows first-pass rate and escalations per model. When a model does worse than its rating, lower the rating.
160
+ - **A role for every coder.** The lead writes `Role:` on each milestone (for UI work, for example, "senior frontend engineer with a designer's eye: matches the existing components, works on a small screen, has loading, empty and error states"). The coder's task file starts with it, so the coder works to that standard.
160
161
  - **Estimate vs actual time.** The lead writes `Estimate:` for each milestone and for the whole feature. orch measures the real time, and the summary shows both. When something took longer, it lists where the time went and who it waited on (for example "10m claude-1 (sonnet): fix rounds: the check command failed" or "20m developer / lead: paused, waiting for an answer"), only from what orch recorded.
161
162
  - **Yours to change.** Add or re-rate models in `~/.config/herdr-orchestra/models.toml` (merged over `models.default.toml`). The default ratings are starting points with their sources, not benchmarks run by this project. A model that is not in the catalog still works; it just has no tier.
162
163
 
@@ -234,6 +235,7 @@ When a milestone passes its checks it's saved to its hidden ref and the coder is
234
235
  | Autopilot is killed mid-step | the next run confirms or re-sends an unconfirmed prompt to the same agent, and finishes or undoes a half-done merge |
235
236
  | Lockfiles changed since a folder was set up | the setup command runs again there (and in your main folder before the merge check) |
236
237
  | Risky change (deleted file, migration, CI config, secrets file, unlisted dependency change, very large diff) | the milestone is **held** until you run `orch approve Mn`; the rest keeps going |
238
+ | The wake-up prompt never became a turn for the lead (it sat in the input box, or you were typing there) | sent again after 30s, then 1 min; after 3 tries you get a notification. The event manager does not leave at ALL_DONE before the lead has read the last events |
237
239
  | A coder changes files outside its `Likely files` | listed in the summary (`Scope: strict` sends it back instead) |
238
240
  | An orch step fails for one task | that task is paused with the error; the others keep running |
239
241
  | The final check fails on the branch | stops; the next run re-checks and carries on once it passes |
@@ -251,7 +253,7 @@ Optional plan header lines: `Lead mode: events | off` (default `events` when the
251
253
  ### Commands
252
254
  `orch status` · `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 cleanup` · `orch finish [--no-push]` · `orch version` · `orch` (full help)
253
255
 
254
- 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_RISK_MAX_LINES` (1500) · `ORCH_LEAD_WAIT_MIN` (15: ready work the lead hasn't dispatched starts by itself) · `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)
256
+ 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_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)
255
257
 
256
258
  ## Develop and release
257
259
 
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.2.0
1
+ 5.3.0
Binary file
package/bin/orch CHANGED
@@ -28,7 +28,9 @@ CONFIRM_S = int(os.environ.get("ORCH_CONFIRM_S", "30")) # a prompt not
28
28
  MAX_LOST = int(os.environ.get("ORCH_MAX_LOST", "4")) # lost attempts (unreachable, gone, rate limit)
29
29
  UNREACHABLE_AFTER = int(os.environ.get("ORCH_UNREACHABLE_AFTER", "3")) # failed prompts in a row before a long bench
30
30
  UNREACHABLE_MIN = int(os.environ.get("ORCH_UNREACHABLE_MIN", "30"))
31
- LEAD_REWAKE_S = int(os.environ.get("ORCH_LEAD_REWAKE_S", "300")) # wake the lead again if it never read its events
31
+ LEAD_REWAKE_S = int(os.environ.get("ORCH_LEAD_REWAKE_S", "300")) # longest wait before a wake-up is sent again
32
+ LEAD_CONFIRM_S = int(os.environ.get("ORCH_LEAD_CONFIRM_S", "30")) # a wake-up the lead did not pick up is sent again after this (doubling)
33
+ LEAD_SETTLE_S = int(os.environ.get("ORCH_LEAD_SETTLE_S", "300")) # at ALL_DONE, stay up this long for the lead to pick up its events
32
34
  LEAD_MAX_WAKES = int(os.environ.get("ORCH_LEAD_MAX_WAKES", "3")) # ...this many times, then tell the developer
33
35
  LEAD_WAIT_S = int(os.environ.get("ORCH_LEAD_WAIT_MIN", "15")) * 60 # ready work the lead never dispatched starts by itself
34
36
  LEAD_IDLE_MAX_S = int(os.environ.get("ORCH_LEAD_IDLE_MAX_MIN", "720")) * 60 # give up waiting for answers after this
@@ -1021,7 +1023,7 @@ def cmd_sync(args):
1021
1023
  "wait": o.get("wait"),
1022
1024
  "files": sorted(files[tid]),
1023
1025
  "parallel": field(t, "parallel", "").lower().startswith("allow"),
1024
- "tier": tiers[tid], "needs": needs[tid], "model_why": field(t, "model why"),
1026
+ "tier": tiers[tid], "needs": needs[tid], "model_why": field(t, "model why"), "role": field(t, "role"),
1025
1027
  "estimate_s": estimates[tid],
1026
1028
  }
1027
1029
  if status != st["tasks"][tid]["status"]:
@@ -2292,6 +2294,8 @@ def cmd_status(args):
2292
2294
  hold = undispatched(st)
2293
2295
  print(f" lead {st['lead']['name']}: {len(unread_events(st))} unread event(s), {len(ev)} open"
2294
2296
  + (f"; waiting for `orch dispatch`: {', '.join(hold)}" if hold else "")
2297
+ + (f"; wake-up sent {lw['n']}x (last {_fmt_secs(now() - lw.get('ts', now()))} ago), not picked up yet"
2298
+ if unread_events(st) and (lw := st.get("lead_wake") or {}).get("n") else "")
2295
2299
  + ("" if driver_alive() else "; the event manager is NOT running (`orch autopilot`)"))
2296
2300
  if all(t["status"] in ("merged", "skipped") for t in st["tasks"].values()):
2297
2301
  print(f"ALL_DONE — run `orch finish` to push {st['branch']} and open a PR into {st.get('base')}")
@@ -2437,7 +2441,14 @@ def cmd_write_task(args):
2437
2441
  secs, glob = plan_sections()
2438
2442
  if tid not in secs:
2439
2443
  die(f"{tid} not found in plan.md")
2440
- parts = [f"# Task {tid}: {t['title']}", "", secs[tid].replace(f"## [x] {tid}:", "Title:", 1), ""]
2444
+ parts = [f"# Task {tid}: {t['title']}", ""]
2445
+ if t.get("role"):
2446
+ parts += ["## Your role", f"For this task you are: **{t['role']}**.",
2447
+ "Work the way that person would. Before you write anything, read the code around the change and "
2448
+ "the patterns it already follows. Then build it to the standard that specialist would put their "
2449
+ "name on: \"the check passes\" is the floor, not the goal. Before you finish, look at your own "
2450
+ "result as that specialist reviewing someone else's work, and fix what they would send back.", ""]
2451
+ parts += [secs[tid].replace(f"## [x] {tid}:", "Title:", 1), ""]
2441
2452
  if glob and glob.lower() not in ("none", "<empty — user may fill in>"):
2442
2453
  parts += ["## Global instructions", glob, ""]
2443
2454
  ctx = []
@@ -2486,7 +2497,7 @@ def task_contract(st, tid):
2486
2497
  "goal": field(pt, "goal"), "why": field(pt, "why"),
2487
2498
  "acceptance_criteria": [{"id": f"AC{i}", "text": c} for i, c in enumerate(items("acceptance criteria"), 1)],
2488
2499
  "files_allowed": t.get("files") or [], "scope": st.get("scope", "warn"),
2489
- "tier": t.get("tier"), "needs": t.get("needs") or [],
2500
+ "tier": t.get("tier"), "needs": t.get("needs") or [], "role": t.get("role") or None,
2490
2501
  "interfaces": items("interfaces"), "constraints": items("constraints"), "out_of_scope": items("out of scope"),
2491
2502
  "depends_on": deps, "check": st["check"], "attempt": t.get("attempt", 0) + 1, "lost_attempts": t.get("lost", 0),
2492
2503
  "previous_work": {"by": t.get("last_worker")} if work_ref(st, tid) else None,
@@ -2638,6 +2649,8 @@ def cmd_fix(args):
2638
2649
  sec = [f"## [x] {new}: {title}", f"Depends on: {tid} (a fix to what {tid} built)",
2639
2650
  f"Why separate: a change the developer asked for after {tid} landed.", f"Review: {review}",
2640
2651
  "Estimate: none"]
2652
+ if field(src, "role"):
2653
+ sec.append(f"Role: {field(src, 'role')}")
2641
2654
  if field(src, "likely files"):
2642
2655
  sec.append(f"Likely files: {field(src, 'likely files')}")
2643
2656
  if t.get("tier"):
@@ -2654,7 +2667,7 @@ def cmd_fix(args):
2654
2667
  "status": "pending", "reason": f"fix for {tid}", "worker": None, "dir": None, "attempt": 0, "fix": 0,
2655
2668
  "review_round": 0, "wait": None, "files": list(t.get("files") or []), "parallel": False,
2656
2669
  "tier": t.get("tier"), "needs": [], "model_why": f"a fix to {tid}, for the coder who built it." if t.get("tier") else "",
2657
- "go": True, "fix_of": tid,
2670
+ "go": True, "fix_of": tid, "role": field(src, "role"),
2658
2671
  }
2659
2672
  if who:
2660
2673
  st["tasks"][new]["assign"] = who
@@ -2776,6 +2789,43 @@ def cmd_nudge(args):
2776
2789
  print(f"NUDGED {tid} -> {w['agent']}")
2777
2790
 
2778
2791
 
2792
+ def auto_checked(st, final_ok):
2793
+ """What the run already verified without a person, for the summary: the check command, the reviews, and each
2794
+ acceptance criterion with the coder's and the reviewer's evidence. The lead builds on this, so the manual
2795
+ checklist holds only what a person must look at. Only recorded facts; a criterion nobody gave evidence for says so."""
2796
+ try:
2797
+ _, ptasks = parse_plan((ORCH / "plan.md").read_text())
2798
+ except OSError:
2799
+ ptasks = []
2800
+ out = [f"- Check command `{st['check']}` on the finished branch: {'PASS' if final_ok else 'FAIL'}"]
2801
+ for tid in st["order"]:
2802
+ t = st["tasks"][tid]
2803
+ if t["status"] != "merged":
2804
+ continue
2805
+ pt = next((x for x in ptasks if x["id"] == tid), {"fields": {}})
2806
+ crit = [v.lstrip("- ").strip() for v in pt["fields"].get("acceptance criteria", [])]
2807
+ crit = [v for v in crit if v and v.lower() != "none"]
2808
+ res, _ = read_result(t.get("last_result"))
2809
+ coder = {str(c.get("id")): c for c in (res or {}).get("criteria", []) if isinstance(c, dict)}
2810
+ k = t.get("review_round", 0)
2811
+ rev, _ = read_json(ORCH / "review" / tid / f"review-{k}.json") if k else (None, None)
2812
+ rcrit = rev.get("criteria", []) if isinstance(rev, dict) and isinstance(rev.get("criteria", []), list) else []
2813
+ reviewer = {str(c.get("id")): c for c in rcrit if isinstance(c, dict)}
2814
+ passed = sum(1 for c in t.get("checks") or [] if c.get("ok"))
2815
+ out.append(f"- {tid} \"{t['title']}\": check command passed" + (f" {passed}x" if passed > 1 else "")
2816
+ + (f"; review passed (round {k})" if t.get("review") and k else "; no review planned"))
2817
+ for i, text in enumerate(crit, 1):
2818
+ cid, ev = f"AC{i}", []
2819
+ c, r = coder.get(cid), reviewer.get(cid)
2820
+ if c and c.get("met") is not None:
2821
+ ev.append(f"coder: {'met' if c['met'] else 'NOT met'}" + (f" ({c['evidence']})" if c.get("evidence") else ""))
2822
+ if r and r.get("met") is not None:
2823
+ ev.append(f"reviewer: {'met' if r['met'] else 'NOT met'}" + (f" ({r['note']})" if r.get("note") else ""))
2824
+ out.append(f" - {cid} {text} — " + ("; ".join(ev) if ev else "no evidence recorded: the lead checks it, "
2825
+ "or it goes on the manual list"))
2826
+ return "\n".join(out)
2827
+
2828
+
2779
2829
  RATE_RE = re.compile(r"usage limit|rate.?limit|quota|too many requests|\b429\b|limit reached|try again (in|at)|out of credits",
2780
2830
  re.I)
2781
2831
 
@@ -2834,25 +2884,31 @@ def cmd_autopilot(args):
2834
2884
  park(tid, "failed", reason)
2835
2885
 
2836
2886
  def wake_lead(force=False):
2837
- """Tell the lead it has unread events: only when it is idle, once per batch, again after LEAD_REWAKE_S if it
2838
- never read them (up to LEAD_MAX_WAKES). The events themselves are already safe in state.json."""
2887
+ """Tell the lead it has unread events, and make sure the wake-up became a turn. Sending the prompt proves
2888
+ nothing: it can sit in the pane's input box or collide with what the developer is typing. Only the lead
2889
+ reading its events (`orch events`) counts. A lead that is idle again with the events still unread did not
2890
+ pick the wake-up up, so it is sent again: after LEAD_CONFIRM_S, then twice that, and so on (never longer
2891
+ than LEAD_REWAKE_S), up to LEAD_MAX_WAKES; then the developer is told. A lead herdr can't watch is woken
2892
+ again every LEAD_REWAKE_S. The events themselves are already safe in state.json."""
2839
2893
  s_ = load()
2840
2894
  if not lead_on(s_):
2841
2895
  return
2842
2896
  un = unread_events(s_)
2897
+ lw = s_.get("lead_wake") or {}
2898
+ lead = s_["lead"]["name"]
2843
2899
  if not un:
2900
+ if lw.get("n") and not lw.get("ack"):
2901
+ patch_state(lambda s2: s2.update(lead_wake={**(s2.get("lead_wake") or {}), "ack": True}))
2902
+ say(f"the lead ({lead}) picked up its events")
2844
2903
  return
2845
- lead, newest = s_["lead"]["name"], max(e["id"] for e in un)
2846
- lw = s_.get("lead_wake") or {}
2904
+ newest = max(e["id"] for e in un)
2847
2905
  # a wake the lead has not acted on yet covers newer events too: it reads the whole queue when it comes
2848
2906
  same = any(e["id"] <= lw.get("upto", 0) for e in un)
2849
- if same and (now() - lw.get("ts", 0) < LEAD_REWAKE_S or lw.get("n", 0) >= LEAD_MAX_WAKES):
2850
- if lw.get("n", 0) >= LEAD_MAX_WAKES and now() - lw.get("ts", 0) >= LEAD_REWAKE_S and not lw.get("told"):
2851
- patch_state(lambda s2: s2["lead_wake"].update(told=True))
2852
- say(f"the lead ({lead}) has not read its events after {LEAD_MAX_WAKES} wake-ups — look at its pane, "
2853
- f"or run `orch events --peek` yourself", True)
2907
+ n = lw.get("n", 0) if same else 0
2908
+ if same and now() - lw.get("ts", 0) < lw.get("wait", LEAD_REWAKE_S):
2854
2909
  return
2855
- if watched(s_, lead) and not force:
2910
+ watch = watched(s_, lead)
2911
+ if watch and not force:
2856
2912
  hs = herdr_state(lead)
2857
2913
  if hs is None:
2858
2914
  if not lw.get("gone"):
@@ -2861,19 +2917,31 @@ def cmd_autopilot(args):
2861
2917
  f"for it (`orch events --peek` shows them)", True)
2862
2918
  return
2863
2919
  if word(hs, "working", "blocked"):
2864
- return # busy: the events wait in the queue, one wake when it is idle
2920
+ return # in a turn: the events wait in the queue, one wake when it is idle
2921
+ if n >= LEAD_MAX_WAKES:
2922
+ if not lw.get("told"):
2923
+ patch_state(lambda s2: s2["lead_wake"].update(told=True))
2924
+ say(f"the lead ({lead}) has not read its events after {LEAD_MAX_WAKES} wake-ups — look at its pane "
2925
+ f"(if the wake-up text sits in its input box, press Enter), or tell it: run `orch events`. "
2926
+ f"{len(un)} event(s) wait for it (`orch events --peek` shows them)", True)
2927
+ return
2865
2928
  text = (f"orch: {len(un)} new event(s) in the run on {s_['branch']} need the lead. Run `orch events` and "
2866
2929
  f"handle what it prints, then stop.")
2867
2930
  try:
2868
2931
  deliver(s_, lead, text)
2869
2932
  except DeliveryError as e:
2870
2933
  say(f"could not wake the lead ({lead}): {e} — will retry; the events are kept")
2871
- patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now() - LEAD_REWAKE_S + SEND_RETRY_S,
2872
- "n": lw.get("n", 0) if same else 0}))
2934
+ patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": n, "wait": SEND_RETRY_S}))
2873
2935
  return
2874
- patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": (lw.get("n", 0) if same else 0) + 1}))
2875
- say(f"woke the lead ({lead}): {len(un)} event(s) — " + ", ".join(
2876
- f"{e['kind']}{' ' + e['task'] if e.get('task') else ''}" for e in un[:6]))
2936
+ wait = min(LEAD_REWAKE_S, LEAD_CONFIRM_S * 2 ** n) if watch else LEAD_REWAKE_S
2937
+ patch_state(lambda s2: s2.update(lead_wake={"upto": newest, "ts": now(), "n": n + 1, "wait": wait}))
2938
+ what = ", ".join(f"{e['kind']}{' ' + e['task'] if e.get('task') else ''}" for e in un[:6])
2939
+ if n:
2940
+ say(f"the lead ({lead}) did not pick up its wake-up (" + ("idle again, " if watch else "")
2941
+ + f"events still unread after {now() - lw.get('ts', now())}s) -> sent it again "
2942
+ f"({n + 1} of {LEAD_MAX_WAKES}): {len(un)} event(s) — {what}")
2943
+ else:
2944
+ say(f"woke the lead ({lead}): {len(un)} event(s) — {what} (sent; it counts once the lead reads them)")
2877
2945
 
2878
2946
  def lead_ready():
2879
2947
  """Ready milestones the lead has not dispatched: tell it once per set; start them ourselves after LEAD_WAIT_S."""
@@ -3287,10 +3355,16 @@ def cmd_autopilot(args):
3287
3355
  + ("## Models: planned and actual\n| Milestone | Planned tier | Ran on | Escalated | Why this tier |\n"
3288
3356
  "|---|---|---|---|---|\n" + "\n".join(models) + "\n\n" if models else "") +
3289
3357
  f"## Time: estimate vs actual\n{timing}\n\n"
3358
+ f"## Checked automatically\nAlready verified by the run; nobody needs to redo these by hand.\n"
3359
+ f"{auto_checked(st, ok)}\n\n"
3290
3360
  f"## Run report\n```\n{report}\n```\n\n"
3291
3361
  + ("## Still to write (the lead was woken to write these)\n" if lead_ else
3292
3362
  "## Still to write (ask the lead: 'use the orch-run skill' to finish the summary)\n") +
3293
- "- Design decisions & study notes\n- Manual verification checklist\n"
3363
+ "- Design decisions & study notes\n"
3364
+ "- Checked by the lead: what you verified yourself by running a command or reading the code, with the "
3365
+ "evidence\n"
3366
+ "- Manual verification checklist: only what a person must see or do (how the UI looks and behaves, a "
3367
+ "real device, an outside account). Nothing a command or a look at the code can settle.\n"
3294
3368
  + ("\nThe summary before this one is in `.orchestrate/summary.prev.md`: carry its notes and checklist "
3295
3369
  "over, and add what the new work changed.\n" if prev.exists() else ""))
3296
3370
  if lead_:
@@ -3304,6 +3378,20 @@ def cmd_autopilot(args):
3304
3378
  wake_lead(force=True)
3305
3379
  say(f"ALL_DONE on {st['branch']} — final check {'PASS' if ok else 'FAIL'}. See .orchestrate/summary.md, "
3306
3380
  f"then run `orch finish` to push {st['branch']} and open a PR into {base}", True)
3381
+ if lead_:
3382
+ # don't leave with a wake-up nobody confirmed: after this exit nothing would send it again
3383
+ end = time.time() + LEAD_SETTLE_S
3384
+ while True:
3385
+ wake_lead()
3386
+ s_ = load()
3387
+ lw_ = s_.get("lead_wake") or {}
3388
+ if not unread_events(s_) or lw_.get("told") or lw_.get("gone"):
3389
+ break
3390
+ if time.time() > end:
3391
+ say(f"the lead ({st['lead']['name']}) still has not read ALL_DONE — tell it: run `orch events`",
3392
+ True)
3393
+ break
3394
+ time.sleep(POLL_STEP_S)
3307
3395
  sys.exit(0 if ok else 3)
3308
3396
  active = [k for k, v in tasks.items() if v["status"] in ACTIVE and v["status"] != "held"]
3309
3397
  ready = [k for k, v in tasks.items() if v["status"] == "pending" and deps_met(st, v)]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "herdr-orchestra",
3
- "version": "5.2.0",
3
+ "version": "5.3.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
@@ -8,6 +8,7 @@ Load the `herdr` skill for exact CLI syntax if you have it (otherwise `herdr --s
8
8
  - Research findings go in as **facts**, not instructions:
9
9
  - ✅ "Uploads are handled in `server/routes/upload.ts`; categories live in the `categories` table."
10
10
  - ❌ "Add a `matchCategory()` function to upload.ts that loops over rows."
11
+ - You give every milestone a **role**: the specialist the coder should work as, and what that specialist cares about here (step 6, Role). That sets the standard, not the method.
11
12
  - You also decide **which level of model each milestone needs** (small, medium or high) and say why (step 6), and **how long each milestone and the whole feature should take** (step 6, Estimate).
12
13
  - You never edit application code, and you never prompt worker agents: you hand out work with `orch dispatch`, and the event manager (`orch autopilot`, a plain script) prompts the agents, watches them and wakes you when something needs a decision.
13
14
 
@@ -92,6 +93,14 @@ Then:
92
93
  - Don't put everything on `high`: a small model on small work is faster and cheaper, and that is the point. Don't put design work on `small` to save money either: a milestone that runs out of fix rounds is moved up to a stronger model once, and that costs more than starting right.
93
94
  - orch gives a milestone to a free coder of its tier, or a stronger one when none is free; never to a weaker one while a suitable coder exists.
94
95
 
96
+ **Give the coder a role.** Every milestone gets `Role:`: one line naming the specialist this work needs and the two or three things that specialist would care about in THIS milestone. orch puts it at the top of the coder's task file ("For this task you are: …"), so the coder aims at that standard instead of at "the check passes". It says who and how good, never how: no steps, no function names.
97
+ - UI work: `Role: senior frontend engineer with a designer's eye: matches the app's existing components and spacing, works on a small screen, has loading, empty and error states, usable by keyboard`
98
+ - An API: `Role: backend engineer who designs APIs other teams depend on: clear error responses, input validated at the edge, every acceptance criterion covered by a test`
99
+ - A schema change: `Role: database engineer who has been burned by migrations: reversible, safe on a table with real data, no long locks`
100
+ - A bug nobody has diagnosed: `Role: debugging specialist: finds and proves the root cause before changing anything, and leaves a test that fails without the fix`
101
+ - Docs: `Role: technical writer for developers new to this project: short sentences, every command copy-pasteable and tested`
102
+ 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.
103
+
95
104
  **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.
96
105
 
97
106
  ## 7. Choose the isolation mode (ask if the user hasn't said)
@@ -136,6 +145,7 @@ Tier: small | medium | high
136
145
  Needs: <any of: reasoning, coding, architecture, long-context, tool-use, planning, speed>
137
146
  Model why: <one line: what in this milestone makes it that tier>
138
147
  Estimate: <e.g. 40m: dispatch to landed if nothing goes wrong>
148
+ Role: <the specialist the coder works as, and what they care about in this milestone>
139
149
  Review: yes | no
140
150
  Likely files: src/a.ts, src/b.ts, src/feature/
141
151
  Parallel: <leave this line out | allow>
@@ -161,7 +171,8 @@ Git: the run makes ONE branch, `Branch:` (use `feature/<slug>`, or `fix/<slug>`
161
171
  Optional header lines: `Scope: strict` sends a milestone back when its coder changes files outside `Likely files` (default `warn`: listed in the summary); `Budget: 3h` stops autopilot when its running time is used up; `Risk hold: off` lets risky changes (deleted files, migrations, CI config, secrets files, unlisted dependency changes, very large diffs) land without `orch approve`; `Setup inputs: <globs>` names the files that mean "run the setup command again" (default: lockfiles and manifests); `Lead mode: off` makes the event manager dispatch by itself and stop for the developer instead of waking you (default with a `Lead:` line: `events`).
162
172
 
163
173
  Rules for every milestone:
164
- - **Acceptance criteria are observable**: "POST /upload returns 400 when the amount column is missing", not "handles errors well". 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.
174
+ - **Role**: from step 6, on every milestone. The standard to work to, never a how-to.
175
+ - **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.
165
176
  - **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).
166
177
  - **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.
167
178
  - **No how**: no code blocks, no function names to create, no numbered implementation steps. `orch sync` warns if it sees them.
package/playbooks/run.md CHANGED
@@ -5,7 +5,7 @@ Extra user input = whatever the user wrote alongside asking you to run this play
5
5
  A run behaves like a call stack. You **dispatch** work and **pause**. The **event manager** (`orch autopilot`, a plain script with no AI in it) prompts the coders and the reviewer, watches them, runs checks, sends fixes, merges, and keeps every event in a queue on disk. When something needs you (a milestone finished, a coder asked a question, a milestone failed or is held, new work is ready) it **wakes you** with one line: run `orch events`. You handle what it prints and pause again. This repeats until every milestone has landed.
6
6
 
7
7
  - You never watch, wait for or poll the agents. Between wake-ups you do nothing and cost nothing.
8
- - No event is lost while you are paused or busy: it waits in the queue, and you get the whole batch in one wake-up. Reading `orch events` is your acknowledgement.
8
+ - No event is lost while you are paused or busy: it waits in the queue, and you get the whole batch in one wake-up. Reading `orch events` is your acknowledgement, and the only thing that counts as "the lead was woken": if you are idle and the events are still unread, the event manager sends the wake-up again (after 30 seconds, then 1 minute, then it tells the developer). So when the developer talks to you and you have not run `orch events` in this turn, run it before you stop.
9
9
  - Only the event manager sends prompts, moves tasks and merges. Your commands (`orch dispatch`, `orch answer`) are requests it carries out, so two processes never act on the run at once. While it runs, `orch` refuses every other command that would change the run from your shell.
10
10
  - Routine recovery is not your job: a failed check goes back to its coder, a rate-limited or vanished agent is benched and its work moves on, a milestone out of fix rounds gets one fresh round on a stronger model. You hear about results, not about every retry.
11
11
 
@@ -52,9 +52,12 @@ If you changed plan.md by hand, run `orch sync` (it works once the event manager
52
52
  **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.
53
53
 
54
54
  ## 3. ALL_DONE
55
- 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)**, **the time table (your estimate vs the real time, per milestone and for the feature; for anything that took longer: where the extra time went and who or what it waited on)** and the run report (time, rounds, first-pass rate, wasted work, how each model did; `orch report` prints it again).
56
- 2. You add two sections: "Design decisions & study notes" for the developer (include any milestone that needed a stronger model than planned, and any estimate that was far off, and what that says about the plan; take the reasons from the time table, never guess them), and a "Manual verification checklist" (`- [ ]` per user-facing behaviour).
57
- 3. Tell the developer: "All tasks landed on <branch>. Review .orchestrate/summary.md and test the checklist. Then run `orch finish`: it re-runs the check, 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.**
55
+ 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).
56
+ 2. You add three sections, in this order:
57
+ - **"Design decisions & study notes"** for the developer (include any milestone that needed a stronger model than planned, and what that says about the plan).
58
+ - **"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>"`.
59
+ - **"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.
60
+ 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, 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.**
58
61
  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.
59
62
 
60
63
  ## Runs without a lead (`Lead mode: off`)