hive-tasks 1.8.1 → 1.10.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 +71 -2
- package/README.md +85 -5
- package/README.zh-CN.md +75 -5
- package/SPEC.md +91 -9
- package/package.json +1 -1
- package/src/cli.js +464 -30
- package/src/git.js +19 -0
- package/src/lease.js +12 -0
- package/src/store.js +225 -21
- package/src/task.js +7 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,7 +4,29 @@ All notable changes to this project are documented here. The format follows
|
|
|
4
4
|
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project uses
|
|
5
5
|
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## [1.10.0] - 2026-12-06
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `HIVE_EVENT_ACTOR` decouples event `actor` from the task owner/claim identity; the
|
|
12
|
+
runner sets it to `worker:<role>` for worker CLI calls while the claim owner stays
|
|
13
|
+
the runner identity.
|
|
14
|
+
- `list --json --state S --role R --limit N --cursor C` returns one server-side page,
|
|
15
|
+
`{ items, total, cursor, hasMore }`, ordered by stateChangedAt descending (ties by
|
|
16
|
+
id); only the page's card blobs are read and cursor is the numeric offset returned
|
|
17
|
+
by the previous page.
|
|
18
|
+
- `counts --json` returns `{ total, byState, superseded, oldestPending }` from a
|
|
19
|
+
lightweight index; `stats` is index-backed too and keeps its shape.
|
|
20
|
+
- `show <id> --json` reads exactly one card blob.
|
|
21
|
+
- Derived `refs/hive/v1/tasks-index` cache, refreshed after every board write and
|
|
22
|
+
rebuilt once when missing or stale.
|
|
23
|
+
|
|
24
|
+
### Tests
|
|
25
|
+
|
|
26
|
+
- 68 node:test scenarios: the 62 from 1.9.0 unchanged, plus six in
|
|
27
|
+
test/pagination.test.mjs covering page walking against the filtered full list,
|
|
28
|
+
boundaries, counts versus stats, index rebuild after a missing/stale index, pages and
|
|
29
|
+
counts being index-only while show reads one blob, and a 100k-entry mock index.
|
|
8
30
|
|
|
9
31
|
### Changed
|
|
10
32
|
|
|
@@ -16,6 +38,49 @@ All notable changes to this project are documented here. The format follows
|
|
|
16
38
|
"never starts a process" claim and the generated id length). No behaviour or protocol
|
|
17
39
|
change.
|
|
18
40
|
|
|
41
|
+
## [1.9.0] - 2026-12-04
|
|
42
|
+
|
|
43
|
+
### Added
|
|
44
|
+
|
|
45
|
+
- `edit <id>` with `--title`, `--scope-add`/`--scope-remove`, `--acceptance`,
|
|
46
|
+
`--priority`, `--after-set`, `--tag +T/-T`, `--role` and `--superseded`/
|
|
47
|
+
`--no-superseded`. It only works on pending or failed tasks and changes only the
|
|
48
|
+
fields passed. An empty `--acceptance` is refused; `--acceptance -` clears it on a
|
|
49
|
+
draft task; `--priority` must be an integer; `--after-set` refuses a dependency cycle.
|
|
50
|
+
A scope edit keeps the task's announcements in sync (added paths are announced under
|
|
51
|
+
the task announcer and removed paths a claim of the task wrote are released). An edit
|
|
52
|
+
never moves the lane, so `stateChangedAt` is untouched.
|
|
53
|
+
- `supersede <id> --reason R [--replaced-by ID]`: retire a task without marking it done
|
|
54
|
+
or failed. The flag keeps the lane but removes the task from ready, next and claim,
|
|
55
|
+
and stats counts superseded tasks separately. `edit --superseded`/`--no-superseded`
|
|
56
|
+
sets and clears the same flag on a pending or failed task.
|
|
57
|
+
- `split <id> --into '<json array>' [--keep] [--reason R] [--json]`: replace a task with
|
|
58
|
+
at least two cards described by `{title, role?, scope?, acceptance?, after?}`. Missing
|
|
59
|
+
values are inherited from the parent and every card needs an acceptance command.
|
|
60
|
+
Without --keep the parent is marked superseded and points at the first card via
|
|
61
|
+
replacedBy; with --keep it keeps its lane and every card lists it in after. Claimed or
|
|
62
|
+
done tasks cannot be split. --json returns `{ task, cards }`.
|
|
63
|
+
- Events: `task_edit` (`{ task, fields }` where fields names the changed fields, never
|
|
64
|
+
their values), `task_split` (`{ task, cards, kept, replacedBy? }`) and
|
|
65
|
+
`task_supersede` (`{ task, reason, replacedBy? }`).
|
|
66
|
+
|
|
67
|
+
### Tests
|
|
68
|
+
|
|
69
|
+
- 62 node:test scenarios: the 52 from 1.8.1 unchanged, plus ten in
|
|
70
|
+
test/edit-split.test.mjs covering per-field edits and the `{ task, fields }` event,
|
|
71
|
+
pending/failed-only edits, integer priority, dependency cycles and the superseded
|
|
72
|
+
toggle, scope announcement sync, the acceptance rules, a JSON-array split that
|
|
73
|
+
supersedes the parent, `--keep` gating, split refusals, `supersede` with
|
|
74
|
+
`--replaced-by`, and stats counting a superseded done task separately.
|
|
75
|
+
|
|
76
|
+
### Published
|
|
77
|
+
|
|
78
|
+
- Not published to npm in this change.
|
|
79
|
+
|
|
80
|
+
### Published
|
|
81
|
+
|
|
82
|
+
- npm: `hive-tasks@1.9.0` on 2026-12-04.
|
|
83
|
+
|
|
19
84
|
## [1.8.1] - 2026-12-04
|
|
20
85
|
|
|
21
86
|
### Added
|
|
@@ -33,6 +98,10 @@ All notable changes to this project are documented here. The format follows
|
|
|
33
98
|
covering lane changes, a stage advance while the card stays pending, renew and a
|
|
34
99
|
title-only metadata edit not moving it, and the updatedAt fallback for legacy cards.
|
|
35
100
|
|
|
101
|
+
### Published
|
|
102
|
+
|
|
103
|
+
- npm: `hive-tasks@1.8.1` on 2026-12-04.
|
|
104
|
+
|
|
36
105
|
## [1.8.0] - 2026-12-04
|
|
37
106
|
|
|
38
107
|
### Added
|
|
@@ -273,4 +342,4 @@ All notable changes to this project are documented here. The format follows
|
|
|
273
342
|
[1.4.0]: https://github.com/d86e/hive-tasks/releases/tag/v1.4.0
|
|
274
343
|
[1.3.0]: https://github.com/d86e/hive-tasks/releases/tag/v1.3.0
|
|
275
344
|
[1.1.0]: https://github.com/d86e/hive-tasks/releases/tag/v1.1.0
|
|
276
|
-
[1.0.0]: https://github.com/d86e/hive-tasks/releases/tag/v1.0.0
|
|
345
|
+
[1.0.0]: https://github.com/d86e/hive-tasks/releases/tag/v1.0.0
|
package/README.md
CHANGED
|
@@ -75,9 +75,12 @@ token-tests-ba66 pending tester token tests
|
|
|
75
75
|
| --- | --- |
|
|
76
76
|
| init | create .hive/ and the hive-tasks section in AGENTS.md |
|
|
77
77
|
| add --title T (--acceptance CMD \| --draft) [--role R] [--scope P] [--after ID] [--review-of ID] [--tag T] [--priority N] [--goal G] [--stage ROLE[:ACCEPTANCE]] [--stages FILE] | create a task; --acceptance is required unless --draft; --review-of links it to the task it tests; --stage/--stages build a stage chain |
|
|
78
|
-
|
|
|
79
|
-
|
|
|
80
|
-
|
|
|
78
|
+
| edit <id> [--title T] [--scope-add P] [--scope-remove P] [--acceptance CMD] [--priority N] [--after-set ID,ID] [--tag +T/-T] [--role R] [--superseded\|--no-superseded] | change only the fields you pass, on a pending or failed task; an empty --acceptance is refused and --acceptance - clears it on a draft; a scope edit syncs the task's announcements |
|
|
79
|
+
| split <id> --into '<json array>' [--keep] [--reason R] [--json] | replace a task with finer cards; the parent is marked superseded unless --keep keeps it and gates the cards on it |
|
|
80
|
+
| supersede <id> --reason R [--replaced-by ID] | retire a task without done/failed; it leaves ready, next and claim |
|
|
81
|
+
| list [--state S] [--role R] [--json] [--limit N] [--cursor C] | every task, or one server-side page (`{ items, total, cursor, hasMore }`) newest stateChangedAt first |
|
|
82
|
+
| show <id> [--json] | one task, its stage chain, the draft and superseded flags, and the resolved role source |
|
|
83
|
+
| ready [--limit N] [--role R] [--json] | pending, non-draft, non-superseded tasks whose dependencies are done, ordered by priority then age |
|
|
81
84
|
| next [--role R] [--json] | the single best candidate |
|
|
82
85
|
| claim <id> --agent A [--ttl 5m] | task CAS, then announce the scope paths on the hive-consensus board |
|
|
83
86
|
| renew <id> [--ttl 5m] | extend a claim so a long but healthy run is not recovered mid-flight |
|
|
@@ -87,7 +90,8 @@ token-tests-ba66 pending tester token tests
|
|
|
87
90
|
| retry <id> [--stage KEY] | failed back to pending (or reset a chain to KEY) |
|
|
88
91
|
| reopen <id> [--reason R] [--agent A] [--stage KEY] | every state back to pending; clears owner, claim, result and verdict, attempt + 1; releases the claim's announcements; a staged task resets to KEY (default the first stage) |
|
|
89
92
|
| rm <id> [--force] [--json] | delete a pending/failed/done task; a claimed task is refused (exit 2) unless --force, which releases its announcements first |
|
|
90
|
-
|
|
|
93
|
+
| counts [--json] | per-state counts, the superseded count and the oldest pending task, from the lightweight index |
|
|
94
|
+
| stats [--json] | counts by state and role, plus the oldest pending task (index-backed) |
|
|
91
95
|
|
|
92
96
|
Exit codes: 0 success, 1 internal error, 2 refused (already claimed, wrong state, unknown
|
|
93
97
|
task, dependency missing, mode freeze, invalid stage chain, missing --acceptance, draft
|
|
@@ -124,7 +128,42 @@ hive-tasks stats
|
|
|
124
128
|
hive-tasks stats --json
|
|
125
129
|
~~~
|
|
126
130
|
|
|
127
|
-
Counts by state and role, plus the oldest pending task.
|
|
131
|
+
Counts by state and role, plus the oldest pending task. Superseded tasks keep their
|
|
132
|
+
lane but are counted separately: `superseded` in the JSON and its own line in the text
|
|
133
|
+
output; they are not part of byState/byRole or the oldest pending task.
|
|
134
|
+
|
|
135
|
+
## Pagination and counts
|
|
136
|
+
|
|
137
|
+
Large boards are served a page at a time. `--limit` and/or `--cursor` switch
|
|
138
|
+
`list` into server-side pagination:
|
|
139
|
+
|
|
140
|
+
~~~bash
|
|
141
|
+
$ hive-tasks list --json --state pending --limit 50 --cursor 0
|
|
142
|
+
{ "items": [ ... ], "total": 1234, "cursor": 50, "hasMore": true }
|
|
143
|
+
$ hive-tasks list --json --state pending --limit 50 --cursor 50 # next page
|
|
144
|
+
~~~
|
|
145
|
+
|
|
146
|
+
- rows are ordered by `stateChangedAt` descending, ties broken by id so a walk is
|
|
147
|
+
deterministic;
|
|
148
|
+
- `cursor` is the numeric offset printed by the previous page; `--limit` must be a
|
|
149
|
+
positive integer (default 50 when only `--cursor` is given), `--cursor` a
|
|
150
|
+
non-negative integer;
|
|
151
|
+
- `total` is the filtered count, so the caller knows how many pages remain;
|
|
152
|
+
- only the page's cards are read from git; filtering, ordering and the total come from
|
|
153
|
+
a lightweight index (`refs/hive/v1/tasks-index`), which is written with every board
|
|
154
|
+
write and rebuilt once when missing or stale.
|
|
155
|
+
|
|
156
|
+
A `list` without `--limit`/`--cursor` keeps returning the full array. `counts --json`
|
|
157
|
+
returns the per-state numbers from that index without parsing any card:
|
|
158
|
+
|
|
159
|
+
~~~bash
|
|
160
|
+
$ hive-tasks counts --json
|
|
161
|
+
{ "total": 1234, "byState": { "pending": 1200, "claimed": 3, "done": 30, "failed": 1 },
|
|
162
|
+
"superseded": 2, "oldestPending": { "id": "auth-token-a1b2", "createdAt": "..." } }
|
|
163
|
+
~~~
|
|
164
|
+
|
|
165
|
+
`show <id> --json` reads exactly that one card blob. `stats` keeps its older shape
|
|
166
|
+
(byState, byRole, superseded, oldestPending) and is index-backed too.
|
|
128
167
|
|
|
129
168
|
## How a claim works
|
|
130
169
|
|
|
@@ -138,6 +177,47 @@ Announcements never refuse a task: two agents may hold two tasks whose scope ove
|
|
|
138
177
|
which is exactly what the queue must allow. merge-on-commit reconciles the two edits at
|
|
139
178
|
commit time; the task is the authority, the announcement is visibility for the board.
|
|
140
179
|
|
|
180
|
+
## Editing, splitting and superseding tasks
|
|
181
|
+
|
|
182
|
+
`edit` changes only the fields you pass, and only on a pending or failed task (a claimed
|
|
183
|
+
task must be done or failed first, a done task reopened first):
|
|
184
|
+
|
|
185
|
+
~~~bash
|
|
186
|
+
$ hive-tasks edit auth-takes-an-object-dea2 --title "auth takes options" --tag +api --priority 5
|
|
187
|
+
$ hive-tasks edit auth-takes-an-object-dea2 --scope-add src/token.ts --scope-remove src/legacy.ts
|
|
188
|
+
$ hive-tasks edit auth-takes-an-object-dea2 --after-set schema-migration-7c1d
|
|
189
|
+
$ hive-tasks edit idea-1a2b --acceptance - # only a draft may clear its acceptance
|
|
190
|
+
$ hive-tasks edit old-plan-1a2b --superseded --reason "replaced" # or --no-superseded
|
|
191
|
+
~~~
|
|
192
|
+
|
|
193
|
+
An empty `--acceptance` is refused; `--acceptance -` clears it on a draft task.
|
|
194
|
+
`--priority` must be an integer, `--after-set` refuses a dependency cycle, and a scope
|
|
195
|
+
edit keeps the task's announcements in sync: added paths are announced under the task's
|
|
196
|
+
announcer (or the editor) and removed paths that a claim of this task wrote are released.
|
|
197
|
+
The edit event stores `{ task, fields }` where `fields` names the changed fields, never
|
|
198
|
+
their values, and stateChangedAt does not move because the lane did not change.
|
|
199
|
+
|
|
200
|
+
`split` replaces one task with at least two finer cards given as a JSON array:
|
|
201
|
+
|
|
202
|
+
~~~bash
|
|
203
|
+
$ hive-tasks split auth-takes-an-object-dea2 --into '[
|
|
204
|
+
{ "title": "auth schema", "scope": ["src/schema.ts"], "acceptance": "npm test -- schema" },
|
|
205
|
+
{ "title": "auth api", "role": "tester" }
|
|
206
|
+
]'
|
|
207
|
+
~~~
|
|
208
|
+
|
|
209
|
+
Each entry takes title (required), role, scope, acceptance and after; missing fields are
|
|
210
|
+
inherited from the parent, and every resulting card must have an acceptance command. The
|
|
211
|
+
parent is marked superseded (its lane is unchanged) and `replacedBy` points at the first
|
|
212
|
+
new card; `--keep` keeps the parent and makes every card list it in `after`, so the cards
|
|
213
|
+
only become ready after the parent is done. `--json` returns `{ task, cards }`; the
|
|
214
|
+
task_split event records the parent and card ids. A claimed or done task cannot be split,
|
|
215
|
+
and splitting an already superseded task is refused.
|
|
216
|
+
|
|
217
|
+
`supersede <id> --reason R [--replaced-by ID]` retires a task without changing its lane:
|
|
218
|
+
it is excluded from ready, next and claim, and stats counts it separately. A superseded
|
|
219
|
+
task is a flag, not a fifth state: its pending/failed/done/claimed lane is unchanged.
|
|
220
|
+
|
|
141
221
|
## When an agent dies
|
|
142
222
|
|
|
143
223
|
Every claim carries claimedUntil (the --ttl, 5 minutes by default). Once it passes, the
|
package/README.zh-CN.md
CHANGED
|
@@ -74,9 +74,12 @@ token-tests-ba66 pending tester token tests
|
|
|
74
74
|
| --- | --- |
|
|
75
75
|
| init | 创建 .hive/,并在 AGENTS.md 里加 hive-tasks 小节 |
|
|
76
76
|
| add --title T (--acceptance CMD \| --draft) [--role R] [--scope P] [--after ID] [--review-of ID] [--tag T] [--priority N] [--goal G] [--stage ROLE[:ACCEPTANCE]] [--stages FILE] | 创建任务;非草稿任务必须带 --acceptance,--draft 创建草稿任务;--review-of 挂到它要评审的任务上;--stage/--stages 建阶段链 |
|
|
77
|
-
|
|
|
78
|
-
|
|
|
79
|
-
|
|
|
77
|
+
| edit <id> [--title T] [--scope-add P] [--scope-remove P] [--acceptance CMD] [--priority N] [--after-set ID,ID] [--tag +T/-T] [--role R] [--superseded\|--no-superseded] | 只改传入的字段,且只对 pending/failed 任务生效;空 --acceptance 被拒,草稿可用 --acceptance - 清空;scope 改动会同步任务自己的公告 |
|
|
78
|
+
| split <id> --into '<json array>' [--keep] [--reason R] [--json] | 用更细的卡替换一张任务;父任务默认标 superseded 并指向第一张新卡,--keep 保留父任务并让新卡以它为前置 |
|
|
79
|
+
| supersede <id> --reason R [--replaced-by ID] | 退休一张任务(不是 done/failed),不再进入 ready、next 和 claim |
|
|
80
|
+
| list [--state S] [--role R] [--json] [--limit N] [--cursor C] | 所有任务,或一页服务端分页结果(`{ items, total, cursor, hasMore }`),stateChangedAt 倒序 |
|
|
81
|
+
| show <id> [--json] | 单个任务、它的阶段链、draft/superseded 标记,以及解析到的角色来源 |
|
|
82
|
+
| ready [--limit N] [--role R] [--json] | 依赖已完成的 pending 非草稿、非 superseded 任务,按优先级、再按时间排序 |
|
|
80
83
|
| next [--role R] [--json] | 只给最优的那一个 |
|
|
81
84
|
| claim <id> --agent A [--ttl 5m] | 先 CAS 任务,再把 scope 路径公告到 hive-consensus 公告看板 |
|
|
82
85
|
| renew <id> [--ttl 5m] | 续期认领,长任务不会被中途回收 |
|
|
@@ -86,7 +89,8 @@ token-tests-ba66 pending tester token tests
|
|
|
86
89
|
| retry <id> [--stage KEY] | failed 回到 pending(或把链复位到 KEY) |
|
|
87
90
|
| reopen <id> [--reason R] [--agent A] [--stage KEY] | 任何状态回到 pending;清 owner、认领、结果与判定,attempt + 1;释放认领时的公告;带阶段的任务复位到 KEY(默认第一阶段) |
|
|
88
91
|
| rm <id> [--force] [--json] | 删除 pending/failed/done 的任务;claimed 的任务默认拒绝(退出码 2),加 --force 会先释放公告再删 |
|
|
89
|
-
|
|
|
92
|
+
| counts [--json] | 各状态计数、superseded 计数和最老 pending 任务,来自轻量索引 |
|
|
93
|
+
| stats [--json] | 按状态和角色计数,外加最老的 pending 任务;superseded 单独计数(同样走索引) |
|
|
90
94
|
|
|
91
95
|
退出码:0 成功,1 内部错误,2 被拒(已被认领、状态不对、任务不存在、依赖缺失、
|
|
92
96
|
模式 freeze、阶段链非法、缺 --acceptance、认领草稿任务)。
|
|
@@ -119,7 +123,37 @@ hive-tasks stats
|
|
|
119
123
|
hive-tasks stats --json
|
|
120
124
|
~~~
|
|
121
125
|
|
|
122
|
-
按状态和角色计数,外加最老的 pending 任务。
|
|
126
|
+
按状态和角色计数,外加最老的 pending 任务。superseded 任务保留原 lane,但单独计数:
|
|
127
|
+
JSON 里是 `superseded`,文本输出单独一行;它们不计入 byState/byRole,也不参与最老 pending。
|
|
128
|
+
|
|
129
|
+
## 分页与计数
|
|
130
|
+
|
|
131
|
+
大看板按页读取。`--limit` 和/或 `--cursor` 会把 `list` 切成服务端分页:
|
|
132
|
+
|
|
133
|
+
~~~bash
|
|
134
|
+
$ hive-tasks list --json --state pending --limit 50 --cursor 0
|
|
135
|
+
{ "items": [ ... ], "total": 1234, "cursor": 50, "hasMore": true }
|
|
136
|
+
$ hive-tasks list --json --state pending --limit 50 --cursor 50 # 下一页
|
|
137
|
+
~~~
|
|
138
|
+
|
|
139
|
+
- 行按 `stateChangedAt` 倒序,时间相同按 id 升序,保证翻页顺序稳定;
|
|
140
|
+
- `cursor` 是上一页返回的数字偏移;`--limit` 必须是正整数(只给 `--cursor` 时默认
|
|
141
|
+
50),`--cursor` 必须是非负整数;
|
|
142
|
+
- `total` 是过滤后的总数,调用方能算出还剩几页;
|
|
143
|
+
- 只读取当前页的卡片 blob;过滤、排序和总数来自轻量索引
|
|
144
|
+
(`refs/hive/v1/tasks-index`),它随每次写板更新,缺失或过期时自动重建一次。
|
|
145
|
+
|
|
146
|
+
不带 `--limit`/`--cursor` 的 `list` 仍返回完整数组。`counts --json` 直接从索引返回
|
|
147
|
+
各状态计数,不解析任何卡片:
|
|
148
|
+
|
|
149
|
+
~~~bash
|
|
150
|
+
$ hive-tasks counts --json
|
|
151
|
+
{ "total": 1234, "byState": { "pending": 1200, "claimed": 3, "done": 30, "failed": 1 },
|
|
152
|
+
"superseded": 2, "oldestPending": { "id": "auth-token-a1b2", "createdAt": "..." } }
|
|
153
|
+
~~~
|
|
154
|
+
|
|
155
|
+
`show <id> --json` 只读取那一张卡的 blob。`stats` 保持原有输出形状
|
|
156
|
+
(byState、byRole、superseded、oldestPending),同样由索引支撑。
|
|
123
157
|
|
|
124
158
|
## claim 怎么走
|
|
125
159
|
|
|
@@ -132,6 +166,42 @@ hive-tasks stats --json
|
|
|
132
166
|
公告永远不拒绝任务:两个智能体可以同时持有 scope 重叠的两个任务,队列本来就该允许这种
|
|
133
167
|
情况。真正撞车的改动由 merge-on-commit 在提交时合并;**任务是权威,公告是看板上的可见性**。
|
|
134
168
|
|
|
169
|
+
## 编辑、拆分与退休任务
|
|
170
|
+
|
|
171
|
+
`edit` 只改传入的字段,且只对 pending/failed 任务生效(claimed 先 done/fail,done 先 reopen):
|
|
172
|
+
|
|
173
|
+
~~~bash
|
|
174
|
+
$ hive-tasks edit auth-takes-an-object-dea2 --title "auth 改成 options" --tag +api --priority 5
|
|
175
|
+
$ hive-tasks edit auth-takes-an-object-dea2 --scope-add src/token.ts --scope-remove src/legacy.ts
|
|
176
|
+
$ hive-tasks edit auth-takes-an-object-dea2 --after-set schema-migration-7c1d
|
|
177
|
+
$ hive-tasks edit idea-1a2b --acceptance - # 只有草稿能清空验收
|
|
178
|
+
$ hive-tasks edit old-plan-1a2b --superseded --reason "replaced" # 或 --no-superseded
|
|
179
|
+
~~~
|
|
180
|
+
|
|
181
|
+
空 `--acceptance` 会被拒绝;`--acceptance -` 仅对草稿任务清空验收。`--priority` 必须是
|
|
182
|
+
整数,`--after-set` 会拒绝依赖环;scope 改动会同步任务自己的公告:新增路径以任务的公告者
|
|
183
|
+
(没有就用编辑者)身份公告,被移除且由这张任务认领写下的公告会被释放。edit 事件形如
|
|
184
|
+
`{ task, fields }`,`fields` 只列变化的字段名,不存字段值;lane 没变,所以 stateChangedAt
|
|
185
|
+
不动。
|
|
186
|
+
|
|
187
|
+
`split` 用 JSON 数组给出的至少两张更细的卡替换一张任务:
|
|
188
|
+
|
|
189
|
+
~~~bash
|
|
190
|
+
$ hive-tasks split auth-takes-an-object-dea2 --into '[
|
|
191
|
+
{ "title": "auth schema", "scope": ["src/schema.ts"], "acceptance": "npm test -- schema" },
|
|
192
|
+
{ "title": "auth api", "role": "tester" }
|
|
193
|
+
]'
|
|
194
|
+
~~~
|
|
195
|
+
|
|
196
|
+
每项可带 title(必填)、role、scope、acceptance、after;缺省字段从父任务继承,且每张新卡
|
|
197
|
+
都必须有验收命令。父任务被标 superseded(lane 不变)并让 `replacedBy` 指向第一张新卡;
|
|
198
|
+
加 `--keep` 时保留父任务,每张新卡的 `after` 都引用它,所以父任务 done 后新卡才 ready。
|
|
199
|
+
`--json` 返回 `{ task, cards }`,task_split 事件记录父子 id。claimed 或 done 的任务不能
|
|
200
|
+
拆分,已 superseded 的任务也不能再拆。
|
|
201
|
+
|
|
202
|
+
`supersede <id> --reason R [--replaced-by ID]` 在不改 lane 的前提下退休一张任务:它不再
|
|
203
|
+
进入 ready、next、claim,stats 单独计数。superseded 是标记而不是第五种状态。
|
|
204
|
+
|
|
135
205
|
## 智能体中途死掉怎么办
|
|
136
206
|
|
|
137
207
|
每次认领都带 claimedUntil(--ttl,默认 5 分钟)。时间一过,这个任务就是**可回收的**:
|
package/SPEC.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# hive-tasks protocol
|
|
2
2
|
|
|
3
|
-
Status: implemented, 1.
|
|
3
|
+
Status: implemented, 1.9.0. Protocol version v1 (task blobs keep `v: 1`).
|
|
4
4
|
|
|
5
5
|
## 1. Scope
|
|
6
6
|
|
|
@@ -10,6 +10,7 @@ defines:
|
|
|
10
10
|
- where a task lives (a git ref, same namespace family as hive);
|
|
11
11
|
- the task blob and its state machine;
|
|
12
12
|
- how a task is claimed, finished and failed, with compare-and-swap;
|
|
13
|
+
- how a task is edited, and how one task is split into subtasks;
|
|
13
14
|
- optional stage chains, so one task can move across roles without being released;
|
|
14
15
|
- what "ready" means, and the CLI surface a dispatcher consumes.
|
|
15
16
|
|
|
@@ -46,6 +47,16 @@ Implementation sketch (plumbing, no working tree involved):
|
|
|
46
47
|
GIT_INDEX_FILE=tmp git write-tree # new tree
|
|
47
48
|
git update-ref refs/hive/v1/tasks <new-tree> <old-tree>
|
|
48
49
|
|
|
50
|
+
A derived index lives next to the tree and is never the source of truth:
|
|
51
|
+
|
|
52
|
+
refs/hive/v1/tasks-index -> blob { v: 1, tasks: <tasks tree sha>, entries: [...] }
|
|
53
|
+
|
|
54
|
+
Each entry is [id, state, role, sortTime(ms), createdAt, superseded]. The blob pins the
|
|
55
|
+
task tree sha it describes: a reader that finds it missing or pinned to another tree
|
|
56
|
+
rebuilds it once from the task tree. A board write refreshes it after the task ref moves,
|
|
57
|
+
so a crash between the two updates only costs one rebuild. `list` pagination, `counts`
|
|
58
|
+
and `stats` read this index instead of parsing every card blob.
|
|
59
|
+
|
|
49
60
|
## 3. Task blob
|
|
50
61
|
|
|
51
62
|
```json
|
|
@@ -98,6 +109,9 @@ Implementation sketch (plumbing, no working tree involved):
|
|
|
98
109
|
| tags | free labels; "fix" is special (see mode) |
|
|
99
110
|
| acceptance | shell command used by done --verify. For a staged task the current stage's acceptance is used first and this command is the fallback. Required when the task is created, unless the task is a draft |
|
|
100
111
|
| draft | optional boolean, stored as true only on a draft task (section 3.2). Normal tasks omit the key entirely. A draft is a flag, not a state: it adds no state of its own and is never dispatched |
|
|
112
|
+
| superseded | optional boolean, stored as true only on a superseded task (section 3.3). Normal tasks omit the key entirely. A superseded task keeps its lane but is never dispatched again |
|
|
113
|
+
| supersededReason | why the task was retired; stored only together with `superseded` |
|
|
114
|
+
| replacedBy | optional id of the card that replaces this one; stored only together with `superseded` |
|
|
101
115
|
| claimedUntil | expiry of the current claim; a claimed task past it is reclaimable |
|
|
102
116
|
| resultCommit | the commit recorded when the task or its current stage was finished |
|
|
103
117
|
| stages | optional ordered stage chain. Absent or [] means a task without stages |
|
|
@@ -170,6 +184,18 @@ and title (`plan[1] ("park the redesign")`). The whole plan is refused before an
|
|
|
170
184
|
is written. An entry may carry both `acceptance` and `"draft": true`; the flag still
|
|
171
185
|
keeps that task out of dispatch.
|
|
172
186
|
|
|
187
|
+
### 3.3 Superseded tasks
|
|
188
|
+
|
|
189
|
+
A superseded task is retired without being marked done or failed. The flag is written by
|
|
190
|
+
`supersede <id> --reason R [--replaced-by ID]` (any lane) or by `edit --superseded` on a
|
|
191
|
+
pending or failed task, and cleared by `edit --no-superseded`. The lane (state, stage,
|
|
192
|
+
stageState) is never changed, so `stateChangedAt` does not move; only `updatedAt` does and
|
|
193
|
+
`replacedBy` records the successor when there is one. A superseded task is excluded from
|
|
194
|
+
ready, next and claim, and `stats` counts it separately (`superseded` in the JSON and its
|
|
195
|
+
own line in the text output) instead of inside byState/byRole. `list`/`show` expose the
|
|
196
|
+
flag and its fields, and `rm` can delete it like any task. A superseded task is not
|
|
197
|
+
a fifth state: pending/claimed/done/failed remain the only stored states.
|
|
198
|
+
|
|
173
199
|
## 4. State machine
|
|
174
200
|
|
|
175
201
|
```
|
|
@@ -219,9 +245,10 @@ task is created, but a later delete can leave that reference dangling on the boa
|
|
|
219
245
|
- done: owner finished and (optionally) a verdict was recorded.
|
|
220
246
|
- failed: the run failed; retry moves it back to pending with attempt preserved.
|
|
221
247
|
|
|
222
|
-
Stored states are pending, claimed, done, failed. ready is always computed. draft
|
|
223
|
-
not
|
|
224
|
-
(
|
|
248
|
+
Stored states are pending, claimed, done, failed. ready is always computed. draft and
|
|
249
|
+
superseded are not states: they are independent boolean flags that only remove a task
|
|
250
|
+
from dispatch (sections 3.2 and 3.3), so the transition table below is unchanged for
|
|
251
|
+
them.
|
|
225
252
|
|
|
226
253
|
A claimed task carries claimedUntil. Once that time passes the task is **reclaimable**:
|
|
227
254
|
claim may take it over exactly as if it were pending, incrementing attempt. This is how
|
|
@@ -295,8 +322,8 @@ Rules:
|
|
|
295
322
|
|
|
296
323
|
A task is ready when:
|
|
297
324
|
|
|
298
|
-
1. the task is not a draft
|
|
299
|
-
whatever its state;
|
|
325
|
+
1. the task is not a draft or superseded: either flag keeps it out of every dispatch
|
|
326
|
+
computation, whatever its state;
|
|
300
327
|
2. state is pending (or a claim expired and is reclaimable);
|
|
301
328
|
3. every id in after exists and is done;
|
|
302
329
|
4. hive mode is free, or the task is tagged "fix" (the fix must be able to run while the
|
|
@@ -326,12 +353,18 @@ see the same order; the claim CAS still gives exactly one winner per task.
|
|
|
326
353
|
[--after ID]... [--goal G] [--review-of ID] [--tag T]...
|
|
327
354
|
[--priority N] [--stage ROLE[:ACCEPTANCE]]... [--stages FILE]
|
|
328
355
|
hive-tasks plan [--file plan.json] # no --file reads the plan from stdin
|
|
329
|
-
hive-tasks list [--json] [--state S] [--role R]
|
|
356
|
+
hive-tasks list [--json] [--state S] [--role R] [--limit N] [--cursor C]
|
|
357
|
+
hive-tasks counts [--json]
|
|
330
358
|
hive-tasks ready [--json] [--limit N] [--role R]
|
|
331
359
|
hive-tasks next [--role R] [--json] # the single best candidate, or null
|
|
332
360
|
hive-tasks show <id> [--json] # task plus resolved role source
|
|
333
361
|
hive-tasks claim <id> --agent A [--ttl 5m] [--force]
|
|
334
362
|
hive-tasks renew <id> [--ttl 5m]
|
|
363
|
+
hive-tasks edit <id> [--title T] [--scope-add P]... [--scope-remove P]...
|
|
364
|
+
[--acceptance CMD] [--priority N] [--after-set ID,ID]
|
|
365
|
+
[--tag +T|-T]... [--role R]
|
|
366
|
+
hive-tasks split <id> --into '<json array>' [--keep] [--reason R] [--json]
|
|
367
|
+
hive-tasks supersede <id> --reason R [--replaced-by ID]
|
|
335
368
|
hive-tasks done <id> [--sha S] [--verdict pass|fail] [--verify]
|
|
336
369
|
hive-tasks fail <id> --reason R
|
|
337
370
|
hive-tasks retry <id> [--stage KEY]
|
|
@@ -359,6 +392,19 @@ per-stage acceptance in one shot. The two flags are mutually exclusive.
|
|
|
359
392
|
Exit codes: 0 success; 1 internal error; 2 refused (already claimed, wrong state,
|
|
360
393
|
dependency missing, mode freeze, invalid stage chain, missing --acceptance, draft claim).
|
|
361
394
|
|
|
395
|
+
`list --json --state S --role R --limit N --cursor C` returns one server-side page:
|
|
396
|
+
`{ items, total, cursor, hasMore }`. Rows are ordered by stateChangedAt descending
|
|
397
|
+
(ties by id ascending); `cursor` is the numeric offset printed by the previous page (a
|
|
398
|
+
cursor at or past the total yields an empty page); --limit must be a positive integer
|
|
399
|
+
(default 50 when only --cursor is passed) and --cursor a non-negative integer. `total`
|
|
400
|
+
is the filtered count, and only the page's card blobs are read. A list without
|
|
401
|
+
--limit/--cursor keeps returning the array of all matching tasks.
|
|
402
|
+
|
|
403
|
+
`counts --json` returns `{ total, byState, superseded, oldestPending }` from the
|
|
404
|
+
lightweight index without parsing card blobs; superseded tasks are counted separately and
|
|
405
|
+
do not appear inside byState. `stats` keeps its shape (byState, byRole, superseded,
|
|
406
|
+
oldestPending) and is index-backed too. `show <id> --json` reads exactly one card blob.
|
|
407
|
+
|
|
362
408
|
claim couples the task with the hive-consensus announcement board, task first:
|
|
363
409
|
|
|
364
410
|
1. CAS the task from pending to claimed (this is what picks the single winner);
|
|
@@ -386,6 +432,34 @@ deletes pending, failed and done tasks, and refuses a claimed task (exit 2) unle
|
|
|
386
432
|
--force, which releases the claim's announcements first; it prints the deleted task
|
|
387
433
|
(with `deleted: true`) under --json.
|
|
388
434
|
|
|
435
|
+
`edit <id>` rewrites only the fields that are passed: --title, --scope-add,
|
|
436
|
+
--scope-remove, --acceptance, --priority, --after-set (a comma list that replaces the
|
|
437
|
+
dependencies; an empty value clears it), --tag +T/-T (repeatable), --role and
|
|
438
|
+
`--superseded`/`--no-superseded`. It only works on a pending or failed task (a claimed
|
|
439
|
+
task must be done or failed first, a done task reopened first). An empty --acceptance is
|
|
440
|
+
refused; `--acceptance -` clears the command on a draft task only; --priority must be an
|
|
441
|
+
integer; --after-set refuses a dependency cycle. Edit never moves the lane, so
|
|
442
|
+
stateChangedAt is untouched (only updatedAt moves and, with --superseded, the superseded
|
|
443
|
+
fields). A scope edit syncs the task's announcements: added paths are announced under the
|
|
444
|
+
task announcer (or the editor) and removed paths that a claim of this task wrote are
|
|
445
|
+
released. The task_edit event carries `fields`, an object whose keys are the changed field
|
|
446
|
+
names; values are never stored.
|
|
447
|
+
|
|
448
|
+
`split <id> --into '<json array>' [--keep] [--reason R] [--json]` replaces one task with
|
|
449
|
+
at least two finer cards. Every entry is an object with title (required), role, scope,
|
|
450
|
+
acceptance and after; missing values are inherited from the parent and every resulting
|
|
451
|
+
card must have an acceptance command. Without --keep the parent is marked superseded with
|
|
452
|
+
the reason (default "split into N") and replacedBy pointing at the first card; with --keep
|
|
453
|
+
the parent keeps its lane and every card lists it in after, so the cards only become ready
|
|
454
|
+
after the parent is done. A claimed or done task cannot be split, and an already
|
|
455
|
+
superseded task cannot be split again. --json returns { task, cards }; the task_split
|
|
456
|
+
event carries the parent id as task and the new card ids as cards.
|
|
457
|
+
|
|
458
|
+
`supersede <id> --reason R [--replaced-by ID]` marks a task superseded without changing
|
|
459
|
+
its lane (section 3.3). It is refused when the task is already superseded, and
|
|
460
|
+
--replaced-by must name an existing, different task. The task_supersede event carries the
|
|
461
|
+
reason and, when present, replacedBy.
|
|
462
|
+
|
|
389
463
|
## 7. Role resolution (dispatchers)
|
|
390
464
|
|
|
391
465
|
A dispatcher needs an adapter, a model and a prompt for the role that works a task.
|
|
@@ -433,12 +507,20 @@ staged done and a failed review add extra lines, see below):
|
|
|
433
507
|
```
|
|
434
508
|
|
|
435
509
|
kinds: task_add, task_claim, task_done, task_fail, task_retry, task_renew, task_plan,
|
|
436
|
-
task_delete, reopen, review_failed, stage_done,
|
|
437
|
-
stage_rewound.
|
|
510
|
+
task_edit, task_split, task_supersede, task_delete, reopen, review_failed, stage_done,
|
|
511
|
+
stage_failed, stage_advanced, stage_rewound.
|
|
438
512
|
|
|
439
513
|
`task_delete` records the removed task: it carries both `task` and `id` (the task id),
|
|
440
514
|
`state` (the state the task had when it was deleted) and `actor`.
|
|
441
515
|
|
|
516
|
+
`task_edit` carries `fields`, an object whose keys are the names of the fields the edit
|
|
517
|
+
changed (the values only mark that a field changed; old and new values are never stored).
|
|
518
|
+
|
|
519
|
+
`task_split` carries the parent id as `task`, the new card ids as `cards`, `kept` (true
|
|
520
|
+
when --keep preserved the parent) and, when the parent was replaced, `replacedBy`.
|
|
521
|
+
|
|
522
|
+
`task_supersede` carries `task`, `reason` and, when given, `replacedBy`.
|
|
523
|
+
|
|
442
524
|
A review task that fails appends review_failed for the review itself (with reviewOf and
|
|
443
525
|
reopened); when it sends an upstream task back to pending, a reopen event is appended
|
|
444
526
|
too.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hive-tasks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.0",
|
|
4
4
|
"description": "Task cards for agent teams: one git tree behind one ref, with a state machine, optional stage chains, role resolution, dependencies and hive leases.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|