Skip to content

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.

fix(proof): capture runtimes inside actual child processes [C7,H16]

Corey Olson5e382c4173c1
diff --git a/docs/formats.md b/docs/formats.md
index 93184a9a..b7d04e00 100644
--- a/docs/formats.md
+++ b/docs/formats.md
@@ -554,7 +554,7 @@ Engine 54 replaces the automatic strong-to-strong ceiling escalation with one co
`PROOF_RUN_ENGINE` adds `recordProofRun` and the append-only `proof-run` item event; its unassigned leaf receives its permanent number at landing. The gate writes a version-two receipt in the existing gate receipt store after execution. The ordered move reads that file itself and binds its recorded seat to the authenticated actor; caller-written provenance is refused. Replay carries the canonical receipt rather than reading the originating machine's filesystem. Like the existing gate-run protocol, this trusts authenticated ordered replay and trusted recovery inputs; it is not independent cryptographic attestation of a machine owner or an imported history. The existing `gate-receipts.jsonl` timing receipt links its executed phases through `proofReceiptIds`; there is no agent-written provenance log. Version-one gate receipts retain their separate flake and quarantine meaning.
-`pullboard show <id> --json` adds `proofReceipts`, in event order. Each entry identifies its native receipt, command kind, item, commit, tree, frozen digest, actual executor environment (`node`, `platform`, `arch`), runner, seat, recorded parent session, exit code, explicit pass/fail/skip counts, duration in milliseconds and source cleanliness. The runner identifies the executor from its native receipt, including the local runner's identity. Unavailable identities or counters stay `null`; a legacy seat's identity is not recorded-parent assurance. This records the single runtime actually used, without adding runtime configuration or requiring execution on multiple versions. Plain `show` prints the same receipt chain. A missing receipt prevents publication of an executed command's outcome. At `PROOF_RUN_ENGINE` and above, shouts longer than 400 Unicode code points are refused with `SHOUT_TOO_LONG`, pointing callers to receipts and `show`; older moves replay under their original limit.
+`pullboard show <id> --json` adds `proofReceipts`, in event order. Each entry identifies its native receipt, command kind, item, commit, tree, frozen digest, actual executor environment (`node`, `platform`, `arch`), runner, seat, recorded parent session, exit code, explicit pass/fail/skip counts, duration in milliseconds and source cleanliness. The runner identifies the executor from its native receipt, including the local runner's identity. Unavailable identities or counters stay `null`; a legacy seat's identity is not recorded-parent assurance. New receipts also carry `testRuntimes`: each child reports its own PID and environment before executing, and the ordinary test-file dispatcher binds its selected file to that closed child, yielding `{pid, environment, file}`. `file` is a relative test path or `null` for an arbitrary Node command. Missing capture is `null`; historical receipts without this field retain their canonical bytes. The singular proof `environment` is the common actual child identity, or `null` when the children differ or are unknown. Plain `show` lists each child separately, including mixed versions. Launcher and worker metadata never substitute for a missing child report; this adds no runtime configuration or requirement to execute on multiple versions. Plain `show` prints the same receipt chain. A missing receipt prevents publication of an executed command's outcome. At `PROOF_RUN_ENGINE` and above, shouts longer than 400 Unicode code points are refused with `SHOUT_TOO_LONG`, pointing callers to receipts and `show`; older moves replay under their original limit.
## Approval provenance
diff --git a/src/commands/show.js b/src/commands/show.js
index ea2c07e8..b1ff664e 100644
--- a/src/commands/show.js
+++ b/src/commands/show.js
@@ -1,4 +1,8 @@
import { withBoardRead } from '../cli-board-read.js';
+import {
+ testRuntimeEnvironment,
+ testRuntimeRows,
+} from '../execution-environment.js';
/** The pullboard show command, in its own module so an item adding another command never edits these lines. */
import {
displayAgentName,
@@ -69,13 +73,20 @@ export async function run(io, { first, values }) {
if (item.item_criterion) io.say(`criterion: ${item.item_criterion}`);
if (item.item_check) io.say(`check: ${item.item_check}`);
for (const receipt of proofReceipts) {
- const runtime = receipt.environment ? `Node ${receipt.environment.node} ${receipt.environment.platform}/${receipt.environment.arch}` : 'runtime unknown';
+ const hasTestRuntimes = Object.hasOwn(receipt, 'testRuntimes');
+ const testRuntimes = hasTestRuntimes ? testRuntimeRows(receipt.testRuntimes) : null;
+ const environment = hasTestRuntimes ? testRuntimeEnvironment(testRuntimes) : receipt.environment;
+ const runtime = environment ? `Node ${environment.node} ${environment.platform}/${environment.arch}` : 'runtime unknown';
const counts = Object.values(receipt.counts).some(value => value === null) ? 'test counts unknown'
: `${receipt.counts.passed} pass, ${receipt.counts.failed} fail, ${receipt.counts.skipped} skip`;
io.say(`receipt ${receipt.id}: ${receipt.kind}, item #${receipt.item}`);
io.say(` commit ${receipt.commit ?? 'unknown'}; tree ${receipt.tree ?? 'unknown'}; frozen ${receipt.frozenDigest ?? 'unknown'}`);
io.say(` ${runtime}; runner ${receipt.runner ?? 'unknown'}; seat ${receipt.seat}; parent ${receipt.parentSession ?? 'unknown'}`);
io.say(` exit ${receipt.exitCode ?? 'unknown'}; ${counts}; ${receipt.durationMs}ms${receipt.sourceClean ? '' : '; source unproven'}`);
+ if (hasTestRuntimes && !testRuntimes) io.say(' test child runtimes unknown');
+ for (const child of testRuntimes ?? []) {
+ io.say(` child ${child.pid}: Node ${child.environment.node} ${child.environment.platform}/${child.environment.arch}; ${child.file ?? 'test file unknown'}`);
+ }
}
sayCheckBaseline(io, item);
sayBrief(io, item.item_brief);
diff --git a/src/execution-environment.js b/src/execution-environment.js
index a918bb99..9ba128e6 100644
--- a/src/execution-environment.js
+++ b/src/execution-environment.js
@@ -1,3 +1,18 @@
+import {
+ lstatSync,
+ mkdtempSync,
+ readFileSync,
+ readdirSync,
+ rmSync,
+ writeFileSync,
+} from 'node:fs';
+import { tmpdir } from 'node:os';
+import {
+ join,
+ relative,
+} from 'node:path';
+import { pathToFileURL } from 'node:url';
+
/** Exact executor identity for gate receipts and landing policy [E27,E28]. */
/** Capture this process on the host that actually executes the command. */
@@ -30,3 +45,94 @@ export function carriesLandingEnvironment(batch) {
return ['environment', 'environmentWarnings', 'testDefects'].some(key => Object.hasOwn(batch ?? {}, key))
|| batch?.state === 'test-defect' || Array.isArray(batch?.gateResults) && batch.gateResults.some(gate => Object.hasOwn(gate ?? {}, 'environment'));
}
+
+
+/** The exact trusted preload reports from inside each Node process, independently of its launcher. */
+export function runtimeCaptureSource(directory) {
+ return `import { writeFileSync } from 'node:fs';
+import { randomUUID } from 'node:crypto';
+const directory=${JSON.stringify(directory)};
+const file=directory+'/runtime-'+process.pid+'-'+randomUUID()+'.json';
+process.env.PULLBOARD_RUNTIME_CAPTURE_RECORD=file;
+writeFileSync(file,JSON.stringify({pid:process.pid,environment:{platform:process.platform,arch:process.arch,node:process.version.slice(1)},file:null}),{flag:'wx',mode:0o600});
+`;
+}
+
+/** Bind a closed admitted worker's self-report to the file selected by its parent, never by test stdout. */
+export function bindTestRuntime(pid, file) {
+ const directory = process.env.PULLBOARD_RUNTIME_CAPTURE_DIR;
+ if (!directory) return null;
+ try {
+ const names = readdirSync(directory).filter(name => name.startsWith('runtime-' + pid + '-') && name.endsWith('.json'));
+ if (names.length !== 1) return false;
+ const path = join(directory, names[0]);
+ const own = JSON.parse(readFileSync(path, 'utf8'));
+ if (own.pid !== pid || environmentProblem(own.environment)) return false;
+ const bound = { pid, environment: own.environment, file: relative(process.cwd(), file).replaceAll('\\', '/') };
+ if (!testRuntimeRows([bound])) return false;
+ writeFileSync(path, JSON.stringify(bound), { mode: 0o600 });
+ return true;
+ } catch { return false; /* A missing child report cannot be replaced by the parent's identity. */ }
+}
+
+/** Validate bounded self-reported child rows; historical absence remains unknown. */
+export function testRuntimeRows(value) {
+ if (value === null) return null;
+ if (!Array.isArray(value) || !value.length || value.length > 100_000) return null;
+ const rows = [];
+ const pids = new Set();
+ for (const row of value) {
+ if (!row || Object.keys(row).sort().join(',') !== 'environment,file,pid'
+ || !Number.isSafeInteger(row.pid) || row.pid < 1 || pids.has(row.pid) || environmentProblem(row.environment)
+ || row.file !== null && (typeof row.file !== 'string' || !row.file || row.file.length > 4096 || /[\r\n\0\\]/u.test(row.file) || row.file.startsWith('/') || /^[A-Za-z]:/u.test(row.file)
+ || row.file.split('/').some(part => !part || part === '.' || part === '..'))) return null;
+ pids.add(row.pid);
+ rows.push({ pid: row.pid, environment: { ...row.environment }, file: row.file });
+ }
+ return rows;
+}
+
+/** Keep the common actual test-child identity only when every selected child agrees; otherwise unknown. */
+export function testRuntimeEnvironment(rows) {
+ const checked = testRuntimeRows(rows);
+ if (!checked) return null;
+ const files = checked.filter(row => row.file !== null);
+ const selected = files.length ? files : checked;
+ const first = selected[0].environment;
+ return selected.every(row => sameEnvironment(first, row.environment)) ? { ...first } : null;
+}
+
+/** Capture actual Node children in a private run directory without changing test output or the machine pool. */
+export function captureTestRuntimes(env) {
+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-test-runtimes-'));
+ const preload = join(directory, 'test-runtime-preload.mjs');
+ writeFileSync(preload, runtimeCaptureSource(directory), { flag: 'wx', mode: 0o600 });
+ let finished = false;
+ return {
+ env: { ...env, NODE_OPTIONS: [env.NODE_OPTIONS, '--import=' + pathToFileURL(preload).href].filter(Boolean).join(' '),
+ PULLBOARD_RUNTIME_CAPTURE_DIR: directory },
+ /** Read bounded child reports only after command close, then remove the private capture directory. */
+ finish() {
+ if (finished) return null;
+ finished = true;
+ try {
+ const names = readdirSync(directory).filter(name => /^runtime-[0-9]+-[a-f0-9-]+\.json$/u.test(name));
+ if (names.length > 100_000) return null;
+ const rows = [];
+ let bytes = 0;
+ for (const name of names.sort()) {
+ const file = join(directory, name);
+ const stat = lstatSync(file);
+ bytes += stat.size;
+ if (!stat.isFile() || stat.size > 8192 || bytes > 8 * 1024 * 1024) return null;
+ rows.push(JSON.parse(readFileSync(file, 'utf8')));
+ }
+ const checked = testRuntimeRows(rows);
+ if (!checked) return null;
+ const files = checked.filter(row => row.file !== null);
+ return files.length ? files : checked;
+ } catch { return null; /* Missing or incomplete self-reports stay unknown, never become the launcher runtime. */ }
+ finally { rmSync(directory, { recursive: true, force: true }); }
+ },
+ };
+}
diff --git a/src/gate.js b/src/gate.js
index bd6c266b..14dc1db1 100644
--- a/src/gate.js
+++ b/src/gate.js
@@ -39,7 +39,11 @@ import {
loadavg,
} from 'node:os';
import { fileURLToPath } from 'node:url';
-import { executionEnvironment } from './execution-environment.js';
+import {
+ captureTestRuntimes,
+ executionEnvironment,
+ testRuntimeEnvironment,
+} from './execution-environment.js';
import { constrainedLandingHost } from './landing-host.js';
import {
gitChildEnv,
@@ -288,7 +292,8 @@ function leaveProofReceipt(root, command, run, before, context, lease) {
const sourceClean = before.clean && after.clean && before.head === after.head && before.tree === after.tree
&& run.executionSourceUnchanged !== false && (!source || source.commit === before.head && source.tree === before.tree)
&& (!lease?.runner || Boolean(source));
- const environment = run.environment ?? run.profile?.environment ?? null;
+ const testRuntimes = run.testRuntimes ?? run.profile?.testRuntimes ?? null;
+ const environment = testRuntimeEnvironment(testRuntimes);
const remote = run.executionRunner ?? run.profile?.executionRunner;
const localLoad = { average: loadavg(), cpus: availableParallelism(), freeMB: Math.floor(freemem() / 1048576) };
let main = null;
@@ -298,7 +303,7 @@ function leaveProofReceipt(root, command, run, before, context, lease) {
green: run.isGreen ?? run.state === 'pass', failures: [],
load: run.executionLoad ?? (remote || lease?.runner ? null : localLoad), at: new Date().toISOString(),
proof: { item: context.item, frozenDigest: context.frozenDigest ?? null, seat: context.seat,
- environment, runner: remote ?? (lease?.runner ? null
+ environment, testRuntimes, runner: remote ?? (lease?.runner ? null
: run.profile?.receipt?.runner?.id ?? lease?.receipt?.runner?.id ?? lease?.localDescriptor?.id ?? null), exitCode: run.exitCode,
counts: run.proofCounts ?? proofCounts(run.outputPath ? logLines(run.outputPath) : run.output ?? ''),
durationMs: Math.max(0, Math.round(run.remoteWallMs ?? run.profile?.wallMs ?? run.seconds * 1000)), sourceClean } });
@@ -351,7 +356,8 @@ export async function runProfiledShellAsync(root, command, { waitMs = 0, gateSlo
[LANDING_RUN_ENV]: landing ? '1' : '0',
PULLBOARD_TEST_STAGE: gateLease?.receiptKind ?? (landing ? 'land' : 'gate'),
};
- const env = { ...gitChildEnv(root), ...inherited };
+ const runtimes = captureTestRuntimes({ ...gitChildEnv(root), ...inherited });
+ const env = runtimes.env;
const environment = executionEnvironment();
const child = spawn(`(\n${command}\n) 2>&1`, { cwd: root, env, shell: true, stdio: ['ignore', 'pipe', 'pipe'] });
const chunks = [];
@@ -368,6 +374,7 @@ export async function runProfiledShellAsync(root, command, { waitMs = 0, gateSlo
child.stderr.setEncoding('utf8').on('data', capture);
child.once('error', error => { failure = error; });
const status = await new Promise(resolveClose => child.once('close', resolveClose));
+ const testRuntimes = runtimes.finish();
gateLease?.tracker?.mark('ranAt');
if (gateLease) gateLease.environment = environment;
invalidateGitFacts();
@@ -377,7 +384,7 @@ export async function runProfiledShellAsync(root, command, { waitMs = 0, gateSlo
const profilePath = join(dirname(gitPath(root, LOG)), `pullboard-gate-${randomUUID()}.profile.json`);
const profile = writeTimingProfile(profilePath, { ...timingFromOutput(output, timingRunner(command)),
waitMs: Math.max(0, Math.round(waitMs)), wallMs, receipt: settleReceipt(gateLease) });
- return { isGreen: status === 0 && !overflow && !failure, environment, sandboxBlocked: status === 0 ? null : sandboxBlockedOperation(root, output), output, seconds: Math.round(wallMs / 1000), profile, profilePath, logPath: null };
+ return { isGreen: status === 0 && !overflow && !failure, environment, testRuntimes, sandboxBlocked: status === 0 ? null : sandboxBlockedOperation(root, output), output, seconds: Math.round(wallMs / 1000), profile, profilePath, logPath: null };
}
/** Close a gated run's receipt (#836) as its evidence is written; the slot's release records this same receipt. */
diff --git a/src/private-check-worker.js b/src/private-check-worker.js
index 03b2f982..ff2f3536 100644
--- a/src/private-check-worker.js
+++ b/src/private-check-worker.js
@@ -1,6 +1,9 @@
/** Collect private command output through pipes; dependency files are never size-limited [V18,V2]. */
import { spawn } from 'node:child_process';
-import { executionEnvironment } from './execution-environment.js';
+import {
+ captureTestRuntimes,
+ executionEnvironment,
+} from './execution-environment.js';
import {
createWriteStream,
readFileSync,
@@ -38,7 +41,8 @@ function capture(chunk) {
}
}
-const child = spawn('sh', ['-c', `(\n${command}\n) 2>&1`], { detached: true, stdio: ['ignore', 'pipe', 'pipe'] });
+const runtimes = captureTestRuntimes(process.env);
+const child = spawn('sh', ['-c', `(\n${command}\n) 2>&1`], { detached: true, env: runtimes.env, stdio: ['ignore', 'pipe', 'pipe'] });
if (child.pid) writeFileSync(pidFile, String(child.pid), { mode: 0o600 });
/** Stop the command's entire process group, including background descendants that retain pipes. */
@@ -63,7 +67,8 @@ child.once('close', (status, signal) => {
sent = true;
const marker = bytes > LIMIT ? '\n[output capped at 8 MiB; middle omitted]\n' : '';
const output = head.toString('utf8') + marker + tail.toString('utf8');
- process.stdout.write(JSON.stringify({ status, signal, executed: Boolean(child.pid), error: timedOut ? { code: 'ETIMEDOUT' } : error, logError, output, environment: executionEnvironment() }));
+ const testRuntimes = runtimes.finish();
+ process.stdout.write(JSON.stringify({ status, signal, executed: Boolean(child.pid), error: timedOut ? { code: 'ETIMEDOUT' } : error, logError, output, environment: executionEnvironment(), testRuntimes }));
};
log.once('close', finish);
if (log.closed) finish();
diff --git a/src/proof-provenance.js b/src/proof-provenance.js
index 62a02b33..672e60fe 100644
--- a/src/proof-provenance.js
+++ b/src/proof-provenance.js
@@ -1,4 +1,8 @@
/** Normalize execution facts without inventing missing runtime identities or test counts [C7,H16]. */
+import {
+ testRuntimeEnvironment,
+ testRuntimeRows,
+} from './execution-environment.js';
/** A bounded identity from the executor, never a command or an agent's narrative. */
function identity(value, limit = 512) {
@@ -15,13 +19,18 @@ export function proofFields(value) {
const environment = value.environment;
if (environment !== null && (!environment || !identity(environment.node, 80)
|| !identity(environment.platform, 80) || !identity(environment.arch, 80))) return null;
+ const hasTestRuntimes = Object.hasOwn(value, 'testRuntimes');
+ const testRuntimes = hasTestRuntimes ? testRuntimeRows(value.testRuntimes) : null;
+ if (hasTestRuntimes && value.testRuntimes !== null && testRuntimes === null) return null;
+ const actualEnvironment = hasTestRuntimes ? testRuntimeEnvironment(testRuntimes) : environment;
const names = ['passed', 'failed', 'skipped'];
if (!value.counts || !names.every(name => value.counts[name] === null
|| Number.isSafeInteger(value.counts[name]) && value.counts[name] >= 0)) return null;
return { item: value.item, frozenDigest: value.frozenDigest,
- environment: environment === null ? null : { node: environment.node, platform: environment.platform, arch: environment.arch },
+ environment: actualEnvironment === null ? null : { node: actualEnvironment.node, platform: actualEnvironment.platform, arch: actualEnvironment.arch },
seat: value.seat, runner: value.runner, exitCode: value.exitCode,
- counts: Object.fromEntries(names.map(name => [name, value.counts[name]])), durationMs: value.durationMs, sourceClean: value.sourceClean };
+ counts: Object.fromEntries(names.map(name => [name, value.counts[name]])), durationMs: value.durationMs, sourceClean: value.sourceClean,
+ ...(hasTestRuntimes ? { testRuntimes } : {}) };
}
/** Read explicit TAP or Node reporter totals; absent counters stay unknown rather than becoming zero. */
diff --git a/src/proof-receipts.js b/src/proof-receipts.js
index cd3049b4..b2a9b273 100644
--- a/src/proof-receipts.js
+++ b/src/proof-receipts.js
@@ -42,7 +42,8 @@ export function proofRunReceipt(board, request) {
const receipt = { id: run.id, kind: run.kind, item: itemId, commit: run.head, tree: run.tree,
frozenDigest: run.proof.frozenDigest, environment: run.proof.environment, runner: run.proof.runner,
seat: agentId, parentSession: seats.agentParent?.(board, agentId) ?? null, exitCode: run.proof.exitCode,
- counts: run.proof.counts, durationMs: run.proof.durationMs, sourceClean: run.proof.sourceClean, at: run.at };
+ counts: run.proof.counts, durationMs: run.proof.durationMs, sourceClean: run.proof.sourceClean, at: run.at,
+ ...(Object.hasOwn(run.proof, 'testRuntimes') ? { testRuntimes: run.proof.testRuntimes } : {}) };
const existing = proofReceipts(board, itemId).find(value => value.id === receipt.id);
if (existing) {
const { eventId, ...fields } = existing;
diff --git a/src/runner-private-check.js b/src/runner-private-check.js
index 158f342b..a201e728 100644
--- a/src/runner-private-check.js
+++ b/src/runner-private-check.js
@@ -92,12 +92,12 @@ export function runnerPrivateCheck(root, item, command, policy, lease, guard, wa
const profile = checkLogPath ? timingFromLog(checkLogPath, timingRunner(command)) : { files: [], tests: [] };
const formatted = format(captureProblem ? 'unverified' : result.privateCheck.state, captureProblem ? `private-check output could not be authenticated or saved; raw output retained at ${result.rawOutputPath} sha256 ${result.rawOutputSha256}` : result.privateCheck.stage, installCapture, checkCapture,
{ root, item, commandRoot: result.executionRoot, installLogPath, checkLogPath, waitMs,
- timingProfile: { ...profile, wallMs: Date.now() - started, environment: result.environment,
+ timingProfile: { ...profile, wallMs: Date.now() - started, environment: result.environment, testRuntimes: result.testRuntimes,
executionRunner: result.executionRunner, executionSource: result.executionSource, executionMain: result.executionMain,
executionLoad: result.executionLoad, executionAdmission: result.executionAdmission,
privateCheckPolicySha256: mode.sha256, rawOutputPath: result.rawOutputPath, rawOutputSha256: result.rawOutputSha256 },
- environment: result.environment, executionSourceUnchanged: result.privateCheck.receipt.sourceUnchanged });
- return { ...formatted, sandboxBlocked: result.sandboxBlocked ?? formatted.sandboxBlocked, executionRunner: result.executionRunner, executionSource: result.executionSource,
+ environment: result.environment, testRuntimes: result.testRuntimes, executionSourceUnchanged: result.privateCheck.receipt.sourceUnchanged });
+ return { ...formatted, testRuntimes: result.testRuntimes ?? null, sandboxBlocked: result.sandboxBlocked ?? formatted.sandboxBlocked, executionRunner: result.executionRunner, executionSource: result.executionSource,
executionLoad: result.executionLoad, executionMain: result.executionMain, executionAdmission: result.executionAdmission,
rawOutputPath: result.rawOutputPath, rawOutputSha256: result.rawOutputSha256,
guardProblem: result.privateCheck.receipt.guard?.problem ?? '',
diff --git a/src/runner-worker.js b/src/runner-worker.js
index ff4d7625..62aff4f3 100644
--- a/src/runner-worker.js
+++ b/src/runner-worker.js
@@ -20,7 +20,10 @@ import {
writeFileSync,
} from 'node:fs';
import { availableParallelism } from 'node:os';
-import { executionEnvironment } from './execution-environment.js';
+import {
+ captureTestRuntimes,
+ executionEnvironment,
+} from './execution-environment.js';
import { sampleRunnerLoad } from './runner-load.js';
import { freemem } from 'node:os';
import { loadavg } from 'node:os';
@@ -858,7 +861,7 @@ async function runPrivateCheck(spec, root, env, sink, tracker) {
async function receipt(spec, fields, sink) {
await flushStdout();
const body = { id: spec.id, commit: spec.commit, tree: spec.tree, code: fields.code, signal: fields.signal,
- environment: executionEnvironment(), gui: fields.gui ?? null, timing: spec.timing === true, executionAdmission: fields.executionAdmission ?? null,
+ environment: executionEnvironment(), testRuntimes: fields.testRuntimes ?? null, gui: fields.gui ?? null, timing: spec.timing === true, executionAdmission: fields.executionAdmission ?? null,
runtimeSha256: spec.runtime.sha256, toolingSha256: spec.tooling.sha256, root: fields.root ?? '', outputSha256: sink.hash.digest('hex'), wallMs: Math.max(0, Date.now() - sink.wallStart),
// The execution host's load and the pinned main this run used, so a paired rerun here can be judged (#925).
main: typeof spec.main === 'string' ? spec.main : null, load: { average: loadavg(), cpus: availableParallelism(), freeMB: Math.floor(freemem() / 1048576) },
@@ -909,6 +912,7 @@ async function main() {
let api;
let lease = null;
let tracker = null;
+ let runtimeCapture = null;
let runDirectory;
let setupStep = 'runner directories';
let gui = null;
@@ -962,7 +966,8 @@ async function main() {
});
cleanupDetails = tracker.cleanupState;
activeDescendantTracker = tracker;
- const env = scopedEnvironment(privateHome, temporary, canonicalMachineHome, lease, api, tracker.nodeOptions);
+ runtimeCapture = captureTestRuntimes(scopedEnvironment(privateHome, temporary, canonicalMachineHome, lease, api, tracker.nodeOptions));
+ const env = runtimeCapture.env;
setupStep = 'source history checkout';
await checkoutHistory(api, runnerRoot, root, packFile, spec, env);
if (!spec.trustedMode) {
@@ -1003,6 +1008,7 @@ async function main() {
}
} finally { await releaseDrainedLease(lease); }
}
+ final.testRuntimes = runtimeCapture?.finish() ?? null;
cleanupStage = 'job files';
if (runDirectory && !cleanupTimedOut) { try { rmSync(runDirectory, { recursive: true, force: true }); } catch {} }
}
diff --git a/src/runners.js b/src/runners.js
index 6a0d8188..4429c941 100644
--- a/src/runners.js
+++ b/src/runners.js
@@ -33,7 +33,10 @@ import {
} from 'node:path';
import { fileURLToPath } from 'node:url';
import { pipeline } from 'node:stream/promises';
-import { environmentProblem } from './execution-environment.js';
+import {
+ environmentProblem,
+ testRuntimeRows,
+} from './execution-environment.js';
import {
gunzipSync,
gzipSync,
@@ -592,6 +595,7 @@ function resultFrom(request, result) {
} else if (receipt.trustedMode !== undefined) throw new RunnerDropped(request.runner.host);
const text = staged?.output ?? output.toString('utf8');
if (receipt.environment !== undefined && environmentProblem(receipt.environment)) throw new RunnerDropped(request.runner.host);
+ if (receipt.testRuntimes != null && !testRuntimeRows(receipt.testRuntimes)) throw new RunnerDropped(request.runner.host);
if (receipt.browserRefused !== undefined && (receipt.browserRefused !== true || receipt.code === 0 || request.spec.browserRequired)) throw new RunnerDropped(request.runner.host);
const admission = remoteAdmission(receipt.executionAdmission);
if (request.spec.timing === true && (receipt.timing !== true || !admission)) throw new RunnerDropped(request.runner.host);
@@ -602,7 +606,7 @@ function resultFrom(request, result) {
throw refused;
}
return { isGreen: receipt.code === 0 && !receipt.signal, output: text, sandboxBlocked, ...(receipt.timedOut ? { timedOut: true } : {}),
- environment: receipt.environment ?? null, executionCapabilities: { gui: receipt.gui ?? null },
+ environment: receipt.environment ?? null, testRuntimes: receipt.testRuntimes ?? null, executionCapabilities: { gui: receipt.gui ?? null },
...(request.spec.stageMarker ? { stages: staged?.stages ?? null } : {}),
seconds: Math.round(receipt.wallMs / 1000), exitCode: receipt.code,
executionRunner: request.runner.host, executionRoot: receipt.root, remoteWallMs: receipt.wallMs,
diff --git a/src/shell-run.js b/src/shell-run.js
index 62dcc382..d8ba5d62 100644
--- a/src/shell-run.js
+++ b/src/shell-run.js
@@ -3,7 +3,10 @@
* board read that replays a check baseline needs only this, so it never loads the gate [C7].
*/
import { spawnSync } from 'node:child_process';
-import { executionEnvironment } from './execution-environment.js';
+import {
+ captureTestRuntimes,
+ executionEnvironment,
+} from './execution-environment.js';
import { randomUUID } from 'node:crypto';
import {
mkdtempSync,
@@ -38,8 +41,8 @@ import { sandboxBlockedOperation } from './sandbox-denial.js';
*/
export function runShell(root, command, { pipefail = false, env = {}, stages = false, timeoutMs } = {}) {
const started = Date.now();
- const environment = executionEnvironment();
- const options = { cwd: root, env: { ...gitChildEnv(root), ...env }, shell: true, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', maxBuffer: 2 ** 30 };
+ const runtimes = captureTestRuntimes({ ...gitChildEnv(root), ...env });
+ const options = { cwd: root, env: runtimes.env, shell: true, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', maxBuffer: 2 ** 30 };
let prefix = '';
if (pipefail) {
// Probe the same shell as the command, with no load-sensitive deadline or alternate shell.
@@ -66,15 +69,17 @@ export function runShell(root, command, { pipefail = false, env = {}, stages = f
invalidateGitFacts();
const pipeStatuses = pipes ? readPipes(split, pipes) : null;
if (pipes) rmSync(pipes, { recursive: true, force: true });
+ const testRuntimes = runtimes.finish();
+ const environment = executionEnvironment();
const raw = `${result.stdout ?? ''}${result.stderr ?? ''}`;
const seconds = Math.round((Date.now() - started) / 1000);
const blocked = (output) => (result.status === 0 ? null : sandboxBlockedOperation(root, output));
- if (!stages) return { isGreen: result.status === 0, exitCode: result.status, output: raw, seconds, environment, ...(timed ? { timedOut: result.timedOut } : {}), sandboxBlocked: blocked(raw) };
- if (!split) return { isGreen: result.status === 0, exitCode: result.status, output: raw, seconds, environment, ...(timed ? { timedOut: result.timedOut } : {}), stages: null, sandboxBlocked: blocked(raw) };
+ if (!stages) return { isGreen: result.status === 0, exitCode: result.status, output: raw, seconds, environment, testRuntimes, ...(timed ? { timedOut: result.timedOut } : {}), sandboxBlocked: blocked(raw) };
+ if (!split) return { isGreen: result.status === 0, exitCode: result.status, output: raw, seconds, environment, testRuntimes, ...(timed ? { timedOut: result.timedOut } : {}), stages: null, sandboxBlocked: blocked(raw) };
const staged = readStages(raw, marker, split.length);
// Each pipeline component's own status rides on its stage, so no failing producer hides behind a later one.
const withPipes = staged.stages.map((stage, index) => (pipeStatuses?.[index] ? { ...stage, pipeline: pipeStatuses[index] } : stage));
- return { isGreen: result.status === 0, exitCode: result.status, seconds, environment, ...(timed ? { timedOut: result.timedOut } : {}), ...staged, stages: withPipes, sandboxBlocked: blocked(staged.output) };
+ return { isGreen: result.status === 0, exitCode: result.status, seconds, environment, testRuntimes, ...(timed ? { timedOut: result.timedOut } : {}), ...staged, stages: withPipes, sandboxBlocked: blocked(staged.output) };
}
/** Conservatively detect a pipe when the configured gate shell cannot enforce every stage's status. */
diff --git a/src/test-file-dispatch.js b/src/test-file-dispatch.js
index 26d36741..e4e60d25 100644
--- a/src/test-file-dispatch.js
+++ b/src/test-file-dispatch.js
@@ -19,6 +19,7 @@ import { testsNeedBrowser } from './browser-admission.js';
import { takeResource } from './resources.js';
import { reserveTestFileToken } from './test-file-pool.js';
import { TEST_FILE_POOL_ENV } from './test-file-pool.js';
+import { bindTestRuntime } from './execution-environment.js';
/** Counter trailers are identified by their structured root-plan boundary, never by parsing test stdout/TAP. */
function trailer(event, afterPlan) {
@@ -54,7 +55,7 @@ function admissionImport(value, browser, runner) {
}
/** Observe the actual native ChildProcess without changing spawn; its opaque bootstrap binds one file. */
-function fileExitObserver(bootstrap) {
+function fileExitObserver(bootstrap, file) {
const records = [];
const source = channel('child_process');
const observe = ({ process: child }) => {
@@ -69,6 +70,9 @@ function fileExitObserver(bootstrap) {
&& child.spawnargs?.includes(bootstrap) && Number.isInteger(child.pid) && child.pid > 0);
if (owned.length > 1) throw new Error('one file admission started more than one actual worker');
await Promise.all(owned.map(record => record.closed));
+ for (const { child } of owned) {
+ if (bindTestRuntime(child.pid, file) === false) throw new Error('the actual test worker has no self-reported runtime: ' + file);
+ }
return owned.length;
})();
}
@@ -140,7 +144,7 @@ export function dispatchTestFiles(options, env) {
const preload = execArgv.indexOf('--import');
if (preload < 0 || !execArgv[preload + 1]) throw new Error('test-file dispatch requires its ordinary runner preload');
execArgv[preload + 1] = admissionImport(token.value, browser, execArgv[preload + 1]);
- fileExited = fileExitObserver(execArgv[preload + 1]);
+ fileExited = fileExitObserver(execArgv[preload + 1], file);
const source = run({ ...options, files: [file], shard: undefined, concurrency: 1, signal,
setup: undefined, execArgv });
source.once('error', error => controller.abort(error));
diff --git a/src/test-isolation.js b/src/test-isolation.js
index 82b8bc87..25d9ffef 100644
--- a/src/test-isolation.js
+++ b/src/test-isolation.js
@@ -14,6 +14,7 @@ import {
join,
} from 'node:path';
import { fileURLToPath } from 'node:url';
+import { runtimeCaptureSource } from './execution-environment.js';
import { childJournalPreloadSource } from './child-journal-preload.js';
/** Stands in for the OS account home when machine state falls back to it (src/machine-home.js). */
@@ -47,6 +48,16 @@ function runnerPreload(declared) {
}
}
+/** Recognize only the exact child-runtime recorder, without trusting a caller's preload declaration. */
+function runtimePreload(token) {
+ const url = /^--import=(file:\/\/\S+\/test-runtime-preload\.mjs)$/u.exec(token ?? '')?.[1];
+ if (!url) return false;
+ try {
+ const file = fileURLToPath(url);
+ return readFileSync(file, 'utf8') === runtimeCaptureSource(dirname(file));
+ } catch { return false; /* A missing or different recorder remains foreign and retains conservative admission. */ }
+}
+
/**
* Point every machine-state fallback of a test run at its sandbox and drop host markers tests model explicitly.
* A test that wants a hostile machine builds one in its own fixture; it never inherits the real one.
@@ -77,5 +88,5 @@ export function foreignNodeOptions(value, env = process.env) {
const declared = env[RUNNER_PRELOAD_ENV];
const known = new Set([SLOT_GUARD_IMPORT]);
if (runnerPreload(declared)) known.add(declared);
- return String(value ?? '').split(/\s+/u).filter(Boolean).some(token => !known.has(token));
+ return String(value ?? '').split(/\s+/u).filter(Boolean).some(token => !known.has(token) && !runtimePreload(token));
}
diff --git a/src/trusted-policy.js b/src/trusted-policy.js
index ba4af69c..753848db 100644
--- a/src/trusted-policy.js
+++ b/src/trusted-policy.js
@@ -195,6 +195,7 @@ export function checkAtCommit(root, item, { waitMs = 0, gateSlotHeld = false, ga
let installOutput = '';
let checkOutput = '';
let environment = null;
+ let testRuntimes = null;
const checkStartedAt = Date.now();
let installLogPath = '';
let checkLogPath = '';
@@ -208,7 +209,7 @@ export function checkAtCommit(root, item, { waitMs = 0, gateSlotHeld = false, ga
const events = checkLogPath && existsSync(checkLogPath) ? timingFromLog(checkLogPath, runner) : timingFromOutput(checkOutput, runner);
timingProfile = { ...events, wallMs: Math.max(0, Date.now() - checkStartedAt), environment };
return checkResult(state, stage, installOutput, checkOutput, { root, item, commandRoot: copy, installLogPath, checkLogPath, timingProfile, waitMs,
- environment, executed, exitCode, proofCounts: privateCheckCounts(checkLogPath, checkOutput), executionSourceUnchanged: checkedSourceReady && privateSourceUnchanged(copy, item.item_commit, env) });
+ environment, testRuntimes, executed, exitCode, proofCounts: privateCheckCounts(checkLogPath, checkOutput), executionSourceUnchanged: checkedSourceReady && privateSourceUnchanged(copy, item.item_commit, env) });
};
try {
const common = policyGit(root, ['rev-parse', '--path-format=absolute', '--git-common-dir']).trim();
@@ -256,6 +257,7 @@ export function checkAtCommit(root, item, { waitMs = 0, gateSlotHeld = false, ga
executed = run.executed === true;
exitCode = run.status ?? null;
environment = environmentProblem(run.environment) ? null : run.environment;
+ testRuntimes = run.testRuntimes ?? null;
checkOutput = run.output;
if (run.error?.code === 'ETIMEDOUT') return finish('unverified', 'check timed out');
if (run.error) return finish('unverified', `check could not start (${run.error.code})`);
@@ -419,7 +421,7 @@ function privateSourceUnchanged(root, commit, env) {
}
/** Persist a sanitized full diagnostic outside the temporary checkout so a refusal can name it. */
-function checkResult(state, stage, installCapture, checkCapture, { root = '', item = {}, commandRoot = root, installLogPath = '', checkLogPath = '', timingProfile = null, waitMs = 0, environment = null, executed = false, exitCode = null, proofCounts = null, executionSourceUnchanged } = {}) {
+function checkResult(state, stage, installCapture, checkCapture, { root = '', item = {}, commandRoot = root, installLogPath = '', checkLogPath = '', timingProfile = null, waitMs = 0, environment = null, testRuntimes = null, executed = false, exitCode = null, proofCounts = null, executionSourceUnchanged } = {}) {
const boundedInstall = secretScanned(installCapture, 'check install capture');
const boundedCheck = secretScanned(checkCapture, 'frozen check capture');
const install = digestOf(boundedInstall) || '(no output)';
@@ -495,6 +497,6 @@ function checkResult(state, stage, installCapture, checkCapture, { root = '', it
: /could not start/u.test(stage) ? "couldn't start" : state === 'unverified' ? 'could not be verified' : 'passed';
const output = `install output:\n${boundedInstall || '(no output)'}\ncheck output:\n${boundedCheck || '(not run or no output)'}`;
return { sandboxBlocked, state, green: state === 'pass', checked: true, stage, failure, report, output, outputTail, outputPath, outputError, profilePath,
- executionRoot: commandRoot, environment, executed, exitCode, proofCounts, ...(executionSourceUnchanged === undefined ? {} : { executionSourceUnchanged }),
+ executionRoot: commandRoot, environment, testRuntimes, executed, exitCode, proofCounts, ...(executionSourceUnchanged === undefined ? {} : { executionSourceUnchanged }),
profile: timingProfile ? { ...timingProfile, profilePath } : null };
}
diff --git a/test/proof-provenance.test.js b/test/proof-provenance.test.js
index 0233b719..8fd30caa 100644
--- a/test/proof-provenance.test.js
+++ b/test/proof-provenance.test.js
@@ -178,3 +178,51 @@ test('an offline proof receipt follows the item its queued add actually creates
assert.deepEqual(applyEngineMove(replica, resolved.move, { sequence: 2, at }), replay, 'same-position retry remains idempotent');
assert.equal(readFileSync(file, 'utf8'), nativeBody, 'wire reference remapping never edits the origin native receipt file');
});
+
+// Synthetic schema/replay controls; these rows do not claim an actual child was executed.
+test('child runtime fields preserve legacy bytes and replay mixed environments without a common runtime [C7,H16]', t => {
+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-child-runtime-replay-'));
+ t.after(() => rmSync(directory, { recursive: true, force: true }));
+ const board = store.openBoard(join(directory, 'board.sqlite'));
+ const replica = store.openBoard(':memory:');
+ t.after(() => { store.closeBoard(replica); store.closeBoard(board); });
+ let item;
+ for (const target of [board, replica]) {
+ store.register(target, { lane: 'coordinator', path: '/runtime-coordinator' });
+ store.register(target, { lane: 'web', path: '/runtime-builder' });
+ item = store.addItem(target, { by: 'coordinator', lane: 'web', title: 'Synthetic child runtime replay' });
+ }
+ const legacy = { version: 2, id: '00000000-0000-4000-8000-00000000c11d', kind: 'check',
+ tree: 'b'.repeat(40), head: 'a'.repeat(40), main: null, command: 'c'.repeat(64), green: false,
+ failures: [], load: null, at: '2026-10-23T00:00:00.000Z',
+ proof: { item, frozenDigest: null, environment: null, seat: 'web-1', runner: null, exitCode: 7,
+ counts: { passed: null, failed: null, skipped: null }, durationMs: 37, sourceClean: false } };
+ assert.equal(receiptBody(legacy), JSON.stringify(legacy) + '\n', 'absent child fields keep exact historical canonical bytes');
+ assert.equal(Object.hasOwn(receiptFields(legacy).proof, 'testRuntimes'), false);
+ const environment = { platform: 'darwin', arch: 'arm64', node: '22.13.1' };
+ const rows = [{ pid: 101, environment, file: 'test/first.test.js' },
+ { pid: 102, environment: { ...environment, node: '24.21.0' }, file: 'test/second.test.js' }];
+ const supplied = { ...legacy, proof: { ...legacy.proof, environment, testRuntimes: rows } };
+ const checked = receiptFields(supplied);
+ assert.equal(checked.proof.environment, null, 'mixed actual child versions cannot borrow the declared launcher environment');
+ assert.deepEqual(checked.proof.testRuntimes, rows);
+ const unknown = receiptFields({ ...supplied, proof: { ...supplied.proof, testRuntimes: null } });
+ assert.equal(unknown.proof.testRuntimes, null);
+ assert.equal(unknown.proof.environment, null, 'explicit unknown children do not become a known launcher');
+ for (const invalid of [undefined, [], {}, [{}], [{ ...rows[0], pid: 0 }],
+ [{ ...rows[0], environment: { ...environment, node: 'not-a-version' } }],
+ [{ ...rows[0], file: '../escape.test.js' }], [rows[0], rows[0]]]) {
+ assert.equal(receiptFields({ ...supplied, proof: { ...supplied.proof, testRuntimes: invalid } }), null,
+ 'malformed supplied child rows are rejected rather than silently omitted');
+ }
+ mkdirSync(boardReceiptStore(board));
+ writeFileSync(join(boardReceiptStore(board), `${supplied.id}.json`), receiptBody(supplied));
+ const args = [{ agentId: 'web-1', itemId: item, receiptId: supplied.id }];
+ const move = prepareEngineMove(board, 'recordProofRun', args, { actor: 'web-1' });
+ const recorded = store.recordProofRun(board, args[0]);
+ assert.equal(recorded.environment, null);
+ assert.deepEqual(recorded.testRuntimes, rows);
+ assert.equal(applyEngineMove(replica, move, { sequence: 1, at: supplied.at }).error, undefined);
+ const [{ eventId, ...replayed }] = store.proofReceipts(replica, item);
+ assert.deepEqual(replayed, recorded, 'sealed native replay preserves every child environment without the origin files');
+});