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(core): cover gate diagnostics and main spec advice [C7,S8]
Corey Olson1e56eaca6ecd
diff --git a/test/spec-behind-main.test.js b/test/spec-behind-main.test.jsindex df115098..083c508f 100644--- a/test/spec-behind-main.test.js+++ b/test/spec-behind-main.test.js@@ -30,14 +30,42 @@ function addRowItem(box, ids = 'G3', lane = 'web') {}/** Commit a local file through the lane's normal hooks. */-function commitLocalWork(box) {+function commitLocalWork(box, id = 'G1') {const file = join(box.web, 'web', 'local.txt');mkdirSync(join(box.web, 'web'), { recursive: true });writeFileSync(file, 'local work\n');box.git(box.web, 'add', 'web/local.txt');- box.git(box.web, 'commit', '-q', '-m', 'docs: local work [G1]');+ box.git(box.web, 'commit', '-q', '-m', `docs: local work [${id}]`);}+/** Main-only cited rows need a merge; a row unknown to Main still needs its historical meaning. */+test('spec check names merge main when a cited row exists on main [S8,B6]', () => {+ for (const [id, onMain] of [['G3', true], ['X9', false]]) {+ const box = project();+ if (onMain) addMainRows(box, [id]);+ const path = join(box.web, 'SPEC.md');+ const previous = readFileSync(path, 'utf8');+ // Cite a working-copy row through the real hook without committing that row, as in E4.+ writeFileSync(path, `${previous}\n- ${id} [approved, must] The new row is in force. | gate: test\n`);+ commitLocalWork(box, id);+ writeFileSync(path, previous);+ const head = box.git(box.web, 'rev-parse', 'HEAD');+ const checked = box.run(box.web, 'spec', 'check');+ assert.equal(checked.code, 1, checked.err || checked.out);+ if (onMain) {+ assert.match(checked.out, /G3 error:.*git merge main/u, 'main-only cited row must name git merge main');+ assert.doesNotMatch(checked.out, /G3 error:.*add it as a retired row/u);+ box.git(box.web, 'merge', '--no-edit', 'main');+ const repaired = box.run(box.web, 'spec', 'check');+ assert.equal(repaired.code, 0, repaired.err || repaired.out);+ } else {+ assert.match(checked.out, /X9 error:.*never committed.*add it as a retired row/u);+ assert.doesNotMatch(checked.out, /git merge main/u);+ assert.equal(box.git(box.web, 'rev-parse', 'HEAD'), head, 'checking never mutates the worktree');+ }+ }+});+test('a worktree behind main on the spec is caught before UNKNOWN_SPEC [B6, V1]', () => {const fastForward = project();addMainRows(fastForward);diff --git a/test/submit-gate.test.js b/test/submit-gate.test.jsindex 4629f537..9cec2bcb 100644--- a/test/submit-gate.test.js+++ b/test/submit-gate.test.js@@ -251,6 +251,42 @@ test('a child process listen denial reads as sandbox blocked [C7,B26]', (t) => {assert.doesNotMatch(barePythonOutput, /GATE_RED/u);});+/** A failed project command keeps its first diagnostic even when later output is unstructured. */+test('a red gate on submit shows what the gate said [C7,V10]', (t) => {+ for (const stream of ['log', 'error']) {+ let box = privateRepo(t);+ const first = stream === 'log' ? 'G1: merge main to get the missing row' : 'G1 error: commit cites it, but it was never committed to the spec';+ put(box.root, 'pullboard.json', JSON.stringify({ gate: 'node test/gate-diagnostic.mjs', spec: 'SPEC.md', verify: 'any', lease: '2h' }));+ put(box.root, 'test/gate-diagnostic.mjs', [+ "import { existsSync } from 'node:fs';",+ "if (existsSync('src/RED')) {",+ ` console.${stream}(${JSON.stringify(first)});`,+ ` for (let n = 0; n < 80; n++) console.${stream}('detail ' + n + ': ' + 'x'.repeat(100));`,+ ' process.exit(1);',+ '}',+ ].join('\n'));+ commitAll(box);+ box = builderRepo(box);+ const added = box.coordinator('add', 'build', 'Show the gate diagnostic');+ assert.equal(added.code, 0, added.err);+ assert.equal(box.run('claim', '1').code, 0);+ put(box.root, 'src/RED', 'red\n');+ commitAll(box, 'feat(core): exercise gate output [G1]');+ const submitted = box.run('submit', '1', '--json');+ assert.notEqual(submitted.code, 0);+ const refusal = JSON.parse(submitted.out).error;+ assert.equal(refusal.code, 'GATE_RED');+ assert.ok(refusal.message.includes(first), 'the first diagnostic must survive the bounded refusal');+ assert.match(refusal.message, /\d+ nonempty output lines omitted/u);+ assert.ok(refusal.message.length < 5000, 'a refusal must remain bounded');+ const log = box.git('rev-parse', '--git-path', 'pullboard-submit.log').trim();+ const raw = readFileSync(resolve(box.root, log), 'utf8');+ assert.ok(raw.includes(first));+ assert.ok(raw.includes('detail 79:'), 'the complete gate output remains available in its log');+ assert.equal(JSON.parse(box.run('show', '1', '--json').out).item_status, 'claimed');+ }+});+test('an ordinary failure stays gate red [C7,B26]', (t) => {const source = ["import { test } from 'node:test';",