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(gate): classify quoted capture checks [C7]
Corey Olsonebefcf95fc46
diff --git a/src/browser-admission.js b/src/browser-admission.jsindex 023a26f7..8369c1b3 100644--- a/src/browser-admission.js+++ b/src/browser-admission.js@@ -103,17 +103,30 @@ function capturedRunner(command) {const bodyEnd = command.indexOf(ending, opening[0].length);if (bodyEnd < 0) return null;const inner = command.slice(opening[0].length, bodyEnd);- let suffix = command.slice(bodyEnd + ending.length);- const first = `; printf "%s\\n" "$${variable}"; printf "%s\\n" "$${variable}" | grep -Eq "`;- const second = `" && printf "%s\\n" "$${variable}" | grep -Eq "`;- if (!suffix.startsWith(first)) return null;- suffix = suffix.slice(first.length);- const split = suffix.indexOf(second);- if (split < 0 || !suffix.endsWith('"')) return null;- const patterns = [suffix.slice(0, split), suffix.slice(split + second.length, -1)];- if (!patterns[0].startsWith('^[[:space:]]*ok [0-9]+ - ') || patterns[0].includes('$')- || patterns[1] !== '^# fail 0$' || patterns.some(pattern => /["\\`]/u.test(pattern))) return null;- return inner;+ const suffix = command.slice(bodyEnd + ending.length);+ const quotes = ['"', "'"];+ // These are the two literal printf newline encodings used by current frozen checks. Keep+ // the surrounding command exact: only quote choice and one/two backslashes may vary.+ const prints = quotes.flatMap(quote => [1, 2].map(count =>+ `printf ${quote}%s${'\\'.repeat(count)}n${quote} "$${variable}"`));+ for (const firstPrint of prints) for (const secondPrint of prints) {+ const prefix = `; ${firstPrint}; ${secondPrint} | grep -Eq `;+ if (!suffix.startsWith(prefix)) continue;+ for (const firstQuote of quotes) {+ const firstPatternStart = prefix + firstQuote;+ if (!suffix.startsWith(firstPatternStart)) continue;+ const remainder = suffix.slice(firstPatternStart.length);+ for (const lastPrint of prints) for (const lastQuote of quotes) {+ const separator = `${firstQuote} && ${lastPrint} | grep -Eq ${lastQuote}`;+ const split = remainder.indexOf(separator);+ if (split < 0 || !remainder.endsWith(lastQuote)) continue;+ const patterns = [remainder.slice(0, split), remainder.slice(split + separator.length, -1)];+ if (patterns[0].startsWith('^[[:space:]]*ok [0-9]+ - ') && !patterns[0].includes('$')+ && patterns[1] === '^# fail 0$' && patterns.every(pattern => !/["'\\`]/u.test(pattern))) return inner;+ }+ }+ }+ return null;}/** Read a commit's regular-file map so verification classifies only the submitted source tree. */diff --git a/test/resources.test.js b/test/resources.test.jsindex 7d8d81d0..7354ae75 100644--- a/test/resources.test.js+++ b/test/resources.test.js@@ -351,12 +351,30 @@ async function release(child) {assert.equal(code, 0, child.errors);}-test('a non-browser check does not wait for the browser slot [C7]', async () => {+test('single-quoted named-test checks skip the browser slot [C7]', async () => {const box = fixture();const { repo, base } = checkProject(box);const itemCheck = 'node bin/run-tests.js --test-name-pattern "item check marker" test/cpu-check.test.js';const submitCheck = 'node bin/run-tests.js --test-name-pattern "submit check marker" test/cpu-check.test.js';assert.equal(await checkNeedsBrowser(repo, itemCheck), false, 'an explicit CPU-only test file is classifiable');+ const outputPattern = '^[[:space:]]*ok [0-9]+ - item check marker';+ const newlinePrint = ([quote, backslashes]) => `printf ${quote}%s${'\\'.repeat(backslashes)}n${quote} "$out"`;+ const capturedCheck = (formats, patternQuotes) => `out=$(${itemCheck} 2>&1); ${newlinePrint(formats[0])}; ${newlinePrint(formats[1])} | grep -Eq ${patternQuotes[0]}${outputPattern}${patternQuotes[0]} && ${newlinePrint(formats[2])} | grep -Eq ${patternQuotes[1]}^# fail 0$${patternQuotes[1]}`;+ const capturedVariants = [+ [[['\'', 1], ['\'', 1], ['\'', 1]], ['\'', '\'']],+ [[['\'', 2], ['"', 1], ['"', 2]], ['\'', '"']],+ [[['"', 1], ['\'', 2], ['\'', 1]], ['"', '\'']],+ [[['"', 2], ['"', 1], ['\'', 2]], ['"', '"']],+ ];+ for (const [formats, patternQuotes] of capturedVariants) {+ assert.equal(await checkNeedsBrowser(repo, capturedCheck(formats, patternQuotes)), false,+ `the exact frozen output-capture wrapper accepts its literal quote/newline variant: ${JSON.stringify({ formats, patternQuotes })}`);+ }+ assert.equal(await checkNeedsBrowser(repo, `${capturedCheck(capturedVariants[1][0], capturedVariants[1][1])}; :`), true,+ 'an arbitrary suffix remains outside the exact capture wrapper');+ const substituted = capturedCheck(capturedVariants[1][0], capturedVariants[1][1])+ .replace('printf \'%s\\\\n\' "$out"', 'printf \'%s\\\\n\' "$(printf %s "$out")"');+ assert.equal(await checkNeedsBrowser(repo, substituted), true, 'a command substitution remains outside the exact printf wrapper');assert.equal(await checkNeedsBrowser(repo, 'node bin/run-tests.js test/cockpit/brief.test.js'), true,'known browser suites remain browser-gated');const added = runFixtureChild(process.execPath, [BIN, 'add', 'coordinator', 'CPU check item', '--check', itemCheck, '--wait', '--json'], {