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: extract rehome trigger assertions [M1,M3]

Corey Olsonb0c652928323
diff --git a/test/machine.test.js b/test/machine.test.js
index ecfaaede..9c2a0b80 100644
--- a/test/machine.test.js
+++ b/test/machine.test.js
@@ -18,6 +18,7 @@ import * as store from '../src/board.js';
import { HELP } from '../src/cli.js';
import { loadConfig } from '../src/config.js';
import { Refused } from '../src/refused.js';
+import { assertRehomeTriggerDeclaration } from './rehome-machine-fixture.js';
import {
runFixtureExecFile as execFileSync,
@@ -833,22 +834,7 @@ test('an older board gets the triggers quietly on its next open; one dropped by
});
test('the triggers come from the declaration, so a changed declaration changes them [M1, M3]', () => {
- const moveSql = (machine) => machineRules.storeTriggers(machine).find(({ name }) => name === 'machine_item_move').sql;
- const pairs = machineRules.MACHINE.moves.flatMap((move) => move.from.filter((from) => from !== move.to).map((from) => `'${from}>${move.to}'`));
- for (const pair of pairs) assert.ok(moveSql(machineRules.MACHINE).includes(pair), `the move trigger allows ${pair}`);
- // The only open-to-verified edge is the source-acceptance import, not a direct verdict.
- assert.deepEqual(machineRules.MACHINE.moves.filter((move) => move.from.includes('open') && move.to === 'verified').map((move) => move.verb), ['rehomeImport']);
- assert.ok(moveSql(machineRules.MACHINE).includes("'open>verified'"));
- const machine = copy();
- machine.moves.push({ verb: 'testDirectVerdict', from: ['withdrawn'], to: 'verified', by: ['coordinator'], refuse: 'CLOSED', guards: ['joined', 'coordinatorOnly', 'itemExists', machineRules.IN_STATE], sets: ['item_built_by', 'item_commit', 'item_frozen_digest'] });
- assert.ok(!moveSql(machineRules.MACHINE).includes("'withdrawn>verified'"));
- assert.ok(moveSql(machine).includes("'withdrawn>verified'"));
- const names = machineRules.storeTriggers().map(({ name }) => name);
- for (const state of machineRules.MACHINE.states.filter((entry) => entry.requires.length)) assert.ok(names.includes(`machine_fields_${state.id}`), `${state.id} has a fields trigger`);
- assert.ok(names.includes('machine_proof_verified'));
- const proof = machineRules.storeTriggers().find(({ name }) => name === 'machine_proof_verified').sql;
- assert.match(proof, /AND NOT \(EXISTS[\s\S]+ OR EXISTS[\s\S]+\)\nBEGIN/u,
- 'the imported proof alternative stays inside the verified proof refusal condition');
+ assertRehomeTriggerDeclaration();
});
test("a verified item's proof cannot be rewritten afterwards: its commit, builder, verifier or criterion [M3]", () => {
diff --git a/test/rehome-machine-fixture.js b/test/rehome-machine-fixture.js
new file mode 100644
index 00000000..129439a5
--- /dev/null
+++ b/test/rehome-machine-fixture.js
@@ -0,0 +1,22 @@
+import assert from 'node:assert/strict';
+import * as machineRules from '../src/machine.js';
+
+/** Keep declaration-derived trigger assertions beside the rehome lifecycle additions. */
+export function assertRehomeTriggerDeclaration() {
+ const moveSql = machine => machineRules.storeTriggers(machine).find(({ name }) => name === 'machine_item_move').sql;
+ const pairs = machineRules.MACHINE.moves.flatMap(move => move.from.filter(from => from !== move.to).map(from => `'${from}>${move.to}'`));
+ for (const pair of pairs) assert.ok(moveSql(machineRules.MACHINE).includes(pair), `the move trigger allows ${pair}`);
+ // The only open-to-verified edge is the source-acceptance import, not a direct verdict.
+ assert.deepEqual(machineRules.MACHINE.moves.filter(move => move.from.includes('open') && move.to === 'verified').map(move => move.verb), ['rehomeImport']);
+ assert.ok(moveSql(machineRules.MACHINE).includes("'open>verified'"));
+ const machine = structuredClone(machineRules.MACHINE);
+ machine.moves.push({ verb: 'testDirectVerdict', from: ['withdrawn'], to: 'verified', by: ['coordinator'], refuse: 'CLOSED', guards: ['joined', 'coordinatorOnly', 'itemExists', machineRules.IN_STATE], sets: ['item_built_by', 'item_commit', 'item_frozen_digest'] });
+ assert.ok(!moveSql(machineRules.MACHINE).includes("'withdrawn>verified'"));
+ assert.ok(moveSql(machine).includes("'withdrawn>verified'"));
+ const names = machineRules.storeTriggers().map(({ name }) => name);
+ for (const state of machineRules.MACHINE.states.filter(entry => entry.requires.length)) assert.ok(names.includes(`machine_fields_${state.id}`), `${state.id} has a fields trigger`);
+ assert.ok(names.includes('machine_proof_verified'));
+ const proof = machineRules.storeTriggers().find(({ name }) => name === 'machine_proof_verified').sql;
+ assert.match(proof, /AND NOT \(EXISTS[\s\S]+ OR EXISTS[\s\S]+\)\nBEGIN/u,
+ 'the imported proof alternative stays inside the verified proof refusal condition');
+}