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): enforce frozen verification policy [H16,O2]
Corey Olsonbe90d2a29309
diff --git a/docs/formats.md b/docs/formats.mdindex 8ad7d0ee..c6dae437 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -257,7 +257,7 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `row_apply` | coordinator | `events` |<!-- events:end -->-New CLI claims include a `policy` object (`version: 1`, `commit`) in the frozen criterion. It pins the coordinator checkout’s committed configuration on its attached main branch. A temporary detached review checkout refuses new policy-dependent claims or project gates with `NO_POLICY`; the coordinator returns to its main branch. Existing frozen submissions remain verifiable. Legacy claims use their recorded claim-base commit. A CLI `submit` records the pre-merge coordinator HEAD as optional `policyCommit`; historical doctor and acceptance checks use this snapshot when allowing unchanged foreign files brought in from MAIN. Verified dependencies may also contribute unchanged files in their own lanes before a MAIN merge; foreign deletion or replacement is not authorized by an unrelated dependency’s tree. The complete candidate diff against both claim base and frozen MAIN is checked with rename detection disabled, preserving deleted paths and whitespace in names. Frozen item checks run against the exact submitted commit in an isolated checkout when accepting and auditing; repairing a reviewer’s checkout cannot make a red submission green.+New CLI claims include a `policy` object (`version: 1`, `commit`, `verify: { policy, family }`) in the frozen criterion. It pins the coordinator checkout’s committed configuration on its attached main branch and captures that commit’s verification and family rules. Relay verification uses those shared frozen values, ignoring policy values supplied by the sealed move; missing or invalid captured values produce `NO_POLICY` with an explicit refreeze step. An ordinary criterion recheck preserves legacy frozen bytes and their digest. An explicit refreeze captures the pinned commit’s verification rules and establishes a new digest. A temporary detached review checkout refuses new policy-dependent claims or project gates with `NO_POLICY`; the coordinator returns to its main branch. Existing frozen submissions remain verifiable. Legacy claims use their recorded claim-base commit. A CLI `submit` records the pre-merge coordinator HEAD as optional `policyCommit`; historical doctor and acceptance checks use this snapshot when allowing unchanged foreign files brought in from MAIN. Verified dependencies may also contribute unchanged files in their own lanes before a MAIN merge; foreign deletion or replacement is not authorized by an unrelated dependency’s tree. The complete candidate diff against both claim base and frozen MAIN is checked with rename detection disabled, preserving deleted paths and whitespace in names. Frozen item checks run against the exact submitted commit in an isolated checkout when accepting and auditing; repairing a reviewer’s checkout cannot make a red submission green.Person answer events additionally record their `channel`, either `terminal` or `view`, including the forwarded answer to the original asker. Agent answers omit that field.diff --git a/src/cli.js b/src/cli.jsindex ac2e81c4..a7b1dec4 100644--- a/src/cli.js+++ b/src/cli.js@@ -56,7 +56,7 @@ import { exportView, serveView } from './serve.js';import { serveApi } from './api.js';import { doctorProblems } from './doctor.js';import { staleFrozenItems, staleItemFinding } from './approved-rows.js';-import { mainPolicy, itemPolicy, submissionPaths, frozenCheck, checkAtCommit, dependencySnapshots } from './trusted-policy.js';+import { mainPolicy, policyAt, itemPolicy, submissionPaths, frozenCheck, checkAtCommit, dependencySnapshots } from './trusted-policy.js';import { exportBoard, importBoard } from './exchange.js';import { addSigner, assertRequiredSigners, defaultPrincipal, hasSignerFile } from './signature.js';import { loadMachineSettings, setGateSlots } from './settings.js';@@ -664,20 +664,34 @@ function whoAmI(ctx, board) {}/**- * The criterion an item is held to, frozen from the spec as it reads now.+ * Freeze a criterion from committed policy, preserving legacy bytes except on an explicit refreeze.** @param {any} ctx+ * @param {{ captureVerifyPolicy?: boolean }} [options]* @returns {(item: any) => { text: string, digest: string }}*/-const freezer = (ctx) => (item) => {- const prior = item.item_frozen ? JSON.parse(item.item_frozen) : null;- const policy = prior?.policy ?? (!prior && !(ctx.info.isMain && !headCommit(ctx.info.root)) ? { version: 1, commit: mainPolicy(ctx.info.root).commit } : null);- const config = policy ? itemPolicy(ctx.info.root, { ...item, item_frozen: JSON.stringify({ policy }) }).config : ctx.config;- const frozen = frozenCriterion(loadSpec(ctx.info.root, config), item);- if (!policy) return frozen; // Legacy criteria retain their original digest and committed claim base.- const text = JSON.stringify({ ...JSON.parse(frozen.text), policy });- return { text, digest: createHash('sha256').update(text).digest('hex') };-};+function freezer(ctx, { captureVerifyPolicy = false } = {}) {+ /** Freeze the item's criterion and, when requested, its committed verifier policy. */+ return (item) => {+ const prior = item.item_frozen ? JSON.parse(item.item_frozen) : null;+ const needsPinnedPolicy = !prior || captureVerifyPolicy;+ let policy = prior?.policy ?? (needsPinnedPolicy && !(ctx.info.isMain && !headCommit(ctx.info.root)) ? { version: 1, commit: mainPolicy(ctx.info.root).commit } : null);+ let config;+ if (policy && needsPinnedPolicy) {+ const commit = /^[0-9a-f]{40,64}$/.test(policy.commit ?? '')+ ? policy.commit+ : (/^[0-9a-f]{40,64}$/.test(item.item_claim_head ?? '') ? item.item_claim_head : mainPolicy(ctx.info.root).commit);+ config = policyAt(ctx.info.root, commit).config;+ policy = { version: 1, commit, verify: { policy: config.verify.policy, family: config.verify.family } };+ } else {+ config = policy ? itemPolicy(ctx.info.root, { ...item, item_frozen: JSON.stringify({ policy }) }).config : ctx.config;+ }+ const frozen = frozenCriterion(loadSpec(ctx.info.root, config), item);+ if (!policy) return frozen; // Legacy criteria retain their original digest and committed claim base.+ const text = JSON.stringify({ ...JSON.parse(frozen.text), policy });+ return { text, digest: createHash('sha256').update(text).digest('hex') };+ };+}/*** The evidence a shout carries, from its flags (B22). The commit is resolved here, in this repo,@@ -1859,7 +1873,7 @@ function workCommands(io, args) {return 0;}),refreeze: () => act(async (ctx, board, me) => {- const result = await ordered(ctx, board, 'refreeze', [idArg(first), { agentId: me.id, freeze: freezer(ctx) }]);+ const result = await ordered(ctx, board, 'refreeze', [idArg(first), { agentId: me.id, freeze: freezer(ctx, { captureVerifyPolicy: true }) }]);io.result?.({ id: idArg(first), ...result });io.say(`#${first} refrozen ${String(result.before).slice(0, 12)} -> ${result.after.slice(0, 12)}; open again`);return 0;diff --git a/src/engine.js b/src/engine.jsindex b503745a..8b8e821a 100644--- a/src/engine.js+++ b/src/engine.js@@ -81,7 +81,7 @@ function validateMove(move) {}/** Restore only the frozen criterion callback; no receiver runs another machine's Git or shell. */-function executableArgs(move) {+function executableArgs(move, board) {const args = structuredClone(move.args);if (['claim', 'refreeze'].includes(move.operation)) {const options = args[1];@@ -92,6 +92,21 @@ function executableArgs(move) {return options.frozen;};}+ if (move.operation === 'verify') {+ const item = store.getItem(board, args[0]);+ const options = args[1];+ let frozen;+ try { frozen = JSON.parse(item.item_frozen ?? 'null'); }+ catch { throw new Refused('NO_POLICY', 'the frozen verify policy is invalid; ask the coordinator to refreeze this item before verifying it'); }+ const capturedPolicy = frozen?.policy;+ const captured = capturedPolicy?.verify;+ if (!options || typeof options !== 'object' || Array.isArray(options) ||+ capturedPolicy?.version !== 1 || !/^[0-9a-f]{40,64}$/.test(capturedPolicy.commit ?? '') ||+ !['any', 'coordinator'].includes(captured?.policy) || !['off', 'prefer', 'require'].includes(captured?.family)) {+ throw new Refused('NO_POLICY', 'the frozen verify policy is missing or invalid; ask the coordinator to refreeze this item before verifying it');+ }+ args[1] = { ...options, policy: captured.policy, familyPolicy: captured.family };+ }return args;}@@ -157,7 +172,7 @@ export function applyEngineMove(board, move, { sequence, at }) {board.clock = { now: () => new Date(at) };const firstEvent = board.emittedEvents?.length ?? 0;try {- const result = store.atomic(board, () => store[move.operation](board, ...executableArgs(move)));+ const result = store.atomic(board, () => store[move.operation](board, ...executableArgs(move, board)));outcome = { result: result ?? null, events: (board.emittedEvents?.slice(firstEvent) ?? []).map((event) => ({ ...event })) };} catch (error) {if (!(error instanceof Refused)) throw error;diff --git a/test/relay-sealed.test.js b/test/relay-sealed.test.jsindex 48afe0bd..50b569f4 100644--- a/test/relay-sealed.test.js+++ b/test/relay-sealed.test.js@@ -1,10 +1,11 @@/** Two real clients and encrypted CLI records exercise the relay without sharing their key [A4,H7]. */import assert from 'node:assert/strict';-import { createCipheriv, createDecipheriv, randomBytes } from 'node:crypto';-import { spawn, spawnSync } from 'node:child_process';-import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';+import { createCipheriv, createDecipheriv, createHash, randomBytes } from 'node:crypto';+import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';-import { join, resolve } from 'node:path';+import { delimiter, join, resolve } from 'node:path';+import { pathToFileURL } from 'node:url';import { test } from 'node:test';import { serveRelay } from '../relay/service.js';import { createRelayAuth } from '../relay/auth.js';@@ -12,8 +13,9 @@ import { createGitHubClient } from '../relay/github.js';import { githubFixture } from './relay-fixture.js';import * as store from '../src/board.js';import { exportBoard } from '../src/exchange.js';-import { checkpointSequence, prepareEngineMove } from '../src/engine.js';+import { checkpointSequence, engineReceipt, prepareEngineMove } from '../src/engine.js';import { seal as sealMove } from '../src/seal.js';+import { ENGINE_VERSION } from '../src/machine.js';/** Seal on the test client only; nonce, authentication tag and ciphertext are opaque to the server. */function seal(key, value, binding) {@@ -40,9 +42,16 @@ async function fixture(t) {const root = join(directory, 'repo');const home = join(directory, 'home');const data = join(directory, 'relay');- mkdirSync(root); mkdirSync(home);+ const privateBin = join(directory, 'bin');+ mkdirSync(root); mkdirSync(home); mkdirSync(privateBin);const env = { ...process.env, HOME: home, PULLBOARD_HOME: home, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' };delete env.PULLBOARD_RELAY_TOKEN;+ const quoteShell = value => `'${String(value).replaceAll("'", "'\\''")}'`;+ const cliPath = resolve(import.meta.dirname, '../bin/pullboard.js');+ const pullboardPath = join(privateBin, 'pullboard');+ writeFileSync(pullboardPath, `#!/bin/sh\nexec ${quoteShell(process.execPath)} ${quoteShell(cliPath)} "$@"\n`);+ chmodSync(pullboardPath, 0o755);+ env.PATH = [privateBin, env.PATH].filter(Boolean).join(delimiter);const git = spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: root, env, encoding: 'utf8' });assert.equal(git.status, 0, git.stderr);/** Run the current CLI only in the fixture's private home and Git repository. */@@ -104,6 +113,41 @@ function replayClient(root, env, ...args) {});}+/** Replay through the native CLI while acknowledging but suppressing checkpoint writes to the fixture relay. */+function replayClientWithoutCheckpoint(root, env) {+ const cliURL = pathToFileURL(resolve(import.meta.dirname, '../src/cli.js')).href;+ const script = `+ import { main } from ${JSON.stringify(cliURL)};+ const realFetch = globalThis.fetch;+ let checkpointWrites = 0;+ globalThis.fetch = async (input, init = {}) => {+ const url = typeof input === 'string' ? input : input.url;+ if (init.method === 'PUT' && /\\/state(?:\\?|$)/.test(url)) {+ checkpointWrites += 1;+ return new Response(JSON.stringify({ version: 1, state: JSON.parse(init.body) }), { status: 200, headers: { 'content-type': 'application/json' } });+ }+ return realFetch(input, init);+ };+ let output = '';+ let diagnostics = '';+ const code = await main(['export', '--json'], { cwd: process.cwd(), stdout: { write(part) { output += part; } }, stderr: { write(part) { diagnostics += part; } } });+ console.log(JSON.stringify({ code, checkpointWrites, document: JSON.parse(output), diagnosticCount: diagnostics.length }));+ `;+ return new Promise((done, fail) => {+ const child = spawn(process.execPath, ['--input-type=module', '-e', script], { cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'] });+ let stdout = '';+ const timer = setTimeout(() => child.kill('SIGKILL'), 25000);+ child.stdout.setEncoding('utf8').on('data', part => { stdout += part; });+ child.stderr.resume();+ child.once('error', error => { clearTimeout(timer); fail(error); });+ child.once('close', code => {+ clearTimeout(timer);+ if (code !== 0) return fail(new Error('isolated native client failed during checkpoint-suppressed replay'));+ try { done(JSON.parse(stdout)); } catch { fail(new Error('checkpoint-suppressed native client returned invalid JSON')); }+ });+ });+}+test('two real clients refuse forged relay actors and person-only requests while advancing identically [H2,H16]', async t => {const box = await fixture(t);const source = store.openBoard(join(box.root, '.git/pullboard/board.sqlite'));@@ -168,6 +212,165 @@ test('two real clients refuse forged relay actors and person-only requests whileassert.deepEqual((await replayClient(roots[0], envs[0], 'export')).tables, result.tables, 'repeat catch-up does not duplicate refusals or actions');});+test('two real clients enforce the verify policy captured in the item freeze [H16,O2]', { timeout: 240_000 }, async t => {+ const box = await fixture(t);+ const configPath = join(box.root, 'pullboard.json');+ const config = JSON.parse(readFileSync(configPath, 'utf8'));+ config.verify = { ...config.verify, policy: 'coordinator', family: 'require' };+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');+ execFileSync('git', ['add', 'pullboard.json', 'SPEC.md'], { cwd: box.root, env: {+ ...box.env, GIT_AUTHOR_NAME: 'Policy Fixture', GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Policy Fixture', GIT_COMMITTER_EMAIL: '[email protected]',+ } });+ execFileSync('git', ['commit', '-q', '-m', 'test(relay): pin verify fixture policy'], { cwd: box.root, env: {+ ...box.env, GIT_AUTHOR_NAME: 'Policy Fixture', GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Policy Fixture', GIT_COMMITTER_EMAIL: '[email protected]',+ } });+ const lane = Object.keys(config.lanes)[0];+ const builder = join(box.directory, 'builder');+ execFileSync('git', ['worktree', 'add', '-q', '-b', 'builder-policy', builder, 'HEAD'], { cwd: box.root, env: box.env });+ /** Run native setup commands from the real linked builder worktree. */+ const runBuilder = (...args) => {+ const result = spawnSync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json'], { cwd: builder, env: box.env, encoding: 'utf8' });+ assert.equal(result.error, undefined);+ assert.equal(result.status, 0, result.stderr || result.stdout || 'the real native CLI prepares a fresh claim under the pinned main policy');+ return JSON.parse(result.stdout);+ };+ const joined = runBuilder('join', lane, '--family', 'Builder Family');+ const builderId = joined.agent;+ assert.equal(typeof builderId, 'string');+ runBuilder('claim', '1');++ const source = store.openBoard(join(box.root, '.git/pullboard/board.sqlite'));+ const commit = execFileSync('git', ['rev-parse', 'HEAD'], { cwd: box.root, env: box.env, encoding: 'utf8' }).trim();+ const tree = execFileSync('git', ['rev-parse', 'HEAD^{tree}'], { cwd: box.root, env: box.env, encoding: 'utf8' }).trim();+ let verifierSame;+ let verifierOther;+ let legacyDigest;+ try {+ const item = store.getItem(source, 1);+ const frozen = JSON.parse(item.item_frozen);+ assert.deepEqual(frozen.policy.verify, { policy: 'coordinator', family: 'require' }, 'fresh native freeze captures both values from committed main config');+ const legacyPolicy = { version: 99, commit: frozen.policy.commit, verify: { policy: 'bogus', family: 'off' } };+ const legacyText = JSON.stringify({ ...frozen, policy: legacyPolicy });+ legacyDigest = createHash('sha256').update(legacyText).digest('hex');+ store.refreeze(source, 1, { agentId: 'coordinator', freeze: () => ({ text: legacyText, digest: legacyDigest }) });+ } finally { store.closeBoard(source); }++ const legacyRefreeze = box.cli('refreeze', '1');+ assert.match(legacyRefreeze, /#1 refrozen/);+ runBuilder('claim', '1');+ const afterRefreeze = store.openBoard(join(box.root, '.git/pullboard/board.sqlite'));+ let document;+ let moves;+ try {+ const refreshed = store.getItem(afterRefreeze, 1);+ assert.equal(JSON.parse(refreshed.item_frozen).policy.version, 1, 'explicit refreeze repairs malformed captured policy metadata');+ assert.deepEqual(JSON.parse(refreshed.item_frozen).policy.verify, { policy: 'coordinator', family: 'require' }, 'explicit native refreeze upgrades the legacy claim policy');+ assert.notEqual(refreshed.item_frozen_digest, legacyDigest, 'explicit refreeze establishes a new digest for the newly captured policy');+ store.submit(afterRefreeze, 1, { agentId: builderId, commit, tree, files: [] });+ store.register(afterRefreeze, { lane: 'coordinator', path: box.root, family: 'Coordinator Family' });+ store.register(afterRefreeze, { lane, path: join(box.directory, 'verifier-same'), family: 'Builder Family' });+ verifierSame = store.agentAt(afterRefreeze, join(box.directory, 'verifier-same')).agent_id;+ store.register(afterRefreeze, { lane, path: join(box.directory, 'verifier-other'), family: 'Reviewer Family' });+ verifierOther = store.agentAt(afterRefreeze, join(box.directory, 'verifier-other')).agent_id;++ /** Freeze test items with a specific historical policy document, keeping engine inputs deterministic. */+ const makeFrozen = (verify, version = 1) => item => {+ const text = JSON.stringify({ title: item.item_title, criterion: item.item_criterion, policy: { version, commit, ...(verify ? { verify } : {}) } });+ return { text, digest: createHash('sha256').update(text).digest('hex') };+ };+ /** Add, claim and submit one private fixture item with the supplied frozen verify values. */+ const makeSubmitted = (title, verify, version = 1) => {+ const id = store.addItem(afterRefreeze, { by: 'coordinator', lane, title });+ store.claim(afterRefreeze, id, { agentId: builderId, lane, leaseMs: 3_600_000, freeze: makeFrozen(verify, version), head: commit });+ store.submit(afterRefreeze, id, { agentId: builderId, commit, tree, files: [] });+ return store.getItem(afterRefreeze, id);+ };+ const legacy = makeSubmitted('legacy frozen verify without policy capture', null);+ const sameFamily = makeSubmitted('require a different verifier family', { policy: 'any', family: 'require' });+ const crossFamily = makeSubmitted('allow a different verifier family', { policy: 'any', family: 'require' });+ const malformed = makeSubmitted('malformed captured verify policy', { policy: 'broken', family: 'off' });+ const wrongVersion = makeSubmitted('unsupported frozen policy version', { policy: 'any', family: 'require' }, 2);+ checkpointSequence(afterRefreeze, 0);+ document = JSON.parse(JSON.stringify(exportBoard(afterRefreeze)));+ /** Build a verifier envelope with deliberately untrusted any/off settings. */+ const forge = (item, agentId, id) => prepareEngineMove(afterRefreeze, 'verify', [item.item_id, {+ agentId, decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'checked by the fixture verifier',+ head: commit, digest: item.item_frozen_digest, policy: 'any', familyPolicy: 'off',+ }], { id });+ moves = [+ forge(refreshed, verifierSame, 'forged_coordinator_policy'),+ forge(legacy, verifierSame, 'missing_frozen_verify_policy'),+ forge(sameFamily, verifierSame, 'forged_family_policy'),+ forge(crossFamily, verifierOther, 'allowed_cross_family_verify'),+ forge(malformed, verifierSame, 'malformed_frozen_verify_policy'),+ forge(wrongVersion, verifierSame, 'unsupported_frozen_policy_version'),+ forge(refreshed, 'coordinator', 'compliant_legacy_refreeze_verify'),+ ];+ } finally { store.closeBoard(afterRefreeze); }++ const roots = [box.root, join(box.directory, 'second-policy-client')];+ const homes = [box.home, join(box.directory, 'second-policy-home')];+ const envs = homes.map(home => ({ ...box.env, HOME: home, PULLBOARD_HOME: home }));+ mkdirSync(roots[1]); mkdirSync(homes[1], { mode: 0o700 });+ assert.equal(spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: roots[1], env: envs[1] }).status, 0);+ await replayClient(roots[1], envs[1], 'init');+ const snapshotFile = join(box.directory, 'policy-snapshot.json');+ writeFileSync(snapshotFile, JSON.stringify(document), { mode: 0o600 });+ await replayClient(roots[1], envs[1], 'import', snapshotFile);+ const recipientConfig = JSON.parse(readFileSync(join(roots[1], 'pullboard.json'), 'utf8'));+ assert.notDeepEqual(recipientConfig.verify, { policy: 'coordinator', family: 'require' }, 'second client has different local settings from the frozen shared policy');+ for (let index = 0; index < roots.length; index += 1) {+ const keyDirectory = join(homes[index], 'relay-keys');+ mkdirSync(keyDirectory, { mode: 0o700 });+ writeFileSync(join(keyDirectory, box.id + '.key'), box.key.toString('base64url') + '\n', { mode: 0o600 });+ writeFileSync(join(roots[index], '.git/pullboard/relay.json'), JSON.stringify({ version: 1, mode: 'ordered', board: box.id, url: box.origin, repository: 'fixture/repository', token: box.person.token, sequence: 0, cursor: document.tables.event.at(-1).event_id }) + '\n', { mode: 0o600 });+ }+ const snapshotSealed = Buffer.from(await sealMove(box.key, new TextEncoder().encode(JSON.stringify(document)), { boardId: box.id, kind: 'snapshot', sequence: 0 })).toString('base64url');+ const savedSnapshot = await box.call(box.path + '/state', { method: 'PUT', token: box.person.token, body: { sequence: 0, sealed: snapshotSealed } });+ assert.equal(savedSnapshot.status, 200, 'person session installs the initial encrypted snapshot');+ const verifierTokens = new Map();+ for (const agent of new Set([verifierSame, verifierOther])) verifierTokens.set(agent, await box.auth.issueToken(box.person.token, { board: box.id, agent }));+ for (let index = 0; index < moves.length; index += 1) {+ const agent = moves[index].args[1].agentId;+ const sequence = index + 1;+ const sealed = Buffer.from(await sealMove(box.key, new TextEncoder().encode(JSON.stringify(moves[index])), { boardId: box.id, kind: 'move', sequence })).toString('base64url');+ const token = agent === 'coordinator' ? box.person.token : verifierTokens.get(agent).token;+ const uploaded = await box.call(box.path + '/moves', { method: 'POST', token, body: { sequence, sealed } });+ assert.equal(uploaded.status, 200, 'the real relay accepts each authenticated verifier move as an opaque envelope');+ }++ const firstClient = await replayClientWithoutCheckpoint(roots[0], envs[0]);+ assert.equal(firstClient.code, 0);+ assert.equal(firstClient.checkpointWrites, 1, 'first client attempted one local checkpoint, suppressed before relay storage');+ const relayAfterFirst = await box.call(box.path + '/state');+ assert.equal(relayAfterFirst.body.state.sequence, 0, 'the second client cannot inherit the first client checkpoint');+ const secondClient = await replayClientWithoutCheckpoint(roots[1], envs[1]);+ assert.equal(secondClient.code, 0);+ assert.equal(secondClient.checkpointWrites, 1, 'second client independently attempted its own checkpoint');+ const exported = [firstClient.document, secondClient.document];+ assert.deepEqual(exported[0].tables, exported[1].tables, 'both real clients replay the same refusal and board prefix');+ assert.deepEqual(exported[0].tables.item.filter(item => ![1, 4].includes(item.item_id)), document.tables.item.filter(item => ![1, 4].includes(item.item_id)), 'policy refusals change no refused item state');+ assert.equal(exported[0].tables.item.find(item => item.item_id === 1).item_status, 'verified', 'an actual legacy refreeze enables a compliant coordinator verification');+ assert.equal(exported[0].tables.item.find(item => item.item_id === 4).item_status, 'verified', 'a different declared family is allowed under the frozen require policy');+ assert.equal(exported[0].tables.verdict.length, document.tables.verdict.length + 2, 'only compliant coordinator and cross-family verifications create verdicts');+ const codes = ['forged_coordinator_policy', 'missing_frozen_verify_policy', 'forged_family_policy', 'malformed_frozen_verify_policy', 'unsupported_frozen_policy_version'];+ const outcomes = [];+ for (const result of exported) {+ assert.equal(result.tables.board_meta.find(row => row.meta_key === 'relay_applied_sequence').meta_value, '7');+ outcomes.push(codes.map(id => JSON.parse(result.tables.board_meta.find(row => row.meta_key === 'relay_receipt_' + id).meta_value).outcome.error.code));+ const accepted = JSON.parse(result.tables.board_meta.find(row => row.meta_key === 'relay_receipt_allowed_cross_family_verify').meta_value);+ assert.equal(accepted.outcome.result.decision, 'ACCEPT');+ const refrozen = JSON.parse(result.tables.board_meta.find(row => row.meta_key === 'relay_receipt_compliant_legacy_refreeze_verify').meta_value);+ assert.equal(refrozen.outcome.result.decision, 'ACCEPT');+ }+ assert.deepEqual(outcomes, [+ ['COORDINATOR_VERIFIES', 'NO_POLICY', 'O2_FAMILY_MATCH', 'NO_POLICY', 'NO_POLICY'],+ ['COORDINATOR_VERIFIES', 'NO_POLICY', 'O2_FAMILY_MATCH', 'NO_POLICY', 'NO_POLICY'],+ ]);+});+test('[A4,H7] two clients append sealed moves in one order and no plaintext or client key reaches storage', async (t) => {const box = await fixture(t);const listed = await box.call('/api/v1/boards');