dsh-hive-runner 0.6.7 → 0.7.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/README.md CHANGED
@@ -4,9 +4,9 @@
4
4
 
5
5
  **English** · [简体中文](README.zh-CN.md)
6
6
 
7
- **A resident Hive supervisor inside DSH.** While DSH is open it keeps taking ready task
8
- cards for your repositories and runs one DSH subagent ("bee") per card, inside the
9
- per-role worker limits you set in the Hive panel.
7
+ **A resident Hive supervisor inside DSH.** While DSH is open it keeps taking ready tasks
8
+ for your repositories and runs one DSH subagent per task, inside the per-role
9
+ agent limits you set in the Hive panel.
10
10
 
11
11
  [![CI](https://img.shields.io/github/actions/workflow/status/d86e/dsh-hive-runner/ci.yml?style=for-the-badge&logo=github)](https://github.com/d86e/dsh-hive-runner/actions)
12
12
  [![npm](https://img.shields.io/npm/v/dsh-hive-runner?style=for-the-badge&logo=npm&color=cb3837)](https://www.npmjs.com/package/dsh-hive-runner)
@@ -17,78 +17,229 @@ per-role worker limits you set in the Hive panel.
17
17
 
18
18
  ---
19
19
 
20
- [Hive](https://github.com/d86e/hive) coordinates a swarm of coding agents inside git: task
21
- cards with acceptance commands, path announcements, a presence board and a commit-time
20
+ [Hive](https://github.com/d86e/hive) coordinates a swarm of coding agents inside git:
21
+ tasks with acceptance commands, path announcements, a presence board and a commit-time
22
22
  merge, all stored as refs and files in the repository itself. The
23
23
  [hive-runner](https://github.com/d86e/hive-runner) CLI runs **one** round and exits.
24
24
 
25
25
  **dsh-hive-runner** makes that loop resident inside DSH. It runs a supervisor in the DSH
26
26
  host process — not in the browser tab — so closing the panel or the window does not stop
27
- it; it keeps working as long as DSH is running. Workers are DSH subagents, and every shell
27
+ it; it keeps working as long as DSH is running. Agents are DSH subagents, and every shell
28
28
  call goes through DSH's own shell seam, so the work stays inside the deployment sandbox:
29
29
  the plugin never spawns processes outside the harness.
30
30
 
31
31
  ## What it does
32
32
 
33
- - For every configured repository it reads the ready task cards and dispatches one worker
34
- subagent per card.
35
- - **Only live workers occupy a slot.** A card waiting for a slot is not counted; when a
36
- worker finishes its card the slot is freed immediately and the next waiting card of the
37
- same role starts.
38
- - Each role has its own limit. The default is **5 live workers per role** for roles that
33
+ - For every configured repository it reads the ready tasks and dispatches one DSH
34
+ subagent per task.
35
+ - **Only running agents count against a slot.** A task waiting for a slot is not
36
+ counted; when an agent finishes its task the slot is freed immediately and the next
37
+ waiting task of the same role starts.
38
+ - Each role has its own limit. The default is **5 live agents per role** for roles that
39
39
  are not configured.
40
- - **0 pauses a role**: its ready cards stay on the Hive board and are not dispatched.
40
+ - **0 pauses a role**: its ready tasks stay on the Hive board and are not dispatched.
41
41
  - A repository is always processed one drain at a time; different repositories can run in
42
42
  parallel (2 by default).
43
- - A card that produces no commit, fails its acceptance command, or whose worker stops
43
+ - A task that produces no commit, fails its acceptance command, or whose agent stops
44
44
  early is recorded as failed in Hive; the rest of the queue continues.
45
45
  - If a repository keeps failing, it backs off and is auto-paused after three consecutive
46
46
  failures. Paused repositories never resume by themselves.
47
- - Workers follow the Hive consensus announcement protocol: before a worker starts, the
48
- supervisor announces the card's scope with `hive guard` (every scope entry, including
47
+ - Agents follow the Hive consensus announcement protocol: before an agent starts, the
48
+ supervisor announces the task's scope with `hive guard` (every scope entry, including
49
49
  `resource:` keys) and clears those announcements afterwards. An overlap with another
50
- agent's announcement is advisory only: the worker keeps working, and merge-on-commit
50
+ agent's announcement is advisory only: the agent keeps working, and merge-on-commit
51
51
  three-way merges the concurrent edits at commit time (unresolved conflicts stay as
52
52
  markers).
53
- - Lessons are read before every card and written after it: the supervisor runs
53
+ - Lessons are read before every task and written after it: the supervisor runs
54
54
  `hive recall` for every scope path plus the repository root and injects the
55
- deduplicated matches at the top of the worker prompt; workers record genuinely new
55
+ deduplicated matches at the top of the agent prompt; agents record genuinely new
56
56
  knowledge with `hive lesson add`. Writing a lesson and reading it at the start of the
57
- next card are a pair — one without the other does not compound.
57
+ next task are a pair — one without the other does not compound.
58
58
  - Commits are verified against merge-on-commit: the repository must have the
59
- merge-on-commit pre-commit hook (`hive init` installs it), and a card only counts as
59
+ merge-on-commit pre-commit hook (`hive init` installs it), and a task only counts as
60
60
  done when HEAD moved through that hook.
61
- - While the repository is in Hive freeze mode, non-fix cards stay on the board instead of
61
+ - While the repository is in Hive freeze mode, non-fix tasks stay on the board instead of
62
62
  failing.
63
63
 
64
- ## Worker sessions
64
+ ## Agent sessions
65
65
 
66
- Workers run in the **queen conversation**: the Session where you opened the Hive panel
67
- and finished `hive init` (or where the queen took over). The panel registers that
68
- Session with the supervisor, and from then on every card worker is parented to it — the
69
- workers show up as subagents in that same conversation, so you can open them from your
70
- own session.
66
+ Agents run in the **queen conversation**: the Session where you opened the Hive panel
67
+ and finished `hive init` (or where the queen took over — the panel's queen mode,
68
+ `autoQueen`, does this automatically for an initialised repository, and `/queen on` /
69
+ `/queen off` control it). The panel registers that Session with the supervisor, and from
70
+ then on each task's agent is parented to it — the agents show up as subagents in that
71
+ same conversation, so you can open them from your own session.
71
72
 
72
73
  - Nothing is dispatched before the queen Session is registered: status reports
73
74
  `waiting: no-queen-session`, a startup-order hint rather than an error.
74
- - The supervisor keeps using exactly that registered Session; it never switches to a
75
- different chat.
75
+ - The registration lives in plugin memory and is never replaced by another chat; after a
76
+ plugin restart the panel registers the same Session again on its next access.
76
77
  - Once registered, dispatch works with zero other user sessions and keeps running when
77
78
  the panel/UI is closed.
78
79
 
80
+ ## The queen as coordinator
81
+
82
+ Since 0.7 the registered queen Session is a **coordinator, supervisor and reviewer**, not
83
+ only a task splitter. The runner gives her the actions below and feeds her the anomalies
84
+ she must act on. The authoritative contract is `<repo>/.hive/roles/queen.md` (written by
85
+ `hive init`) plus the `hive-queen` skill; this section documents the host behaviour.
86
+
87
+ ### Her actions
88
+
89
+ | Tool | What the queen uses it for |
90
+ | --- | --- |
91
+ | `hive_board`, `hive_tasks_ready` | who is doing what, what is ready now |
92
+ | `hive_tasks` | `list`/`show` (task + last-run record: output tail, heartbeat, overlaps) and `add`/`reopen`/`retry`/`rm` for ordering, splitting and remediation |
93
+ | `hive_arch_review` | record the architecture review of an accepted (done) task: appends a durable `arch_review` event `{ kind, task, verdict, findings }` to `.hive/events.jsonl` |
94
+ | `hive_events` | read the event tail (for example every `arch_review` still missing) |
95
+ | `hive_lesson_add`, `hive_recall` | knowledge management: read before planning, write after an episode |
96
+ | `hive_roles` | `list`/`add`/`rm` roles in `.hive/roles.yaml` |
97
+ | `hive_supervisor_status`, `hive_supervisor_control` | status; `pause`/`resume` a repository and `limits` (per-role agent caps) to throttle the swarm |
98
+ | `hive_anomalies` | `list`/`ack` the pending anomaly digest, `patrol` runs one audit tick now |
99
+ | `hive_intervene` | act on a stuck task (reopen/split/reassign/remove/rebuild/pause/fail/guide/escalate) and record it as an event |
100
+ | `hive_run_round` | run one round on demand (a registered queen Session is required) |
101
+
102
+ The tool surface keeps the boundary: none of the queen's tools claims or finishes a task
103
+ (`hive-tasks claim` / `done` belong to agents and the supervisor), and none edits or
104
+ commits code. The queen contract forbids code edits; task metadata
105
+ (add/reopen/retry/rm), roles and lessons are coordination state, not code.
106
+
107
+ ### When the queen hears from the supervisor
108
+
109
+ The runner turns supervision events — `card-failed`, `card-timeout`,
110
+ `heartbeat-warn`, `worker-aborted`, `round-failed`, `auto-paused`,
111
+ `environment-error` — into one compact digest and **injects it into the queen
112
+ conversation** through DSH's public Agent inbox:
113
+
114
+ ```text
115
+ agent.followup({ id, role: 'user', content: [{ type: 'text', text: digest }],
116
+ source: { kind: 'hive-runner' } })
117
+ ```
118
+
119
+ (`followup` queues an ordinary next turn and wakes the queen; `steer`/`inject` are
120
+ fallbacks. The user-role message with a plugin source kind passes the session-log
121
+ contract, so no DSH change is needed.) Duplicate events coalesce per
122
+ `(kind, repo, task)` (coalesced on the task id) in a ten-minute window and task events debounce for three seconds,
123
+ so a noisy minute becomes **one** message, not ten.
124
+
125
+ Two guarantees keep this quiet:
126
+
127
+ - **Only anomalies are delivered.** A healthy swarm produces no message at all; the
128
+ periodical **patrol** (`patrolMs`, default 5 minutes) re-reads the supervisor status,
129
+ reports auto-paused repositories, environment errors, stalled heartbeats and agents
130
+ past their deadline, and delivers only when something is pending.
131
+ - **Nothing is lost when no queen is live.** If the panel is closed or the Session is
132
+ gone the digest stays in the pending list: `hive_anomalies` lists and acknowledges it,
133
+ `hive_supervisor_status` reports `pendingAnomalies`, and the next registered queen
134
+ Session flushes the queue. `notifyQueen: false` keeps the pending list only.
135
+
136
+ ### The gates the queen orchestrates
137
+
138
+ 1. **Single task**: the agent commits and the task acceptance command must pass.
139
+ 2. **Architecture review**: the queen reviews every accepted task (batched at the next
140
+ patrol is fine) against directory/module boundaries, dependency direction, naming,
141
+ duplicated capabilities, error handling, docs/ADR updates, consistency with existing
142
+ patterns and test coverage; `pass` is recorded as an `arch_review` event,
143
+ `reject` reopens the task with a reason and spawns one or more fine-grained fix tasks.
144
+ 3. **Functional-group tests**: after a related set of tasks (one functional unit) lands,
145
+ she dispatches module-level integration test tasks.
146
+ 4. **Overall tests**: before release/delivery, separate tasks for smoke, end-to-end,
147
+ regression, performance, compatibility/cross-platform, security, and docs/examples
148
+ consistency — each with an executable acceptance command.
149
+ 5. **Release**: only after every gate is green; a failure at any gate becomes fix tasks
150
+ plus `after` links, never a silent retry.
151
+
152
+ ### Gate labels and release readiness
153
+
154
+ The gate order is mechanical, not just prose. Two labels turn the board into a
155
+ pipeline, and the supervisor refuses to dispatch a gate before the previous one is
156
+ all green:
157
+
158
+ | Tag | Tasks | Dispatches when |
159
+ | --- | --- | --- |
160
+ | (none) | ordinary work tasks | always |
161
+ | `gate:group` | module / functional-group integration tests | every base task is `done` |
162
+ | `gate:overall` | overall tests (smoke, e2e, regression, performance, compatibility, security, docs) | every `gate:group` task is `done` |
163
+
164
+ A phase is "all green" only when every task in it is `done`: a `failed` or `claimed`
165
+ task keeps the next gate closed, so the queen has to reopen/remove/fix it. This is a
166
+ tag plus ordinary dependencies — the four task states are unchanged. Status exposes the
167
+ computed `gate` per repository:
168
+
169
+ ```json
170
+ "gate": { "phase": "base|group|overall|released|no-overall|unknown",
171
+ "base": { "total": 3, "done": 1, "outstanding": 2, "failed": 0 },
172
+ "group": { ... }, "overall": { ... },
173
+ "releaseReady": false, "reason": "waiting for 2 base tasks to finish" }
174
+ ```
175
+
176
+ `releaseReady` is true only when an overall gate task exists and every gate is green —
177
+ the fact a release must be checked against. A repository with no `gate:overall` task
178
+ reports `phase: "no-overall"` and cannot be released.
179
+
180
+ ### Interventions on stuck tasks
181
+
182
+ The queen acts, not just reports. `hive_intervene` performs one action **and** records a
183
+ durable `queen_intervention` event `{ kind, task, action, reason, newCards?, removed? }`
184
+ in `.hive/events.jsonl`:
185
+
186
+ | Action | When | What happens |
187
+ | --- | --- | --- |
188
+ | `reopen` | the implementation path was wrong; the task itself is fine | reopens the task with the guidance in its `reason` — the next agent prompt opens with `## Queen guidance for this attempt`, so the diagnosis is the main guidance channel |
189
+ | `split` | the task is too coarse | creates fine-grained tasks (each needs `acceptance`), reopens the original with the new ids |
190
+ | `reassign` | the role/implementation route is wrong | creates tasks for another role, reopens the original |
191
+ | `remove` | the task content has no value or repeats are meaningless | deletes the task, but records its title/state/scope in the event first — nothing disappears silently |
192
+ | `rebuild` | title/scope/acceptance/dependencies were wrong | deletes and recreates it (new tasks reference the old id in `reason`/`after`); allowed at most twice per task |
193
+ | `pause` | the cause is environmental (missing external dependency) | pauses dispatch for the repository; status carries the reason |
194
+ | `fail` | no solution exists | only confirms a task an agent already failed (the queen never changes a task state) and records why |
195
+ | `guide` | an agent is live and a nudge helps | delivers the guidance message to that agent Session (optional path; the reopen reason remains the main channel) |
196
+ | `escalate` | a human must decide | records the escalation; after more than **3** interventions on one task the runner also writes a `queen_escalation` event and raises the error-severity `queen-escalation` anomaly (the red flag) |
197
+
198
+ Every action requires a reason with evidence. A reopen writes the guidance into the task's
199
+ reason, so the panel's task drawer shows it and the next agent prompt opens with it; the
200
+ events tail (`hive_events` / the panel's event list) shows every intervention and, for a
201
+ deletion, the removed task's summary.
202
+
203
+ ### Architecture review is audited
204
+
205
+ A `done` task must carry an `arch_review` event. Every patrol checks the board; a done
206
+ task with no review older than `archReviewGraceMs` (10 minutes) becomes an
207
+ `arch-review-missing` anomaly, is logged as a warning and appears in the queen's pending
208
+ digest. The queen reviews at the next patrol (batched) through
209
+ `hive_arch_review { card, verdict: pass|reject, findings[] }`, which appends an
210
+ `arch_review` event `{ kind, task, verdict, findings }`; a reject reopens the task and
211
+ spawns fine-grained fix tasks.
212
+
213
+ The queen contract's same-class rule: a third occurrence of one problem (three rejected
214
+ reviews of the same kind, three identical failures) is promoted to a convention —
215
+ written to `docs/CONVENTIONS.md` / `AGENTS.md` / an ADR, not just remembered in the chat.
216
+
217
+ ### New configuration
218
+
219
+ | Key | Default | Meaning |
220
+ | --- | --- | --- |
221
+ | `patrolMs` | `300000` (5 min) | queen patrol period; a tick delivers only when something is pending |
222
+ | `notifyQueen` | `true` | inject the digest into the registered queen Session; `false` = pending list only |
223
+ | `anomalyDebounceMs` | `3000` | coalescing window before one digest is sent |
224
+ | `anomalyMax` | `50` | bound on the undelivered anomaly queue |
225
+ | `archReviewGraceMs` | `600000` (10 min) | grace before a done task without an `arch_review` event is flagged |
226
+ | `rolesBin` | `null` | executable for `hive roles` (umbrella `@d86e/hive`); falls back to `hiveBin` |
227
+
79
228
  ## Requirements
80
229
 
81
230
  - DSH 0.2.2-rc.5 with the `desktop` or `web` profile — the version the plugin is
82
- developed against. Node 22 or newer.
231
+ developed against. Node 22.19 or newer.
83
232
  - The [hive](https://github.com/d86e/hive) and
84
233
  [hive-tasks](https://github.com/d86e/hive-tasks) packages. `hive-tasks` and `hive`
85
234
  are called by their PATH names by default and retried through `npx` when the shell
86
- cannot find them; `tasksBin`/`hiveBin` pin an explicit executable instead.
87
- - Repositories already initialised with Hive (`hive init`), unless you enable discovery.
235
+ cannot find them; `tasksBin`/`hiveBin`/`rolesBin` pin an explicit executable instead.
236
+ - Repositories already initialised with Hive (`hive init`); auto-discovery only finds
237
+ repositories that were initialised.
88
238
  - The [Hive panel](https://github.com/d86e/dsh-hive-panel) **0.2.3 or newer**. It
89
- registers the queen conversation when you initialise the repository there (and
90
- re-registers it on every panel access); without that registration the supervisor
91
- waits and dispatches nothing.
239
+ registers the queen conversation when a Session becomes the queen there (on `hive
240
+ init`, or when opening an already-initialised repository in queen mode) and
241
+ re-registers it on every panel access; without that registration the supervisor waits
242
+ and dispatches nothing.
92
243
 
93
244
  ## Install
94
245
 
@@ -100,31 +251,34 @@ DSH 0.2.2-rc.5):
100
251
  is locked while it runs. If the app has never been opened, start it once so it creates
101
252
  `~/.dsh/profiles/desktop/package.json`, then quit.
102
253
 
103
- 2. **Install the plugin into the profile.** `dsh` and `pnpm` must be on PATH; the
104
- command updates both `dependencies` and `dsh.profile.bundles`:
254
+ 2. **Install the panel and the plugin into the profile.** `dsh` and `pnpm` must be on
255
+ PATH; the command updates both `dependencies` and `dsh.profile.bundles`. The panel is
256
+ required: it registers the queen Session and exposes the supervisor controls.
105
257
 
106
258
  ```bash
107
- dsh plugin --profile desktop add dsh-hive-runner
259
+ dsh plugin --profile desktop add dsh-hive-panel dsh-hive-runner
108
260
  ```
109
261
 
110
262
  For a CLI profile such as `web`, use
111
- `dsh plugin --profile web add dsh-hive-runner` and restart with `dsh web`.
263
+ `dsh plugin --profile web add dsh-hive-panel dsh-hive-runner` and restart with
264
+ `dsh web`.
112
265
 
113
266
  3. Add your repositories to the `hive-runner` entry in that profile's
114
- `cordis.patch.yml`, restart DSH, and open the Hive panel's **Runner** tab.
267
+ `cordis.patch.yml`, restart DSH, and open an initialised repository in the Hive panel
268
+ so the Session becomes the queen.
115
269
 
116
270
  <details>
117
271
  <summary>Manual profile edit (same result, only needed when the CLI is unavailable)</summary>
118
272
 
119
- While DSH Desktop is not running, add `"dsh-hive-runner": "^0.6.7"` to the profile's
120
- `dependencies`, add `dsh-hive-runner` to `dsh.profile.bundles`, then
121
- `cd ~/.dsh/profiles/desktop && pnpm install`.
273
+ While DSH Desktop is not running, add `"dsh-hive-panel": ">=0.2.3"` and
274
+ `"dsh-hive-runner": "^0.7.0"` to the profile's `dependencies`, add both names to
275
+ `dsh.profile.bundles`, then `cd ~/.dsh/profiles/desktop && pnpm install`.
122
276
 
123
277
  </details>
124
278
 
125
279
  ## Five-minute quickstart
126
280
 
127
- 1. **Install** the plugin as above and restart DSH.
281
+ 1. **Install** the panel and the plugin as above and restart DSH.
128
282
  2. **Add one repository** to the `hive-runner` config entry:
129
283
 
130
284
  ```yaml
@@ -135,57 +289,62 @@ While DSH Desktop is not running, add `"dsh-hive-runner": "^0.6.7"` to the profi
135
289
  - /absolute/path/to/your/repo
136
290
  ```
137
291
 
138
- 3. **Create a ready card** in that repository (the Hive CLI, from the repository root):
292
+ 3. **Create a ready task** in that repository (the Hive CLI, from the repository root):
139
293
 
140
294
  ```bash
141
295
  hive tasks add --title "add token refresh" --role coder \
142
296
  --scope src/auth.ts --acceptance "npm test -- auth"
143
297
  ```
144
298
 
145
- 4. **Watch it run.** The supervisor ticks every 30 seconds, claims the card and starts a
146
- DSH subagent worker for it. The Hive panel's Runner tab shows the per-role limits, live
147
- workers and cards waiting for a slot; the card moves to done when the worker commits and
148
- the acceptance command passes.
149
- 5. **Adjust the swarm.** Set per-role worker counts in the panel (0 pauses a role), or
150
- pause the whole repository with the same tab. Changes take effect immediately.
299
+ 4. **Watch it run.** The supervisor ticks every 30 seconds, claims the task and starts a
300
+ DSH subagent for it. The Hive panel shows the supervisor state and running agent count,
301
+ and its agent-concurrency settings show the per-role limits with tasks waiting for a
302
+ slot; the task moves to done when the agent commits and the acceptance command passes.
303
+ 5. **Adjust the swarm.** Set the per-role agent limits in the panel's **Agent
304
+ concurrency** settings (0 pauses a role); changes take effect on the next dispatch.
305
+ To stop a repository, ask the queen to pause it (`hive_supervisor_control pause`) or
306
+ list it under `paused` in the config and restart.
151
307
 
152
308
  The supervisor keeps running with the panel closed. To stop all work, pause the
153
- repository or remove it from `repos`.
309
+ repository (queen or config) or remove it from `repos`.
154
310
 
155
- ## Changing the number of bees
311
+ ## Changing the number of agents
156
312
 
157
- Everything is controlled from the **Hive panel**:
313
+ The per-role limits are controlled from the **Hive panel**:
158
314
 
159
- 1. Open the Hive panel in DSH and select the **Runner** tab.
160
- 2. In **Per-role workers** (每角色蜂数量) set the number for each role: how many live
161
- workers of that role may run at the same time in that repository. Use 0 to pause a role.
162
- 3. Changes take effect immediately (no restart, no plugin reload).
315
+ 1. Open the Hive panel in DSH and open the repository's **Settings → Concurrency limit**
316
+ (设置 → 并发上限) dialog.
317
+ 2. Under **Agent concurrency** (智能体的并发上限) set the **Concurrency limit** (并发上限)
318
+ for each role: how many live agents of that role may run in that repository at the same
319
+ time. Use 0 to pause a role. The dialog also shows Running (运行) and Waiting (等待).
320
+ 3. Changes take effect on the next dispatch (no restart, no plugin reload).
163
321
  4. The value is saved to `<repo>/.hive/limits.json`, so it also survives DSH restarts.
164
322
  The file is plain JSON and **safe to commit** into the repository, which shares the same
165
323
  limits with every teammate and every machine.
166
324
 
167
- To pause or resume the whole repository, use the **Pause / Resume** button in the same
168
- Runner tab. Pause stops new work from being scheduled; cards that are already running
169
- finish, and resume makes the repository eligible again on the next tick.
325
+ The supervisor strip at the top of the Hive view shows the repository state (idle,
326
+ running, backoff, paused), the running agent count and a **resume** control. Pause stops
327
+ new work from being scheduled (tasks already running finish); resume makes the repository
328
+ eligible again on the next tick. Pausing is a queen decision (`hive_supervisor_control
329
+ pause` / `hive_intervene pause`) or a startup setting (`paused` in the config).
170
330
 
171
- The panel also shows, per role, the configured limit, how many workers are live right now,
172
- and how many cards are waiting for a slot. For a running card it exposes the worker
173
- Session (so you can open that conversation), the start time and a heartbeat warning when
174
- the worker has produced no commit/output for a while; stuck cards are aborted and failed
175
- at `cardTimeoutMs` (default 15 minutes).
331
+ The concurrency dialog shows, per role, the configured limit, how many agents are running
332
+ right now and how many tasks are waiting for a slot. For a running task the panel exposes
333
+ the agent Session (so you can open that conversation), the start time and a heartbeat
334
+ warning when the agent has produced no commit/output for a while; stuck tasks are aborted
335
+ and failed at `cardTimeoutMs` (default 15 minutes).
176
336
 
177
- ## How many bees should I set?
337
+ ## How many agents should I set?
178
338
 
179
339
  The limits are user settings, not a hardcoded number. Small values (the default 5 per
180
340
  role) keep token cost predictable. Only when you set the values very high does the
181
- supervisor approximate "as many bees as ready tasks", because the real ceiling is DSH's
341
+ supervisor approximate "as many agents as ready tasks", because the real ceiling is DSH's
182
342
  subagent capacity plus the model provider's rate limits:
183
343
 
184
- - DSH's profile setting `subagent.maxActiveSubagents` (desktop profile default 80 - check
185
- your profile) caps how many subagents can exist at once across the whole app. If more
186
- cards become ready than the capacity allows, they wait and are retried; no card is
187
- dropped.
188
- - Token consumption grows roughly linearly with the number of concurrent bees. Measure a
344
+ - DSH's profile setting `subagent.maxActiveSubagents` (check your profile) caps how many
345
+ subagents can exist at once across the whole app. If more tasks become ready than the
346
+ capacity allows, they wait and are retried; no task is dropped.
347
+ - Token consumption grows roughly linearly with the number of concurrent agents. Measure a
189
348
  small repository first, then raise the numbers.
190
349
  - If you want more parallelism than the default, raise both the panel limits and
191
350
  `subagent.maxActiveSubagents` (for example to 128), and confirm the provider rate limits.
@@ -202,15 +361,15 @@ accepted as plugin `config`. User-facing keys:
202
361
  | `discoverRoots` | `[]` | Roots to scan when auto-discovering; empty = parents of `repos` |
203
362
  | `intervalMs` / `idleBackoffMs` | `30000` / `120000` | How often to look for work / how long to wait when a repository is empty |
204
363
  | `maxConcurrentRepos` | `2` | How many repositories may work at the same time |
205
- | `cardTimeoutMs` | `900000` | Hard limit per card: abort the worker and fail the card at the deadline |
206
- | `heartbeatWarnMs` / `heartbeatIntervalMs` | `300000` / `30000` | Mark a running worker as heartbeat-warn after this long without output / how often to check |
207
- | `roleConcurrency` | `{ coder: 5, tester: 5 }` | Initial/fallback per-role worker limits |
364
+ | `cardTimeoutMs` | `900000` | Hard limit per task: abort the agent and fail the task at the deadline |
365
+ | `heartbeatWarnMs` / `heartbeatIntervalMs` | `300000` / `30000` | Mark a running agent as heartbeat-warn after this long without output / how often to check |
366
+ | `roleConcurrency` | `{ coder: 5, tester: 5 }` | Initial/fallback per-role agent limits |
208
367
  | `defaultRoleConcurrency` | `5` | Fallback for roles not listed in `roleConcurrency` |
209
368
  | `paused` | `[]` | Repositories paused at startup (absolute paths) |
210
- | `agent` / `ttl` | `dsh` / `20m` | Identity and claim TTL for claims (raise `ttl` for very large waiting queues) |
211
- | `provider` | `spawn` | DSH subagent provider used for workers |
212
- | `parentSession` | `null` | Optional live session used as the parent for workers |
213
- | `tasksBin` / `hiveBin` | `null` | Explicit `hive-tasks` / `hive` executables (PATH name or absolute path). Default: the PATH name, retried once through `npx -y -p hive-tasks` / `npx -y -p hive-consensus` when missing |
369
+ | `agent` / `ttl` | `dsh` / `20m` | Claim identity / claim TTL. Keep `ttl` at least `cardTimeoutMs` so a long run does not outlive its claim; the TTL never aborts a running agent |
370
+ | `provider` | `spawn` | DSH subagent provider used for agents |
371
+ | `parentSession` | `null` | Legacy fallback parent for agents, used only when the registered queen Session is not live |
372
+ | `tasksBin` / `hiveBin` / `rolesBin` | `null` | Explicit `hive-tasks` / `hive` / `hive roles` executables (PATH name or absolute path). Default: the PATH name, retried once through `npx -y -p hive-tasks` / `npx -y -p hive-consensus` / `npx -y -p @d86e/hive` when missing; `rolesBin` falls back to `hiveBin` |
214
373
  | `gitBin` | `git` | Git executable |
215
374
  | `cliTimeoutMs` / `headTimeoutMs` / `acceptanceTimeoutMs` | `120000` / `30000` / `900000` | Command timeouts |
216
375
  | `debug` | `false` | Verbose supervisor logging |
@@ -237,17 +396,18 @@ DSH host process (alive as long as the app runs)
237
396
  +-- HiveSupervisor: tick every 30 s, per-repository backoff, pause/resume
238
397
  | |
239
398
  | +-- repository registry: config.repos, discovery, <repo>/.hive/limits.json
240
- | +-- ready cards: hive-tasks through DSH's shell seam (sandbox applies)
399
+ | +-- ready tasks: hive-tasks through DSH's shell seam (sandbox applies)
241
400
  | +-- per-role queues: live-only slots, default 5, 0 pauses a role
242
401
  | |
243
- | +-- one card round
244
- | claim -> DSH subagent worker ("bee") -> commit + acceptance
402
+ | +-- one task round
403
+ | claim -> DSH subagent -> commit + acceptance
245
404
  | -> verify -> done | fail on the Hive board
246
405
  |
247
- +-- Hive panel Runner tab: per-role limits, live counts, pause/resume
406
+ +-- Hive panel: supervisor strip (state, running count, resume)
407
+ | and agent-concurrency settings (per-role limits)
248
408
  ```
249
409
 
250
- The supervisor owns the cadence (tick, backoff, persistence, pause state). A card worker
410
+ The supervisor owns the cadence (tick, backoff, persistence, pause state). A task's agent
251
411
  is a normal DSH subagent; its commands and shell run through the harness under the
252
412
  applicable sandbox policy.
253
413
 
@@ -255,70 +415,78 @@ applicable sandbox policy.
255
415
 
256
416
  | Project | What it does | How this plugin relates |
257
417
  | --- | --- | --- |
258
- | [hive](https://github.com/d86e/hive) | One CLI entry point: init, roles, tasks, run, board, commit, doctor | The supervisor reads state and cards through the Hive CLIs |
259
- | [hive-tasks](https://github.com/d86e/hive-tasks) | Task cards with dependencies, priority and acceptance | Ready cards are fetched, claimed, completed or failed through it |
260
- | [hive-consensus](https://github.com/d86e/hive-consensus) | Path announcements, presence board, freeze mode, shared lessons | `hive guard` publishes each worker's paths; overlaps are advisory and merge-on-commit resolves the concurrent writes |
418
+ | [hive](https://github.com/d86e/hive) | One CLI entry point: init, roles, tasks, plan, run, board, commit, stats, doctor | The supervisor reads state and tasks through the Hive CLIs |
419
+ | [hive-tasks](https://github.com/d86e/hive-tasks) | Tasks with dependencies, priority and acceptance | Ready tasks are fetched, claimed, completed or failed through it |
420
+ | [hive-consensus](https://github.com/d86e/hive-consensus) | Path announcements, presence board, freeze mode, shared lessons | `hive guard` publishes each agent's paths; overlaps are advisory and merge-on-commit resolves the concurrent writes |
261
421
  | [hive-runner](https://github.com/d86e/hive-runner) | One execution round per invocation (`hive-run --once`) | This plugin uses the same round primitives, resident and DSH-native |
262
- | [merge-on-commit](https://github.com/d86e/merge-on-commit) | Three-way merge at commit time | Workers' commits go through the repository hook like any other commit |
422
+ | [merge-on-commit](https://github.com/d86e/merge-on-commit) | Three-way merge at commit time | Agents' commits go through the repository hook like any other commit |
263
423
  | [hive-panel](https://github.com/d86e/hive-panel) | Standalone read-only board outside DSH | Not needed; [dsh-hive-panel](https://github.com/d86e/dsh-hive-panel) is the DSH-native board |
264
- | [dsh-hive-panel](https://github.com/d86e/dsh-hive-panel) | Hive view inside DSH Web | Optional UI: shows supervisor status and edits the per-role limits |
424
+ | [dsh-hive-panel](https://github.com/d86e/dsh-hive-panel) | Hive view inside DSH Web | Required for queen registration; shows the supervisor status, edits the per-role limits and resumes a paused repository |
265
425
 
266
426
  ## Relation to `hive-run --watch`
267
427
 
268
428
  `hive-run --watch` loops inside one CLI process over one repository. This plugin does
269
429
  **not** invoke `--watch` and does not modify the `hive-runner` CLI: the supervisor owns
270
- the cadence (tick every 30 s, back off when empty, persist per-role limits, pause/resume
271
- from the panel). `hive-run --once` still works manually; do not run it against a
430
+ the cadence (tick every 30 s, back off when empty, persist per-role limits, resume from
431
+ the panel). `hive-run --once` still works manually; do not run it against a
272
432
  repository while the supervisor is active on the same repository.
273
433
 
274
434
  ## FAQ and known limits
275
435
 
276
- **How many bees run at once?** Per role and per repository, the configured limit (default
277
- 5) of live workers. Across repositories, at most `maxConcurrentRepos` drains run at the
278
- same time; DSH's `subagent.maxActiveSubagents` is the hard ceiling below that. Cards that
436
+ **How many agents run at once?** Per role and per repository, the configured limit (default
437
+ 5) of live agents. Across repositories, at most `maxConcurrentRepos` drains run at the
438
+ same time; DSH's `subagent.maxActiveSubagents` is the hard ceiling below that. Tasks that
279
439
  do not fit wait and are retried, so very large limits do not increase real throughput by
280
440
  themselves, and token cost grows with concurrency.
281
441
 
282
- **A card is claimed but not started.** Cards waiting in a repository's queue hold their
283
- Hive claim; if the wait outlives the claim TTL (`ttl`, default 20m) the claim expires and
284
- the card can be reclaimed. Raise `ttl` for very large queues.
442
+ **A task stays claimed but never starts.** A claim is taken right before its agent
443
+ starts; an agent that ends without a verdict can leave one behind. It expires after the
444
+ claim TTL (`ttl`, default 20m) and the task becomes claimable again. Keep `ttl` at least
445
+ `cardTimeoutMs` so a long run does not outlive its claim.
285
446
 
286
- **A repository says it is waiting.** Workers need a live DSH agent as their parent. When
287
- no session is live the repository waits (and the panel says why) instead of failing.
447
+ **A repository says it is waiting.** Agents are parented to the registered queen
448
+ Session. Until the panel registers it (`waiting: no-queen-session`) nothing is
449
+ dispatched; the supervisor waits instead of failing. Re-open the repository in the Hive
450
+ panel after a restart to restore the registration.
288
451
 
289
452
  **A repository is paused and does not restart.** That is deliberate: auto-pause after
290
- three consecutive failures, and pause from the panel, both require an explicit resume.
453
+ three consecutive failures, and a queen/config pause, both require an explicit resume
454
+ (the panel's resume control, `hive_supervisor_control resume`, or removing the path
455
+ from `paused`).
291
456
 
292
- **Does it write without asking?** It claims cards and commits through the normal Hive and
293
- git flows of the repository. The acceptance command comes from the card, i.e. from the
457
+ **Does it write without asking?** It claims tasks and commits through the normal Hive and
458
+ git flows of the repository. The acceptance command comes from the task, i.e. from the
294
459
  repository; treat the repository as trusted input. A read-only deployment cannot claim or
295
- write cards.
460
+ write tasks.
296
461
 
297
462
  **What survives a DSH restart?** Per-role limits (in `.hive/limits.json`) and the Hive
298
- state (in git refs) survive. In-memory queues do not: claimed cards return to the board
299
- after their claim TTL.
463
+ state (in git refs) survive. In-memory queues and the queen registration do not: claimed
464
+ tasks return to the board after their claim TTL, and the panel re-registers the queen
465
+ Session on its next access.
300
466
 
301
- **Do I need the Hive panel?** No. The panel is the convenient front-end for limits and
302
- pause/resume; the supervisor works from `cordis.patch.yml` alone.
467
+ **Do I need the Hive panel?** Yes. The supervisor itself starts from `cordis.patch.yml`
468
+ alone, but nothing is dispatched until a live Session registers as the queen; the panel
469
+ is what registers it (on init/queen mode) and exposes the limits and resume controls.
303
470
 
304
471
  ## Development
305
472
 
306
473
  ```bash
307
- npm test # node --test test/*.test.js (124 tests)
474
+ npm test # node --test test/*.test.js (197 tests)
308
475
  npm run check # node --check on index.js and lib/
309
476
  npm pack --dry-run
310
477
  ```
311
478
 
312
479
  The test suite is a pure shim (no DSH process, no real timers, no real CLI) and covers the
313
- default five-per-role limits, live-only slot accounting with immediate refill, queued cards
314
- not occupying slots, 0 pausing a role, persisted limits taking effect immediately and
315
- surviving a restart, invalid limit updates being rejected, the state machine, card round
316
- paths, discovery, the command allowlist, and an architecture guard that the plugin never
317
- spawns child processes.
480
+ default five-per-role limits, live-only slot accounting with immediate refill, queued tasks
481
+ not counting against a slot, 0 pausing a role, persisted limits taking effect immediately
482
+ and surviving a restart, invalid limit updates being rejected, the state machine, task
483
+ round paths, discovery, the gate pipeline, queen-session dispatch and parenting, the
484
+ anomaly feed/patrol/notifier pipeline, arch-review and intervention events, the command
485
+ allowlist, and an architecture guard that the plugin never spawns child processes.
318
486
 
319
487
  The protocol is specified in [SPEC.md](SPEC.md); implementation notes are in
320
488
  [docs/DESIGN.md](docs/DESIGN.md).
321
489
 
322
490
  ## License
323
491
 
324
- MIT © Tommy. See [LICENSE](LICENSE).
492
+ MIT © Tommy. See [LICENSE](LICENSE).