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(rules): distinguish portable and path-bound proof [S1,C7]

Corey Olson87bcfa418b88
diff --git a/test/rule-proof-counts.test.js b/test/rule-proof-counts.test.js
index 1add8eba..a99bcf2e 100644
--- a/test/rule-proof-counts.test.js
+++ b/test/rule-proof-counts.test.js
@@ -16,6 +16,7 @@ import {
import { loadSpec } from '../src/spec.js';
import { createE2eHelpers } from './e2e-helpers.js';
import { fetchFresh } from './http-fixture.js';
+import { runFixtureChild } from './fixture-child.js';
const helpers = createE2eHelpers();
test.after(helpers.cleanup);
@@ -141,3 +142,58 @@ test('a read-only legacy board retains recent red counts and exact expiry withou
assert.equal(box.board.db.prepare('SELECT total_changes() AS n').get().n, changes);
assert.deepEqual(box.board.db.prepare('SELECT event_id,event_detail FROM event ORDER BY event_id').all(), snapshot);
});
+
+/** Simulate only a private reader's parser context after imports; the child still runs the real current Node. */
+function simulatedReaderContext(box, identity) {
+ const script = `
+import * as store from ${JSON.stringify(new URL('../src/board.js', import.meta.url).href)};
+import { ruleProofCounts } from ${JSON.stringify(new URL('../src/rule-proof-counts.js', import.meta.url).href)};
+import { loadSpec } from ${JSON.stringify(new URL('../src/spec.js', import.meta.url).href)};
+const root = ${JSON.stringify(box.root)};
+const actualRuntime = { execPath: process.execPath, version: process.version };
+const board = store.openBoard(${JSON.stringify(join(box.root, '.git', 'pullboard', 'board.sqlite'))}, undefined, { isMain: false });
+const rows = loadSpec(root, { spec: 'SPEC.md' }).rows;
+const simulated = ${JSON.stringify(identity)};
+Object.defineProperty(process, 'execPath', { value: simulated.execPath });
+Object.defineProperty(process, 'version', { value: simulated.version });
+board.db.exec('PRAGMA query_only=ON');
+try {
+ const before = board.db.prepare('SELECT total_changes() AS n').get().n;
+ const ruleCounts = ruleProofCounts(root, board, rows);
+ const after = board.db.prepare('SELECT total_changes() AS n').get().n;
+ console.log(JSON.stringify({ actualRuntime, simulated, ruleCounts, writes: after - before }));
+} finally { store.closeBoard(board); }
+`;
+ const result = runFixtureChild(process.execPath, ['--input-type=module', '-e', script], {
+ cwd: box.root, env: box.env, encoding: 'utf8',
+ });
+ assert.equal(result.status, 0, result.failure ?? result.stderr);
+ const document = JSON.parse(result.stdout.trim());
+ assert.deepEqual(document.actualRuntime, { execPath: process.execPath, version: process.version },
+ 'this fixture simulates read-context properties; it does not claim an alternate runtime executed');
+ assert.equal(document.writes, 0);
+ return document.ruleCounts;
+}
+
+test('literal-node rule proof survives simulated reader runtime changes while absolute-node proof stays path-bound [S1,A1,A2,C7]', (t) => {
+ const literal = fixture();
+ const absolute = fixture();
+ t.after(() => { store.closeBoard(literal.board); store.closeBoard(absolute.board); });
+ seedRun(literal);
+ const changedContext = { execPath: process.execPath + '.other-installation', version: 'v24.0.0' };
+ assert.equal(simulatedReaderContext(literal, changedContext).proven, 2,
+ 'literal node coverage is independent of the reader installation path and supported version');
+ const command = JSON.stringify(process.execPath) + ' --test test/proven.test.js test/both.test.js';
+ writeFileSync(join(absolute.root, 'pullboard.json'), JSON.stringify({ ...helpers.CONFIG, gate: command }));
+ absolute.git(absolute.root, 'add', 'pullboard.json');
+ absolute.git(absolute.root, 'commit', '-q', '-m', 'chore(fixture): configure absolute Node gate');
+ absolute.head = absolute.git(absolute.root, 'rev-parse', 'HEAD').trim();
+ seedRun(absolute, { command });
+ const samePath = { execPath: process.execPath, version: 'v24.0.0' };
+ assert.equal(simulatedReaderContext(absolute, samePath).proven, 2,
+ 'an unchanged absolute command path keeps its proof across reader version labels');
+ assert.equal(simulatedReaderContext(absolute, changedContext).proven, 0,
+ 'a reader with another executable path does not reinterpret the absolute command');
+ assert.equal(simulatedReaderContext(literal, changedContext).proven, 2,
+ 'separate absolute-command records never downgrade the literal-node board');
+});