dsh-hive-runner 0.6.4 → 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/CHANGELOG.md +179 -0
- package/README.md +297 -100
- package/README.zh-CN.md +203 -63
- package/SPEC.md +227 -61
- package/cordis.patch.yml +38 -6
- package/docs/DESIGN.md +122 -31
- package/index.js +617 -37
- package/lib/anomalies.js +216 -0
- package/lib/audit.js +134 -0
- package/lib/commands.js +282 -12
- package/lib/config.js +51 -1
- package/lib/events.js +249 -0
- package/lib/gates.js +101 -0
- package/lib/host-env.js +51 -22
- package/lib/http.js +59 -4
- package/lib/notify.js +145 -0
- package/lib/patrol.js +218 -0
- package/lib/round.js +430 -124
- package/lib/runs.js +96 -4
- package/lib/supervisor.js +152 -1
- package/package.json +1 -1
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
|
|
8
|
-
|
|
9
|
-
|
|
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
|
[](https://github.com/d86e/dsh-hive-runner/actions)
|
|
12
12
|
[](https://www.npmjs.com/package/dsh-hive-runner)
|
|
@@ -17,54 +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:
|
|
21
|
-
|
|
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.
|
|
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
|
|
34
|
-
subagent per
|
|
35
|
-
- **Only
|
|
36
|
-
|
|
37
|
-
same role starts.
|
|
38
|
-
- Each role has its own limit. The default is **5 live
|
|
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
|
|
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
|
|
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
|
-
-
|
|
48
|
-
with `hive guard`
|
|
49
|
-
and
|
|
50
|
-
|
|
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
|
+
`resource:` keys) and clears those announcements afterwards. An overlap with another
|
|
50
|
+
agent's announcement is advisory only: the agent keeps working, and merge-on-commit
|
|
51
|
+
three-way merges the concurrent edits at commit time (unresolved conflicts stay as
|
|
52
|
+
markers).
|
|
53
|
+
- Lessons are read before every task and written after it: the supervisor runs
|
|
54
|
+
`hive recall` for every scope path plus the repository root and injects the
|
|
55
|
+
deduplicated matches at the top of the agent prompt; agents record genuinely new
|
|
56
|
+
knowledge with `hive lesson add`. Writing a lesson and reading it at the start of the
|
|
57
|
+
next task are a pair — one without the other does not compound.
|
|
51
58
|
- Commits are verified against merge-on-commit: the repository must have the
|
|
52
|
-
merge-on-commit pre-commit hook (`hive init` installs it), and a
|
|
59
|
+
merge-on-commit pre-commit hook (`hive init` installs it), and a task only counts as
|
|
53
60
|
done when HEAD moved through that hook.
|
|
54
|
-
- While the repository is in Hive freeze mode, non-fix
|
|
61
|
+
- While the repository is in Hive freeze mode, non-fix tasks stay on the board instead of
|
|
55
62
|
failing.
|
|
56
63
|
|
|
64
|
+
## Agent sessions
|
|
65
|
+
|
|
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.
|
|
72
|
+
|
|
73
|
+
- Nothing is dispatched before the queen Session is registered: status reports
|
|
74
|
+
`waiting: no-queen-session`, a startup-order hint rather than an error.
|
|
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.
|
|
77
|
+
- Once registered, dispatch works with zero other user sessions and keeps running when
|
|
78
|
+
the panel/UI is closed.
|
|
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
|
+
|
|
57
228
|
## Requirements
|
|
58
229
|
|
|
59
230
|
- DSH 0.2.2-rc.5 with the `desktop` or `web` profile — the version the plugin is
|
|
60
|
-
developed against. Node 22 or newer.
|
|
231
|
+
developed against. Node 22.19 or newer.
|
|
61
232
|
- The [hive](https://github.com/d86e/hive) and
|
|
62
233
|
[hive-tasks](https://github.com/d86e/hive-tasks) packages. `hive-tasks` and `hive`
|
|
63
234
|
are called by their PATH names by default and retried through `npx` when the shell
|
|
64
|
-
cannot find them; `tasksBin`/`hiveBin` pin an explicit executable instead.
|
|
65
|
-
- Repositories already initialised with Hive (`hive init`)
|
|
66
|
-
|
|
67
|
-
|
|
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.
|
|
238
|
+
- The [Hive panel](https://github.com/d86e/dsh-hive-panel) **0.2.3 or newer**. It
|
|
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.
|
|
68
243
|
|
|
69
244
|
## Install
|
|
70
245
|
|
|
@@ -76,31 +251,34 @@ DSH 0.2.2-rc.5):
|
|
|
76
251
|
is locked while it runs. If the app has never been opened, start it once so it creates
|
|
77
252
|
`~/.dsh/profiles/desktop/package.json`, then quit.
|
|
78
253
|
|
|
79
|
-
2. **Install the plugin into the profile.** `dsh` and `pnpm` must be on
|
|
80
|
-
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.
|
|
81
257
|
|
|
82
258
|
```bash
|
|
83
|
-
dsh plugin --profile desktop add dsh-hive-runner
|
|
259
|
+
dsh plugin --profile desktop add dsh-hive-panel dsh-hive-runner
|
|
84
260
|
```
|
|
85
261
|
|
|
86
262
|
For a CLI profile such as `web`, use
|
|
87
|
-
`dsh plugin --profile web add dsh-hive-runner` and restart with
|
|
263
|
+
`dsh plugin --profile web add dsh-hive-panel dsh-hive-runner` and restart with
|
|
264
|
+
`dsh web`.
|
|
88
265
|
|
|
89
266
|
3. Add your repositories to the `hive-runner` entry in that profile's
|
|
90
|
-
`cordis.patch.yml`, restart DSH, and open the Hive panel
|
|
267
|
+
`cordis.patch.yml`, restart DSH, and open an initialised repository in the Hive panel
|
|
268
|
+
so the Session becomes the queen.
|
|
91
269
|
|
|
92
270
|
<details>
|
|
93
271
|
<summary>Manual profile edit (same result, only needed when the CLI is unavailable)</summary>
|
|
94
272
|
|
|
95
|
-
While DSH Desktop is not running, add `"dsh-hive-
|
|
96
|
-
`
|
|
97
|
-
`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`.
|
|
98
276
|
|
|
99
277
|
</details>
|
|
100
278
|
|
|
101
279
|
## Five-minute quickstart
|
|
102
280
|
|
|
103
|
-
1. **Install** the plugin as above and restart DSH.
|
|
281
|
+
1. **Install** the panel and the plugin as above and restart DSH.
|
|
104
282
|
2. **Add one repository** to the `hive-runner` config entry:
|
|
105
283
|
|
|
106
284
|
```yaml
|
|
@@ -111,54 +289,62 @@ While DSH Desktop is not running, add `"dsh-hive-runner": "^0.6.4"` to the profi
|
|
|
111
289
|
- /absolute/path/to/your/repo
|
|
112
290
|
```
|
|
113
291
|
|
|
114
|
-
3. **Create a ready
|
|
292
|
+
3. **Create a ready task** in that repository (the Hive CLI, from the repository root):
|
|
115
293
|
|
|
116
294
|
```bash
|
|
117
295
|
hive tasks add --title "add token refresh" --role coder \
|
|
118
296
|
--scope src/auth.ts --acceptance "npm test -- auth"
|
|
119
297
|
```
|
|
120
298
|
|
|
121
|
-
4. **Watch it run.** The supervisor ticks every 30 seconds, claims the
|
|
122
|
-
DSH subagent
|
|
123
|
-
|
|
124
|
-
the acceptance command passes.
|
|
125
|
-
5. **Adjust the swarm.** Set per-role
|
|
126
|
-
|
|
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.
|
|
127
307
|
|
|
128
308
|
The supervisor keeps running with the panel closed. To stop all work, pause the
|
|
129
|
-
repository or remove it from `repos`.
|
|
309
|
+
repository (queen or config) or remove it from `repos`.
|
|
130
310
|
|
|
131
|
-
## Changing the number of
|
|
311
|
+
## Changing the number of agents
|
|
132
312
|
|
|
133
|
-
|
|
313
|
+
The per-role limits are controlled from the **Hive panel**:
|
|
134
314
|
|
|
135
|
-
1. Open the Hive panel in DSH and
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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).
|
|
139
321
|
4. The value is saved to `<repo>/.hive/limits.json`, so it also survives DSH restarts.
|
|
140
322
|
The file is plain JSON and **safe to commit** into the repository, which shares the same
|
|
141
323
|
limits with every teammate and every machine.
|
|
142
324
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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).
|
|
146
330
|
|
|
147
|
-
The
|
|
148
|
-
and how many
|
|
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).
|
|
149
336
|
|
|
150
|
-
## How many
|
|
337
|
+
## How many agents should I set?
|
|
151
338
|
|
|
152
339
|
The limits are user settings, not a hardcoded number. Small values (the default 5 per
|
|
153
340
|
role) keep token cost predictable. Only when you set the values very high does the
|
|
154
|
-
supervisor approximate "as many
|
|
341
|
+
supervisor approximate "as many agents as ready tasks", because the real ceiling is DSH's
|
|
155
342
|
subagent capacity plus the model provider's rate limits:
|
|
156
343
|
|
|
157
|
-
- DSH's profile setting `subagent.maxActiveSubagents` (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
- 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
|
|
162
348
|
small repository first, then raise the numbers.
|
|
163
349
|
- If you want more parallelism than the default, raise both the panel limits and
|
|
164
350
|
`subagent.maxActiveSubagents` (for example to 128), and confirm the provider rate limits.
|
|
@@ -175,13 +361,15 @@ accepted as plugin `config`. User-facing keys:
|
|
|
175
361
|
| `discoverRoots` | `[]` | Roots to scan when auto-discovering; empty = parents of `repos` |
|
|
176
362
|
| `intervalMs` / `idleBackoffMs` | `30000` / `120000` | How often to look for work / how long to wait when a repository is empty |
|
|
177
363
|
| `maxConcurrentRepos` | `2` | How many repositories may work at the same time |
|
|
178
|
-
| `
|
|
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 |
|
|
179
367
|
| `defaultRoleConcurrency` | `5` | Fallback for roles not listed in `roleConcurrency` |
|
|
180
368
|
| `paused` | `[]` | Repositories paused at startup (absolute paths) |
|
|
181
|
-
| `agent` / `ttl` | `dsh` / `
|
|
182
|
-
| `provider` | `spawn` | DSH subagent provider used for
|
|
183
|
-
| `parentSession` | `null` |
|
|
184
|
-
| `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` |
|
|
185
373
|
| `gitBin` | `git` | Git executable |
|
|
186
374
|
| `cliTimeoutMs` / `headTimeoutMs` / `acceptanceTimeoutMs` | `120000` / `30000` / `900000` | Command timeouts |
|
|
187
375
|
| `debug` | `false` | Verbose supervisor logging |
|
|
@@ -208,17 +396,18 @@ DSH host process (alive as long as the app runs)
|
|
|
208
396
|
+-- HiveSupervisor: tick every 30 s, per-repository backoff, pause/resume
|
|
209
397
|
| |
|
|
210
398
|
| +-- repository registry: config.repos, discovery, <repo>/.hive/limits.json
|
|
211
|
-
| +-- ready
|
|
399
|
+
| +-- ready tasks: hive-tasks through DSH's shell seam (sandbox applies)
|
|
212
400
|
| +-- per-role queues: live-only slots, default 5, 0 pauses a role
|
|
213
401
|
| |
|
|
214
|
-
| +-- one
|
|
215
|
-
| claim -> DSH subagent
|
|
402
|
+
| +-- one task round
|
|
403
|
+
| claim -> DSH subagent -> commit + acceptance
|
|
216
404
|
| -> verify -> done | fail on the Hive board
|
|
217
405
|
|
|
|
218
|
-
+-- Hive panel
|
|
406
|
+
+-- Hive panel: supervisor strip (state, running count, resume)
|
|
407
|
+
| and agent-concurrency settings (per-role limits)
|
|
219
408
|
```
|
|
220
409
|
|
|
221
|
-
The supervisor owns the cadence (tick, backoff, persistence, pause state). A
|
|
410
|
+
The supervisor owns the cadence (tick, backoff, persistence, pause state). A task's agent
|
|
222
411
|
is a normal DSH subagent; its commands and shell run through the harness under the
|
|
223
412
|
applicable sandbox policy.
|
|
224
413
|
|
|
@@ -226,70 +415,78 @@ applicable sandbox policy.
|
|
|
226
415
|
|
|
227
416
|
| Project | What it does | How this plugin relates |
|
|
228
417
|
| --- | --- | --- |
|
|
229
|
-
| [hive](https://github.com/d86e/hive) | One CLI entry point: init, roles, tasks, run, board, commit, doctor | The supervisor reads state and
|
|
230
|
-
| [hive-tasks](https://github.com/d86e/hive-tasks) |
|
|
231
|
-
| [hive-consensus](https://github.com/d86e/hive-consensus) | Path
|
|
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 |
|
|
232
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 |
|
|
233
|
-
| [merge-on-commit](https://github.com/d86e/merge-on-commit) | Three-way merge at commit time |
|
|
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 |
|
|
234
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 |
|
|
235
|
-
| [dsh-hive-panel](https://github.com/d86e/dsh-hive-panel) | Hive view inside DSH Web |
|
|
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 |
|
|
236
425
|
|
|
237
426
|
## Relation to `hive-run --watch`
|
|
238
427
|
|
|
239
428
|
`hive-run --watch` loops inside one CLI process over one repository. This plugin does
|
|
240
429
|
**not** invoke `--watch` and does not modify the `hive-runner` CLI: the supervisor owns
|
|
241
|
-
the cadence (tick every 30 s, back off when empty, persist per-role limits,
|
|
242
|
-
|
|
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
|
|
243
432
|
repository while the supervisor is active on the same repository.
|
|
244
433
|
|
|
245
434
|
## FAQ and known limits
|
|
246
435
|
|
|
247
|
-
**How many
|
|
248
|
-
5) of live
|
|
249
|
-
same time; DSH's `subagent.maxActiveSubagents` is the hard ceiling below 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
|
|
250
439
|
do not fit wait and are retried, so very large limits do not increase real throughput by
|
|
251
440
|
themselves, and token cost grows with concurrency.
|
|
252
441
|
|
|
253
|
-
**A
|
|
254
|
-
|
|
255
|
-
the
|
|
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.
|
|
256
446
|
|
|
257
|
-
**A repository says it is waiting.**
|
|
258
|
-
|
|
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.
|
|
259
451
|
|
|
260
452
|
**A repository is paused and does not restart.** That is deliberate: auto-pause after
|
|
261
|
-
three consecutive failures, and
|
|
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`).
|
|
262
456
|
|
|
263
|
-
**Does it write without asking?** It claims
|
|
264
|
-
git flows of the repository. The acceptance command comes 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
|
|
265
459
|
repository; treat the repository as trusted input. A read-only deployment cannot claim or
|
|
266
|
-
write
|
|
460
|
+
write tasks.
|
|
267
461
|
|
|
268
462
|
**What survives a DSH restart?** Per-role limits (in `.hive/limits.json`) and the Hive
|
|
269
|
-
state (in git refs) survive. In-memory queues do not: claimed
|
|
270
|
-
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.
|
|
271
466
|
|
|
272
|
-
**Do I need the Hive panel?**
|
|
273
|
-
|
|
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.
|
|
274
470
|
|
|
275
471
|
## Development
|
|
276
472
|
|
|
277
473
|
```bash
|
|
278
|
-
npm test # node --test test/*.test.js (
|
|
474
|
+
npm test # node --test test/*.test.js (197 tests)
|
|
279
475
|
npm run check # node --check on index.js and lib/
|
|
280
476
|
npm pack --dry-run
|
|
281
477
|
```
|
|
282
478
|
|
|
283
479
|
The test suite is a pure shim (no DSH process, no real timers, no real CLI) and covers the
|
|
284
|
-
default five-per-role limits, live-only slot accounting with immediate refill, queued
|
|
285
|
-
not
|
|
286
|
-
surviving a restart, invalid limit updates being rejected, the state machine,
|
|
287
|
-
paths, discovery, the
|
|
288
|
-
|
|
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.
|
|
289
486
|
|
|
290
487
|
The protocol is specified in [SPEC.md](SPEC.md); implementation notes are in
|
|
291
488
|
[docs/DESIGN.md](docs/DESIGN.md).
|
|
292
489
|
|
|
293
490
|
## License
|
|
294
491
|
|
|
295
|
-
MIT © Tommy. See [LICENSE](LICENSE).
|
|
492
|
+
MIT © Tommy. See [LICENSE](LICENSE).
|