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.

chore: compose indexed proof baseline for npm gate check [S1,A1,A2]

Corey Olson3de90f4330c3
diff --cc test/rule-proof-counts.test.js
index 84f9f657,a99bcf2e..b61da450
--- a/test/rule-proof-counts.test.js
+++ b/test/rule-proof-counts.test.js
@@@ -101,43 -108,92 +108,133 @@@ test('the server reports how many rule
assert.deepEqual((await documents(empty, api)).map(document => document.ruleCounts), [none, none]);
});
+ test('a read-only legacy board retains recent red counts and exact expiry without warming proof indexes [S1,A1,A2,C7]', (t) => {
+ const box = fixture();
+ t.after(() => store.closeBoard(box.board));
+ seedRun(box, { green: false, days: 2,
+ failures: [{ file: 'test/contradicted.test.js', name: 'legacy recent red' }] });
+ seedRun(box, { green: false, days: 1, kind: 'submit',
+ failures: [{ file: 'test/unproven.test.js', name: 'submission is not trunk gate proof' }] });
+ seedRun(box);
+ const runs = store.gateRuns(box.board);
+ const red = runs.find(run => run.kind === 'gate' && !run.green);
+ const submit = runs.find(run => run.kind === 'submit');
+ assert.ok(red && submit, 'the private board has validated historical receipts of both kinds');
+ // A pre-projection board or a disposable cache loss keeps its authoritative native history.
+ clearProofCounters(box.board);
+ const rows = loadSpec(box.root, { spec: 'SPEC.md' }).rows;
+ const snapshot = box.board.db.prepare('SELECT event_id,event_detail FROM event ORDER BY event_id').all();
+ const changes = box.board.db.prepare('SELECT total_changes() AS n').get().n;
+ box.board.db.exec('PRAGMA query_only=ON');
+ const week = 7 * 86_400_000;
+ const end = Date.parse(red.at) + week;
+ const atBoundary = ruleProofCounts(box.root, box.board, rows, { now: end });
+ assert.equal(atBoundary.contradicted, 1, 'recent native trunk red remains visible at the inclusive seven-day boundary');
+ assert.equal(atBoundary.proven, 0, 'missing coverage projection never invents green proof');
+ assert.deepEqual(ruleProofWindow(box.board, new Date(end).toISOString()), {
+ events: [red.eventId, submit.eventId], nextExpiry: new Date(end + 1).toISOString(),
+ }, 'the window deliberately retains submit-red invalidation while proof counts exclude it');
+ const expired = ruleProofCounts(box.root, box.board, rows, { now: end + 1 });
+ assert.equal(expired.contradicted, 0, 'the native red expires one millisecond after seven days without a write');
+ assert.deepEqual(ruleProofWindow(box.board, new Date(end + 1).toISOString()), {
+ events: [submit.eventId], nextExpiry: new Date(Date.parse(submit.at) + week + 1).toISOString(),
+ });
+ 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');
+ });
++
+test('a gate command with npm flags counts as opaque [S1,A1,A2]', async (t) => {
+ const script = 'node --test test/proven.test.js';
+ const scripts = { test: script, 'integration-test': script, '--if-present': script, '--silent': script, '-s': script, '--': script };
+ const cases = [
+ ['npm test', 1],
+ ['npm run test', 1],
+ ["npm run 'integration-test'", 1],
+ ['npm run test && node --test test/proven.test.js', 1],
+ ['npm run --if-present', 0],
+ ['npm run --silent', 0],
+ ['npm run -s', 0],
+ ['npm run --', 0],
+ ["npm run '--if-present'", 0],
+ ['npm run --if-present test', 0],
+ ['npm run test --if-present', 0],
+ ['npm --silent run test', 0],
+ ['npm test --if-present', 0],
+ ['npm run test -- --test-name-pattern=proven', 0],
+ ['npm run --if-present && node --test test/proven.test.js', 0],
+ ['node --test test/proven.test.js && npm run --silent', 0],
+ ];
+ for (const [command, proven] of cases) {
+ const box = fixture();
+ t.after(() => store.closeBoard(box.board));
+ writeFileSync(join(box.root, 'package.json'), JSON.stringify({ private: true, type: 'module', scripts }));
+ writeFileSync(join(box.root, 'pullboard.json'), JSON.stringify({ ...helpers.CONFIG, gate: command }));
+ box.git(box.root, 'add', '-A');
+ box.git(box.root, 'commit', '-q', '-m', 'chore(fixture): configure the npm gate');
+ box.head = box.git(box.root, 'rev-parse', 'HEAD').trim();
+ // These historical records are seeded classification inputs, never a claim that npm ran the script.
+ seedRun(box, { command });
+ const api = await serveApi({ runCommand: main, isMain: true,
+ projects: () => [{ root: box.root, name: 'Npm gate proof fixture' }] });
+ try {
+ const seen = await documents(box, api);
+ const expected = { approved: 6, gated: 5, ungated: 1, proven, unproven: 5 - proven, contradicted: 0 };
+ assert.deepEqual(seen.map(document => document.ruleCounts), [expected, expected], command);
+ } finally { await api.close(); }
+ }
+});