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.

fix(spec): a gate path is normalized before a deletion is matched [S4]

Corey Olson20d2d4fc6492
diff --git a/src/spec.js b/src/spec.js
index 31bba151..d9f6a186 100644
--- a/src/spec.js
+++ b/src/spec.js
@@ -7,6 +7,7 @@
* Also here: the frozen criterion an item is verified against (V2), and sign-offs, a person's word
* that a row is met, kept with the text they read (S5).
*/
+import { posix } from 'node:path';
import { createHash } from 'node:crypto';
import { spawnSync } from 'node:child_process';
import {
@@ -254,13 +255,14 @@ const GATE_FILE_RE = /(?:^|\s)((?:[\w.-]+\/)*[\w.-]+\.(?:js|mjs|cjs|sh|md|json|y
/**
* The repo files a row's gate names, such as `test/board.test.js` or `bin/checks/file-size.js`. A gate
- * word without a path, such as `review` or `true`, names no file to check.
+ * word without a path, such as `review` or `true`, names no file to check. Each path is normalized, so
+ * ./test/a.test.js and test/x/../a.test.js name test/a.test.js, the spelling Git reports for a deletion (#809).
*
* @param {string | undefined} gate
* @returns {string[]}
*/
export function gateFiles(gate) {
- return [...String(gate ?? '').matchAll(GATE_FILE_RE)].map((match) => match[1]);
+ return [...String(gate ?? '').matchAll(GATE_FILE_RE)].map((match) => posix.normalize(match[1]));
}
/**
diff --git a/test/spec.test.js b/test/spec.test.js
index 15f52e74..0cc95599 100644
--- a/test/spec.test.js
+++ b/test/spec.test.js
@@ -1099,3 +1099,18 @@ test('a commit that deletes an approved row test is refused [S4]', (t) => {
const repointed = preCommitProblems({ root: box.root, isMain: true, config, agent: null });
assert.ok(!repointed.some((problem) => problem.includes('G9 names')), `the same commit repoints the row: ${repointed.join('\n')}`);
});
+
+test('a gate path written another way still guards its test [S4]', (t) => {
+ // ./test/proof.test.js and test/x/../proof.test.js name the file Git reports as test/proof.test.js (#809 review).
+ for (const gate of ['./test/proof.test.js', 'test/x/../proof.test.js']) {
+ const box = specBox(t, { specSource: `${SPEC}- G9 [approved, must] A rule keeps its proof. | gate: ${gate}\n` });
+ mkdirSync(join(box.root, 'test'));
+ writeFileSync(join(box.root, 'test/proof.test.js'), 'export {};\n');
+ box.git('add', '-A');
+ box.git('commit', '-q', '-m', 'test: the proof');
+ const config = configFromSource(readFileSync(join(box.root, 'pullboard.json'), 'utf8'));
+ box.git('rm', '-q', 'test/proof.test.js');
+ const refused = preCommitProblems({ root: box.root, isMain: true, config, agent: null });
+ assert.ok(refused.some((problem) => problem.includes('G9 names test/proof.test.js, which this commit deletes')), `${gate}: ${refused.join('\n')}`);
+ }
+});