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(submit): a gate named by a quoted path or separator [C7,V4]
Corey Olsonc863dda61fc5
diff --git a/src/infra-note.js b/src/infra-note.jsindex c01b490e..4eb7caa9 100644--- a/src/infra-note.js+++ b/src/infra-note.js@@ -12,8 +12,39 @@ const TEST_FILE = /^test\/|\.(?:test|spec)\.[cm]?js$/u;const GATE_FILE = /\.(?:[cm]?js|sh|json)$|\//u;/**- * The gate files a command names, relative to the checkout. A command like "node --test test/a.test.js" names- * test/a.test.js; a flag or a URL names nothing.+ * The words of a shell command, as the shell reads them: quotes group a path with spaces, a backslash escapes the next+ * character, and whitespace or a separator (;, &, |, parentheses, redirects) ends a word. A reader that splits on+ * whitespace alone keeps "src/check.js;" and "'src/check gate.js'" as they are, and misses both (#814).+ *+ * @param {string} command one gate command+ * @returns {string[]} the words, in order, without their quotes+ */+function shellWords(command) {+ const words = [];+ let word = null;+ let quote = null;+ for (let at = 0; at < command.length; at += 1) {+ const character = command[at];+ if (quote) {+ if (character === quote) quote = null;+ else word = (word ?? '') + character;+ } else if (character === '"' || character === "'") {+ quote = character;+ word = word ?? '';+ } else if (character === '\\' && at + 1 < command.length) {+ word = (word ?? '') + command[++at];+ } else if (/\s/u.test(character) || ';&|()<>'.includes(character)) {+ if (word !== null) words.push(word);+ word = null;+ } else word = (word ?? '') + character;+ }+ if (word !== null) words.push(word);+ return words;+}++/**+ * The gate files the gate commands name, relative to the checkout. A flag or a URL names nothing; a word that ends in a+ * script extension, or holds a path separator, names a file.** @param {string[]} commands the gate commands in force* @returns {Set<string>}@@ -21,8 +52,7 @@ const GATE_FILE = /\.(?:[cm]?js|sh|json)$|\//u;function namedByGates(commands) {const named = new Set();for (const command of commands) {- for (const token of String(command ?? '').split(/\s+/u)) {- const word = token.replace(/^["']|["']$/gu, '');+ for (const word of shellWords(String(command ?? ''))) {if (word && !word.startsWith('-') && !word.includes('://') && GATE_FILE.test(word)) named.add(word.replace(/^\.\//u, ''));}}diff --git a/test/submit-infra.test.js b/test/submit-infra.test.jsindex 84b55ffb..d3296606 100644--- a/test/submit-infra.test.js+++ b/test/submit-infra.test.js@@ -127,3 +127,23 @@ test('a new test file needs no note [C7,V4]', (t) => {assert.equal(submitted.code, 0, `${submitted.out}\n${submitted.err}`);assert.doesNotMatch(`${submitted.out}\n${submitted.err}`, /INFRA_NOTE_REQUIRED/u);});++test('a gate named by a quoted path or a shell separator needs a note [C7,V4]', (t) => {+ // Each gate names a script the change then edits: a quoted path with a space, and a path followed by a separator.+ for (const [gate, file] of [["node 'src/check gate.js'", 'src/check gate.js'], ['node src/check.js; true', 'src/check.js']]) {+ let box = privateRepo(t);+ put(box.root, 'pullboard.json', JSON.stringify({ gate, spec: 'SPEC.md' }));+ put(box.root, file, 'process.exit(0);\n');+ commitAll(box);+ box = builderRepo(box);+ assert.equal(box.coordinator('add', 'build', 'Gate named by a path', '--check', 'true').code, 0);+ assert.equal(box.run('claim', '1').code, 0);+ put(box.root, file, 'process.exit(0); // edited after the claim\n');+ commitAll(box, 'feat(core): change the gate script [G1]');+ const refused = box.run('submit', '1');+ const output = `${refused.out}\n${refused.err}`;+ assert.equal(refused.code, 1, `${gate}: the edit is refused without a note\n${output}`);+ assert.match(output, /INFRA_NOTE_REQUIRED/u, `${gate}: the refusal is INFRA_NOTE_REQUIRED`);+ assert.ok(output.includes(file), `${gate}: the refusal names ${file}`);+ }+});