hive-tasks 1.7.0 → 1.9.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 +110 -0
- package/README.md +181 -70
- package/README.zh-CN.md +173 -74
- package/SPEC.md +252 -117
- package/package.json +1 -1
- package/src/cli.js +446 -12
- package/src/lease.js +12 -0
- package/src/task.js +32 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,112 @@ 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
|
+
## Unreleased
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- Documentation aligned with the current implementation. README.md, README.zh-CN.md and
|
|
12
|
+
SPEC.md now use "task" throughout, describe the four states (pending, claimed, done,
|
|
13
|
+
failed), the required `--acceptance`/`--draft` rule, drafts as a flag, stage chains
|
|
14
|
+
and role fallback, `stateChangedAt`, reopen/review-of and `rm`. Statements without
|
|
15
|
+
code support were corrected (for example the missing-dependency "data error", the
|
|
16
|
+
"never starts a process" claim and the generated id length). No behaviour or protocol
|
|
17
|
+
change.
|
|
18
|
+
|
|
19
|
+
## [1.9.0] - 2026-12-04
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
|
|
23
|
+
- `edit <id>` with `--title`, `--scope-add`/`--scope-remove`, `--acceptance`,
|
|
24
|
+
`--priority`, `--after-set`, `--tag +T/-T`, `--role` and `--superseded`/
|
|
25
|
+
`--no-superseded`. It only works on pending or failed tasks and changes only the
|
|
26
|
+
fields passed. An empty `--acceptance` is refused; `--acceptance -` clears it on a
|
|
27
|
+
draft task; `--priority` must be an integer; `--after-set` refuses a dependency cycle.
|
|
28
|
+
A scope edit keeps the task's announcements in sync (added paths are announced under
|
|
29
|
+
the task announcer and removed paths a claim of the task wrote are released). An edit
|
|
30
|
+
never moves the lane, so `stateChangedAt` is untouched.
|
|
31
|
+
- `supersede <id> --reason R [--replaced-by ID]`: retire a task without marking it done
|
|
32
|
+
or failed. The flag keeps the lane but removes the task from ready, next and claim,
|
|
33
|
+
and stats counts superseded tasks separately. `edit --superseded`/`--no-superseded`
|
|
34
|
+
sets and clears the same flag on a pending or failed task.
|
|
35
|
+
- `split <id> --into '<json array>' [--keep] [--reason R] [--json]`: replace a task with
|
|
36
|
+
at least two cards described by `{title, role?, scope?, acceptance?, after?}`. Missing
|
|
37
|
+
values are inherited from the parent and every card needs an acceptance command.
|
|
38
|
+
Without --keep the parent is marked superseded and points at the first card via
|
|
39
|
+
replacedBy; with --keep it keeps its lane and every card lists it in after. Claimed or
|
|
40
|
+
done tasks cannot be split. --json returns `{ task, cards }`.
|
|
41
|
+
- Events: `task_edit` (`{ task, fields }` where fields names the changed fields, never
|
|
42
|
+
their values), `task_split` (`{ task, cards, kept, replacedBy? }`) and
|
|
43
|
+
`task_supersede` (`{ task, reason, replacedBy? }`).
|
|
44
|
+
|
|
45
|
+
### Tests
|
|
46
|
+
|
|
47
|
+
- 62 node:test scenarios: the 52 from 1.8.1 unchanged, plus ten in
|
|
48
|
+
test/edit-split.test.mjs covering per-field edits and the `{ task, fields }` event,
|
|
49
|
+
pending/failed-only edits, integer priority, dependency cycles and the superseded
|
|
50
|
+
toggle, scope announcement sync, the acceptance rules, a JSON-array split that
|
|
51
|
+
supersedes the parent, `--keep` gating, split refusals, `supersede` with
|
|
52
|
+
`--replaced-by`, and stats counting a superseded done task separately.
|
|
53
|
+
|
|
54
|
+
### Published
|
|
55
|
+
|
|
56
|
+
- Not published to npm in this change.
|
|
57
|
+
|
|
58
|
+
## [1.8.1] - 2026-12-04
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
- `stateChangedAt` (ISO timestamp) on every card: the last time the card really moved
|
|
63
|
+
lane or stage (claim, done, fail, retry, reopen and stage transitions, including a
|
|
64
|
+
stage advance that keeps the card pending). Metadata-only updates such as renew leave
|
|
65
|
+
it unchanged. list/show/next/ready JSON expose it.
|
|
66
|
+
- Legacy cards written before 1.8.1 have no field; the read side falls back to
|
|
67
|
+
`updatedAt`.
|
|
68
|
+
|
|
69
|
+
### Tests
|
|
70
|
+
|
|
71
|
+
- 52 node:test scenarios: the 48 from 1.8.0 unchanged, plus test/state-changed.test.mjs
|
|
72
|
+
covering lane changes, a stage advance while the card stays pending, renew and a
|
|
73
|
+
title-only metadata edit not moving it, and the updatedAt fallback for legacy cards.
|
|
74
|
+
|
|
75
|
+
### Published
|
|
76
|
+
|
|
77
|
+
- npm: `hive-tasks@1.8.1` on 2026-12-04.
|
|
78
|
+
|
|
79
|
+
## [1.8.0] - 2026-12-04
|
|
80
|
+
|
|
81
|
+
### Added
|
|
82
|
+
|
|
83
|
+
- Draft cards: `add --draft` creates a card without an acceptance command and stores
|
|
84
|
+
`draft: true` on the blob (normal cards omit the key entirely). draft is a flag, not a
|
|
85
|
+
state: the card keeps pending/claimed/done/failed, but ready, next and every
|
|
86
|
+
dispatch-ready computation exclude it, and claim refuses it with exit 2 and a clear
|
|
87
|
+
message. list/show expose the flag in JSON and text.
|
|
88
|
+
- `plan --file plan.json` accepts `"draft": true` per entry. Every entry without an
|
|
89
|
+
acceptance command and without `"draft": true` is rejected before anything is
|
|
90
|
+
written; the refusal names the offending entry as `plan[N] ("title")`.
|
|
91
|
+
|
|
92
|
+
### Changed
|
|
93
|
+
|
|
94
|
+
- `add` now mechanically requires `--acceptance` unless `--draft` is passed:
|
|
95
|
+
`add: --acceptance is required (or pass --draft for a draft card)`, exit 2. The rule
|
|
96
|
+
also applies to staged cards; per-stage acceptance still overrides the card command
|
|
97
|
+
for done --verify.
|
|
98
|
+
- USAGE, README.md, README.zh-CN.md and SPEC.md document the required acceptance, the
|
|
99
|
+
draft field and the dispatch rule; the CI smoke test creates its card with --acceptance.
|
|
100
|
+
|
|
101
|
+
### Tests
|
|
102
|
+
|
|
103
|
+
- 48 node:test scenarios. The 43 scenarios from 1.7.0 were updated to create cards with
|
|
104
|
+
--acceptance where they only exercised another behaviour; five new scenarios in
|
|
105
|
+
test/draft.test.mjs cover the add refusal and both escapes, the stored flag (and its
|
|
106
|
+
absence on normal cards), ready/next exclusion and claim refusal for plain and staged
|
|
107
|
+
drafts, plan rejection naming the entry, and draft entries in a plan.
|
|
108
|
+
|
|
109
|
+
### Published
|
|
110
|
+
|
|
111
|
+
- Not published to npm in this change.
|
|
112
|
+
|
|
7
113
|
## [1.7.0] - 2026-12-04
|
|
8
114
|
|
|
9
115
|
### Changed
|
|
@@ -27,6 +133,10 @@ All notable changes to this project are documented here. The format follows
|
|
|
27
133
|
by different agents (both claimed, both visible on the hive board, overlap reported)
|
|
28
134
|
and release ownership for a superseded announcement.
|
|
29
135
|
|
|
136
|
+
### Published
|
|
137
|
+
|
|
138
|
+
- npm: `hive-tasks@1.7.0` on 2026-12-04.
|
|
139
|
+
|
|
30
140
|
## [1.6.0] - 2026-12-04
|
|
31
141
|
|
|
32
142
|
### Changed
|
package/README.md
CHANGED
|
@@ -5,16 +5,16 @@
|
|
|
5
5
|
[](https://github.com/d86e/hive-tasks/actions/workflows/ci.yml)
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
|
|
8
|
-
**When several agents share a repository, "what is left to do, in what order, and who is doing it" lives in a chat prompt and dies with the session. hive-tasks makes it a query: every unit of work is a
|
|
8
|
+
**When several agents share a repository, "what is left to do, in what order, and who is doing it" lives in a chat prompt and dies with the session. hive-tasks makes it a query: every unit of work is a task in one git tree, behind one ref, with a state machine, optional stage chains, dependencies and a role.**
|
|
9
9
|
|
|
10
10
|
```
|
|
11
11
|
refs/hive/v1/tasks -> tree
|
|
12
|
-
auth-token-a1b2 -> blob (the
|
|
12
|
+
auth-token-a1b2 -> blob (the task)
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
No server, no database, no queue process. A claim is a compare-and-swap on that one ref, so exactly one agent wins a
|
|
15
|
+
No server, no database, no queue process. A claim is a compare-and-swap on that one ref, so exactly one agent wins a task; the paths it touches are announced on the [hive-consensus](https://github.com/d86e/hive-consensus) board, where overlaps are visible information rather than a refusal.
|
|
16
16
|
|
|
17
|
-
> ~1,
|
|
17
|
+
> ~1,600 lines, zero dependencies, Node.js >= 22.19, git >= 2.40
|
|
18
18
|
|
|
19
19
|
**Built for**: agent teams that already coordinate with hive; a queen that hands out work; a dispatcher that needs a stable list instead of a conversation.
|
|
20
20
|
|
|
@@ -26,20 +26,28 @@ No server, no database, no queue process. A claim is a compare-and-swap on that
|
|
|
26
26
|
|
|
27
27
|
An agent crashes mid-run. Was task 4 done? Nobody knows. Another agent finishes a task and the queen's list is stale. Two agents pick up "the tests" because both read the same paragraph.
|
|
28
28
|
|
|
29
|
-
A
|
|
29
|
+
A task fixes that: it has an id, a state, an owner, an attempt count and a verdict. The answer to "what is left" is a command, not a memory.
|
|
30
30
|
|
|
31
31
|
## Install
|
|
32
32
|
|
|
33
|
+
hive-tasks needs Node.js >= 22.19 and git >= 2.40. `init` creates `.hive/` and adds a
|
|
34
|
+
short hive-tasks section to `AGENTS.md`:
|
|
35
|
+
|
|
33
36
|
```bash
|
|
34
37
|
npx hive-tasks init
|
|
35
|
-
npx hive-tasks add --title "auth takes an object" --role coder --scope src/auth.ts
|
|
38
|
+
npx hive-tasks add --title "auth takes an object" --role coder --scope src/auth.ts --acceptance "npm test -- auth"
|
|
36
39
|
```
|
|
37
40
|
|
|
41
|
+
`--acceptance` is required for every task that is not a draft: a task has to say how it
|
|
42
|
+
will be judged.
|
|
43
|
+
|
|
38
44
|
## 60-second demo
|
|
39
45
|
|
|
40
46
|
```bash
|
|
41
|
-
$ hive-tasks add --title "auth takes an object" --role coder --scope src/auth.ts
|
|
47
|
+
$ hive-tasks add --title "auth takes an object" --role coder --scope src/auth.ts --acceptance "npm test -- auth"
|
|
42
48
|
auth-takes-an-object-dea2 [pending] auth takes an object
|
|
49
|
+
role: coder owner: - attempt: 0
|
|
50
|
+
scope: src/auth.ts
|
|
43
51
|
|
|
44
52
|
$ hive-tasks ready
|
|
45
53
|
auth-takes-an-object-dea2 pending coder auth takes an object
|
|
@@ -47,11 +55,12 @@ auth-takes-an-object-dea2 pending coder auth takes an object
|
|
|
47
55
|
$ hive-tasks claim auth-takes-an-object-dea2 --agent agent-A
|
|
48
56
|
auth-takes-an-object-dea2 [claimed] auth takes an object
|
|
49
57
|
role: coder owner: agent-A attempt: 1
|
|
58
|
+
scope: src/auth.ts
|
|
50
59
|
|
|
51
60
|
$ hive-tasks claim auth-takes-an-object-dea2 --agent agent-B
|
|
52
61
|
hive-tasks: task auth-takes-an-object-dea2 is claimed # exit 2
|
|
53
62
|
|
|
54
|
-
$ hive-tasks add --title "token tests" --role tester --after auth-takes-an-object-dea2
|
|
63
|
+
$ hive-tasks add --title "token tests" --role tester --after auth-takes-an-object-dea2 --acceptance "npm test -- token"
|
|
55
64
|
$ hive-tasks ready
|
|
56
65
|
Nothing ready.
|
|
57
66
|
|
|
@@ -64,33 +73,50 @@ token-tests-ba66 pending tester token tests
|
|
|
64
73
|
|
|
65
74
|
| Command | Effect |
|
|
66
75
|
| --- | --- |
|
|
67
|
-
|
|
|
68
|
-
|
|
|
69
|
-
|
|
|
70
|
-
|
|
|
71
|
-
|
|
|
72
|
-
|
|
|
73
|
-
|
|
|
74
|
-
|
|
|
75
|
-
|
|
|
76
|
+
| init | create .hive/ and the hive-tasks section in AGENTS.md |
|
|
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
|
+
| 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] | every task, drafts and superseded ones included |
|
|
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 |
|
|
84
|
+
| next [--role R] [--json] | the single best candidate |
|
|
85
|
+
| claim <id> --agent A [--ttl 5m] | task CAS, then announce the scope paths on the hive-consensus board |
|
|
86
|
+
| renew <id> [--ttl 5m] | extend a claim so a long but healthy run is not recovered mid-flight |
|
|
87
|
+
| done <id> [--sha S] [--verdict pass\|fail] [--verify] | finish, release the claim's announcements, record resultCommit; on a staged task it opens the next stage; --verify runs the current stage acceptance first |
|
|
88
|
+
| plan --file plan.json | create a whole dependency tree in one transaction; entries take title, key, acceptance (or "draft": true), role, scope, after, priority, tags, goal and stages |
|
|
76
89
|
| fail <id> --reason R | failure is data: attempt stays; a stage with a done onFail target rewinds instead |
|
|
77
90
|
| retry <id> [--stage KEY] | failed back to pending (or reset a chain to KEY) |
|
|
78
|
-
| 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
|
|
79
|
-
| rm <id> [--force] [--json] | delete a pending/failed/done
|
|
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) |
|
|
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 |
|
|
93
|
+
| stats [--json] | counts by state and role, plus the oldest pending task |
|
|
94
|
+
|
|
95
|
+
Exit codes: 0 success, 1 internal error, 2 refused (already claimed, wrong state, unknown
|
|
96
|
+
task, dependency missing, mode freeze, invalid stage chain, missing --acceptance, draft
|
|
97
|
+
claim).
|
|
80
98
|
|
|
81
|
-
|
|
99
|
+
## Timestamps
|
|
100
|
+
|
|
101
|
+
Each task stores `stateChangedAt`, the ISO time it last really moved lane or stage (lane =
|
|
102
|
+
state plus current stage and stage state). Claiming a pending task, done, fail, retry,
|
|
103
|
+
reopen and stage transitions move it when they change the lane, including a stage advance
|
|
104
|
+
that keeps the task pending. Anything that leaves the lane alone — renew, an external
|
|
105
|
+
title or goal edit, or reclaiming an expired claim while the task stays claimed — leaves
|
|
106
|
+
it unchanged. list, ready, next and show JSON expose it; tasks written before 1.8.1 have
|
|
107
|
+
no such field and readers fall back to `updatedAt`.
|
|
82
108
|
|
|
83
109
|
## Resource keys
|
|
84
110
|
|
|
85
|
-
scope entries are usually paths, but the
|
|
86
|
-
works. Use a prefix for shared things that are not files:
|
|
111
|
+
scope entries are usually paths, but the announcement layer does not care: any stable
|
|
112
|
+
string works. Use a prefix for shared things that are not files:
|
|
87
113
|
|
|
88
114
|
~~~bash
|
|
89
|
-
hive-tasks add --title "run the dev server" --scope src/web --scope resource:port:3000
|
|
90
|
-
hive-tasks add --title "migrate" --scope resource:db:dev
|
|
115
|
+
hive-tasks add --title "run the dev server" --acceptance "curl -sf localhost:3000/health" --scope src/web --scope resource:port:3000
|
|
116
|
+
hive-tasks add --title "migrate" --acceptance "npm run migrate:verify" --scope resource:db:dev
|
|
91
117
|
~~~
|
|
92
118
|
|
|
93
|
-
Two
|
|
119
|
+
Two tasks that name the same resource can be claimed at the same time: the claim
|
|
94
120
|
announces the key and reports an existing live announcement as an overlap. Nothing else
|
|
95
121
|
is required: no daemon watches ports, and no claim is refused because of one.
|
|
96
122
|
|
|
@@ -101,25 +127,68 @@ hive-tasks stats
|
|
|
101
127
|
hive-tasks stats --json
|
|
102
128
|
~~~
|
|
103
129
|
|
|
104
|
-
Counts by state and role, plus the oldest pending
|
|
130
|
+
Counts by state and role, plus the oldest pending task. Superseded tasks keep their
|
|
131
|
+
lane but are counted separately: `superseded` in the JSON and its own line in the text
|
|
132
|
+
output; they are not part of byState/byRole or the oldest pending task.
|
|
105
133
|
|
|
106
134
|
## How a claim works
|
|
107
135
|
|
|
108
|
-
1. the
|
|
109
|
-
2. every scope path is announced on the hive-consensus
|
|
136
|
+
1. the task CAS moves pending -> claimed in the task tree (one winner per task);
|
|
137
|
+
2. every scope path is announced on the hive-consensus announcement board; the latest
|
|
110
138
|
announcement wins and a live announcement by another agent is reported as an
|
|
111
139
|
overlap;
|
|
112
|
-
3. done, fail,
|
|
140
|
+
3. done, fail, reopen and rm --force release the announcements their claim owns.
|
|
113
141
|
|
|
114
|
-
Announcements never refuse a
|
|
142
|
+
Announcements never refuse a task: two agents may hold two tasks whose scope overlaps,
|
|
115
143
|
which is exactly what the queue must allow. merge-on-commit reconciles the two edits at
|
|
116
|
-
commit time; the
|
|
144
|
+
commit time; the task is the authority, the announcement is visibility for the board.
|
|
145
|
+
|
|
146
|
+
## Editing, splitting and superseding tasks
|
|
147
|
+
|
|
148
|
+
`edit` changes only the fields you pass, and only on a pending or failed task (a claimed
|
|
149
|
+
task must be done or failed first, a done task reopened first):
|
|
150
|
+
|
|
151
|
+
~~~bash
|
|
152
|
+
$ hive-tasks edit auth-takes-an-object-dea2 --title "auth takes options" --tag +api --priority 5
|
|
153
|
+
$ hive-tasks edit auth-takes-an-object-dea2 --scope-add src/token.ts --scope-remove src/legacy.ts
|
|
154
|
+
$ hive-tasks edit auth-takes-an-object-dea2 --after-set schema-migration-7c1d
|
|
155
|
+
$ hive-tasks edit idea-1a2b --acceptance - # only a draft may clear its acceptance
|
|
156
|
+
$ hive-tasks edit old-plan-1a2b --superseded --reason "replaced" # or --no-superseded
|
|
157
|
+
~~~
|
|
158
|
+
|
|
159
|
+
An empty `--acceptance` is refused; `--acceptance -` clears it on a draft task.
|
|
160
|
+
`--priority` must be an integer, `--after-set` refuses a dependency cycle, and a scope
|
|
161
|
+
edit keeps the task's announcements in sync: added paths are announced under the task's
|
|
162
|
+
announcer (or the editor) and removed paths that a claim of this task wrote are released.
|
|
163
|
+
The edit event stores `{ task, fields }` where `fields` names the changed fields, never
|
|
164
|
+
their values, and stateChangedAt does not move because the lane did not change.
|
|
165
|
+
|
|
166
|
+
`split` replaces one task with at least two finer cards given as a JSON array:
|
|
167
|
+
|
|
168
|
+
~~~bash
|
|
169
|
+
$ hive-tasks split auth-takes-an-object-dea2 --into '[
|
|
170
|
+
{ "title": "auth schema", "scope": ["src/schema.ts"], "acceptance": "npm test -- schema" },
|
|
171
|
+
{ "title": "auth api", "role": "tester" }
|
|
172
|
+
]'
|
|
173
|
+
~~~
|
|
174
|
+
|
|
175
|
+
Each entry takes title (required), role, scope, acceptance and after; missing fields are
|
|
176
|
+
inherited from the parent, and every resulting card must have an acceptance command. The
|
|
177
|
+
parent is marked superseded (its lane is unchanged) and `replacedBy` points at the first
|
|
178
|
+
new card; `--keep` keeps the parent and makes every card list it in `after`, so the cards
|
|
179
|
+
only become ready after the parent is done. `--json` returns `{ task, cards }`; the
|
|
180
|
+
task_split event records the parent and card ids. A claimed or done task cannot be split,
|
|
181
|
+
and splitting an already superseded task is refused.
|
|
182
|
+
|
|
183
|
+
`supersede <id> --reason R [--replaced-by ID]` retires a task without changing its lane:
|
|
184
|
+
it is excluded from ready, next and claim, and stats counts it separately. A superseded
|
|
185
|
+
task is a flag, not a fifth state: its pending/failed/done/claimed lane is unchanged.
|
|
117
186
|
|
|
118
187
|
## When an agent dies
|
|
119
188
|
|
|
120
189
|
Every claim carries claimedUntil (the --ttl, 5 minutes by default). Once it passes, the
|
|
121
|
-
|
|
122
|
-
pending, incrementing attempt. No operator
|
|
190
|
+
task is **reclaimable**: the next agent that claims it takes over as if the task were
|
|
191
|
+
pending, incrementing attempt. No operator and no manual cleanup:
|
|
123
192
|
|
|
124
193
|
~~~bash
|
|
125
194
|
$ hive-tasks claim slow-task-1a2b --agent agent-A --ttl 1s
|
|
@@ -130,28 +199,30 @@ $ hive-tasks claim slow-task-1a2b --agent agent-B # attempt 2, owner agent-B
|
|
|
130
199
|
|
|
131
200
|
A long but healthy run calls renew to keep its claim.
|
|
132
201
|
|
|
133
|
-
## Deleting a
|
|
202
|
+
## Deleting a task
|
|
134
203
|
|
|
135
|
-
Remove a
|
|
204
|
+
Remove a task that should not stay on the board:
|
|
136
205
|
|
|
137
206
|
~~~bash
|
|
138
|
-
$ hive-tasks rm stale-
|
|
139
|
-
stale-
|
|
207
|
+
$ hive-tasks rm stale-task-1a2b
|
|
208
|
+
stale-task-1a2b deleted [pending] stale task
|
|
140
209
|
|
|
141
|
-
$ hive-tasks rm working-
|
|
142
|
-
hive-tasks: task working-
|
|
143
|
-
$ hive-tasks rm working-
|
|
210
|
+
$ hive-tasks rm working-task-9f8e
|
|
211
|
+
hive-tasks: task working-task-9f8e is claimed by agent-A; release or reopen it first, or use --force # exit 2
|
|
212
|
+
$ hive-tasks rm working-task-9f8e --force # releases the claim's announcements, then deletes
|
|
144
213
|
~~~
|
|
145
214
|
|
|
146
|
-
pending, failed and done
|
|
147
|
-
purpose: delete it with --force, which
|
|
148
|
-
|
|
149
|
-
instead of pretending to
|
|
215
|
+
pending, failed and done tasks are deletable, and so is a draft task (draft is a flag,
|
|
216
|
+
not a state). A claimed task is protected on purpose: delete it with --force, which
|
|
217
|
+
releases exactly that claim's announcements first, so no announcement is stranded. An
|
|
218
|
+
unknown id is exit 2, and a second delete reports "no such task" instead of pretending to
|
|
219
|
+
succeed.
|
|
150
220
|
|
|
151
221
|
## Acceptance and freeze
|
|
152
222
|
|
|
153
|
-
|
|
154
|
-
is repository content and executing it would
|
|
223
|
+
Every new task must carry an acceptance command, or be created as a draft. The command is
|
|
224
|
+
**not** executed by default, because a task is repository content and executing it would
|
|
225
|
+
mean running code someone else pushed:
|
|
155
226
|
|
|
156
227
|
~~~bash
|
|
157
228
|
$ hive-tasks add --title "auth takes an object" --acceptance "npm test -- auth"
|
|
@@ -159,38 +230,76 @@ $ hive-tasks done auth-takes-an-object-dea2 --verify # runs it, records res
|
|
|
159
230
|
$ hive-tasks done auth-takes-an-object-dea2 # records resultCommit only
|
|
160
231
|
~~~
|
|
161
232
|
|
|
162
|
-
|
|
163
|
-
|
|
233
|
+
The rule is mechanical: add without either flag exits 2 and writes no task.
|
|
234
|
+
|
|
235
|
+
~~~bash
|
|
236
|
+
$ hive-tasks add --title "auth takes an object"
|
|
237
|
+
hive-tasks: add: --acceptance is required (or pass --draft for a draft card) # exit 2
|
|
238
|
+
~~~
|
|
239
|
+
|
|
240
|
+
When hive mode is freeze, ready returns only tasks tagged fix and claim refuses anything
|
|
241
|
+
else (exit 2) unless --force is passed, so the hotfix can run while the pipeline is red.
|
|
242
|
+
Everything else waits.
|
|
243
|
+
|
|
244
|
+
## Draft tasks
|
|
245
|
+
|
|
246
|
+
Use --draft for work that should be on the board but must not be picked up yet. It skips
|
|
247
|
+
the acceptance requirement and stores `draft: true` on the blob (a normal task omits the
|
|
248
|
+
key entirely):
|
|
249
|
+
|
|
250
|
+
~~~bash
|
|
251
|
+
$ hive-tasks add --title "auth takes an object" --draft
|
|
252
|
+
auth-takes-an-object-dea2 [pending] auth takes an object
|
|
253
|
+
role: worker owner: - attempt: 0
|
|
254
|
+
draft: true (never ready, not claimable)
|
|
255
|
+
~~~
|
|
256
|
+
|
|
257
|
+
draft is a **flag, not a state**: it adds no fifth state and changes no transition, so a
|
|
258
|
+
draft task stays pending (claim refuses it with exit 2) and ready and next never return
|
|
259
|
+
it. list and show expose the flag. There is no un-draft command: to dispatch a parked
|
|
260
|
+
task, remove it and add it again with --acceptance.
|
|
261
|
+
|
|
262
|
+
plan --file takes the same rule per entry, and every entry may instead opt out with
|
|
263
|
+
"draft": true; a missing acceptance refuses the whole plan and names the entry:
|
|
264
|
+
|
|
265
|
+
~~~json
|
|
266
|
+
[
|
|
267
|
+
{ "key": "impl", "title": "implement auth", "acceptance": "npm test" },
|
|
268
|
+
{ "key": "idea", "title": "park the redesign", "draft": true }
|
|
269
|
+
]
|
|
270
|
+
~~~
|
|
164
271
|
|
|
165
|
-
## Review
|
|
272
|
+
## Review tasks
|
|
166
273
|
|
|
167
|
-
A review
|
|
274
|
+
A review task tests another task. Link it when you create it:
|
|
168
275
|
|
|
169
276
|
~~~bash
|
|
170
|
-
$ hive-tasks add --title "review auth" --role reviewer --review-of auth-takes-an-object-dea2
|
|
277
|
+
$ hive-tasks add --title "review auth" --role reviewer --review-of auth-takes-an-object-dea2 --acceptance "npm test -- auth"
|
|
171
278
|
~~~
|
|
172
279
|
|
|
173
280
|
reviewOf is stored, and the upstream id is added to after, so the review only becomes
|
|
174
|
-
ready once the implementation is done. When the review fails
|
|
175
|
-
reopened automatically (attempt + 1, reason "test failed: ...")
|
|
176
|
-
becomes failed and can be retried
|
|
281
|
+
ready once the implementation is done. When the review fails and the upstream is done,
|
|
282
|
+
the upstream task is reopened automatically (attempt + 1, reason "test failed: ...")
|
|
283
|
+
while the review task becomes failed and can be retried; if the upstream is missing or not
|
|
284
|
+
done, the review still fails and nothing is reopened. A passing review leaves the upstream
|
|
285
|
+
alone.
|
|
177
286
|
|
|
178
287
|
## Stage chains
|
|
179
288
|
|
|
180
|
-
One
|
|
289
|
+
One task can carry an ordered chain of stages instead of a single role. Every stage has a
|
|
181
290
|
role, an optional acceptance command and an optional onFail target:
|
|
182
291
|
|
|
183
292
|
~~~bash
|
|
184
|
-
$ hive-tasks add --title "ship auth" --stage coder --stage tester:"npm test" --stage reviewer
|
|
293
|
+
$ hive-tasks add --title "ship auth" --acceptance "npm test" --stage coder --stage tester:"npm test" --stage reviewer
|
|
185
294
|
$ hive-tasks claim ship-auth-1a2b --agent agent-A # the coder stage
|
|
186
|
-
$ hive-tasks done ship-auth-1a2b # stage done, next stage opens,
|
|
187
|
-
$ hive-tasks ready --role tester # the same
|
|
295
|
+
$ hive-tasks done ship-auth-1a2b # stage done, next stage opens, task stays pending
|
|
296
|
+
$ hive-tasks ready --role tester # the same task, now routed to the tester
|
|
188
297
|
~~~
|
|
189
298
|
|
|
190
299
|
done marks the current stage done and opens the next one, releasing the claim but not the
|
|
191
|
-
|
|
192
|
-
so two agents cannot work two stages at once. --stages FILE
|
|
193
|
-
per-stage acceptance and onFail in one JSON array:
|
|
300
|
+
task; only the last stage finishes the task. claim accepts only the current pending stage
|
|
301
|
+
(or an expired claim on it), so two agents cannot work two stages at once. --stages FILE
|
|
302
|
+
writes explicit keys, per-stage acceptance and onFail in one JSON array:
|
|
194
303
|
|
|
195
304
|
~~~json
|
|
196
305
|
[
|
|
@@ -200,14 +309,16 @@ per-stage acceptance and onFail in one JSON array:
|
|
|
200
309
|
~~~
|
|
201
310
|
|
|
202
311
|
When a stage with onFail fails and its target is done, the chain rewinds: the target and
|
|
203
|
-
|
|
204
|
-
earlier role instead of dying. fail without a usable onFail
|
|
205
|
-
reopen --stage KEY (default the first stage) resets a chain so
|
|
206
|
-
|
|
312
|
+
every later stage become pending again (the failed stage is kept as history), attempt + 1,
|
|
313
|
+
and the task is ready for the earlier role instead of dying. fail without a usable onFail
|
|
314
|
+
still fails the whole task. reopen --stage KEY (default the first stage) resets a chain so
|
|
315
|
+
it can run again. Tasks
|
|
316
|
+
created without stages keep the old single-implicit-stage behaviour and store no stage
|
|
317
|
+
fields.
|
|
207
318
|
|
|
208
319
|
## Role resolution
|
|
209
320
|
|
|
210
|
-
A role is a free string, never an enum, so resolving one must never refuse a
|
|
321
|
+
A role is a free string, never an enum, so resolving one must never refuse a task. show
|
|
211
322
|
prints where the role came from:
|
|
212
323
|
|
|
213
324
|
~~~bash
|
|
@@ -226,7 +337,7 @@ resolveRole(repo, name) tries three tiers and never throws:
|
|
|
226
337
|
|
|
227
338
|
show --json returns the whole resolution as roleResolved ({ name, source, adapter, model,
|
|
228
339
|
prompt, args, stage }) plus roleSource, so a runner or supervisor can consume it directly;
|
|
229
|
-
claim never refuses a
|
|
340
|
+
claim never refuses a task because its role is not configured.
|
|
230
341
|
|
|
231
342
|
## Works with
|
|
232
343
|
|
|
@@ -238,15 +349,15 @@ claim never refuses a card because its role is not configured.
|
|
|
238
349
|
|
|
239
350
|
## Design
|
|
240
351
|
|
|
241
|
-
- [SPEC.md](SPEC.md): ref layout,
|
|
352
|
+
- [SPEC.md](SPEC.md): ref layout, task schema, state machine, claim algorithm, exit codes.
|
|
242
353
|
- [docs/RFC-0001-task-cards.md](docs/RFC-0001-task-cards.md): why one tree instead of one ref per task, and why the queue is derived.
|
|
243
354
|
|
|
244
355
|
## Limits
|
|
245
356
|
|
|
246
357
|
- **Not a scheduler.** It never starts an agent; a dispatcher reads ready/next and spawns.
|
|
247
358
|
- **One ref means one writer at a time.** Claims serialize and retry; that is intended.
|
|
248
|
-
- **No per-
|
|
249
|
-
- **Single repository.**
|
|
359
|
+
- **No per-task history.** Use .hive/events.jsonl, or turn on reflog for the one ref.
|
|
360
|
+
- **Single repository.** Tasks do not cross repositories.
|
|
250
361
|
|
|
251
362
|
## License
|
|
252
363
|
|