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
test: cover registry repair, policy and dirty snapshots [C7,V4]
Corey Olson4928aa13847f
diff --git a/src/gate.js b/src/gate.jsindex dca9be7c..89c693ce 100644--- a/src/gate.js+++ b/src/gate.js@@ -634,7 +634,8 @@ export async function runSubmitGate(root, config, { base, trunk, changed, check,? (proofFiles.length > 0 && (!allowBrowserFreeChecks || await testsNeedBrowser(root, proofFiles, { onFallback: onBrowserFallback }))): (selection.full || !allowBrowserFreeChecks || await testsNeedBrowser(root, proofFiles, { onFallback: onBrowserFallback }));const browser = checkUsesBrowser || proofUsesBrowser;- const gui = (check ? await checkNeedsGui(root, check) : false) || ((selection.full && !deferFullFallback && !deferSelection) ? projectNeedsGui(root) : testsNeedGui(root, proofFiles));+ const gui = (check ? await checkNeedsGui(root, check) : false)+ || ((selection.full && !deferFullFallback && !deferSelection) && projectNeedsGui(root)) || testsNeedGui(root, proofFiles);return await withGateSlot(root, async (lease) => {pinRunMain(lease, onFailure);const startedAt = Date.now();diff --git a/src/test-run.js b/src/test-run.jsindex 09e9f070..e11a624a 100644--- a/src/test-run.js+++ b/src/test-run.js@@ -127,7 +127,7 @@ export async function runTestFiles(root, config, files, { agent, onWait, affecteconst command = full ? `(${config.gate})${focused ? ' && ' + focused : ''}` : (focused || 'true');const browser = full || !browserFreeChecksEnabled() || await testsNeedBrowser(checkout, paths);return withGateSlot(checkout, (lease) => runProfiledShellAsync(checkout, command, { gateLease: lease, waitMs: lease.waitMs }),- { browser, gui: full ? projectNeedsGui(checkout) : testsNeedGui(checkout, paths), shortEligible: !full, agent, kind: 'test', onWait });+ { browser, gui: (full && projectNeedsGui(checkout)) || testsNeedGui(checkout, paths), shortEligible: !full, agent, kind: 'test', onWait });});const result = { green: run.isGreen, output: run.output, runner: run.executionRunner || 'this machine', seconds: Math.round((Date.now() - started) / 1000), files: paths, known: [], main: null,...(run.executionRunner ? {} : { local: localReason() }) };diff --git a/test/submit-registry-guards.test.js b/test/submit-registry-guards.test.jsindex 4f9cbf35..66eef6c2 100644--- a/test/submit-registry-guards.test.js+++ b/test/submit-registry-guards.test.js@@ -4,6 +4,8 @@ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';import { dirname, join } from 'node:path';import { after, test } from 'node:test';import { createE2eHelpers } from './e2e-helpers.js';+import { selectRegistryGuards } from '../src/registry-guards.js';+import { configFromSource } from '../src/config.js';const e2e = createE2eHelpers();after(e2e.cleanup);@@ -21,13 +23,14 @@ function commit(box, root, message) {}/** Set accepted registry policy and one real move guard with no JavaScript import edge to new leaves. */-function registryBox() {+function registryBox({ deferred = true } = {}) {const box = e2e.project('true');const config = JSON.parse(readFileSync(join(box.repo, 'pullboard.json'), 'utf8'));- config.lanes.web.owns.push('src/', 'test/');+ config.lanes.web.owns.push('src/', 'test/', 'pullboard.json');config.affectedTests = 'env -u NODE_TEST_CONTEXT node --test --test-reporter=tap';config.submitGate = 'landing';config.submitDeferAbove = 1;+ if (!deferred) { delete config.submitGate; delete config.submitDeferAbove; }config.registryGuards = [{ inputs: ['src/moves/**'], tests: ['test/relay-credential.test.js'] }];put(box.repo, 'pullboard.json', JSON.stringify(config));put(box.repo, 'package.json', '{"type":"module"}\n');@@ -67,5 +70,67 @@ test('submit runs the move registry guard for an item that adds a move and refusassert.match(submitted.err + submitted.out, /missing actor credential for newMove\.js/u, 'the refusal retains the missing entry');const state = box.run(box.web, 'show', String(box.id), '--json');assert.equal(state.code, 0, state.err);- assert.equal(JSON.parse(state.out).item.item_status, 'claimed', 'the rejected proof records no submission');+ assert.equal(JSON.parse(state.out).item_status, 'claimed', 'the rejected proof records no submission');++ // A real repair passes, and its native submission retains the guard among the files actually proved.+ const guard = join(box.web, 'test/relay-credential.test.js');+ writeFileSync(guard, readFileSync(guard, 'utf8').replace("['known.js']", "['known.js', 'newMove.js']"));+ commit(box, box.web, 'fix(core): map the fixture actor [G1]');+ const repaired = box.run(box.web, 'submit', String(box.id));+ assert.equal(repaired.code, 0, repaired.err + repaired.out);+ const exported = box.run(box.web, 'export', '--json');+ assert.equal(exported.code, 0, exported.err);+ const event = JSON.parse(exported.out).tables.event.findLast(row => row.event_kind === 'submit');+ assert.ok(JSON.parse(event.event_detail).submissionProof.files.includes('test/relay-credential.test.js'));+});++test('full fallback and candidate policy edits cannot omit an accepted registry guard [C7,V4,V16]', () => {+ const box = registryBox({ deferred: false });+ put(box.web, 'src/moves/newMove.js', 'export const operation = "newMove";\n');+ // Unknown data forces a full gate, which is deliberately true and does not include this guard.+ put(box.web, 'web/opaque.data', 'forces full fallback\n');+ const config = JSON.parse(readFileSync(join(box.web, 'pullboard.json'), 'utf8'));+ config.registryGuards = [];+ config.affectedTests = 'true';+ put(box.web, 'pullboard.json', JSON.stringify(config));+ commit(box, box.web, 'feat(core): add a move with candidate policy edits [G1]');+ const submitted = box.run(box.web, 'submit', String(box.id));+ assert.equal(submitted.code, 1, submitted.out);+ assert.match(submitted.err, /registry guards: test\/relay-credential\.test\.js/u);+ assert.match(submitted.err, /missing actor credential for newMove\.js/u);+});++test('affected tests include dirty registry changes without changing HEAD or the real index [C7,V4]', () => {+ const box = registryBox();+ const head = box.git(box.web, 'rev-parse', 'HEAD').trim();+ const index = box.git(box.web, 'write-tree').trim();+ put(box.web, 'src/moves/newMove.js', 'export const operation = "newMove";\n');+ const config = JSON.parse(readFileSync(join(box.web, 'pullboard.json'), 'utf8'));+ config.registryGuards = [];+ config.affectedTests = 'true';+ put(box.web, 'pullboard.json', JSON.stringify(config));+ const result = box.run(box.web, 'test', '--affected', '--json');+ assert.equal(result.code, 1, result.err + result.out);+ const output = JSON.parse(result.out);+ assert.ok(output.files.includes('test/relay-credential.test.js'));+ assert.match(output.output, /missing actor credential for newMove\.js/u);+ assert.equal(box.git(box.web, 'rev-parse', 'HEAD').trim(), head);+ assert.equal(box.git(box.web, 'write-tree').trim(), index);+});++test('registry policy validates paths and selects deleted and renamed inputs conservatively [C7,V4]', () => {+ assert.deepEqual(configFromSource('{"gate":"true"}').registryGuards, [], 'other projects opt in explicitly');+ for (const path of ['../outside.js', '/absolute.js', 'test/*.js', 'test/../outside.js']) {+ assert.throws(() => configFromSource(JSON.stringify({ affectedTests: 'custom-runner', registryGuards: [{ inputs: ['src/**'], tests: [path] }] })),+ error => error.code === 'BAD_CONFIG' && error.message.includes('registryGuards'));+ }+ const box = registryBox();+ const base = box.git(box.web, 'rev-parse', 'HEAD').trim();+ const rules = [{ inputs: ['src/moves/**'], tests: ['test/relay-credential.test.js'] }];+ assert.deepEqual(selectRegistryGuards(box.web, rules, { base, changed: ['web/unrelated.js'] }), []);+ box.git(box.web, 'mv', 'src/moves/known.js', 'web/renamed.js');+ commit(box, box.web, 'chore: rename the fixture move out of its registry');+ assert.deepEqual(selectRegistryGuards(box.web, rules, { base }), ['test/relay-credential.test.js']);+ assert.deepEqual(selectRegistryGuards(box.web, rules, { base, changed: ['src/moves/deleted.js'] }), ['test/relay-credential.test.js']);+ assert.deepEqual(selectRegistryGuards(box.web, rules), ['test/relay-credential.test.js'], 'an unknown base retains every obligation');});