Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

feat(api): renew held next moves and document HTTP [A1,A2,B4,N2]

Corey Olson29677f7b3635
diff --git a/docs/api.md b/docs/api.md
index 5db94c47..59c6b084 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -15,7 +15,7 @@ A successful command returns the fields listed below. `version` is always the nu
| `hooks` | `version:number`, `notes:array` |
| `join` | `version:number`, `agent:string`, `lane:string`, `route:string`, `path:string` |
| `worktree` | `version:number`, `agent:string`, `lane:string`, `route:string`, `path:string`, `branch:string`, `prompt:string` |
-| `resume` | `version:number`, `me:object`, `all:array`, `holding:array`, `sentBack:array`, `awaiting:array`, `toVerify:array`, `toMerge:array`, `open:array`, `holds:array`, `unread:number`, `newest:array`, `root:string`, `dirty:number`, `next:string` |
+| `resume` | `version:number`, `me:object`, `all:array`, `requests:array`, `holding:array`, `sentBack:array`, `awaiting:array`, `toVerify:array`, `toMerge:array`, `open:array`, `holds:array`, `unread:number`, `newest:array`, `root:string`, `dirty:number`, `next:string` |
| `whoami` | `version:number`, `id:string`, `lane:string`, `path:string` |
| `lanes` | `version:number`, `lanes:object`, `shared:array`, `coordinator:string` |
| `list` | `version:number`, `items:array` |
@@ -46,6 +46,7 @@ A successful command returns the fields listed below. `version` is always the nu
| `tour` | `version:number`, `messages:array` |
| `lifecycle` | `version:number`, `markdown:string` |
| `view` | `version:number`, `url:string`, `port:number` |
+| `serve` | `version:number`, `url:string`, `port:number` |
| `forget` | `version:number`, `root:string` |
| `prompt` | `version:number`, `role:string`, `text:string` |
| `gate` | `version:number`, `green:boolean`, `report:string` |
@@ -83,3 +84,34 @@ A refusal keeps the command's existing exit status and prints exactly one versio
<!-- api-refusal-shapes:end -->
The result and refusal tables are checked against `JSON_SHAPES` in `src/json.js` by `docs/api.test.js`.
+
+## Local HTTP API v1
+
+Run `pullboard serve --port 0` to print a private API address on `127.0.0.1`. Authenticate each call with the address's `k` query parameter, an `X-Pullboard-Key` header, or `Authorization: Bearer <key>`. The secret belongs to that server session. Board ids are random 128-bit values stored in each board; reopening or moving a repo preserves its id.
+
+| Method and path | Result |
+| --- | --- |
+| `GET /api/v1/boards` | Registered boards with their project details and ids |
+| `GET /api/v1/boards/:board/state` | The view's board state, including open coordinator requests |
+| `GET /api/v1/boards/:board/events?after=N` | Events after sequence N, in order |
+| `POST /api/v1/boards/:board/moves` | One CLI move and its emitted event |
+| `POST /api/v1/boards/:board/requests` | A person's request for the coordinator |
+
+<!-- api-http-shapes:start -->
+| Response | Required top-level fields |
+| --- | --- |
+| `boards` | `version:number`, `boards:array` |
+| `state` | `version:number`, `state:object` |
+| `events` | `version:number`, `events:array` |
+| `move` | `version:number`, `event:object`, `result:object` |
+| `request` | `version:number`, `event:object`, `result:object` |
+| `stream` | `version:number`, `event:object` |
+<!-- api-http-shapes:end -->
+
+A move body is `{verb, item, args, agent}`. `item` is the positive integer id when the move needs one. `args` names its CLI positional arguments and flags; text values stay literal, including leading dashes. Omit `agent` to act as the coordinator, or name a registered agent to run in its worktree. Coordinator verification takes `args.as: "coordinator"`, matching the CLI's explicit identity check. The local session secret may act as any agent on that board. `result` is the CLI's JSON result. `next` claims work atomically; when a claim is already held it renews it and returns the renewal event. With no work available it returns the CLI's `NOTHING_FREE` refusal. Waiting remains a CLI option.
+
+A request body is `{text}`. It creates a request from the person to the coordinator. Open requests stay first in coordinator `resume` and `inbox` until answered `done`, or `declined` with a reason, and do not count as open decisions.
+
+For live events, send `Accept: text/event-stream` to the events path. Each message's `id` is its event sequence and its `data` has the `stream` shape above. Reconnect with `Last-Event-ID` to resume after that sequence; it takes precedence over `after`.
+
+HTTP refusals use the same versioned error envelope above: 400 for malformed calls, 401 for a missing or wrong session secret, 403 for an agent belonging to another board, 404 for an unknown board or path, and 409 for the CLI engine's refusal. Shouts and answers append their events in the same transaction as their records. A move returns its own event, including when it also sends a coordinator shout.
diff --git a/docs/api.test.js b/docs/api.test.js
index 56baa7de..3aeb31d9 100644
--- a/docs/api.test.js
+++ b/docs/api.test.js
@@ -37,4 +37,10 @@ test('[A1] API guide documents every CLI result and refusal shape from the sourc
assert.deepEqual(documentedRefusals.envelope, JSON_SHAPES.error.required);
assert.deepEqual(documentedRefusals.error, JSON_SHAPES.errorFields);
assert.deepEqual(Object.keys(documentedRefusals).sort(), ['envelope', 'error']);
-});
\ No newline at end of file
+});
+
+test('[A2] API guide documents the local HTTP response catalog', () => {
+ const documented = readShapeTable('<!-- api-http-shapes:start -->', '<!-- api-http-shapes:end -->');
+ const source = Object.fromEntries(Object.entries(JSON_SHAPES.http).map(([name, shape]) => [name, shape.required]));
+ assert.deepEqual(documented, source);
+});
diff --git a/src/cli.js b/src/cli.js
index eb09d083..3917d086 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -1092,14 +1092,14 @@ function nextOnce(ctx, values) {
const warm = warmFiles(ctx, board, me);
const { item, reasons, shared } = store.nextFor(board, { agentId: me.id, lane: me.lane, runnable: values.runnable, routes: values.routes, warm });
if (!item) return { reasons };
- if (item.item_status === 'claimed') return { item, held: true };
+ const held = item.item_status === 'claimed';
try {
store.claim(board, item.item_id, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: freezer(ctx), head: headCommit(ctx.info.root) });
} catch (error) {
if (error instanceof Refused && ['HELD', 'BLOCKED', 'ONE_CLAIM'].includes(error.code)) return { retry: true };
throw error;
}
- return { item: store.getItem(board, item.item_id), shared };
+ return { item: store.getItem(board, item.item_id), shared, held };
});
}
diff --git a/test/api.test.js b/test/api.test.js
index 3b3e5d59..28ceb8c7 100644
--- a/test/api.test.js
+++ b/test/api.test.js
@@ -524,11 +524,19 @@ test('[A2] moves run as the named worktree agent and requests stay visible until
assert.equal(claimed.event.event_kind, 'claim');
assert.equal(claimed.result.item.item_id, added.result.item.item_id);
+ const renewedResponse = await apiFetch(api, `${path}/moves`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ verb: 'next', args: {}, agent: 'app-1' }) });
+ assert.equal(renewedResponse.status, 200);
+ const renewed = await renewedResponse.json();
+ assert.equal(renewed.result.held, true);
+ assert.equal(renewed.event.event_kind, 'renew');
+ assert.ok(renewed.event.event_id > claimed.event.event_id);
+ assert.equal(renewed.result.item.item_id, claimed.result.item.item_id);
+
const escalatedResponse = await apiFetch(api, `${path}/moves`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ verb: 'escalate', item: added.result.item.item_id, args: { note: 'Two attempts failed' }, agent: 'app-1' }) });
assert.equal(escalatedResponse.status, 200);
const escalated = await escalatedResponse.json();
assert.equal(escalated.event.event_kind, 'escalate', 'a move returns its own event even when it also sends a coordinator shout');
- const afterEscalation = (await (await apiFetch(api, `${path}/events?after=${claimed.event.event_id}`)).json()).events;
+ const afterEscalation = (await (await apiFetch(api, `${path}/events?after=${renewed.event.event_id}`)).json()).events;
assert.deepEqual(afterEscalation.map((event) => event.event_kind), ['escalate', 'shout']);
assert.equal(afterEscalation[0].event_id, escalated.event.event_id);