hive-tasks 1.4.0 → 1.5.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 +25 -0
- package/README.md +19 -0
- package/README.zh-CN.md +18 -0
- package/SPEC.md +19 -3
- package/package.json +1 -1
- package/src/cli.js +38 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,26 @@ 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
|
+
## [1.5.0] - 2026-12-04
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `rm <id> [--force] [--json]`: delete a task card. pending, failed, blocked and done
|
|
12
|
+
cards are removed by one compare-and-swap on refs/hive/v1/tasks, which drops the
|
|
13
|
+
card's blob from the tree. A claimed card is refused with exit 2 and a hint to
|
|
14
|
+
release or reopen it first; `--force` releases exactly that claim's hive leases
|
|
15
|
+
before deleting, so a forced delete never strands a lease. An unknown id is exit 2
|
|
16
|
+
and a second delete reports "no such task" instead of succeeding silently, so the
|
|
17
|
+
command is never a silent idempotent.
|
|
18
|
+
- Events: `task_delete`, carrying the card id, its state before the delete and the actor.
|
|
19
|
+
|
|
20
|
+
### Tests
|
|
21
|
+
|
|
22
|
+
- 40 node:test scenarios: the original 34 unchanged, plus test/delete.test.mjs covering
|
|
23
|
+
every deletable state, blob removal, the claimed refusal and its lease, --force lease
|
|
24
|
+
release, the task_delete event, unknown ids, the non-idempotent second delete and
|
|
25
|
+
--json output.
|
|
26
|
+
|
|
7
27
|
## [1.4.0] - 2026-12-04
|
|
8
28
|
|
|
9
29
|
### Added
|
|
@@ -43,6 +63,10 @@ All notable changes to this project are documented here. The format follows
|
|
|
43
63
|
chain advance, cross-role routing, onFail rewind, reopen --stage, claim gating, legacy
|
|
44
64
|
cards, the three-tier resolveRole fallback, show role source and per-stage acceptance.
|
|
45
65
|
|
|
66
|
+
### Published
|
|
67
|
+
|
|
68
|
+
- npm: `hive-tasks@1.4.0` on 2026-12-04.
|
|
69
|
+
|
|
46
70
|
## [1.3.0] - 2026-12-04
|
|
47
71
|
|
|
48
72
|
### Added
|
|
@@ -124,6 +148,7 @@ All notable changes to this project are documented here. The format follows
|
|
|
124
148
|
- SPEC.md and RFC-0001 (why one tree, why the queue is derived).
|
|
125
149
|
- 9 node:test scenarios, including two concurrent claims.
|
|
126
150
|
|
|
151
|
+
[1.5.0]: https://github.com/d86e/hive-tasks/releases/tag/v1.5.0
|
|
127
152
|
[1.4.0]: https://github.com/d86e/hive-tasks/releases/tag/v1.4.0
|
|
128
153
|
[1.3.0]: https://github.com/d86e/hive-tasks/releases/tag/v1.3.0
|
|
129
154
|
[1.1.0]: https://github.com/d86e/hive-tasks/releases/tag/v1.1.0
|
package/README.md
CHANGED
|
@@ -77,6 +77,7 @@ token-tests-ba66 pending tester token tests
|
|
|
77
77
|
| retry <id> [--stage KEY] | failed or blocked back to pending (or reset a chain to KEY) |
|
|
78
78
|
| block <id> --reason R / unblock <id> | park a card without losing it |
|
|
79
79
|
| 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 leases; a staged card resets to KEY (default the first stage) |
|
|
80
|
+
| rm <id> [--force] [--json] | delete a pending/failed/blocked/done card; a claimed card is refused (exit 2) unless --force, which releases its leases first |
|
|
80
81
|
|
|
81
82
|
Exit codes: 0 done, 1 internal error, 2 refused (already claimed, wrong state, dependency missing, mode freeze, path busy).
|
|
82
83
|
|
|
@@ -125,6 +126,24 @@ $ hive-tasks claim slow-task-1a2b --agent agent-B # attempt 2, owner agent-B
|
|
|
125
126
|
|
|
126
127
|
A long but healthy run calls renew to keep its claim.
|
|
127
128
|
|
|
129
|
+
## Deleting a card
|
|
130
|
+
|
|
131
|
+
Remove a card that should not stay on the board:
|
|
132
|
+
|
|
133
|
+
~~~bash
|
|
134
|
+
$ hive-tasks rm stale-card-1a2b
|
|
135
|
+
stale-card-1a2b deleted [pending] stale card
|
|
136
|
+
|
|
137
|
+
$ hive-tasks rm working-card-9f8e
|
|
138
|
+
hive-tasks: task working-card-9f8e is claimed by agent-A; release or reopen it first, or use --force # exit 2
|
|
139
|
+
$ hive-tasks rm working-card-9f8e --force # releases the claim's leases, then deletes
|
|
140
|
+
~~~
|
|
141
|
+
|
|
142
|
+
pending, failed, blocked and done cards are deletable. A claimed card is protected on
|
|
143
|
+
purpose: delete it with --force, which releases exactly that claim's hive leases first, so
|
|
144
|
+
no lease is stranded. An unknown id is exit 2, and a second delete reports "no such task"
|
|
145
|
+
instead of pretending to succeed.
|
|
146
|
+
|
|
128
147
|
## Acceptance and freeze
|
|
129
148
|
|
|
130
149
|
A card may carry an acceptance command. It is **not** executed by default, because a card
|
package/README.zh-CN.md
CHANGED
|
@@ -77,6 +77,7 @@ token-tests-ba66 pending tester token 测试
|
|
|
77
77
|
| retry <id> [--stage KEY] | failed 或 blocked 回到 pending(或把链复位到 KEY) |
|
|
78
78
|
| block <id> --reason R / unblock <id> | 挂起而不丢卡 |
|
|
79
79
|
| reopen <id> [--reason R] [--agent A] [--stage KEY] | 任何状态回到 pending;清 owner、认领、结果与判定,attempt + 1;释放认领时的租约;带阶段的卡复位到 KEY(默认第一阶段) |
|
|
80
|
+
| rm <id> [--force] [--json] | 删除 pending/failed/blocked/done 的卡;claimed 的卡默认拒绝(退出码 2),加 --force 会先释放租约再删 |
|
|
80
81
|
|
|
81
82
|
退出码:0 成功,1 内部错误,2 被拒(已被认领、状态不对、依赖缺失、模式 freeze、路径忙)。
|
|
82
83
|
|
|
@@ -121,6 +122,23 @@ $ hive-tasks claim slow-task-1a2b --agent agent-B # attempt 2,owner agent-
|
|
|
121
122
|
|
|
122
123
|
跑得久的健康任务用 renew 续期。
|
|
123
124
|
|
|
125
|
+
## 删除卡片
|
|
126
|
+
|
|
127
|
+
不再需要的卡可以删掉:
|
|
128
|
+
|
|
129
|
+
~~~bash
|
|
130
|
+
$ hive-tasks rm stale-card-1a2b
|
|
131
|
+
stale-card-1a2b deleted [pending] stale card
|
|
132
|
+
|
|
133
|
+
$ hive-tasks rm working-card-9f8e
|
|
134
|
+
hive-tasks: task working-card-9f8e is claimed by agent-A; release or reopen it first, or use --force # 退出码 2
|
|
135
|
+
$ hive-tasks rm working-card-9f8e --force # 先释放认领时的租约,再删除
|
|
136
|
+
~~~
|
|
137
|
+
|
|
138
|
+
pending、failed、blocked、done 的卡都可以删。claimed 的卡是**故意保护**的:要加
|
|
139
|
+
--force 才删,并且会先释放这次认领持有的 hive 租约,不会留下孤儿租约。未知 id 退出码
|
|
140
|
+
为 2;第二次删除会报 "no such task",不会静默成功。
|
|
141
|
+
|
|
124
142
|
## 验收与冻结
|
|
125
143
|
|
|
126
144
|
卡片可以带一条验收命令。**默认不执行**——卡片是仓库内容,默认执行等于让别人 push 一段代码就能在你机器上跑:
|
package/SPEC.md
CHANGED
|
@@ -151,6 +151,14 @@ claimed card releases its hive leases, so no orphan lease is left behind. On a s
|
|
|
151
151
|
card reopen always resets the chain (default first stage, --stage KEY selects another),
|
|
152
152
|
including a card that is currently pending.
|
|
153
153
|
|
|
154
|
+
`rm` is the only destructive command: it removes the card's blob from the task tree in
|
|
155
|
+
one CAS. pending, failed, blocked and done cards are deletable. A claimed card is refused
|
|
156
|
+
(exit 2, with a hint to release or reopen it) unless --force is given; --force releases
|
|
157
|
+
exactly that claim's hive leases and then deletes the card, so a forced delete cannot
|
|
158
|
+
strand a lease. Deleting a card is not idempotent: an unknown id is exit 2, and a second
|
|
159
|
+
`rm` of the same id reports "no such task". Cards that named the deleted id in `after`
|
|
160
|
+
now have a missing dependency, which the ready computation reports as a data error.
|
|
161
|
+
|
|
154
162
|
| From | Command | To | Effect |
|
|
155
163
|
| --- | --- | --- | --- |
|
|
156
164
|
| pending | claim | claimed | CAS winner; attempt + 1 |
|
|
@@ -166,6 +174,8 @@ including a card that is currently pending.
|
|
|
166
174
|
| blocked | reopen | pending | attempt + 1 |
|
|
167
175
|
| pending | reopen | pending | no-op (exit 0) |
|
|
168
176
|
| any stored state | block | blocked | block accepts any state |
|
|
177
|
+
| pending/failed/blocked/done | rm | deleted | removes the blob in one CAS |
|
|
178
|
+
| claimed | rm --force | deleted | releases the claim's leases, then removes the blob |
|
|
169
179
|
|
|
170
180
|
- pending: exists, dependencies not satisfied (or no capacity to run it).
|
|
171
181
|
- ready: pending with every id in after in state done. Computed, never stored.
|
|
@@ -285,6 +295,7 @@ see the same order; the claim CAS still gives exactly one winner per card.
|
|
|
285
295
|
hive-tasks block <id> --reason R
|
|
286
296
|
hive-tasks unblock <id>
|
|
287
297
|
hive-tasks reopen <id> [--reason R] [--stage KEY]
|
|
298
|
+
hive-tasks rm <id> [--force] [--json]
|
|
288
299
|
|
|
289
300
|
`--stage ROLE[:ACCEPTANCE]` is repeatable: each flag adds one stage in order, and the
|
|
290
301
|
stage key is derived from the role (duplicates become role-2, role-3...). `--stages
|
|
@@ -309,7 +320,9 @@ the leases and keeps the attempt counter. retry accepts failed or blocked and re
|
|
|
309
320
|
card to pending (or resets the chain to a stage). block accepts any state; unblock
|
|
310
321
|
accepts blocked. reopen accepts every stored state, returns the card to pending and
|
|
311
322
|
releases a claimed card's leases (section 4). add --review-of links a review card to its
|
|
312
|
-
upstream (section 4.1).
|
|
323
|
+
upstream (section 4.1). rm deletes pending, failed, blocked and done cards, and refuses a
|
|
324
|
+
claimed card (exit 2) unless --force, which releases the claim's leases first; it prints
|
|
325
|
+
the deleted card (with `deleted: true`) under --json.
|
|
313
326
|
|
|
314
327
|
## 7. Role resolution (dispatchers)
|
|
315
328
|
|
|
@@ -355,8 +368,11 @@ Each command appends one line to .hive/events.jsonl:
|
|
|
355
368
|
```
|
|
356
369
|
|
|
357
370
|
kinds: task_add, task_claim, task_done, task_fail, task_retry, task_block,
|
|
358
|
-
task_unblock, task_renew, task_plan, reopen, review_failed, stage_done,
|
|
359
|
-
stage_advanced, stage_rewound.
|
|
371
|
+
task_unblock, task_renew, task_plan, task_delete, reopen, review_failed, stage_done,
|
|
372
|
+
stage_failed, stage_advanced, stage_rewound.
|
|
373
|
+
|
|
374
|
+
`task_delete` records the removed card: it carries both `task` and `id` (the card id),
|
|
375
|
+
`state` (the state the card had when it was deleted) and `actor`.
|
|
360
376
|
|
|
361
377
|
A review card that fails appends two extra events: reopen for the upstream card it sends
|
|
362
378
|
back to pending, and review_failed for the review itself (with reviewOf and reopened).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hive-tasks",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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": {
|
package/src/cli.js
CHANGED
|
@@ -47,6 +47,7 @@ const USAGE = [
|
|
|
47
47
|
" hive-tasks reopen <id> [--reason R] [--agent A] [--stage KEY]",
|
|
48
48
|
" any state back to pending, attempt+1; a staged card",
|
|
49
49
|
" resets to KEY (default the first stage)",
|
|
50
|
+
" hive-tasks rm <id> [--force] [--json] delete a card; a claimed card needs --force",
|
|
50
51
|
"",
|
|
51
52
|
"ENVIRONMENT",
|
|
52
53
|
" HIVE_AGENT=name identity used for claims",
|
|
@@ -315,6 +316,43 @@ function run(argv) {
|
|
|
315
316
|
return printTask(reopened, options.json);
|
|
316
317
|
}
|
|
317
318
|
|
|
319
|
+
if (command === "rm") {
|
|
320
|
+
const id = options.args[0];
|
|
321
|
+
if (!id) fail("rm needs a task id", 2);
|
|
322
|
+
const agent = options.agent || process.env.HIVE_AGENT || "unknown";
|
|
323
|
+
const current = readTask(repo, id);
|
|
324
|
+
if (!current) fail("no such task: " + id, 2);
|
|
325
|
+
if (current.state === "claimed" && !options.force) {
|
|
326
|
+
fail("task " + id + " is claimed by " + (current.owner || "another agent") + "; release or reopen it first, or use --force", 2);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// The blob is removed by the same CAS that reads the board, so a card that
|
|
330
|
+
// moved meanwhile (another writer, a concurrent claim) is re-checked
|
|
331
|
+
// instead of racing the tree write.
|
|
332
|
+
let deleted = null;
|
|
333
|
+
try {
|
|
334
|
+
const result = mutate(repo, (tasks) => {
|
|
335
|
+
const task = byId(tasks).get(id);
|
|
336
|
+
if (!task) throw new Error("no such task: " + id);
|
|
337
|
+
if (task.state === "claimed" && !options.force) {
|
|
338
|
+
throw new Error("task " + id + " is claimed by " + (task.owner || "another agent") + "; release or reopen it first, or use --force");
|
|
339
|
+
}
|
|
340
|
+
deleted = task;
|
|
341
|
+
return tasks.filter((entry) => entry.id !== id);
|
|
342
|
+
});
|
|
343
|
+
if (!result.ok) fail("could not delete " + id + " (too much contention)");
|
|
344
|
+
} catch (error) {
|
|
345
|
+
fail(error.message, 2);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// --force deletes a claimed card only after releasing exactly the leases
|
|
349
|
+
// that claim holds, so a forced delete cannot strand them.
|
|
350
|
+
if (deleted.state === "claimed") releaseLeases(repo, { paths: deleted.scope, agent: deleted.owner || agent });
|
|
351
|
+
append(repo, { actor: agent, kind: "task_delete", task: id, id, state: deleted.state });
|
|
352
|
+
if (options.json) return process.stdout.write(JSON.stringify({ ...viewTask(deleted), deleted: true }, null, 2) + "\n");
|
|
353
|
+
return process.stdout.write(id + " deleted [" + deleted.state + "] " + deleted.title + "\n");
|
|
354
|
+
}
|
|
355
|
+
|
|
318
356
|
if (command === "add") {
|
|
319
357
|
if (!options.title) fail("--title is required", 2);
|
|
320
358
|
if (options.reviewOf && !readTask(repo, options.reviewOf)) fail("no such task: " + options.reviewOf, 2);
|