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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
refactor(test): isolate membership handover case [C7,E17]
Corey Olson3dba367f430e
diff --git a/test/handover-membership-case.js b/test/handover-membership-case.jsnew file mode 100644index 00000000..5d1e5b58--- /dev/null+++ b/test/handover-membership-case.js@@ -0,0 +1,67 @@+/** Real SSH membership handover controls, kept separate from the team lifecycle file [H15,E17]. */+import assert from 'node:assert/strict';+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { randomBytes } from 'node:crypto';+import { join } from 'node:path';+import { tmpdir } from 'node:os';+import * as store from '../src/board.js';+import { ENGINE_VERSION as PEOPLE_VERSION } from '../src/machine.js';+import { createDeviceKeys, unwrapDeviceBoardKey } from '../src/relay-device-keys.js';+import { handOverBoardKeys, statementBytes } from '../src/relay-handover.js';+import { signSshVouch } from '../src/relay-ssh-proof.js';+import { runFixtureChild } from './fixture-child.js';++/** Preserve the real device-key and direct GitHub-signature boundary using the team's private Git helpers. */+export async function memberHandoverCase(t, { helpers, withBoard }) {+ 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');+}diff --git a/test/team.test.js b/test/team.test.jsindex 7db3d9fa..733895ed 100644--- a/test/team.test.js+++ b/test/team.test.js@@ -1,3 +1,4 @@+import { memberHandoverCase } from './handover-membership-case.js';/** @pullboard-test-loads src/board.js src/engine.js src/exchange.js src/person-signing.js relay/passkeys.js *//** Two independent Git/SQLite replicas derive verdict freshness without rewriting proof [E8]. */import assert from 'node:assert/strict';@@ -86,9 +87,6 @@ import {import { ENGINE_VERSION as PEOPLE_VERSION } from '../src/machine.js';import { relayWorkBudgetMs } from './relay-budget.js';import { hostname, tmpdir } from 'node:os';-import { createDeviceKeys, unwrapDeviceBoardKey } from '../src/relay-device-keys.js';-import { handOverBoardKeys, statementBytes } from '../src/relay-handover.js';-import { signSshVouch } from '../src/relay-ssh-proof.js';import { assertMatchingLandingHost, assertNoCulpritTrunkHold } from './landing-environment-fixture.js';import { landingQueueCase } from './landing-queue-fixture.js';import { DatabaseSync } from 'node:sqlite';@@ -1483,56 +1481,4 @@ test('two repos of a project that share a name are addressed by folder, never gu});-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');-});+test('a non-approver device without a signed member list receives no board key [H15,E17]', async t => memberHandoverCase(t, { helpers, withBoard }));