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): fence old outbox readers from result paths [B26,H16,H17]
Corey Olsona72b1ef4d1b5
diff --git a/src/relay-outbox.js b/src/relay-outbox.jsindex a9e0b17a..73da9e01 100644--- a/src/relay-outbox.js+++ b/src/relay-outbox.js@@ -78,7 +78,7 @@ export async function readOutbox(file, key, boardId) {if (!existsSync(file)) return null;const plain = await unseal(key, readFileSync(file), { boardId, kind: 'outbox', sequence: 0 });const document = JSON.parse(gunzipSync(plain).toString('utf8'));- if (document?.version !== 1 || !Array.isArray(document.moves) || !document.base || !Number.isSafeInteger(document.baseSequence)) {+ if (![1, 2].includes(document?.version) || !Array.isArray(document.moves) || !document.base || !Number.isSafeInteger(document.baseSequence)) {throw new Refused('RELAY_OUTBOX', 'the relay outbox on this machine is unreadable; keep it, and ask for help before relinking this board');}return document;@@ -86,6 +86,9 @@ export async function readOutbox(file, key, boardId) {/** Seal and atomically replace the outbox, readable only by this user. */export async function writeOutbox(file, key, boardId, document) {+ // Old clients must refuse richer result bindings rather than treating temporary item numbers as final.+ if (document.moves.some(entry => entry.created?.some(row => row.resultPath.length)+ || entry.refs?.some(ref => ref.resultPath?.length))) document.version = 2;const sealed = await seal(key, gzipSync(Buffer.from(JSON.stringify(document))), { boardId, kind: 'outbox', sequence: 0 });mkdirSync(dirname(file), { recursive: true, mode: 0o700 });const temporary = file + '.' + randomUUID() + '.tmp';diff --git a/test/relay-outbox-format.test.js b/test/relay-outbox-format.test.jsnew file mode 100644index 00000000..9551a053--- /dev/null+++ b/test/relay-outbox-format.test.js@@ -0,0 +1,39 @@+/** Sealed local outbox compatibility uses the actual old reader, not an imitation of its version check [B26,H16,H17]. */+import assert from 'node:assert/strict';+import { randomBytes } from 'node:crypto';+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import test from 'node:test';+import { fileURLToPath, pathToFileURL } from 'node:url';+import { readOutbox, writeOutbox } from '../src/relay-outbox.js';+import { runFixtureGit } from './fixture-child.js';++const ROOT = fileURLToPath(new URL('..', import.meta.url));+const OLD = '876df36c23a63993b371d4d85b9cf3b54f8ed38d';++test('legacy numeric outboxes remain readable and an old reader refuses new result bindings [B26,H16,H17]', async t => {+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-outbox-format-'));+ t.after(() => rmSync(directory, { recursive: true, force: true }));+ const source = runFixtureGit(['show', `${OLD}:src/relay-outbox.js`], { cwd: ROOT });+ // Relocate imports only; the complete accepted old module and its read function remain otherwise unchanged.+ const relocated = source.replace(/from '(\.\/[^']+)'/gu,+ (_, specifier) => `from '${new URL(specifier, new URL('../src/relay-outbox.js', import.meta.url)).href}'`);+ const oldModule = join(directory, 'old-outbox.mjs');+ writeFileSync(oldModule, relocated);+ const old = await import(pathToFileURL(oldModule).href);+ const file = join(directory, 'outbox.sealed');+ const key = randomBytes(32);+ const board = randomBytes(16).toString('hex');+ const legacy = { version: 1, base: { tables: {} }, baseSequence: 0,+ moves: [{ move: { id: 'old-add', operation: 'addItem' }, visible: 7 }], results: {} };+ await writeOutbox(file, key, board, legacy);+ assert.deepEqual(await old.readOutbox(file, key, board), legacy);+ assert.deepEqual(await readOutbox(file, key, board), legacy);+ const modern = { ...legacy, moves: [{ move: { id: 'handoff', operation: 'openHandoff' },+ created: [{ resultPath: ['item'], item: 8 }] }] };+ await writeOutbox(file, key, board, modern);+ assert.equal((await readOutbox(file, key, board)).version, 2);+ await assert.rejects(old.readOutbox(file, key, board), error => error.code === 'RELAY_OUTBOX',+ 'the actual old reader refuses the new local format instead of silently ignoring result paths');+});