dsh-hive-runner 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/README.md +49 -2
- package/README.zh-CN.md +41 -2
- package/SPEC.md +38 -3
- package/docs/DESIGN.md +1 -1
- package/index.js +113 -27
- package/lib/commands.js +123 -1
- package/lib/gates.js +4 -2
- package/lib/round.js +58 -3
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,35 @@ 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
|
+
## [0.8.0] - 2026-12-04
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **Task-tree lifecycle tools.** `hive_tasks` gains `edit` (partial update of
|
|
15
|
+
title/role/priority/acceptance/scope/after/tags/superseded on a pending or failed task;
|
|
16
|
+
goal and draft are not editable), `split` (at least two fine-grained tasks atomically
|
|
17
|
+
replace one, original superseded without a state change, replacedBy = first child) and
|
|
18
|
+
`supersede` (reason required; mark without changing the four-state state, allowed on a
|
|
19
|
+
claimed/running task). Backed by hive-tasks 1.9 `edit`/`split`/`supersede`; events
|
|
20
|
+
`task_edit`, `task_split` and `task_supersede` are written by hive-tasks.
|
|
21
|
+
- **Abort a live worker.** `runner.abortCard()` + `hive_intervene action=abort` stop one
|
|
22
|
+
card worker on request; that card is recorded `failed` with the queen's reason instead of
|
|
23
|
+
turning the round into an error. `pause` remains the repository-level throttle and
|
|
24
|
+
`supersede` the "let it finish but never dispatch again" path.
|
|
25
|
+
- **Goal evolution and autonomy** documented in README (en/zh) and SPEC §8.9: classify every
|
|
26
|
+
human message as a goal change before acting, state the interpretation, adjust the tree
|
|
27
|
+
live, evaluate the impact on running/claimed/done cards, record events and report
|
|
28
|
+
what/why/affected. Inside a confirmed goal the queen decides autonomously (splitting,
|
|
29
|
+
editing, ordering, pausing, retrying, arch reject, superseding); only a changed/ambiguous
|
|
30
|
+
goal, conflicting requirements, irreversible/high-cost actions, or three failed
|
|
31
|
+
interventions on one task go to the human.
|
|
32
|
+
- Superseded cards are excluded from gate phases exactly like drafts.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- `hive_intervene split` now uses the native atomic split (the original is superseded, not
|
|
37
|
+
reopened); `reassign`/`rebuild` keep their create-and-reopen/remove semantics.
|
|
38
|
+
|
|
10
39
|
## [Unreleased]
|
|
11
40
|
|
|
12
41
|
### Documentation
|
|
@@ -70,6 +99,10 @@ without editing code or claiming cards.
|
|
|
70
99
|
- Existing configurations keep working: every new key is defaulted, and
|
|
71
100
|
`notifyQueen: false` leaves delivery in the pending list.
|
|
72
101
|
|
|
102
|
+
### Published
|
|
103
|
+
|
|
104
|
+
- npm: `dsh-hive-runner@0.7.0` on 2026-12-04.
|
|
105
|
+
|
|
73
106
|
## [0.6.7] - 2026-12-04
|
|
74
107
|
|
|
75
108
|
### Fixed
|
package/README.md
CHANGED
|
@@ -89,7 +89,7 @@ she must act on. The authoritative contract is `<repo>/.hive/roles/queen.md` (wr
|
|
|
89
89
|
| Tool | What the queen uses it for |
|
|
90
90
|
| --- | --- |
|
|
91
91
|
| `hive_board`, `hive_tasks_ready` | who is doing what, what is ready now |
|
|
92
|
-
| `hive_tasks` | `list`/`show` (task + last-run record: output tail, heartbeat, overlaps) and `add`/`reopen`/`retry`/`rm` for ordering, splitting and remediation |
|
|
92
|
+
| `hive_tasks` | `list`/`show` (task + last-run record: output tail, heartbeat, overlaps) and `add`/`edit`/`split`/`supersede`/`reopen`/`retry`/`rm` for goal evolution, ordering, splitting and remediation |
|
|
93
93
|
| `hive_arch_review` | record the architecture review of an accepted (done) task: appends a durable `arch_review` event `{ kind, task, verdict, findings }` to `.hive/events.jsonl` |
|
|
94
94
|
| `hive_events` | read the event tail (for example every `arch_review` still missing) |
|
|
95
95
|
| `hive_lesson_add`, `hive_recall` | knowledge management: read before planning, write after an episode |
|
|
@@ -200,6 +200,53 @@ reason, so the panel's task drawer shows it and the next agent prompt opens with
|
|
|
200
200
|
events tail (`hive_events` / the panel's event list) shows every intervention and, for a
|
|
201
201
|
deletion, the removed task's summary.
|
|
202
202
|
|
|
203
|
+
### Goal evolution and task lifecycle
|
|
204
|
+
|
|
205
|
+
The human's messages are the primary input. Every turn, classify the message before acting:
|
|
206
|
+
is this a goal change — **add / modify / delete / narrow / widen**? Say the interpretation out
|
|
207
|
+
loud ("this narrows the goal to X") and only then act. The queen does not change the goal
|
|
208
|
+
silently, and a change to the goal itself goes to the human — but inside the confirmed goal
|
|
209
|
+
frame she decides autonomously and reports afterwards.
|
|
210
|
+
|
|
211
|
+
**Autonomy.** The queen decides on her own: splitting, editing task details, splitting/removing
|
|
212
|
+
cards, ordering, pausing/resuming, retrying, arch-review reject, superseding. She reports
|
|
213
|
+
"what changed and why" after the fact instead of asking for permission in advance. Only four
|
|
214
|
+
things go to the human: (1) the goal itself changed, or is too ambiguous to judge the scope;
|
|
215
|
+
(2) two requirements conflict with no self-consistent trade-off; (3) an irreversible or
|
|
216
|
+
high-cost action (release, repo-level data deletion, external publication); (4) the same task
|
|
217
|
+
was handled three times without progress.
|
|
218
|
+
|
|
219
|
+
The task tree is a living structure, not a one-shot plan:
|
|
220
|
+
|
|
221
|
+
- **edit** — `hive_tasks action=edit` partially updates a pending/failed task: title,
|
|
222
|
+
role, priority, acceptance, scope (replace: the runner translates it to scope add/remove),
|
|
223
|
+
dependencies (replace), tags and the superseded flag. Goal and draft cannot be edited; the
|
|
224
|
+
CLI refuses claimed/done tasks (reopen first).
|
|
225
|
+
- **split** — `hive_tasks action=split` atomically replaces one task with **at least two**
|
|
226
|
+
fine-grained tasks (each with its own acceptance or the parent's) and marks the original
|
|
227
|
+
superseded in the same transaction (`replacedBy` = first child), without changing its
|
|
228
|
+
state. Each child may override role/scope/acceptance/after; priority and tags are inherited.
|
|
229
|
+
- **supersede** — `hive_tasks action=supersede` marks a task as superseded **without changing
|
|
230
|
+
its state** (a reason is required), so a claimed/running task can be marked and allowed to
|
|
231
|
+
finish; it is never dispatched again and never gates the pipeline.
|
|
232
|
+
- **rm** — `hive_tasks action=rm` deletes a card whose content has no value; the queen records
|
|
233
|
+
an intervention event with the card summary first, so the deletion is visible in the history.
|
|
234
|
+
|
|
235
|
+
Decomposition is continuous: plan only what can be determined now, and add/edit/split cards as
|
|
236
|
+
later messages and discoveries arrive. Every change also evaluates its impact:
|
|
237
|
+
|
|
238
|
+
| Situation | Queen action |
|
|
239
|
+
| --- | --- |
|
|
240
|
+
| an affected card is running | `hive_intervene action=pause` (stop new dispatch for the repo) or `action=abort` (stop that worker now; the card is recorded failed with the reason), or let it finish and `action=supersede` it |
|
|
241
|
+
| an affected card is claimed but waiting | `hive_tasks action=edit` (priority/after) or `supersede`, then reopen/rebuild as needed |
|
|
242
|
+
| a done card was overturned | reopen it (with guidance) or add a fine-grained correction card linked with `after` |
|
|
243
|
+
| a dependency disappeared | edit the dependents' `after` list, or split them again |
|
|
244
|
+
|
|
245
|
+
Events make the history auditable: hive-tasks writes `task_edit`, `task_split` and
|
|
246
|
+
`task_supersede` to `.hive/events.jsonl`; the runner writes `queen_intervention
|
|
247
|
+
{ card, action, reason }` for the queen's decisions. Every report states **what changed, why,
|
|
248
|
+
and which cards were affected**.
|
|
249
|
+
|
|
203
250
|
### Architecture review is audited
|
|
204
251
|
|
|
205
252
|
A `done` task must carry an `arch_review` event. Every patrol checks the board; a done
|
|
@@ -271,7 +318,7 @@ DSH 0.2.2-rc.5):
|
|
|
271
318
|
<summary>Manual profile edit (same result, only needed when the CLI is unavailable)</summary>
|
|
272
319
|
|
|
273
320
|
While DSH Desktop is not running, add `"dsh-hive-panel": ">=0.2.3"` and
|
|
274
|
-
`"dsh-hive-runner": "^0.
|
|
321
|
+
`"dsh-hive-runner": "^0.8.0"` to the profile's `dependencies`, add both names to
|
|
275
322
|
`dsh.profile.bundles`, then `cd ~/.dsh/profiles/desktop && pnpm install`.
|
|
276
323
|
|
|
277
324
|
</details>
|
package/README.zh-CN.md
CHANGED
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
| 工具 | 女王用它做什么 |
|
|
56
56
|
| --- | --- |
|
|
57
57
|
| `hive_board`、`hive_tasks_ready` | 看谁在做什么、现在哪些任务可跑 |
|
|
58
|
-
| `hive_tasks` | `list`/`show`(任务 + 最近一次 run 记录:输出尾部、心跳、overlap)与 `add`/`reopen`/`retry`/`rm
|
|
58
|
+
| `hive_tasks` | `list`/`show`(任务 + 最近一次 run 记录:输出尾部、心跳、overlap)与 `add`/`edit`/`split`/`supersede`/`reopen`/`retry`/`rm`,用于目标演进、排序、拆分、处置失败 |
|
|
59
59
|
| `hive_arch_review` | 对已验收(done)的任务做架构复审并落一条 `arch_review` 事件 `{ kind, task, verdict, findings }` 到 `.hive/events.jsonl` |
|
|
60
60
|
| `hive_events` | 读事件尾部(例如哪些已完成的任务还没复审) |
|
|
61
61
|
| `hive_lesson_add`、`hive_recall` | 知识管理:规划前读经验,一轮结束后写经验 |
|
|
@@ -143,6 +143,45 @@ outstanding/failed 与 `releaseReady`、`reason`)。`releaseReady` 为 true
|
|
|
143
143
|
下一次智能体 prompt 也会以它开头;事件尾部(`hive_events` / 面板事件列表)能看到每次处置
|
|
144
144
|
记录,删除类事件还带被删任务摘要。
|
|
145
145
|
|
|
146
|
+
### 目标演进与任务生命周期
|
|
147
|
+
|
|
148
|
+
人类的每次发言是主要输入。每次先判断:这是不是对目标的变更——**新增 / 修改 / 删除 / 收窄 /
|
|
149
|
+
放宽**?先把理解明确说出来("这把目标收窄为 X")再动手。女王不会悄悄改目标;**目标本身变了**
|
|
150
|
+
属于要交给人类的四类情况之一,但在已确认的目标框架内,她自主决定并事后汇报。
|
|
151
|
+
|
|
152
|
+
**自主性。** 拆卡、改任务细节、拆分、删除卡片、调顺序、暂停/恢复、重试、架构复审 reject、
|
|
153
|
+
标记 superseded——这些都由女王自己决定,做完汇报「改了什么、为什么」,不需要事前征求同意。
|
|
154
|
+
只有四类情况找人类:(1) 目标本身变了,或含糊到无法判断范围;(2) 两个要求互相冲突且无法
|
|
155
|
+
自洽取舍;(3) 不可逆或高代价动作(发版、删仓库级数据、对外发布);(4) 同一任务处置 3 次
|
|
156
|
+
仍无进展。
|
|
157
|
+
|
|
158
|
+
任务树是活的,不是一次性计划:
|
|
159
|
+
|
|
160
|
+
- **edit** —— `hive_tasks action=edit` 局部修改 pending/failed 任务:标题、角色、优先级、
|
|
161
|
+
验收命令、scope(替换语义:runner 会翻译成 scope add/remove)、依赖(替换)、tags 与
|
|
162
|
+
superseded 标记。goal 与 draft 不能编辑;claimed/done 任务先 reopen,CLI 会拒绝。
|
|
163
|
+
- **split** —— `hive_tasks action=split` 在一个事务里用**至少两张**细粒度任务替换原任务
|
|
164
|
+
(每张可带自己的验收,否则继承父任务),原任务标记 superseded(`replacedBy` = 第一张子任务),
|
|
165
|
+
状态不变。子任务可覆盖 role/scope/acceptance/after,priority 与 tags 继承父任务。
|
|
166
|
+
- **supersede** —— `hive_tasks action=supersede` 只加 superseded 标记,**不改四态**(必须给
|
|
167
|
+
reason):正在 claimed/running 的任务也可以标记并让它跑完,此后不再派发、也不参与门禁进度。
|
|
168
|
+
- **rm** —— `hive_tasks action=rm` 删除已无价值的卡;女王会先写带卡片摘要的处置事件,删除
|
|
169
|
+
不会无声消失。
|
|
170
|
+
|
|
171
|
+
拆解是持续过程:每轮只产出「现在能确定的」任务,后续消息与新发现再用 add/edit/split 调整。
|
|
172
|
+
每次变更都要评估影响面:
|
|
173
|
+
|
|
174
|
+
| 情况 | 女王动作 |
|
|
175
|
+
| --- | --- |
|
|
176
|
+
| 受影响卡在运行 | `hive_intervene action=pause`(停该仓库新派发)或 `action=abort`(立刻停掉该 worker,卡按 reason 记 failed),或让它跑完再 `action=supersede` |
|
|
177
|
+
| 受影响卡仅被 claim 等待 | `hive_tasks action=edit`(优先级/依赖)或 `supersede`,必要时再 reopen/rebuild |
|
|
178
|
+
| 已完成的卡被推翻 | reopen(带指导)或新开细粒度修正卡,用 `after` 关联 |
|
|
179
|
+
| 依赖消失 | 改受影响卡的 `after`,或重新拆卡 |
|
|
180
|
+
|
|
181
|
+
事件保证可追溯:hive-tasks 写 `task_edit` / `task_split` / `task_supersede` 到
|
|
182
|
+
`.hive/events.jsonl`;runner 为女王的决策写 `queen_intervention { card, action, reason }`。
|
|
183
|
+
每次汇报都要说明**改了什么、为什么、影响了哪些卡**。
|
|
184
|
+
|
|
146
185
|
### 架构复审会被审计
|
|
147
186
|
|
|
148
187
|
每个 `done` 任务必须有一条 `arch_review` 事件。每次巡检都会核对看板:done 超过
|
|
@@ -197,7 +236,7 @@ outstanding/failed 与 `releaseReady`、`reason`)。`releaseReady` 为 true
|
|
|
197
236
|
<details>
|
|
198
237
|
<summary>手工改 profile(效果相同,仅在 CLI 不可用时使用)</summary>
|
|
199
238
|
|
|
200
|
-
在 DSH Desktop 退出时,把 `"dsh-hive-panel": ">=0.2.3"` 与 `"dsh-hive-runner": "^0.
|
|
239
|
+
在 DSH Desktop 退出时,把 `"dsh-hive-panel": ">=0.2.3"` 与 `"dsh-hive-runner": "^0.8.0"`
|
|
201
240
|
加进 profile 的 `dependencies`、把两个包名加进 `dsh.profile.bundles`,然后
|
|
202
241
|
`cd ~/.dsh/profiles/desktop && pnpm install`。
|
|
203
242
|
|
package/SPEC.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# dsh-hive-runner — protocol specification
|
|
2
2
|
|
|
3
|
-
Status: 0.
|
|
3
|
+
Status: 0.8.0, verified against DSH 0.2.2-rc.5.
|
|
4
4
|
|
|
5
5
|
This document is normative for the host contract of the plugin. It is written for
|
|
6
6
|
maintainers: user documentation is [README.md](README.md) and
|
|
@@ -207,7 +207,7 @@ repository unless it is that default.
|
|
|
207
207
|
| `hive_tasks_ready` | `repo`, `role`, `limit` | Ready tasks, best first |
|
|
208
208
|
| `hive_board` | `repo` | Presence board |
|
|
209
209
|
| `hive_supervisor_status` | - | Same data as `GET ?op=status` (including `pendingAnomalies`) |
|
|
210
|
-
| `hive_tasks` | `action` = `list`/`show`/`add`/`reopen`/`retry`/`rm` + task fields | Tasks with a `lastRun` summary (output tail, heartbeat, overlaps); add/reopen/retry
|
|
210
|
+
| `hive_tasks` | `action` = `list`/`show`/`add`/`edit`/`split`/`supersede`/`reopen`/`retry`/`rm` + task fields | Tasks with a `lastRun` summary (output tail, heartbeat, overlaps); add/edit/split/supersede/reopen/retry return the changed task(s) |
|
|
211
211
|
| `hive_arch_review` | `repo`, `card`, `verdict: pass\|reject`, `findings[]`, `summary` | Appends an `arch_review` event; the task must be `done`; a `reject` needs at least one actionable finding |
|
|
212
212
|
| `hive_events` | `repo`, `kind`, `task`, `limit` | Event-log tail, newest first |
|
|
213
213
|
| `hive_lesson_add` | `repo`, `text`, `scope`, `evidence`, `status` | `hive lesson add` output |
|
|
@@ -215,7 +215,7 @@ repository unless it is that default.
|
|
|
215
215
|
| `hive_roles` | `action` = `list`/`add`/`rm` + `name`, `adapter`, `model`, `prompt`, `description`, `force` | `hive roles` output |
|
|
216
216
|
| `hive_supervisor_control` | `action` = `status`/`pause`/`resume`/`limits`, `repo`, `reason`, `roleLimits` | Supervisor/repository snapshot |
|
|
217
217
|
| `hive_anomalies` | `action` = `list`/`ack`/`patrol`, `ids`, `all`, `limit` | Pending digest queue or one patrol result |
|
|
218
|
-
| `hive_intervene` | `repo`, `action: reopen|split|reassign|pause|fail|guide|remove|rebuild|escalate`, `card`, `reason`, `cards[]`, `role`, `sessionId` | The intervention event, created tasks, intervention count and escalation flag |
|
|
218
|
+
| `hive_intervene` | `repo`, `action: reopen|split|reassign|pause|abort|fail|guide|supersede|remove|rebuild|escalate`, `card`, `reason`, `cards[]`, `role`, `sessionId` | The intervention event, created tasks, intervention count and escalation flag |
|
|
219
219
|
|
|
220
220
|
The queen's tools never claim or finish a task: `hive-tasks claim`/`done` stay with the
|
|
221
221
|
supervisor. `hive tasks rm` is forwarded without `--force`, so a claimed task is refused
|
|
@@ -379,6 +379,41 @@ The patrol also audits done tasks for a missing `arch_review` event: past
|
|
|
379
379
|
`archReviewGraceMs` (default 10 minutes) the task becomes an `arch-review-missing`
|
|
380
380
|
anomaly (warning + pending digest entry).
|
|
381
381
|
|
|
382
|
+
## 8.9 Goal evolution and task lifecycle
|
|
383
|
+
|
|
384
|
+
The queen treats the human conversation as the primary input and the task tree as a living
|
|
385
|
+
structure. Autonomy: inside a confirmed goal she decides and acts on her own — splitting,
|
|
386
|
+
editing task details, splitting/removing cards, ordering, pausing/resuming, retrying, arch
|
|
387
|
+
reject, superseding — and reports what changed and why afterwards. Only four cases go to the
|
|
388
|
+
human: the goal itself changed or is too ambiguous to judge scope; conflicting requirements
|
|
389
|
+
with no self-consistent trade-off; irreversible/high-cost actions (release, repo-level data
|
|
390
|
+
deletion, external publication); the same task handled three times without progress.
|
|
391
|
+
|
|
392
|
+
Mechanical support (hive-tasks 1.9+):
|
|
393
|
+
|
|
394
|
+
- `hive-tasks edit <id>` partial update of title/role/priority/acceptance/scope/after/tags/
|
|
395
|
+
superseded on a pending/failed task (claimed/done -> reopen first). The CLI exposes scope as
|
|
396
|
+
incremental `--scope-add`/`--scope-remove` and dependencies as `--after-set ID,ID`; the
|
|
397
|
+
runner tool accepts replace-style `scope`/`after` lists and translates them. Goal and draft
|
|
398
|
+
cannot be edited; acceptance cannot become empty. Appends `task_edit` with an object of
|
|
399
|
+
changed fields.
|
|
400
|
+
- `hive-tasks split <id> --into '<json array>' [--reason R] [--json]` transactional: at least
|
|
401
|
+
two entries `{ title, role?, scope?, acceptance?, after? }` (acceptance falls back to the
|
|
402
|
+
parent's; priority/tags/role/scope inherit), validates everything, creates them and marks the
|
|
403
|
+
original superseded without changing its state (`replacedBy` = first child). Appends
|
|
404
|
+
`task_split { task, cards, kept, replacedBy? }`.
|
|
405
|
+
- `hive-tasks supersede <id> --reason R [--replaced-by ID]` sets `superseded: true` +
|
|
406
|
+
`supersededReason` without changing the four-state state; allowed on claimed/running tasks
|
|
407
|
+
(finish it, never dispatch again). Appends `task_supersede`. Draft and superseded are
|
|
408
|
+
independent flags; neither is a state, neither is ever ready/claimable, and neither gates the
|
|
409
|
+
pipeline.
|
|
410
|
+
- The runner's `hive_tasks` tool forwards edit/split/supersede; `hive_intervene` adds
|
|
411
|
+
`abort` (stop one live worker now; the card is recorded failed with the reason),
|
|
412
|
+
`supersede` and keeps `pause` for repository-level throttling. Impact analysis is the
|
|
413
|
+
queen's rule: running -> pause/abort/supersede; claimed-waiting -> edit/supersede;
|
|
414
|
+
done-but-overturned -> reopen or a correction card linked with `after`; vanished
|
|
415
|
+
dependency -> edit the dependents' `after`.
|
|
416
|
+
|
|
382
417
|
## 9. Security invariants
|
|
383
418
|
|
|
384
419
|
- Commands are built from fixed templates; ids, roles, agents, TTLs and shas are
|
package/docs/DESIGN.md
CHANGED
|
@@ -222,7 +222,7 @@ consuming the failure budget.
|
|
|
222
222
|
| `lib/events.js` | `.hive/events.jsonl` append/read plus the `arch_review`, `queen_intervention` and `queen_escalation` event contracts |
|
|
223
223
|
| `lib/limits.js` | `<repo>/.hive/limits.json` read/write/hot-reload and precedence helpers |
|
|
224
224
|
| `lib/config.js` | Config defaults/validation (`patrolMs`, `notifyQueen`, `anomaly*`, `rolesBin`), role map parsing, effective-limit helpers |
|
|
225
|
-
| `lib/commands.js` | Allowlisted `hive-tasks` / `hive` / `git` / acceptance commands with shell quoting; queen verbs list/add/reopen/retry/rm/lesson/roles |
|
|
225
|
+
| `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 |
|
|
226
226
|
| `lib/shell.js` | `ctx.shell.resolve/execute` adapter (sandbox policy per call) |
|
|
227
227
|
| `lib/discover.js` | `refs/hive/v1` repository discovery |
|
|
228
228
|
| `lib/http.js` | `/api/hive-runner` Fetch route (status/pending/ack/pause/resume/limits/queen) |
|
package/index.js
CHANGED
|
@@ -346,32 +346,45 @@ export function apply(ctx, config = {}) {
|
|
|
346
346
|
registerTextTool({
|
|
347
347
|
name: 'hive_tasks',
|
|
348
348
|
description:
|
|
349
|
-
'Manage Hive task
|
|
350
|
-
+ 'list/show return the
|
|
351
|
-
+ 'add creates a
|
|
352
|
-
+ '
|
|
353
|
-
+ '
|
|
354
|
-
+ '
|
|
349
|
+
'Manage the Hive task tree without claiming tasks. action=list|show|add|edit|split|supersede|reopen|retry|rm. '
|
|
350
|
+
+ 'list/show return the task plus its last-run record (status, heartbeat, output tail, overlaps) for triage; '
|
|
351
|
+
+ 'add creates a task (title required; acceptance required unless draft=true; scope, after, priority, tags, reviewOf optional); '
|
|
352
|
+
+ 'edit partially updates a pending/failed task — title, role, priority, acceptance, scope, after, tags and the superseded flag (goal and draft cannot be edited; hive-tasks 1.9 requires pending/failed) — the queen adjusts the tree as the goal evolves; '
|
|
353
|
+
+ 'split atomically replaces a pending/failed task with at least two fine-grained tasks and marks the original superseded (replacedBy = first child); '
|
|
354
|
+
+ 'supersede marks a task (including a claimed/running one) as superseded without changing its state and requires a reason; '
|
|
355
|
+
+ 'reopen resets any task to pending with an attempt+1 and an optional reason; retry moves a failed task back to pending; '
|
|
356
|
+
+ 'rm deletes a task (the CLI refuses a claimed task — reopen or wait for the claim to expire first). '
|
|
357
|
+
+ 'The queen uses these for ordering, splitting, goal evolution and remediation; workers alone claim and finish tasks.',
|
|
355
358
|
parameters: {
|
|
356
359
|
repo: repoParameter,
|
|
357
360
|
action: {
|
|
358
361
|
type: 'string',
|
|
359
|
-
enum: ['list', 'show', 'add', 'reopen', 'retry', 'rm'],
|
|
360
|
-
description: 'What to do. list/show read; add/reopen/retry/rm change the board.',
|
|
362
|
+
enum: ['list', 'show', 'add', 'edit', 'split', 'supersede', 'reopen', 'retry', 'rm'],
|
|
363
|
+
description: 'What to do. list/show read; add/edit/split/supersede/reopen/retry/rm change the board.',
|
|
361
364
|
},
|
|
362
|
-
id: { type: 'string', description: '
|
|
365
|
+
id: { type: 'string', description: 'Task id (show/edit/split/supersede/reopen/retry/rm).' },
|
|
363
366
|
state: { type: 'string', enum: ['pending', 'claimed', 'done', 'failed'], description: 'list: state filter.' },
|
|
364
|
-
role: { type: 'string', description: 'list/add: role filter or role
|
|
365
|
-
title: { type: 'string', description: 'add:
|
|
366
|
-
goal: { type: 'string', description: 'add: goal of the
|
|
367
|
-
scope: { type: 'array', items: { type: 'string' }, description: 'add: paths or resource keys the
|
|
368
|
-
after: { type: 'array', items: { type: 'string' }, description: 'add:
|
|
369
|
-
priority: { type: 'number', description: 'add: higher runs first (-1000..1000).' },
|
|
370
|
-
tags: { type: 'array', items: { type: 'string' }, description: 'add: tags
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
367
|
+
role: { type: 'string', description: 'list/add/edit: role filter or new role for the task(s).' },
|
|
368
|
+
title: { type: 'string', description: 'add/edit: task title.' },
|
|
369
|
+
goal: { type: 'string', description: 'add: goal of the task (hive-tasks 1.9 edit cannot change it).' },
|
|
370
|
+
scope: { type: 'array', items: { type: 'string' }, description: 'add/edit: paths or resource keys (edit replaces the list; the runner translates it to scope add/remove).' },
|
|
371
|
+
after: { type: 'array', items: { type: 'string' }, description: 'add/edit: task ids that must be done first (edit replaces the list).' },
|
|
372
|
+
priority: { type: 'number', description: 'add/edit: higher runs first (-1000..1000).' },
|
|
373
|
+
tags: { type: 'array', items: { type: 'string' }, description: 'add: initial tags. edit: tags to add.' },
|
|
374
|
+
removeTags: { type: 'array', items: { type: 'string' }, description: 'edit: tags to remove.' },
|
|
375
|
+
clearScope: { type: 'boolean', description: 'edit: clear the scope list.' },
|
|
376
|
+
clearAfter: { type: 'boolean', description: 'edit: clear the dependency list.' },
|
|
377
|
+
acceptance: { type: 'string', description: 'add/edit: shell command/assertion that proves the task (required unless draft).' },
|
|
378
|
+
reviewOf: { type: 'string', description: 'add: the task id this task reviews.' },
|
|
379
|
+
draft: { type: 'boolean', description: 'add: create a draft (no acceptance needed, never dispatched). Not editable afterwards.' },
|
|
380
|
+
superseded: { type: 'boolean', description: 'edit: mark/unmark superseded (superseded tasks are never dispatched).' },
|
|
381
|
+
cards: {
|
|
382
|
+
type: 'array',
|
|
383
|
+
items: { type: 'object', additionalProperties: true, description: 'New task: { title, role?, scope?, acceptance?, after? }' },
|
|
384
|
+
description: 'split: at least two fine-grained replacement tasks; each inherits the parent scope/role/priority/tags/acceptance unless overridden.',
|
|
385
|
+
},
|
|
386
|
+
replacedBy: { type: 'string', description: 'supersede: the task id that replaces this one.' },
|
|
387
|
+
reason: { type: 'string', description: 'reopen/split/supersede: why the task changes (supersede requires it).' },
|
|
375
388
|
},
|
|
376
389
|
execute: async (args = {}, exec) => {
|
|
377
390
|
const repo = repoOf(args);
|
|
@@ -402,6 +415,58 @@ export function apply(ctx, config = {}) {
|
|
|
402
415
|
}, options);
|
|
403
416
|
return jsonText({ ok: true, card });
|
|
404
417
|
}
|
|
418
|
+
if (action === 'edit') {
|
|
419
|
+
if (typeof args.id !== 'string') throw new Error('hive_tasks edit needs an id');
|
|
420
|
+
if (args.goal !== undefined && args.goal !== null && args.goal !== '') {
|
|
421
|
+
throw new Error('hive-tasks 1.9 edit cannot change goal; split or recreate the task instead');
|
|
422
|
+
}
|
|
423
|
+
if (args.draft === true || args.draft === false) {
|
|
424
|
+
throw new Error('hive-tasks 1.9 edit cannot change the draft flag; draft is set at creation');
|
|
425
|
+
}
|
|
426
|
+
const patch = {
|
|
427
|
+
title: args.title,
|
|
428
|
+
role: args.role,
|
|
429
|
+
priority: args.priority,
|
|
430
|
+
acceptance: args.acceptance,
|
|
431
|
+
superseded: args.superseded,
|
|
432
|
+
reason: args.reason,
|
|
433
|
+
};
|
|
434
|
+
// Scope is replace-style at the tool level: read the current card and
|
|
435
|
+
// translate into the CLI's incremental --scope-add/--scope-remove.
|
|
436
|
+
if (args.clearScope === true || Array.isArray(args.scope)) {
|
|
437
|
+
const current = await commands.show(repo, args.id, options);
|
|
438
|
+
if (current === null || current === undefined) throw new Error('no such task: ' + args.id);
|
|
439
|
+
const before = Array.isArray(current.scope) ? current.scope : [];
|
|
440
|
+
const desired = args.clearScope === true ? [] : args.scope;
|
|
441
|
+
patch.scopeAdd = desired.filter((path) => !before.includes(path));
|
|
442
|
+
patch.scopeRemove = before.filter((path) => !desired.includes(path));
|
|
443
|
+
}
|
|
444
|
+
if (args.clearAfter === true || Array.isArray(args.after)) {
|
|
445
|
+
patch.afterSet = args.clearAfter === true ? [] : args.after;
|
|
446
|
+
}
|
|
447
|
+
const addTags = Array.isArray(args.tags) ? args.tags.map((tag) => '+' + String(tag).trim()) : [];
|
|
448
|
+
const removeTags = Array.isArray(args.removeTags) ? args.removeTags.map((tag) => '-' + String(tag).trim()) : [];
|
|
449
|
+
if (addTags.length > 0 || removeTags.length > 0) patch.tagMutations = [...addTags, ...removeTags];
|
|
450
|
+
const card = await commands.edit(repo, args.id, patch, options);
|
|
451
|
+
return jsonText({ ok: true, card });
|
|
452
|
+
}
|
|
453
|
+
if (action === 'split') {
|
|
454
|
+
if (typeof args.id !== 'string') throw new Error('hive_tasks split needs an id');
|
|
455
|
+
if (!Array.isArray(args.cards) || args.cards.length < 2) {
|
|
456
|
+
throw new Error('hive_tasks split needs cards: at least two fine-grained card drafts');
|
|
457
|
+
}
|
|
458
|
+
return jsonText(await commands.split(repo, args.id, args.cards, { reason: args.reason, ...options }));
|
|
459
|
+
}
|
|
460
|
+
if (action === 'supersede') {
|
|
461
|
+
if (typeof args.id !== 'string') throw new Error('hive_tasks supersede needs an id');
|
|
462
|
+
if (typeof args.reason !== 'string' || args.reason.trim() === '') {
|
|
463
|
+
throw new Error('hive_tasks supersede needs a reason (the CLI requires it)');
|
|
464
|
+
}
|
|
465
|
+
return jsonText({
|
|
466
|
+
ok: true,
|
|
467
|
+
card: await commands.supersede(repo, args.id, { reason: args.reason, replacedBy: args.replacedBy }, options),
|
|
468
|
+
});
|
|
469
|
+
}
|
|
405
470
|
if (action === 'reopen') {
|
|
406
471
|
if (typeof args.id !== 'string') throw new Error('hive_tasks reopen needs an id');
|
|
407
472
|
return jsonText({ ok: true, card: await commands.reopen(repo, args.id, { reason: args.reason }, options) });
|
|
@@ -414,7 +479,7 @@ export function apply(ctx, config = {}) {
|
|
|
414
479
|
if (typeof args.id !== 'string') throw new Error('hive_tasks rm needs an id');
|
|
415
480
|
return jsonText({ ok: true, deleted: args.id, output: await commands.remove(repo, args.id, options) });
|
|
416
481
|
}
|
|
417
|
-
throw new Error('hive_tasks action must be one of list, show, add, reopen, retry, rm');
|
|
482
|
+
throw new Error('hive_tasks action must be one of list, show, add, edit, split, supersede, reopen, retry, rm');
|
|
418
483
|
},
|
|
419
484
|
});
|
|
420
485
|
|
|
@@ -597,9 +662,11 @@ export function apply(ctx, config = {}) {
|
|
|
597
662
|
name: 'hive_intervene',
|
|
598
663
|
description:
|
|
599
664
|
'Act on a stuck card and record the decision as a queen_intervention event { card, action, reason }. '
|
|
600
|
-
+ 'action=reopen|split|reassign|pause|fail|guide|remove|rebuild|escalate. '
|
|
665
|
+
+ 'action=reopen|split|reassign|pause|abort|fail|guide|supersede|remove|rebuild|escalate. '
|
|
601
666
|
+ 'reopen writes the guidance into the card reason, which the next worker prompt carries verbatim — the main guidance channel. '
|
|
602
|
-
+ 'split/
|
|
667
|
+
+ 'split atomically replaces a pending/failed task with at least two fine-grained cards from `cards` and marks the original superseded; reassign creates cards for another role and reopens the original. '
|
|
668
|
+
+ 'abort stops one live worker on request (the card is recorded failed with the reason); pause is the softer repository-level throttle. '
|
|
669
|
+
+ 'supersede marks a card — including a claimed/running one — as superseded without changing its state, so it is never dispatched again. '
|
|
603
670
|
+ 'remove deletes a card whose content has no value, recording its title/state/scope in the event first — a deleted card never disappears silently. '
|
|
604
671
|
+ 'rebuild deletes and recreates a card whose title/scope/acceptance/dependencies were wrong; the new cards reference the old id in reason/after and the old id is recorded in the event. '
|
|
605
672
|
+ 'pause pauses dispatch for the repository (external dependency missing). fail only confirms a card a worker already failed (the queen never changes a card state). '
|
|
@@ -609,7 +676,7 @@ export function apply(ctx, config = {}) {
|
|
|
609
676
|
repo: repoParameter,
|
|
610
677
|
action: {
|
|
611
678
|
type: 'string',
|
|
612
|
-
enum: ['reopen', 'split', 'reassign', 'pause', 'fail', 'guide', 'remove', 'rebuild', 'escalate'],
|
|
679
|
+
enum: ['reopen', 'split', 'reassign', 'pause', 'abort', 'fail', 'guide', 'supersede', 'remove', 'rebuild', 'escalate'],
|
|
613
680
|
description: 'What the queen decides to do.',
|
|
614
681
|
},
|
|
615
682
|
card: { type: 'string', description: 'The stuck card id.' },
|
|
@@ -639,7 +706,19 @@ export function apply(ctx, config = {}) {
|
|
|
639
706
|
let removed = null;
|
|
640
707
|
if (action === 'reopen') {
|
|
641
708
|
await commands.reopen(repo, cardId, { reason: args.reason }, options);
|
|
642
|
-
} else if (action === 'split'
|
|
709
|
+
} else if (action === 'split') {
|
|
710
|
+
if (!Array.isArray(args.cards) || args.cards.length === 0) {
|
|
711
|
+
throw new Error('split needs at least two fine-grained cards: [{ title, acceptance, ... }, ...]');
|
|
712
|
+
}
|
|
713
|
+
const split = await commands.split(repo, cardId, args.cards, { reason: args.reason, ...options });
|
|
714
|
+
const created = Array.isArray(split?.cards) ? split.cards : [];
|
|
715
|
+
for (const entry of created) {
|
|
716
|
+
const id = entry !== null && typeof entry === 'object' && typeof entry.id === 'string'
|
|
717
|
+
? entry.id
|
|
718
|
+
: (typeof entry === 'string' ? entry : null);
|
|
719
|
+
if (id !== null) newCards.push(id);
|
|
720
|
+
}
|
|
721
|
+
} else if (action === 'reassign' || action === 'rebuild') {
|
|
643
722
|
if (action === 'rebuild' && (rebuildCounts(eventsBefore).get(cardId) ?? 0) >= REBUILD_LIMIT) {
|
|
644
723
|
throw new Error('card ' + cardId + ' was already rebuilt ' + String(REBUILD_LIMIT) + ' times; escalate it to a human decision instead');
|
|
645
724
|
}
|
|
@@ -675,6 +754,13 @@ export function apply(ctx, config = {}) {
|
|
|
675
754
|
const key = normalizeRepoKey(repo);
|
|
676
755
|
if (!supervisor.hasRepo(key)) throw new Error('unknown repository ' + JSON.stringify(key));
|
|
677
756
|
supervisor.pause(key, args.reason);
|
|
757
|
+
} else if (action === 'abort') {
|
|
758
|
+
const result = runner.abortCard(repo, cardId, args.reason);
|
|
759
|
+
if (result.aborted !== true) {
|
|
760
|
+
throw new Error('no live worker for card ' + cardId + ' (it may already have finished; use reopen/supersede)');
|
|
761
|
+
}
|
|
762
|
+
} else if (action === 'supersede') {
|
|
763
|
+
await commands.supersede(repo, cardId, { reason: args.reason }, options);
|
|
678
764
|
} else if (action === 'fail') {
|
|
679
765
|
if (card.state !== 'failed') {
|
|
680
766
|
throw new Error(
|
|
@@ -691,7 +777,7 @@ export function apply(ctx, config = {}) {
|
|
|
691
777
|
throw new Error('cannot deliver guidance: ' + String(delivery.reason ?? 'unknown'));
|
|
692
778
|
}
|
|
693
779
|
} else if (action !== 'escalate') {
|
|
694
|
-
throw new Error('hive_intervene action must be reopen, split, reassign, pause, fail, guide, remove, rebuild or escalate');
|
|
780
|
+
throw new Error('hive_intervene action must be reopen, split, reassign, pause, abort, fail, guide, supersede, remove, rebuild or escalate');
|
|
695
781
|
}
|
|
696
782
|
const event = appendIntervention(repo, {
|
|
697
783
|
card: cardId,
|
|
@@ -772,4 +858,4 @@ export function apply(ctx, config = {}) {
|
|
|
772
858
|
throw new Error('hive_anomalies action must be list, ack or patrol');
|
|
773
859
|
},
|
|
774
860
|
});
|
|
775
|
-
}
|
|
861
|
+
}
|
package/lib/commands.js
CHANGED
|
@@ -49,6 +49,9 @@ const VERB_BINS = Object.freeze({
|
|
|
49
49
|
fail: 'tasks',
|
|
50
50
|
list: 'tasks',
|
|
51
51
|
add: 'tasks',
|
|
52
|
+
edit: 'tasks',
|
|
53
|
+
split: 'tasks',
|
|
54
|
+
supersede: 'tasks',
|
|
52
55
|
reopen: 'tasks',
|
|
53
56
|
retry: 'tasks',
|
|
54
57
|
remove: 'tasks',
|
|
@@ -245,6 +248,103 @@ export function buildCommand(verb, args = {}, bins = {}) {
|
|
|
245
248
|
if (args.draft === true) parts.push('--draft');
|
|
246
249
|
return parts.join(' ');
|
|
247
250
|
}
|
|
251
|
+
case 'edit': {
|
|
252
|
+
// hive-tasks 1.9 edit flags: --title/--role/--priority/--acceptance,
|
|
253
|
+
// incremental scope (--scope-add/--scope-remove), --after-set (comma list),
|
|
254
|
+
// --tag +name/-name, --superseded/--no-superseded, optional --reason.
|
|
255
|
+
const id = needMatch(ID_RE, args.id, 'edit.id');
|
|
256
|
+
const parts = [tasks, 'edit', quote(id), '--json'];
|
|
257
|
+
let changes = 0;
|
|
258
|
+
const title = optionalText(args.title, 'edit.title', 300);
|
|
259
|
+
if (title !== null) { parts.push('--title', quote(title)); changes += 1; }
|
|
260
|
+
if (args.role !== undefined && args.role !== null && args.role !== '') {
|
|
261
|
+
parts.push('--role', quote(needMatch(CARD_ROLE_RE, args.role, 'edit.role')));
|
|
262
|
+
changes += 1;
|
|
263
|
+
}
|
|
264
|
+
for (const path of listArg(args.scopeAdd, 'edit.scopeAdd')) { parts.push('--scope-add', quote(path)); changes += 1; }
|
|
265
|
+
for (const path of listArg(args.scopeRemove, 'edit.scopeRemove')) { parts.push('--scope-remove', quote(path)); changes += 1; }
|
|
266
|
+
if (args.afterSet !== undefined && args.afterSet !== null) {
|
|
267
|
+
const deps = Array.isArray(args.afterSet) ? args.afterSet : [];
|
|
268
|
+
const ids = deps.map((dep) => needMatch(ID_RE, dep, 'edit.afterSet entry'));
|
|
269
|
+
parts.push('--after-set', quote(ids.join(',')));
|
|
270
|
+
changes += 1;
|
|
271
|
+
}
|
|
272
|
+
if (args.priority !== undefined && args.priority !== null) {
|
|
273
|
+
parts.push('--priority', String(intArg(args.priority, 'edit.priority', -1000, 1000)));
|
|
274
|
+
changes += 1;
|
|
275
|
+
}
|
|
276
|
+
const acceptance = optionalText(args.acceptance, 'edit.acceptance');
|
|
277
|
+
if (acceptance !== null) { parts.push('--acceptance', quote(acceptance)); changes += 1; }
|
|
278
|
+
for (const mutation of listArg(args.tagMutations, 'edit.tagMutations', { max: 64 })) {
|
|
279
|
+
if (!/^[+-][A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(mutation)) {
|
|
280
|
+
throw new HiveCommandError('hive/invalid-argument', 'edit.tagMutations entries must look like +tag or -tag');
|
|
281
|
+
}
|
|
282
|
+
parts.push('--tag', quote(mutation));
|
|
283
|
+
changes += 1;
|
|
284
|
+
}
|
|
285
|
+
if (args.superseded === true) { parts.push('--superseded'); changes += 1; }
|
|
286
|
+
else if (args.superseded === false) { parts.push('--no-superseded'); changes += 1; }
|
|
287
|
+
if (changes === 0) {
|
|
288
|
+
throw new HiveCommandError('hive/invalid-argument', 'edit needs at least one field to change');
|
|
289
|
+
}
|
|
290
|
+
if (args.superseded === true) {
|
|
291
|
+
const reason = optionalText(args.reason, 'edit.reason', 1000);
|
|
292
|
+
if (reason !== null) parts.push('--reason', quote(reason));
|
|
293
|
+
}
|
|
294
|
+
return parts.join(' ');
|
|
295
|
+
}
|
|
296
|
+
case 'split': {
|
|
297
|
+
// hive-tasks 1.9 split: --into '<json array>' (at least two entries),
|
|
298
|
+
// entries { title, role?, scope?, acceptance?, after? }; the parent is
|
|
299
|
+
// superseded with replacedBy = first child unless --keep is passed.
|
|
300
|
+
const id = needMatch(ID_RE, args.id, 'split.id');
|
|
301
|
+
const into = args.cards;
|
|
302
|
+
if (!Array.isArray(into) || into.length < 2) {
|
|
303
|
+
throw new HiveCommandError('hive/invalid-argument', 'split.cards must be an array of at least two fine-grained cards');
|
|
304
|
+
}
|
|
305
|
+
if (into.length > 32) {
|
|
306
|
+
throw new HiveCommandError('hive/invalid-argument', 'split.cards must have at most 32 entries; split in rounds');
|
|
307
|
+
}
|
|
308
|
+
const allowed = new Set(['title', 'role', 'scope', 'acceptance', 'after']);
|
|
309
|
+
const cards = into.map((entry, index) => {
|
|
310
|
+
if (entry === null || typeof entry !== 'object' || Array.isArray(entry)) {
|
|
311
|
+
throw new HiveCommandError('hive/invalid-argument', 'split.cards[' + index + '] must be an object');
|
|
312
|
+
}
|
|
313
|
+
for (const key of Object.keys(entry)) {
|
|
314
|
+
if (!allowed.has(key)) {
|
|
315
|
+
throw new HiveCommandError(
|
|
316
|
+
'hive/invalid-argument',
|
|
317
|
+
'split.cards[' + index + '].' + key + ' is not supported by hive-tasks 1.9 (title/role/scope/acceptance/after only)',
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const card = { title: textArg(entry.title, 'split.cards[' + index + '].title', 300) };
|
|
322
|
+
if (entry.role !== undefined) card.role = needMatch(CARD_ROLE_RE, entry.role, 'split.cards[' + index + '].role');
|
|
323
|
+
if (entry.scope !== undefined) card.scope = listArg(entry.scope, 'split.cards[' + index + '].scope');
|
|
324
|
+
if (entry.acceptance !== undefined) card.acceptance = textArg(entry.acceptance, 'split.cards[' + index + '].acceptance');
|
|
325
|
+
if (entry.after !== undefined) {
|
|
326
|
+
card.after = listArg(entry.after, 'split.cards[' + index + '].after', { max: 128 })
|
|
327
|
+
.map((dep) => needMatch(ID_RE, dep, 'split.cards[' + index + '].after entry'));
|
|
328
|
+
}
|
|
329
|
+
return card;
|
|
330
|
+
});
|
|
331
|
+
const json = JSON.stringify(cards);
|
|
332
|
+
if (json.length > 24_000) {
|
|
333
|
+
throw new HiveCommandError('hive/invalid-argument', 'split.cards JSON is too large (limit 24000 characters)');
|
|
334
|
+
}
|
|
335
|
+
const reason = optionalText(args.reason, 'split.reason', 1000);
|
|
336
|
+
return tasks + ' split ' + quote(id) + ' --into ' + quote(json) + ' --json'
|
|
337
|
+
+ (reason === null ? '' : ' --reason ' + quote(reason));
|
|
338
|
+
}
|
|
339
|
+
case 'supersede': {
|
|
340
|
+
const id = needMatch(ID_RE, args.id, 'supersede.id');
|
|
341
|
+
const reason = textArg(args.reason, 'supersede.reason', 1000);
|
|
342
|
+
const parts = [tasks, 'supersede', quote(id), '--json', '--reason', quote(reason)];
|
|
343
|
+
if (args.replacedBy !== undefined && args.replacedBy !== null && args.replacedBy !== '') {
|
|
344
|
+
parts.push('--replaced-by', quote(needMatch(ID_RE, args.replacedBy, 'supersede.replacedBy')));
|
|
345
|
+
}
|
|
346
|
+
return parts.join(' ');
|
|
347
|
+
}
|
|
248
348
|
case 'reopen': {
|
|
249
349
|
const id = needMatch(ID_RE, args.id, 'reopen.id');
|
|
250
350
|
const reason = args.reason === undefined || args.reason === null || args.reason === ''
|
|
@@ -574,6 +674,28 @@ export function createCommands({ ctx, config }) {
|
|
|
574
674
|
const value = parseJson(result.stdout, 'hive-tasks add');
|
|
575
675
|
return value !== null && typeof value === 'object' ? value : null;
|
|
576
676
|
},
|
|
677
|
+
/** `hive-tasks edit <id> [flags]` -> the updated card (partial update). */
|
|
678
|
+
async edit(repo, id, patch, options = {}) {
|
|
679
|
+
const result = await execute('edit', { id, ...patch }, { ...options, repo });
|
|
680
|
+
if (result.exitCode !== 0) throw failure(result, 'hive-tasks edit ' + id);
|
|
681
|
+
return parseJson(result.stdout, 'hive-tasks edit');
|
|
682
|
+
},
|
|
683
|
+
/** `hive-tasks split <id> --into '<json>'` -> { task, cards }. */
|
|
684
|
+
async split(repo, id, cards, options = {}) {
|
|
685
|
+
const result = await execute('split', { id, cards, reason: options.reason }, { ...options, repo });
|
|
686
|
+
if (result.exitCode !== 0) throw failure(result, 'hive-tasks split ' + id);
|
|
687
|
+
return parseJson(result.stdout, 'hive-tasks split');
|
|
688
|
+
},
|
|
689
|
+
/** `hive-tasks supersede <id> --reason R [--replaced-by ID]` -> the marked card. */
|
|
690
|
+
async supersede(repo, id, options = {}) {
|
|
691
|
+
const result = await execute('supersede', {
|
|
692
|
+
id,
|
|
693
|
+
reason: options.reason,
|
|
694
|
+
replacedBy: options.replacedBy,
|
|
695
|
+
}, { ...options, repo });
|
|
696
|
+
if (result.exitCode !== 0) throw failure(result, 'hive-tasks supersede ' + id);
|
|
697
|
+
return parseJson(result.stdout, 'hive-tasks supersede');
|
|
698
|
+
},
|
|
577
699
|
/** `hive-tasks reopen <id> [--reason R]` -> the reopened card. */
|
|
578
700
|
async reopen(repo, id, options = {}) {
|
|
579
701
|
const result = await execute('reopen', { id, reason: options.reason }, { ...options, repo });
|
|
@@ -632,4 +754,4 @@ export function createCommands({ ctx, config }) {
|
|
|
632
754
|
};
|
|
633
755
|
}
|
|
634
756
|
|
|
635
|
-
export { createShellRunner };
|
|
757
|
+
export { createShellRunner };
|
package/lib/gates.js
CHANGED
|
@@ -51,9 +51,11 @@ function progressOf(cards) {
|
|
|
51
51
|
* @returns {{ phase: string, base: object, group: object, overall: object, releaseReady: boolean, reason: string }}
|
|
52
52
|
*/
|
|
53
53
|
export function gatePhase(tasks) {
|
|
54
|
-
// Draft cards are
|
|
54
|
+
// Draft and superseded cards are not work: they never gate progress.
|
|
55
|
+
// (Both are flags on a four-state card, never states.)
|
|
55
56
|
const cards = Array.isArray(tasks)
|
|
56
|
-
? tasks.filter((card) => card !== null && typeof card === 'object'
|
|
57
|
+
? tasks.filter((card) => card !== null && typeof card === 'object'
|
|
58
|
+
&& card.draft !== true && card.superseded !== true)
|
|
57
59
|
: [];
|
|
58
60
|
const base = cards.filter((card) => gateOf(card) === null);
|
|
59
61
|
const group = cards.filter((card) => gateOf(card) === 'group');
|
package/lib/round.js
CHANGED
|
@@ -202,7 +202,7 @@ export function createRoundRunner({
|
|
|
202
202
|
// supervision is advisory
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
/** repo -> Map(cardId,
|
|
205
|
+
/** repo -> Map(cardId, { run, abort }) for status and queen abort requests. */
|
|
206
206
|
const active = new Map();
|
|
207
207
|
function registerActive(repo, run) {
|
|
208
208
|
let runs = active.get(repo);
|
|
@@ -210,7 +210,28 @@ export function createRoundRunner({
|
|
|
210
210
|
runs = new Map();
|
|
211
211
|
active.set(repo, runs);
|
|
212
212
|
}
|
|
213
|
-
runs.set(run.cardId, run);
|
|
213
|
+
runs.set(run.cardId, { run, abort: null });
|
|
214
|
+
}
|
|
215
|
+
/** Attach the per-card abort handle once the worker controller exists. */
|
|
216
|
+
function setActiveAbort(repo, cardId, abort) {
|
|
217
|
+
const runs = active.get(repo);
|
|
218
|
+
const entry = runs?.get(cardId);
|
|
219
|
+
if (entry !== undefined) entry.abort = typeof abort === 'function' ? abort : null;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Abort one live card worker on request (the queen's "stop it now" path).
|
|
223
|
+
* The abort is delivered as a card failure carrying the reason; supervisor
|
|
224
|
+
* pause is the softer action that only stops new dispatch.
|
|
225
|
+
* @param {string} repo
|
|
226
|
+
* @param {string} cardId
|
|
227
|
+
* @param {string} [reason]
|
|
228
|
+
* @returns {{ aborted: boolean, cardId: string }}
|
|
229
|
+
*/
|
|
230
|
+
function abortCard(repo, cardId, reason = 'aborted by the queen') {
|
|
231
|
+
const entry = active.get(repo)?.get(cardId);
|
|
232
|
+
if (entry === undefined || entry.abort === null) return { aborted: false, cardId };
|
|
233
|
+
entry.abort(reason);
|
|
234
|
+
return { aborted: true, cardId };
|
|
214
235
|
}
|
|
215
236
|
function unregisterActive(repo, cardId) {
|
|
216
237
|
const runs = active.get(repo);
|
|
@@ -222,7 +243,7 @@ export function createRoundRunner({
|
|
|
222
243
|
function activeRuns(repo) {
|
|
223
244
|
const runs = active.get(repo);
|
|
224
245
|
if (runs === undefined) return [];
|
|
225
|
-
return [...runs.values()].map((run) => ({
|
|
246
|
+
return [...runs.values()].map((entry) => entry.run).filter((run) => run !== undefined).map((run) => ({
|
|
226
247
|
cardId: run.cardId,
|
|
227
248
|
role: run.role,
|
|
228
249
|
agent: run.agent,
|
|
@@ -472,6 +493,9 @@ export function createRoundRunner({
|
|
|
472
493
|
let activation;
|
|
473
494
|
let releaseEnv = () => {};
|
|
474
495
|
let timedOut = false;
|
|
496
|
+
// Set when the queen aborts this worker on request; the card is recorded as
|
|
497
|
+
// failed with her reason instead of turning into a round-level error.
|
|
498
|
+
let queenAbort = null;
|
|
475
499
|
let settled = false;
|
|
476
500
|
const controller = new AbortController();
|
|
477
501
|
const workerSignal = signal === undefined ? controller.signal : AbortSignal.any([signal, controller.signal]);
|
|
@@ -479,6 +503,11 @@ export function createRoundRunner({
|
|
|
479
503
|
if (controller.signal.aborted) resolve();
|
|
480
504
|
else controller.signal.addEventListener('abort', () => resolve(), { once: true });
|
|
481
505
|
});
|
|
506
|
+
setActiveAbort(repo, id, (reason) => {
|
|
507
|
+
if (queenAbort !== null) return;
|
|
508
|
+
queenAbort = typeof reason === 'string' && reason.trim() !== '' ? reason.trim() : 'aborted by the queen';
|
|
509
|
+
controller.abort();
|
|
510
|
+
});
|
|
482
511
|
let timeoutTimer;
|
|
483
512
|
let heartbeatTimer;
|
|
484
513
|
const clearMonitors = () => {
|
|
@@ -599,7 +628,29 @@ export function createRoundRunner({
|
|
|
599
628
|
settled = true;
|
|
600
629
|
clearMonitors();
|
|
601
630
|
if (timedOut) return await failCard(abortReason());
|
|
631
|
+
// A queen abort wins over whatever the provider reports afterwards: the
|
|
632
|
+
// card is failed with her reason, never a generic stopReason message.
|
|
633
|
+
if (queenAbort !== null) {
|
|
634
|
+
emitAnomaly({
|
|
635
|
+
kind: 'worker-aborted',
|
|
636
|
+
repo,
|
|
637
|
+
cardId: id,
|
|
638
|
+
role: card.role,
|
|
639
|
+
detail: 'aborted on queen request: ' + queenAbort,
|
|
640
|
+
});
|
|
641
|
+
return await failCard('aborted on request: ' + queenAbort);
|
|
642
|
+
}
|
|
602
643
|
if (outcome === null) {
|
|
644
|
+
if (queenAbort !== null) {
|
|
645
|
+
emitAnomaly({
|
|
646
|
+
kind: 'worker-aborted',
|
|
647
|
+
repo,
|
|
648
|
+
cardId: id,
|
|
649
|
+
role: card.role,
|
|
650
|
+
detail: 'aborted on queen request: ' + queenAbort,
|
|
651
|
+
});
|
|
652
|
+
return await failCard('aborted on request: ' + queenAbort);
|
|
653
|
+
}
|
|
603
654
|
// Aborted before the provider settled: report it as a round failure and
|
|
604
655
|
// let the supervisor decide (external cancellation/teardown).
|
|
605
656
|
emitAnomaly({
|
|
@@ -636,6 +687,9 @@ export function createRoundRunner({
|
|
|
636
687
|
if (timedOut) {
|
|
637
688
|
return await failCard(abortReason(), messageOf(error) || abortReason());
|
|
638
689
|
}
|
|
690
|
+
if (queenAbort !== null) {
|
|
691
|
+
return await failCard('aborted on request: ' + queenAbort, messageOf(error) || 'aborted on request: ' + queenAbort);
|
|
692
|
+
}
|
|
639
693
|
if (!runFinished) finishRun('failed', { exitCode: 1, output: messageOf(error) });
|
|
640
694
|
if (isCapacityError(error)) {
|
|
641
695
|
// Capacity is a scheduling concern, not this card's failure: keep the
|
|
@@ -673,6 +727,7 @@ export function createRoundRunner({
|
|
|
673
727
|
return {
|
|
674
728
|
resolveParent,
|
|
675
729
|
activeRuns,
|
|
730
|
+
abortCard,
|
|
676
731
|
|
|
677
732
|
/**
|
|
678
733
|
* Round-start environment check: the repository must be Hive-initialised
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-hive-runner",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
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",
|