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
Merge branch 'main' into core/344-opus
Corey Olsondb743675e0f1
diff --cc src/relay.jsindex 77ed0bf0,8b6ab5b2..1f41a0d0--- a/src/relay.js+++ b/src/relay.js@@@ -1260,11 -1260,11 +1261,10 @@@ export async function relayOperation(ro/** Catch up an opted-in replica before/after a CLI command; offline reads retain local evidence. */export async function syncRelay(root, io) {// Reuse Git discovery only within this command; still re-read the link before each retry.- let files = LINK_FILES.get(io);- if (!files) { files = new Map(); LINK_FILES.set(io, files); }+ const files = LINK_FILES.get(io) ?? LINK_FILES.set(io, new Map()).get(io);const file = files.get(root) ?? linkFile(root);files.set(root, file);- // A CI or cloud session with an agent token and a board key in its environment links itself once [E18].- if (!await environmentLink(root, file, io) && !existsSync(file)) return null;- if (!existsSync(file)) return null;++ if (!await environmentLink(root, file, io) && !existsSync(file)) return null; // a CI or cloud session links from its environment [E18]return locked(file, async () => {const state = loadLink(file);if (!state) return null;diff --cc test/team.test.jsindex 8031d09f,ac0b51d0..ac991741--- a/test/team.test.js+++ b/test/team.test.js@@@ -475,110 -473,75 +480,183 @@@ test('an older pushed landing shows staassert.equal(withBoard(box.repo, board => store.getItem(board, 1)).item_merged_commit, submitted);});++/** Every file under a directory, so a test can prove no secret was written anywhere in it. */+function filesUnder(directory) {+ if (!existsSync(directory)) return [];+ return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => entry.isDirectory() ? filesUnder(join(directory, entry.name)) : [join(directory, entry.name)]);+}++test('every session reads and moves: terminal, SSH, agent, job or CI [E9,E18]', { timeout: 240_000 }, async (t) => { // budget: hang ceiling for real CLI runs on three homes and a loopback relay; not a speed target.+ const box = await sessionRelay(t);+ const cli = join(import.meta.dirname, '..', 'bin', 'pullboard.js');++ // S6d: on a machine with a keychain, relay on keeps the key in the owner-only file every session can read.+ const keychainBin = join(box.root, '..', 'keychain-bin');+ mkdirSync(keychainBin, { mode: 0o700 });+ for (const name of readdirSync(box.env.PATH)) symlinkSync(join(box.env.PATH, name), join(keychainBin, name));+ const keychainLog = join(box.root, '..', 'keychain-calls.log');+ for (const name of ['security', 'secret-tool']) {+ writeFileSync(join(keychainBin, name), `#!/bin/sh\necho "$1" >> ${JSON.stringify(keychainLog)}\n[ "$1" = search ] && exit 1\nexit 0\n`, { mode: 0o755 });+ }+ const plainPath = box.env.PATH;+ box.env.PATH = keychainBin;+ assert.equal((await box.link()).code, 0, 'relay on links the board on a machine with a keychain');+ box.env.PATH = plainPath;+ const keys = join(box.env.PULLBOARD_HOME, 'relay-keys');+ assert.deepEqual(readdirSync(keys).filter((name) => name.endsWith('.key')).length, 1, 'the key sits in one owner-only file');+ assert.equal(statSyncMode(box.keyFile), 0o600, 'the key file is owner-only');+ const writes = existsSync(keychainLog) ? readFileSync(keychainLog, 'utf8').split('\n').filter((call) => ['add-generic-password', 'store'].includes(call)) : [];+ assert.deepEqual(writes, [], 'relay on never writes the key to the keychain');++ // S6b: a session that cannot read the key (SSH, a scheduled job, a locked keychain) still reads the whole board.+ assert.equal((await box.cli('add', box.lane, 'Read from any session')).code, 0);+ renameSync(keys, keys + '.parked');+ try {+ for (const command of [['list'], ['show', '1'], ['inbox'], ['whoami'], ['status'], ['resume'], ['log']]) {+ const read = await box.cli(...command);+ assert.equal(read.code, 0, `${command[0]} reads without the key: ${JSON.stringify(read.document?.error ?? null)}`);+ }+ const move = await box.cli('add', box.lane, 'Needs the key');+ assert.equal(move.document?.error?.code, 'RELAY_KEY_MISSING', 'a move without the key is refused, never sent or lost');+ } finally { renameSync(keys + '.parked', keys); }++ // S6c: a CI or cloud session, with an agent token and the board key in its environment and no key file, reads and moves.+ // The project's committed setup is what every checkout, CI's included, gets.+ sessionGit(['add', '-A'], { cwd: box.root, env: box.env });+ sessionGit(['-c', 'core.hooksPath=/dev/null', 'commit', '-q', '-m', 'chore: set up pullboard'], { cwd: box.root, env: box.env });+ const seatRoot = join(box.root, '..', 'ci-seat');+ sessionGit(['worktree', 'add', '-q', '-b', 'ci-seat', seatRoot], { cwd: box.root, env: box.env });+ const joined = await box.cliAt(seatRoot, 'join', box.lane, '--model', 'fixture-model');+ assert.equal(joined.code, 0, `the person gives CI its own seat: ${JSON.stringify(joined.document?.error ?? null)}`);+ const seat = (await box.cliAt(seatRoot, 'whoami')).document;+ assert.equal((await box.cliAt(seatRoot, 'shout', 'coordinator', 'the CI seat is ready')).code, 0, 'the seat moves once, which mints its token');+ const link = JSON.parse(readFileSync(box.linkFile, 'utf8'));+ const token = link.agentTokens?.[seat.id]?.token;+ assert.match(token ?? '', /^pa_/u, 'the seat holds its own agent token');+ const ciRoot = join(box.root, '..', 'ci-clone');+ sessionGit(['clone', '-q', box.root, ciRoot], { cwd: box.root, env: box.env });+ sessionGit(['remote', 'set-url', 'origin', '[email protected]:fixture/repository.git'], { cwd: ciRoot, env: box.env });+ const ciHome = join(box.root, '..', 'ci-home');+ mkdirSync(ciHome, { mode: 0o700 });+ const key = readFileSync(box.keyFile, 'utf8').trim();+ // The CI machine also has a keychain holding a legacy copy of the key; the session must not move it into a file.+ const ciKeychainBin = join(ciHome, 'keychain-bin');+ mkdirSync(ciKeychainBin, { mode: 0o700 });+ for (const name of readdirSync(box.env.PATH)) symlinkSync(join(box.env.PATH, name), join(ciKeychainBin, name));+ for (const name of ['security', 'secret-tool']) {+ writeFileSync(join(ciKeychainBin, name), '#!/bin/sh\ncase "$1" in search) exit 1;; find-generic-password|lookup) printf %s "$PULLBOARD_RELAY_KEY"; exit 0;; esac\nexit 0\n', { mode: 0o755 });+ }+ const ciEnv = { ...box.env, HOME: ciHome, PULLBOARD_HOME: join(ciHome, '.pullboard'), PULLBOARD_MACHINE_HOME: join(ciHome, 'machine'), PATH: ciKeychainBin,+ PULLBOARD_RELAY_TOKEN: token, PULLBOARD_RELAY_KEY: key, PULLBOARD_RELAY_URL: box.origin };+ const ci = (...args) => sessionChild(ciRoot, ciEnv, [cli, ...args, '--json']);+ const status = await ci('status');+ assert.equal(status.code, 0, 'CI reads the board');+ const listed = await ci('list', '--all');+ assert.ok(listed.document.items.some((item) => (item.title ?? item.item_title) === 'Read from any session'),+ `CI reads the board’s items: ${JSON.stringify(listed.document.items?.map((item) => item.title ?? item.item_title))} ${JSON.stringify(status.document).replaceAll(token, '<token>').replaceAll(key, '<key>').slice(0, 900)}`);+ const added = await ci('add', box.lane, 'Added from CI');+ assert.equal(added.code, 0, `CI moves on the board: ${JSON.stringify(added.document?.error ?? null)}`);+ assert.equal((await box.cli('status')).code, 0);+ const items = (await box.cli('export')).document.tables.item;+ assert.ok(items.some((item) => item.item_title === 'Added from CI'), 'the CI move reaches the person’s board');+ assert.equal(filesUnder(join(ciEnv.PULLBOARD_HOME, 'relay-keys')).length, 0, 'CI keeps no key file');+ const written = [...filesUnder(join(ciRoot, '.git', 'pullboard')), ...filesUnder(ciHome)].map((file) => readFileSync(file)).map((bytes) => bytes.toString('latin1'));+ assert.equal(written.some((text) => text.includes(token) || text.includes(key)), false, 'neither the token nor the key is written to disk');+ for (const output of [status, listed, added]) {+ const shown = JSON.stringify(output.document) + (output.failure ?? '');+ assert.equal(shown.includes(token) || shown.includes(key), false, 'no output repeats a secret');+ }+ // A clone already linked to another board keeps its link: the environment never overwrites it.+ const otherLink = join(ciRoot, '.git', 'pullboard', 'relay.json');+ const elsewhere = JSON.stringify({ ...JSON.parse(readFileSync(otherLink, 'utf8')), board: 'f'.repeat(32) });+ writeFileSync(otherLink, elsewhere, { mode: 0o600 });+ const warned = await ci('status');+ assert.match(JSON.stringify(warned.document?.diagnostics ?? []), /RELAY_LINKED/u, 'the environment names the link to another board and the read goes on');+ const relayRead = await ci('relay', 'status');+ assert.equal(relayRead.code, 0, `relay status is a read too, so it goes on: ${JSON.stringify(relayRead.document?.error?.code ?? null)}`);+ assert.match(JSON.stringify(relayRead.document?.diagnostics ?? []), /RELAY_LINKED/u, 'relay status names the link to another board');+ const refused = await ci('add', box.lane, 'Added across boards');+ assert.notEqual(refused.code, 0, 'a session on another board’s link does not move');+ for (const output of [warned, relayRead, refused]) {+ const shown = JSON.stringify(output.document) + (output.failure ?? '');+ assert.equal(shown.includes(token) || shown.includes(key), false, 'the refusal repeats no secret');+ }+ assert.equal(readFileSync(otherLink, 'utf8'), elsewhere, 'the other board’s link is left as it was');+});++/** A file's permission bits. */+function statSyncMode(file) { return lstatSync(file).mode & 0o777; }+++ test('one coordinator per board across machines [E19]', { timeout: relayWorkBudgetMs(12) }, async t => { // budget: hang ceiling for two linked devices' real CLI and relay round trips; not a speed target.+ const box = await relayClientFixture(t);+ await box.link();+ const pairing = await box.cli('relay', 'pair');+ const other = await box.otherDeviceJoin(pairing.document.code);+ /** A refusal's code and message as the CLI reports them. */+ const refusal = result => ({ code: result.document?.error?.code, message: String(result.document?.error?.message ?? '') });++ // The first device to act as coordinator holds it; the board keeps working there as it does today.+ assert.equal((await box.cli('add', box.lane, 'Planned on the first machine')).code, 0, 'the first machine coordinates');+ assert.equal((await box.cli('add', box.lane, 'Still planned on the first machine')).code, 0, 'the holder keeps coordinating');++ // On one machine, the main checkout is held by one agent session at a time; takeover passes it between sessions.+ /** Run the first machine's real CLI from a named agent session. */+ const inSession = (session, ...args) => relayFixtureChild(box.root, { ...box.env, CLAUDECODE: '1', CLAUDE_CODE_SESSION_ID: session },+ [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json']);+ assert.equal((await inSession('first-session', 'add', box.lane, 'Planned in the first session')).code, 0, 'one agent session coordinates');+ assert.equal(refusal(await inSession('second-session', 'add', box.lane, 'Planned in a second session')).code, 'NOT_YOUR_CHECKOUT',+ 'a second session acting as coordinator in the same main checkout is refused');+ assert.equal((await inSession('second-session', 'takeover')).code, 0, 'takeover passes the main checkout to the second session');+ assert.equal((await inSession('second-session', 'add', box.lane, 'Planned in the second session after takeover')).code, 0, 'the new session coordinates');+ assert.equal(refusal(await inSession('first-session', 'add', box.lane, 'Planned again in the first session')).code, 'NOT_YOUR_CHECKOUT',+ 'the earlier session is refused after the takeover');++ // A second machine's main checkout acting as coordinator is refused, by name.+ const second = await other.cli('add', box.lane, 'Planned on the second machine');+ assert.notEqual(second.code, 0, 'a second coordinator is refused');+ assert.equal(refusal(second).code, 'COORDINATOR_HELD');+ const firstName = `computer ${JSON.parse(readFileSync(box.linkFile, 'utf8')).machine.slice(-8)}`;+ const secondName = `computer ${other.machine.slice(-8)}`;+ assert.notEqual(firstName, secondName, 'the two linked computers have different names');+ assert.ok(refusal(second).message.includes(firstName), `the refusal names the holding computer: ${refusal(second).message}`);+ assert.doesNotMatch(refusal(second).message, new RegExp(hostname(), 'u'), 'the name carries no host name');+ assert.match(refusal(second).message, /pullboard takeover/u, 'the refusal names the takeover');++ // Takeover passes the coordinator to the second machine, and the first is then refused by name.+ const taken = await other.cli('takeover');+ assert.equal(taken.code, 0, `takeover passes the coordinator: ${JSON.stringify(taken.document)}`);+ assert.equal(taken.document.coordinator, secondName, 'takeover reports the new holder');+ assert.equal(taken.document.previous, firstName, 'takeover reports the holder it replaced');+ assert.equal((await other.cli('add', box.lane, 'Planned on the second machine after takeover')).code, 0, 'the new holder coordinates');+ const first = await box.cli('add', box.lane, 'Planned again on the first machine');+ assert.equal(refusal(first).code, 'COORDINATOR_HELD', 'the earlier holder is now the second coordinator');+ assert.ok(refusal(first).message.includes(secondName), `the refusal names the new holder: ${refusal(first).message}`);++ // Both replicas agree on the items each holder made, and on no others.+ for (const device of [box, other]) {+ const titles = (await device.cli('list')).document.items.map(item => item.item_title);+ assert.deepEqual(titles.filter(title => title.startsWith('Planned') || title.startsWith('Still')).sort(),+ ['Planned in the first session', 'Planned in the second session after takeover', 'Planned on the first machine',+ 'Planned on the second machine after takeover', 'Still planned on the first machine']);+ }+ });++ test('an agent session on a computer that does not hold the coordinator takes it over [E19]', { timeout: relayWorkBudgetMs(12) }, async t => { // budget: hang ceiling for two linked devices' real CLI and relay round trips; not a speed target.+ const box = await relayClientFixture(t);+ await box.link();+ const pairing = await box.cli('relay', 'pair');+ const other = await box.otherDeviceJoin(pairing.document.code);+ /** Run the second computer's real CLI from a named agent session. */+ const inSession = (...args) => relayFixtureChild(other.root, { ...other.env, CLAUDECODE: '1', CLAUDE_CODE_SESSION_ID: 'second-computer-session' },+ [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json']);+ assert.equal((await box.cli('add', box.lane, 'Planned on the holding computer')).code, 0, 'the first computer holds the coordinator');+ const held = await inSession('add', box.lane, 'Planned before the takeover');+ assert.equal(held.document?.error?.code, 'COORDINATOR_HELD', 'the second computer is refused by name');+ assert.match(held.document.error.message, /pullboard takeover/u, 'the refusal names the takeover');+ const taken = await inSession('takeover');+ assert.equal(taken.code, 0, `the takeover the refusal names succeeds from the agent session: ${JSON.stringify(taken.document)}`);+ assert.equal(taken.document.coordinator, `computer ${other.machine.slice(-8)}`, 'the second computer now holds the coordinator');+ assert.equal((await inSession('add', box.lane, 'Planned after the takeover')).code, 0, 'the new holder coordinates');+ assert.equal((await box.cli('add', box.lane, 'Planned again on the first computer')).document?.error?.code, 'COORDINATOR_HELD', 'the earlier holder is refused');+ });