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): preserve check pipes when preloading the guard [V18,V2]
Corey Olson997d6a641a85
diff --git a/src/browser-slot-guard.js b/src/browser-slot-guard.jsindex b5cde9a4..cc5407a1 100644--- a/src/browser-slot-guard.js+++ b/src/browser-slot-guard.js@@ -17,9 +17,12 @@ import childProcess from 'node:child_process';import { statSync, realpathSync } from 'node:fs';import { syncBuiltinESMExports } from 'node:module';import { basename, delimiter, isAbsolute, relative, resolve } from 'node:path';-import { promisify } from 'node:util';import { Refused } from './refused.js';+// The util ESM facade evaluates lazy exports, including diff, which opens stderr on Node 24.+// A child may share that descriptor with stdout; keep its pipe mode unchanged when preloading us.+const { promisify } = process.getBuiltinModule('node:util');+/** The marker the runner sets in a test file's process: held, none, or unset when the setting is off. */export const BROWSER_SLOT_ENV = 'PULLBOARD_TEST_BROWSER_SLOT';/** Install paths test/chrome-fixture.js's findChromeExecutable looks in, besides PULLBOARD_CHROME. */diff --git a/test/e2e-private-checks.test.js b/test/e2e-private-checks.test.jsindex e599e183..0d8dfe94 100644--- a/test/e2e-private-checks.test.js+++ b/test/e2e-private-checks.test.js@@ -20,6 +20,7 @@ import { tmpdir } from 'node:os';import { request } from 'node:http';import { connect } from 'node:net';import { join, resolve } from 'node:path';+import { pathToFileURL } from 'node:url';import { after, test } from 'node:test';import { parseSpec } from '../src/spec.js';import { checkAtCommit } from '../src/trusted-policy.js';@@ -176,6 +177,47 @@ test('stream scanning handles UTF-8 and a secret split across read chunks [V18,Vassert.match(saved, /TAIL-CHUNK/);});+test('a check output survives the browser launch guard [V18,V2]', () => {+ const probe = sandbox();+ const observed = join(probe.dir, 'guard-stdio.json');+ const preload = join(probe.dir, 'observe-guard.mjs');+ const guard = pathToFileURL(resolve(import.meta.dirname, '../src/browser-slot-guard.js')).href;+ // Observe only the node -e check writer. Other CLI processes legitimately use their own stdio.+ writeFileSync(preload, `+const fs = process.getBuiltinModule('node:fs');+const accessed = [];+if (process.argv.length === 1) {+ for (const name of ['stdin', 'stdout', 'stderr']) {+ const descriptor = Object.getOwnPropertyDescriptor(process, name);+ Object.defineProperty(process, name, { ...descriptor, get() {+ accessed.push(name);+ return descriptor.get.call(process);+ } });+ }+}+await import(${JSON.stringify(guard)});+if (process.argv.length === 1) fs.writeFileSync(${JSON.stringify(observed)}, JSON.stringify(accessed));+`);+ const planted = 'sk-proj-' + 'b'.repeat(40);+ const box = privateCheckSubmission({ check: `node -e 'const fs=require("node:fs"); fs.writeSync(1,"x".repeat(32766)+"😀\\n"); fs.writeSync(1,"x".repeat(32762)+"${planted}\\nTAIL-CHUNK\\n"); process.exitCode=1'` });+ box.env.NODE_OPTIONS = `--import=${pathToFileURL(preload).href}`;+ box.env.PULLBOARD_TEST_BROWSER_SLOT = 'none';+ const refused = box.run(box.review, 'verify', '1', 'accept', '--note', 'the guard preserves the private check writer', '--json');+ assert.equal(refused.code, 1, refused.err);+ const error = JSON.parse(refused.out).error;+ assert.equal(error.code, 'CHECK_RED');+ assert.deepEqual(JSON.parse(readFileSync(observed, 'utf8')), [], 'loading the guard must not initialize a check writer’s stdio');+ assert.match(error.message, /redacted OpenAI key/);+ assert.match(error.message, /TAIL-CHUNK/);+ const artifact = /full output file: ([^\n]+)/.exec(error.message)?.[1];+ assert.ok(artifact && existsSync(artifact));+ const saved = readFileSync(artifact, 'utf8');+ assert.match(saved, /😀/);+ assert.match(saved, /redacted OpenAI key/);+ assert.match(saved, /TAIL-CHUNK/);+ assert.doesNotMatch(saved, new RegExp(planted));+});+test('accept reports failed install as CHECK_UNVERIFIED with an output digest [V18,V2]', () => {const box = privateCheckSubmission({ install: 'echo install-failed; exit 9', check: 'true' });const refused = box.run(box.review, 'verify', '1', 'accept', '--note', 'install must complete before verification', '--json');