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): recognize bare child denial TAP [C7,B26]
Corey Olsonbb446bb28b9e
diff --git a/src/gate.js b/src/gate.jsindex 3cb1cf2f..9fb65673 100644--- a/src/gate.js+++ b/src/gate.js@@ -222,7 +222,20 @@ function tapScalar(value) {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;+ // 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+ // 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;+ const bareFatalDetail = bareAssertionExit ? detail.slice(0, bareAssertionExit.index) : '';+ const completeNodeFatal = bareAssertionExit+ && /(?:^|\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;const errorLine = /^\s*Error: (.+)$/mu.exec(detail);if (errorLine) {@@ -253,7 +266,7 @@ 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 = parentCode === 'ERR_ASSERTION'+ const assertionFooter = childExit && 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);diff --git a/test/submit-gate.test.js b/test/submit-gate.test.jsindex 5128a25c..636b9977 100644--- a/test/submit-gate.test.js+++ b/test/submit-gate.test.js@@ -192,6 +192,18 @@ test('a child process listen denial reads as sandbox blocked [C7,B26]', (t) => {assert.match(output, /listen \(EPERM\)/u);assert.doesNotMatch(output, /GATE_RED/u);+ const explanatory = " assert.equal(child.status, 0, `App exited before listening (code ${child.status}, signal ${child.signal}):\\n${child.stderr}`);";+ const original = childListenerTestSource();+ assert.equal(original.split(explanatory).length, 2, 'replace exactly one explanatory message');+ const bareSource = original.replace(explanatory, ' assert.equal(child.status, 0, child.stderr);');+ const bareBox = childFailureSubmitBox(t, bareSource);+ const bare = bareBox.run('submit', '1');+ const bareOutput = `${bare.out}\n${bare.err}`;+ assert.equal(bare.code, 1, bareOutput);+ assert.match(bareOutput, /SANDBOX_BLOCKED/u, 'bare stderr with structured fatal fields still names the denial');+ assert.match(bareOutput, /listen \(EPERM\)/u);+ assert.doesNotMatch(bareOutput, /GATE_RED/u);+const pythonBox = childFailureSubmitBox(t, childPythonTestSource());pythonBox.env.CHILD_PERMISSION_PATH = join(pythonBox.dir, 'outside-python-denial.txt');const python = pythonBox.run('submit', '1');@@ -1257,4 +1269,43 @@ test('nested TAP child denials require bounded matching fatal details [C7,B26]','an oversized error block is not classified');assert.equal(sandboxBlockedOperation(box.root, tapChildError(), { includeFilePaths: false }), null,'file-path classification remains disabled when requested');++ /** Build stderr-only Node fatal TAP while varying its proof fields. */+ function tapBareNodeError({ code = 'EPERM', syscall = 'listen', version = true, stack = true,+ footer = '1 !== 0', parentCode = 'ERR_ASSERTION', trailing = '', object = true, closeObject = true, exitProse = '' } = {}) {+ return [+ 'TAP version 13',+ 'not ok 1 - child listens',+ ' ---',+ " failureType: 'testCodeFailure'",+ ' error: |-',+ ...(exitProse ? [` ${exitProse}`] : []),+ ' Error: listen EPERM: operation not permitted 127.0.0.1:0',+ ...(stack ? [' at Server.listen (node:net:2000:7)'] : []),+ ...(object ? [' {', ` code: '${code}',`, ` syscall: '${syscall}',`," address: '127.0.0.1',",' port: 0', ...(closeObject ? [' }'] : [])] : []),+ ...(version ? [' Node.js v22.22.2'] : []),+ ...(trailing ? [` ${trailing}`] : []),+ '',+ ` ${footer}`,+ ` code: '${parentCode}'`,+ ' ...',+ ].join('\n');+ }+ assert.equal(sandboxBlockedOperation(box.root, tapBareNodeError()), 'listen (EPERM)',+ 'bare stderr remains recognizable when the Node fatal fields and assertion prove nonzero exit');+ for (const [label, options] of [+ ['missing stack', { stack: false }],+ ['missing Node version', { version: false }],+ ['missing structured error fields', { object: false }],+ ['truncated structured object', { closeObject: false }],+ ['mismatched structured code', { code: 'EACCES' }],+ ['mismatched structured syscall', { syscall: 'open' }],+ ['non-assertion parent', { parentCode: 'ERR_TEST_FAILURE' }],+ ['zero exit footer', { footer: '0 !== 0' }],+ ['zero child-exit prose cannot fall back to footer', { exitProse: 'App exited before listening (code 0, signal null):' }],+ ['invalid child-exit prose cannot fall back to footer', { exitProse: 'App exited before listening (code unknown, signal null):' }],+ ['unrelated trailing error', { trailing: 'Error: later ordinary failure' }],+ ]) {+ assert.equal(sandboxBlockedOperation(box.root, tapBareNodeError(options)), null, `${label} stays unclassified`);+ }});