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(core): retain refused handoff actor audit receipts [B3,H16]
Corey Olsondc3a501e2b4c
diff --git a/src/board-event-log.js b/src/board-event-log.jsindex be24eeb8..cd5906a7 100644--- a/src/board-event-log.js+++ b/src/board-event-log.js@@ -17,7 +17,8 @@ import { ensureProofCounters } from './proof-counters.js';* @param {Date} [at] An enabled move may share one instant with its deadline.*/export function logEvent(board, by, kind, itemId, detail = {}, at) {- requireHandoffActive(board, by, kind, [{ item: kind === 'shout' ? detail.item : undefined }]);+ // A refused authenticated request remains auditable; it is not an outgoing board move.+ if (kind !== 'relay_refused') requireHandoffActive(board, by, kind, [{ item: kind === 'shout' ? detail.item : undefined }]);board.db.exec('SAVEPOINT proof_event_append');try {ensureProofCounters(board);diff --git a/src/engine.js b/src/engine.jsindex 039d014f..373f7717 100644--- a/src/engine.js+++ b/src/engine.js@@ -1,4 +1,5 @@import { HANDOFF_ENGINE } from './handoff-engine.js';+import { handoffMoveProblem } from './handoff-state.js';import { requireHandoffActive } from './handoff-state.js';import { BAR_READY_ENGINE } from './bar-ready-engine.js';import { barReadySetting } from './bar-readiness.js';@@ -340,7 +341,9 @@ function registrationProblem(board, move, { sender, registration, sequence, digeexport function applyRelayMove(board, move, { sequence, at, sender, kind, digest = null, registration }) {requireSupportedEngine(move);const phoneReceipt = sender?.kind === 'machine' && move?.engine >= 6 && Boolean(move.personRequest) && !requestMoveProblem(board, move, { checkExecutorLease: false });- const problem = relaySenderProblem(move, sender, kind, { phoneReceipt }) ?? (kind === 'move' ? registrationProblem(board, move, { sender, registration, sequence, digest }) : null);+ const problem = relaySenderProblem(move, sender, kind, { phoneReceipt })+ ?? (kind === 'move' ? handoffMoveProblem(board, relayMoveActor(move), move.operation, move.args) : null)+ ?? (kind === 'move' ? registrationProblem(board, move, { sender, registration, sequence, digest }) : null);if (!problem) {// Engine-48 relay moves run under linked verifier standing; older recorded moves replay as they did.// The person is above every seat; their own moves act with the coordinator's standing.diff --git a/src/handoff-state.js b/src/handoff-state.jsindex 58e17c2a..2caf1ebf 100644--- a/src/handoff-state.js+++ b/src/handoff-state.js@@ -17,10 +17,16 @@ export function itemHandoff(board, item) {}/** Refuse a replaced seat before any move, except a message on its exact hand-off item. */-export function requireHandoffActive(board, actor, operation, args) {+export function handoffMoveProblem(board, actor, operation, args) {if (typeof actor !== 'string' || actor === 'person' || actor === 'coordinator') return;const handoff = agentHandoff(board, actor);if (!handoff?.takenAt) return;if (operation === 'shout' && args?.[0]?.item === handoff.item) return;- throw new Refused('AGENT_REPLACED', `${actor} was taken over by ${handoff.incoming} at ${handoff.takenAt}; only pullboard shout --item ${handoff.item} "<answer for the incoming agent>" remains available`);+ return new Refused('AGENT_REPLACED', `${actor} was taken over by ${handoff.incoming} at ${handoff.takenAt}; only pullboard shout --item ${handoff.item} "<answer for the incoming agent>" remains available`);+}++/** Raise the same replacement refusal at native writes and deterministic engine dispatch. */+export function requireHandoffActive(board, actor, operation, args) {+ const problem = handoffMoveProblem(board, actor, operation, args);+ if (problem) throw problem;}diff --git a/test/handoff.test.js b/test/handoff.test.jsindex 7ef75d74..9dcfdf04 100644--- a/test/handoff.test.js+++ b/test/handoff.test.js@@ -90,8 +90,10 @@ test('handoff takeover prints real work and retires only the outgoing seat [B3,Nassert.ok(taken.document.facts.some(row => row.text.includes('Outside scratch')));assert.ok(taken.document.facts.some(row => row.kind === 'note' && row.text.includes(box.clock.now().toISOString())));assert.equal(store.getItem(box.board, item).item_owner, outgoing, 'takeover reports claims; it does not silently reassign work');+ const beforeBlockedFact = store.events(box.board).length;const blocked = await box.cli(0, ['fact', String(id), 'note', 'not a permitted post-takeover move']);assert.equal(blocked.document.error.code, 'AGENT_REPLACED');+ assert.equal(store.events(box.board).length, beforeBlockedFact, 'a refused fact leaves no partial event');assert.match(blocked.document.error.message, new RegExp(incoming, 'u'));assert.equal((await box.cli(0, ['shout', 'coordinator', 'a different channel'])).document.error.code, 'AGENT_REPLACED');assert.equal((await box.cli(0, ['shout', '--item', String(item), 'wrong item'])).document.error.code, 'AGENT_REPLACED');@@ -119,6 +121,7 @@ test('handoff takeover is first-wins and cannot be forged by facts or an authentassert.equal(box.replay('takeHandoff', [{ agentId: other, item: id }], other).error.code, 'HANDOFF_TAKEN');assert.equal(store.events(box.board).filter(row => row.event_kind === 'handoff-take').length, 1);const count = store.listItems(box.board, { all: true }).length;+ assert.equal(box.replay('addItem', [{ by: incoming, lane: 'core', title: 'Spoof incoming', route: 'strong' }], outgoing).error.code, 'RELAY_SENDER_MISMATCH', 'authentication refusals stay auditable after retirement');for (const engine of [1, ENGINE_VERSION]) {assert.equal(box.replay('addItem', [{ by: outgoing, lane: 'core', title: 'Old actor must fail', route: 'strong' }], outgoing, engine).error.code, 'AGENT_REPLACED');}@@ -138,5 +141,7 @@ test('handoff rejects main and ordinary items, and a closed untaken channel is rassert.notEqual(next.item, first.item);assert.throws(() => store.takeHandoff(box.board, { agentId: incoming, item: first.item }), error => error.code === 'NO_HANDOFF');assert.equal(store.takeHandoff(box.board, { agentId: incoming, item: next.item }).incoming, incoming);+ const beforeRefusedFact = store.events(box.board).length;assert.throws(() => store.appendFact(box.board, next.item, { agentId: outgoing, kind: 'note', text: 'direct store is also refused' }), error => error.code === 'AGENT_REPLACED');+ assert.equal(store.events(box.board).length, beforeRefusedFact);});