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/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
|
|
|
@@ -53,8 +54,11 @@ wrong method -> `405` (`hive/method-not-allowed`).
|
|
|
53
54
|
"repoRoleConcurrency": {},
|
|
54
55
|
"defaultRoleConcurrency": 5,
|
|
55
56
|
"capacityRetryMs": 2000,
|
|
57
|
+
"queenSessionId": "queen-session-id",
|
|
58
|
+
"waiting": null,
|
|
56
59
|
"lastTickAt": "2026-12-04T00:00:00.000Z",
|
|
57
60
|
"lastDiscoverError": null,
|
|
61
|
+
"pendingAnomalies": 0,
|
|
58
62
|
"repos": [
|
|
59
63
|
{
|
|
60
64
|
"repo": "/abs/repo",
|
|
@@ -70,27 +74,54 @@ wrong method -> `405` (`hive/method-not-allowed`).
|
|
|
70
74
|
"consecutiveFailures": 0,
|
|
71
75
|
"lastCards": 0,
|
|
72
76
|
"lastResults": 0,
|
|
77
|
+
"waiting": null,
|
|
73
78
|
"backlog": { "queued": 3, "inFlight": 5, "completed": 12 },
|
|
74
79
|
"roles": {
|
|
75
80
|
"coder": { "limit": 5, "live": 5, "queued": 3 },
|
|
76
81
|
"tester": { "limit": 5, "live": 0, "queued": 0 }
|
|
77
82
|
},
|
|
83
|
+
"workers": [
|
|
84
|
+
{
|
|
85
|
+
"cardId": "readme-89ab",
|
|
86
|
+
"role": "coder",
|
|
87
|
+
"agent": "dsh",
|
|
88
|
+
"sessionId": "session-id",
|
|
89
|
+
"agentName": "agent-1",
|
|
90
|
+
"parentSource": "queen",
|
|
91
|
+
"startedAt": "2026-12-04T00:00:03.000Z",
|
|
92
|
+
"lastOutputAt": "2026-12-04T00:02:00.000Z",
|
|
93
|
+
"heartbeat": "ok",
|
|
94
|
+
"claimDeadline": "2026-12-04T00:05:03.000Z",
|
|
95
|
+
"timeoutAt": "2026-12-04T00:15:03.000Z"
|
|
96
|
+
}
|
|
97
|
+
],
|
|
78
98
|
"limitsError": null,
|
|
79
99
|
"environmentError": null,
|
|
80
100
|
"mode": null,
|
|
81
101
|
"frozenSkipped": 0,
|
|
82
|
-
"lastSkipReason": null
|
|
102
|
+
"lastSkipReason": null,
|
|
103
|
+
"gate": null
|
|
83
104
|
}
|
|
84
105
|
]
|
|
85
106
|
}
|
|
86
107
|
```
|
|
87
108
|
|
|
88
|
-
- `roles[role].limit` — effective live-
|
|
109
|
+
- `roles[role].limit` — effective live-agent cap (persisted file > repo config >
|
|
89
110
|
global role config > `defaultRoleConcurrency`).
|
|
90
|
-
- `roles[role].live` —
|
|
111
|
+
- `roles[role].live` — agents running right now; a finished agent frees its slot
|
|
91
112
|
immediately.
|
|
92
|
-
- `roles[role].queued` — fetched
|
|
113
|
+
- `roles[role].queued` — fetched tasks waiting for a slot; they do not count as live.
|
|
93
114
|
- `backlog` — aggregate `{ queued, inFlight, completed }` for the current or last drain.
|
|
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.
|
|
118
|
+
- `waiting` — per repository (and top level) `"no-queen-session"` before the queen
|
|
119
|
+
Session is registered; then `null`. It is a startup-order hint, never an error.
|
|
120
|
+
- `workers` — the agents currently running in this repository, each with
|
|
121
|
+
`cardId`, `role`, `agent`, `sessionId`, `agentName`, `parentSource` (`queen`),
|
|
122
|
+
`startedAt`, `lastOutputAt`,
|
|
123
|
+
`heartbeat` (`ok` | `warn`), `claimDeadline` and `timeoutAt`; the panel uses the
|
|
124
|
+
Session id to open the agent chat.
|
|
94
125
|
- `state` — `idle` | `running` | `backoff` | `paused`.
|
|
95
126
|
|
|
96
127
|
### 3.2 `POST ?op=pause` / `POST ?op=resume`
|
|
@@ -113,6 +144,17 @@ Body:
|
|
|
113
144
|
- Response: `{ ok: true, op: "limits", repo: <repository status> }`.
|
|
114
145
|
- Malformed values -> `400` `hive/invalid-role-limits`.
|
|
115
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
|
+
|
|
116
158
|
## 4. Per-repository limits
|
|
117
159
|
|
|
118
160
|
Precedence for one role in one repository:
|
|
@@ -129,27 +171,27 @@ The persisted file contains only runtime overrides and is safe to commit. Shape:
|
|
|
129
171
|
|
|
130
172
|
## 5. Concurrency and capacity
|
|
131
173
|
|
|
132
|
-
- At most 5 **live**
|
|
133
|
-
- Queued
|
|
134
|
-
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.
|
|
135
177
|
- `maxConcurrentRepos` (default 2) limits how many repositories drain at the same time;
|
|
136
178
|
a single repository is always serial.
|
|
137
179
|
- DSH's `subagent.maxActiveSubagents` is the hard ceiling below the plugin:
|
|
138
180
|
`startActivation` can reject with `ACTIVATION_LIMIT_REACHED`. The queue requeues the
|
|
139
|
-
claimed
|
|
140
|
-
- 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.
|
|
141
183
|
|
|
142
184
|
## 6. Supervisor state machine
|
|
143
185
|
|
|
144
186
|
```text
|
|
145
|
-
idle --tick, ready
|
|
146
|
-
idle --tick, no
|
|
187
|
+
idle --tick, ready tasks--> running --drain done--> idle (next tick)
|
|
188
|
+
idle --tick, no tasks--> backoff (idleBackoffMs)
|
|
147
189
|
running --drain exception--> backoff (intervalMs * 2^failures, capped at idleBackoffMs)
|
|
148
190
|
running --3 consecutive exceptions--> paused (auto; requires explicit resume)
|
|
149
191
|
paused --resume--> idle
|
|
150
192
|
```
|
|
151
193
|
|
|
152
|
-
|
|
194
|
+
Task-level failures (no commit, acceptance failure, non-completed subagent) are recorded
|
|
153
195
|
in Hive as `fail` and do not count as round exceptions. Environmental errors (no live
|
|
154
196
|
parent agent, no subagent provider) are deferrable: they set `lastError` and back off
|
|
155
197
|
for `idleBackoffMs` without consuming the failure budget.
|
|
@@ -161,65 +203,187 @@ repository unless it is that default.
|
|
|
161
203
|
|
|
162
204
|
| Tool | Parameters | Output |
|
|
163
205
|
| --- | --- | --- |
|
|
164
|
-
| `hive_run_round` | `repo`, `ttl`, `agent` | Per-
|
|
165
|
-
| `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 |
|
|
166
208
|
| `hive_board` | `repo` | Presence board |
|
|
167
|
-
| `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`).
|
|
168
224
|
|
|
169
225
|
Tool-triggered rounds use the calling Session's sandbox policy; resident rounds use the
|
|
170
226
|
deployment policy with the repository pinned as the workspace root.
|
|
171
227
|
|
|
172
|
-
## 8. Round preconditions and
|
|
228
|
+
## 8. Round preconditions and agent protocol
|
|
229
|
+
|
|
230
|
+
Every task agent is parented to the **queen conversation**: the Session where the
|
|
231
|
+
panel was initialised and the queen took over. The panel registers that Session id
|
|
232
|
+
with the supervisor (`POST /api/hive-runner?op=queen { sessionId }` or
|
|
233
|
+
`hiveSupervisor.setQueenSession()`); the registration lives in plugin memory and the
|
|
234
|
+
next panel access re-registers it after a restart. Before registration the supervisor
|
|
235
|
+
does not dispatch: the round is skipped and status reports
|
|
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.
|
|
173
242
|
|
|
174
243
|
Before every drain the supervisor requires a Hive-initialised repository whose
|
|
175
244
|
`<repo>/.git/hooks/pre-commit` runs merge-on-commit (it mentions merge-on-commit or moc).
|
|
176
245
|
A missing hook is a deferrable environment error: the repository backs off,
|
|
177
|
-
`environmentError` is reported, and no
|
|
178
|
-
|
|
179
|
-
Per
|
|
180
|
-
|
|
181
|
-
1. `hive guard <scope...> --
|
|
182
|
-
the
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
the
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
246
|
+
`environmentError` is reported, and no task is failed and no auto-pause counts.
|
|
247
|
+
|
|
248
|
+
Per task:
|
|
249
|
+
|
|
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
|
|
253
|
+
1.5.0 announcements never block: `hive guard` always exits 0 and publishes the
|
|
254
|
+
announced paths on the board. The runner parses the JSON document's advisory
|
|
255
|
+
`overlaps` array, logs the agent names and keeps the entries on the run record. A
|
|
256
|
+
non-zero exit (an unexpected CLI problem) and malformed or empty JSON are tolerated:
|
|
257
|
+
they are logged or ignored and never fail the task.
|
|
258
|
+
2. `hive recall` runs once for every scope entry and once for the repository root (query
|
|
259
|
+
`.`); the deduplicated lessons are injected at the top of the agent prompt (after
|
|
260
|
+
the title/role, before the goal) under `## Recalled experience (hive recall)`. A read
|
|
261
|
+
error is logged and recorded on the run record's `lessons.error`, and never blocks
|
|
262
|
+
the task. Writing lessons (`hive lesson add`) and reading them at the start are a
|
|
263
|
+
pair: a lesson nobody reads does not compound.
|
|
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
|
|
267
|
+
another writer's; treat overlaps as information only, keep working and do not shrink
|
|
268
|
+
the scope; clear your own announcements before finishing; never delete another
|
|
269
|
+
agent's announcements) and the commit rules (plain `git commit` only, never
|
|
270
|
+
`--no-verify`/history rewrites, resolve hook conflicts in place keeping both sides).
|
|
271
|
+
4. Every Hive/git shell command carries `HIVE_AGENT=<claim identity>` in its
|
|
272
|
+
environment; every per-task Hive command (`claim`, `guard`, `done`, `fail`,
|
|
273
|
+
`release`, `renew`) also carries `HIVE_INSTANCE=<task id>`. Subagent
|
|
274
|
+
activations inject both variables into the
|
|
275
|
+
in-process agent environment for their lifetime (DSH's model-facing bash tool
|
|
276
|
+
inherits ambient env) and restore the previous values afterwards.
|
|
200
277
|
5. Done verification requires HEAD to have moved and the merge-on-commit hook to still be
|
|
201
|
-
present;
|
|
278
|
+
present; announcements for the scope are best-effort released after done or fail.
|
|
202
279
|
6. Every attempt writes `<repo>/.hive/runs/<cardId>.json`: `running` when the attempt
|
|
203
|
-
starts,
|
|
204
|
-
endings. The record carries
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
280
|
+
starts, a second `running` write after the lesson read (now carrying `lessons`), then
|
|
281
|
+
the terminal state for done, failed and exceptional endings. The record carries
|
|
282
|
+
`cardId`, `agent`, `startedAt`, `endedAt`, `status`, optional
|
|
283
|
+
`exitCode`/`commit`, optional `overlaps` (`[{ key, agent, task, expiresAt }]`, only
|
|
284
|
+
entries with a non-empty string agent, capped at 100, omitted when empty), `lessons`
|
|
285
|
+
(`{ count, scopes, error? }`: the number of deduplicated lessons read, the queries
|
|
286
|
+
used and the read error when one occurred), and `output` (the agent's final
|
|
287
|
+
result message only: the text blocks of its last assistant message, with
|
|
288
|
+
reasoning/thinking, tool calls and the narration around them stripped; a provider
|
|
289
|
+
that returned no typed text block falls back to the last non-empty text, and a run
|
|
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
|
|
292
|
+
also adds `sessionId` (the child Session id returned by `startActivation`) and
|
|
293
|
+
`agentName` (its model-facing child name); both keys are omitted when no activation
|
|
294
|
+
was accepted (for example an activation that threw, or a deferrable environment
|
|
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
|
|
298
|
+
overwritten per attempt, so only the most recent run is kept; read failures and
|
|
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
|
|
301
|
+
`lastOutputAt`, advanced when the repository HEAD moves.
|
|
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
|
|
304
|
+
reason, and the scope announcements are released. The claim TTL never aborts a
|
|
305
|
+
running task. A running agent whose HEAD has not moved for `heartbeatWarnMs`
|
|
306
|
+
(default 5 min) is marked `heartbeat: "warn"` in status and the run record;
|
|
307
|
+
heartbeat polling uses `heartbeatIntervalMs` (default 30 s).
|
|
308
|
+
|
|
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`,
|
|
216
311
|
`frozenSkipped` and `lastSkipReason`.
|
|
217
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
|
+
|
|
218
382
|
## 9. Security invariants
|
|
219
383
|
|
|
220
384
|
- Commands are built from fixed templates; ids, roles, agents, TTLs and shas are
|
|
221
385
|
regex-validated, free text is POSIX-quoted before entering `bash -c`.
|
|
222
|
-
-
|
|
386
|
+
- Task `acceptance` is repository-controlled shell under the same policy: treat the
|
|
223
387
|
repository as trusted input.
|
|
224
388
|
- The route is same-origin and authenticated by DSH; no port is opened.
|
|
225
389
|
- Auto-paused repositories require an explicit resume.
|
|
@@ -227,5 +391,7 @@ dispatched, other ready cards stay on the board and are reported through `mode`,
|
|
|
227
391
|
## 10. Compatibility
|
|
228
392
|
|
|
229
393
|
Host APIs used: `tools.register`, `shell.resolve/execute`, `subagents.startActivation`,
|
|
230
|
-
`connection.fetch.register`, `provide`, `effect
|
|
231
|
-
|
|
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
|
|
@@ -43,9 +46,12 @@
|
|
|
43
46
|
maxConsecutiveFailures: 3
|
|
44
47
|
# Repositories paused at startup (absolute paths). Manual resume works.
|
|
45
48
|
paused: []
|
|
46
|
-
# Claim identity / claim TTL.
|
|
49
|
+
# Claim identity / claim TTL. Every card also runs its consensus calls
|
|
50
|
+
# with HIVE_INSTANCE=<card id>, so concurrent workers of this runner are
|
|
51
|
+
# distinct announcers on the board. The claim TTL never aborts a running
|
|
52
|
+
# card (cardTimeoutMs does that); raise ttl for very large queues.
|
|
47
53
|
agent: dsh
|
|
48
|
-
ttl:
|
|
54
|
+
ttl: 20m
|
|
49
55
|
# Per-role LIVE-worker limits, per repository. Default five workers per
|
|
50
56
|
# role; 0 pauses a role (its ready cards stay on the board). These are
|
|
51
57
|
# the config defaults/fallbacks — each repository can persist its own
|
|
@@ -62,6 +68,29 @@
|
|
|
62
68
|
# Delay (ms) before retrying queued cards when DSH subagent capacity is
|
|
63
69
|
# exhausted (ACTIVATION_LIMIT_REACHED).
|
|
64
70
|
capacityRetryMs: 2000
|
|
71
|
+
# Hard per-card wall-clock limit (ms). At the deadline the worker is
|
|
72
|
+
# aborted, the card is recorded failed and its announcements are released.
|
|
73
|
+
cardTimeoutMs: 900000
|
|
74
|
+
# Heartbeat: while a worker runs, watch the repository HEAD as the
|
|
75
|
+
# observable output signal. No movement for heartbeatWarnMs marks the
|
|
76
|
+
# worker heartbeat=warn in status/run record; heartbeatIntervalMs is the
|
|
77
|
+
# poll cadence.
|
|
78
|
+
heartbeatWarnMs: 300000
|
|
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
|
|
65
94
|
# Subagent provider used to run card workers (spawn is the shipped
|
|
66
95
|
# in-process fresh-child backend).
|
|
67
96
|
provider: spawn
|
|
@@ -72,11 +101,14 @@
|
|
|
72
101
|
# Tool default repository when a tool call does not pass `repo`.
|
|
73
102
|
cwd: null
|
|
74
103
|
# Binaries (absolute path or PATH name); the HIVE_*_BIN env vars win.
|
|
75
|
-
# Default null means the PATH name (hive-tasks / hive); a missing
|
|
76
|
-
# 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.
|
|
77
108
|
# An explicit absolute path is used as-is and never replaced.
|
|
78
109
|
tasksBin: null
|
|
79
110
|
hiveBin: null
|
|
111
|
+
rolesBin: null
|
|
80
112
|
gitBin: git
|
|
81
113
|
# Timeouts (ms).
|
|
82
114
|
cliTimeoutMs: 120000
|