Skip to content

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.

test(reopen): seed replay with the released writer [V2,V6,H16]

Corey Olsone31d2675f43b
diff --git a/test/reopen.test.js b/test/reopen.test.js
index dfece2b2..ceddd284 100644
--- a/test/reopen.test.js
+++ b/test/reopen.test.js
@@ -12,6 +12,7 @@ import { appliedSequence, applyRelayMove, engineReceipt, prepareEngineMove } fro
import { exportBoard, importBoard } from '../src/exchange.js';
import { ENGINE_VERSION } from '../src/machine.js';
import { QUOTED_LANDING_FAILURE_ENGINE } from '../src/quoted-landing-failure-engine.js';
+import { AGENT_GRANT_ENGINE } from '../src/agent-grant-engine.js';
import { createE2eHelpers } from './e2e-helpers.js';
import { unpackRelease } from './release-archive.js';
@@ -146,6 +147,7 @@ const engine9Source = '314ef28751c44c96186b337cc4ace0fd8bf33d42';
/** Compare verified-item reopen behavior across engines 8 through 10 and the current receiver. */
async function assertLegacyVerifiedReopen(t, box, item, note) {
+ let engine10Store, engine10Exchange;
for (const [version, reference] of [[8, 'v0.8.6'], [9, engine9Source], [10, 'v0.8.23']]) {
const directory = mkdtempSync(join(tmpdir(), `pullboard-engine-${version}-verified-reopen-`));
t.after(() => rmSync(directory, { recursive: true, force: true }));
@@ -676,6 +678,7 @@ test('a reopened bar takes the same commit again [V2,V6,H16]', async (t) => {
const legacyExchange = await import(pathToFileURL(join(legacyDirectory, 'src/exchange.js')).href);
const legacyMachine = await import(pathToFileURL(join(legacyDirectory, 'src/machine.js')).href);
assert.equal(legacyMachine.ENGINE_VERSION, version, `exercise the actual engine-${version} source`);
+ if (version === 10) { engine10Store = legacyStore; engine10Exchange = legacyExchange; }
const legacyReceiver = legacyStore.openBoard(join(box.dir, `engine-${version}-reopen.sqlite`));
t.after(() => legacyStore.closeBoard(legacyReceiver));
const submittedSnapshot = exportBoard(copies[0]);
@@ -768,8 +771,37 @@ test('a reopened bar takes the same commit again [V2,V6,H16]', async (t) => {
const builderSender = { kind: 'agent', userId: 'fixture-user', agent: 'web-1' };
const engine10Replica = store.openBoard(join(box.dir, 'engine-10-same-commit.sqlite'));
t.after(() => store.closeBoard(engine10Replica));
- importBoard(engine10Replica, exportBoard(claimedBoard));
const engine10Move = { ...engine11Move, id: 'same-commit-engine-10', engine: 10 };
+ const markedReplica = store.openBoard(join(box.dir, 'modern-grant-same-commit.sqlite'));
+ t.after(() => store.closeBoard(markedReplica));
+ importBoard(markedReplica, exportBoard(claimedBoard));
+ assert.throws(() => applyRelayMove(markedReplica, engine10Move, {
+ sequence: 1, at: '2026-10-10T12:00:02.000Z', kind: 'move', sender: builderSender,
+ }), error => error.code === 'RELAY_MOVE' && error.message.includes(String(AGENT_GRANT_ENGINE)),
+ 'an engine-10 move cannot interpret a current claim carrying the new grant marker');
+
+ // Seed the historical lifecycle with the actual released engine-10 writer, not by deleting modern markers.
+ // These are board-state fixtures only: neither direct submit call claims an executed gate.
+ const legacySeed = engine10Store.openBoard(join(box.dir, 'actual-engine10-submit-state.sqlite'));
+ t.after(() => engine10Store.closeBoard(legacySeed));
+ engine10Store.register(legacySeed, { lane: 'coordinator', path: box.repo });
+ const legacyBuilder = engine10Store.register(legacySeed, { lane: 'web', path: box.web });
+ const initialItem = store.getItem(copies[0], 1), correctedItem = store.getItem(claimedBoard, 1);
+ const legacyId = engine10Store.addItem(legacySeed, { by: 'coordinator', lane: 'web', title: initialItem.item_title,
+ criterion: initialItem.item_criterion, check: initialItem.item_check });
+ /** Reuse each criterion's real frozen bytes while the released writer records its own historical claim. */
+ const historicalFreeze = item => () => ({ text: item.item_frozen, digest: item.item_frozen_digest });
+ engine10Store.claim(legacySeed, legacyId, { agentId: legacyBuilder, lane: 'web', leaseMs: 60_000,
+ freeze: historicalFreeze(initialItem) });
+ engine10Store.submit(legacySeed, legacyId, { agentId: legacyBuilder, commit: submitted.commit, tree: submitted.tree });
+ engine10Store.reopen(legacySeed, legacyId, { agentId: 'coordinator', note: 'Historical criterion correction' });
+ engine10Store.editItem(legacySeed, legacyId, { agentId: 'coordinator', criterion: correctedItem.item_criterion });
+ engine10Store.claim(legacySeed, legacyId, { agentId: legacyBuilder, lane: 'web', leaseMs: 60_000,
+ freeze: historicalFreeze(correctedItem) });
+ const historicalSnapshot = engine10Exchange.exportBoard(legacySeed);
+ assert.ok(historicalSnapshot.tables.event.filter(row => ['join', 'claim'].includes(row.event_kind))
+ .every(row => JSON.parse(row.event_detail).grantEngine === undefined), 'the actual old writer emitted no future grant marker');
+ importBoard(engine10Replica, historicalSnapshot);
const oldBehavior = applyRelayMove(engine10Replica, engine10Move, {
sequence: 1, at: '2026-10-10T12:00:02.000Z', kind: 'move', sender: builderSender,
});