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(proof): preserve exact capture tokens through timed workers [C7,H16]
Corey Olson1009bd332fe4
diff --git a/src/execution-environment.js b/src/execution-environment.jsindex 700c8061..40448add 100644--- a/src/execution-environment.js+++ b/src/execution-environment.js@@ -57,7 +57,7 @@ writeFileSync(file,JSON.stringify({pid:process.pid,environment:{platform:process// Node's --test parent only starts workers; retain capture until the actual test process boots.// User code sees its original NODE_OPTIONS, not this recorder's injected option.if (!process.execArgv.includes('--test')) {- const token='--import='+import.meta.url;+ const token=${JSON.stringify('--import=' + pathToFileURL(join(directory, 'test-runtime-preload.mjs')).href)};const options=process.env.NODE_OPTIONS;if (options===token) delete process.env.NODE_OPTIONS;else if (options?.endsWith(' '+token)) process.env.NODE_OPTIONS=options.slice(0,-token.length-1);diff --git a/src/shell-run.js b/src/shell-run.jsindex 28b73ea3..b61dd0fe 100644--- a/src/shell-run.js+++ b/src/shell-run.js@@ -53,6 +53,7 @@ export function runShell(root, command, { pipefail = false, env = {}, stages = f}// Read-only baselines and caller-output profiles have no proof receipt to bind.// Leave their execution environment unchanged; only admitted proof runs collect children.+ const callerEnv = options.env;const runtimes = captureRuntimes ? captureTestRuntimes(options.env) : null;if (runtimes) options.env = runtimes.env;try {@@ -63,7 +64,7 @@ export function runShell(root, command, { pipefail = false, env = {}, stages = fconst script = `${prefix}(\n${split ? stagedScript(split, marker, pipes) : command}\n) 2>&1`;const timedDirectory = timeoutMs ? mkdtempSync(join(tmpdir(), 'pullboard-timed-output-')) : null;const outputFile = timedDirectory ? join(timedDirectory, 'output.log') : null;- const timed = timeoutMs ? spawnSync(process.execPath, [fileURLToPath(new URL('./timed-shell-worker.js', import.meta.url))], { ...options, shell: false, stdio: ['pipe', 'pipe', 'pipe'], input: JSON.stringify({ command: script, timeoutMs, outputFile }) }) : null;+ const timed = timeoutMs ? spawnSync(process.execPath, [fileURLToPath(new URL('./timed-shell-worker.js', import.meta.url))], { ...options, env: { ...callerEnv, ...(runtimes ? { PULLBOARD_RUNTIME_CAPTURE_DIR: runtimes.env.PULLBOARD_RUNTIME_CAPTURE_DIR } : {}) }, shell: false, stdio: ['pipe', 'pipe', 'pipe'], input: JSON.stringify({ command: script, timeoutMs, outputFile }) }) : null;if (timed && (timed.status !== 0 || timed.error)) throw new Refused('LAND_TIMEOUT_CUSTODY', 'the timed gate worker did not prove cleanup; inspect its owned processes before landing again');const result = timed ? { ...JSON.parse(timed.stdout || '{}'), stdout: '', stderr: timed.stderr } : spawnSync(script, options);if (timed && result.error) throw new Refused('LAND_GATE_OUTPUT', `the timed gate stopped and drained after its output failed (${result.error}); inspect free disk space and ${timedDirectory} before landing again`);diff --git a/src/timed-shell-worker.js b/src/timed-shell-worker.jsindex 6154401b..f479211a 100644--- a/src/timed-shell-worker.js+++ b/src/timed-shell-worker.js@@ -13,6 +13,7 @@ import {join,} from 'node:path';import { createDescendantTracker } from './runner-custody.js';+import { testRuntimeImport } from './execution-environment.js';const request = JSON.parse(readFileSync(0, 'utf8'));if (!Number.isSafeInteger(request.timeoutMs) || request.timeoutMs < 1 || request.timeoutMs > 2_147_483_647) throw new Error('invalid shell timeout');@@ -31,7 +32,8 @@ function reportState(force = false) {catch { process.stderr.write('timed gate: cleanup state could not be written; retain the worker and inspect its private output directory\n'); }}tracker = createDescendantTracker(directory, { tick: () => reportState(), warn: () => reportState(true) });-const env = { ...process.env, NODE_OPTIONS: [process.env.NODE_OPTIONS, tracker.nodeOptions].filter(Boolean).join(' '), PULLBOARD_RUNNER_PRELOAD: tracker.nodeOptions };+const recorder = testRuntimeImport();+const env = { ...process.env, NODE_OPTIONS: [process.env.NODE_OPTIONS, tracker.nodeOptions, recorder ? '--import=' + recorder : null].filter(Boolean).join(' '), PULLBOARD_RUNNER_PRELOAD: tracker.nodeOptions };const child = spawn('/bin/sh', ['-c', request.command], { env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });tracker.registerRoot(child.pid);tracker.observe();diff --git a/test/proof-provenance.test.js b/test/proof-provenance.test.jsindex fa6165dd..bb32729b 100644--- a/test/proof-provenance.test.js+++ b/test/proof-provenance.test.js@@ -8,6 +8,7 @@ import * as store from '../src/board.js';import { prepareEngineMove, applyEngineMove } from '../src/engine.js';import { boardReceiptStore, receiptBody, receiptFields } from '../src/gate-run-receipt.js';import { proofCounts } from '../src/proof-provenance.js';+import { runShell } from '../src/shell-run.js';import { captureTestRuntimes } from '../src/execution-environment.js';import { runFixtureChild } from './fixture-child.js';import { fileURLToPath } from 'node:url';@@ -109,6 +110,20 @@ test('runtime capture binds the admitted file to its closed actual worker [C7,H1assert.notEqual(children[0].pid, process.pid);});+test('timed shell proof records the actual command child rather than the timeout worker [C7,H16]', t => {+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-timed-runtime-'));+ t.after(() => rmSync(directory, { recursive: true, force: true }));+ const trace = join(directory, 'actual.json');+ const program = `require('node:fs').writeFileSync(${JSON.stringify(trace)}, JSON.stringify({pid:process.pid,node:process.versions.node}));`;+ const result = runShell(directory, `${JSON.stringify(process.execPath)} -e ${JSON.stringify(program)}`,+ { timeoutMs: 5_000, captureRuntimes: true }); // budget: declared timeout input exercises the real custody worker.+ assert.equal(result.isGreen, true, result.output);+ const actual = JSON.parse(readFileSync(trace, 'utf8'));+ assert.equal(result.testRuntimes.length, 1, 'the timeout launcher never substitutes for the actual command');+ assert.equal(result.testRuntimes[0].pid, actual.pid);+ assert.equal(result.testRuntimes[0].environment.node, actual.node);+});+test('child boot reports remain read only and a writable replacement stays unknown [C7,H16]', t => {const capture = captureTestRuntimes(process.env);t.after(() => capture.finish());