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): match nested Python denial assertion footer [C7,B26]
Corey Olson266b699f36e1
diff --git a/src/gate.js b/src/gate.jsindex d490a918..3cb1cf2f 100644--- a/src/gate.js+++ b/src/gate.js@@ -219,7 +219,7 @@ function tapScalar(value) {}/** Recognize a bounded child fatal denial carried inside one failed TAP error block. */-function nestedChildPermission(root, lines, { includeFilePaths = true } = {}) {+function nestedChildPermission(root, lines, { includeFilePaths = true, parentCode = null } = {}) {const detail = lines.join('\n');const childExit = /\b(?:child|app|server|process)\b[^\n]{0,120}\bexited\b[^\n]{0,100}\bcode\s*[(:=]?\s*([1-9]\d*)/iu.exec(detail);if (!childExit || !Number.isSafeInteger(Number(childExit[1]))) return null;@@ -251,10 +251,15 @@ function nestedChildPermission(root, lines, { includeFilePaths = true } = {}) {// Python child failures have a standard traceback frame and terminal PermissionError,// rather than Node's structured `Error` code/syscall/path object.- const tracebackMarker = /(?:^|\n)Traceback \(most recent call last\):\n/u.exec(detail);- const tracebackError = /(?:^|\n)(PermissionError: \[Errno (?:1|13)\] [^\n]+)\s*$/u.exec(detail);+ // 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 = parentCode === 'ERR_ASSERTION'+ ? new RegExp(`\\n{2,}${childExit[1]} !== 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);if (!tracebackMarker || !tracebackError || tracebackError.index <= tracebackMarker.index) return null;- const tracebackBody = detail.slice(tracebackMarker.index + tracebackMarker[0].length, tracebackError.index);+ const tracebackBody = tracebackDetail.slice(tracebackMarker.index + tracebackMarker[0].length, tracebackError.index);if (!/(?:^|\n)File (?:'[^'\n]+'|"[^"\n]+"), line \d+(?:, in [^\n]+)?(?:\n|$)/u.test(tracebackBody)) return null;const operation = permissionOperation(root, tracebackError[1], { includeFilePaths });return operation && operation.syscall === null ? operation : null;@@ -350,7 +355,7 @@ export function sandboxBlockedScanner(root, { includeFilePaths = true } = {}) {else exitCode = /^[1-9]\d*$/u.test(field[2]) && Number.isSafeInteger(Number(field[2])) ? Number(field[2]) : null;const nestedPermission = field[1] === 'code'&& failureType && nestedError && !nestedErrorOverflow- ? nestedChildPermission(root, nestedError, { includeFilePaths }) : null;+ ? nestedChildPermission(root, nestedError, { includeFilePaths, parentCode: code }) : null;if (nestedPermission) return nestedPermission.operation;if (permission && permission.code === code) return permission.operation;if (startup && code === 'ERR_TEST_FAILURE' && failureMessage === 'test failed'diff --git a/test/submit-gate.test.js b/test/submit-gate.test.jsindex d30d6f5a..5128a25c 100644--- a/test/submit-gate.test.js+++ b/test/submit-gate.test.js@@ -164,11 +164,12 @@ function pythonPermissionError(path, errno = 13) {}/** Wrap scanner input in a failed child TAP record with or without a fatal traceback. */-function pythonChildTap(path, { traceback = true, frame = true, prefixMarker = false, errno = 13, wrapper = true, exitCode = 1, trailingError = false } = {}) {+function pythonChildTap(path, { traceback = true, frame = true, prefixMarker = false, errno = 13, wrapper = true, exitCode = 1, trailingError = false, assertionFooter = null, footerSeparator = '\n\n\n', parentCode = 'ERR_ASSERTION' } = {}) {const diagnostic = pythonPermissionError(path, errno);const marker = prefixMarker ? 'not a traceback marker: Traceback (most recent call last):' : 'Traceback (most recent call last):';const tracebackDetail = `${marker}\n${frame ? ' File "child.py", line 1, in <module>\n' : ''}${diagnostic}${trailingError ? '\nValueError: later unrelated failure' : ''}`;const detail = traceback ? tracebackDetail : `AssertionError: expected ordinary output\n${diagnostic}`;+ const renderedDetail = assertionFooter === null ? detail : `${detail}${footerSeparator}${assertionFooter}`;return ['TAP version 13','not ok 1 - child reads a file',@@ -176,8 +177,8 @@ function pythonChildTap(path, { traceback = true, frame = true, prefixMarker = f" failureType: 'testCodeFailure'",' error: |-',...(wrapper ? [` Child process exited with code ${exitCode}:`] : []),- ...detail.split('\n').map((line) => ` ${line}`),- " code: 'ERR_ASSERTION'",+ ...renderedDetail.split('\n').map((line) => ` ${line}`),+ ` code: '${parentCode}'`,' ...',].join('\n');}@@ -233,6 +234,25 @@ test('an ordinary failure stays gate red [C7,B26]', (t) => {'a different terminal exception after PermissionError stays ordinary');assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { errno: 1 })), `file access "${outside}" (EACCES)`,'a nested EPERM-style Python errno remains recognized');+ const recognized = `file access "${outside}" (EACCES)`;+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { assertionFooter: '1 !== 0' })), recognized,+ 'the matching Node assertion footer does not hide the terminal child denial');+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { assertionFooter: '2 !== 0' })), null,+ 'a footer exit code different from the child wrapper stays ordinary');+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { assertionFooter: '1 !== 1' })), null,+ 'a footer with a nonzero expected value stays ordinary');+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { assertionFooter: '1 !== 0', footerSeparator: '\nnot blank\n' })), null,+ 'a comparison without the blank-line boundary stays ordinary');+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { assertionFooter: '1 !== 0\nextra text' })), null,+ 'arbitrary text after the comparison stays ordinary');+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { assertionFooter: '1 !== 0', parentCode: 'ERR_TEST_FAILURE' })), null,+ 'the footer is accepted only in an assertion failure record');+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { trailingError: true, assertionFooter: '1 !== 0' })), null,+ 'a later Python exception stays ordinary even when the Node assertion footer follows');+ assert.equal(sandboxBlockedOperation(box.root, pythonChildTap(outside, { assertionFooter: '1 !== 0', footerSeparator: '\n' })), null,+ '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');const result = box.run('submit', '1');const output = `${result.out}\n${result.err}`;assert.equal(result.code, 1, output);