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(core): recognize bare child Python denials [C7,B26]
Corey Olsonedf26068d17e
diff --git a/src/gate.js b/src/gate.jsindex 9fb65673..59312477 100644--- a/src/gate.js+++ b/src/gate.js@@ -225,8 +225,8 @@ function nestedChildPermission(root, lines, { includeFilePaths = true, parentCod// A malformed or zero child-exit statement is evidence against using the footer fallback.const childExitMention = /\b(?:child|app|server|process)\b[^\n]{0,120}\bexited\b[^\n]{0,100}\bcode\b/iu.test(detail);// Some TAP reporters preserve only stderr as the assertion message. Accept that- // shape only with an ERR_ASSERTION nonzero-vs-zero footer and a complete Node fatal- // signature; the structured Error fields below remain mandatory. Scanner lines are+ // shape only with an ERR_ASSERTION nonzero-vs-zero footer and a complete fatal+ // signature for the child runtime. Its diagnostic fields below remain mandatory. Scanner lines are// trimmed before collection, so stack frames start with `at`, without indentation.const bareAssertionExit = !childExit && !childExitMention && parentCode === 'ERR_ASSERTION'? /\n{2,}([1-9]\d*) !== 0\s*$/u.exec(detail) : null;@@ -235,10 +235,11 @@ function nestedChildPermission(root, lines, { includeFilePaths = true, parentCod&& /(?:^|\n)Node\.js v\d+\.\d+\.\d+\s*$/u.test(bareFatalDetail)&& /(?:^|\n)at [^\n]+/u.test(bareFatalDetail);const childExitCode = childExit ? Number(childExit[1]) : bareAssertionExit ? Number(bareAssertionExit[1]) : null;- if (!Number.isSafeInteger(childExitCode) || childExitCode <= 0 || (!childExit && !completeNodeFatal)) return null;+ if (!Number.isSafeInteger(childExitCode) || childExitCode <= 0) return null;const errorLine = /^\s*Error: (.+)$/mu.exec(detail);if (errorLine) {+ if (!childExit && !completeNodeFatal) return null;const operation = permissionOperation(root, errorLine[1], { includeFilePaths });if (operation?.syscall) {const objectStart = detail.indexOf('{', errorLine.index + errorLine[0].length);@@ -266,8 +267,8 @@ function nestedChildPermission(root, lines, { includeFilePaths = true, parentCod// rather than Node's structured `Error` code/syscall/path object.// Node appends this exact assertion comparison to TAP's error scalar after the child stderr.// Strip it only for an AssertionError whose nonzero child exit matches `actual !== 0`.- const assertionFooter = childExit && parentCode === 'ERR_ASSERTION'- ? new RegExp(`\\n{2,}${childExit[1]} !== 0\\s*$`, 'u') : null;+ const assertionFooter = parentCode === 'ERR_ASSERTION'+ ? new RegExp(`\\n{2,}${childExitCode} !== 0\\s*$`, 'u') : null;const tracebackDetail = assertionFooter?.test(detail) ? detail.replace(assertionFooter, '') : detail;const tracebackMarker = /(?:^|\n)Traceback \(most recent call last\):\n/u.exec(tracebackDetail);const tracebackError = /(?:^|\n)(PermissionError: \[Errno (?:1|13)\] [^\n]+)\s*$/u.exec(tracebackDetail);diff --git a/test/submit-gate.test.js b/test/submit-gate.test.jsindex 636b9977..b8c49f03 100644--- a/test/submit-gate.test.js+++ b/test/submit-gate.test.js@@ -213,6 +213,18 @@ test('a child process listen denial reads as sandbox blocked [C7,B26]', (t) => {assert.match(python.err, /file access .*\(EACCES\)/u);assert.match(python.err, /Ask the person to allow this operation/u);assert.doesNotMatch(python.err, /GATE_RED/u);++ const pythonSource = childPythonTestSource();+ const pythonExplanation = " assert.equal(child.status, 0, `Child process exited with code ${child.status}:\\n${child.stderr}`);";+ assert.equal(pythonSource.split(pythonExplanation).length - 1, 1, 'the bare Python counter changes exactly one parent message');+ const barePythonBox = childFailureSubmitBox(t, pythonSource.replace(pythonExplanation, ' assert.equal(child.status, 0, child.stderr);'));+ barePythonBox.env.CHILD_PERMISSION_PATH = join(barePythonBox.dir, 'outside-bare-python-denial.txt');+ const barePython = barePythonBox.run('submit', '1');+ const barePythonOutput = `${barePython.out}\n${barePython.err}`;+ assert.equal(barePython.code, 1, barePythonOutput);+ assert.match(barePython.err, /SANDBOX_BLOCKED/u, 'complete bare Python stderr still names the known denial');+ assert.match(barePython.err, /file access .*\(EACCES\)/u);+ assert.doesNotMatch(barePythonOutput, /GATE_RED/u);});test('an ordinary failure stays gate red [C7,B26]', (t) => {@@ -265,6 +277,30 @@ test('an ordinary failure stays gate red [C7,B26]', (t) => {'a comparison without a blank-line boundary stays ordinary');assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { traceback: false, assertionFooter: '1 !== 0' })), null,'an assertion footer does not turn non-traceback text into a Python denial');+ for (const errno of [1, 13]) {+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { wrapper: false, errno, assertionFooter: '1 !== 0' })), recognized,+ 'a complete bare traceback and positive assertion exit prove a known child denial');+ }+ for (const [label, options] of [+ ['missing traceback', { traceback: false }],+ ['missing frame', { frame: false }],+ ['prefixed traceback marker', { prefixMarker: true }],+ ['later exception', { trailingError: true }],+ ['unknown errno', { errno: 2 }],+ ['zero exit', { assertionFooter: '0 !== 0' }],+ ['nonzero expected status', { assertionFooter: '1 !== 1' }],+ ['unsafe exit integer', { assertionFooter: '9007199254740992 !== 0' }],+ ['missing footer separation', { footerSeparator: '\n' }],+ ['text after footer', { assertionFooter: '1 !== 0\nextra text' }],+ ['non-assertion parent', { parentCode: 'ERR_TEST_FAILURE' }],+ ]) {+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { wrapper: false, assertionFooter: '1 !== 0', ...options })), null,+ `bare Python ${label} stays unclassified`);+ }+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(join(box.root, 'inside.txt'), { wrapper: false, assertionFooter: '1 !== 0' })), null,+ 'bare Python in-repo access stays an ordinary failure');+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { wrapper: false, assertionFooter: '1 !== 0' }), { includeFilePaths: false }), null,+ 'bare Python does not bypass the file-path classification switch');const result = box.run('submit', '1');const output = `${result.out}\n${result.err}`;assert.equal(result.code, 1, output);