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(merge): compose foreign waits with main [B24,H15]

Corey Olson4348c10a1762
diff --cc src/board.js
index 4425d16d,148e0b5d..44d4224b
--- a/src/board.js
+++ b/src/board.js
@@@ -1,9 -1,4 +1,10 @@@
+import { foreignBlockers } from './cross-repo-dependencies.js';
+import {
+ dependencyValues,
+ localDependencyIds,
+ dependencyLabel,
+} from './item-dependencies.js';
+ export { readBoardMembers, setBoardMembers } from './board-members.js';
import { heartbeatSeat } from './seat-presence.js';
import * as itemDecisions from './item-decision-queue.js';
import * as activityDeliveryStore from './activity-delivery-store.js';
diff --cc test/team.test.js
index bc14a3fa,c7ac8f7c..a20feccd
--- a/test/team.test.js
+++ b/test/team.test.js
@@@ -875,116 -1020,57 +1022,171 @@@ test('a landing lease renewal or waite
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;
+ writeFileSync(join(parent.root, 'pullboard.json'), JSON.stringify({ name: 'app', project: 'fixture', gate: 'true', lanes: { web: { owns: ['web/'] } } }));
+ writeFileSync(join(parent.root, 'SPEC.md'), '# Synthetic fixture\n\n- B24 [approved, must] Cross-repo fixture. | gate: test/team.test.js\n');
+ parent.git('add', 'pullboard.json', 'SPEC.md');
+ parent.git('commit', '-q', '-m', 'fixture: configure the private dependency API');
+ 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) {
+ const box = root === parent.root ? parent : child;
+ const commit = box.git('rev-parse', 'HEAD').trim();
+ const tree = box.git('rev-parse', 'HEAD^{tree}').trim();
+ store.claim(board, id, { agentId: 'web-1', lane: 'web', leaseMs: 60_000, head: commit, freeze });
+ submitFixture(board, id, { agentId: 'web-1', commit, 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: commit, digest: `fixture:${title}`, policy: 'any' });
+ }
+ accept(local, localId, parent.root, 'Local same-number item');
+ store.merged(local, localId, { agentId: 'coordinator', commit: parent.git('rev-parse', 'HEAD').trim() });
+ /** 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');
+ const builds = [];
+ const localApi = await serveApi({ port: 0, runCommand: main, stateDetail: 'full',
+ projects: () => [{ root: parent.root, name: 'app', project: 'fixture', added: '2026-10-25T00:00:00Z' }],
+ onItemBuild: entry => builds.push(entry.itemId) });
+ t.after(() => localApi.close());
+ const address = new URL(localApi.url);
+ /** Observe the real cached API projection without substituting an item builder. */
+ async function readState() {
+ const response = await fetchFresh(`${address.origin}/api/v1/boards/${parent.reference.boardId}/state?detail=full`,
+ { headers: { 'x-pullboard-key': address.searchParams.get('k') } });
+ const document = await response.json();
+ assert.equal(response.status, 200, JSON.stringify(document));
+ return document.state;
+ }
+ await readState();
+ builds.length = 0;
+ await readState();
+ assert.deepEqual(builds, [], 'unchanged API reads actually reuse the warm item cache');
+ accept(foreign, foreignId, child.root, 'Foreign prerequisite');
+ blocked(dependent, 'service#1');
+ await announce(2);
+ await readState();
+ assert.ok(builds.includes(dependent), 'an authenticated global state announcement rebuilds its cached foreign dependents');
+ 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);
+ const move = prepareEngineMove(local, 'claim', [dependent, options]);
+ const { CROSS_REPO_DEPENDENCY_ENGINE } = await import('../src/cross-repo-dependency-engine.js');
+ assert.ok(move.engine >= CROSS_REPO_DEPENDENCY_ENGINE, 'older replicas cannot flatten a foreign-dependent claim');
+ const ordered = { sequence: 1, at: clock.now().toISOString() };
+ assert.deepEqual(applyEngineMove(local, move, ordered), applyEngineMove(replica, move, ordered), 'one ordered claim returns the same receipt on both replicas');
+ 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');
+ await readState();
+ builds.length = 0;
+ const revoked = await api.revokeBoardLink(record, parent.reference.boardId, authority, { by: parent.by, key: parent.key });
+ await api.applyBoardLink(local, revoked, authority);
+ await readState();
+ assert.ok(builds.includes(dependent), 'a canonical link revocation invalidates cached foreign dependency status');
+});
++
+
+ test('a non-approver device without a signed member list receives no board key [H15,E17]', async t => {
+ const folder = mkdtempSync(join(tmpdir(), 'pullboard-handover-membership-'));
+ t.after(() => rmSync(folder, { recursive: true, force: true }));
+ const box = helpers.project();
+ const state = { board: withBoard(box.repo, store.boardId), repository: 'fixture/repository', login: 'alice' };
+ const boardKey = randomBytes(32);
+ /** Make an actual SSH signature and device key, independent of what the malicious relay asserts. */
+ async function request(login) {
+ const file = join(folder, login);
+ const made = runFixtureChild('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', file], { encoding: 'utf8' });
+ assert.equal(made.status, 0, 'OpenSSH creates the private fixture signing key');
+ const device = await createDeviceKeys();
+ const statement = { v: 1, board: state.board, repository: state.repository, login, device: device.deviceId,
+ publicKey: device.publicKey, engine: PEOPLE_VERSION, expires: Date.now() + 60_000 };
+ const input = file + '.statement';
+ writeFileSync(input, statementBytes(statement), { mode: 0o600 });
+ const signed = runFixtureChild('ssh-keygen', ['-Y', 'sign', '-q', '-n', 'pullboard-device-key', '-f', file, input], { encoding: 'utf8' });
+ assert.equal(signed.status, 0, "the request is genuinely signed by that login's SSH key");
+ return { device, signingKey: file, publicKey: readFileSync(file + '.pub', 'utf8').trim().split(' ').slice(0, 2).join(' '),
+ entry: { id: login, login, statement, signature: readFileSync(input + '.sig', 'utf8') } };
+ }
+ const outsider = await request('bob');
+ const member = await request('alice');
+ const body = { v: 1, board: state.board, repository: state.repository, login: 'alice' };
+ const identity = { body, signature: signSshVouch(JSON.stringify(['pullboard-person-identity', body]), 'pullboard-person-identity', member.signingKey) };
+ /** Present attacker-controlled relay entries while resolving SSH ownership directly for each account. */
+ async function answer(person) {
+ const deliveries = [];
+ await handOverBoardKeys(state, boardKey, {
+ root: box.repo, identity,
+ async send(_state, _path, options) {
+ if (options.method === 'PUT') { deliveries.push(options.body); return {}; }
+ return { requests: [person.entry] };
+ },
+ async githubKeys(login) { return login === person.entry.login ? [person.publicKey] : []; },
+ }, { err() {} });
+ assert.equal(deliveries.length, 1, 'each request gets one explicit refusal or delivery');
+ return deliveries[0];
+ }
+ const refused = await answer(outsider);
+ const leaked = refused.wrapped ? await unwrapDeviceBoardKey(outsider.device.privateKey,
+ JSON.parse(Buffer.from(refused.wrapped, 'base64url').toString('utf8')),
+ { board: state.board, device: outsider.device.deviceId, engine: PEOPLE_VERSION }) : null;
+ assert.equal(leaked !== null && Buffer.from(leaked).equals(boardKey), false, 'the outsider cannot decrypt the actual board key');
+ assert.equal(refused.refused?.code, 'RELAY_NOT_MEMBER', 'a valid outsider signature cannot establish trusted board membership');
+ assert.equal(Object.hasOwn(refused, 'wrapped'), false, 'the relay receives no key ciphertext it could unwrap as the outsider');
+ const allowed = await answer(member);
+ assert.ok(allowed.wrapped, 'the linked person can still bootstrap their own independently vouched device');
+ const unwrapped = await unwrapDeviceBoardKey(member.device.privateKey,
+ JSON.parse(Buffer.from(allowed.wrapped, 'base64url').toString('utf8')),
+ { board: state.board, device: member.device.deviceId, engine: PEOPLE_VERSION });
+ assert.deepEqual(Buffer.from(unwrapped), boardKey, 'the legitimate new device receives the actual board key');
+ });