dsh-hive-runner 1.0.11 → 1.0.13
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 +32 -0
- package/README.md +16 -3
- package/README.zh-CN.md +2 -0
- package/SPEC.md +23 -4
- package/cordis.patch.yml +7 -0
- package/docs/DESIGN.md +34 -3
- package/index.js +34 -0
- package/lib/checkpoint.js +288 -0
- package/lib/config.js +11 -0
- package/lib/events.js +1 -1
- package/lib/queen-boundary.js +5 -2
- package/lib/supervisor.js +15 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,34 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
7
7
|
Version 0.6.0 is the first public snapshot; 0.1.0-0.5.0 were local development
|
|
8
8
|
iterations of the plugin before this repository was published.
|
|
9
9
|
|
|
10
|
+
## [1.0.13] - 2026-12-05
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Progress checkpoints delivered to the queen: the patrol now reports progress, not
|
|
15
|
+
only anomalies. Triggers: a drained queue (no pending/claimed, at least
|
|
16
|
+
`checkpointDrainMs` since the last checkpoint), all tasks done / gate phase advance /
|
|
17
|
+
`releaseReady` flip, or no ready task for `checkpointIdleMs` while unfinished goals
|
|
18
|
+
remain. The digest carries done/failed/pending/claimed/total counts, recent completed
|
|
19
|
+
titles, gate phase/releaseReady, a bounded last-10-minute event summary and the
|
|
20
|
+
instruction to evaluate the goal (split the next batch, or summarize and ask the human
|
|
21
|
+
to confirm release). A state signature deduplicates it; no live queen Session keeps
|
|
22
|
+
checkpoints pending (`status.pendingCheckpoints`) until the next patrol/registration.
|
|
23
|
+
- New config keys `checkpointDrainMs` / `checkpointIdleMs` (defaults 600000).
|
|
24
|
+
|
|
25
|
+
## [1.0.12] - 2026-12-05
|
|
26
|
+
|
|
27
|
+
### Fixed
|
|
28
|
+
|
|
29
|
+
- The queen can use `run_code` again: PTC mode exposes only `run_code` and the
|
|
30
|
+
mutation list wrongly vetoed it, leaving the queen with no callable tool. `run_code`
|
|
31
|
+
is removed from `QUEEN_MUTATING_TOOLS`; its nested `tools.write` / `tools.edit` /
|
|
32
|
+
`tools.bash` dispatches still pass the same Agent into the shared PTC pipeline, so
|
|
33
|
+
`ctx.tools.guard` vetoes the nested mutation before the body runs. Direct
|
|
34
|
+
write/edit/bash/apply_patch/notebook/office/terminal calls remain vetoed.
|
|
35
|
+
- Boundary denial text now says `女王可以用 hive_* 与只读工具,实现请交给 worker`
|
|
36
|
+
instead of suggesting a workflow that leaves the PTC queen tool-less.
|
|
37
|
+
|
|
10
38
|
## [1.0.11] - 2026-12-05
|
|
11
39
|
|
|
12
40
|
### Fixed
|
|
@@ -20,6 +48,10 @@ iterations of the plugin before this repository was published.
|
|
|
20
48
|
`parentSession === queenSessionId` as the restart/provider fallback, so a worker's
|
|
21
49
|
write/edit/bash and subagent tools keep working while the queen is still denied.
|
|
22
50
|
|
|
51
|
+
### Published
|
|
52
|
+
|
|
53
|
+
- npm: `dsh-hive-runner@1.0.11` on 2026-12-05.
|
|
54
|
+
|
|
23
55
|
## [1.0.10] - 2026-12-05
|
|
24
56
|
|
|
25
57
|
### Fixed
|
package/README.md
CHANGED
|
@@ -104,10 +104,12 @@ The tool surface keeps the boundary: none of the queen's tools claims or finishe
|
|
|
104
104
|
commits code. The boundary is enforced, not just documented: the runner registers a
|
|
105
105
|
DSH `ctx.tools.guard`, so a queen Session calling a delegation tool (`subagent`,
|
|
106
106
|
`subagent_fork`, `subagent_claude_code`) or a mutation tool (`write`, `edit`, `bash`,
|
|
107
|
-
`apply_patch`, notebook/office/terminal
|
|
108
|
-
tool result telling her
|
|
107
|
+
`apply_patch`, notebook/office/terminal tools, ...) directly gets a failed
|
|
108
|
+
tool result telling her `女王可以用 hive_* 与只读工具,实现请交给 worker`;
|
|
109
109
|
read-only tools (`read`, `grep`, `glob`, `web_*`, `hive_*`, `list_agents`, ...) stay
|
|
110
|
-
available.
|
|
110
|
+
available. `run_code` is allowed (it is the PTC transport), while a nested
|
|
111
|
+
write/edit/bash dispatch inside the program still passes the same guard and is
|
|
112
|
+
vetoed. The attempt is recorded as a `queen_boundary_violation` event (with an
|
|
111
113
|
anomaly digest for self-correction). The
|
|
112
114
|
guard recognizes the queen by registration or by an ordinary chat Session whose cwd
|
|
113
115
|
is a Hive-initialized repository (`.hive/roles/queen.md`), so it works without the
|
|
@@ -150,6 +152,15 @@ Two guarantees keep this quiet:
|
|
|
150
152
|
gone the digest stays in the pending list: `hive_anomalies` lists and acknowledges it,
|
|
151
153
|
`hive_supervisor_status` reports `pendingAnomalies`, and the next registered queen
|
|
152
154
|
Session flushes the queue. `notifyQueen: false` keeps the pending list only.
|
|
155
|
+
Progress is reported separately from anomalies: when the queue drains (and at least
|
|
156
|
+
`checkpointDrainMs`, default 10 minutes, passed since the last checkpoint), when every
|
|
157
|
+
task is done or a gate phase advances, or when no task is ready for
|
|
158
|
+
`checkpointIdleMs` (default 10 minutes) while work remains, the queen gets a checkpoint
|
|
159
|
+
digest with task counts, recently completed titles, gate state and the last 10 minutes
|
|
160
|
+
of events. It asks her to evaluate the goal and either split the next batch or summarize
|
|
161
|
+
and ask the human to confirm release. The same state is sent once; a state change
|
|
162
|
+
re-arms it. With no live queen Session the checkpoint stays pending
|
|
163
|
+
(`pendingCheckpoints` in status) and is flushed on the next patrol/registration.
|
|
153
164
|
|
|
154
165
|
### The gates the queen orchestrates
|
|
155
166
|
|
|
@@ -288,6 +299,8 @@ written to `docs/CONVENTIONS.md` / `AGENTS.md` / an ADR, not just remembered in
|
|
|
288
299
|
| `anomalyDebounceMs` | `3000` | coalescing window before one digest is sent |
|
|
289
300
|
| `anomalyMax` | `50` | bound on the undelivered anomaly queue |
|
|
290
301
|
| `archReviewGraceMs` | `600000` (10 min) | grace before a done task without an `arch_review` event is flagged |
|
|
302
|
+
| `checkpointDrainMs` | `600000` (10 min) | minimum gap between drained-queue progress checkpoints |
|
|
303
|
+
| `checkpointIdleMs` | `600000` (10 min) | no-ready time before the idle progress checkpoint fires |
|
|
291
304
|
| `rolesBin` | `null` | executable for `hive roles` (umbrella `@d86e/hive`); falls back to `hiveBin` |
|
|
292
305
|
|
|
293
306
|
## Requirements
|
package/README.zh-CN.md
CHANGED
|
@@ -207,6 +207,8 @@ outstanding/failed 与 `releaseReady`、`reason`)。`releaseReady` 为 true
|
|
|
207
207
|
| `anomalyDebounceMs` | `3000` | 合并成一条摘要前的防抖时间 |
|
|
208
208
|
| `anomalyMax` | `50` | 待投递异常队列上限 |
|
|
209
209
|
| `archReviewGraceMs` | `600000`(10 分钟) | done 任务缺少 `arch_review` 事件多久后被标记 |
|
|
210
|
+
| `checkpointDrainMs` | `600000`(10 分钟) | 队列排空后两次进度 checkpoint 的最小间隔 |
|
|
211
|
+
| `checkpointIdleMs` | `600000`(10 分钟) | 无 ready 任务多久后触发 idle 进度 checkpoint |
|
|
210
212
|
| `rolesBin` | `null` | `hive roles` 的可执行文件(umbrella `@d86e/hive`),默认退回 `hiveBin` |
|
|
211
213
|
|
|
212
214
|
## 环境要求
|
package/SPEC.md
CHANGED
|
@@ -120,6 +120,8 @@ wrong method -> `405` (`hive/method-not-allowed`).
|
|
|
120
120
|
immediately.
|
|
121
121
|
- `roles[role].queued` — fetched tasks waiting for a slot; they do not count as live.
|
|
122
122
|
- `backlog` — aggregate `{ queued, inFlight, completed }` for the current or last drain.
|
|
123
|
+
- `pendingCheckpoints` — progress checkpoints queued while no live queen Session was
|
|
124
|
+
available; the next patrol/queen registration flushes them.
|
|
123
125
|
- `repos` / `repoCount` — the status-visible repository registry. `hiveSupervisor.addRepo(repo)`
|
|
124
126
|
adds one at runtime (absolute path, must be an initialized Hive repository; idempotent;
|
|
125
127
|
rejects a relative or uninitialized path).
|
|
@@ -372,7 +374,22 @@ Agent exists the digest is *not* marked delivered: it stays pending, is listed b
|
|
|
372
374
|
flushed by the next `setQueenSession` registration or patrol tick. A healthy swarm
|
|
373
375
|
delivers nothing.
|
|
374
376
|
|
|
375
|
-
### 8.6.1
|
|
377
|
+
### 8.6.1 Progress checkpoints
|
|
378
|
+
|
|
379
|
+
The patrol also sends a progress digest to the queen (not just anomalies): (1) the
|
|
380
|
+
queue is drained — no pending/claimed tasks, including failed ones — and at least
|
|
381
|
+
`checkpointDrainMs` (default 10 min) passed since the last checkpoint; (2) all tasks
|
|
382
|
+
are done or the gate phase advanced / `releaseReady` became true; (3) no ready task
|
|
383
|
+
exists while unfinished tasks remain, continuously for `checkpointIdleMs` (default
|
|
384
|
+
10 min). The digest carries done/failed/pending/claimed/total counts, recent completed
|
|
385
|
+
task titles, gate phase/releaseReady, a bounded last-10-minute event summary, the
|
|
386
|
+
trigger, and the instruction: `评估目标是否达成:未达成请继续拆解下一批任务并说明依据;
|
|
387
|
+
达成请汇总结果并请人类确认发布。`. The same state is sent once (state signature =
|
|
388
|
+
counts + gate + recent completed ids); a change re-arms it. With no live queen
|
|
389
|
+
Session it stays pending (`status.pendingCheckpoints`) and is flushed by the next
|
|
390
|
+
patrol or queen registration.
|
|
391
|
+
|
|
392
|
+
### 8.6.2 Queen tool boundary
|
|
376
393
|
|
|
377
394
|
DSH's `ctx.tools.guard` lets a plugin veto a tool call after pre-execute policy and
|
|
378
395
|
before the body. The runner registers one global guard. A Session is recognized as
|
|
@@ -381,9 +398,11 @@ whose cwd contains `.hive/roles/queen.md`; an explicit latest `/queen off` comma
|
|
|
381
398
|
suppresses the veto for that Session (`/queen on` re-enables it). Two tool classes are
|
|
382
399
|
vetoed: delegation (`subagent`, `subagent_fork`, `subagent_claude_code`) and mutation
|
|
383
400
|
(an explicit `QUEEN_MUTATING_TOOLS` name list: write/edit/apply_patch/str_replace_editor,
|
|
384
|
-
bash/pwsh
|
|
385
|
-
Read-only tools (read/grep/glob/web_*/hive_*/list_agents/...) stay allowed.
|
|
386
|
-
|
|
401
|
+
bash/pwsh, notebook/office/terminal/ralph/create_worktree and common aliases).
|
|
402
|
+
Read-only tools (read/grep/glob/web_*/hive_*/list_agents/...) stay allowed. `run_code`
|
|
403
|
+
is allowed because PTC is the queen's transport; its nested write/edit/bash calls carry
|
|
404
|
+
the same Agent and go through the shared pipeline's guard, so they are still vetoed.
|
|
405
|
+
The call fails with `女王可以用 hive_* 与只读工具,实现请交给 worker(检测到 <tool>
|
|
387
406
|
调用,已拦截)`; the body never runs. The attempt is appended to `<repo>/.hive/events.jsonl` with
|
|
388
407
|
`kind: "queen_boundary_violation"` (`ts`, `actor`, `tool`, `message`, `sessionId`),
|
|
389
408
|
pushed as a `queen-boundary-violation` anomaly so the digest reaches the queen, and
|
package/cordis.patch.yml
CHANGED
|
@@ -91,6 +91,13 @@
|
|
|
91
91
|
# card with no review after this grace (the queen reviews finished cards
|
|
92
92
|
# at the next patrol).
|
|
93
93
|
archReviewGraceMs: 600000
|
|
94
|
+
# Progress checkpoints (not just anomalies): when the queue drains, all
|
|
95
|
+
# cards are done, a gate advances, or no ready card exists while goals
|
|
96
|
+
# remain, the queen gets a digest asking whether the goal is achieved.
|
|
97
|
+
# checkpointDrainMs is the minimum gap for a drained-queue checkpoint;
|
|
98
|
+
# checkpointIdleMs is the no-ready duration before the idle checkpoint.
|
|
99
|
+
checkpointDrainMs: 600000
|
|
100
|
+
checkpointIdleMs: 600000
|
|
94
101
|
# Subagent provider used to run card workers (spawn is the shipped
|
|
95
102
|
# in-process fresh-child backend).
|
|
96
103
|
provider: spawn
|
package/docs/DESIGN.md
CHANGED
|
@@ -50,6 +50,7 @@ Response:
|
|
|
50
50
|
"lastTickAt": "2026-12-04T00:00:00.000Z",
|
|
51
51
|
"lastDiscoverError": null,
|
|
52
52
|
"pendingAnomalies": 0,
|
|
53
|
+
"pendingCheckpoints": 0,
|
|
53
54
|
"repoCount": 1,
|
|
54
55
|
"claimedButOrphaned": 0,
|
|
55
56
|
"workerSessionIds": ["worker-session-id"],
|
|
@@ -110,6 +111,8 @@ Response:
|
|
|
110
111
|
against `live`).
|
|
111
112
|
- `backlog` — aggregate `{ queued, inFlight, completed }` for the current or
|
|
112
113
|
last drain.
|
|
114
|
+
- `pendingCheckpoints` — progress checkpoints queued while no live queen Session was
|
|
115
|
+
available; the next patrol/queen registration flushes them.
|
|
113
116
|
- `repos` / `repoCount` — the repositories the supervisor currently tracks; this is the
|
|
114
117
|
status-visible registry the panel renders. Runtime additions go through
|
|
115
118
|
`hiveSupervisor.addRepo(repo)` (absolute path, initialized Hive repository, idempotent).
|
|
@@ -262,6 +265,7 @@ auto-pause failure budget; status exposes `claimedButOrphaned`,
|
|
|
262
265
|
| `lib/anomalies.js` | Supervision anomaly feed: coalescing per (kind, repo, task id), bounded queue, pending/delivered state, compact digest |
|
|
263
266
|
| `lib/notify.js` | Queen message injection: resolve the live Agent for the registered Session and deliver one identified user-role message (followup/steer/inject) |
|
|
264
267
|
| `lib/patrol.js` | 5-minute queen patrol: run the optional audit hook, scan supervisor status for auto-pause/environment/heartbeat/timeout anomalies, flush one digest, stay silent when healthy |
|
|
268
|
+
| `lib/checkpoint.js` | Progress checkpoints: drained/all-done/gate-advance/idle triggers, task/event digest, state-signature dedup and pending queue |
|
|
265
269
|
| `lib/gates.js` | Gate pipeline: tag classification (`gate:group`, `gate:overall`), phase computation (base -> group -> overall -> released/no-overall), release readiness and dispatch filtering |
|
|
266
270
|
| `lib/audit.js` | Patrol audit: done tasks without an `arch_review` event become `arch-review-missing` anomalies; more than three `queen_intervention` events on one stuck task write `queen_escalation` and raise the red-flag anomaly |
|
|
267
271
|
| `lib/events.js` | `.hive/events.jsonl` append/read plus the `arch_review`, `queen_intervention`, `queen_escalation` and `queen_boundary_violation` event contracts |
|
|
@@ -314,6 +318,26 @@ lessons, and the supervisor feeds it anomalies. The design constraints:
|
|
|
314
318
|
`hive_anomalies` / `GET ?op=pending`; the next queen registration or patrol flushes
|
|
315
319
|
it. This is the documented degradation path when no Session is live.
|
|
316
320
|
|
|
321
|
+
### Progress checkpoints
|
|
322
|
+
|
|
323
|
+
A patrol also reports progress, not only problems. `lib/checkpoint.js` runs from the
|
|
324
|
+
patrol inspect hook for every registered repository and sends a checkpoint when:
|
|
325
|
+
|
|
326
|
+
1. the queue is drained (no pending/claimed tasks, including failed ones) and at
|
|
327
|
+
least `checkpointDrainMs` (default 10 min) passed since the last checkpoint;
|
|
328
|
+
2. all tasks are done, or the gate phase advanced / `releaseReady` flipped true;
|
|
329
|
+
3. no ready task exists while unfinished tasks remain, continuously for
|
|
330
|
+
`checkpointIdleMs` (default 10 min).
|
|
331
|
+
|
|
332
|
+
The digest contains `done/failed/pending/claimed/total`, the last completed task
|
|
333
|
+
titles, gate phase/releaseReady/reason, a bounded summary of events from the last
|
|
334
|
+
10 minutes, the trigger, and the instruction `评估目标是否达成:未达成请继续拆解下一批任务并说明依据;达成请汇总结果并请人类确认发布。`.
|
|
335
|
+
It is delivered through the queen notifier. The state signature (counts + gate +
|
|
336
|
+
releaseReady + recent completed ids) deduplicates it: the same state is sent once and
|
|
337
|
+
only a state change re-arms it. Without a live queen Session the checkpoint is kept in
|
|
338
|
+
the controller's pending list (status `pendingCheckpoints`) and flushed by the next
|
|
339
|
+
patrol or queen registration; it never falls through to an anomaly digest.
|
|
340
|
+
|
|
317
341
|
### Tool boundary: hard veto through `ctx.tools.guard`
|
|
318
342
|
|
|
319
343
|
DSH does expose a plugin-side tool veto. `ToolsService.guard(guard)` registers a
|
|
@@ -330,9 +354,15 @@ needed and is not implemented.
|
|
|
330
354
|
- predicate: the tool is in one of two classes — delegation (`subagent`,
|
|
331
355
|
`subagent_fork`, `subagent_claude_code`) or mutation (the explicit
|
|
332
356
|
`QUEEN_MUTATING_TOOLS` list: `write`/`edit`/`apply_patch`/`str_replace_editor`,
|
|
333
|
-
`bash`/`pwsh
|
|
357
|
+
`bash`/`pwsh`, notebook editors, `create_worktree`, `office_*`, `ralph*`,
|
|
334
358
|
`terminal_*`, and common aliases). Read-only tools (`read`, `grep`, `glob`,
|
|
335
359
|
`web_*`, `hive_*`, `list_agents`, ...) are not in the list and stay allowed.
|
|
360
|
+
`run_code` is **not** in the list: under the PTC preset it is the queen's only
|
|
361
|
+
transport. Its nested `tools.write`/`tools.edit`/`tools.bash` calls carry the same
|
|
362
|
+
Agent in `ToolExecutionInput` and go through `executor.prepare()` in the PTC
|
|
363
|
+
executor, which invokes the shared pipeline's `tools.checkGuards()` before the body
|
|
364
|
+
(ptc.ts nested dispatch + pipeline.ts guard check). The nested mutation is thus
|
|
365
|
+
still vetoed; only the outer `run_code` call is allowed.
|
|
336
366
|
DSH does not expose a mutability bit on a tool execution, so the name list is
|
|
337
367
|
explicit and must be extended when a new mutation tool is composed. The calling
|
|
338
368
|
Session is a queen in one of two ways:
|
|
@@ -347,7 +377,7 @@ needed and is not implemented.
|
|
|
347
377
|
- when path 2 recognizes a Session, the guard calls the supervisor's
|
|
348
378
|
`setQueenSession()` (idempotent) so the panel can display it and future workers
|
|
349
379
|
use it as parent;
|
|
350
|
-
- denial:
|
|
380
|
+
- denial: `女王可以用 hive_* 与只读工具,实现请交给 worker(检测到 <tool>
|
|
351
381
|
调用,已拦截)`, with `info.code = QUEEN_BOUNDARY_VIOLATION`;
|
|
352
382
|
- the attempt is appended to `<repo>/.hive/events.jsonl` as
|
|
353
383
|
`{ ts, actor: "hive-runner", kind: "queen_boundary_violation", tool, message,
|
|
@@ -365,7 +395,8 @@ needed and is not implemented.
|
|
|
365
395
|
service call, not a tool execution, so it bypasses `tools.guard` as well.
|
|
366
396
|
|
|
367
397
|
Tests: `test/queen-boundary.test.js` covers all three delegation tools and the
|
|
368
|
-
mutation tools (write/edit/bash/notebook
|
|
398
|
+
mutation tools (write/edit/bash/notebook denied; read/grep/web/hive/run_code allowed)
|
|
399
|
+
and the nested write/bash veto via the shared PTC pipeline,
|
|
369
400
|
the queen-only
|
|
370
401
|
predicate, cwd-role detection and auto-registration, `/queen off` suppression,
|
|
371
402
|
uninitialized repositories, worker/other Sessions, the durable event, the anomaly and
|
package/index.js
CHANGED
|
@@ -41,6 +41,7 @@ import { createArchReviewAudit } from './lib/audit.js';
|
|
|
41
41
|
import { createHiveRunnerRoute } from './lib/http.js';
|
|
42
42
|
import { RepoLimits } from './lib/limits.js';
|
|
43
43
|
import { createAnomalyFeed } from './lib/anomalies.js';
|
|
44
|
+
import { createCheckpointController } from './lib/checkpoint.js';
|
|
44
45
|
import { createQueenNotifier, deliverToSession } from './lib/notify.js';
|
|
45
46
|
import { createPatrol } from './lib/patrol.js';
|
|
46
47
|
import { drainQueue } from './lib/queue.js';
|
|
@@ -127,6 +128,8 @@ export function apply(ctx, config = {}) {
|
|
|
127
128
|
const anomalies = createAnomalyFeed({ max: resolved.anomalyMax });
|
|
128
129
|
/** @type {ReturnType<typeof createPatrol> | undefined} */
|
|
129
130
|
let patrol;
|
|
131
|
+
/** @type {ReturnType<typeof createCheckpointController> | undefined} */
|
|
132
|
+
let checkpoint;
|
|
130
133
|
function recordAnomaly(event) {
|
|
131
134
|
try {
|
|
132
135
|
anomalies.push(event);
|
|
@@ -241,8 +244,10 @@ export function apply(ctx, config = {}) {
|
|
|
241
244
|
onAnomaly: (event) => recordAnomaly(event),
|
|
242
245
|
onQueenSession: () => {
|
|
243
246
|
if (patrol !== undefined) patrol.flushPending();
|
|
247
|
+
if (checkpoint !== undefined) checkpoint.flushPending();
|
|
244
248
|
},
|
|
245
249
|
pendingAnomalies: () => anomalies.pendingCount(),
|
|
250
|
+
pendingCheckpoints: () => (checkpoint === undefined ? 0 : checkpoint.pendingCount()),
|
|
246
251
|
logger: console,
|
|
247
252
|
debug: resolved.debug,
|
|
248
253
|
});
|
|
@@ -268,7 +273,36 @@ export function apply(ctx, config = {}) {
|
|
|
268
273
|
log('warn', 'arch review audit failed for ' + repo + ': ' + (error instanceof Error ? error.message : String(error)));
|
|
269
274
|
}
|
|
270
275
|
}
|
|
276
|
+
// Progress checkpoints: drained/all-done/gate-advance/idle goals. Delivery
|
|
277
|
+
// is direct; failures stay pending in the checkpoint controller.
|
|
278
|
+
try {
|
|
279
|
+
await checkpoint.tick();
|
|
280
|
+
checkpoint.flushPending();
|
|
281
|
+
} catch (error) {
|
|
282
|
+
log('warn', 'checkpoint tick failed', error);
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
log,
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
checkpoint = createCheckpointController({
|
|
289
|
+
supervisor,
|
|
290
|
+
notifier: resolved.notifyQueen ? notifier : undefined,
|
|
291
|
+
loadBoard: async (repo) => {
|
|
292
|
+
const tasks = await commands.list(repo, {});
|
|
293
|
+
let ready = null;
|
|
294
|
+
try {
|
|
295
|
+
ready = await commands.ready(repo, { limit: 500 });
|
|
296
|
+
} catch {
|
|
297
|
+
// Without a ready list only the idle-no-ready trigger is disabled; the
|
|
298
|
+
// drained/all-done/gate triggers still work from the full board.
|
|
299
|
+
ready = null;
|
|
300
|
+
}
|
|
301
|
+
return { tasks, ready };
|
|
271
302
|
},
|
|
303
|
+
loadEvents: (repo) => readEvents(repo, { limit: 100 }),
|
|
304
|
+
drainMs: resolved.checkpointDrainMs,
|
|
305
|
+
idleMs: resolved.checkpointIdleMs,
|
|
272
306
|
log,
|
|
273
307
|
});
|
|
274
308
|
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queen checkpoint: a progress digest, not just an anomaly digest.
|
|
3
|
+
*
|
|
4
|
+
* The patrol reports problems (failed/timed-out/stalled workers). This module
|
|
5
|
+
* reports *progress* so the queen reacts when work finishes: a drained queue,
|
|
6
|
+
* all tasks done, a gate phase advancing, or a long idle period with no ready
|
|
7
|
+
* work while goals remain. It injects one digest with task statistics, recent
|
|
8
|
+
* completions, gate state, recent events, and an explicit next action.
|
|
9
|
+
*
|
|
10
|
+
* Spam control: the digest is keyed by a state signature (counts + gate +
|
|
11
|
+
* release readiness + recent completed ids). The same state is delivered at most
|
|
12
|
+
* once; a state change immediately re-arms it. When no queen Session is live the
|
|
13
|
+
* digest is queued (pending) and flushed by the next patrol/queen registration.
|
|
14
|
+
*
|
|
15
|
+
* @module dsh-hive-runner/checkpoint
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** Default minimum gap between queue-drained checkpoints. */
|
|
19
|
+
export const DEFAULT_CHECKPOINT_DRAIN_MS = 10 * 60_000;
|
|
20
|
+
/** Default no-ready period before the idle checkpoint fires. */
|
|
21
|
+
export const DEFAULT_CHECKPOINT_IDLE_MS = 10 * 60_000;
|
|
22
|
+
/** Default event window shown in the digest. */
|
|
23
|
+
export const DEFAULT_CHECKPOINT_EVENT_WINDOW_MS = 10 * 60_000;
|
|
24
|
+
|
|
25
|
+
/** Exact model-facing decision request appended to every checkpoint. */
|
|
26
|
+
export const CHECKPOINT_INSTRUCTION = '评估目标是否达成:未达成请继续拆解下一批任务并说明依据;达成请汇总结果并请人类确认发布。';
|
|
27
|
+
|
|
28
|
+
const PHASE_ORDER = ['base', 'group', 'overall', 'released'];
|
|
29
|
+
|
|
30
|
+
function phaseRank(phase) {
|
|
31
|
+
const index = PHASE_ORDER.indexOf(phase);
|
|
32
|
+
return index === -1 ? 0 : index + 1;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function isoAt(value) {
|
|
36
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
37
|
+
if (typeof value === 'string') {
|
|
38
|
+
const parsed = Date.parse(value);
|
|
39
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
40
|
+
}
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function titleOf(task) {
|
|
45
|
+
return typeof task?.title === 'string' && task.title.trim() !== '' ? task.title.trim() : String(task?.id ?? '?');
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Task counts and recent completions from one board snapshot. */
|
|
49
|
+
export function taskCheckpointStats(tasks) {
|
|
50
|
+
const list = Array.isArray(tasks) ? tasks : [];
|
|
51
|
+
const stats = { total: 0, done: 0, failed: 0, pending: 0, claimed: 0, superseded: 0 };
|
|
52
|
+
const completed = [];
|
|
53
|
+
for (const task of list) {
|
|
54
|
+
if (task === null || typeof task !== 'object') continue;
|
|
55
|
+
stats.total += 1;
|
|
56
|
+
if (task.state === 'done') {
|
|
57
|
+
stats.done += 1;
|
|
58
|
+
completed.push({ id: String(task.id ?? ''), title: titleOf(task), at: isoAt(task.doneAt ?? task.updatedAt ?? task.finishedAt) });
|
|
59
|
+
} else if (task.state === 'failed') stats.failed += 1;
|
|
60
|
+
else if (task.state === 'claimed') stats.claimed += 1;
|
|
61
|
+
else if (task.state === 'superseded') stats.superseded += 1;
|
|
62
|
+
else stats.pending += 1;
|
|
63
|
+
}
|
|
64
|
+
completed.sort((a, b) => b.at - a.at);
|
|
65
|
+
return { ...stats, recentCompleted: completed.slice(0, 5) };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** Bounded event summary for the checkpoint's "recent events" line. */
|
|
69
|
+
export function summarizeCheckpointEvents(events, { since = 0, maxKinds = 6 } = {}) {
|
|
70
|
+
const list = Array.isArray(events) ? events : [];
|
|
71
|
+
const counts = new Map();
|
|
72
|
+
let window = 0;
|
|
73
|
+
for (const event of list) {
|
|
74
|
+
if (event === null || typeof event !== 'object') continue;
|
|
75
|
+
if (isoAt(event.ts ?? event.at) < since) continue;
|
|
76
|
+
window += 1;
|
|
77
|
+
const kind = typeof event.kind === 'string' && event.kind !== '' ? event.kind : 'event';
|
|
78
|
+
counts.set(kind, (counts.get(kind) ?? 0) + 1);
|
|
79
|
+
}
|
|
80
|
+
if (window === 0) return 'none in the last window';
|
|
81
|
+
return [...counts.entries()]
|
|
82
|
+
.sort((a, b) => b[1] - a[1])
|
|
83
|
+
.slice(0, maxKinds)
|
|
84
|
+
.map(([kind, count]) => kind + '×' + String(count))
|
|
85
|
+
.join(', ');
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Build the complete injected checkpoint body. */
|
|
89
|
+
export function renderCheckpoint({ repo, stats, gate, recentEvents, trigger, at }) {
|
|
90
|
+
const gatePhase = typeof gate?.phase === 'string' ? gate.phase : 'unknown';
|
|
91
|
+
const releaseReady = gate?.releaseReady === true;
|
|
92
|
+
const titles = stats.recentCompleted.length > 0
|
|
93
|
+
? stats.recentCompleted.map((task) => JSON.stringify(task.title)).join(', ')
|
|
94
|
+
: '(none)';
|
|
95
|
+
return [
|
|
96
|
+
'[hive-runner] checkpoint — ' + String(repo),
|
|
97
|
+
'Trigger: ' + String(trigger),
|
|
98
|
+
'Tasks: done=' + stats.done + ' failed=' + stats.failed + ' pending=' + stats.pending
|
|
99
|
+
+ ' claimed=' + stats.claimed + ' total=' + stats.total,
|
|
100
|
+
'Recently completed: ' + titles,
|
|
101
|
+
'Gate: phase=' + gatePhase + ' releaseReady=' + String(releaseReady)
|
|
102
|
+
+ (typeof gate?.reason === 'string' && gate.reason !== '' ? ' — ' + gate.reason : ''),
|
|
103
|
+
'Events (last window): ' + recentEvents,
|
|
104
|
+
'At: ' + new Date(at).toISOString(),
|
|
105
|
+
'',
|
|
106
|
+
CHECKPOINT_INSTRUCTION,
|
|
107
|
+
].join('\n');
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Create the checkpoint controller used by the patrol.
|
|
112
|
+
* @param {{
|
|
113
|
+
* supervisor?: { status: () => object },
|
|
114
|
+
* loadBoard: (repo: string) => Promise<{ tasks?: object[], ready?: object[] | null }>,
|
|
115
|
+
* loadEvents?: (repo: string) => Promise<object[]> | object[],
|
|
116
|
+
* notifier?: { deliver: (body: string) => { delivered: boolean, via?: string, reason?: string } },
|
|
117
|
+
* now?: () => number,
|
|
118
|
+
* drainMs?: number,
|
|
119
|
+
* idleMs?: number,
|
|
120
|
+
* eventWindowMs?: number,
|
|
121
|
+
* log?: (level: string, ...args: unknown[]) => void,
|
|
122
|
+
* }} options
|
|
123
|
+
*/
|
|
124
|
+
export function createCheckpointController({
|
|
125
|
+
supervisor,
|
|
126
|
+
loadBoard,
|
|
127
|
+
loadEvents = () => [],
|
|
128
|
+
notifier,
|
|
129
|
+
now = () => Date.now(),
|
|
130
|
+
drainMs = DEFAULT_CHECKPOINT_DRAIN_MS,
|
|
131
|
+
idleMs = DEFAULT_CHECKPOINT_IDLE_MS,
|
|
132
|
+
eventWindowMs = DEFAULT_CHECKPOINT_EVENT_WINDOW_MS,
|
|
133
|
+
log = () => {},
|
|
134
|
+
} = {}) {
|
|
135
|
+
if (typeof loadBoard !== 'function') throw new TypeError('createCheckpointController: loadBoard is required');
|
|
136
|
+
const states = new Map();
|
|
137
|
+
const pending = [];
|
|
138
|
+
|
|
139
|
+
function stateFor(repo) {
|
|
140
|
+
let state = states.get(repo);
|
|
141
|
+
if (state === undefined) {
|
|
142
|
+
state = {
|
|
143
|
+
lastCheckpointAt: 0,
|
|
144
|
+
lastSignature: null,
|
|
145
|
+
lastGatePhase: undefined,
|
|
146
|
+
lastReleaseReady: undefined,
|
|
147
|
+
noReadySince: null,
|
|
148
|
+
};
|
|
149
|
+
states.set(repo, state);
|
|
150
|
+
}
|
|
151
|
+
return state;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function deliver(entry) {
|
|
155
|
+
if (notifier === undefined || typeof notifier.deliver !== 'function') {
|
|
156
|
+
return { delivered: false, reason: 'no-notifier' };
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
const result = notifier.deliver(entry.body);
|
|
160
|
+
if (result !== undefined && result.delivered === true) {
|
|
161
|
+
return { delivered: true, via: result.via ?? null };
|
|
162
|
+
}
|
|
163
|
+
return { delivered: false, reason: result?.reason ?? 'not-delivered' };
|
|
164
|
+
} catch (error) {
|
|
165
|
+
log('warn', 'checkpoint delivery failed', error);
|
|
166
|
+
return { delivered: false, reason: 'delivery-threw' };
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function signatureOf(stats, gate) {
|
|
171
|
+
return JSON.stringify({
|
|
172
|
+
done: stats.done,
|
|
173
|
+
failed: stats.failed,
|
|
174
|
+
pending: stats.pending,
|
|
175
|
+
claimed: stats.claimed,
|
|
176
|
+
phase: typeof gate?.phase === 'string' ? gate.phase : null,
|
|
177
|
+
releaseReady: gate?.releaseReady === true,
|
|
178
|
+
completed: stats.recentCompleted.map((task) => task.id),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async function tick() {
|
|
183
|
+
const results = [];
|
|
184
|
+
if (supervisor === undefined || typeof supervisor.status !== 'function') return results;
|
|
185
|
+
let status;
|
|
186
|
+
try {
|
|
187
|
+
status = supervisor.status();
|
|
188
|
+
} catch (error) {
|
|
189
|
+
log('warn', 'checkpoint could not read supervisor status', error);
|
|
190
|
+
return results;
|
|
191
|
+
}
|
|
192
|
+
if (status === null || typeof status !== 'object' || !Array.isArray(status.repos)) return results;
|
|
193
|
+
const at = now();
|
|
194
|
+
for (const repoStatus of status.repos) {
|
|
195
|
+
if (repoStatus === null || typeof repoStatus !== 'object') continue;
|
|
196
|
+
const repo = typeof repoStatus.repo === 'string' ? repoStatus.repo : '';
|
|
197
|
+
if (repo === '') continue;
|
|
198
|
+
let board;
|
|
199
|
+
try {
|
|
200
|
+
board = await loadBoard(repo);
|
|
201
|
+
} catch (error) {
|
|
202
|
+
log('warn', 'checkpoint could not read board for ' + repo, error);
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
if (board === null || typeof board !== 'object') continue;
|
|
206
|
+
const stats = taskCheckpointStats(board.tasks);
|
|
207
|
+
const gate = repoStatus.gate ?? null;
|
|
208
|
+
const phase = typeof gate?.phase === 'string' ? gate.phase : null;
|
|
209
|
+
const releaseReady = gate?.releaseReady === true;
|
|
210
|
+
const state = stateFor(repo);
|
|
211
|
+
|
|
212
|
+
// "No ready work while goals remain" needs the ready count; a loader may
|
|
213
|
+
// not provide it (legacy/test), in which case this trigger is skipped.
|
|
214
|
+
const readyCount = Array.isArray(board.ready) ? board.ready.length : null;
|
|
215
|
+
const unfinished = stats.pending + stats.claimed > 0;
|
|
216
|
+
if (readyCount !== null && unfinished && readyCount === 0) {
|
|
217
|
+
if (state.noReadySince === null) state.noReadySince = at;
|
|
218
|
+
} else {
|
|
219
|
+
state.noReadySince = null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const drained = stats.total > 0 && stats.pending === 0 && stats.claimed === 0;
|
|
223
|
+
const allDone = stats.total > 0 && stats.done === stats.total;
|
|
224
|
+
const gateAdvanced = state.lastGatePhase !== undefined
|
|
225
|
+
&& (phaseRank(phase) > phaseRank(state.lastGatePhase)
|
|
226
|
+
|| (state.lastReleaseReady === false && releaseReady === true));
|
|
227
|
+
const reasons = [];
|
|
228
|
+
if (allDone) reasons.push('all-done');
|
|
229
|
+
else if (drained && at - state.lastCheckpointAt >= drainMs) reasons.push('queue-drained');
|
|
230
|
+
if (gateAdvanced) reasons.push('gate-advanced');
|
|
231
|
+
if (state.noReadySince !== null && at - state.noReadySince >= idleMs) reasons.push('no-ready');
|
|
232
|
+
|
|
233
|
+
const signature = signatureOf(stats, gate);
|
|
234
|
+
if (reasons.length > 0 && signature !== state.lastSignature) {
|
|
235
|
+
let events = [];
|
|
236
|
+
try {
|
|
237
|
+
events = await loadEvents(repo);
|
|
238
|
+
} catch (error) {
|
|
239
|
+
log('warn', 'checkpoint could not read events for ' + repo, error);
|
|
240
|
+
}
|
|
241
|
+
const body = renderCheckpoint({
|
|
242
|
+
repo,
|
|
243
|
+
stats,
|
|
244
|
+
gate,
|
|
245
|
+
recentEvents: summarizeCheckpointEvents(events, { since: at - eventWindowMs }),
|
|
246
|
+
trigger: reasons.join('+'),
|
|
247
|
+
at,
|
|
248
|
+
});
|
|
249
|
+
const entry = { repo, body, signature, at, trigger: reasons.join('+') };
|
|
250
|
+
const delivery = deliver(entry);
|
|
251
|
+
state.lastSignature = signature;
|
|
252
|
+
state.lastCheckpointAt = at;
|
|
253
|
+
if (delivery.delivered) {
|
|
254
|
+
log('info', 'checkpoint delivered to queen', repo, reasons.join('+'));
|
|
255
|
+
results.push({ repo, trigger: entry.trigger, delivered: true, via: delivery.via ?? null });
|
|
256
|
+
} else {
|
|
257
|
+
pending.push(entry);
|
|
258
|
+
log('info', 'checkpoint queued (no live queen)', repo, delivery.reason);
|
|
259
|
+
results.push({ repo, trigger: entry.trigger, delivered: false, reason: delivery.reason ?? 'not-delivered' });
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
state.lastGatePhase = phase;
|
|
263
|
+
state.lastReleaseReady = releaseReady;
|
|
264
|
+
}
|
|
265
|
+
return results;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function flushPending() {
|
|
269
|
+
let delivered = 0;
|
|
270
|
+
for (const entry of [...pending]) {
|
|
271
|
+
const result = deliver(entry);
|
|
272
|
+
if (result.delivered) {
|
|
273
|
+
pending.splice(pending.indexOf(entry), 1);
|
|
274
|
+
delivered += 1;
|
|
275
|
+
log('info', 'pending checkpoint delivered', entry.repo);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return { delivered, pending: pending.length };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return {
|
|
282
|
+
tick,
|
|
283
|
+
flushPending,
|
|
284
|
+
pendingCount: () => pending.length,
|
|
285
|
+
pending: () => pending.map((entry) => ({ ...entry })),
|
|
286
|
+
size: () => states.size,
|
|
287
|
+
};
|
|
288
|
+
}
|
package/lib/config.js
CHANGED
|
@@ -32,6 +32,10 @@ export const DEFAULT_ANOMALY_DEBOUNCE_MS = 3_000;
|
|
|
32
32
|
export const DEFAULT_ANOMALY_MAX = 50;
|
|
33
33
|
/** Grace before a done card without an arch_review event is flagged. */
|
|
34
34
|
export const DEFAULT_ARCH_REVIEW_GRACE_MS = 10 * 60_000;
|
|
35
|
+
/** Minimum gap between queue-drained progress checkpoints sent to the queen. */
|
|
36
|
+
export const DEFAULT_CHECKPOINT_DRAIN_MS = 10 * 60_000;
|
|
37
|
+
/** No-ready time before the idle progress checkpoint fires. */
|
|
38
|
+
export const DEFAULT_CHECKPOINT_IDLE_MS = 10 * 60_000;
|
|
35
39
|
/** Default role -> concurrent live-worker cap, per repository. */
|
|
36
40
|
export const DEFAULT_ROLE_CONCURRENCY = Object.freeze({ coder: 5, tester: 5 });
|
|
37
41
|
/** Fallback cap for roles not listed in `roleConcurrency` (also finite). */
|
|
@@ -76,6 +80,11 @@ const DEFAULTS = Object.freeze({
|
|
|
76
80
|
// A done card must carry an arch_review event; flag it after this grace (the
|
|
77
81
|
// queen reviews finished cards at the next patrol).
|
|
78
82
|
archReviewGraceMs: DEFAULT_ARCH_REVIEW_GRACE_MS,
|
|
83
|
+
// Progress checkpoints (not anomalies): the queen is asked to evaluate the
|
|
84
|
+
// goal when the queue drains, all cards are done, a gate advances, or no
|
|
85
|
+
// ready work exists while goals remain.
|
|
86
|
+
checkpointDrainMs: DEFAULT_CHECKPOINT_DRAIN_MS,
|
|
87
|
+
checkpointIdleMs: DEFAULT_CHECKPOINT_IDLE_MS,
|
|
79
88
|
provider: 'spawn',
|
|
80
89
|
parentSession: null,
|
|
81
90
|
cwd: null,
|
|
@@ -282,6 +291,8 @@ export function resolveConfig(config = {}) {
|
|
|
282
291
|
fail('defaultRoleConcurrency must be an integer in 0..999 (0 pauses unlisted roles)');
|
|
283
292
|
}
|
|
284
293
|
cfg.capacityRetryMs = positiveNumber(cfg.capacityRetryMs, 'capacityRetryMs');
|
|
294
|
+
cfg.checkpointDrainMs = positiveNumber(cfg.checkpointDrainMs, 'checkpointDrainMs');
|
|
295
|
+
cfg.checkpointIdleMs = positiveNumber(cfg.checkpointIdleMs, 'checkpointIdleMs');
|
|
285
296
|
cfg.cardTimeoutMs = positiveNumber(cfg.cardTimeoutMs, 'cardTimeoutMs');
|
|
286
297
|
cfg.heartbeatWarnMs = positiveNumber(cfg.heartbeatWarnMs, 'heartbeatWarnMs');
|
|
287
298
|
cfg.heartbeatIntervalMs = positiveNumber(cfg.heartbeatIntervalMs, 'heartbeatIntervalMs');
|
package/lib/events.js
CHANGED
|
@@ -108,7 +108,7 @@ export const ESCALATION_KIND = 'queen_escalation';
|
|
|
108
108
|
/** Event kind written when the queen tries to delegate coding directly. */
|
|
109
109
|
export const QUEEN_BOUNDARY_KIND = 'queen_boundary_violation';
|
|
110
110
|
/** Model-facing correction carried by a boundary violation. */
|
|
111
|
-
export const QUEEN_BOUNDARY_MESSAGE = '
|
|
111
|
+
export const QUEEN_BOUNDARY_MESSAGE = '女王可以用 hive_* 与只读工具,实现请交给 worker';
|
|
112
112
|
/** Intervention actions the queen may record. */
|
|
113
113
|
export const INTERVENTION_ACTIONS = Object.freeze([
|
|
114
114
|
'reopen', 'split', 'reassign', 'pause', 'fail', 'guide', 'remove', 'rebuild', 'escalate',
|
package/lib/queen-boundary.js
CHANGED
|
@@ -51,7 +51,10 @@ export const QUEEN_MUTATING_TOOLS = Object.freeze([
|
|
|
51
51
|
'str_replace_editor',
|
|
52
52
|
'bash',
|
|
53
53
|
'pwsh',
|
|
54
|
-
|
|
54
|
+
// NOTE: run_code is intentionally NOT here. Under the PTC preset it is the
|
|
55
|
+
// queen's only transport; its nested tool dispatches still run through the
|
|
56
|
+
// shared tool pipeline with the queen's Agent, so write/edit/bash remain
|
|
57
|
+
// vetoed inside the program (see docs/DESIGN.md).
|
|
55
58
|
'create_worktree',
|
|
56
59
|
'notebook',
|
|
57
60
|
'notebook_edit',
|
|
@@ -70,7 +73,7 @@ export const QUEEN_MUTATING_TOOLS = Object.freeze([
|
|
|
70
73
|
]);
|
|
71
74
|
|
|
72
75
|
/** Model-facing correction for a blocked queen tool call. */
|
|
73
|
-
export const QUEEN_BOUNDARY_MESSAGE = '
|
|
76
|
+
export const QUEEN_BOUNDARY_MESSAGE = '女王可以用 hive_* 与只读工具,实现请交给 worker';
|
|
74
77
|
|
|
75
78
|
/**
|
|
76
79
|
* Classify a tool name inside the queen boundary.
|
package/lib/supervisor.js
CHANGED
|
@@ -140,6 +140,7 @@ export class HiveSupervisor {
|
|
|
140
140
|
* @param {(event: object) => void} [options.onAnomaly] supervision event sink (queen digest)
|
|
141
141
|
* @param {(sessionId: string) => void} [options.onQueenSession] called after a queen Session registers
|
|
142
142
|
* @param {() => number} [options.pendingAnomalies] undelivered queen anomalies reported in status
|
|
143
|
+
* @param {() => number} [options.pendingCheckpoints] undelivered progress checkpoints reported in status
|
|
143
144
|
* @param {Console} [options.logger]
|
|
144
145
|
* @param {boolean} [options.debug]
|
|
145
146
|
*/
|
|
@@ -178,6 +179,7 @@ export class HiveSupervisor {
|
|
|
178
179
|
this.onAnomaly = typeof options.onAnomaly === 'function' ? options.onAnomaly : undefined;
|
|
179
180
|
this.onQueenSession = typeof options.onQueenSession === 'function' ? options.onQueenSession : undefined;
|
|
180
181
|
this.pendingAnomalies = typeof options.pendingAnomalies === 'function' ? options.pendingAnomalies : undefined;
|
|
182
|
+
this.pendingCheckpoints = typeof options.pendingCheckpoints === 'function' ? options.pendingCheckpoints : undefined;
|
|
181
183
|
this.discover = options.discover;
|
|
182
184
|
this.logger = options.logger === undefined ? console : options.logger;
|
|
183
185
|
this.debug = options.debug === true;
|
|
@@ -547,8 +549,10 @@ export class HiveSupervisor {
|
|
|
547
549
|
capacityRetryMs: this.capacityRetryMs,
|
|
548
550
|
lastTickAt: iso(this.lastTickAt),
|
|
549
551
|
lastDiscoverError: this.lastDiscoverError,
|
|
550
|
-
// Undelivered anomaly digests waiting for a live
|
|
552
|
+
// Undelivered anomaly digests / progress checkpoints waiting for a live
|
|
553
|
+
// queen Session.
|
|
551
554
|
pendingAnomalies: this.#pendingAnomalyCount(),
|
|
555
|
+
pendingCheckpoints: this.#pendingCheckpointCount(),
|
|
552
556
|
repoCount: this.repos.size,
|
|
553
557
|
// Worker Session ids across all repositories: the panel exempts them from
|
|
554
558
|
// queen-mode prompt injection and the guard exempts their tool calls.
|
|
@@ -852,6 +856,16 @@ export class HiveSupervisor {
|
|
|
852
856
|
}
|
|
853
857
|
}
|
|
854
858
|
|
|
859
|
+
/** Undelivered progress checkpoint count; observability never throws. */
|
|
860
|
+
#pendingCheckpointCount() {
|
|
861
|
+
try {
|
|
862
|
+
const value = typeof this.pendingCheckpoints === 'function' ? this.pendingCheckpoints() : 0;
|
|
863
|
+
return Number.isInteger(value) && value >= 0 ? value : 0;
|
|
864
|
+
} catch {
|
|
865
|
+
return 0;
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
855
869
|
/** Best-effort live worker list for status; observability never throws. */
|
|
856
870
|
#workers(repo) {
|
|
857
871
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hive-runner",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.13",
|
|
4
4
|
"description": "DSH host plugin for Hive: a resident supervisor that runs one DSH subagent per ready task card, with per-role worker limits, pause/resume and Hive tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./index.js",
|