dsh-hive-runner 1.0.11 → 1.0.14
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 +57 -0
- package/README.md +20 -5
- package/README.zh-CN.md +6 -3
- package/SPEC.md +28 -6
- package/cordis.patch.yml +12 -5
- package/docs/DESIGN.md +43 -4
- package/index.js +47 -1
- package/lib/checkpoint.js +373 -0
- package/lib/config.js +24 -7
- package/lib/events.js +1 -1
- package/lib/queen-boundary.js +5 -2
- package/lib/round.js +8 -0
- package/lib/supervisor.js +31 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,59 @@ 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.14] - 2026-12-05
|
|
11
|
+
|
|
12
|
+
### Fixed
|
|
13
|
+
|
|
14
|
+
- Progress checkpoints are near-real-time again: the patrol default is now
|
|
15
|
+
`patrolIntervalMs: 5000` (the old `patrolMs` name is accepted as an alias), the first
|
|
16
|
+
drained checkpoint after a supervisor restart needs only 5 seconds of drained state,
|
|
17
|
+
and the first digest is labelled `supervisor 刚启动`. Later drain checkpoints keep the
|
|
18
|
+
10-minute `checkpointDrainMs` minimum.
|
|
19
|
+
- Card settle (`done`/`failed`) and gate-phase/releaseReady changes trigger an immediate
|
|
20
|
+
checkpoint request via new `onSettled`/`onGateChange` hooks instead of waiting for the
|
|
21
|
+
next patrol tick. Same-state dedup still applies.
|
|
22
|
+
- Board-read overhead is bounded: consecutive checkpoint ticks reuse the same repository
|
|
23
|
+
`hive-tasks list --json` result for 2 seconds (events invalidate it), and a failing
|
|
24
|
+
shell read backs off for 15 seconds.
|
|
25
|
+
|
|
26
|
+
### Compatibility
|
|
27
|
+
|
|
28
|
+
- `patrolMs` is still accepted as a legacy alias for `patrolIntervalMs`; both keys are
|
|
29
|
+
reported on the resolved config.
|
|
30
|
+
|
|
31
|
+
## [1.0.13] - 2026-12-05
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- Progress checkpoints delivered to the queen: the patrol now reports progress, not
|
|
36
|
+
only anomalies. Triggers: a drained queue (no pending/claimed, at least
|
|
37
|
+
`checkpointDrainMs` since the last checkpoint), all tasks done / gate phase advance /
|
|
38
|
+
`releaseReady` flip, or no ready task for `checkpointIdleMs` while unfinished goals
|
|
39
|
+
remain. The digest carries done/failed/pending/claimed/total counts, recent completed
|
|
40
|
+
titles, gate phase/releaseReady, a bounded last-10-minute event summary and the
|
|
41
|
+
instruction to evaluate the goal (split the next batch, or summarize and ask the human
|
|
42
|
+
to confirm release). A state signature deduplicates it; no live queen Session keeps
|
|
43
|
+
checkpoints pending (`status.pendingCheckpoints`) until the next patrol/registration.
|
|
44
|
+
- New config keys `checkpointDrainMs` / `checkpointIdleMs` (defaults 600000).
|
|
45
|
+
|
|
46
|
+
### Published
|
|
47
|
+
|
|
48
|
+
- npm: `dsh-hive-runner@1.0.13` on 2026-12-05.
|
|
49
|
+
|
|
50
|
+
## [1.0.12] - 2026-12-05
|
|
51
|
+
|
|
52
|
+
### Fixed
|
|
53
|
+
|
|
54
|
+
- The queen can use `run_code` again: PTC mode exposes only `run_code` and the
|
|
55
|
+
mutation list wrongly vetoed it, leaving the queen with no callable tool. `run_code`
|
|
56
|
+
is removed from `QUEEN_MUTATING_TOOLS`; its nested `tools.write` / `tools.edit` /
|
|
57
|
+
`tools.bash` dispatches still pass the same Agent into the shared PTC pipeline, so
|
|
58
|
+
`ctx.tools.guard` vetoes the nested mutation before the body runs. Direct
|
|
59
|
+
write/edit/bash/apply_patch/notebook/office/terminal calls remain vetoed.
|
|
60
|
+
- Boundary denial text now says `女王可以用 hive_* 与只读工具,实现请交给 worker`
|
|
61
|
+
instead of suggesting a workflow that leaves the PTC queen tool-less.
|
|
62
|
+
|
|
10
63
|
## [1.0.11] - 2026-12-05
|
|
11
64
|
|
|
12
65
|
### Fixed
|
|
@@ -20,6 +73,10 @@ iterations of the plugin before this repository was published.
|
|
|
20
73
|
`parentSession === queenSessionId` as the restart/provider fallback, so a worker's
|
|
21
74
|
write/edit/bash and subagent tools keep working while the queen is still denied.
|
|
22
75
|
|
|
76
|
+
### Published
|
|
77
|
+
|
|
78
|
+
- npm: `dsh-hive-runner@1.0.11` on 2026-12-05.
|
|
79
|
+
|
|
23
80
|
## [1.0.10] - 2026-12-05
|
|
24
81
|
|
|
25
82
|
### 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
|
|
@@ -143,13 +145,24 @@ so a noisy minute becomes **one** message, not ten.
|
|
|
143
145
|
Two guarantees keep this quiet:
|
|
144
146
|
|
|
145
147
|
- **Only anomalies are delivered.** A healthy swarm produces no message at all; the
|
|
146
|
-
periodical **patrol** (`
|
|
148
|
+
periodical **patrol** (`patrolIntervalMs`, default 5 seconds) re-reads the supervisor status,
|
|
147
149
|
reports auto-paused repositories, environment errors, stalled heartbeats and agents
|
|
148
150
|
past their deadline, and delivers only when something is pending.
|
|
149
151
|
- **Nothing is lost when no queen is live.** If the panel is closed or the Session is
|
|
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 (the first
|
|
156
|
+
checkpoint after a restart needs only 5 seconds of drained state; later ones use
|
|
157
|
+
`checkpointDrainMs`, default 10 minutes), when every task is done, when a gate phase
|
|
158
|
+
advances (these fire immediately on the worker/gate event), or when no task is ready
|
|
159
|
+
for `checkpointIdleMs` (default 10 minutes) while work remains, the queen gets a
|
|
160
|
+
checkpoint digest with task counts, recently completed titles, gate state and the last
|
|
161
|
+
10 minutes of events. The first one is labelled `supervisor 刚启动`. It asks her to
|
|
162
|
+
evaluate the goal and either split the next batch or summarize and ask the human to
|
|
163
|
+
confirm release. The same state is sent once; a state change re-arms it. With no live
|
|
164
|
+
queen Session the checkpoint stays pending (`pendingCheckpoints` in status) and is
|
|
165
|
+
flushed on the next patrol/registration.
|
|
153
166
|
|
|
154
167
|
### The gates the queen orchestrates
|
|
155
168
|
|
|
@@ -283,11 +296,13 @@ written to `docs/CONVENTIONS.md` / `AGENTS.md` / an ADR, not just remembered in
|
|
|
283
296
|
|
|
284
297
|
| Key | Default | Meaning |
|
|
285
298
|
| --- | --- | --- |
|
|
286
|
-
| `
|
|
299
|
+
| `patrolIntervalMs` | `5000` (5 s) | queen/checkpoint patrol period; board reads are cached for 2 s |
|
|
287
300
|
| `notifyQueen` | `true` | inject the digest into the registered queen Session; `false` = pending list only |
|
|
288
301
|
| `anomalyDebounceMs` | `3000` | coalescing window before one digest is sent |
|
|
289
302
|
| `anomalyMax` | `50` | bound on the undelivered anomaly queue |
|
|
290
303
|
| `archReviewGraceMs` | `600000` (10 min) | grace before a done task without an `arch_review` event is flagged |
|
|
304
|
+
| `checkpointDrainMs` | `600000` (10 min) | minimum gap between drained-queue progress checkpoints |
|
|
305
|
+
| `checkpointIdleMs` | `600000` (10 min) | no-ready time before the idle progress checkpoint fires |
|
|
291
306
|
| `rolesBin` | `null` | executable for `hive roles` (umbrella `@d86e/hive`); falls back to `hiveBin` |
|
|
292
307
|
|
|
293
308
|
## Requirements
|
package/README.zh-CN.md
CHANGED
|
@@ -91,8 +91,9 @@ user 消息能通过 session 日志校验,不需要改 DSH。)同类事件
|
|
|
91
91
|
|
|
92
92
|
两条静默保证:
|
|
93
93
|
|
|
94
|
-
- **只有异常才投递。** 蜂群健康时一条消息都不发;周期性**巡检**(`
|
|
95
|
-
|
|
94
|
+
- **只有异常才投递。** 蜂群健康时一条消息都不发;周期性**巡检**(`patrolIntervalMs`,默认 5
|
|
95
|
+
秒)重读 supervisor 状态;同一仓库的 board 读取缓存 2 秒,发现自动暂停、环境错误、
|
|
96
|
+
心跳告警、任务超时或进度 checkpoint 时才投递。
|
|
96
97
|
- **没有女王时不丢。** 面板关掉或会话不在,摘要留在待处理列表:`hive_anomalies`
|
|
97
98
|
可列出/确认,`hive_supervisor_status` 报告 `pendingAnomalies`,下一个注册的女王会话
|
|
98
99
|
会把队列冲掉。`notifyQueen: false` 表示只保留待处理列表、不注入。
|
|
@@ -202,11 +203,13 @@ outstanding/failed 与 `releaseReady`、`reason`)。`releaseReady` 为 true
|
|
|
202
203
|
|
|
203
204
|
| 键 | 默认 | 含义 |
|
|
204
205
|
| --- | --- | --- |
|
|
205
|
-
| `
|
|
206
|
+
| `patrolIntervalMs` | `5000`(5 秒) | 女王/进度巡检周期;任务板读取缓存 2 秒 |
|
|
206
207
|
| `notifyQueen` | `true` | 把摘要注入已注册的女王会话;`false` 只留待处理列表 |
|
|
207
208
|
| `anomalyDebounceMs` | `3000` | 合并成一条摘要前的防抖时间 |
|
|
208
209
|
| `anomalyMax` | `50` | 待投递异常队列上限 |
|
|
209
210
|
| `archReviewGraceMs` | `600000`(10 分钟) | done 任务缺少 `arch_review` 事件多久后被标记 |
|
|
211
|
+
| `checkpointDrainMs` | `600000`(10 分钟) | 队列排空后两次进度 checkpoint 的最小间隔 |
|
|
212
|
+
| `checkpointIdleMs` | `600000`(10 分钟) | 无 ready 任务多久后触发 idle 进度 checkpoint |
|
|
210
213
|
| `rolesBin` | `null` | `hive roles` 的可执行文件(umbrella `@d86e/hive`),默认退回 `hiveBin` |
|
|
211
214
|
|
|
212
215
|
## 环境要求
|
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).
|
|
@@ -348,8 +350,8 @@ Two sources feed one digest:
|
|
|
348
350
|
`auto-paused`, `environment-error`. The plugin pushes them into an in-memory
|
|
349
351
|
AnomalyFeed (`lib/anomalies.js`): entries coalesce per `(kind, repo, cardId)`
|
|
350
352
|
inside a ten-minute window and are bounded by `anomalyMax`.
|
|
351
|
-
- **Patrol** — `lib/patrol.js` re-reads `supervisor.status()` every `
|
|
352
|
-
(default 5
|
|
353
|
+
- **Patrol** — `lib/patrol.js` re-reads `supervisor.status()` every `patrolIntervalMs`
|
|
354
|
+
(default 5 seconds; same-repo board reads reuse a 2-second cache) and pushes `auto-paused`, `environment-error`, `heartbeat-warn`
|
|
353
355
|
(agent heartbeat `warn`) and `card-timeout` (agent past `timeoutAt`), so a missed
|
|
354
356
|
event is recovered even though only one digest is delivered.
|
|
355
357
|
|
|
@@ -372,7 +374,25 @@ 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 5-second patrol also sends a progress digest to the queen (not just anomalies):
|
|
380
|
+
(1) the queue is drained — no pending/claimed tasks, including failed ones — and the
|
|
381
|
+
first checkpoint after a restart needs only 5 seconds of drained state; later ones use
|
|
382
|
+
`checkpointDrainMs` (default 10 min); (2) all tasks are done or the gate phase advanced
|
|
383
|
+
/ `releaseReady` became true — delivered immediately via the settled/gate hooks, not on
|
|
384
|
+
the next tick; (3) no ready task exists while unfinished tasks remain, continuously for
|
|
385
|
+
`checkpointIdleMs` (default 10 min). The first checkpoint after startup is labelled
|
|
386
|
+
`supervisor 刚启动`. Board reads reuse a 2-second same-repo cache and back off 15 seconds
|
|
387
|
+
after a shell failure. The digest carries done/failed/pending/claimed/total counts, recent completed
|
|
388
|
+
task titles, gate phase/releaseReady, a bounded last-10-minute event summary, the
|
|
389
|
+
trigger, and the instruction: `评估目标是否达成:未达成请继续拆解下一批任务并说明依据;
|
|
390
|
+
达成请汇总结果并请人类确认发布。`. The same state is sent once (state signature =
|
|
391
|
+
counts + gate + recent completed ids); a change re-arms it. With no live queen
|
|
392
|
+
Session it stays pending (`status.pendingCheckpoints`) and is flushed by the next
|
|
393
|
+
patrol or queen registration.
|
|
394
|
+
|
|
395
|
+
### 8.6.2 Queen tool boundary
|
|
376
396
|
|
|
377
397
|
DSH's `ctx.tools.guard` lets a plugin veto a tool call after pre-execute policy and
|
|
378
398
|
before the body. The runner registers one global guard. A Session is recognized as
|
|
@@ -381,9 +401,11 @@ whose cwd contains `.hive/roles/queen.md`; an explicit latest `/queen off` comma
|
|
|
381
401
|
suppresses the veto for that Session (`/queen on` re-enables it). Two tool classes are
|
|
382
402
|
vetoed: delegation (`subagent`, `subagent_fork`, `subagent_claude_code`) and mutation
|
|
383
403
|
(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
|
-
|
|
404
|
+
bash/pwsh, notebook/office/terminal/ralph/create_worktree and common aliases).
|
|
405
|
+
Read-only tools (read/grep/glob/web_*/hive_*/list_agents/...) stay allowed. `run_code`
|
|
406
|
+
is allowed because PTC is the queen's transport; its nested write/edit/bash calls carry
|
|
407
|
+
the same Agent and go through the shared pipeline's guard, so they are still vetoed.
|
|
408
|
+
The call fails with `女王可以用 hive_* 与只读工具,实现请交给 worker(检测到 <tool>
|
|
387
409
|
调用,已拦截)`; the body never runs. The attempt is appended to `<repo>/.hive/events.jsonl` with
|
|
388
410
|
`kind: "queen_boundary_violation"` (`ts`, `actor`, `tool`, `message`, `sessionId`),
|
|
389
411
|
pushed as a `queen-boundary-violation` anomaly so the digest reaches the queen, and
|
package/cordis.patch.yml
CHANGED
|
@@ -77,11 +77,11 @@
|
|
|
77
77
|
# poll cadence.
|
|
78
78
|
heartbeatWarnMs: 300000
|
|
79
79
|
heartbeatIntervalMs: 30000
|
|
80
|
-
# Queen coordination. The patrol checks the supervisor every
|
|
81
|
-
#
|
|
82
|
-
#
|
|
83
|
-
# notifyQueen=false
|
|
84
|
-
|
|
80
|
+
# Queen coordination. The patrol checks the supervisor every
|
|
81
|
+
# patrolIntervalMs (default 5s for near-real-time progress) and delivers
|
|
82
|
+
# ONE digest to the registered queen Session only when there is an
|
|
83
|
+
# anomaly or checkpoint. notifyQueen=false keeps the pending list only.
|
|
84
|
+
patrolIntervalMs: 5000
|
|
85
85
|
notifyQueen: true
|
|
86
86
|
# Card events coalesce for anomalyDebounceMs before one digest is sent;
|
|
87
87
|
# anomalyMax bounds the undelivered queue exposed by hive_anomalies.
|
|
@@ -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,12 +265,13 @@ 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 |
|
|
268
272
|
| `lib/queen-boundary.js` | `ctx.tools.guard` veto for queen → `subagent`/`subagent_fork`/`subagent_claude_code`; returns the correction and reports the attempt |
|
|
269
273
|
| `lib/limits.js` | `<repo>/.hive/limits.json` read/write/hot-reload and precedence helpers |
|
|
270
|
-
| `lib/config.js` | Config defaults/validation (`
|
|
274
|
+
| `lib/config.js` | Config defaults/validation (`patrolIntervalMs`, `notifyQueen`, `anomaly*`, `checkpoint*`, `rolesBin`), role map parsing, effective-limit helpers |
|
|
271
275
|
| `lib/commands.js` | Allowlisted `hive-tasks` / `hive` / `git` / acceptance commands with shell quoting; queen verbs list/add/edit/split/supersede/reopen/retry/rm/lesson/roles |
|
|
272
276
|
| `lib/shell.js` | `ctx.shell.resolve/execute` adapter (sandbox policy per call) |
|
|
273
277
|
| `lib/discover.js` | `refs/hive/v1` repository discovery |
|
|
@@ -314,6 +318,34 @@ 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 5-second patrol also reports progress, not only problems. `lib/checkpoint.js` runs
|
|
324
|
+
from the patrol inspect hook for every registered repository and sends a checkpoint
|
|
325
|
+
when:
|
|
326
|
+
|
|
327
|
+
1. the queue is drained (no pending/claimed tasks, including failed ones); the first
|
|
328
|
+
drained checkpoint after a supervisor restart needs only 5 seconds of drained state,
|
|
329
|
+
later ones use `checkpointDrainMs` (default 10 min);
|
|
330
|
+
2. all tasks are done, or the gate phase advanced / `releaseReady` flipped true — this
|
|
331
|
+
fires immediately via the `onSettled`/`onGateChange` hooks, without waiting for the
|
|
332
|
+
next patrol tick;
|
|
333
|
+
3. no ready task exists while unfinished tasks remain, continuously for
|
|
334
|
+
`checkpointIdleMs` (default 10 min).
|
|
335
|
+
|
|
336
|
+
The first checkpoint after startup carries `Context: supervisor 刚启动` so the queen
|
|
337
|
+
knows the digest is from a fresh process. The digest contains
|
|
338
|
+
`done/failed/pending/claimed/total`, the last completed task titles, gate
|
|
339
|
+
phase/releaseReady/reason, a bounded summary of events from the last 10 minutes, the
|
|
340
|
+
trigger, and the instruction `评估目标是否达成:未达成请继续拆解下一批任务并说明依据;达成请汇总结果并请人类确认发布。`.
|
|
341
|
+
It is delivered through the queen notifier. The state signature (counts + gate +
|
|
342
|
+
releaseReady + recent completed ids) deduplicates it: the same state is sent once and
|
|
343
|
+
only a state change re-arms it. Board reads reuse a 2-second same-repo cache (events
|
|
344
|
+
invalidate it); a failing `hive-tasks list` backs off for 15 seconds. Without a live
|
|
345
|
+
queen Session the checkpoint is kept in the controller's pending list (status
|
|
346
|
+
`pendingCheckpoints`) and flushed by the next patrol or queen registration; it never
|
|
347
|
+
falls through to an anomaly digest.
|
|
348
|
+
|
|
317
349
|
### Tool boundary: hard veto through `ctx.tools.guard`
|
|
318
350
|
|
|
319
351
|
DSH does expose a plugin-side tool veto. `ToolsService.guard(guard)` registers a
|
|
@@ -330,9 +362,15 @@ needed and is not implemented.
|
|
|
330
362
|
- predicate: the tool is in one of two classes — delegation (`subagent`,
|
|
331
363
|
`subagent_fork`, `subagent_claude_code`) or mutation (the explicit
|
|
332
364
|
`QUEEN_MUTATING_TOOLS` list: `write`/`edit`/`apply_patch`/`str_replace_editor`,
|
|
333
|
-
`bash`/`pwsh
|
|
365
|
+
`bash`/`pwsh`, notebook editors, `create_worktree`, `office_*`, `ralph*`,
|
|
334
366
|
`terminal_*`, and common aliases). Read-only tools (`read`, `grep`, `glob`,
|
|
335
367
|
`web_*`, `hive_*`, `list_agents`, ...) are not in the list and stay allowed.
|
|
368
|
+
`run_code` is **not** in the list: under the PTC preset it is the queen's only
|
|
369
|
+
transport. Its nested `tools.write`/`tools.edit`/`tools.bash` calls carry the same
|
|
370
|
+
Agent in `ToolExecutionInput` and go through `executor.prepare()` in the PTC
|
|
371
|
+
executor, which invokes the shared pipeline's `tools.checkGuards()` before the body
|
|
372
|
+
(ptc.ts nested dispatch + pipeline.ts guard check). The nested mutation is thus
|
|
373
|
+
still vetoed; only the outer `run_code` call is allowed.
|
|
336
374
|
DSH does not expose a mutability bit on a tool execution, so the name list is
|
|
337
375
|
explicit and must be extended when a new mutation tool is composed. The calling
|
|
338
376
|
Session is a queen in one of two ways:
|
|
@@ -347,7 +385,7 @@ needed and is not implemented.
|
|
|
347
385
|
- when path 2 recognizes a Session, the guard calls the supervisor's
|
|
348
386
|
`setQueenSession()` (idempotent) so the panel can display it and future workers
|
|
349
387
|
use it as parent;
|
|
350
|
-
- denial:
|
|
388
|
+
- denial: `女王可以用 hive_* 与只读工具,实现请交给 worker(检测到 <tool>
|
|
351
389
|
调用,已拦截)`, with `info.code = QUEEN_BOUNDARY_VIOLATION`;
|
|
352
390
|
- the attempt is appended to `<repo>/.hive/events.jsonl` as
|
|
353
391
|
`{ ts, actor: "hive-runner", kind: "queen_boundary_violation", tool, message,
|
|
@@ -365,7 +403,8 @@ needed and is not implemented.
|
|
|
365
403
|
service call, not a tool execution, so it bypasses `tools.guard` as well.
|
|
366
404
|
|
|
367
405
|
Tests: `test/queen-boundary.test.js` covers all three delegation tools and the
|
|
368
|
-
mutation tools (write/edit/bash/notebook
|
|
406
|
+
mutation tools (write/edit/bash/notebook denied; read/grep/web/hive/run_code allowed)
|
|
407
|
+
and the nested write/bash veto via the shared PTC pipeline,
|
|
369
408
|
the queen-only
|
|
370
409
|
predicate, cwd-role detection and auto-registration, `/queen off` suppression,
|
|
371
410
|
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';
|
|
@@ -114,6 +115,13 @@ export function apply(ctx, config = {}) {
|
|
|
114
115
|
limitFor: (repo, role) => limits.limitFor(repo, role),
|
|
115
116
|
parentProvider: (explicit) => parentProviderImpl(explicit),
|
|
116
117
|
onAnomaly: (event) => recordAnomaly(event),
|
|
118
|
+
// A finished worker or a settled card asks for a near-real-time checkpoint
|
|
119
|
+
// check instead of waiting for the next patrol tick.
|
|
120
|
+
onSettled: (event) => {
|
|
121
|
+
if (checkpoint !== undefined) {
|
|
122
|
+
void checkpoint.requestTick({ repo: event.repo }).catch((error) => log('warn', 'checkpoint event tick failed', error));
|
|
123
|
+
}
|
|
124
|
+
},
|
|
117
125
|
log,
|
|
118
126
|
});
|
|
119
127
|
parentProviderImpl = async (explicit) => {
|
|
@@ -127,6 +135,8 @@ export function apply(ctx, config = {}) {
|
|
|
127
135
|
const anomalies = createAnomalyFeed({ max: resolved.anomalyMax });
|
|
128
136
|
/** @type {ReturnType<typeof createPatrol> | undefined} */
|
|
129
137
|
let patrol;
|
|
138
|
+
/** @type {ReturnType<typeof createCheckpointController> | undefined} */
|
|
139
|
+
let checkpoint;
|
|
130
140
|
function recordAnomaly(event) {
|
|
131
141
|
try {
|
|
132
142
|
anomalies.push(event);
|
|
@@ -239,10 +249,17 @@ export function apply(ctx, config = {}) {
|
|
|
239
249
|
queenBoundary,
|
|
240
250
|
readMode: (repo) => commands.mode(repo),
|
|
241
251
|
onAnomaly: (event) => recordAnomaly(event),
|
|
252
|
+
onGateChange: (event) => {
|
|
253
|
+
if (checkpoint !== undefined) {
|
|
254
|
+
void checkpoint.requestTick({ repo: event.repo }).catch((error) => log('warn', 'checkpoint gate tick failed', error));
|
|
255
|
+
}
|
|
256
|
+
},
|
|
242
257
|
onQueenSession: () => {
|
|
243
258
|
if (patrol !== undefined) patrol.flushPending();
|
|
259
|
+
if (checkpoint !== undefined) checkpoint.flushPending();
|
|
244
260
|
},
|
|
245
261
|
pendingAnomalies: () => anomalies.pendingCount(),
|
|
262
|
+
pendingCheckpoints: () => (checkpoint === undefined ? 0 : checkpoint.pendingCount()),
|
|
246
263
|
logger: console,
|
|
247
264
|
debug: resolved.debug,
|
|
248
265
|
});
|
|
@@ -251,7 +268,7 @@ export function apply(ctx, config = {}) {
|
|
|
251
268
|
supervisor,
|
|
252
269
|
feed: anomalies,
|
|
253
270
|
notifier: resolved.notifyQueen ? notifier : undefined,
|
|
254
|
-
intervalMs: resolved.
|
|
271
|
+
intervalMs: resolved.patrolIntervalMs,
|
|
255
272
|
debounceMs: resolved.anomalyDebounceMs,
|
|
256
273
|
// Every patrol also audits done cards for a missing architecture review.
|
|
257
274
|
inspect: async () => {
|
|
@@ -268,7 +285,36 @@ export function apply(ctx, config = {}) {
|
|
|
268
285
|
log('warn', 'arch review audit failed for ' + repo + ': ' + (error instanceof Error ? error.message : String(error)));
|
|
269
286
|
}
|
|
270
287
|
}
|
|
288
|
+
// Progress checkpoints: drained/all-done/gate-advance/idle goals. Delivery
|
|
289
|
+
// is direct; failures stay pending in the checkpoint controller.
|
|
290
|
+
try {
|
|
291
|
+
await checkpoint.tick();
|
|
292
|
+
checkpoint.flushPending();
|
|
293
|
+
} catch (error) {
|
|
294
|
+
log('warn', 'checkpoint tick failed', error);
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
log,
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
checkpoint = createCheckpointController({
|
|
301
|
+
supervisor,
|
|
302
|
+
notifier: resolved.notifyQueen ? notifier : undefined,
|
|
303
|
+
loadBoard: async (repo) => {
|
|
304
|
+
const tasks = await commands.list(repo, {});
|
|
305
|
+
let ready = null;
|
|
306
|
+
try {
|
|
307
|
+
ready = await commands.ready(repo, { limit: 500 });
|
|
308
|
+
} catch {
|
|
309
|
+
// Without a ready list only the idle-no-ready trigger is disabled; the
|
|
310
|
+
// drained/all-done/gate triggers still work from the full board.
|
|
311
|
+
ready = null;
|
|
312
|
+
}
|
|
313
|
+
return { tasks, ready };
|
|
271
314
|
},
|
|
315
|
+
loadEvents: (repo) => readEvents(repo, { limit: 100 }),
|
|
316
|
+
drainMs: resolved.checkpointDrainMs,
|
|
317
|
+
idleMs: resolved.checkpointIdleMs,
|
|
272
318
|
log,
|
|
273
319
|
});
|
|
274
320
|
|
|
@@ -0,0 +1,373 @@
|
|
|
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
|
+
/** First startup checkpoint after a drained queue needs only this long. */
|
|
21
|
+
export const DEFAULT_CHECKPOINT_FIRST_DRAIN_MS = 5_000;
|
|
22
|
+
/** A repeated checkpoint tick may reuse the board read for this long. */
|
|
23
|
+
export const DEFAULT_CHECKPOINT_CACHE_MS = 2_000;
|
|
24
|
+
/** After a shell failure, do not retry the board read for this long. */
|
|
25
|
+
export const DEFAULT_CHECKPOINT_ERROR_BACKOFF_MS = 15_000;
|
|
26
|
+
/** Default no-ready period before the idle checkpoint fires. */
|
|
27
|
+
export const DEFAULT_CHECKPOINT_IDLE_MS = 10 * 60_000;
|
|
28
|
+
/** Default event window shown in the digest. */
|
|
29
|
+
export const DEFAULT_CHECKPOINT_EVENT_WINDOW_MS = 10 * 60_000;
|
|
30
|
+
|
|
31
|
+
/** Exact model-facing decision request appended to every checkpoint. */
|
|
32
|
+
export const CHECKPOINT_INSTRUCTION = '评估目标是否达成:未达成请继续拆解下一批任务并说明依据;达成请汇总结果并请人类确认发布。';
|
|
33
|
+
|
|
34
|
+
const PHASE_ORDER = ['base', 'group', 'overall', 'released'];
|
|
35
|
+
|
|
36
|
+
function phaseRank(phase) {
|
|
37
|
+
const index = PHASE_ORDER.indexOf(phase);
|
|
38
|
+
return index === -1 ? 0 : index + 1;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isoAt(value) {
|
|
42
|
+
if (typeof value === 'number' && Number.isFinite(value)) return value;
|
|
43
|
+
if (typeof value === 'string') {
|
|
44
|
+
const parsed = Date.parse(value);
|
|
45
|
+
if (Number.isFinite(parsed)) return parsed;
|
|
46
|
+
}
|
|
47
|
+
return 0;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function titleOf(task) {
|
|
51
|
+
return typeof task?.title === 'string' && task.title.trim() !== '' ? task.title.trim() : String(task?.id ?? '?');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Task counts and recent completions from one board snapshot. */
|
|
55
|
+
export function taskCheckpointStats(tasks) {
|
|
56
|
+
const list = Array.isArray(tasks) ? tasks : [];
|
|
57
|
+
const stats = { total: 0, done: 0, failed: 0, pending: 0, claimed: 0, superseded: 0 };
|
|
58
|
+
const completed = [];
|
|
59
|
+
for (const task of list) {
|
|
60
|
+
if (task === null || typeof task !== 'object') continue;
|
|
61
|
+
stats.total += 1;
|
|
62
|
+
if (task.state === 'done') {
|
|
63
|
+
stats.done += 1;
|
|
64
|
+
completed.push({ id: String(task.id ?? ''), title: titleOf(task), at: isoAt(task.doneAt ?? task.updatedAt ?? task.finishedAt) });
|
|
65
|
+
} else if (task.state === 'failed') stats.failed += 1;
|
|
66
|
+
else if (task.state === 'claimed') stats.claimed += 1;
|
|
67
|
+
else if (task.state === 'superseded') stats.superseded += 1;
|
|
68
|
+
else stats.pending += 1;
|
|
69
|
+
}
|
|
70
|
+
completed.sort((a, b) => b.at - a.at);
|
|
71
|
+
return { ...stats, recentCompleted: completed.slice(0, 5) };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Bounded event summary for the checkpoint's "recent events" line. */
|
|
75
|
+
export function summarizeCheckpointEvents(events, { since = 0, maxKinds = 6 } = {}) {
|
|
76
|
+
const list = Array.isArray(events) ? events : [];
|
|
77
|
+
const counts = new Map();
|
|
78
|
+
let window = 0;
|
|
79
|
+
for (const event of list) {
|
|
80
|
+
if (event === null || typeof event !== 'object') continue;
|
|
81
|
+
if (isoAt(event.ts ?? event.at) < since) continue;
|
|
82
|
+
window += 1;
|
|
83
|
+
const kind = typeof event.kind === 'string' && event.kind !== '' ? event.kind : 'event';
|
|
84
|
+
counts.set(kind, (counts.get(kind) ?? 0) + 1);
|
|
85
|
+
}
|
|
86
|
+
if (window === 0) return 'none in the last window';
|
|
87
|
+
return [...counts.entries()]
|
|
88
|
+
.sort((a, b) => b[1] - a[1])
|
|
89
|
+
.slice(0, maxKinds)
|
|
90
|
+
.map(([kind, count]) => kind + '×' + String(count))
|
|
91
|
+
.join(', ');
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** Build the complete injected checkpoint body. */
|
|
95
|
+
export function renderCheckpoint({ repo, stats, gate, recentEvents, trigger, at, startup = false }) {
|
|
96
|
+
const gatePhase = typeof gate?.phase === 'string' ? gate.phase : 'unknown';
|
|
97
|
+
const releaseReady = gate?.releaseReady === true;
|
|
98
|
+
const titles = stats.recentCompleted.length > 0
|
|
99
|
+
? stats.recentCompleted.map((task) => JSON.stringify(task.title)).join(', ')
|
|
100
|
+
: '(none)';
|
|
101
|
+
return [
|
|
102
|
+
'[hive-runner] checkpoint — ' + String(repo),
|
|
103
|
+
...(startup ? ['Context: supervisor 刚启动(first checkpoint after restart)'] : []),
|
|
104
|
+
'Trigger: ' + String(trigger),
|
|
105
|
+
'Tasks: done=' + stats.done + ' failed=' + stats.failed + ' pending=' + stats.pending
|
|
106
|
+
+ ' claimed=' + stats.claimed + ' total=' + stats.total,
|
|
107
|
+
'Recently completed: ' + titles,
|
|
108
|
+
'Gate: phase=' + gatePhase + ' releaseReady=' + String(releaseReady)
|
|
109
|
+
+ (typeof gate?.reason === 'string' && gate.reason !== '' ? ' — ' + gate.reason : ''),
|
|
110
|
+
'Events (last window): ' + recentEvents,
|
|
111
|
+
'At: ' + new Date(at).toISOString(),
|
|
112
|
+
'',
|
|
113
|
+
CHECKPOINT_INSTRUCTION,
|
|
114
|
+
].join('\n');
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Create the checkpoint controller used by the patrol.
|
|
119
|
+
* @param {{
|
|
120
|
+
* supervisor?: { status: () => object },
|
|
121
|
+
* loadBoard: (repo: string) => Promise<{ tasks?: object[], ready?: object[] | null }>,
|
|
122
|
+
* loadEvents?: (repo: string) => Promise<object[]> | object[],
|
|
123
|
+
* notifier?: { deliver: (body: string) => { delivered: boolean, via?: string, reason?: string } },
|
|
124
|
+
* now?: () => number,
|
|
125
|
+
* drainMs?: number,
|
|
126
|
+
* firstDrainMs?: number,
|
|
127
|
+
* startedAt?: number,
|
|
128
|
+
* idleMs?: number,
|
|
129
|
+
* eventWindowMs?: number,
|
|
130
|
+
* cacheMs?: number,
|
|
131
|
+
* errorBackoffMs?: number,
|
|
132
|
+
* log?: (level: string, ...args: unknown[]) => void,
|
|
133
|
+
* }} options
|
|
134
|
+
*/
|
|
135
|
+
export function createCheckpointController({
|
|
136
|
+
supervisor,
|
|
137
|
+
loadBoard,
|
|
138
|
+
loadEvents = () => [],
|
|
139
|
+
notifier,
|
|
140
|
+
now = () => Date.now(),
|
|
141
|
+
drainMs = DEFAULT_CHECKPOINT_DRAIN_MS,
|
|
142
|
+
firstDrainMs = DEFAULT_CHECKPOINT_FIRST_DRAIN_MS,
|
|
143
|
+
startedAt,
|
|
144
|
+
idleMs = DEFAULT_CHECKPOINT_IDLE_MS,
|
|
145
|
+
eventWindowMs = DEFAULT_CHECKPOINT_EVENT_WINDOW_MS,
|
|
146
|
+
cacheMs = DEFAULT_CHECKPOINT_CACHE_MS,
|
|
147
|
+
errorBackoffMs = DEFAULT_CHECKPOINT_ERROR_BACKOFF_MS,
|
|
148
|
+
log = () => {},
|
|
149
|
+
} = {}) {
|
|
150
|
+
if (typeof loadBoard !== 'function') throw new TypeError('createCheckpointController: loadBoard is required');
|
|
151
|
+
const controllerStartedAt = Number.isFinite(startedAt) ? startedAt : now();
|
|
152
|
+
const states = new Map();
|
|
153
|
+
const pending = [];
|
|
154
|
+
const boardCache = new Map();
|
|
155
|
+
let firstCheckpointCreated = false;
|
|
156
|
+
|
|
157
|
+
function stateFor(repo) {
|
|
158
|
+
let state = states.get(repo);
|
|
159
|
+
if (state === undefined) {
|
|
160
|
+
state = {
|
|
161
|
+
lastCheckpointAt: 0,
|
|
162
|
+
lastSignature: null,
|
|
163
|
+
lastGatePhase: undefined,
|
|
164
|
+
lastReleaseReady: undefined,
|
|
165
|
+
noReadySince: null,
|
|
166
|
+
drainedSince: null,
|
|
167
|
+
hasCheckpoint: false,
|
|
168
|
+
};
|
|
169
|
+
states.set(repo, state);
|
|
170
|
+
}
|
|
171
|
+
return state;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function deliver(entry) {
|
|
175
|
+
if (notifier === undefined || typeof notifier.deliver !== 'function') {
|
|
176
|
+
return { delivered: false, reason: 'no-notifier' };
|
|
177
|
+
}
|
|
178
|
+
try {
|
|
179
|
+
const result = notifier.deliver(entry.body);
|
|
180
|
+
if (result !== undefined && result.delivered === true) {
|
|
181
|
+
return { delivered: true, via: result.via ?? null };
|
|
182
|
+
}
|
|
183
|
+
return { delivered: false, reason: result?.reason ?? 'not-delivered' };
|
|
184
|
+
} catch (error) {
|
|
185
|
+
log('warn', 'checkpoint delivery failed', error);
|
|
186
|
+
return { delivered: false, reason: 'delivery-threw' };
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function signatureOf(stats, gate) {
|
|
191
|
+
return JSON.stringify({
|
|
192
|
+
done: stats.done,
|
|
193
|
+
failed: stats.failed,
|
|
194
|
+
pending: stats.pending,
|
|
195
|
+
claimed: stats.claimed,
|
|
196
|
+
phase: typeof gate?.phase === 'string' ? gate.phase : null,
|
|
197
|
+
releaseReady: gate?.releaseReady === true,
|
|
198
|
+
completed: stats.recentCompleted.map((task) => task.id),
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
async function runTick(options = {}) {
|
|
203
|
+
const results = [];
|
|
204
|
+
const force = options.force === true;
|
|
205
|
+
if (supervisor === undefined || typeof supervisor.status !== 'function') return results;
|
|
206
|
+
let status;
|
|
207
|
+
try {
|
|
208
|
+
status = supervisor.status();
|
|
209
|
+
} catch (error) {
|
|
210
|
+
log('warn', 'checkpoint could not read supervisor status', error);
|
|
211
|
+
return results;
|
|
212
|
+
}
|
|
213
|
+
if (status === null || typeof status !== 'object' || !Array.isArray(status.repos)) return results;
|
|
214
|
+
const at = now();
|
|
215
|
+
for (const repoStatus of status.repos) {
|
|
216
|
+
if (repoStatus === null || typeof repoStatus !== 'object') continue;
|
|
217
|
+
const repo = typeof repoStatus.repo === 'string' ? repoStatus.repo : '';
|
|
218
|
+
if (repo === '') continue;
|
|
219
|
+
if (force) boardCache.delete(repo);
|
|
220
|
+
let board;
|
|
221
|
+
let cacheEntry = boardCache.get(repo);
|
|
222
|
+
if (cacheEntry !== undefined && Number.isFinite(cacheEntry.errorUntil) && cacheEntry.errorUntil > at) {
|
|
223
|
+
// Shell failure backoff: do not hammer a broken hive-tasks CLI.
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
const cacheFresh = cacheEntry !== undefined
|
|
227
|
+
&& cacheEntry.board !== undefined
|
|
228
|
+
&& cacheEntry.stale !== true
|
|
229
|
+
&& at - cacheEntry.at < cacheMs;
|
|
230
|
+
if (cacheFresh) {
|
|
231
|
+
board = cacheEntry.board;
|
|
232
|
+
} else {
|
|
233
|
+
try {
|
|
234
|
+
board = await loadBoard(repo);
|
|
235
|
+
boardCache.set(repo, { at, board, stale: false, errorUntil: 0 });
|
|
236
|
+
} catch (error) {
|
|
237
|
+
boardCache.set(repo, { at: 0, board: undefined, stale: true, errorUntil: at + errorBackoffMs });
|
|
238
|
+
log('warn', 'checkpoint could not read board for ' + repo, error);
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
if (board === null || typeof board !== 'object') continue;
|
|
243
|
+
const stats = taskCheckpointStats(board.tasks);
|
|
244
|
+
const gate = repoStatus.gate ?? null;
|
|
245
|
+
const phase = typeof gate?.phase === 'string' ? gate.phase : null;
|
|
246
|
+
const releaseReady = gate?.releaseReady === true;
|
|
247
|
+
const state = stateFor(repo);
|
|
248
|
+
|
|
249
|
+
// "No ready work while goals remain" needs the ready count; a loader may
|
|
250
|
+
// not provide it (legacy/test), in which case this trigger is skipped.
|
|
251
|
+
const readyCount = Array.isArray(board.ready) ? board.ready.length : null;
|
|
252
|
+
const unfinished = stats.pending + stats.claimed > 0;
|
|
253
|
+
if (readyCount !== null && unfinished && readyCount === 0) {
|
|
254
|
+
if (state.noReadySince === null) state.noReadySince = at;
|
|
255
|
+
} else {
|
|
256
|
+
state.noReadySince = null;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const drained = stats.total > 0 && stats.pending === 0 && stats.claimed === 0;
|
|
260
|
+
// A restart must not wait the normal 10-minute drain interval: if the
|
|
261
|
+
// queue was already drained before this process started, the first
|
|
262
|
+
// checkpoint needs only firstDrainMs (60s). Later drain checkpoints use
|
|
263
|
+
// the normal drainMs gap.
|
|
264
|
+
if (drained) {
|
|
265
|
+
if (state.drainedSince === null) {
|
|
266
|
+
state.drainedSince = state.hasCheckpoint ? at : controllerStartedAt;
|
|
267
|
+
}
|
|
268
|
+
} else {
|
|
269
|
+
state.drainedSince = null;
|
|
270
|
+
}
|
|
271
|
+
const firstDrainReady = !state.hasCheckpoint
|
|
272
|
+
&& state.drainedSince !== null
|
|
273
|
+
&& at - state.drainedSince >= firstDrainMs;
|
|
274
|
+
const laterDrainReady = state.hasCheckpoint && at - state.lastCheckpointAt >= drainMs;
|
|
275
|
+
const allDone = stats.total > 0 && stats.done === stats.total;
|
|
276
|
+
const gateAdvanced = state.lastGatePhase !== undefined
|
|
277
|
+
&& (phaseRank(phase) > phaseRank(state.lastGatePhase)
|
|
278
|
+
|| (state.lastReleaseReady === false && releaseReady === true));
|
|
279
|
+
const reasons = [];
|
|
280
|
+
if (allDone) reasons.push('all-done');
|
|
281
|
+
else if (drained && (firstDrainReady || laterDrainReady)) reasons.push('queue-drained');
|
|
282
|
+
if (gateAdvanced) reasons.push('gate-advanced');
|
|
283
|
+
if (state.noReadySince !== null && at - state.noReadySince >= idleMs) reasons.push('no-ready');
|
|
284
|
+
|
|
285
|
+
const signature = signatureOf(stats, gate);
|
|
286
|
+
if (reasons.length > 0 && signature !== state.lastSignature) {
|
|
287
|
+
let events = [];
|
|
288
|
+
try {
|
|
289
|
+
events = await loadEvents(repo);
|
|
290
|
+
} catch (error) {
|
|
291
|
+
log('warn', 'checkpoint could not read events for ' + repo, error);
|
|
292
|
+
}
|
|
293
|
+
const body = renderCheckpoint({
|
|
294
|
+
repo,
|
|
295
|
+
stats,
|
|
296
|
+
gate,
|
|
297
|
+
recentEvents: summarizeCheckpointEvents(events, { since: at - eventWindowMs }),
|
|
298
|
+
trigger: reasons.join('+'),
|
|
299
|
+
at,
|
|
300
|
+
startup: !firstCheckpointCreated,
|
|
301
|
+
});
|
|
302
|
+
const entry = { repo, body, signature, at, trigger: reasons.join('+') };
|
|
303
|
+
const delivery = deliver(entry);
|
|
304
|
+
state.lastSignature = signature;
|
|
305
|
+
state.lastCheckpointAt = at;
|
|
306
|
+
state.hasCheckpoint = true;
|
|
307
|
+
firstCheckpointCreated = true;
|
|
308
|
+
if (delivery.delivered) {
|
|
309
|
+
log('info', 'checkpoint delivered to queen', repo, reasons.join('+'));
|
|
310
|
+
results.push({ repo, trigger: entry.trigger, delivered: true, via: delivery.via ?? null });
|
|
311
|
+
} else {
|
|
312
|
+
pending.push(entry);
|
|
313
|
+
log('info', 'checkpoint queued (no live queen)', repo, delivery.reason);
|
|
314
|
+
results.push({ repo, trigger: entry.trigger, delivered: false, reason: delivery.reason ?? 'not-delivered' });
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
state.lastGatePhase = phase;
|
|
318
|
+
state.lastReleaseReady = releaseReady;
|
|
319
|
+
}
|
|
320
|
+
return results;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
function flushPending() {
|
|
324
|
+
let delivered = 0;
|
|
325
|
+
for (const entry of [...pending]) {
|
|
326
|
+
const result = deliver(entry);
|
|
327
|
+
if (result.delivered) {
|
|
328
|
+
pending.splice(pending.indexOf(entry), 1);
|
|
329
|
+
delivered += 1;
|
|
330
|
+
log('info', 'pending checkpoint delivered', entry.repo);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
return { delivered, pending: pending.length };
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
let tickChain = Promise.resolve();
|
|
337
|
+
function enqueue(fn) {
|
|
338
|
+
const run = tickChain.then(fn, fn);
|
|
339
|
+
tickChain = run.then(() => undefined, () => undefined);
|
|
340
|
+
return run;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
/** Serialize ticks; a board cache may serve repeated patrol ticks. */
|
|
344
|
+
function tick(options = {}) {
|
|
345
|
+
return enqueue(() => runTick(options));
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Immediate event-triggered check (card settled, gate advanced). Marks the
|
|
350
|
+
* affected board cache stale and runs without waiting for the next patrol.
|
|
351
|
+
* @param {{ repo?: string, force?: boolean }} [options]
|
|
352
|
+
* @returns {Promise<object[]>}
|
|
353
|
+
*/
|
|
354
|
+
function requestTick(options = {}) {
|
|
355
|
+
const repo = typeof options.repo === 'string' && options.repo !== '' ? options.repo : null;
|
|
356
|
+
if (repo === null) {
|
|
357
|
+
for (const entry of boardCache.values()) entry.stale = true;
|
|
358
|
+
} else {
|
|
359
|
+
const entry = boardCache.get(repo);
|
|
360
|
+
if (entry !== undefined) entry.stale = true;
|
|
361
|
+
}
|
|
362
|
+
return tick();
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
tick,
|
|
367
|
+
requestTick,
|
|
368
|
+
flushPending,
|
|
369
|
+
pendingCount: () => pending.length,
|
|
370
|
+
pending: () => pending.map((entry) => ({ ...entry })),
|
|
371
|
+
size: () => states.size,
|
|
372
|
+
};
|
|
373
|
+
}
|
package/lib/config.js
CHANGED
|
@@ -24,14 +24,20 @@ export const DEFAULT_CARD_TIMEOUT_MS = 15 * 60_000;
|
|
|
24
24
|
export const DEFAULT_HEARTBEAT_WARN_MS = 5 * 60_000;
|
|
25
25
|
/** How often heartbeat/liveness is checked while a worker runs. */
|
|
26
26
|
export const DEFAULT_HEARTBEAT_INTERVAL_MS = 30_000;
|
|
27
|
-
/** Queen patrol period:
|
|
28
|
-
export const
|
|
27
|
+
/** Queen patrol period: near-real-time supervision (5s) by default. */
|
|
28
|
+
export const DEFAULT_PATROL_INTERVAL_MS = 5_000;
|
|
29
|
+
/** Backward-compatible alias for the old patrol period constant. */
|
|
30
|
+
export const DEFAULT_PATROL_MS = DEFAULT_PATROL_INTERVAL_MS;
|
|
29
31
|
/** How long anomaly events coalesce before one digest is delivered to the queen. */
|
|
30
32
|
export const DEFAULT_ANOMALY_DEBOUNCE_MS = 3_000;
|
|
31
33
|
/** Maximum number of undelivered anomaly entries kept for the queen's pending list. */
|
|
32
34
|
export const DEFAULT_ANOMALY_MAX = 50;
|
|
33
35
|
/** Grace before a done card without an arch_review event is flagged. */
|
|
34
36
|
export const DEFAULT_ARCH_REVIEW_GRACE_MS = 10 * 60_000;
|
|
37
|
+
/** Minimum gap between queue-drained progress checkpoints sent to the queen. */
|
|
38
|
+
export const DEFAULT_CHECKPOINT_DRAIN_MS = 10 * 60_000;
|
|
39
|
+
/** No-ready time before the idle progress checkpoint fires. */
|
|
40
|
+
export const DEFAULT_CHECKPOINT_IDLE_MS = 10 * 60_000;
|
|
35
41
|
/** Default role -> concurrent live-worker cap, per repository. */
|
|
36
42
|
export const DEFAULT_ROLE_CONCURRENCY = Object.freeze({ coder: 5, tester: 5 });
|
|
37
43
|
/** Fallback cap for roles not listed in `roleConcurrency` (also finite). */
|
|
@@ -66,16 +72,22 @@ const DEFAULTS = Object.freeze({
|
|
|
66
72
|
cardTimeoutMs: DEFAULT_CARD_TIMEOUT_MS,
|
|
67
73
|
heartbeatWarnMs: DEFAULT_HEARTBEAT_WARN_MS,
|
|
68
74
|
heartbeatIntervalMs: DEFAULT_HEARTBEAT_INTERVAL_MS,
|
|
69
|
-
// Queen coordination: the supervisor patrols every
|
|
70
|
-
// digest to the registered queen Session only when something
|
|
71
|
-
// Until a live queen Session exists the entries stay in the
|
|
72
|
-
patrolMs
|
|
75
|
+
// Queen coordination: the supervisor patrols every patrolIntervalMs and
|
|
76
|
+
// delivers ONE digest to the registered queen Session only when something
|
|
77
|
+
// needs attention. Until a live queen Session exists the entries stay in the
|
|
78
|
+
// pending list. `patrolMs` remains accepted as a legacy alias.
|
|
79
|
+
patrolIntervalMs: DEFAULT_PATROL_INTERVAL_MS,
|
|
73
80
|
notifyQueen: true,
|
|
74
81
|
anomalyDebounceMs: DEFAULT_ANOMALY_DEBOUNCE_MS,
|
|
75
82
|
anomalyMax: DEFAULT_ANOMALY_MAX,
|
|
76
83
|
// A done card must carry an arch_review event; flag it after this grace (the
|
|
77
84
|
// queen reviews finished cards at the next patrol).
|
|
78
85
|
archReviewGraceMs: DEFAULT_ARCH_REVIEW_GRACE_MS,
|
|
86
|
+
// Progress checkpoints (not anomalies): the queen is asked to evaluate the
|
|
87
|
+
// goal when the queue drains, all cards are done, a gate advances, or no
|
|
88
|
+
// ready work exists while goals remain.
|
|
89
|
+
checkpointDrainMs: DEFAULT_CHECKPOINT_DRAIN_MS,
|
|
90
|
+
checkpointIdleMs: DEFAULT_CHECKPOINT_IDLE_MS,
|
|
79
91
|
provider: 'spawn',
|
|
80
92
|
parentSession: null,
|
|
81
93
|
cwd: null,
|
|
@@ -282,6 +294,8 @@ export function resolveConfig(config = {}) {
|
|
|
282
294
|
fail('defaultRoleConcurrency must be an integer in 0..999 (0 pauses unlisted roles)');
|
|
283
295
|
}
|
|
284
296
|
cfg.capacityRetryMs = positiveNumber(cfg.capacityRetryMs, 'capacityRetryMs');
|
|
297
|
+
cfg.checkpointDrainMs = positiveNumber(cfg.checkpointDrainMs, 'checkpointDrainMs');
|
|
298
|
+
cfg.checkpointIdleMs = positiveNumber(cfg.checkpointIdleMs, 'checkpointIdleMs');
|
|
285
299
|
cfg.cardTimeoutMs = positiveNumber(cfg.cardTimeoutMs, 'cardTimeoutMs');
|
|
286
300
|
cfg.heartbeatWarnMs = positiveNumber(cfg.heartbeatWarnMs, 'heartbeatWarnMs');
|
|
287
301
|
cfg.heartbeatIntervalMs = positiveNumber(cfg.heartbeatIntervalMs, 'heartbeatIntervalMs');
|
|
@@ -296,7 +310,10 @@ export function resolveConfig(config = {}) {
|
|
|
296
310
|
if (cfg.parentSession !== null && cfg.parentSession !== undefined) cfg.parentSession = nonEmptyString(cfg.parentSession, 'parentSession');
|
|
297
311
|
else cfg.parentSession = null;
|
|
298
312
|
cfg.cwd = cfg.cwd === null || cfg.cwd === undefined ? process.cwd() : absolutePath(cfg.cwd, 'cwd');
|
|
299
|
-
|
|
313
|
+
// Accept the pre-1.0.14 `patrolMs` name as an alias for patrolIntervalMs.
|
|
314
|
+
if (config.patrolIntervalMs === undefined && config.patrolMs !== undefined) cfg.patrolIntervalMs = config.patrolMs;
|
|
315
|
+
cfg.patrolIntervalMs = positiveNumber(cfg.patrolIntervalMs, 'patrolIntervalMs');
|
|
316
|
+
cfg.patrolMs = cfg.patrolIntervalMs;
|
|
300
317
|
cfg.notifyQueen = boolean(cfg.notifyQueen, 'notifyQueen');
|
|
301
318
|
cfg.anomalyDebounceMs = positiveNumber(cfg.anomalyDebounceMs, 'anomalyDebounceMs');
|
|
302
319
|
cfg.anomalyMax = positiveInteger(cfg.anomalyMax, 'anomalyMax', 1000);
|
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/round.js
CHANGED
|
@@ -178,6 +178,7 @@ export function createRoundRunner({
|
|
|
178
178
|
writeRun = writeRunRecord,
|
|
179
179
|
parentProvider,
|
|
180
180
|
onAnomaly,
|
|
181
|
+
onSettled,
|
|
181
182
|
now = () => Date.now(),
|
|
182
183
|
log = () => {},
|
|
183
184
|
}) {
|
|
@@ -494,6 +495,13 @@ export function createRoundRunner({
|
|
|
494
495
|
emitAnomaly({ kind: 'card-failed', repo, cardId: id, role: card.role, detail });
|
|
495
496
|
}
|
|
496
497
|
unregisterActive(repo, id);
|
|
498
|
+
try {
|
|
499
|
+
if (typeof onSettled === 'function') {
|
|
500
|
+
onSettled({ repo, cardId: id, role: card.role, status, sha: patch.commit ?? null, reason: patch.reason ?? null });
|
|
501
|
+
}
|
|
502
|
+
} catch (error) {
|
|
503
|
+
log('warn', 'onSettled hook failed', error);
|
|
504
|
+
}
|
|
497
505
|
};
|
|
498
506
|
let activation;
|
|
499
507
|
let releaseEnv = () => {};
|
package/lib/supervisor.js
CHANGED
|
@@ -138,8 +138,10 @@ export class HiveSupervisor {
|
|
|
138
138
|
* @param {(repo: string) => Promise<string|{mode: string}>} [options.readMode] Hive mode reader (free/freeze)
|
|
139
139
|
* @param {() => Promise<string[]>} [options.discover]
|
|
140
140
|
* @param {(event: object) => void} [options.onAnomaly] supervision event sink (queen digest)
|
|
141
|
+
* @param {(event: object) => void} [options.onGateChange] gate phase/release-readiness change sink
|
|
141
142
|
* @param {(sessionId: string) => void} [options.onQueenSession] called after a queen Session registers
|
|
142
143
|
* @param {() => number} [options.pendingAnomalies] undelivered queen anomalies reported in status
|
|
144
|
+
* @param {() => number} [options.pendingCheckpoints] undelivered progress checkpoints reported in status
|
|
143
145
|
* @param {Console} [options.logger]
|
|
144
146
|
* @param {boolean} [options.debug]
|
|
145
147
|
*/
|
|
@@ -176,8 +178,10 @@ export class HiveSupervisor {
|
|
|
176
178
|
this.queenBoundary = options.queenBoundary ?? { count: 0, last: null };
|
|
177
179
|
this.readMode = typeof options.readMode === 'function' ? options.readMode : undefined;
|
|
178
180
|
this.onAnomaly = typeof options.onAnomaly === 'function' ? options.onAnomaly : undefined;
|
|
181
|
+
this.onGateChange = typeof options.onGateChange === 'function' ? options.onGateChange : undefined;
|
|
179
182
|
this.onQueenSession = typeof options.onQueenSession === 'function' ? options.onQueenSession : undefined;
|
|
180
183
|
this.pendingAnomalies = typeof options.pendingAnomalies === 'function' ? options.pendingAnomalies : undefined;
|
|
184
|
+
this.pendingCheckpoints = typeof options.pendingCheckpoints === 'function' ? options.pendingCheckpoints : undefined;
|
|
181
185
|
this.discover = options.discover;
|
|
182
186
|
this.logger = options.logger === undefined ? console : options.logger;
|
|
183
187
|
this.debug = options.debug === true;
|
|
@@ -431,6 +435,7 @@ export class HiveSupervisor {
|
|
|
431
435
|
*/
|
|
432
436
|
async #gateFor(repo, signal) {
|
|
433
437
|
const entry = this.#entry(repo);
|
|
438
|
+
const previous = entry.gate ?? null;
|
|
434
439
|
if (this.listAll === undefined) {
|
|
435
440
|
entry.gate = { phase: 'ungated', releaseReady: false, reason: 'gate ordering is not configured' };
|
|
436
441
|
return entry.gate;
|
|
@@ -439,6 +444,7 @@ export class HiveSupervisor {
|
|
|
439
444
|
const tasks = await this.listAll(repo, { signal });
|
|
440
445
|
const gate = gatePhase(tasks);
|
|
441
446
|
entry.gate = gate;
|
|
447
|
+
this.#emitGateChange(repo, previous, gate);
|
|
442
448
|
return gate;
|
|
443
449
|
} catch (error) {
|
|
444
450
|
entry.gate = {
|
|
@@ -451,6 +457,18 @@ export class HiveSupervisor {
|
|
|
451
457
|
}
|
|
452
458
|
}
|
|
453
459
|
|
|
460
|
+
/** Report a gate phase / release-readiness change for the immediate checkpoint path. */
|
|
461
|
+
#emitGateChange(repo, previous, gate) {
|
|
462
|
+
if (typeof this.onGateChange !== 'function' || previous === null) return;
|
|
463
|
+
const phaseChanged = previous.phase !== gate.phase;
|
|
464
|
+
const releaseChanged = previous.releaseReady !== gate.releaseReady;
|
|
465
|
+
if (!phaseChanged && !releaseChanged) return;
|
|
466
|
+
try {
|
|
467
|
+
this.onGateChange({ repo, previous, gate });
|
|
468
|
+
} catch (error) {
|
|
469
|
+
this.#log('warn', 'gate-change sink failed', messageOf(error));
|
|
470
|
+
}
|
|
471
|
+
}
|
|
454
472
|
/**
|
|
455
473
|
* Filter a ready list through the current gate phase. Manual rounds use this
|
|
456
474
|
* so the queen's on-demand run obeys the same gate order as the resident one.
|
|
@@ -547,8 +565,10 @@ export class HiveSupervisor {
|
|
|
547
565
|
capacityRetryMs: this.capacityRetryMs,
|
|
548
566
|
lastTickAt: iso(this.lastTickAt),
|
|
549
567
|
lastDiscoverError: this.lastDiscoverError,
|
|
550
|
-
// Undelivered anomaly digests waiting for a live
|
|
568
|
+
// Undelivered anomaly digests / progress checkpoints waiting for a live
|
|
569
|
+
// queen Session.
|
|
551
570
|
pendingAnomalies: this.#pendingAnomalyCount(),
|
|
571
|
+
pendingCheckpoints: this.#pendingCheckpointCount(),
|
|
552
572
|
repoCount: this.repos.size,
|
|
553
573
|
// Worker Session ids across all repositories: the panel exempts them from
|
|
554
574
|
// queen-mode prompt injection and the guard exempts their tool calls.
|
|
@@ -852,6 +872,16 @@ export class HiveSupervisor {
|
|
|
852
872
|
}
|
|
853
873
|
}
|
|
854
874
|
|
|
875
|
+
/** Undelivered progress checkpoint count; observability never throws. */
|
|
876
|
+
#pendingCheckpointCount() {
|
|
877
|
+
try {
|
|
878
|
+
const value = typeof this.pendingCheckpoints === 'function' ? this.pendingCheckpoints() : 0;
|
|
879
|
+
return Number.isInteger(value) && value >= 0 ? value : 0;
|
|
880
|
+
} catch {
|
|
881
|
+
return 0;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
855
885
|
/** Best-effort live worker list for status; observability never throws. */
|
|
856
886
|
#workers(repo) {
|
|
857
887
|
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.14",
|
|
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",
|