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
fix(spec): a lost gate test fails spec check, a new one warns [D1,S1]
Corey Olson73f1a4baebf4
diff --git a/docs/api.md b/docs/api.mdindex b3db0a04..39c6a04d 100644--- a/docs/api.md+++ b/docs/api.md@@ -467,7 +467,7 @@ HTTP refusals use the same versioned error envelope above: 400 for malformed cal## Spec gates-`pullboard spec check` fails when an approved must-row names a gate file the repo does not have, and it names the row and the file. A row of any other status that names a missing file only warns, so a draft can name a file it will create. The pre-commit hook refuses a commit that deletes or renames a file an approved must-row names, unless the same commit points that row at its new home.+`pullboard spec check` fails when an approved must-row names a gate file that was committed and is gone now (a lost test), and it names the row, the file and the removal. A gate file that was never committed only warns that its test is not written yet, so a new project's example spec still passes, and every other row only warns. The pre-commit hook refuses a commit that deletes or renames a file an approved must-row names, unless the same commit points that row at its new home.## SSH spec sign-offsdiff --git a/src/spec.js b/src/spec.jsindex 9d58657e..31bba151 100644--- a/src/spec.js+++ b/src/spec.js@@ -264,9 +264,23 @@ export function gateFiles(gate) {}/**- * Findings for each row whose gate names a file the repo does not have (#809). An approved must-row is- * an error, so spec check fails and names the row and the file; every other row only warns, so a draft- * can name a file it will create.+ * The commit that last held a file anywhere in the repository's history, or '' when no commit ever did (#809).+ * A file that was committed and is gone now is a lost test; one never committed is a test not written yet.+ *+ * @param {string} root+ * @param {string} file+ * @returns {string}+ */+function lastCommitOf(root, file) {+ const result = spawnSync('git', ['log', '--all', '-n', '1', '--format=%h', '--', file], { cwd: root, encoding: 'utf8', env: cleanGitEnvironment() });+ return result.status === 0 ? result.stdout.trim() : '';+}++/**+ * Findings for each row whose gate names a file the repo does not have (#809). An approved must-row whose file+ * was committed and is gone is an error that names the removal, so spec check fails; a file never committed is+ * a warning that the test is not written yet, so a new project's README example still fits. Every other row+ * only warns.** @param {any} spec - a parsed spec* @param {string} root - the repo root the gate paths resolve against@@ -277,8 +291,12 @@ export function missingGateFindings(spec, root) {for (const row of spec.rows) {for (const file of gateFiles(row.gate)) {if (existsSync(join(root, file))) continue;- const level = row.status === 'approved' && row.tier === 'must' ? 'error' : 'warning';- findings.push({ level, line: row.line, id: row.id, message: `gate file ${file} does not exist; name the file that proves the row` });+ const lost = lastCommitOf(root, file);+ if (row.status === 'approved' && row.tier === 'must' && lost) {+ findings.push({ level: 'error', line: row.line, id: row.id, message: `gate file ${file} was removed from the repository (last in ${lost}); restore it or point the row at its new home` });+ } else {+ findings.push({ level: 'warning', line: row.line, id: row.id, message: `gate file ${file} does not exist yet; write the test it names` });+ }}}return findings;diff --git a/test/spec.test.js b/test/spec.test.jsindex f84e9ddd..15f52e74 100644--- a/test/spec.test.js+++ b/test/spec.test.js@@ -1048,15 +1048,28 @@ function answerCommandCase(t, separateGitDir) {}test('spec check fails when an approved row names a missing gate [S4]', (t) => {- // An approved must-row whose gate file is gone fails spec check and names both the row and the file (#809).- const source = `${SPEC}- G9 [approved, must] A rule keeps its proof. | gate: test/proof-gone.test.js\n`;- const box = specBox(t, { specSource: source });- const text = box.run('check');- assert.equal(text.status, 1, text.stdout + text.stderr);- assert.match(text.stdout + text.stderr, /G9 error: gate file test\/proof-gone\.test\.js does not exist/u);+ // A gate file that was committed and then removed is a lost test: an approved must-row fails spec check and+ // names the row, the file and the removal (#809).+ const box = specBox(t, { specSource: SPEC });mkdirSync(join(box.root, 'test'));writeFileSync(join(box.root, 'test/proof-gone.test.js'), 'export {};\n');- assert.equal(box.run('check').status, 0, 'the same row passes once its file exists');+ box.git('add', '-A');+ box.git('commit', '-q', '-m', 'test: the proof');+ box.git('rm', '-q', 'test/proof-gone.test.js');+ box.git('commit', '-q', '-m', 'test: remove the proof');+ writeFileSync(join(box.root, box.specName), `${SPEC}- G9 [approved, must] A rule keeps its proof. | gate: test/proof-gone.test.js\n`);+ const text = box.run('check');+ assert.equal(text.status, 1, text.stdout + text.stderr);+ assert.match(text.stdout + text.stderr, /G9 error: gate file test\/proof-gone\.test\.js was removed from the repository/u);+});++test('a gate test that was never written only warns, so a new project passes [S4]', (t) => {+ // A gate file that was never committed is a test not written yet: a warning, so the README's example still fits (#809).+ const source = `${SPEC}- G9 [approved, must] A rule keeps its proof. | gate: test/never-written.test.js\n`;+ const box = specBox(t, { specSource: source });+ const text = box.run('check');+ assert.equal(text.status, 0, text.stdout + text.stderr);+ assert.match(text.stdout + text.stderr, /G9 warning: gate file test\/never-written\.test\.js does not exist yet/u);});test('a draft row with a missing gate file only warns [S4]', (t) => {