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/CHANGELOG.md +67 -0
- package/README.md +284 -116
- package/README.zh-CN.md +197 -72
- package/SPEC.md +162 -60
- package/cordis.patch.yml +24 -4
- package/docs/DESIGN.md +88 -42
- package/index.js +595 -37
- package/lib/anomalies.js +216 -0
- package/lib/audit.js +134 -0
- package/lib/commands.js +266 -3
- package/lib/config.js +24 -0
- package/lib/events.js +249 -0
- package/lib/gates.js +101 -0
- package/lib/http.js +42 -4
- package/lib/notify.js +145 -0
- package/lib/patrol.js +218 -0
- package/lib/round.js +45 -3
- package/lib/runs.js +19 -0
- package/lib/supervisor.js +96 -1
- package/package.json +1 -1
package/SPEC.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-hive-runner — protocol specification
|
|
2
2
|
|
|
3
|
-
Status: 0.
|
|
3
|
+
Status: 0.7.0, verified against DSH 0.2.2-rc.5.
|
|
4
4
|
|
|
5
5
|
This document is normative for the host contract of the plugin. It is written for
|
|
6
6
|
maintainers: user documentation is [README.md](README.md) and
|
|
@@ -15,18 +15,19 @@ notes are in [docs/DESIGN.md](docs/DESIGN.md).
|
|
|
15
15
|
| `main` / `exports["."]` | `./index.js` | Cordis host plugin (`name`, `inject`, `apply`) |
|
|
16
16
|
| `dsh.bundle.patch` | `./cordis.patch.yml` | Inserts the host plugin entry (`id: hive-runner`) into the composition |
|
|
17
17
|
| `peerDependencies` | `@deepseek-ai/dsh-tools` | Provided by the DSH host |
|
|
18
|
-
| `engines.node` | `>=22` | Matches the DSH runtime |
|
|
18
|
+
| `engines.node` | `>=22.19` | Matches the DSH runtime |
|
|
19
19
|
|
|
20
20
|
## 2. Host surfaces
|
|
21
21
|
|
|
22
22
|
| Surface | Registration | Purpose |
|
|
23
23
|
| --- | --- | --- |
|
|
24
24
|
| `HiveSupervisor` | `ctx.provide('hiveSupervisor', supervisor)` | Resident scheduler service |
|
|
25
|
-
| Timer | `ctx.effect(() => { supervisor.start(); return () => supervisor.stop() })` | Ticks while DSH runs, independent of browser tabs |
|
|
25
|
+
| Timer | `ctx.effect(() => { supervisor.start(); patrol.start(); return () => { patrol.stop(); supervisor.stop() } })` | Ticks while DSH runs, independent of browser tabs |
|
|
26
26
|
| Fetch route | `ctx.connection.fetch.register({ path: '/api/hive-runner', methods: ['GET','POST'], requestBody: 'buffered', fetch })` | Same-origin control and observability |
|
|
27
|
-
|
|
|
27
|
+
| Queen notifier | `agent.followup(createUserMessage(...))` on the live registered queen Session | Delivers one anomaly digest; `steer`/`inject` fallbacks |
|
|
28
|
+
| Tools | `ctx.tools.register(defineTool(...))` | See §7: round/board/tasks/arch-review/events/lessons/recall/roles/supervisor-control/interventions/anomalies |
|
|
28
29
|
|
|
29
|
-
All shell work goes through `ctx.shell.resolve` + `ctx.shell.execute`;
|
|
30
|
+
All shell work goes through `ctx.shell.resolve` + `ctx.shell.execute`; task agents are
|
|
30
31
|
DSH subagents started with `ctx.subagents.startActivation`. The plugin never imports
|
|
31
32
|
`node:child_process` (architecture test).
|
|
32
33
|
|
|
@@ -57,6 +58,7 @@ wrong method -> `405` (`hive/method-not-allowed`).
|
|
|
57
58
|
"waiting": null,
|
|
58
59
|
"lastTickAt": "2026-12-04T00:00:00.000Z",
|
|
59
60
|
"lastDiscoverError": null,
|
|
61
|
+
"pendingAnomalies": 0,
|
|
60
62
|
"repos": [
|
|
61
63
|
{
|
|
62
64
|
"repo": "/abs/repo",
|
|
@@ -97,27 +99,29 @@ wrong method -> `405` (`hive/method-not-allowed`).
|
|
|
97
99
|
"environmentError": null,
|
|
98
100
|
"mode": null,
|
|
99
101
|
"frozenSkipped": 0,
|
|
100
|
-
"lastSkipReason": null
|
|
102
|
+
"lastSkipReason": null,
|
|
103
|
+
"gate": null
|
|
101
104
|
}
|
|
102
105
|
]
|
|
103
106
|
}
|
|
104
107
|
```
|
|
105
108
|
|
|
106
|
-
- `roles[role].limit` — effective live-
|
|
109
|
+
- `roles[role].limit` — effective live-agent cap (persisted file > repo config >
|
|
107
110
|
global role config > `defaultRoleConcurrency`).
|
|
108
|
-
- `roles[role].live` —
|
|
111
|
+
- `roles[role].live` — agents running right now; a finished agent frees its slot
|
|
109
112
|
immediately.
|
|
110
|
-
- `roles[role].queued` — fetched
|
|
113
|
+
- `roles[role].queued` — fetched tasks waiting for a slot; they do not count as live.
|
|
111
114
|
- `backlog` — aggregate `{ queued, inFlight, completed }` for the current or last drain.
|
|
112
|
-
- `queenSessionId` — the queen conversation registered by the panel;
|
|
113
|
-
parented to it. `waiting` is
|
|
115
|
+
- `queenSessionId` — the queen conversation registered by the panel; agents are
|
|
116
|
+
parented to that Session while it is live (see §8). `waiting` is
|
|
117
|
+
`"no-queen-session"` until that registration happens.
|
|
114
118
|
- `waiting` — per repository (and top level) `"no-queen-session"` before the queen
|
|
115
119
|
Session is registered; then `null`. It is a startup-order hint, never an error.
|
|
116
|
-
- `workers` — the
|
|
120
|
+
- `workers` — the agents currently running in this repository, each with
|
|
117
121
|
`cardId`, `role`, `agent`, `sessionId`, `agentName`, `parentSource` (`queen`),
|
|
118
122
|
`startedAt`, `lastOutputAt`,
|
|
119
123
|
`heartbeat` (`ok` | `warn`), `claimDeadline` and `timeoutAt`; the panel uses the
|
|
120
|
-
Session id to open the
|
|
124
|
+
Session id to open the agent chat.
|
|
121
125
|
- `state` — `idle` | `running` | `backoff` | `paused`.
|
|
122
126
|
|
|
123
127
|
### 3.2 `POST ?op=pause` / `POST ?op=resume`
|
|
@@ -140,6 +144,17 @@ Body:
|
|
|
140
144
|
- Response: `{ ok: true, op: "limits", repo: <repository status> }`.
|
|
141
145
|
- Malformed values -> `400` `hive/invalid-role-limits`.
|
|
142
146
|
|
|
147
|
+
### 3.4 `GET ?op=pending` / `POST ?op=ack`
|
|
148
|
+
|
|
149
|
+
Pending queen anomalies (the digest queue). `GET ?op=pending[&all=1]` returns
|
|
150
|
+
`{ ok: true, op: "pending", count, items: [{ id, kind, severity, repo, cardId, role,
|
|
151
|
+
summary, detail, count, at, lastAt, deliveredAt }] }`; `all=1` includes already
|
|
152
|
+
delivered entries. `POST ?op=ack { ids: [...] }` marks entries delivered and returns
|
|
153
|
+
`{ ok: true, op: "ack", changed }`; a missing/empty `ids` array -> `400`
|
|
154
|
+
`hive/missing-ids`, a non-POST -> `405`. Anomaly delivery itself does not use this
|
|
155
|
+
route: the supervisor injects the digest into the queen Session and only falls back to
|
|
156
|
+
the pending list when no live Session exists.
|
|
157
|
+
|
|
143
158
|
## 4. Per-repository limits
|
|
144
159
|
|
|
145
160
|
Precedence for one role in one repository:
|
|
@@ -156,27 +171,27 @@ The persisted file contains only runtime overrides and is safe to commit. Shape:
|
|
|
156
171
|
|
|
157
172
|
## 5. Concurrency and capacity
|
|
158
173
|
|
|
159
|
-
- At most 5 **live**
|
|
160
|
-
- Queued
|
|
161
|
-
queued
|
|
174
|
+
- At most 5 **live** agents per role per repository by default.
|
|
175
|
+
- Queued tasks do not use a slot; when an agent finishes it immediately takes the next
|
|
176
|
+
queued task of the same role.
|
|
162
177
|
- `maxConcurrentRepos` (default 2) limits how many repositories drain at the same time;
|
|
163
178
|
a single repository is always serial.
|
|
164
179
|
- DSH's `subagent.maxActiveSubagents` is the hard ceiling below the plugin:
|
|
165
180
|
`startActivation` can reject with `ACTIVATION_LIMIT_REACHED`. The queue requeues the
|
|
166
|
-
claimed
|
|
167
|
-
- A role limit of `0` leaves the role's ready
|
|
181
|
+
claimed task, waits `capacityRetryMs` (default 2000) and retries; nothing is dropped.
|
|
182
|
+
- A role limit of `0` leaves the role's ready tasks untouched on the Hive board.
|
|
168
183
|
|
|
169
184
|
## 6. Supervisor state machine
|
|
170
185
|
|
|
171
186
|
```text
|
|
172
|
-
idle --tick, ready
|
|
173
|
-
idle --tick, no
|
|
187
|
+
idle --tick, ready tasks--> running --drain done--> idle (next tick)
|
|
188
|
+
idle --tick, no tasks--> backoff (idleBackoffMs)
|
|
174
189
|
running --drain exception--> backoff (intervalMs * 2^failures, capped at idleBackoffMs)
|
|
175
190
|
running --3 consecutive exceptions--> paused (auto; requires explicit resume)
|
|
176
191
|
paused --resume--> idle
|
|
177
192
|
```
|
|
178
193
|
|
|
179
|
-
|
|
194
|
+
Task-level failures (no commit, acceptance failure, non-completed subagent) are recorded
|
|
180
195
|
in Hive as `fail` and do not count as round exceptions. Environmental errors (no live
|
|
181
196
|
parent agent, no subagent provider) are deferrable: they set `lastError` and back off
|
|
182
197
|
for `idleBackoffMs` without consuming the failure budget.
|
|
@@ -188,60 +203,76 @@ repository unless it is that default.
|
|
|
188
203
|
|
|
189
204
|
| Tool | Parameters | Output |
|
|
190
205
|
| --- | --- | --- |
|
|
191
|
-
| `hive_run_round` | `repo`, `ttl`, `agent` | Per-
|
|
192
|
-
| `hive_tasks_ready` | `repo`, `role`, `limit` | Ready
|
|
206
|
+
| `hive_run_round` | `repo`, `ttl`, `agent` | Per-task results, role state and remaining queue |
|
|
207
|
+
| `hive_tasks_ready` | `repo`, `role`, `limit` | Ready tasks, best first |
|
|
193
208
|
| `hive_board` | `repo` | Presence board |
|
|
194
|
-
| `hive_supervisor_status` | - | Same data as `GET ?op=status` |
|
|
209
|
+
| `hive_supervisor_status` | - | Same data as `GET ?op=status` (including `pendingAnomalies`) |
|
|
210
|
+
| `hive_tasks` | `action` = `list`/`show`/`add`/`reopen`/`retry`/`rm` + task fields | Tasks with a `lastRun` summary (output tail, heartbeat, overlaps); add/reopen/retry/rm return the changed task |
|
|
211
|
+
| `hive_arch_review` | `repo`, `card`, `verdict: pass\|reject`, `findings[]`, `summary` | Appends an `arch_review` event; the task must be `done`; a `reject` needs at least one actionable finding |
|
|
212
|
+
| `hive_events` | `repo`, `kind`, `task`, `limit` | Event-log tail, newest first |
|
|
213
|
+
| `hive_lesson_add` | `repo`, `text`, `scope`, `evidence`, `status` | `hive lesson add` output |
|
|
214
|
+
| `hive_recall` | `repo`, `query` | Applicable lessons |
|
|
215
|
+
| `hive_roles` | `action` = `list`/`add`/`rm` + `name`, `adapter`, `model`, `prompt`, `description`, `force` | `hive roles` output |
|
|
216
|
+
| `hive_supervisor_control` | `action` = `status`/`pause`/`resume`/`limits`, `repo`, `reason`, `roleLimits` | Supervisor/repository snapshot |
|
|
217
|
+
| `hive_anomalies` | `action` = `list`/`ack`/`patrol`, `ids`, `all`, `limit` | Pending digest queue or one patrol result |
|
|
218
|
+
| `hive_intervene` | `repo`, `action: reopen|split|reassign|pause|fail|guide|remove|rebuild|escalate`, `card`, `reason`, `cards[]`, `role`, `sessionId` | The intervention event, created tasks, intervention count and escalation flag |
|
|
219
|
+
|
|
220
|
+
The queen's tools never claim or finish a task: `hive-tasks claim`/`done` stay with the
|
|
221
|
+
supervisor. `hive tasks rm` is forwarded without `--force`, so a claimed task is refused
|
|
222
|
+
by the CLI instead of being deleted under a live agent. `hive_run_round` refuses to run
|
|
223
|
+
before a queen Session is registered (it throws `waiting: no-queen-session`).
|
|
195
224
|
|
|
196
225
|
Tool-triggered rounds use the calling Session's sandbox policy; resident rounds use the
|
|
197
226
|
deployment policy with the repository pinned as the workspace root.
|
|
198
227
|
|
|
199
|
-
## 8. Round preconditions and
|
|
228
|
+
## 8. Round preconditions and agent protocol
|
|
200
229
|
|
|
201
|
-
Every
|
|
230
|
+
Every task agent is parented to the **queen conversation**: the Session where the
|
|
202
231
|
panel was initialised and the queen took over. The panel registers that Session id
|
|
203
232
|
with the supervisor (`POST /api/hive-runner?op=queen { sessionId }` or
|
|
204
233
|
`hiveSupervisor.setQueenSession()`); the registration lives in plugin memory and the
|
|
205
234
|
next panel access re-registers it after a restart. Before registration the supervisor
|
|
206
235
|
does not dispatch: the round is skipped and status reports
|
|
207
|
-
`waiting: "no-queen-session"` (a startup-order hint, not an error).
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
236
|
+
`waiting: "no-queen-session"` (a startup-order hint, not an error). While the
|
|
237
|
+
registered Session is live, every activation uses exactly its Agent. If that Agent
|
|
238
|
+
cannot be resolved any more (for example the Session was closed), parent resolution
|
|
239
|
+
falls back to `config.parentSession` and then to the first live Agent; when no Agent is
|
|
240
|
+
live the round defers with `hive/no-parent-agent` and the task is not failed. Once
|
|
241
|
+
registered, dispatch does not depend on any other user session being live.
|
|
211
242
|
|
|
212
243
|
Before every drain the supervisor requires a Hive-initialised repository whose
|
|
213
244
|
`<repo>/.git/hooks/pre-commit` runs merge-on-commit (it mentions merge-on-commit or moc).
|
|
214
245
|
A missing hook is a deferrable environment error: the repository backs off,
|
|
215
|
-
`environmentError` is reported, and no
|
|
246
|
+
`environmentError` is reported, and no task is failed and no auto-pause counts.
|
|
216
247
|
|
|
217
|
-
Per
|
|
248
|
+
Per task:
|
|
218
249
|
|
|
219
|
-
1. `hive guard <scope...> --task <id> --ttl <ttl> --json` announces the
|
|
220
|
-
before the
|
|
221
|
-
|
|
250
|
+
1. `hive guard <scope...> --task <id> --ttl <ttl> --json` announces the task's scope
|
|
251
|
+
before the agent starts, using the claim agent and a per-task `HIVE_INSTANCE` (the
|
|
252
|
+
task id) so concurrent agents of one runner are distinct announcers. hive-consensus
|
|
222
253
|
1.5.0 announcements never block: `hive guard` always exits 0 and publishes the
|
|
223
254
|
announced paths on the board. The runner parses the JSON document's advisory
|
|
224
255
|
`overlaps` array, logs the agent names and keeps the entries on the run record. A
|
|
225
256
|
non-zero exit (an unexpected CLI problem) and malformed or empty JSON are tolerated:
|
|
226
|
-
they are logged or ignored and never fail the
|
|
257
|
+
they are logged or ignored and never fail the task.
|
|
227
258
|
2. `hive recall` runs once for every scope entry and once for the repository root (query
|
|
228
|
-
`.`); the deduplicated lessons are injected at the top of the
|
|
259
|
+
`.`); the deduplicated lessons are injected at the top of the agent prompt (after
|
|
229
260
|
the title/role, before the goal) under `## Recalled experience (hive recall)`. A read
|
|
230
261
|
error is logged and recorded on the run record's `lessons.error`, and never blocks
|
|
231
|
-
the
|
|
262
|
+
the task. Writing lessons (`hive lesson add`) and reading them at the start are a
|
|
232
263
|
pair: a lesson nobody reads does not compound.
|
|
233
|
-
3. The
|
|
234
|
-
including `resource:` keys with `--task <
|
|
235
|
-
so the
|
|
264
|
+
3. The agent prompt hard-codes the consensus rules (announce every scope entry
|
|
265
|
+
including `resource:` keys with `--task <task id>` and the runner's claim identity,
|
|
266
|
+
so the agent's announcement belongs to this task and can never be mistaken for
|
|
236
267
|
another writer's; treat overlaps as information only, keep working and do not shrink
|
|
237
268
|
the scope; clear your own announcements before finishing; never delete another
|
|
238
269
|
agent's announcements) and the commit rules (plain `git commit` only, never
|
|
239
270
|
`--no-verify`/history rewrites, resolve hook conflicts in place keeping both sides).
|
|
240
271
|
4. Every Hive/git shell command carries `HIVE_AGENT=<claim identity>` in its
|
|
241
|
-
environment; every per-
|
|
242
|
-
`release`, `renew`) also carries `HIVE_INSTANCE=<
|
|
272
|
+
environment; every per-task Hive command (`claim`, `guard`, `done`, `fail`,
|
|
273
|
+
`release`, `renew`) also carries `HIVE_INSTANCE=<task id>`. Subagent
|
|
243
274
|
activations inject both variables into the
|
|
244
|
-
in-process
|
|
275
|
+
in-process agent environment for their lifetime (DSH's model-facing bash tool
|
|
245
276
|
inherits ambient env) and restore the previous values afterwards.
|
|
246
277
|
5. Done verification requires HEAD to have moved and the merge-on-commit hook to still be
|
|
247
278
|
present; announcements for the scope are best-effort released after done or fail.
|
|
@@ -252,38 +283,107 @@ Per card:
|
|
|
252
283
|
`exitCode`/`commit`, optional `overlaps` (`[{ key, agent, task, expiresAt }]`, only
|
|
253
284
|
entries with a non-empty string agent, capped at 100, omitted when empty), `lessons`
|
|
254
285
|
(`{ count, scopes, error? }`: the number of deduplicated lessons read, the queries
|
|
255
|
-
used and the read error when one occurred), and `output` (the
|
|
286
|
+
used and the read error when one occurred), and `output` (the agent's final
|
|
256
287
|
result message only: the text blocks of its last assistant message, with
|
|
257
288
|
reasoning/thinking, tool calls and the narration around them stripped; a provider
|
|
258
289
|
that returned no typed text block falls back to the last non-empty text, and a run
|
|
259
|
-
with no text at all falls back to the
|
|
260
|
-
last 200 lines and the last 32 KiB of UTF-8). A started
|
|
290
|
+
with no text at all falls back to the task verdict; capped to the smaller of the
|
|
291
|
+
last 200 lines and the last 32 KiB of UTF-8). A started subagent activation
|
|
261
292
|
also adds `sessionId` (the child Session id returned by `startActivation`) and
|
|
262
293
|
`agentName` (its model-facing child name); both keys are omitted when no activation
|
|
263
294
|
was accepted (for example an activation that threw, or a deferrable environment
|
|
264
|
-
error), so consumers can distinguish "no
|
|
265
|
-
running record is rewritten as soon as the activation is accepted, so a
|
|
266
|
-
still in progress already exposes its
|
|
295
|
+
error), so consumers can distinguish "no agent chat" from an empty value. The
|
|
296
|
+
running record is rewritten as soon as the activation is accepted, so a task that is
|
|
297
|
+
still in progress already exposes its agent Session and name. The file is
|
|
267
298
|
overwritten per attempt, so only the most recent run is kept; read failures and
|
|
268
|
-
write failures are ignored by the round and never change the
|
|
269
|
-
|
|
299
|
+
write failures are ignored by the round and never change the task verdict. While the
|
|
300
|
+
agent runs, the record also carries `heartbeat` (`ok`/`warn`) and
|
|
270
301
|
`lastOutputAt`, advanced when the repository HEAD moves.
|
|
271
|
-
7. Every
|
|
272
|
-
deadline the
|
|
302
|
+
7. Every task has a hard wall-clock limit `cardTimeoutMs` (default 15 min). At the
|
|
303
|
+
deadline the agent signal is aborted, the task is recorded failed with a timeout
|
|
273
304
|
reason, and the scope announcements are released. The claim TTL never aborts a
|
|
274
|
-
running
|
|
305
|
+
running task. A running agent whose HEAD has not moved for `heartbeatWarnMs`
|
|
275
306
|
(default 5 min) is marked `heartbeat: "warn"` in status and the run record;
|
|
276
307
|
heartbeat polling uses `heartbeatIntervalMs` (default 30 s).
|
|
277
308
|
|
|
278
|
-
The supervisor reads the Hive mode every round: in freeze mode only fix
|
|
279
|
-
dispatched, other ready
|
|
309
|
+
The supervisor reads the Hive mode every round: in freeze mode only fix tasks are
|
|
310
|
+
dispatched, other ready tasks stay on the board and are reported through `mode`,
|
|
280
311
|
`frozenSkipped` and `lastSkipReason`.
|
|
281
312
|
|
|
313
|
+
## 8.6 The queen coordination pipeline
|
|
314
|
+
|
|
315
|
+
Two sources feed one digest:
|
|
316
|
+
|
|
317
|
+
- **Event-driven** — `lib/round.js` emits `card-failed`, `card-timeout`,
|
|
318
|
+
`heartbeat-warn`, `worker-aborted`; `lib/supervisor.js` emits `round-failed`,
|
|
319
|
+
`auto-paused`, `environment-error`. The plugin pushes them into an in-memory
|
|
320
|
+
AnomalyFeed (`lib/anomalies.js`): entries coalesce per `(kind, repo, cardId)`
|
|
321
|
+
inside a ten-minute window and are bounded by `anomalyMax`.
|
|
322
|
+
- **Patrol** — `lib/patrol.js` re-reads `supervisor.status()` every `patrolMs`
|
|
323
|
+
(default 5 minutes) and pushes `auto-paused`, `environment-error`, `heartbeat-warn`
|
|
324
|
+
(agent heartbeat `warn`) and `card-timeout` (agent past `timeoutAt`), so a missed
|
|
325
|
+
event is recovered even though only one digest is delivered.
|
|
326
|
+
|
|
327
|
+
Delivery: task events schedule a debounced flush (`anomalyDebounceMs`, default 3 s); a
|
|
328
|
+
flush renders `renderDigest(pending)` and calls the notifier
|
|
329
|
+
(`lib/notify.js`), which resolves the live Agent for the registered queen Session and
|
|
330
|
+
injects one user-role message:
|
|
331
|
+
|
|
332
|
+
```js
|
|
333
|
+
{ id: <uuid>, role: 'user', content: [{ type: 'text', text: digest }],
|
|
334
|
+
source: { kind: 'hive-runner' } }
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
`agent.followup(message)` is the primary path (ordinary next turn, wakes the driver);
|
|
338
|
+
`agent.steer` and `agent.inject` are fallbacks for a future Agent surface. The session
|
|
339
|
+
log only requires a non-empty string source kind and consumers fall through unknown
|
|
340
|
+
producers, so a plugin-produced user message is valid without a DSH change. When no live
|
|
341
|
+
Agent exists the digest is *not* marked delivered: it stays pending, is listed by
|
|
342
|
+
`hive_anomalies`/`GET ?op=pending`, counted by `pendingAnomalies` in status, and is
|
|
343
|
+
flushed by the next `setQueenSession` registration or patrol tick. A healthy swarm
|
|
344
|
+
delivers nothing.
|
|
345
|
+
|
|
346
|
+
## 8.7 Gates and release readiness
|
|
347
|
+
|
|
348
|
+
Gate ordering is tag-based, never a new task state. `gate:group` tasks dispatch only when
|
|
349
|
+
every non-gate base task is `done`; `gate:overall` tasks only when every `gate:group` task
|
|
350
|
+
is `done`. A `failed` (or still `claimed`) task is not green and keeps the next gate
|
|
351
|
+
closed. `lib/gates.js` computes `gatePhase(tasks)` -> `{ phase, base, group, overall,
|
|
352
|
+
releaseReady, reason }` with `phase in base|group|overall|released|no-overall|unknown`
|
|
353
|
+
(`ungated` only exists for in-process configurations without a full-board reader; the
|
|
354
|
+
plugin always wires one, and status `gate` is `null` until the first computation).
|
|
355
|
+
`releaseReady` requires at least one `gate:overall` task and every gate green;
|
|
356
|
+
`no-overall` means the repository does not declare a release gate and cannot be released.
|
|
357
|
+
The supervisor stores the latest phase on the repository entry (status `gate`) and filters
|
|
358
|
+
both the resident round and `hive_run_round` through it. Draft tasks (`draft: true`, a
|
|
359
|
+
hive-tasks 1.8 flag, not a state) are excluded from the phase: a parked idea never blocks
|
|
360
|
+
a gate. When the full board cannot be read
|
|
361
|
+
(`unknown`) only non-gate tasks dispatch; gate tasks wait.
|
|
362
|
+
|
|
363
|
+
## 8.8 Queen interventions
|
|
364
|
+
|
|
365
|
+
`hive_intervene` performs one action and appends a durable `queen_intervention` event
|
|
366
|
+
`{ kind, task, action, reason, newCards?, removed?, sessionId? }` to
|
|
367
|
+
`.hive/events.jsonl`: `reopen` (guidance in the task's `reason`, which the next agent
|
|
368
|
+
prompt renders as
|
|
369
|
+
`## Queen guidance for this attempt`), `split`, `reassign`, `remove` (records
|
|
370
|
+
`{ title, state, scope }` of the deleted task in the event — a deletion must never be
|
|
371
|
+
silent), `rebuild` (remove + recreate with the old id referenced; at most twice per task),
|
|
372
|
+
`pause` (supervisor pause), `fail` (only confirms a task already `failed`; the queen never
|
|
373
|
+
transitions task states), `guide` (delivers a user-role message to a live agent Session
|
|
374
|
+
via the Agent inbox; optional path) and `escalate`. Every action requires a reason. After
|
|
375
|
+
more than three interventions on one task the runner appends a `queen_escalation` event and
|
|
376
|
+
raises the error-severity `queen-escalation` anomaly (red flag for the human).
|
|
377
|
+
|
|
378
|
+
The patrol also audits done tasks for a missing `arch_review` event: past
|
|
379
|
+
`archReviewGraceMs` (default 10 minutes) the task becomes an `arch-review-missing`
|
|
380
|
+
anomaly (warning + pending digest entry).
|
|
381
|
+
|
|
282
382
|
## 9. Security invariants
|
|
283
383
|
|
|
284
384
|
- Commands are built from fixed templates; ids, roles, agents, TTLs and shas are
|
|
285
385
|
regex-validated, free text is POSIX-quoted before entering `bash -c`.
|
|
286
|
-
-
|
|
386
|
+
- Task `acceptance` is repository-controlled shell under the same policy: treat the
|
|
287
387
|
repository as trusted input.
|
|
288
388
|
- The route is same-origin and authenticated by DSH; no port is opened.
|
|
289
389
|
- Auto-paused repositories require an explicit resume.
|
|
@@ -291,5 +391,7 @@ dispatched, other ready cards stay on the board and are reported through `mode`,
|
|
|
291
391
|
## 10. Compatibility
|
|
292
392
|
|
|
293
393
|
Host APIs used: `tools.register`, `shell.resolve/execute`, `subagents.startActivation`,
|
|
294
|
-
`connection.fetch.register`, `provide`, `effect
|
|
295
|
-
|
|
394
|
+
`connection.fetch.register`, `provide`, `effect`, `inject(['connection'])`,
|
|
395
|
+
`agents.get/list` (queen parent + notifier), `sandboxPolicy.resolve`. A DSH upgrade can
|
|
396
|
+
change these: re-run `npm test` and `npm run check` against the installed DSH before
|
|
397
|
+
releasing.
|
package/cordis.patch.yml
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
# dsh-hive-runner — DSH host half for Hive.
|
|
2
2
|
#
|
|
3
3
|
# The plugin registers a resident HiveSupervisor (Cordis service + effect-owned
|
|
4
|
-
# timer),
|
|
5
|
-
#
|
|
4
|
+
# timer), the queen tool surface (board/tasks/roles/lessons/arch-review/
|
|
5
|
+
# supervisor-control/anomalies) and the same-origin control route
|
|
6
|
+
# /api/hive-runner. Supervision events (failed card, timeout, stalled heartbeat,
|
|
7
|
+
# auto-pause) are coalesced into one digest and injected into the registered
|
|
8
|
+
# queen Session; without a live queen they stay in the pending list.
|
|
6
9
|
#
|
|
7
10
|
# Supervisor semantics (see README):
|
|
8
11
|
# tick every intervalMs; dispatch every ready card (one subagent per task) and
|
|
@@ -74,6 +77,20 @@
|
|
|
74
77
|
# poll cadence.
|
|
75
78
|
heartbeatWarnMs: 300000
|
|
76
79
|
heartbeatIntervalMs: 30000
|
|
80
|
+
# Queen coordination. The patrol checks the supervisor every patrolMs and
|
|
81
|
+
# delivers ONE digest to the registered queen Session only when there is
|
|
82
|
+
# an anomaly (failed card, timeout, stalled heartbeat, auto-pause).
|
|
83
|
+
# notifyQueen=false disables delivery and keeps the pending list only.
|
|
84
|
+
patrolMs: 300000
|
|
85
|
+
notifyQueen: true
|
|
86
|
+
# Card events coalesce for anomalyDebounceMs before one digest is sent;
|
|
87
|
+
# anomalyMax bounds the undelivered queue exposed by hive_anomalies.
|
|
88
|
+
anomalyDebounceMs: 3000
|
|
89
|
+
anomalyMax: 50
|
|
90
|
+
# A done card must carry an arch_review event; the patrol flags a done
|
|
91
|
+
# card with no review after this grace (the queen reviews finished cards
|
|
92
|
+
# at the next patrol).
|
|
93
|
+
archReviewGraceMs: 600000
|
|
77
94
|
# Subagent provider used to run card workers (spawn is the shipped
|
|
78
95
|
# in-process fresh-child backend).
|
|
79
96
|
provider: spawn
|
|
@@ -84,11 +101,14 @@
|
|
|
84
101
|
# Tool default repository when a tool call does not pass `repo`.
|
|
85
102
|
cwd: null
|
|
86
103
|
# Binaries (absolute path or PATH name); the HIVE_*_BIN env vars win.
|
|
87
|
-
# Default null means the PATH name (hive-tasks / hive); a missing
|
|
88
|
-
# name is retried once through npx (-y -p hive-tasks /
|
|
104
|
+
# Default null means the PATH name (hive-tasks / hive / hive); a missing
|
|
105
|
+
# PATH name is retried once through npx (-y -p hive-tasks /
|
|
106
|
+
# -p hive-consensus / -p @d86e/hive). rolesBin is the umbrella router for
|
|
107
|
+
# `hive roles`; it falls back to hiveBin when unset.
|
|
89
108
|
# An explicit absolute path is used as-is and never replaced.
|
|
90
109
|
tasksBin: null
|
|
91
110
|
hiveBin: null
|
|
111
|
+
rolesBin: null
|
|
92
112
|
gitBin: git
|
|
93
113
|
# Timeouts (ms).
|
|
94
114
|
cliTimeoutMs: 120000
|