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
fix(relay): a CI session never files its key; relay status reads [E18]
Corey Olson8f1154665804
diff --git a/docs/api.md b/docs/api.mdindex 5b9265b2..17498485 100644--- a/docs/api.md+++ b/docs/api.md@@ -522,7 +522,7 @@ upgrade guidance; it never returns an older or partial image.Every session on a paired machine reads the board: a terminal, SSH, an agent, a scheduled job or CI. `relay on` keeps the board key only in the owner-only file `relay-keys/<board>.key` under the pullboard home, even where a keychain exists. A session that cannot read that file still reads the local board with every read command, `resume` included: resume reports once that the key is not reachable and leaves its own bookkeeping moves to a session that holds it. A move in such a session is refused with `RELAY_KEY_MISSING` and nothing is sent.-A CI or cloud session that cannot pair sets `PULLBOARD_RELAY_TOKEN` to one agent token, `PULLBOARD_RELAY_KEY` to the board key and, for a relay other than app.pullboard.dev, `PULLBOARD_RELAY_URL`. In a clone with no relay link, its first command asks the relay for the token's one board, reads that board's sealed snapshot with the key and writes the local board, plus a `relay.json` marked `environment` that names the token's agent and holds neither the token nor the key. Every later command reads and moves as that agent, on that one board; a token for any other board is refused (`TOKEN_BOARD`). A clone already linked to another board keeps its `relay.json`: the environment never overwrites it, reads go on with a `RELAY_LINKED` notice, and moves are refused.+A CI or cloud session that cannot pair sets `PULLBOARD_RELAY_TOKEN` to one agent token, `PULLBOARD_RELAY_KEY` to the board key and, for a relay other than app.pullboard.dev, `PULLBOARD_RELAY_URL`. In a clone with no relay link, its first command asks the relay for the token's one board, reads that board's sealed snapshot with the key and writes the local board, plus a `relay.json` marked `environment` that names the token's agent and holds neither the token nor the key. Every later command reads and moves as that agent, on that one board; a token for any other board is refused (`TOKEN_BOARD`). A clone already linked to another board keeps its `relay.json`: the environment never overwrites it, reads, `relay status` among them, go on with a `RELAY_LINKED` notice, and moves are refused. A session with both `PULLBOARD_RELAY_TOKEN` and `PULLBOARD_RELAY_KEY` uses that key as given when no key file exists: it never reads a keychain for it or writes a key file.## Sealed person requestsdiff --git a/src/commands/relay.js b/src/commands/relay.jsindex e2f29771..b3b2b242 100644--- a/src/commands/relay.js+++ b/src/commands/relay.js@@ -103,7 +103,7 @@ export async function run(io, { first, second, rest, values }) {if (second || rest.length || (first && !['on', 'off', 'status'].includes(first)) || (values.url && first !== 'on')) throw new Refused('USAGE', 'pullboard relay [status|on|off] [--url <address>]');const ctx = context(io);// pullboard relay status is the named form of plain pullboard relay: the same sync and report.- if (!first || first === 'status') { await syncRelay(ctx.info.root, io); await executePersonRequests(ctx.info.root, io, main); }+ if (!first || first === 'status') await relayRead(ctx.info.root, io);const result = first === 'on' ? await relayOn(ctx.info.root, values.url, io): first === 'off' ? await relayOff(ctx.info.root, io) : relayStatus(ctx.info.root);io.result?.(result);@@ -111,3 +111,21 @@ export async function run(io, { first, second, rest, values }) {for (const line of relayOutput.detailLines(result, boardName)) io.say(line);return 0;}++/**+ * Sync and run the phone's requests before a relay status read. A clone linked to another board than the+ * environment's token stays as it is and the read goes on with the notice, as every other read does [E18].+ *+ * @param {string} root+ * @param {any} io+ * @returns {Promise<void>}+ */+async function relayRead(root, io) {+ try { await syncRelay(root, io); }+ catch (error) {+ if (!(error instanceof Refused) || error.code !== 'RELAY_LINKED') throw error;+ io.err(`pullboard: [RELAY_LINKED] ${error.message}`);+ return;+ }+ await executePersonRequests(root, io, main);+}diff --git a/src/relay-key.js b/src/relay-key.jsindex f4b30014..f2831128 100644--- a/src/relay-key.js+++ b/src/relay-key.js@@ -73,7 +73,7 @@ function removeKeychainValue(service, id) {if (removed.status !== 0 && !absent) throw new Refused('RELAY_KEYCHAIN', 'unlock the system keychain to finish moving this board key');}-/** Read device storage first, migrating legacy keychain values before using an environment fallback. */+/** Read device storage first; a CI or cloud session then uses its environment key, and any other session migrates a legacy keychain value before the environment fallback. */export function readBoardKey(boardId) {const id = identity(boardId);const file = keyFile(id);@@ -92,6 +92,10 @@ export function readBoardKey(boardId) {}return key;}+ // A CI or cloud session, with an agent token and the key in its environment, uses that key as given: it never reads+ // a keychain or writes a key file [E18]. A person's machine still migrates a legacy keychain value first.+ const environmentSession = process.env.PULLBOARD_RELAY_TOKEN !== undefined && process.env.PULLBOARD_RELAY_KEY !== undefined;+ if (environmentSession) return decodeBoardKey(process.env.PULLBOARD_RELAY_KEY);const service = keychain();if (service) {const args = service === 'security'diff --git a/test/team.test.js b/test/team.test.jsindex 4e66163c..8031d09f 100644--- a/test/team.test.js+++ b/test/team.test.js@@ -535,7 +535,14 @@ test('every session reads and moves: terminal, SSH, agent, job or CI [E9,E18]',const ciHome = join(box.root, '..', 'ci-home');mkdirSync(ciHome, { mode: 0o700 });const key = readFileSync(box.keyFile, 'utf8').trim();- const ciEnv = { ...box.env, HOME: ciHome, PULLBOARD_HOME: join(ciHome, '.pullboard'), PULLBOARD_MACHINE_HOME: join(ciHome, 'machine'),+ // 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');@@ -561,9 +568,12 @@ test('every session reads and moves: terminal, SSH, agent, job or CI [E9,E18]',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, refused]) {+ 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');}