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(merge): the board state sends item summaries [A2,N26]

Corey Olsonabb4b9f06be9
diff --cc docs/api.test.js
index 15e65e70,32654801..4a018925
--- a/docs/api.test.js
+++ b/docs/api.test.js
@@@ -45,8 -45,10 +45,12 @@@ test('[A2] API guide documents the loca
assert.deepEqual(documented, source);
assert.match(guide, /`warnings` with its registry display fields and a versioned refusal/);
assert.match(guide, /`GET \/api\/v1\/boards\/:board\/state\?seen=N`/);
+ assert.match(guide, /`GET \/api\/v1\/boards\/:board\/state\?detail=full`/);
+ assert.match(guide, /`GET \/api\/v1\/boards\/:board\/items\/:id`/);
+ assert.match(guide, /`GET \/api\/v1\/boards\/:board\/items\?q=text`/);
+ assert.match(guide, /`ITEM_NOT_AVAILABLE`/);
assert.match(guide, /`GET \/api\/v1\/boards\/:board\/code\?ref=path:lines@commit&before=\.\.\.`/);
assert.match(guide, /`CODE_NOT_AVAILABLE` refusal/);
+ assert.match(guide, /`event: changed` with `data: \{"version":1,"event":\{"event_kind":"changed"\}\}`/);
+ assert.match(guide, /notification has no `id` and does not move the reconnect cursor/);
});
diff --cc src/api.js
index 26c85c65,1a311490..d7d741b4
--- a/src/api.js
+++ b/src/api.js
@@@ -10,7 -10,8 +10,8 @@@ import { codeIsFromMain, repoInfo, reso
import { refusalDocument } from './json.js';
import { relayLinked, relayOperation, relayRevoke, relayTokens } from './relay.js';
import { laneNames } from './lanes.js';
+ import { MACHINE } from './machine.js';
-import { listApiProjects } from './projects.js';
+import { listApiProjects, registryFile } from './projects.js';
import { milestoneRoadmap } from './roadmap.js';
import { proofStats } from './stats.js';
import { prepareFlowHistory, projectFlowStats } from './stats-flow.js';
@@@ -542,10 -376,12 +654,12 @@@ async function createRequest(root, body
}, isMain);
}
- /** Share the local router with the person's view; the standalone API explicitly denies person authority. */
- export function createLocalApiHandler({ secret, getPort, runCommand, projects = listApiProjects, isMain, allowedOrigins = [], onStateBuild, personChannel = 'view' } = {}) {
-/** Create the authenticated local adapter used by the HTTP server and other local transports. */
-export function createLocalApiHandler({ secret, getPort, runCommand, projects = listApiProjects, isMain, allowedOrigins = [], onStateBuild, stateDetail = 'full' } = {}) {
++/** Share the local router with the person's view and other local transports; the standalone API explicitly denies person authority. */
++export function createLocalApiHandler({ secret, getPort, runCommand, projects = listApiProjects, isMain, allowedOrigins = [], onStateBuild, personChannel = 'view', stateDetail = 'full' } = {}) {
if (typeof getPort !== 'function') throw new TypeError('createLocalApiHandler needs a bound-port getter');
if (typeof runCommand !== 'function') throw new TypeError('createLocalApiHandler needs the actual CLI entry point as runCommand');
+ // A page that still reads each item's detail from the state keeps full items until it opts in.
+ if (!['full', 'summary'].includes(stateDetail)) throw new TypeError('createLocalApiHandler stateDetail is full or summary');
const codeIsMain = codeIsFromMain() && isMain !== false;
const key = Buffer.from(secret);
const permittedOrigins = new Set(allowedOrigins);
@@@ -593,9 -454,10 +732,11 @@@
},
boards: () => apiBoardListing(projects, codeIsMain),
board: (id) => findBoard(id, projects, codeIsMain),
- state: (board, who, seen) => localState(board, seen).state,
- stateJson: (board, who, seen) => localState(board, seen).json,
+ state: (board, who, seen, options) => localState(board, seen, options).state,
+ stateJson: (board, who, seen, options) => localState(board, seen, options).json,
+ watchRevision: (board) => watchLocalStateRevision(board),
+ item: (board, id) => localItem(board, id),
+ search: (board, text) => localSearch(board, text),
shout: (board, id) => relayLinked(board.root)
? relayPresentationShout(board.root, id)
: withBoard(board.root, (db) => store.shoutDetails(db, id), codeIsMain),
@@@ -609,12 -471,14 +750,15 @@@
});
}
- /** Serve the RFC 0002 API only on loopback, behind the same session-secret boundary as the view. */
- export function serveApi({ port = 0, secret = randomBytes(18).toString('base64url'), runCommand, projects = listApiProjects, isMain, onStateBuild } = {}) {
+ /**
+ * Serve the RFC 0002 API only on loopback, behind the same session-secret boundary as the view. Its
+ * state sends item summaries unless asked for detail=full; each item's detail has its own path (A2).
+ */
+ export function serveApi({ port = 0, secret = randomBytes(18).toString('base64url'), runCommand, projects = listApiProjects, isMain, onStateBuild, stateDetail = 'summary' } = {}) {
if (typeof runCommand !== 'function') throw new TypeError('serveApi needs the actual CLI entry point as runCommand');
let bound;
- const handler = createLocalApiHandler({ secret, getPort: () => bound, runCommand, projects, isMain, onStateBuild, stateDetail });
+ // A serve key authenticates board access, never a person, even in an ordinary terminal.
- const handler = createLocalApiHandler({ secret, getPort: () => bound, runCommand, projects, isMain, onStateBuild, personChannel: 'api' });
++ const handler = createLocalApiHandler({ secret, getPort: () => bound, runCommand, projects, isMain, onStateBuild, personChannel: 'api', stateDetail });
const server = createServer(handler);
server.requestTimeout = 15_000;
return new Promise((ready, fail) => {
diff --cc test/api-http.test.js
index 81fe9d89,f3f600ec..ff670c17
--- a/test/api-http.test.js
+++ b/test/api-http.test.js
@@@ -1,14 -1,14 +1,15 @@@
/** Real HTTP calls against an isolated Git repo and the actual board engine (A2). */
import assert from 'node:assert/strict';
import { randomUUID } from 'node:crypto';
-import { runFixtureChild, runFixtureGit } from './fixture-child.js';
-import { chmodSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
+import { runFixtureChild, runFixtureGit, startFixtureChild } from './fixture-child.js';
+import { chmodSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
+ import { spawn } from 'node:child_process';
import { createServer, request as httpRequest } from 'node:http';
import { join, resolve } from 'node:path';
import { test } from 'node:test';
- import { serveApi } from '../src/api.js';
+ import { createLocalApiHandler, serveApi } from '../src/api.js';
+import { serveView } from '../src/serve.js';
import { main } from '../src/cli.js';
import { createApiHandler } from '../src/api-http.js';
import { registryFile, registerProject } from '../src/projects.js';