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.

chore(spec): merge sign-off rework source [S17,S18,S19,S20,S21]

Corey Olson387b251198de
diff --cc docs/api.md
index 15138f89,021ef9a4..425d5c15
--- a/docs/api.md
+++ b/docs/api.md
@@@ -94,44 -91,8 +95,50 @@@ A refusal keeps the command's existing
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.
+
+The server checks any Origin against its own address and grants no CORS permission. JSON request bodies are limited to 100000 bytes; oversized bodies are drained and refused without applying a partial move. A missing or invalid registered folder does not hide readable boards: it appears in `warnings` with its registry display fields and a versioned refusal whose `next` field explains how to restore or forget it.
+
+| Method and path | Result |
+| --- | --- |
+| `GET /api/v1/boards` | Registered boards with their project details and ids |
+| `GET /api/v1/boards/:board/state?seen=N` | The view's board state, including open coordinator requests and the unseen shout count since N |
+| `GET /api/v1/boards/:board/code?ref=path:lines@commit&before=...` | A bounded preview of committed file lines from that registered board |
+| `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 |
+
+The boards response keeps `boards` and may include `warnings` for registered entries that could not be opened. State `seen` must be a nonnegative safe integer; omitting it retains the `unseen: null` result. Code previews read only a registered repo's committed tree, use a plain commit SHA and at most 60 lines, and never read the working tree. The shared router lets adapters omit the optional code capability; such adapters return the versioned `CODE_NOT_AVAILABLE` refusal.
+
+<!-- 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.
+
+Decision moves keep the CLI's routing: `shout` with `args.decision: true` may omit `args.to`; agents ask their coordinator, and the coordinator asks the person. `pass` takes the decision's id as `item` and `args.note`. Answering a decision addressed to the person requires `answer` with `args.as: "person"` from the coordinator's main checkout. Other callers receive the CLI's refusal.
+
+The SQLite schema marker is now `PRAGMA user_version = 2`. Opening an older board upgrades it in place: `board_meta` stores the id as `meta_key = "board_id"` and a 32-character hexadecimal `meta_value`; `shout_request` and `shout_request_outcome` mark requests and their answers. Existing items, agents and events remain intact. The HTTP envelope stays at version 1 independently of the SQLite schema marker.
+
+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`.
+
+The local server uses a shared HTTP router. Streams recheck access before each poll and close with a versioned refusal if access ends. Slow readers pause delivery and resume from the last delivered sequence.
+
+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.
++
+ ## SSH spec sign-offs
+
+ `pullboard spec signers add [--key <path>] [--by <principal>]` opts a repo into OpenSSH-signed spec sign-offs. The key defaults to Git `user.signingkey`, then `~/.ssh/id_ed25519.pub`. The principal defaults to the exact Git `user.email`; `--by` overrides it. `spec signoff` uses the same email default in a repo with SSH signers, and accepts `--by` when a listed principal differs. A row's `signers:` names those exact principals. Spec checking refuses a required principal without a corresponding signer entry.
+
+ The initial command output names `.pullboard/signers`, `.pullboard/first-commit` and `.pullboard/signers.initial` for staging and committing. Later sign-offs and signed signer-list changes are recorded in `.pullboard/signoffs.jsonl`; commit that file with the corresponding signer-list change.
diff --cc src/cli.js
index d9fc60d3,4cbeaf6a..5c9f0a15
--- a/src/cli.js
+++ b/src/cli.js
@@@ -45,12 -44,11 +45,13 @@@ import { renderSpecView } from './view.
import { tour } from './tour.js';
import { commandOutput } from './json.js';
import { forgetProject, registerProject } from './projects.js';
+import { listResources } from './resources.js';
import { citedTestFiles, rowEvidence, rowStage } from './evidence.js';
import { serveView } from './serve.js';
+import { serveApi } from './api.js';
import { doctorProblems } from './doctor.js';
import { exportBoard, importBoard } from './exchange.js';
+ import { addSigner, assertRequiredSigners, defaultPrincipal, hasSignerFile } from './signature.js';
const PACKAGE = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
export const VERSION = PACKAGE.version;
@@@ -1516,9 -1465,11 +1521,11 @@@ function specCommand(io, { first, secon
}
const spec = loadSpec(ctx.info.root, ctx.config);
if (!spec.exists) throw new Refused('NO_SPEC', `no ${ctx.config.spec}; run: pullboard init`);
- const practice = loadSpec(ctx.info.root, { ...ctx.config, spec: ctx.config.practice });
+ const practice = ctx.doctrine;
+ const signoffs = readSignoffs(ctx.info.root);
if (first === 'check' || first === undefined) {
const files = [[ctx.config.spec, spec], ...(practice.exists ? [[ctx.config.practice, practice]] : [])];
+ for (const [, parsed] of files) assertRequiredSigners(ctx.info.root, parsed.rows);
let errors = 0;
const messages = [];
for (const [name, parsed] of files) {
@@@ -1536,9 -1487,8 +1543,9 @@@
unnamed.forEach((problem) => messages.push(`${ctx.config.spec}: error: ${problem}`));
errors += unnamed.length;
if (values.json && !errors) {
- const rows = files.flatMap(([file, parsed]) => parsed.rows.map(({ id, status, tier, text, gate, serves, section, line, origin, version, reason, file: source }) => (
- { id, status, tier, text, gate, serves, section, line, file: source ?? file,
- const rows = files.flatMap(([file, parsed]) => parsed.rows.map(({ id, status, tier, text, gate, serves, signers, section, line }) => (
- { id, status, tier, text, gate, serves, signers, section, line, file }
++ const rows = files.flatMap(([file, parsed]) => parsed.rows.map(({ id, status, tier, text, gate, serves, signers = [], section, line, origin, version, reason, file: source }) => (
++ { id, status, tier, text, gate, serves, signers, section, line, file: source ?? file,
+ ...(origin ? { origin, version, reason } : {}) }
)));
io.result({ rows });
} else messages.forEach((message) => io.say(message));
diff --cc test/spec.test.js
index d52a1770,10a05ce0..a71c6499
--- a/test/spec.test.js
+++ b/test/spec.test.js
@@@ -212,17 -220,13 +221,17 @@@ test('spec --json emits one versioned d
const shown = box.run('--json');
assert.equal(shown.status, 0, shown.stderr);
const data = JSON.parse(shown.stdout);
- assert.deepEqual(data, {
+ const inherited = data.rows.filter(row => row.origin === 'standard');
+ assert.equal(data.rows.length, 4 + standardDoctrine().rows.length);
+ assert.deepEqual(inherited.map(row => row.id), standardDoctrine().rows.map(row => row.id));
+ assert.ok(inherited.every(row => row.file === 'standard doctrine 1' && row.version === 1 && row.reason === ''));
+ assert.deepEqual({ version: data.version, rows: data.rows.filter(row => row.file === 'SPEC.md') }, {
version: 1,
rows: [
- { id: 'G1', status: 'approved', tier: 'must', text: 'Same file twice is a no-op.', gate: 'idempotency test', serves: [], section: 'G · Goals', line: 6, file: 'SPEC.md' },
- { id: 'G1.2', status: 'draft', tier: 'aim', text: 'Shows a diff.', gate: '', serves: ['G1'], section: 'G · Goals', line: 7, file: 'SPEC.md' },
- { id: 'G2', status: 'retired', tier: '', text: 'Old idea.', gate: '', serves: [], section: 'G · Goals', line: 8, file: 'SPEC.md' },
- { id: 'K1', status: 'approved', tier: 'must', text: 'Runs offline.', gate: 'e2e test', serves: ['G1', 'G1.2'], section: 'K · Constraints', line: 11, file: 'SPEC.md' },
+ { id: 'G1', status: 'approved', tier: 'must', text: 'Same file twice is a no-op.', gate: 'idempotency test', serves: [], signers: [], section: 'G · Goals', line: 6, file: 'SPEC.md' },
+ { id: 'G1.2', status: 'draft', tier: 'aim', text: 'Shows a diff.', gate: '', serves: ['G1'], signers: [], section: 'G · Goals', line: 7, file: 'SPEC.md' },
+ { id: 'G2', status: 'retired', tier: '', text: 'Old idea.', gate: '', serves: [], signers: [], section: 'G · Goals', line: 8, file: 'SPEC.md' },
+ { id: 'K1', status: 'approved', tier: 'must', text: 'Runs offline.', gate: 'e2e test', serves: ['G1', 'G1.2'], signers: [], section: 'K · Constraints', line: 11, file: 'SPEC.md' },
],
});
});
@@@ -234,13 -238,12 +243,13 @@@ test('spec --json combines both configu
assert.equal(shown.status, 0, shown.stderr);
const data = JSON.parse(shown.stdout);
assert.equal(data.version, 1);
- assert.equal(data.rows.length, 7);
+ assert.equal(data.rows.length, 7 + standardDoctrine().rows.length);
+ assert.equal(data.rows.filter(row => row.origin === 'standard').length, standardDoctrine().rows.length);
assert.ok(data.rows.slice(0, 4).every((row) => row.file === 'requirements.md'));
- assert.deepEqual(data.rows.slice(4), [
- { id: 'P1', status: 'fact', tier: '', text: 'A fact.', gate: '', serves: [], signers: [], section: 'P · Practice', line: 4, file: 'ways.md' },
- { id: 'P2', status: 'pending', tier: 'must', text: 'A question.', gate: '', serves: [], signers: [], section: 'P · Practice', line: 5, file: 'ways.md' },
- { id: 'P3', status: 'wont', tier: '', text: 'An old plan.', gate: '', serves: [], signers: [], section: 'P · Practice', line: 6, file: 'ways.md' },
+ assert.deepEqual(data.rows.filter(row => row.file === 'ways.md'), [
- { id: 'P1', status: 'fact', tier: '', text: 'A fact.', gate: '', serves: [], section: 'P · Practice', line: 4, file: 'ways.md', origin: 'repo', version: null, reason: '' },
- { id: 'P2', status: 'pending', tier: 'must', text: 'A question.', gate: '', serves: [], section: 'P · Practice', line: 5, file: 'ways.md', origin: 'repo', version: null, reason: '' },
- { id: 'P3', status: 'wont', tier: '', text: 'An old plan.', gate: '', serves: [], section: 'P · Practice', line: 6, file: 'ways.md', origin: 'repo', version: null, reason: 'An old plan.' },
++ { id: 'P1', status: 'fact', tier: '', text: 'A fact.', gate: '', serves: [], signers: [], section: 'P · Practice', line: 4, file: 'ways.md', origin: 'repo', version: null, reason: '' },
++ { id: 'P2', status: 'pending', tier: 'must', text: 'A question.', gate: '', serves: [], signers: [], section: 'P · Practice', line: 5, file: 'ways.md', origin: 'repo', version: null, reason: '' },
++ { id: 'P3', status: 'wont', tier: '', text: 'An old plan.', gate: '', serves: [], signers: [], section: 'P · Practice', line: 6, file: 'ways.md', origin: 'repo', version: null, reason: 'An old plan.' },
]);
});