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(engine): version dependency edits before replay [B3,A5]
Corey Olson414e5cfd54a4
diff --git a/docs/formats.md b/docs/formats.mdindex 6cd1c4e3..43b4a140 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -107,7 +107,7 @@ The board file is in the repository's Git common directory at `.git/pullboard/boPullboard 0.6.1 released engine 1. Engine 2 records a fresh explicit-build claim's skipped-review snapshot. Pullboard 0.8.1 released engine 3, including lane-sensitive graft refusals and authenticated relay senders. Engine 4 adds captured background-baseline completions through `completeCheckBaseline`; released engine-3 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Engine 5 requires a one-line reason when releasing a review and gives that reviewer a one-hour cooldown for the current submission. Each sealed move replays under its recorded engine version: engines 1 through 4 retain the original release event and review-reservation behavior. Engine 5 retains support for older moves, including engine-4 baseline completions. Pullboard 0.8.3 released engine 6, adding board-scoped machine credentials and permitting machine execution only for one exact, earlier authenticated phone request, including its payload digest. Engine 7 adds ordered item holds through `holdItem` and `releaseItemHold`; engine-6 clients stop with `ENGINE_VERSION` before interpreting either operation or advancing their replay cursor. Engine 8, shared by the 0.8.5 move changes, retains merged-item exception notes, selects the next review in roadmap order, and adds coordinator-only `reopen` for a submission returned without a verdict; engine-7 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Recorded engines 1 through 7 retain their original tier-first review selection. Engine 8 also adds durable refusal recovery for blocked relay positions; each explicit skip publishes the readable prefix even when another unsupported record follows. Engine 8 also permits coordinator criterion/check edits on a live claim as pending corrections; the holder cannot renew or submit until a refreeze adopts the correction while preserving the claim. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new moves. Each release shares one engine bump across its changed moves. Engine 8 also retains declared model labels on registration and records each registered agent move's model snapshot; engines 1 through 7 retain their original registration and event details without these model fields. Pullboard 0.8.8 released engine 9, which allows resubmitting the same rejected commit after a corrected criterion is refrozen, but only when the rejection names a different frozen digest. Engine 8 retains its HEAD_NOT_NEW refusal and prior submit-event detail. Engine-9 submit events add `criterionDigest`, and engine-8 boards replay with the original refusal and event history.-Engine 10 adds coordinator-only reopening for an unmerged verified item after a red landing candidate. Its append-only `reopen` event names the superseded accept, failing test and landing merge commit; the original accept and verdict remain in history. Engines 8 and 9 retain their submitted-only `reopen` behavior: a verified-item reopen is refused without changing the replayed board. Only engine 10 may return a verified item to open, with a failing test and landing merge commit in the note.+Engine 10 adds coordinator-only reopening for an unmerged verified item after a red landing candidate. Its append-only `reopen` event names the superseded accept, failing test and landing merge commit; the original accept and verdict remain in history. Engines 8 and 9 retain their submitted-only `reopen` behavior: a verified-item reopen is refused without changing the replayed board. Only engine 10 may return a verified item to open, with a failing test and landing merge commit in the note. Dependency edits also require engine 10: an `editItem` move with `after`, including `after: []` to clear dependencies, cannot be replayed under an older engine. Ordinary edits without `after` retain their historical behavior. Older clients refuse an engine-10 move before changing their board or replay cursor; upgrade Pullboard before sending or applying dependency edits.The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.A linked board requires at least engine 3 after issuing any agent token, including@@ -296,7 +296,7 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `model` | agent | — || `moved` | coordinator | `path` || `add` | item creator | `lane`, `specIds`, `after`, `route` |-| `edit` | editor | `brief`, `route`, `criterion`, `check`, `unfrozen`, optional `pendingRefreeze` |+| `edit` | editor | `brief`, `route`, `criterion`, `check`, `unfrozen`, optional `after`, optional `pendingRefreeze` || `escalate` | builder | `from`, `to`, `note`, `attempt` || `attempt` | reporting agent | `n`, `seconds`, `result` || `fact` | author | `id`, `kind`, `text`, `ref`, `supersedes` |diff --git a/docs/formats.test.js b/docs/formats.test.jsindex 682652a4..b0a0d9bb 100644--- a/docs/formats.test.js+++ b/docs/formats.test.js@@ -276,6 +276,9 @@ function recordEventContract() {const fact = appendFact(board, first, { agentId: builder, kind: 'note', text: 'Captured evidence', ref: 'docs/formats.md:1-3@' + 'a'.repeat(40) });appendFact(board, first, { agentId: coordinator, kind: 'measurement', text: 'Corrected evidence', supersedes: fact.id });editItem(board, first, { agentId: coordinator, brief: 'Files: docs/formats.md\nTest: docs/formats.test.js', route: 'mid', criterion: 'Changed', check: 'node test' });+ const dependency = addItem(board, { by: coordinator, lane: 'docs', title: 'Dependency example' });+ editItem(board, first, { agentId: coordinator, after: [dependency] });+ editItem(board, first, { agentId: coordinator, after: [] });holdItem(board, first, { agentId: coordinator, reason: 'fixture item hold' });releaseItemHold(board, first, { agentId: coordinator });recordAttempt(board, first, { agentId: builder, n: 1, seconds: 2, result: 'failed' });diff --git a/src/board.js b/src/board.jsindex 2e18e1e2..c9769830 100644--- a/src/board.js+++ b/src/board.js@@ -777,6 +777,10 @@ export function editItem(board, id, { agentId, brief, route, criterion, check, a/** Validate an edit without side effects, so a refused change never starts a shell baseline. */export function validateItemEdit(board, id, { agentId, brief, route, criterion, check, after }) {+ const engine = board.executionEngineVersion ?? ENGINE_VERSION;+ if (after !== undefined && engine < 10) {+ throw new Refused('ENGINE_VERSION', `editing item dependencies requires engine 10; this board uses engine ${engine}; upgrade Pullboard before using --after`);+ }let item = (board.executionEngineVersion ?? ENGINE_VERSION) >= 8 ? current(board, itemById(board, id)) : null;if (item?.item_status === 'claimed' && agentId !== COORDINATOR) {throw new Refused('HELD', `item #${id} is claimed; only the coordinator may edit it while held; shout coordinator`);@@ -792,7 +796,12 @@ export function validateItemEdit(board, id, { agentId, brief, route, criterion,if (['verified', 'withdrawn'].includes(item.item_status)) {throw new Refused('CLOSED', `item #${id} is ${item.item_status}`);}- if (after !== undefined) validateItemDependencies(board, id, after);+ if (after !== undefined) {+ if (!Array.isArray(after) || !after.every((dependency) => Number.isSafeInteger(dependency) && dependency > 0)) {+ throw new Refused('BAD_DEPENDENCIES', 'item dependencies must be an array of positive integer item ids; use --after 1,2 or --after none');+ }+ validateItemDependencies(board, id, after);+ }const next = {item_brief: brief === undefined ? item.item_brief : brief.trim(),item_route: route ?? item.item_route,diff --git a/src/engine.js b/src/engine.jsindex 5106f608..3b5c167c 100644--- a/src/engine.js+++ b/src/engine.js@@ -22,6 +22,13 @@ export const ENGINE_OPERATIONS = Object.freeze([/** Engine version at which each ordered operation first has stable replay semantics. */const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8 });+/** Dependency edits add engine-10 meaning without changing ordinary historical edit envelopes. */+function minimumOperationEngine(operation, args) {+ const options = args[1];+ return operation === 'editItem' && options && Object.hasOwn(options, 'after') && options.after !== undefined+ ? 10 : OPERATION_ENGINE[operation] ?? 1;+}+/** Read a replica's committed prefix without trusting an independently saved transport cursor. */export function appliedSequence(board) {const row = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get('relay_applied_sequence');@@ -58,7 +65,7 @@ export function startRelayEpoch(board) {/** Turn caller-only callbacks into deterministic values before sealing an executable operation. */export function prepareEngineMove(board, operation, args, { id = randomUUID(), actor } = {}) {if (!ENGINE_OPERATIONS.includes(operation) || !Array.isArray(args)) throw new Refused('RELAY_MOVE', 'use a supported board-engine operation with its argument array');- const minimumEngine = OPERATION_ENGINE[operation] ?? 1;+ const minimumEngine = minimumOperationEngine(operation, args);if (ENGINE_VERSION < minimumEngine) throw new Refused('ENGINE_VERSION', `${operation} requires engine version ${minimumEngine}; this pullboard uses engine ${ENGINE_VERSION}; upgrade before sending it`);const values = args.map((value) => value && typeof value === 'object' ? { ...value } : value);if (operation === 'release') {@@ -96,7 +103,7 @@ function validateMove(move) {if (!move || move.version !== 1 || !Number.isSafeInteger(move.engine) || move.engine < 1) throw new Refused('RELAY_MOVE', 'this executable move format is invalid; upgrade pullboard or restore a consistent relay snapshot');requireSupportedEngine(move);if (typeof move.id !== 'string' || !/^[A-Za-z0-9_-]{1,80}$/.test(move.id) || !ENGINE_OPERATIONS.includes(move.operation) || !Array.isArray(move.args)) throw new Refused('RELAY_MOVE', 'this sealed operation is invalid; use a supported board-engine operation');- const minimumEngine = OPERATION_ENGINE[move.operation] ?? 1;+ const minimumEngine = minimumOperationEngine(move.operation, move.args);if (move.engine < minimumEngine) throw new Refused('RELAY_MOVE', `${move.operation} cannot be replayed from engine version ${move.engine}; it was introduced in engine ${minimumEngine}; restore a consistent relay prefix`);}diff --git a/test/pending-refreeze.test.js b/test/pending-refreeze.test.jsindex 4d354aeb..7fed54dd 100644--- a/test/pending-refreeze.test.js+++ b/test/pending-refreeze.test.js@@ -3,11 +3,14 @@ import assert from 'node:assert/strict';import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';+import { pathToFileURL } from 'node:url';import { test } from 'node:test';import * as store from '../src/board.js';-import { applyRelayMove, prepareEngineMove } from '../src/engine.js';+import { appliedSequence, applyRelayMove, prepareEngineMove } from '../src/engine.js';import { exportBoard, importBoard } from '../src/exchange.js';+import { ENGINE_VERSION } from '../src/machine.js';import { createE2eHelpers } from './e2e-helpers.js';+import { unpackRelease } from './release-archive.js';const e2e = createE2eHelpers();@@ -188,6 +191,137 @@ test("edit adds and clears an item's dependencies [B3,V2]", (t) => {assert.ok(store.events(board, { itemId: claimed }).some((event) => event.event_kind === 'refreeze'), 'the holder refreeze is recorded in history');});+/** Exercise real older executables, rather than treating a retagged current move as an old client. */+async function checkDependencyLegacyClients(cleanup, directory, snapshot, target, add, clear) {+ for (const [version, reference] of [[7, 'v0.8.4'], [8, 'v0.8.6'], [9, '314ef28751c44c96186b337cc4ace0fd8bf33d42']]) {+ const source = join(directory, `client-${version}`);+ mkdirSync(source);+ unpackRelease(reference, source);+ const legacyStore = await import(pathToFileURL(join(source, 'src/board.js')).href);+ const legacyEngine = await import(pathToFileURL(join(source, 'src/engine.js')).href);+ const legacyExchange = await import(pathToFileURL(join(source, 'src/exchange.js')).href);+ const legacyMachine = await import(pathToFileURL(join(source, 'src/machine.js')).href);+ assert.equal(legacyMachine.ENGINE_VERSION, version, 'the archived executable has the claimed engine');+ const old = legacyStore.openBoard(join(directory, `client-${version}.sqlite`));+ const current = store.openBoard(join(directory, `current-from-${version}.sqlite`));+ cleanup.push(() => { legacyStore.closeBoard(old); store.closeBoard(current); });+ legacyExchange.importBoard(old, snapshot);+ importBoard(current, snapshot);+ const ordinary = legacyEngine.prepareEngineMove(old, 'editItem', [target, {+ agentId: 'coordinator', brief: `Ordinary edit from actual engine ${version}.`,+ }], { id: `ordinary-client-${version}`, actor: 'coordinator' });+ const receipt = { sequence: 1, at: '2026-10-13T12:00:01.000Z', kind: 'move',+ sender: { kind: 'agent', userId: 'fixture-user', agent: 'coordinator' } };+ const oldResult = legacyEngine.applyRelayMove(old, ordinary, receipt);+ assert.equal(oldResult.error, undefined, JSON.stringify(oldResult));+ const result = applyRelayMove(current, ordinary, receipt);+ assert.equal(result.error, undefined, JSON.stringify(result));+ assert.deepEqual(store.getItem(current, target), legacyStore.getItem(old, target), 'ordinary legacy edits retain their exact row');+ assert.deepEqual(store.events(current), legacyStore.events(old), 'ordinary legacy edits retain their event history');+ const before = legacyExchange.exportBoard(old);+ for (const move of [add, clear]) {+ assert.throws(() => legacyEngine.applyRelayMove(old, move, { ...receipt, sequence: 2 }),+ (error) => error.code === 'ENGINE_VERSION', 'a genuine future envelope is refused by the actual old client');+ assert.deepEqual(legacyExchange.exportBoard(old), before, 'future refusal changes no board rows or replay metadata');+ assert.equal(legacyEngine.appliedSequence(old), 1, 'future refusal leaves the committed prefix unchanged');+ }+ }+}++test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {+ assert.equal(ENGINE_VERSION, 10);+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));+ const cleanup = [];+ t.after(() => {+ for (const close of cleanup) close();+ rmSync(directory, { recursive: true, force: true });+ });+ /** Open a private, file-backed SQLite board and optionally import its real snapshot. */+ function open(name, snapshot) {+ const board = store.openBoard(join(directory, `${name}.sqlite`));+ cleanup.push(() => store.closeBoard(board));+ if (snapshot) importBoard(board, snapshot);+ return board;+ }+ const seed = open('seed');+ store.register(seed, { lane: 'coordinator', path: '/dependency/coordinator' });+ /** Add independent real items to the seed board. */+ function addItem(title) {+ return store.addItem(seed, { by: 'coordinator', lane: 'web', title, criterion: title, brief: e2e.LIGHT_BRIEF });+ }+ const dependency = addItem('First prerequisite');+ const secondDependency = addItem('Second prerequisite');+ const target = addItem('Work with dependencies');+ const snapshot = exportBoard(seed);+ const sender = { kind: 'agent', userId: 'fixture-user', agent: 'coordinator' };+ const add = prepareEngineMove(seed, 'editItem', [target, { agentId: 'coordinator', after: [dependency, secondDependency] }],+ { id: 'dependency-add', actor: 'coordinator' });+ const clear = prepareEngineMove(seed, 'editItem', [target, { agentId: 'coordinator', after: [] }],+ { id: 'dependency-clear', actor: 'coordinator' });+ assert.equal(add.engine, 10);+ assert.equal(clear.engine, 10);+ const copies = [open('one', snapshot), open('two', snapshot)];+ for (const [index, move] of [add, clear].entries()) {+ const receipt = { sequence: index + 1, at: `2026-10-13T12:00:0${index + 1}.000Z`, sender, kind: 'move' };+ const results = copies.map((board) => applyRelayMove(board, move, receipt));+ assert.equal(results[0].error, undefined, JSON.stringify(results[0]));+ assert.deepEqual(results[1], results[0]);+ assert.deepEqual(exportBoard(copies[1]), exportBoard(copies[0]), 'current replicas have identical rows, events and prefix');+ assert.equal(store.getItem(copies[0], target).item_after, index === 0 ? `${dependency},${secondDependency}` : '');+ const event = store.events(copies[0], { itemId: target }).findLast((entry) => entry.event_kind === 'edit');+ assert.deepEqual(JSON.parse(event.event_detail).after, index === 0 ? [dependency, secondDependency] : []);+ assert.equal(appliedSequence(copies[0]), index + 1);+ }+ for (let version = 1; version < 10; version++) {+ const board = open(`tag-${version}`, snapshot);+ const ordinary = prepareEngineMove(board, 'editItem', [target, {+ agentId: 'coordinator', brief: `Ordinary historical engine ${version}.`, after: undefined,+ }], { id: `ordinary-tag-${version}`, actor: 'coordinator' });+ assert.equal(Object.hasOwn(ordinary.args[1], 'after'), false, 'an omitted CLI flag stays omitted on the wire');+ ordinary.engine = version;+ const receipt = { sequence: 1, at: '2026-10-13T12:00:01.000Z', sender, kind: 'move' };+ let result;+ assert.doesNotThrow(() => { result = applyRelayMove(board, ordinary, receipt); },+ `ordinary engine-${version} edits remain executable`);+ assert.equal(result.error, undefined, `ordinary engine-${version} edit remains valid: ${JSON.stringify(result)}`);+ const event = store.events(board, { itemId: target }).findLast((entry) => entry.event_kind === 'edit');+ assert.equal(Object.hasOwn(JSON.parse(event.event_detail), 'after'), false);+ const before = exportBoard(board);+ for (const move of [add, clear]) {+ assert.throws(() => applyRelayMove(board, { ...move, id: `${move.id}-tag-${version}`, engine: version },+ { ...receipt, sequence: 2 }), (error) => error.code === 'RELAY_MOVE' && /engine 10/u.test(error.message),+ 'old-tag dependency fields, including empty-on-empty clears, cannot enter replay');+ assert.deepEqual(exportBoard(board), before, 'malformed old-tag moves change no row, event, receipt or cursor');+ }+ board.executionEngineVersion = version;+ try {+ for (const after of [[dependency], []]) {+ for (const edit of [store.validateItemEdit, store.editItem]) {+ assert.throws(() => edit(board, target, { agentId: 'coordinator', after }),+ (error) => error.code === 'ENGINE_VERSION' && error.message.includes(`engine ${version}`)+ && /engine 10/u.test(error.message) && /upgrade/iu.test(error.message));+ assert.deepEqual(exportBoard(board), before, 'direct and preflight old-engine dependency refusals change nothing');+ }+ }+ } finally { delete board.executionEngineVersion; }+ }+ for (const [index, after] of [null, '1', {}, [0], [-1], [1.5], [{}], ['1']].entries()) {+ const board = open(`invalid-${index}`, snapshot);+ const before = store.getItem(board, target);+ const beforeEvents = store.events(board);+ const move = prepareEngineMove(board, 'editItem', [target, { agentId: 'coordinator', after }],+ { id: `invalid-dependencies-${index}`, actor: 'coordinator' });+ let result;+ assert.doesNotThrow(() => { result = applyRelayMove(board, move, { sequence: 1, at: '2026-10-13T12:00:01.000Z', sender, kind: 'move' }); },+ 'malformed dependencies are a typed operation refusal, never an unhandled exception');+ assert.equal(result.error?.code, 'BAD_DEPENDENCIES', 'malformed current dependencies yield a typed refusal');+ assert.deepEqual(store.getItem(board, target), before);+ assert.deepEqual(store.events(board), beforeEvents, 'a typed operation refusal creates no edit event');+ assert.equal(appliedSequence(board), 1, 'the refused current operation has one consumed receipt');+ }+ await checkDependencyLegacyClients(cleanup, directory, snapshot, target, add, clear);+});+test('ordered refreeze corrections retain engine-7 history and engine-8 live claims [V2,H16]', (t) => {const replicaDirectory = mkdtempSync(join(tmpdir(), 'pullboard-refreeze-replicas-'));const replicaBoards = [];