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): scope repair notices and retain local reads [H16,H5,N26]
Corey Olson0807d8438235
diff --git a/src/activity-delivery-cli.js b/src/activity-delivery-cli.jsindex 3ae6d7a9..bee38978 100644--- a/src/activity-delivery-cli.js+++ b/src/activity-delivery-cli.js@@ -66,16 +66,16 @@ export async function deliverActivity(ctx, { actedIds = [], afterSubmit = false,else {try { await recordIncluded(ctx, board, me.id, observation); }catch (error) {- if (!(error instanceof Refused) || !['RELAY_RECOVERY_PENDING', 'RELAY_KEY_MISSING'].includes(error.code)) throw error;+ if (!(error instanceof Refused) || !['RELAY_RECOVERY_PENDING', 'RELAY_KEY_MISSING', 'AUTH_REQUIRED'].includes(error.code)) throw error;// A read remains available while canonical writes are fenced; its obligations remain unrecorded.activity.receipt = { recorded: false, code: error.code, message: error.message };}}- const shouts = directShouts ? store.inbox(board, me.id, { through: shoutCursor, markRead: activity.receipt?.code !== 'RELAY_KEY_MISSING' })+ const shouts = directShouts ? store.inbox(board, me.id, { through: shoutCursor, markRead: !['RELAY_KEY_MISSING', 'AUTH_REQUIRED'].includes(activity.receipt?.code) }).filter(shout => !newsShouts.includes(shout.shout_id)) : [];return { shouts, agents: store.listAgents(board), activity, local };});- if (delivered.activity.receipt?.code !== 'RELAY_KEY_MISSING' && !saveActivityCursor(delivered.local, delivered.activity.cursor)) {+ if (!['RELAY_KEY_MISSING', 'AUTH_REQUIRED'].includes(delivered.activity.receipt?.code) && !saveActivityCursor(delivered.local, delivered.activity.cursor)) {ctx.io.err('activity cursor could not be saved; activity may repeat when you read inbox again');}const { local, ...result } = delivered;diff --git a/src/relay.js b/src/relay.jsindex 9c1d64f4..4f723201 100644--- a/src/relay.js+++ b/src/relay.js@@ -546,10 +546,11 @@ export function pendingCheckpointProblem(root) {return state?.checkpointRefusal ? checkpointProblem(state) : null;}-/** Deduplicate within one move, retaining its preflight notice and allowing later moves to warn. */+/** Share one notice across a native command and its bookkeeping, or one direct ordered move. */function reportCheckpointRefusal(state, io) {- let boards = CHECKPOINT_NOTICES.get(io);- if (!boards) { boards = new Set(); CHECKPOINT_NOTICES.set(io, boards); }+ const scope = io.relayCommand ?? io;+ let boards = CHECKPOINT_NOTICES.get(scope);+ if (!boards) { boards = new Set(); CHECKPOINT_NOTICES.set(scope, boards); }if (boards.has(state.board)) return;boards.add(state.board);if (uploadPauseType(state.checkpointRefusal) && !firstUploadPauseNotice(state)) return;@@ -1132,7 +1133,7 @@ export async function relayOperation(root, operation, args, io, command, applyLo}let moves = CHECKPOINT_MOVES.get(io);if (!moves) { moves = new Set(); CHECKPOINT_MOVES.set(io, moves); }- if (moves.has(state.board)) CHECKPOINT_NOTICES.get(io)?.delete(state.board);+ if (!io.relayCommand && moves.has(state.board)) CHECKPOINT_NOTICES.get(io)?.delete(state.board);moves.add(state.board);let requestedMove;try {diff --git a/test/inbox-key-fixture.js b/test/inbox-key-fixture.jsindex 21828545..08b9736f 100644--- a/test/inbox-key-fixture.js+++ b/test/inbox-key-fixture.js@@ -46,13 +46,13 @@ export async function prepareKeylessInbox(box) {}/** Preserve both cursors while displaying a real obligation and refusing explicit acknowledgement. */-export async function readKeylessInbox(box, state) {+export async function readKeylessInbox(box, state, code = 'RELAY_KEY_MISSING') {const beforeCursor = cursor(box), beforeReceipts = receipts(box);const beforeShouts = shoutCursors(box);const read = await box.cli('inbox');assert.equal(read.code, 0, `inbox reads without the key: ${JSON.stringify(read.document?.error ?? null)}`);assert.equal(read.document.activity.receipt.recorded, false, 'an unavailable canonical receipt is never claimed');- assert.equal(read.document.activity.receipt.code, 'RELAY_KEY_MISSING', 'delivery reports why it remains unrecorded');+ assert.equal(read.document.activity.receipt.code, code, 'delivery reports why it remains unrecorded');const interrupt = read.document.activity.interrupts.find(entry => entry.shout === state.answer);assert.ok(interrupt, 'the answered decision remains visible despite the missing key');state.interrupt = interrupt.id;@@ -60,7 +60,7 @@ export async function readKeylessInbox(box, state) {assert.deepEqual(receipts(box), beforeReceipts, 'the read cannot forge a canonical delivery');assert.deepEqual(shoutCursors(box), beforeShouts, 'an unrecorded read cannot consume its answer through the unread projection');const acted = await box.cli('inbox', '--acted-on', state.interrupt);- assert.equal(acted.document?.error?.code, 'RELAY_KEY_MISSING', 'explicit acknowledgement stays an authenticated write');+ assert.equal(acted.document?.error?.code, code, 'explicit acknowledgement stays an authenticated write');assert.deepEqual(receipts(box), beforeReceipts, 'a refused acknowledgement changes no receipt');return read;}diff --git a/test/relay-auth-expired.test.js b/test/relay-auth-expired.test.jsindex eaa6de6c..b1793026 100644--- a/test/relay-auth-expired.test.js+++ b/test/relay-auth-expired.test.js@@ -7,6 +7,7 @@ import { fileURLToPath } from 'node:url';import { createDeviceKeys, signDeviceEnrollment } from '../src/relay-device-keys.js';import { ENGINE_VERSION } from '../src/machine.js';import { relayClientFixture } from './relay-client-fixture.js';+import { prepareKeylessInbox, readKeylessInbox } from './inbox-key-fixture.js';import { runFixtureGit } from './fixture-child.js';/** Revoke one private fixture credential through the real relay authorization endpoint. */@@ -33,6 +34,7 @@ async function assertLocalRead(box, board, ...args) {test('reads and status answer when the relay sign-in expired [H16,H5]', async t => {const box = await relayClientFixture(t);+ const obligation = await prepareKeylessInbox(box);await box.link();const seed = await box.cli('add', box.lane, 'local read fixture');assert.equal(seed.code, 0, seed.failure ?? 'the private real relay accepts a fixture move');@@ -45,7 +47,10 @@ test('reads and status answer when the relay sign-in expired [H16,H5]', async tawait assertLocalRead(box, board, 'show', String(seed.document.item.item_id));await assertLocalRead(box, board, 'list', '--all');await assertLocalRead(box, board, 'decisions');+ await readKeylessInbox(box, obligation, 'AUTH_REQUIRED');await assertLocalRead(box, board, 'inbox');+ const write = await box.cli('shout', 'all', 'must not bypass expired authentication');+ assert.equal(write.document?.error?.code, 'AUTH_REQUIRED', 'explicit writes still require relay authentication');await assertLocalRead(box, board, 'log');const view = await assertLocalRead(box, board, 'view', '--export', join(box.root, 'local-view.html'));assert.equal(existsSync(view.document.path), true, 'the local view export is available after relay auth refusal');diff --git a/test/relay-relink.test.js b/test/relay-relink.test.jsindex 481fa98e..6be6b8f4 100644--- a/test/relay-relink.test.js+++ b/test/relay-relink.test.js@@ -7,6 +7,7 @@ import { fileURLToPath } from 'node:url';import { randomUUID } from 'node:crypto';import { decodeBoardKey, seal, unseal } from '../src/seal.js';import { relayClientFixture } from './relay-client-fixture.js';+import { assertPersonUnlinkHistory } from './relay-exclusion-fixture.js';import { runFixtureGit } from './fixture-child.js';import { ENGINE_VERSION } from '../src/machine.js';@@ -18,8 +19,7 @@ test('a relink after relay off seals moves with the new key [H15,H17]', async tassert.equal((await box.cli('shout', 'all', 'before explicit unlink')).code, 0);const beforeOff = (await box.cli('export')).document;assert.equal((await box.cli('relay', 'off')).code, 0);- assert.deepEqual((await box.cli('export')).document.tables, beforeOff.tables,- 'local unlink does not rewrite native history or board identity');+ assertPersonUnlinkHistory((await box.cli('export')).document.tables, beforeOff.tables);assert.equal((await box.cli('relay', 'on', '--url', box.origin)).code, 0);const linked = JSON.parse(readFileSync(box.linkFile, 'utf8'));assert.notEqual(linked.board, oldLink.board, 'forgetting the key requires a fresh remote board');diff --git a/test/relay-stuck-upload.test.js b/test/relay-stuck-upload.test.jsindex 2e649243..6cf5362d 100644--- a/test/relay-stuck-upload.test.js+++ b/test/relay-stuck-upload.test.js@@ -547,14 +547,25 @@ test('a refused later checkpoint names each distinct ordered move with the sameconst second = await relayOperation(root, 'shout', [{ from: 'coordinator', to: 'all', text: 'same io second ordered move', lanes: [] }], io);await syncRelay(root, io);await syncRelay(root, io);- console.log(JSON.stringify({ first: Number.isSafeInteger(first), second: Number.isSafeInteger(second), firstCount, lines: notices() }));+ const directCount = notices().length;+ io.relayCommand = { cliOperation: 'submit', cwd: root };+ await syncRelay(root, io);+ await relayOperation(root, 'shout', [{ from: 'coordinator', to: 'all', text: 'command bookkeeping first', lanes: [] }], { ...io });+ await relayOperation(root, 'shout', [{ from: 'coordinator', to: 'all', text: 'command bookkeeping second', lanes: [] }], { ...io });+ const commandCount = notices().length;+ io.relayCommand = { cliOperation: 'submit', cwd: root };+ await syncRelay(root, io);+ await relayOperation(root, 'shout', [{ from: 'coordinator', to: 'all', text: 'next independent command', lanes: [] }], io);+ console.log(JSON.stringify({ first: Number.isSafeInteger(first), second: Number.isSafeInteger(second), firstCount, directCount, commandCount, lines: notices() }));`);assert.equal(result.code, 0);assert.equal(result.document.first, true);assert.equal(result.document.second, true);- assert.equal(box.moveAcks.length - before, 2, 'both distinct moves are acknowledged through the real ordered relay');+ assert.equal(box.moveAcks.length - before, 5, 'all distinct moves are acknowledged through the real ordered relay');assert.equal(result.document.firstCount, 1, 'preflight, one move and repeated synchronization share one diagnostic');- assert.equal(result.document.lines.length, 2, 'two distinct acknowledged moves sharing io each name the refused checkpoint');+ assert.equal(result.document.directCount, 2, 'two distinct acknowledged moves sharing io each name the refused checkpoint');+ assert.equal(result.document.commandCount, 3, 'preflight and cloned bookkeeping io share one logical command notice');+ assert.equal(result.document.lines.length, 4, 'the next independent command sharing io receives a fresh notice');for (const line of result.document.lines) {assert.match(line, /relay checkpoint refused for [0-9a-f]{32}: BAD_UPLOAD malformed sealed snapshot/u);assert.match(line, /moves still sync in order.*npm i -g pullboard.*relay off then relay on --all/u);