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.

test(board): cover foreign prerequisite authority [B24,H16]

Corey Olson06d21072b057
diff --git a/test/board-link-fixture.js b/test/board-link-fixture.js
new file mode 100644
index 00000000..c06b319c
--- /dev/null
+++ b/test/board-link-fixture.js
@@ -0,0 +1,95 @@
+/** Shared real private Git/SSH/SQLite and loopback E32 fixture, with no production credentials [E32,B24]. */
+import assert from 'node:assert/strict';
+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import * as store from '../src/board.js';
+import { addSigner } from '../src/signature.js';
+import { runFixtureChild, runFixtureGit, fixtureChildMessage } from './fixture-child.js';
+
+/** Create an isolated native board with its established SSH signer authority. */
+export function signedBoard(t, name, clock) {
+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-board-link-'));
+ let board = null;
+ t.after(() => { if (board) store.closeBoard(board); rmSync(directory, { recursive: true, force: true }); });
+ const root = join(directory, 'repo');
+ const key = join(directory, 'signer');
+ mkdirSync(root);
+ const env = { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',
+ GIT_AUTHOR_NAME: 'Link fixture', GIT_AUTHOR_EMAIL: '[email protected]',
+ GIT_COMMITTER_NAME: 'Link fixture', GIT_COMMITTER_EMAIL: '[email protected]' };
+ const generated = runFixtureChild('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', key], { env, encoding: 'utf8' });
+ assert.equal(generated.status, 0, fixtureChildMessage(generated));
+ const git = (...args) => runFixtureGit(args, { cwd: root, env, encoding: 'utf8' });
+ git('init', '-q', '-b', 'main');
+ writeFileSync(join(root, 'README.md'), 'Private board-link fixture.\n');
+ git('add', '.');
+ git('commit', '-q', '-m', 'fixture: establish board signer root');
+ addSigner(root, { by: name, key: key + '.pub' });
+ board = store.openBoard(join(root, '.git', 'pullboard', 'board.sqlite'), clock);
+ return { root, key, by: name, board, reference: { boardId: store.boardId(board), organization: 'fixture', handle: name } };
+}
+
+/** Obtain genuine independent approval of the exact same link document from both boards. */
+export async function consent(api, authority, parent, child, linkId, disclosure = 'states', generation = 1) {
+ let record = { version: 1, linkId, parent: parent.reference, child: child.reference,
+ generation, disclosure, approvals: [], revocation: null };
+ record = await api.approveBoardLink(record, parent.reference.boardId, authority, { by: parent.by, key: parent.key });
+ return api.approveBoardLink(record, child.reference.boardId, authority, { by: child.by, key: child.key });
+}
+
+/** Start the existing authenticated relay with real stand-in OAuth and private native snapshots. */
+export async function linkRelay(t, boards, authority) {
+ const { githubFixture } = await import('./relay-fixture.js');
+ const { createGitHubClient } = await import('../relay/github.js');
+ const { createRelayAuth } = await import('../relay/auth.js');
+ const { serveRelay } = await import('../relay/service.js');
+ const { request } = await import('../src/relay.js');
+ const { generateBoardKey, seal } = await import('../src/seal.js');
+ const { exportBoard } = await import('../src/exchange.js');
+ const { ENGINE_VERSION } = await import('../src/machine.js');
+ const provider = await githubFixture(t);
+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-link-relay-'));
+ let time = Date.now();
+ const auth = createRelayAuth({ database: join(directory, 'auth.sqlite'),
+ github: createGitHubClient(provider.config), now: () => time });
+ let service = null;
+ t.after(async () => {
+ try { if (service) await service.close(); }
+ finally { auth.close(); rmSync(directory, { recursive: true, force: true }); }
+ });
+ const grant = await auth.beginDevice();
+ provider.state.deviceAuthorized = true;
+ time += grant.interval * 1000;
+ const person = await auth.pollDevice(grant.ticket);
+ for (const box of boards) await auth.linkBoard(person.token, box.reference.boardId, 'fixture/repository');
+ service = await serveRelay({ directory: join(directory, 'relay'), auth, maintenanceMs: 0,
+ now: () => time, boardLinkAuthority: authority });
+ let origin = 'http://127.0.0.1:' + service.port;
+ const states = new Map();
+ for (const box of boards) {
+ const board = box.reference.boardId;
+ const key = await generateBoardKey();
+ const snapshot = await seal(key, Buffer.from(JSON.stringify(exportBoard(box.board))), { boardId: board, kind: 'snapshot', sequence: 0 });
+ const uploaded = await fetch(origin + '/api/v1/boards/' + board + '/state', { method: 'PUT',
+ headers: { authorization: 'Bearer ' + person.token, 'x-pullboard-engine': String(ENGINE_VERSION), 'content-type': 'application/json' },
+ body: JSON.stringify({ sequence: 0, sealed: Buffer.from(snapshot).toString('base64url') }) });
+ assert.equal(uploaded.status, 200, JSON.stringify(await uploaded.json()));
+ const issued = await auth.issueToken(person.token, { board, agent: 'link-agent' });
+ states.set(board, { url: origin, token: issued.token, board, agent: 'link-agent' });
+ }
+ return { states, request,
+ async restart(options = {}) {
+ await service.close();
+ service = await serveRelay({ directory: join(directory, 'relay'), auth, maintenanceMs: 0,
+ now: () => time, boardLinkAuthority: authority, accountStorageBytes: options.accountStorageBytes });
+ origin = 'http://127.0.0.1:' + service.port;
+ for (const state of states.values()) state.url = origin;
+ },
+ async storedBytes() {
+ const { boardStorageBytes } = await import('../relay/storage-quota.js');
+ return boards.reduce((total, box) => total + boardStorageBytes(join(directory, 'relay'), box.reference.boardId), 0);
+ },
+ };
+}
+
diff --git a/test/board-link.test.js b/test/board-link.test.js
index bcdc8813..910ecd02 100644
--- a/test/board-link.test.js
+++ b/test/board-link.test.js
@@ -1,43 +1,11 @@
+import { signedBoard, consent, linkRelay } from './board-link-fixture.js';
/** Bilateral board links disclose only authorized state and retain real SSH consent [E32,H16,H17]. */
import assert from 'node:assert/strict';
-import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { test } from 'node:test';
import * as store from '../src/board.js';
-import { addSigner } from '../src/signature.js';
-import { runFixtureChild, runFixtureGit, fixtureChildMessage } from './fixture-child.js';
-
-/** Create an isolated native board with its established SSH signer authority. */
-function signedBoard(t, name) {
- const directory = mkdtempSync(join(tmpdir(), 'pullboard-board-link-'));
- let board = null;
- t.after(() => { if (board) store.closeBoard(board); rmSync(directory, { recursive: true, force: true }); });
- const root = join(directory, 'repo');
- const key = join(directory, 'signer');
- mkdirSync(root);
- const env = { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',
- GIT_AUTHOR_NAME: 'Link fixture', GIT_AUTHOR_EMAIL: '[email protected]',
- GIT_COMMITTER_NAME: 'Link fixture', GIT_COMMITTER_EMAIL: '[email protected]' };
- const generated = runFixtureChild('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', key], { env, encoding: 'utf8' });
- assert.equal(generated.status, 0, fixtureChildMessage(generated));
- const git = (...args) => runFixtureGit(args, { cwd: root, env, encoding: 'utf8' });
- git('init', '-q', '-b', 'main');
- writeFileSync(join(root, 'README.md'), 'Private board-link fixture.\n');
- git('add', '.');
- git('commit', '-q', '-m', 'fixture: establish board signer root');
- addSigner(root, { by: name, key: key + '.pub' });
- board = store.openBoard(join(root, '.git', 'pullboard', 'board.sqlite'));
- return { root, key, by: name, board, reference: { boardId: store.boardId(board), organization: 'fixture', handle: name } };
-}
-
-/** Obtain genuine independent approval of the exact same link document from both boards. */
-async function consent(api, authority, parent, child, linkId, disclosure = 'states', generation = 1) {
- let record = { version: 1, linkId, parent: parent.reference, child: child.reference,
- generation, disclosure, approvals: [], revocation: null };
- record = await api.approveBoardLink(record, parent.reference.boardId, authority, { by: parent.by, key: parent.key });
- return api.approveBoardLink(record, child.reference.boardId, authority, { by: child.by, key: child.key });
-}
test('opening a relay journal installs delivery storage before the first link envelope [E32,H16,H17]', async t => {
const { DatabaseSync } = await import('node:sqlite');
@@ -123,61 +91,6 @@ test('a signed two-sided link carries only its disclosure mode and refuses a cyc
position: 9, rows: [{ board: child.reference.boardId, id: 8, state: 'claimed', title: 'private' }] }).rows, []);
});
-/** Start the existing authenticated relay with real stand-in OAuth and private native snapshots. */
-async function linkRelay(t, boards, authority) {
- const { githubFixture } = await import('./relay-fixture.js');
- const { createGitHubClient } = await import('../relay/github.js');
- const { createRelayAuth } = await import('../relay/auth.js');
- const { serveRelay } = await import('../relay/service.js');
- const { request } = await import('../src/relay.js');
- const { generateBoardKey, seal } = await import('../src/seal.js');
- const { exportBoard } = await import('../src/exchange.js');
- const { ENGINE_VERSION } = await import('../src/machine.js');
- const provider = await githubFixture(t);
- const directory = mkdtempSync(join(tmpdir(), 'pullboard-link-relay-'));
- let time = Date.now();
- const auth = createRelayAuth({ database: join(directory, 'auth.sqlite'),
- github: createGitHubClient(provider.config), now: () => time });
- let service = null;
- t.after(async () => {
- try { if (service) await service.close(); }
- finally { auth.close(); rmSync(directory, { recursive: true, force: true }); }
- });
- const grant = await auth.beginDevice();
- provider.state.deviceAuthorized = true;
- time += grant.interval * 1000;
- const person = await auth.pollDevice(grant.ticket);
- for (const box of boards) await auth.linkBoard(person.token, box.reference.boardId, 'fixture/repository');
- service = await serveRelay({ directory: join(directory, 'relay'), auth, maintenanceMs: 0,
- now: () => time, boardLinkAuthority: authority });
- let origin = 'http://127.0.0.1:' + service.port;
- const states = new Map();
- for (const box of boards) {
- const board = box.reference.boardId;
- const key = await generateBoardKey();
- const snapshot = await seal(key, Buffer.from(JSON.stringify(exportBoard(box.board))), { boardId: board, kind: 'snapshot', sequence: 0 });
- const uploaded = await fetch(origin + '/api/v1/boards/' + board + '/state', { method: 'PUT',
- headers: { authorization: 'Bearer ' + person.token, 'x-pullboard-engine': String(ENGINE_VERSION), 'content-type': 'application/json' },
- body: JSON.stringify({ sequence: 0, sealed: Buffer.from(snapshot).toString('base64url') }) });
- assert.equal(uploaded.status, 200, JSON.stringify(await uploaded.json()));
- const issued = await auth.issueToken(person.token, { board, agent: 'link-agent' });
- states.set(board, { url: origin, token: issued.token, board, agent: 'link-agent' });
- }
- return { states, request,
- async restart(options = {}) {
- await service.close();
- service = await serveRelay({ directory: join(directory, 'relay'), auth, maintenanceMs: 0,
- now: () => time, boardLinkAuthority: authority, accountStorageBytes: options.accountStorageBytes });
- origin = 'http://127.0.0.1:' + service.port;
- for (const state of states.values()) state.url = origin;
- },
- async storedBytes() {
- const { boardStorageBytes } = await import('../relay/storage-quota.js');
- return boards.reduce((total, box) => total + boardStorageBytes(join(directory, 'relay'), box.reference.boardId), 0);
- },
- };
-}
-
test('sealed board-link delivery authenticates both boards and retains exact retries after restart [E32,H16,H17]', async t => {
const loaded = await import('../src/board-link-relay.js').then(api => ({ api }), error => ({ error }));
assert.equal(loaded.error, undefined, 'the common authenticated delivery dispatcher must exist');
diff --git a/test/team.test.js b/test/team.test.js
index 3a2516ce..96154100 100644
--- a/test/team.test.js
+++ b/test/team.test.js
@@ -1,3 +1,5 @@
+import { signedBoard, consent, linkRelay } from './board-link-fixture.js';
+import { submitFixture } from './board-submit-fixture.js';
/** @pullboard-test-loads src/board.js src/engine.js src/exchange.js */
/** Two independent Git/SQLite replicas derive verdict freshness without rewriting proof [E8]. */
import assert from 'node:assert/strict';
@@ -872,3 +874,80 @@ test('a landing lease renewal or waiter poll writes no board event [Q1,Q2,Q3]',
assert.equal(state.holder, null);
assert.equal(state.line.length, 1, 'suppressing polling events does not discard the waiting command');
});
+
+/** Cross-repository prerequisites use real signed E32 disclosure and never a same-number local item [B24,H16]. */
+test('an item waits across repos [B24,H16]', async t => {
+ /** A private board clock makes exact canonical replay comparisons deterministic. */
+ const clock = { now: () => new Date('2026-10-25T00:00:00Z') };
+ const parent = signedBoard(t, 'app', clock);
+ const child = signedBoard(t, 'service', clock);
+ const local = parent.board, foreign = child.board;
+ for (const box of [parent, child]) {
+ store.register(box.board, { lane: 'coordinator', path: box.root });
+ store.register(box.board, { lane: 'web', path: join(box.root, 'synthetic-builder') });
+ }
+ const localId = store.addItem(local, { by: 'coordinator', lane: 'web', title: 'Local same-number item' });
+ const foreignId = store.addItem(foreign, { by: 'coordinator', lane: 'web', title: 'Foreign prerequisite' });
+ assert.equal(localId, foreignId, 'independent real Git/SQLite boards intentionally reuse the same item number');
+ const dependent = store.addItem(local, { by: 'coordinator', lane: 'web', title: 'Wait for service', after: [`service#${foreignId}`] });
+ assert.equal(store.getItem(local, dependent).item_after, `service#${foreignId}`);
+ /** Explicit synthetic frozen bar; native moves below do not claim that this fixture ran a gate. */
+ const freeze = item => ({ text: item.item_title, digest: `fixture:${item.item_title}` });
+ /** Record an actual native verified transition, with a clearly synthetic build receipt. */
+ function accept(board, id, root, title) {
+ store.claim(board, id, { agentId: 'web-1', lane: 'web', leaseMs: 60_000, freeze });
+ submitFixture(board, id, { agentId: 'web-1', commit: 'a'.repeat(40), tree: 'synthetic-tree' });
+ const reviewer = store.register(board, { lane: 'web', path: join(root, 'synthetic-reviewer') });
+ store.verify(board, id, { agentId: reviewer, decision: 'ACCEPT', reason: 'CRITERION_MET',
+ note: 'synthetic board-state fixture; no gate execution', head: 'a'.repeat(40), digest: `fixture:${title}`, policy: 'any' });
+ }
+ accept(local, localId, parent.root, 'Local same-number item');
+ /** Assert the native claim guard and pull queue name the owning repository. */
+ function blocked(id, label) {
+ assert.throws(() => store.claim(local, id, { agentId: 'web-1', lane: 'web', leaseMs: 60_000, freeze }),
+ error => error.code === 'BLOCKED' && error.message.includes(label));
+ assert.ok(store.nextFor(local, { agentId: 'web-1', lane: 'web' }).reasons.some(reason => reason.includes(label)));
+ }
+ blocked(dependent, 'service#1');
+ const missing = store.addItem(local, { by: 'coordinator', lane: 'web', title: 'Missing board', after: ['missing#999'] });
+ blocked(missing, 'missing#999');
+ const api = await import('../src/board-link.js');
+ const transportApi = await import('../src/board-link-relay.js');
+ const { createSshBoardLinkAuthority } = await import('../src/board-link-ssh.js');
+ const { createBoardLinkCapability } = await import('../src/board-link-envelope.js');
+ const { generateBoardKey } = await import('../src/seal.js');
+ const authority = createSshBoardLinkAuthority([parent, child]);
+ const record = await consent(api, authority, parent, child, 'dependency');
+ await api.applyBoardLink(local, record, authority);
+ await api.applyBoardLink(foreign, record, authority);
+ const relay = await linkRelay(t, [parent, child], authority);
+ const sender = transportApi.createBoardLinkRelayTransport(relay.states.get(child.reference.boardId));
+ const receiver = transportApi.createBoardLinkRelayTransport(relay.states.get(parent.reference.boardId));
+ await sender.publish(record);
+ const capability = createBoardLinkCapability(record, await generateBoardKey());
+ /** Send only actual child item states through the established authenticated E32 transport. */
+ async function announce(position) {
+ const context = { linkId: record.linkId, generation: record.generation, sourceBoardId: child.reference.boardId,
+ destinationBoardId: parent.reference.boardId, position, correlationId: `state-${position}`,
+ rows: [{ board: child.reference.boardId, id: foreignId, state: store.getItem(foreign, foreignId).item_status }] };
+ await transportApi.deliverBoardState(foreign, context, { authority, capability, transport: sender });
+ const deliveries = (await receiver.read()).deliveries;
+ await transportApi.receiveBoardState(local, deliveries.at(-1), { authority, capability });
+ }
+ await announce(1);
+ blocked(dependent, 'service#1');
+ accept(foreign, foreignId, child.root, 'Foreign prerequisite');
+ blocked(dependent, 'service#1');
+ await announce(2);
+ const replica = store.openBoard(':memory:', clock);
+ t.after(() => store.closeBoard(replica));
+ importBoard(replica, exportBoard(local));
+ const options = { agentId: 'web-1', lane: 'web', leaseMs: 60_000, freeze };
+ assert.equal(store.nextFor(local, { agentId: 'web-1', lane: 'web' }).item.item_id, dependent);
+ assert.equal(store.nextFor(replica, { agentId: 'web-1', lane: 'web' }).item.item_id, dependent);
+ store.claim(local, dependent, options);
+ store.claim(replica, dependent, options);
+ assert.equal(store.getItem(local, dependent).item_status, 'claimed');
+ assert.equal(store.getItem(replica, dependent).item_status, 'claimed', 'replica uses canonical received state, not a local registry or foreign-board path');
+ assert.deepEqual(exportBoard(replica), exportBoard(local), 'same canonical state and claim produce exact replica rows and event IDs');
+});