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
test(core): report fixture child failures [C7]
Corey Olson268431fd286c
diff --git a/test/agent-session.test.js b/test/agent-session.test.jsindex f8f1b262..e8f7b019 100644--- a/test/agent-session.test.js+++ b/test/agent-session.test.js@@ -1,6 +1,7 @@/** Checkout-session ownership and takeover behavior [B3,B7]. */import assert from 'node:assert/strict';-import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { spawn } from 'node:child_process';+import { fixtureChildMessage, reportFixtureChildFailure, runFixtureChild, runFixtureGit } from './fixture-child.js';import { createHash } from 'node:crypto';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync, readdirSync } from 'node:fs';import { tmpdir } from 'node:os';@@ -37,7 +38,7 @@ function sandbox() {});/** Run real Git with the private environment. */function git(cwd, ...args) {- return execFileSync('git', args, { cwd, env: base, encoding: 'utf8', stdio: 'pipe' }).trim();+ return runFixtureGit(args, { cwd, env: base });}/** Run the actual CLI with an explicit agent session or markerless terminal. */function run(cwd, args, { session, sessionKey = 'CLAUDE_CODE_SESSION_ID', agent = true } = {}) {@@ -46,7 +47,7 @@ function sandbox() {env.CLAUDECODE = '1';if (session !== undefined) env[sessionKey] = session;}- return spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 15_000 });+ return runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });}return { dir, base, git, run };}@@ -217,10 +218,10 @@ test('the actual view adapter writes without taking over an agent session [B3,B7const response = await executeMove(process.cwd(), { verb: 'shout', args: { to: 'web', text: 'actual view action' } }, main);process.stdout.write(JSON.stringify(response));`;- const response = spawnSync(process.execPath, ['--input-type=module', '-e', source], {+ const response = runFixtureChild(process.execPath, ['--input-type=module', '-e', source], {cwd: box.repo, env: { ...box.base, CODEX_THREAD_ID: 'other-process-view-session-273' }, encoding: 'utf8', timeout: 15_000,});- assert.equal(response.status, 0, response.stderr);+ assert.equal(response.status, 0, fixtureChildMessage(response));const document = JSON.parse(response.stdout);assert.equal(document.status, 200, response.stdout);assert.equal(document.body.event.event_kind, 'shout');@@ -250,11 +251,23 @@ test('takeover waits for an active write and then refuses the old session [B3,B7box.git(box.web, 'commit', '-q', '-m', 'feat(web): change the page [G1]');/** Start a real CLI write with a durable closed-process observation. */function launch(session, ...args) {- const child = spawn(process.execPath, [BIN, ...args, '--json'], { cwd: box.web, env: { ...box.base, CODEX_SESSION_ID: session }, stdio: ['ignore', 'pipe', 'pipe'] });+ const command = process.execPath;+ const childArgs = [BIN, ...args, '--json'];+ const childEnv = { ...box.base, CODEX_SESSION_ID: session };+ const startedAt = performance.now();+ const child = spawn(command, childArgs, { cwd: box.web, env: childEnv, stdio: ['ignore', 'pipe', 'pipe'] });let output = '';+ let stderr = '';child.stdout.setEncoding('utf8').on('data', (part) => { output += part; });- child.stderr.resume();- child.closed = new Promise((resolveClose) => child.once('close', (code) => resolveClose({ code, output })));+ child.stderr.setEncoding('utf8').on('data', (part) => { stderr += part; });+ let spawnError = null;+ child.once('error', (error) => { spawnError = error; });+ child.closed = new Promise((resolveClose) => child.once('close', (code, signal) => {+ const failure = code === 0 && !signal && !spawnError ? null : reportFixtureChildFailure({ command, args: childArgs,+ status: code, signal, elapsedMs: performance.now() - startedAt, stderr, env: childEnv,+ detail: spawnError?.message ?? '' });+ resolveClose({ code, signal, output, stderr, failure });+ }));return child;}/** Wait on an actual private fixture observation, with an assertion if it never becomes true. */@@ -278,9 +291,9 @@ test('takeover waits for an active write and then refuses the old session [B3,B7assert.equal(boardSnapshot(box.boardFile).shout.length, 0, 'takeover has not recorded a receipt before acquiring the checkout');writeFileSync(release, 'release');const submitted = await submission.closed;- assert.equal(submitted.code, 0, submitted.output);+ assert.equal(submitted.code, 0, submitted.failure ?? submitted.output);const taken = await takeover.closed;- assert.equal(taken.code, 0, taken.output);+ assert.equal(taken.code, 0, taken.failure ?? taken.output);assert.equal(boardSnapshot(box.boardFile).item[0].item_status, 'submitted');const beforeRefusal = boardSnapshot(box.boardFile);const old = box.run(box.web, ['shout', 'coordinator', 'old session cannot write', '--json'], { session: 'active-write-273', sessionKey: 'CODEX_SESSION_ID' });diff --git a/test/api-events.test.js b/test/api-events.test.jsindex bf6d228b..09ed6f98 100644--- a/test/api-events.test.js+++ b/test/api-events.test.js@@ -1,6 +1,6 @@/** CLI move events are the rows written by their command, even with another writer (A2, R2). */import assert from 'node:assert/strict';-import { execFileSync } from 'node:child_process';+import { runFixtureGit } from './fixture-child.js';import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';@@ -37,7 +37,7 @@ async function project(t) {else process.env[key] = value;}});- const git = (...args) => execFileSync('git', args, { cwd: repo, env: { ...process.env, ...env }, stdio: 'pipe' });+ const git = (...args) => runFixtureGit(args, { cwd: repo, env: { ...process.env, ...env }, stdio: 'pipe' });git('init', '-q', '-b', 'main');await command(repo, ['init', '--json']);const configFile = join(repo, 'pullboard.json');diff --git a/test/api-http.test.js b/test/api-http.test.jsindex 2f202533..61c35951 100644--- a/test/api-http.test.js+++ b/test/api-http.test.js@@ -1,7 +1,7 @@/** Real HTTP calls against an isolated Git repo and the actual board engine (A2). */import assert from 'node:assert/strict';import { randomUUID } from 'node:crypto';-import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { createServer, request as httpRequest } from 'node:http';@@ -40,9 +40,9 @@ function fixture(t) {};mkdirSync(env.HOME);/** Run Git only inside the private fixture. */- const git = (...args) => execFileSync('git', args, { cwd: root, env, stdio: 'pipe', encoding: 'utf8' });+ const git = (...args) => runFixtureGit(args, { cwd: root, env, stdio: 'pipe', encoding: 'utf8' });/** Exercise this worktree's real CLI with a private environment. */- const run = (cwd, ...args) => spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ const run = (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });/** Decode one successful versioned CLI invocation without printing session links. */function cli(cwd, ...args) {const result = run(cwd, ...args, '--json');@@ -139,7 +139,7 @@ test('[A2, N33, N35] API listing refreshes live labels and preserves unreadable-t.after(() => { if (priorHome === undefined) delete process.env.PULLBOARD_HOME; else process.env.PULLBOARD_HOME = priorHome; });const second = join(box.dir, 'second-repo');mkdirSync(second);- execFileSync('git', ['init', '-q', '-b', 'main'], { cwd: second, env: box.env, stdio: 'pipe' });+ runFixtureGit(['init', '-q', '-b', 'main'], { cwd: second, env: box.env, stdio: 'pipe' });box.cli(second, 'init');const secondConfigFile = join(second, 'pullboard.json');const secondConfig = JSON.parse(readFileSync(secondConfigFile, 'utf8'));diff --git a/test/api.test.js b/test/api.test.jsindex 67c564ff..4f0e3815 100644--- a/test/api.test.js+++ b/test/api.test.js@@ -1,6 +1,8 @@/** The public, versioned JSON surface of every pullboard command (A1). */import assert from 'node:assert/strict';import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { performance } from 'node:perf_hooks';+import { reportFixtureChildFailure, runFixtureChild, runFixtureGit } from './fixture-child.js';import {chmodSync,existsSync,@@ -67,8 +69,8 @@ function sandbox() {PULLBOARD_HOME: join(dir, 'home'),};for (const marker of SSH_SHELL_MARKERS) delete env[marker];- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();- const run = (cwd, ...args) => spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env, encoding: 'utf8', stdio: 'pipe' });+ const run = (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });return { dir, env, git, run };}@@ -501,7 +503,9 @@ test('[A1] long-running servers flush one JSON document before shutdown', asyncfor (const command of ['view', 'serve']) {const box = project();t.after(() => rmSync(box.dir, { recursive: true, force: true }));- const child = spawn(process.execPath, [BIN, command, ...(command === 'view' ? ['--no-open'] : []), '--port', '0', '--json'], { cwd: box.repo, env: box.env, stdio: ['ignore', 'pipe', 'pipe'] });+ const args = [BIN, command, ...(command === 'view' ? ['--no-open'] : []), '--port', '0', '--json'];+ const startedAt = performance.now();+ const child = spawn(process.execPath, args, { cwd: box.repo, env: box.env, stdio: ['ignore', 'pipe', 'pipe'] });let stdout = '';let stderr = '';child.stdout.setEncoding('utf8');@@ -513,10 +517,20 @@ test('[A1] long-running servers flush one JSON document before shutdown', asyncif (child.exitCode === null) child.kill('SIGTERM');});const ready = new Promise((resolveReady, rejectReady) => {- const timeout = setTimeout(() => rejectReady(new Error('view did not flush its JSON result')), 10_000);+ let settled = false;+ const failStartup = (detail, status = child.exitCode, signal = child.signalCode) => {+ if (settled) return;+ settled = true;+ clearTimeout(timeout);+ rejectReady(new Error(reportFixtureChildFailure({ command: process.execPath, args, status, signal,+ elapsedMs: performance.now() - startedAt, stderr, env: box.env, detail })));+ };+ const timeout = setTimeout(() => failStartup('server readiness deadline (10000ms) expired'), 10_000);child.stdout.on('data', () => {try {const document = JSON.parse(stdout);+ if (settled) return;+ settled = true;clearTimeout(timeout);resolveReady(document);} catch {@@ -524,9 +538,9 @@ test('[A1] long-running servers flush one JSON document before shutdown', async}});child.once('error', (error) => {- clearTimeout(timeout);- rejectReady(error);+ failStartup(error.message, null, null);});+ child.once('close', (code, signal) => failStartup('server exited before flushing its JSON result', code, signal));});const document = await ready;assert.equal(document.version, 1);@@ -593,7 +607,7 @@ test('[A1] every catalog command and subcommand has a real CLI exercise', () =>json(source, source.repo, 'spec', ['decline', 'G1', '--reason', 'Catalog decline'], 'decline');json(source, source.repo, 'spec', ['apply'], 'apply');/** Exercise the agent-only takeover with a private explicit session, leaving later terminal calls markerless. */- const sessionSource = { ...source, run: (cwd, ...args) => spawnSync(process.execPath, [BIN, ...args], { cwd, env: { ...source.env, CODEX_SESSION_ID: 'api-catalog-session' }, encoding: 'utf8' }) };+ const sessionSource = { ...source, run: (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env: { ...source.env, CODEX_SESSION_ID: 'api-catalog-session' }, encoding: 'utf8' }) };json(sessionSource, source.repo, 'takeover');const missing = Object.keys(JSON_SHAPES.commands).filter((key) => !covered.has(key));assert.deepEqual(missing, [], `add real-repo invocations for undocumented coverage gaps: ${missing.join(', ')}`);@@ -653,7 +667,9 @@ test('[N26,A2] roadmap text, JSON and API state follow live local and registered/** Start the real local API server and stop it when its test finishes. */async function startApi(t, box) {- const child = spawn(process.execPath, [BIN, 'serve', '--port', '0', '--json'], { cwd: box.repo, env: box.env, stdio: ['ignore', 'pipe', 'pipe'] });+ const args = [BIN, 'serve', '--port', '0', '--json'];+ const startedAt = performance.now();+ const child = spawn(process.execPath, args, { cwd: box.repo, env: box.env, stdio: ['ignore', 'pipe', 'pipe'] });let stdout = '';let stderr = '';child.stdout.setEncoding('utf8');@@ -670,10 +686,20 @@ async function startApi(t, box) {}});const document = await new Promise((resolveReady, rejectReady) => {- const timeout = setTimeout(() => rejectReady(new Error(`serve did not flush its JSON result: ${stderr}`)), 10_000);+ let settled = false;+ const failStartup = (detail, status = child.exitCode, signal = child.signalCode) => {+ if (settled) return;+ settled = true;+ clearTimeout(timeout);+ rejectReady(new Error(reportFixtureChildFailure({ command: process.execPath, args, status, signal,+ elapsedMs: performance.now() - startedAt, stderr, env: box.env, detail })));+ };+ const timeout = setTimeout(() => failStartup('serve readiness deadline (10000ms) expired'), 10_000);const check = () => {try {const parsed = JSON.parse(stdout);+ if (settled) return;+ settled = true;clearTimeout(timeout);resolveReady(parsed);} catch {@@ -681,7 +707,8 @@ async function startApi(t, box) {}};child.stdout.on('data', check);- child.once('error', (error) => { clearTimeout(timeout); rejectReady(error); });+ child.once('error', (error) => failStartup(error.message, null, null));+ child.once('close', (code, signal) => failStartup('serve exited before readiness', code, signal));child.once('close', (code) => {if (code !== 0) { clearTimeout(timeout); rejectReady(new Error(`serve exited ${code}: ${stderr}`)); }});diff --git a/test/approved-row-changes.test.js b/test/approved-row-changes.test.jsindex e4e19fb2..c2e9ee1c 100644--- a/test/approved-row-changes.test.js+++ b/test/approved-row-changes.test.js@@ -1,6 +1,7 @@/** Approved-row edits need an exact person decision or staged SSH receipt [S19,V3]. */import assert from 'node:assert/strict';import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { fixtureChildMessage, runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, rmdirSync, statSync, writeFileSync } from 'node:fs';import { once } from 'node:events';import { tmpdir } from 'node:os';@@ -78,11 +79,11 @@ function fixture(t, { signer = false, doctrine = false } = {}) {};/** Run Git while preserving this fixture's local identity and the hook's active index. */function git(...args) {- return execFileSync('git', args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ return runFixtureGit(args, { cwd: root, env });}/** Run Pullboard in the fixture repo and retain both output streams for assertions. */function pullboard(...args) {- return spawnSync(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8', timeout: 20_000 });+ return runFixtureChild(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });}git('init', '-q', '-b', 'main');git('config', 'user.name', 'Approved-row fixture');@@ -98,11 +99,12 @@ function fixture(t, { signer = false, doctrine = false } = {}) {mkdirSync(join(root, 'test'));writeFileSync(join(root, 'test', 'promise.test.js'), "import assert from 'node:assert/strict';\nimport { readFileSync } from 'node:fs';\nimport { test } from 'node:test';\ntest('approved promise remains documented [G1]', () => { assert.match(readFileSync('SPEC.md', 'utf8'), /G1 \\[approved/); });\n");git('add', '-A');- const initial = spawnSync('git', ['commit', '-q', '-m', 'chore: initialize approved-row fixture'], { cwd: root, env, encoding: 'utf8', timeout: 20_000 });- assert.equal(initial.status, 0, `${initial.stdout}${initial.stderr}`);+ const initial = runFixtureChild('git', ['commit', '-q', '-m', 'chore: initialize approved-row fixture'], { cwd: root, env, encoding: 'utf8' });+ assert.equal(initial.status, 0, fixtureChildMessage(initial));if (signer) {const key = join(dir, 'co-signing-key');- execFileSync('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-C', '[email protected]', '-f', key], { stdio: 'pipe' });+ const generated = runFixtureChild('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-C', '[email protected]', '-f', key], { encoding: 'utf8' });+ assert.equal(generated.status, 0, fixtureChildMessage(generated));git('config', 'user.signingkey', key);const added = pullboard('spec', 'signers', 'add', '--key', `${key}.pub`, '--by', 'CO');assert.equal(added.status, 0, `${added.stdout}${added.stderr}`);@@ -178,7 +180,7 @@ function setRowText(box, id, text) {/** Attempt a real commit through the installed Pullboard pre-commit and commit-msg hooks. */function commit(box, subject = 'docs: update approved row') {- return spawnSync('git', ['commit', '-m', subject], { cwd: box.root, env: box.env, encoding: 'utf8', timeout: 30_000 });+ return runFixtureChild('git', ['commit', '-m', subject], { cwd: box.root, env: box.env, encoding: 'utf8' });}/** Stage SPEC.md and any explicitly named supporting receipt files. */diff --git a/test/board.test.js b/test/board.test.jsindex 4e48a17f..a4cc9f6e 100644--- a/test/board.test.js+++ b/test/board.test.js@@ -4,6 +4,7 @@*/import assert from 'node:assert/strict';import { execFileSync } from 'node:child_process';+import { runFixtureGit } from './fixture-child.js';import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';@@ -825,7 +826,7 @@ test('[O3] declared families travel from join through submit and verdict, and abGIT_COMMITTER_EMAIL: '[email protected]',};/** Run Git with isolated identity and configuration in the fixture repository. */- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env, encoding: 'utf8', stdio: 'pipe' });git(repo, 'init', '-q', '-b', 'main');writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({gate: 'true',diff --git a/test/check-baseline-delivery.test.js b/test/check-baseline-delivery.test.jsindex 3b68ca7b..c5763f9a 100644--- a/test/check-baseline-delivery.test.js+++ b/test/check-baseline-delivery.test.js@@ -1,6 +1,7 @@/** Durable check observations retry delivery without running their shell again [V2,H16]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -50,11 +51,11 @@ function sandbox() {});/** Run Git with only this private fixture's configuration and identity. */function git(cwd, ...args) {- return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ return runFixtureGit(args, { cwd, env });}- /** Run the real CLI in a private process with a bounded timeout. */+ /** Run the real CLI in a child whose lifetime is bounded by the test runner. */function run(cwd, args) {- return spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 20_000 });+ return runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });}return { dir, env, git, run };}@@ -112,7 +113,7 @@ function completionCount(board, id) {/** Run the actual worker function in a clean child process using the fixture environment. */function runWorker(box, id, request) {const source = `import { runCheckBaselineWorker } from ${JSON.stringify(WORKER_MODULE)};\nawait runCheckBaselineWorker(process.cwd(), Number(process.argv[1]), process.argv[2]);`;- return spawnSync(process.execPath, ['--input-type=module', '-e', source, String(id), request], {+ return runFixtureChild(process.execPath, ['--input-type=module', '-e', source, String(id), request], {cwd: box.repo, env: box.env, encoding: 'utf8', timeout: 45_000,});}diff --git a/test/check-baseline.test.js b/test/check-baseline.test.jsindex 9a628870..53d792b6 100644--- a/test/check-baseline.test.js+++ b/test/check-baseline.test.js@@ -1,6 +1,7 @@/** Check baselines run against main and travel with deterministic board moves [V2,H3,H16,N23]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -51,12 +52,12 @@ function sandbox() {});/** Run Git with only this fixture's config and identity. */function git(cwd, ...args) {- return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ return runFixtureGit(args, { cwd, env });}/** Run a real pullboard CLI process with optional stdin. */function run(cwd, args, input, options = {}) {- return spawnSync(process.execPath, [BIN, ...args], {- cwd, env, encoding: 'utf8', timeout: 20_000,+ return runFixtureChild(process.execPath, [BIN, ...args], {+ cwd, env, encoding: 'utf8',...(input === undefined ? {} : { input }), ...options,});}@@ -164,7 +165,7 @@ test('[V2,H16] add and edit return while isolated background checks are held, thwriteFileSync(addition.release, 'release');writeFileSync(edit.release, 'release');});- const added = box.run(box.repo, ['add', 'web', 'Background check', '--check', addition.command, '--json'], undefined, { timeout: 45_000 });+ const added = box.run(box.repo, ['add', 'web', 'Background check', '--check', addition.command, '--json']);assert.equal(added.status, 0, `${added.stdout}${added.stderr}`);assert.equal(existsSync(addition.finished), false, 'add returns before its baseline finishes');const item = JSON.parse(added.stdout).item;@@ -178,7 +179,7 @@ test('[V2,H16] add and edit return while isolated background checks are held, thawait waitForState(() => withBoard(join(box.repo, BOARD_FILE), (board) => getItem(board, item.item_id).item_check_baseline?.result === 'green'), 'the background add result is recorded');assert.equal(existsSync(observed.cwd), false, 'the isolated checkout is removed after its check');assert.match(box.run(box.repo, ['show', String(item.item_id)]).stdout, /CRITERION_PROVES_NOTHING/u);- const edited = box.run(box.repo, ['edit', String(item.item_id), '--check', edit.command, '--json'], undefined, { timeout: 45_000 });+ const edited = box.run(box.repo, ['edit', String(item.item_id), '--check', edit.command, '--json']);assert.equal(edited.status, 0, `${edited.stdout}${edited.stderr}`);assert.equal(existsSync(edit.finished), false, 'edit returns before its changed check finishes');assert.equal(JSON.parse(edited.stdout).item.item_check_baseline.result, 'pending');@@ -195,7 +196,7 @@ test('[V2,H16] --wait keeps the check blocking and the captured base survives aconst box = project({ content: 'original' });const held = heldCheck(box, 'wait-background');t.after(() => writeFileSync(held.release, 'release'));- const waited = box.run(box.repo, ['add', 'web', 'Wait for check', '--check', held.command, '--wait', '--json'], undefined, { timeout: 45_000 });+ const waited = box.run(box.repo, ['add', 'web', 'Wait for check', '--check', held.command, '--wait', '--json']);assert.equal(waited.status, 0, `${waited.stdout}${waited.stderr}`);assert.equal(existsSync(held.finished), true, '--wait returns only after the held check finishes');assert.equal(JSON.parse(waited.stdout).item.item_check_baseline.result, 'green');@@ -361,7 +362,7 @@ function applyInReplica(file, replicaDir, moveFile, env, at = '2026-10-07T12:00:'try { applyEngineMove(board, JSON.parse(readFileSync(process.argv[2], "utf8")), { sequence: Number(process.argv[3]), at: process.argv[4] }); }','finally { closeBoard(board); }',].join('\n');- return spawnSync(process.execPath, ['--input-type=module', '-e', source, file, moveFile, String(env.sequence), at], {+ return runFixtureChild(process.execPath, ['--input-type=module', '-e', source, file, moveFile, String(env.sequence), at], {cwd: replicaDir, env, encoding: 'utf8', timeout: 10_000,});}diff --git a/test/check.test.js b/test/check.test.jsindex b4675362..dc25a668 100644--- a/test/check.test.js+++ b/test/check.test.js@@ -1,6 +1,7 @@/** Coordinator-owned check commands and explicit caller consent [V2,N23]. */import assert from 'node:assert/strict';import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -45,10 +46,10 @@ function sandbox() {PULLBOARD_HOME: join(dir, 'pullboard-home'),};/** Run Git with private fixture identity and config. */- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env });/** Run the production CLI in a separate process, optionally with piped stdin. */- const run = (cwd, args, input) => spawnSync(process.execPath, [BIN, ...args], {- cwd, env, encoding: 'utf8', timeout: 10_000, ...(input === undefined ? {} : { input }),+ const run = (cwd, args, input) => runFixtureChild(process.execPath, [BIN, ...args], {+ cwd, env, encoding: 'utf8', ...(input === undefined ? {} : { input }),});return { dir, env, git, run };}diff --git a/test/cli-help.test.js b/test/cli-help.test.jsindex 975d66f5..a6f54c1c 100644--- a/test/cli-help.test.js+++ b/test/cli-help.test.js@@ -3,7 +3,7 @@ import assert from 'node:assert/strict';import { mkdtempSync, rmSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';-import { spawnSync } from 'node:child_process';+import { runFixtureChild } from './fixture-child.js';import { after, test } from 'node:test';import { HELP, resultCommands } from '../src/cli.js';@@ -18,7 +18,7 @@ after(() => {function run(...args) {const folder = mkdtempSync(join(tmpdir(), 'pullboard-help-'));sandboxes.push(folder);- return spawnSync(process.execPath, [BIN, ...args], { cwd: folder, encoding: 'utf8' });+ return runFixtureChild(process.execPath, [BIN, ...args], { cwd: folder, encoding: 'utf8' });}/** Read the flag rows between their heading and the example from one command's help. */@@ -33,7 +33,7 @@ test('bare help is a short first-run overview generated from its command groupsconst bare = run();const helpFlag = run('--help');const helpCommand = run('help');- assert.equal(bare.status, 0, bare.stderr);+ assert.equal(bare.status, 0, bare.failure ?? bare.stderr);assert.equal(bare.stdout, `${HELP.firstRun}\n`);assert.equal(helpFlag.stdout, bare.stdout);assert.equal(helpCommand.stdout, `${HELP.overview}\n`);diff --git a/test/coordinator-resume.test.js b/test/coordinator-resume.test.jsindex 3d3342bf..04b1fc57 100644--- a/test/coordinator-resume.test.js+++ b/test/coordinator-resume.test.js@@ -1,6 +1,7 @@/** Keep the coordinator's handoff brief short, ordered, and derived from real Git and board state [N19,B3]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { DatabaseSync } from 'node:sqlite';import { chmodSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';@@ -37,11 +38,11 @@ function fixture() {const repo = join(dir, 'repo');mkdirSync(repo);/** Run Git in this private fixture with its isolated identity. */- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env });/** Run the actual CLI in a fixture checkout and retain both output streams. */const run = (cwd, ...args) => {- const result = spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 90_000 });- return { code: result.status, out: result.stdout ?? '', err: result.stderr ?? '' };+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout ?? '', err: result.failure ?? result.stderr ?? '', failure: result.failure };};git(repo, 'init', '-q', '-b', 'main');assert.equal(run(repo, 'init').code, 0);@@ -73,7 +74,7 @@ function commit(git, cwd, message) {/** Ask real Git whether one fixture commit contains another. */function isAncestor(box, cwd, ancestor, commitId) {- return spawnSync('git', ['merge-base', '--is-ancestor', ancestor, commitId], { cwd, env: box.env }).status === 0;+ return runFixtureChild('git', ['merge-base', '--is-ancestor', ancestor, commitId], { cwd, env: box.env }).status === 0;}/** Add a separately joined strong builder so each item's accepted commit has an isolated branch. */diff --git a/test/doctor.test.js b/test/doctor.test.jsindex 13500d9a..1a3d8926 100644--- a/test/doctor.test.js+++ b/test/doctor.test.js@@ -1,6 +1,6 @@/** Integrity checks use throwaway git repositories and real board databases (A6). */import assert from 'node:assert/strict';-import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -35,8 +35,8 @@ function boardBox({ initialize = true, repoName = 'repo' } = {}) {GIT_COMMITTER_NAME: 'Doctor Test',GIT_COMMITTER_EMAIL: '[email protected]',});- const git = (...args) => execFileSync('git', args, { cwd: root, env, encoding: 'utf8' }).trim();- const run = (...args) => spawnSync(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });+ const git = (...args) => runFixtureGit(args, { cwd: root, env, encoding: 'utf8' });+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });git('init', '-q', '-b', 'main');const mergeHook = join(root, '.git', 'hooks', 'pre-merge-commit');mkdirSync(join(root, '.git', 'hooks'), { recursive: true });@@ -114,9 +114,10 @@ test('commands and doctor explain how to repair core.bare without crossing a nesconst nested = join(box.root, 'nested');mkdirSync(nested);- execFileSync('git', ['init', '-q', '-b', 'main'], { cwd: nested, env: box.env });+ const nestedGitInit = runFixtureChild('git', ['init', '-q', '-b', 'main'], { cwd: nested, env: box.env, encoding: 'utf8' });+ assert.equal(nestedGitInit.status, 0, nestedGitInit.failure);/** Run the private Pullboard CLI from the nested repo under the bare parent. */- const nestedRun = (...args) => spawnSync(process.execPath, [BIN, ...args], { cwd: nested, env: box.env, encoding: 'utf8' });+ const nestedRun = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: nested, env: box.env, encoding: 'utf8' });const nestedInit = nestedRun('init');assert.equal(nestedInit.status, 0, nestedInit.stderr);const nestedStatus = nestedRun('status');@@ -124,7 +125,8 @@ test('commands and doctor explain how to repair core.bare without crossing a nesconst nestedDoctor = nestedRun('doctor');assert.equal(nestedDoctor.status, 0, nestedDoctor.stderr);- execFileSync('sh', ['-c', repair], { cwd: root, env: box.env });+ const repaired = runFixtureChild('sh', ['-c', repair], { cwd: root, env: box.env, encoding: 'utf8' });+ assert.equal(repaired.status, 0, repaired.failure);assert.equal(box.run('status').status, 0);assert.equal(box.run('doctor').status, 0);});diff --git a/test/doctrine-name.test.js b/test/doctrine-name.test.jsindex 34ff16f4..5f4f32d3 100644--- a/test/doctrine-name.test.js+++ b/test/doctrine-name.test.js@@ -1,6 +1,7 @@/** Canonical doctrine naming keeps legacy repos and the stable state API readable [D1,D2,A5]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -51,11 +52,11 @@ function sandbox() {});/** Run Git with the fixture's isolated identity and configuration. */function git(cwd, ...args) {- return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ return runFixtureGit(args, { cwd, env });}/** Run one real CLI command and keep stdout, stderr and status available to assertions. */function run(cwd, ...args) {- return spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 20_000 });+ return runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });}return { dir, env, git, run };}@@ -140,7 +141,7 @@ test('[D1,D2,A5] legacy init keeps PRACTICE rules and doctor offers a working onconst untrackedRename = doctorProblems(box, repo.root).find((problem) => problem.code === 'DOCTRINE_LEGACY');assert.ok(untrackedRename);assert.equal(untrackedRename.next, `mv -- ${PRACTICE} ${DOCTRINE}`, 'an untracked legacy file needs a filesystem rename');- const moved = spawnSync('sh', ['-c', untrackedRename.next], { cwd: repo.root, env: box.env, encoding: 'utf8' });+ const moved = runFixtureChild('sh', ['-c', untrackedRename.next], { cwd: repo.root, env: box.env, encoding: 'utf8' });assert.equal(moved.status, 0, moved.stderr);assert.ok(specRows(box, repo.root).some((row) => row.id === 'L1' && row.file === DOCTRINE));renameSync(join(repo.root, DOCTRINE), join(repo.root, PRACTICE));@@ -345,7 +346,7 @@ test('[D4,A5] detached verifier clones use a recorded trunk or their checked comconst noTrunkCommit = box.git(withoutTrunk, 'rev-parse', 'HEAD');// Init and the installed commit hook both remember the attached trunk; remove it only after them.box.git(withoutTrunk, 'config', '--local', '--unset-all', 'pullboard.trunk');- assert.equal(spawnSync('git', ['config', '--local', '--get', 'pullboard.trunk'], {+ assert.equal(runFixtureChild('git', ['config', '--local', '--get', 'pullboard.trunk'], {cwd: withoutTrunk, env: box.env,}).status, 1, 'the source actually has no retained trunk');const attachedWithoutTrunk = box.run(withoutTrunk, 'spec', 'check');diff --git a/test/e2e-helpers.js b/test/e2e-helpers.jsindex 5e28d9e4..4e1eff32 100644--- a/test/e2e-helpers.js+++ b/test/e2e-helpers.js@@ -1,5 +1,7 @@import assert from 'node:assert/strict';-import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { spawn } from 'node:child_process';+import { performance } from 'node:perf_hooks';+import { reportFixtureChildFailure, runFixtureChild, runFixtureGit } from './fixture-child.js';import {chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync,rmSync, statSync, symlinkSync, writeFileSync,@@ -46,11 +48,11 @@ function sandbox() {};for (const marker of [...AGENT_SHELL_MARKERS, ...SSH_SHELL_MARKERS]) delete env[marker];delete env.PULLBOARD_RELAY_TOKEN;- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();- const tryGit = (cwd, ...args) => spawnSync('git', args, { cwd, env, encoding: 'utf8' });+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env });+ const tryGit = (cwd, ...args) => runFixtureChild('git', args, { cwd, env, encoding: 'utf8' });const run = (cwd, ...args) => {- const result = spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });- return { code: result.status, out: result.stdout, err: result.stderr };+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout, err: result.failure ?? result.stderr, failure: result.failure };};return { dir, env, git, tryGit, run };}@@ -112,12 +114,26 @@ function holdingGate(box) {/** Launch a CLI or Git process while preserving its output for the gate-lock assertion. */function launch(box, cwd, command, args) {+ const startedAt = performance.now();const child = spawn(command, args, { cwd, env: box.env, stdio: ['ignore', 'pipe', 'pipe'] });child.stdoutText = '';child.stderrText = '';child.stdout.setEncoding('utf8').on('data', (chunk) => { child.stdoutText += chunk; });child.stderr.setEncoding('utf8').on('data', (chunk) => { child.stderrText += chunk; });- child.closed = new Promise((resolveClose) => child.once('close', (code, signal) => resolveClose({ code, signal })));+ child.closed = new Promise((resolveClose) => {+ let reported = false;+ const reportFailure = (code, signal, extra = '') => {+ if (reported) return;+ reported = true;+ child.failure = reportFixtureChildFailure({ command, args, status: code, signal,+ elapsedMs: performance.now() - startedAt, stderr: child.stderrText, env: box.env, detail: extra });+ };+ child.once('error', (error) => reportFailure(null, null, error.message));+ child.once('close', (code, signal) => {+ if (code !== 0 || signal) reportFailure(code, signal);+ resolveClose({ code, signal, failure: child.failure ?? null });+ });+ });return child;}@@ -150,15 +166,27 @@ function commitFile(box, cwd, path, text, message) {const LIGHT_BRIEF = 'Files:\n- web/page.js\nChange:\n- copy the header from the api\nTest:\n- the page test asserts the header\nOut of scope: anything else\n';async function startView(box, cwd) {+ const startedAt = performance.now();const child = spawn(process.execPath, [BIN, 'view', '--no-open'], { cwd, env: box.env });const link = await new Promise((found, fail) => {let out = '';+ let stderr = '';+ let settled = false;+ const rejectStartup = (code, signal, extra = '') => {+ if (settled) return;+ settled = true;+ const failure = reportFixtureChildFailure({ command: process.execPath, args: [BIN, 'view', '--no-open'],+ status: code, signal, elapsedMs: performance.now() - startedAt, stderr, env: box.env, detail: extra });+ fail(new Error(failure));+ };child.stdout.on('data', (chunk) => {out += chunk;const match = /Pullboard view: (http:\/\/127\.0\.0\.1:\d+\/\?k=\S+)/.exec(out);- if (match) found(new URL(match[1]));+ if (match && !settled) { settled = true; found(new URL(match[1])); }});- child.on('exit', (code) => fail(new Error(`view exited ${code}: ${out}`)));+ child.stderr.on('data', (chunk) => { stderr += chunk; });+ child.once('error', (error) => rejectStartup(null, null, error.message));+ child.once('exit', (code, signal) => rejectStartup(code, signal));});const key = link.searchParams.get('k');const base = `http://127.0.0.1:${link.port}`;diff --git a/test/e2e-items.test.js b/test/e2e-items.test.jsindex 7da6aa64..acf7eedb 100644--- a/test/e2e-items.test.js+++ b/test/e2e-items.test.js@@ -4,6 +4,7 @@*/import assert from 'node:assert/strict';import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { runFixtureChild } from './fixture-child.js';import {chmodSync,existsSync,@@ -358,7 +359,7 @@ function foreignGitScript(box, name, { fixer = false } = {}) {`const ordinary = ${JSON.stringify(ordinary)}; const bare = ${JSON.stringify(bare)};`,"fs.mkdirSync(ordinary); fs.mkdirSync(bare);","let failed = false;",- "const run = (cwd, args) => { const r = cp.spawnSync('git', args, { cwd, encoding: 'utf8', timeout: 10000 }); if (r.status !== 0) { failed = true; console.error(r.stderr); } };",+ "const run = (cwd, args) => { const started = Date.now(); const r = cp.spawnSync('git', args, { cwd, encoding: 'utf8' }); if (r.status !== 0) { failed = true; console.error(JSON.stringify({command: ['git', ...args], status: r.status, signal: r.signal, elapsed: Date.now() - started, stderr: r.stderr})); } };","run(ordinary, ['init', '-q', '-b', 'main']);","fs.writeFileSync(ordinary + '/probe.txt', 'its own repository\\n');","run(ordinary, ['add', 'probe.txt']); run(ordinary, ['commit', '-q', '-m', 'chore: foreign probe']);",diff --git a/test/evidence.test.js b/test/evidence.test.jsindex c2f13e6f..2667c468 100644--- a/test/evidence.test.js+++ b/test/evidence.test.js@@ -1,6 +1,6 @@/** Row evidence and stage precedence (S15, S16). */import assert from 'node:assert/strict';-import { execFileSync } from 'node:child_process';+import { runFixtureChild } from './fixture-child.js';import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';@@ -19,7 +19,8 @@ function trackedFile(root, path, text) {const file = join(root, path);mkdirSync(join(file, '..'), { recursive: true });writeFileSync(file, text);- execFileSync('git', ['-C', root, 'add', '--', path]);+ const staged = runFixtureChild('git', ['-C', root, 'add', '--', path], { encoding: 'utf8' });+ assert.equal(staged.status, 0, staged.failure);}test('evidence uses exact citations in tracked visible tests and stage precedence follows sign-offs [S15, S16]', () => {@@ -29,7 +30,8 @@ test('evidence uses exact citations in tracked visible tests and stage precedencconst root = join(sandbox, 'repo');try {mkdirSync(root);- execFileSync('git', ['init', '--quiet', root]);+ const initialized = runFixtureChild('git', ['init', '--quiet', root], { encoding: 'utf8' });+ assert.equal(initialized.status, 0, initialized.failure);trackedFile(root, 'test/primary.test.js', '// proves [S15] and [S16]; not [S150]\n');trackedFile(root, 'tests/support.js', '/* shared [S15, S150] */\n');trackedFile(root, 'src/target.spec.md', 'S15 [S15]\n');diff --git a/test/exchange.test.js b/test/exchange.test.jsindex e7320f71..0fe7d0af 100644--- a/test/exchange.test.js+++ b/test/exchange.test.js@@ -3,7 +3,7 @@*/import assert from 'node:assert/strict';import { mkdtempSync, mkdirSync, rmSync, writeFileSync } from 'node:fs';-import { spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { test } from 'node:test';@@ -61,8 +61,7 @@ const tempDirectory = () => mkdtempSync(join(tmpdir(), 'pullboard-exchange-'));*/function gitRepo(root) {mkdirSync(root);- const result = spawnSync('git', ['init', '-q'], { cwd: root, encoding: 'utf8' });- assert.equal(result.status, 0, result.stderr);+ runFixtureGit(['init', '-q'], { cwd: root, encoding: 'utf8' });writeFileSync(join(root, 'pullboard.json'), JSON.stringify({ lanes: {} }));}@@ -228,7 +227,7 @@ test('export and import CLI commands exchange a versioned document between realGIT_COMMITTER_EMAIL: '[email protected]',PULLBOARD_HOME: join(directory, 'home'),};- const cli = (cwd, ...args) => spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ const cli = (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });try {const initialized = cli(targetRoot, 'init');assert.equal(initialized.status, 0, initialized.stderr || initialized.stdout);diff --git a/test/fixture-child.js b/test/fixture-child.jsnew file mode 100644index 00000000..b6ba4e51--- /dev/null+++ b/test/fixture-child.js@@ -0,0 +1,124 @@+/** Shared private fixture child runner and redacted failure diagnostics [C7]. */+import { spawn, spawnSync } from 'node:child_process';+import { performance } from 'node:perf_hooks';++const SENSITIVE_NAME = /(?:token|secret|password|private.?key|access.?key|relay[_ -]?key|pairing.?code|verification.?code)/iu;+const activeFixtureChildren = new Set();++/** Redact known fixture credentials before a child failure reaches an assertion message. */+export function safeFixtureDiagnostic(value, env = process.env) {+ let text = String(value ?? '');+ for (const [name, secret] of Object.entries(env ?? {})) {+ if (SENSITIVE_NAME.test(name) && typeof secret === 'string' && secret.length >= 4) {+ text = text.replaceAll(secret, '[redacted]');+ }+ }+ return text+ .replace(/\b(?:ps|pa)_[A-Za-z0-9_-]+\b/gu, '[redacted-token]')+ .replace(/\b[a-f\d]{32}\.[A-Za-z0-9_-]{22}\.[A-Za-z0-9_-]{43}\b/giu, '[redacted-pairing-code]')+ .replace(/((?:token|secret|password|private[_ -]?key|access[_ -]?key|relay[_ -]?key|pairing[_ -]?code|verification[_ -]?code)\s*[:=]\s*)[^\s,;]+/giu, '$1[redacted]')+ .replace(/(authorization\s*:\s*bearer\s+)[^\s,;]+/giu, '$1[redacted]');+}++/** Format one failed fixture child without leaking fixture credentials. */+export function fixtureChildFailureContext({ command, args = [], status, signal, elapsedMs, stderr = '', env = process.env, detail = '' }) {+ return [+ `command: ${safeFixtureDiagnostic(JSON.stringify([command, ...args]), env)}`,+ `status: ${status === null ? 'null' : status}`,+ `signal: ${signal ?? 'none'}`,+ `elapsed: ${Math.round(elapsedMs)}ms`,+ `stderr: ${safeFixtureDiagnostic(stderr, env)}`,+ ...(detail ? [`detail: ${safeFixtureDiagnostic(detail, env)}`] : []),+ ].join('\n');+}++/** Emit and return the common diagnostic for any unexpected fixture child result. */+export function reportFixtureChildFailure(options) {+ const context = fixtureChildFailureContext(options);+ process.stderr.write(`${context}\n`);+ return context;+}++/** Run one fixture child and retain enough context to explain any failed result. */+export function runFixtureChild(command, args = [], options = {}) {+ if (!Array.isArray(args)) { options = args; args = []; }+ const started = performance.now();+ const result = spawnSync(command, args, options);+ const elapsedMs = Math.round(performance.now() - started);+ const env = options.env ?? process.env;+ const stderr = safeFixtureDiagnostic(Buffer.isBuffer(result.stderr) ? result.stderr.toString('utf8') : (result.stderr ?? ''), env);+ const safeCommand = safeFixtureDiagnostic(JSON.stringify([command, ...args]), env);+ const context = [+ `command: ${safeCommand}`,+ `status: ${result.status === null ? 'null' : result.status}`,+ `signal: ${result.signal ?? 'none'}`,+ `elapsed: ${elapsedMs}ms`,+ `stderr: ${stderr}`,+ ].join('\n');+ const failure = result.status === 0 && !result.signal && !result.error ? null : reportFixtureChildFailure({+ command, args, status: result.status, signal: result.signal, elapsedMs, stderr, env,+ detail: result.error?.message ?? '',+ });+ return { ...result, command: [command, ...args], elapsedMs, context, failure };+}++/** Run an async fixture child, retaining redacted diagnostics without imposing a child clock. */+export function runFixtureChildAsync(command, args, options = {}) {+ const { onStderrChunk, ...spawnOptions } = options;+ const started = performance.now();+ const child = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'], ...spawnOptions });+ activeFixtureChildren.add(child);+ let stdout = '';+ let rawStderr = '';+ return new Promise((resolveResult) => {+ child.stdout.setEncoding('utf8').on('data', (part) => { stdout += part; });+ child.stderr.setEncoding('utf8').on('data', (part) => {+ rawStderr += part;+ onStderrChunk?.(part, child);+ });+ let spawnError = null;+ child.once('error', (error) => { spawnError = error; });+ child.once('close', (status, signal) => {+ activeFixtureChildren.delete(child);+ const elapsedMs = Math.round(performance.now() - started);+ const env = spawnOptions.env ?? process.env;+ const stderr = safeFixtureDiagnostic(rawStderr, env);+ const safeCommand = safeFixtureDiagnostic(JSON.stringify([command, ...args]), env);+ const context = [+ `command: ${safeCommand}`,+ `status: ${status === null ? 'null' : status}`,+ `signal: ${signal ?? 'none'}`,+ `elapsed: ${elapsedMs}ms`,+ `stderr: ${stderr}`,+ ...(spawnError ? [`spawn error: ${safeFixtureDiagnostic(spawnError.message, env)}`] : []),+ ].join('\n');+ const failure = status === 0 && !signal && !spawnError ? null : reportFixtureChildFailure({+ command, args, status, signal, elapsedMs, stderr, env,+ detail: spawnError?.message ?? '',+ });+ resolveResult({ status, signal, stdout, stderr, elapsedMs, context, failure, error: spawnError });+ });+ });+}++/** Stop only fixture children still alive when their owning test file has finished. */+export async function cleanupFixtureChildren() {+ const children = [...activeFixtureChildren];+ for (const child of children) child.kill('SIGKILL');+ await Promise.all(children.map((child) => new Promise((resolveClosed) => {+ if (child.exitCode !== null || child.signalCode !== null) return resolveClosed();+ child.once('close', resolveClosed);+ })));+}++/** Prefer the structured child context in a failed assertion while keeping raw stderr untouched. */+export function fixtureChildMessage(result) {+ return result.failure ?? result.stderr ?? '';+}++/** Run a successful Git fixture operation and include elapsed command context if it fails. */+export function runFixtureGit(args, options = {}) {+ const result = runFixtureChild('git', args, { encoding: 'utf8', ...options });+ if (result.status !== 0) throw new Error(result.failure);+ return result.stdout.trim();+}diff --git a/test/fixture-child.test.js b/test/fixture-child.test.jsnew file mode 100644index 00000000..dc08b64e--- /dev/null+++ b/test/fixture-child.test.js@@ -0,0 +1,66 @@+/** Verify fixture child failures remain actionable without leaking credentials [C7]. */+import assert from 'node:assert/strict';+import { performance } from 'node:perf_hooks';+import { after, test } from 'node:test';+import { cleanupFixtureChildren, runFixtureChild, runFixtureChildAsync } from './fixture-child.js';++after(cleanupFixtureChildren);++/** Prove failed fixture children explain outcomes while redacting fixture credentials. */+test('a fixture child killed or failed names its command, signal and stderr [C7]', { timeout: 10_000 }, async () => {+ const failed = runFixtureChild(process.execPath, ['-e', "process.stderr.write('fixture stderr\\n'); process.exit(7)"], {+ encoding: 'utf8',+ });+ assert.equal(failed.status, 7, failed.failure);+ assert.match(failed.failure, /command: .*node/u);+ assert.match(failed.failure, /status: 7/u);+ assert.match(failed.failure, /elapsed: \d+ms/u);+ assert.match(failed.failure, /stderr: fixture stderr/u);++ let requestedSignal = false;+ const startedAt = performance.now();+ let readyAt = 0;+ let terminateTimer;+ const killed = await runFixtureChildAsync(process.execPath, ['-e', "console.error('sleeping child'); setInterval(() => {}, 1000)"], {+ onStderrChunk(part, child) {+ if (!readyAt && part.includes('sleeping child')) {+ readyAt = performance.now();+ terminateTimer = setTimeout(() => {+ requestedSignal = child.kill('SIGTERM');+ }, 80);+ }+ },+ });+ clearTimeout(terminateTimer);+ assert.equal(requestedSignal, true, killed.failure);+ assert.equal(killed.status, null, killed.failure);+ assert.equal(killed.signal, 'SIGTERM', killed.failure);+ assert.match(killed.failure, /command: .*setInterval/u);+ assert.match(killed.failure, /signal: SIGTERM/u);+ const elapsed = /elapsed: (\d+)ms/u.exec(killed.failure);+ assert.ok(Number(elapsed?.[1]) - (readyAt - startedAt) >= 80, killed.failure);+ assert.match(killed.failure, /stderr: sleeping child/u);++ const pairingCode = '0123456789abcdef0123456789abcdef.ABCDEFGHIJKLMNOPQRSTUV.abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQ';+ const credentialFailure = runFixtureChild(process.execPath, ['-e', `console.error('token ps_fixtureSecret_98765 pairing-code pa_fixtureCode_12345 relay-key relay-fixture-secret-abcdef ${pairingCode}'); process.exit(2)`], {+ encoding: 'utf8', env: { ...process.env, PULLBOARD_RELAY_KEY: 'relay-fixture-secret-abcdef' },+ });+ assert.equal(credentialFailure.status, 2, credentialFailure.failure);+ assert.match(credentialFailure.failure, /stderr: token \[redacted-token\] pairing-code \[redacted-token\] relay-key \[redacted\] \[redacted-pairing-code\]/u);+ assert.doesNotMatch(credentialFailure.failure, /ps_fixtureSecret_98765|pa_fixtureCode_12345|relay-fixture-secret-abcdef|0123456789abcdef/u);+});++/** Verify an ignored failure object still leaves structured diagnostics at the helper boundary. */+test('fixture child helpers emit structured failure diagnostics [C7]', () => {+ const helperUrl = new URL('./fixture-child.js', import.meta.url).href;+ const nested = `import(${JSON.stringify(helperUrl)}).then(async ({runFixtureChild,runFixtureChildAsync}) => { runFixtureChild(process.execPath, ['-e', "console.error('nested sync stderr'); process.exit(9)"], {encoding:'utf8'}); await runFixtureChildAsync(process.execPath, ['-e', "console.error('nested async stderr'); process.exit(8)"]); });`;+ const observed = runFixtureChild(process.execPath, ['--input-type=module', '-e', nested], { encoding: 'utf8' });+ assert.equal(observed.status, 0, observed.failure);+ assert.match(observed.stderr, /command: .*node/u);+ assert.match(observed.stderr, /status: 9/u);+ assert.match(observed.stderr, /status: 8/u);+ assert.match(observed.stderr, /signal: none/u);+ assert.match(observed.stderr, /elapsed: \d+ms/u);+ assert.match(observed.stderr, /stderr: nested sync stderr/u);+ assert.match(observed.stderr, /stderr: nested async stderr/u);+});diff --git a/test/gate-resource.test.js b/test/gate-resource.test.jsindex cc339a24..1ee2f5f5 100644--- a/test/gate-resource.test.js+++ b/test/gate-resource.test.js@@ -1,6 +1,7 @@/** Real gates and item checks share the machine queue; landing priority and lease behavior stay intact [Q1,Q2,Q4,O5,O6,V18]. */import assert from 'node:assert/strict';import { spawn, spawnSync } from 'node:child_process';+import { runFixtureChild } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -35,7 +36,7 @@ function fixture() {function gateRepo(box, name, delay = 0.25, releaseFile = null) {const root = join(box.dir, name);mkdirSync(root);- const git = (...args) => spawnSync('git', args, { cwd: root, env: box.env, encoding: 'utf8' });+ const git = (...args) => runFixtureChild('git', args, { cwd: root, env: box.env, encoding: 'utf8' });assert.equal(git('init', '-q', '-b', 'main').status, 0);const wait = releaseFile ? `while [ ! -e ${quote(releaseFile)} ]; do sleep 0.02; done` : `sleep ${delay}`;const command = `printf '${name} start\\n' >> ${quote(box.events)}; ${wait}; printf '${name} end\\n' >> ${quote(box.events)}`;@@ -166,7 +167,7 @@ test('[Q4] an exact-tree cached gate starts while another machine gate holds theassert.equal(refusedChange.status, 1);assert.equal(JSON.parse(refusedChange.stdout).error.code, 'RESOURCE_BUSY');assert.equal(JSON.parse(readFileSync(join(box.env.PULLBOARD_HOME, 'settings.json'), 'utf8')).gateSlots, 1);- const cached = spawnSync(process.execPath, [BIN, 'gate'], { cwd: cachedRoot, env: box.env, encoding: 'utf8', timeout: 30_000 });+ const cached = runFixtureChild(process.execPath, [BIN, 'gate'], { cwd: cachedRoot, env: box.env, encoding: 'utf8' });assert.equal(cached.status, 0, cached.stderr);assert.match(cached.stdout, /already passed/);assert.ok(events(box).includes('holder start') && !events(box).includes('holder end'), 'cached gate returned while the other machine gate still held its slot');diff --git a/test/gate.test.js b/test/gate.test.jsindex 95c568df..c48844ea 100644--- a/test/gate.test.js+++ b/test/gate.test.js@@ -4,6 +4,7 @@*/import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -40,8 +41,8 @@ function repoWithGate(gate, check = '') {GIT_COMMITTER_EMAIL: '[email protected]',PULLBOARD_HOME: join(dir, 'home'),};- const git = (...args) => execFileSync('git', args, { cwd: repo, env, encoding: 'utf8', stdio: 'pipe' }).trim();- const run = (...args) => spawnSync(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8', timeout: 60_000 });+ const git = (...args) => runFixtureGit(args, { cwd: repo, env });+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });git('init', '-q', '-b', 'main');writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({ gate: `echo run >> ../runs.log; ${gate}` }));writeFileSync(join(repo, 'SPEC.md'), '# Demo\n\n## G · Goals\n- G1 [approved, must] It works. | gate: test\n');@@ -154,7 +155,7 @@ function shellWord(value) {function privateCheck(box, command) {const logPath = join(box.dir, 'private-command.log');const pidFile = logPath + '.pid';- const run = spawnSync(process.execPath, [PRIVATE_WORKER], {+ const run = runFixtureChild(process.execPath, [PRIVATE_WORKER], {cwd: box.repo, env: box.env, encoding: 'utf8',input: JSON.stringify({ command, timeout: 30_000, pidFile, logPath }), timeout: 35_000,});@@ -164,7 +165,7 @@ function privateCheck(box, command) {}test('a piped gate fails on any red stage without changing its existing shell [V16,C7]', () => {- const supported = spawnSync('set -o pipefail', { shell: true }).status === 0;+ const supported = runFixtureChild('set -o pipefail', { shell: true }).status === 0;const failing = repoWithGate('sh -c "exit 7" | tail -1');const red = failing.run('gate', '--json');assert.equal(red.status, 1, 'a failing producer cannot leave the gate green');diff --git a/test/git-calls.test.js b/test/git-calls.test.jsindex 109f7405..04343770 100644--- a/test/git-calls.test.js+++ b/test/git-calls.test.js@@ -1,6 +1,7 @@/** Count real Git child processes and prove command-scoped facts refresh after a commit [C7]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { delimiter, join, resolve } from 'node:path';import { tmpdir } from 'node:os';@@ -63,8 +64,12 @@ function fixture(t) {lanes: { core: { owns: ['src/'], specs: ['C7'] } },}));writeFileSync(join(repo, 'SPEC.md'), '# Test spec\n\n## C · Core\n- C7 [approved, must] A command reads each Git fact once. | gate: test/git-calls.test.js\n');- const git = (cwd, ...args) => execFileSync(realGit, args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();- const run = (cwd, ...args) => spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 60_000 });+ const git = (cwd, ...args) => {+ const result = runFixtureChild(realGit, args, { cwd, env, encoding: 'utf8', stdio: 'pipe' });+ if (result.status !== 0) throw new Error(result.failure);+ return result.stdout.trim();+ };+ const run = (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });const ok = (cwd, ...args) => {const result = run(cwd, ...args);assert.equal(result.status, 0, `${result.stdout}${result.stderr}`);@@ -180,7 +185,7 @@ const item = JSON.parse(process.env.PULLBOARD_TEST_ITEM);const result = await withGitFacts(() => commitWork(root, item, loadConfig(root), ['src/runner-result.txt']));console.log(JSON.stringify(result));`;const env = { ...box.env, PULLBOARD_TEST_ITEM: JSON.stringify(item) };- const result = spawnSync(process.execPath, ['--input-type=module', '-e', script], { cwd: box.worker, env, encoding: 'utf8' });+ const result = runFixtureChild(process.execPath, ['--input-type=module', '-e', script], { cwd: box.worker, env, encoding: 'utf8' });assert.equal(result.status, 0, `${result.stdout}${result.stderr}`);const committed = JSON.parse(result.stdout.trim());assert.equal(committed.ok, true, committed.output);diff --git a/test/hooks.test.js b/test/hooks.test.jsindex d8b24cb8..d47af4e0 100644--- a/test/hooks.test.js+++ b/test/hooks.test.js@@ -3,6 +3,7 @@*/import assert from 'node:assert/strict';import { execFileSync } from 'node:child_process';+import { runFixtureGit } from './fixture-child.js';import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';@@ -21,7 +22,7 @@ function stagedRepo(t) {const env = { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' };t.after(() => rmSync(root, { recursive: true, force: true }));/** Run Git only in this fixture, without the maintainer's identity or configuration. */- const git = (...args) => execFileSync('git', args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (...args) => runFixtureGit(args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' });git('init', '-q', '-b', 'main');return { root, git };}diff --git a/test/http-fixture.test.js b/test/http-fixture.test.jsindex cccf3c49..c3e3641d 100644--- a/test/http-fixture.test.js+++ b/test/http-fixture.test.js@@ -1,6 +1,8 @@/** Fixture requests reach a live server even after the test blocked its own event loop past keep-alive [C7]. */import assert from 'node:assert/strict';-import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { spawn } from 'node:child_process';+import { performance } from 'node:perf_hooks';+import { reportFixtureChildFailure, runFixtureChild, runFixtureGit } from './fixture-child.js';import { once } from 'node:events';import { mkdirSync, mkdtempSync, realpathSync, rmSync } from 'node:fs';import { createServer } from 'node:http';@@ -29,15 +31,17 @@ function privateBoard(t) {mkdirSync(root);mkdirSync(home);const env = { ...process.env, HOME: home, PULLBOARD_HOME: home, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' };- execFileSync('git', ['init', '-q', '-b', 'main'], { cwd: root, env });- const init = spawnSync(process.execPath, [BIN, 'init', '--json'], { cwd: root, env, encoding: 'utf8' });- assert.equal(init.status, 0, `${init.stdout}${init.stderr}`);+ runFixtureGit(['init', '-q', '-b', 'main'], { cwd: root, env });+ const init = runFixtureChild(process.execPath, [BIN, 'init', '--json'], { cwd: root, env, encoding: 'utf8' });+ assert.equal(init.status, 0, init.failure ?? `${init.stdout}${init.stderr}`);return { root, env };}/** Start the real view as a child process, stop it with the test, and return its origin and key. */async function startView(t, box) {- const child = spawn(process.execPath, [BIN, 'view', '--no-open', '--port', '0', '--json'], {+ const args = [BIN, 'view', '--no-open', '--port', '0', '--json'];+ const startedAt = performance.now();+ const child = spawn(process.execPath, args, {cwd: box.root, env: box.env, stdio: ['ignore', 'pipe', 'pipe'],});const closed = once(child, 'close');@@ -50,13 +54,28 @@ async function startView(t, box) {let stderr = '';child.stderr.setEncoding('utf8').on('data', (part) => { stderr += part; });const document = await new Promise((ready, fail) => {- const timer = setTimeout(() => fail(new Error(`view printed no address within 30 s: ${stderr}`)), 30_000);+ let settled = false;+ const failStartup = (detail, status = child.exitCode, signal = child.signalCode) => {+ if (settled) return;+ settled = true;+ clearTimeout(timer);+ fail(new Error(reportFixtureChildFailure({ command: process.execPath, args, status, signal,+ elapsedMs: performance.now() - startedAt, stderr, env: box.env, detail })));+ };+ const timer = setTimeout(() => failStartup('view readiness deadline (30000ms) expired'), 30_000);child.stdout.setEncoding('utf8').on('data', (part) => {stdout += part;- try { ready(JSON.parse(stdout)); clearTimeout(timer); }+ try {+ const document = JSON.parse(stdout);+ if (settled) return;+ settled = true;+ clearTimeout(timer);+ ready(document);+ }catch { /* Wait until the one JSON document is complete. */ }});- child.once('close', (code) => { clearTimeout(timer); fail(new Error(`view exited ${code} before printing its address: ${stderr}`)); });+ child.once('close', (code, signal) => failStartup('view exited before printing its address', code, signal));+ child.once('error', (error) => failStartup(error.message, null, null));});const url = new URL(document.url);return { origin: url.origin, key: url.searchParams.get('k') };diff --git a/test/init-ignore.test.js b/test/init-ignore.test.jsindex 6d681f1c..1660e998 100644--- a/test/init-ignore.test.js+++ b/test/init-ignore.test.js@@ -1,6 +1,6 @@/** Setup preserves local ignore rules and excludes real nested agent worktrees [I1,I2,I16]. */import assert from 'node:assert/strict';-import { spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -21,14 +21,12 @@ function fixture(t, ignore) {Object.assign(env, { GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', GIT_AUTHOR_NAME: 'Init Fixture', GIT_AUTHOR_EMAIL: '[email protected]', GIT_COMMITTER_NAME: 'Init Fixture', GIT_COMMITTER_EMAIL: '[email protected]' });/** Run actual Git and its installed hooks, requiring success. */function git(...args) {- const result = spawnSync('git', args, { cwd: root, env, encoding: 'utf8' });- assert.equal(result.status, 0, result.stderr);- return result.stdout;+ return runFixtureGit(args, { cwd: root, env, encoding: 'utf8' });}/** Invoke the real command and retain its typed result, including refusals. */function cli(...args) {- const result = spawnSync(process.execPath, [cliPath, ...args, '--json'], { cwd: root, env, encoding: 'utf8' });- return { code: result.status, document: JSON.parse(result.stdout), stderr: result.stderr };+ const result = runFixtureChild(process.execPath, [cliPath, ...args, '--json'], { cwd: root, env, encoding: 'utf8' });+ return { code: result.status, document: JSON.parse(result.stdout), stderr: result.failure ?? result.stderr, failure: result.failure };}git('init', '-q', '-b', 'main');writeFileSync(join(root, 'pullboard.json'), JSON.stringify({ gate: 'true', lanes: { web: { owns: ['web/'], specs: [] } } }));diff --git a/test/lane-bypass.test.js b/test/lane-bypass.test.jsindex bd020305..66096c1b 100644--- a/test/lane-bypass.test.js+++ b/test/lane-bypass.test.js@@ -1,6 +1,7 @@/** Reproduce lane-policy bypasses with private Git repositories and their installed hooks [L1,L3]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -48,16 +49,16 @@ function sandbox() {mkdirSync(env.HOME);/** Run Git in a fixture repo and return trimmed output. */function git(cwd, ...args) {- return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ return runFixtureGit(args, { cwd, env });}/** Run Git while preserving expected hook failures for assertions. */function tryGit(cwd, ...args) {- return spawnSync('git', args, { cwd, env, encoding: 'utf8', timeout: 30_000 });+ return runFixtureChild('git', args, { cwd, env, encoding: 'utf8' });}/** Run this checkout's CLI in the selected private working tree. */function run(cwd, ...args) {- const result = spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 30_000 });- return { code: result.status, out: result.stdout, err: result.stderr };+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout, err: result.failure ?? result.stderr, failure: result.failure };}return { dir, env, git, tryGit, run };}diff --git a/test/machine.test.js b/test/machine.test.jsindex 64a956a3..a097f0cb 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -15,6 +15,7 @@ import { loadConfig } from '../src/config.js';import { Refused } from '../src/refused.js';import { BLANKS, IN_STATE, MACHINE, effectiveGuards, lifecycleHelp, lifecycleMarkdown, machineProblems, storeTriggers } from '../src/machine.js';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';/*** Refusals that are not about an item's lifecycle, so no move declares them: command input, caller@@ -766,7 +767,7 @@ test('the page and the help follow the declaration: a new move appears in both [});test('pullboard help lists each role\'s moves from the declaration, and pullboard lifecycle prints the page [M1, P4]', () => {- const help = spawnSync(process.execPath, [BIN, 'help', '--all'], { encoding: 'utf8' });+ const help = runFixtureChild(process.execPath, [BIN, 'help', '--all'], { encoding: 'utf8' });assert.equal(help.status, 0, help.stderr);for (const role of MACHINE.roles) {const line = help.stdout.split('\n').find((text) => text.startsWith(` ${role} `));@@ -775,7 +776,7 @@ test('pullboard help lists each role\'s moves from the declaration, and pullboarassert.deepEqual(listed.sort(), MACHINE.moves.filter((move) => move.by.includes(role)).map((move) => move.verb).sort(), `${role}'s moves`);}assert.ok(HELP.all.includes(lifecycleHelp()), 'the full help screen carries the generated section, not a typed copy');- const printed = spawnSync(process.execPath, [BIN, 'lifecycle'], { encoding: 'utf8' });+ const printed = runFixtureChild(process.execPath, [BIN, 'lifecycle'], { encoding: 'utf8' });assert.equal(printed.status, 0, printed.stderr);assert.equal(printed.stdout, lifecycleMarkdown());});@@ -1028,9 +1029,9 @@ test('next --verify reserves the review for the reviewLease and says until when;GIT_COMMITTER_EMAIL: '[email protected]',PULLBOARD_HOME: join(dir, 'home'),};- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();- // A command that never returns fails the test after a minute instead of holding the gate open.- const run = (cwd, ...args) => spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 60_000 });+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env, encoding: 'utf8', stdio: 'pipe' });+ // The test runner's per-test timeout bounds hangs without killing this CLI early under load.+ const run = (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });const repo = join(dir, 'repo');mkdirSync(repo);git(repo, 'init', '-q', '-b', 'main');diff --git a/test/merge-hooks.test.js b/test/merge-hooks.test.jsindex 5f6aec8c..e7426e44 100644--- a/test/merge-hooks.test.js+++ b/test/merge-hooks.test.js@@ -1,6 +1,6 @@/** Real merge indexes prove exact foreign-object preservation without weakening lane ownership [L3]. */import assert from 'node:assert/strict';-import { spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, rmSync, unlinkSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';@@ -12,12 +12,10 @@ const BIN = join(import.meta.dirname, '..', 'bin', 'pullboard.js');/** Run private Git with an explicit fixture identity, retaining only nonsensitive diagnostics. */function git(root, ...args) {- const result = spawnSync('git', args, { cwd: root, encoding: 'utf8', env: {+ return runFixtureGit(args, { cwd: root, encoding: 'utf8', env: {...process.env, GIT_AUTHOR_NAME: 'Merge Fixture', GIT_AUTHOR_EMAIL: '[email protected]',GIT_COMMITTER_NAME: 'Merge Fixture', GIT_COMMITTER_EMAIL: '[email protected]',} });- assert.equal(result.status, 0, 'fixture git ' + args[0] + ': ' + result.stderr);- return result.stdout.trim();}/** Make separate main and lane checkouts with committed policy and two owned files. */@@ -62,16 +60,11 @@ function nativeFixture(t) {GIT_COMMITTER_NAME: 'Merge Fixture', GIT_COMMITTER_EMAIL: '[email protected]',HOME: join(dir, 'home'), PULLBOARD_HOME: join(dir, 'pullboard-home'), PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),});- const git = (...args) => {- const result = spawnSync('git', args, { cwd: main, env, encoding: 'utf8' });- assert.equal(result.status, 0, `native fixture git ${args[0]}: ${result.stderr}`);- return result.stdout.trim();- };+ const git = (...args) => runFixtureGit(args, { cwd: main, env, encoding: 'utf8' });const gitAt = (cwd, ...args) => {- const result = spawnSync('git', args, { cwd, env, encoding: 'utf8' });- return result;+ return runFixtureChild('git', args, { cwd, env, encoding: 'utf8' });};- const cli = (cwd, ...args) => spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ const cli = (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });git('init', '-q', '-b', 'main');assert.equal(cli(main, 'init').status, 0, 'the native CLI installs hooks and initializes the board');const config = {@@ -105,8 +98,8 @@ function diverge(box, { conflict = false } = {}) {if (conflict) writeFileSync(join(box.main, 'core', 'file'), 'accepted core\n');git(box.main, 'add', '-A');git(box.main, 'commit', '-q', '-m', 'test: accepted main change');- const result = spawnSync('git', ['merge', '--no-commit', '--no-ff', git(box.main, 'rev-parse', 'HEAD')], { cwd: box.lane, encoding: 'utf8' });- assert.equal(result.status, conflict ? 1 : 0, 'a real merge is pending');+ const result = runFixtureChild('git', ['merge', '--no-commit', '--no-ff', git(box.main, 'rev-parse', 'HEAD')], { cwd: box.lane, encoding: 'utf8' });+ assert.equal(result.status, conflict ? 1 : 0, result.failure ?? 'a real merge is pending');}test('accepted-main merges preserve exact foreign objects on a primary branch named trunk [L3]', (t) => {@@ -148,8 +141,8 @@ test('a foreign resolution identical to HEAD is allowed, including literal odd fwriteFileSync(join(box.main, path), 'accepted other parent\n');git(box.main, 'add', '-A');git(box.main, 'commit', '-q', '-m', 'test: alternate accepted parent');- const result = spawnSync('git', ['merge', '--no-commit', '--no-ff', 'main'], { cwd: box.lane, encoding: 'utf8' });- assert.equal(result.status, 1, 'foreign parents conflict');+ const result = runFixtureChild('git', ['merge', '--no-commit', '--no-ff', 'main'], { cwd: box.lane, encoding: 'utf8' });+ assert.equal(result.status, 1, result.failure ?? 'foreign parents conflict');assert.ok(preCommitProblems(box.context).some((problem) => problem.includes('literal')),'unresolved stages are never treated as an absent path');git(box.lane, 'restore', '--source=HEAD', '--staged', '--worktree', '--', path);diff --git a/test/newcomer.test.js b/test/newcomer.test.jsindex 4197d1d1..9797d3d3 100644--- a/test/newcomer.test.js+++ b/test/newcomer.test.js@@ -1,6 +1,7 @@/** First-run guidance on private Git repos, including unrelated files setup must not stage [I1,I2]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -14,9 +15,9 @@ function project(t) {t.after(() => rmSync(root, { recursive: true, force: true }));const env = { ...process.env, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', PULLBOARD_HOME: join(root, '.private-home') };/** Read a private Git command's result without inheriting the maintainer's configuration. */- const git = (...args) => execFileSync('git', args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (...args) => runFixtureGit(args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' });/** Preserve CLI output so guidance is checked exactly as a newcomer receives it. */- const run = (...args) => spawnSync(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });git('init', '-q', '-b', 'main');return { root, env, git, run };}diff --git a/test/person.test.js b/test/person.test.jsindex 9e9dc79e..7109f33d 100644--- a/test/person.test.js+++ b/test/person.test.js@@ -1,6 +1,8 @@/** Person terminal identity and immutable channel receipts on real repositories [B26]. */import assert from 'node:assert/strict';-import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { spawn } from 'node:child_process';+import { performance } from 'node:perf_hooks';+import { fixtureChildMessage, reportFixtureChildFailure, runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -60,10 +62,10 @@ function sandbox() {PULLBOARD_HOME: join(dir, 'pullboard-home'),});/** Run real Git commands under isolated author and configuration settings. */- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env });/** Run the real Pullboard CLI in its own process with optional environment markers. */- const run = (cwd, args, extraEnv = {}) => spawnSync(process.execPath, [BIN, ...args], {- cwd, env: { ...env, ...extraEnv }, encoding: 'utf8', timeout: 10_000,+ const run = (cwd, args, extraEnv = {}) => runFixtureChild(process.execPath, [BIN, ...args], {+ cwd, env: { ...env, ...extraEnv }, encoding: 'utf8',});return { dir, env, git, run };}@@ -75,7 +77,7 @@ function project() {mkdirSync(repo);box.git(repo, 'init', '-q', '-b', 'main');const initialized = box.run(repo, ['init']);- assert.equal(initialized.status, 0, initialized.stderr);+ assert.equal(initialized.status, 0, fixtureChildMessage(initialized));const configPath = join(repo, 'pullboard.json');const config = JSON.parse(readFileSync(configPath, 'utf8'));writeFileSync(configPath, `${JSON.stringify({@@ -163,7 +165,9 @@ test('[B26] person answers refuse agent environments without writes and record t/** Start the actual view in an agent environment and retain only its private request credentials. */async function startView(t, box, extraEnv = {}) {- const child = spawn(process.execPath, [BIN, 'view', '--no-open', '--port', '0', '--json'], {+ const args = [BIN, 'view', '--no-open', '--port', '0', '--json'];+ const startedAt = performance.now();+ const child = spawn(process.execPath, args, {cwd: box.repo, env: { ...box.env, ...MARKERS, ...extraEnv }, stdio: ['ignore', 'pipe', 'pipe'],});let output = '';@@ -181,17 +185,27 @@ async function startView(t, box, extraEnv = {}) {clearTimeout(timer);});const document = await new Promise((ready, fail) => {- const timer = setTimeout(() => fail(new Error('the private view did not start: ' + diagnostics)), 10_000);+ let settled = false;+ const failStartup = (detail, status = child.exitCode, signal = child.signalCode) => {+ if (settled) return;+ settled = true;+ clearTimeout(timer);+ fail(new Error(reportFixtureChildFailure({ command: process.execPath, args, status, signal,+ elapsedMs: performance.now() - startedAt, stderr: diagnostics, env: box.env, detail })));+ };+ const timer = setTimeout(() => failStartup('private view readiness deadline (10000ms) expired'), 10_000);child.stdout.on('data', (part) => {output += part;try {const value = JSON.parse(output);+ if (settled) return;+ settled = true;clearTimeout(timer);ready(value);} catch { /* The JSON envelope may arrive in several chunks. */ }});- child.once('error', (error) => { clearTimeout(timer); fail(error); });- child.once('close', () => { clearTimeout(timer); fail(new Error('the private view exited: ' + diagnostics)); });+ child.once('error', (error) => failStartup(error.message, null, null));+ child.once('close', (code, signal) => failStartup('private view exited before readiness', code, signal));});const address = new URL(document.url);const secret = address.searchParams.get('k');@@ -316,7 +330,7 @@ test('[B26,S18] signer enrollment refuses agent shells without creating or changconst box = project();t.after(() => rmSync(box.dir, { recursive: true, force: true }));const key = join(box.dir, 'fixture-signing-key');- const generated = spawnSync('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', key], { env: box.env, stdio: 'ignore' });+ const generated = runFixtureChild('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', key], { env: box.env, stdio: 'ignore' });assert.equal(generated.status, 0, 'the fixture creates a disposable signing identity');const files = ['signers', 'signers.initial', 'first-commit', 'signoffs.jsonl'].map(name => join(box.repo, '.pullboard', name));/** Read only private fixture trust bytes; assertions never print key contents. */diff --git a/test/products.test.js b/test/products.test.jsindex 8a837a8f..46fd61a5 100644--- a/test/products.test.js+++ b/test/products.test.js@@ -4,7 +4,7 @@* spec check catches an entry that names no row.*/import assert from 'node:assert/strict';-import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -104,8 +104,8 @@ test('in a real repo, status prints each product, and spec check fails on an entGIT_COMMITTER_EMAIL: '[email protected]',PULLBOARD_HOME: join(dir, 'home'),};- const git = (...args) => execFileSync('git', args, { cwd: repo, env, encoding: 'utf8', stdio: 'pipe' });- const run = (...args) => spawnSync(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });+ const git = (...args) => runFixtureGit(args, { cwd: repo, env, encoding: 'utf8', stdio: 'pipe' });+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });const writeConfig = (products) => writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({ gate: 'true', lanes: CONFIG.lanes, products }, null, 2));git('init', '-q', '-b', 'main');writeConfig(PRODUCTS);diff --git a/test/project-meta.test.js b/test/project-meta.test.jsindex 4cfe6412..f7dca65a 100644--- a/test/project-meta.test.js+++ b/test/project-meta.test.js@@ -1,6 +1,7 @@/** Project metadata and registry lifecycle (N33, N35, N36). */import assert from 'node:assert/strict';-import { execFileSync, spawnSync } from 'node:child_process';+import { execFileSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -23,8 +24,8 @@ function fleet(t) {const prior = process.env.PULLBOARD_HOME;process.env.PULLBOARD_HOME = home;t.after(() => { if (prior === undefined) delete process.env.PULLBOARD_HOME; else process.env.PULLBOARD_HOME = prior; });- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();- const run = (cwd, ...args) => spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env, encoding: 'utf8', stdio: 'pipe' });+ const run = (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });const ok = (cwd, ...args) => { const out = run(cwd, ...args); assert.equal(out.status, 0, `${out.stdout}${out.stderr}`); return out.stdout; };const repo = (folder, name, project = 'Demo group') => {const root = join(dir, folder);diff --git a/test/registry.test.js b/test/registry.test.jsindex 6c016e15..78613a0a 100644--- a/test/registry.test.js+++ b/test/registry.test.js@@ -1,12 +1,14 @@/** Registry metadata, refresh, pruning and forgetting (N33, N35, N36). */import assert from 'node:assert/strict';-import { execFileSync, spawn } from 'node:child_process';+import { spawn } from 'node:child_process';+import { performance } from 'node:perf_hooks';import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { basename, join, resolve } from 'node:path';import { test } from 'node:test';import { configProblems, defaults, loadConfig } from '../src/config.js';import { forgetProject, listProjects, registerProject, registryFile } from '../src/projects.js';+import { reportFixtureChildFailure, runFixtureGit } from './fixture-child.js';/*** Create an initialized temporary Git repository with a private Pullboard home.@@ -18,7 +20,7 @@ import { forgetProject, listProjects, registerProject, registryFile } from '../sfunction makeRepo(parent, name) {const root = join(parent, name);mkdirSync(root, { recursive: true });- execFileSync('git', ['init', '--quiet', root]);+ runFixtureGit(['init', '--quiet', root]);return root;}@@ -79,9 +81,12 @@ test('registry uses validated repo labels, refreshes metadata, prunes missing ro* @returns {{ child: import('node:child_process').ChildProcess, ready: Promise<void>, exited: Promise<{ code: number | null, signal: NodeJS.Signals | null, stderr: string }> }}*/function startNode(args, env) {- const child = spawn(process.execPath, args, { env, stdio: ['ignore', 'pipe', 'pipe'] });+ const command = process.execPath;+ const started = performance.now();+ const child = spawn(command, args, { env, stdio: ['ignore', 'pipe', 'pipe'] });let stderr = '';let announcedReady = false;+ let failureReported = false;let resolveReady;let rejectReady;const ready = new Promise((resolvePromise, rejectPromise) => {@@ -95,10 +100,18 @@ function startNode(args, env) {}});child.stderr.setEncoding('utf8').on('data', (chunk) => { stderr += chunk; });- child.on('error', (error) => rejectReady(error));+ child.on('error', (error) => {+ failureReported = true;+ reportFixtureChildFailure({ command, args, status: null, signal: null, elapsedMs: performance.now() - started, stderr, env, detail: error.message });+ rejectReady(error);+ });const exited = new Promise((resolvePromise, rejectPromise) => {child.on('error', rejectPromise);child.on('close', (code, signal) => {+ if ((code !== 0 || signal) && !failureReported) {+ failureReported = true;+ reportFixtureChildFailure({ command, args, status: code, signal, elapsedMs: performance.now() - started, stderr, env, detail: announcedReady ? '' : 'child exited before ready' });+ }if (!announcedReady) rejectReady(new Error(`child exited before ready (${code ?? signal}): ${stderr}`));resolvePromise({ code, signal, stderr });});diff --git a/test/relay-agent.test.js b/test/relay-agent.test.jsindex c8fd55f3..7748d01e 100644--- a/test/relay-agent.test.js+++ b/test/relay-agent.test.js@@ -1,12 +1,13 @@/** Private end-to-end proof for ordered agent enrollment and scoped relay credentials [H2,H9,A4]. */import assert from 'node:assert/strict';-import { spawn, spawnSync } from 'node:child_process';+import { spawnSync } from 'node:child_process';import { createHash } from 'node:crypto';import { DatabaseSync } from 'node:sqlite';import { chmodSync, existsSync, readFileSync, realpathSync, unlinkSync, writeFileSync } from 'node:fs';import { basename, dirname, join } from 'node:path';import { fileURLToPath } from 'node:url';-import { test } from 'node:test';+import { after, test } from 'node:test';+import { cleanupFixtureChildren, runFixtureChild, runFixtureChildAsync } from './fixture-child.js';import { claim as claimStoredItem, closeBoard, openBoard, register as registerStoredAgent, submit as submitStoredItem } from '../src/board.js';import { serveApi } from '../src/api.js';import { main } from '../src/cli.js';@@ -16,34 +17,27 @@ import { frozenCriterion, parseSpec } from '../src/spec.js';import { relayClientFixture } from './relay-client-fixture.js';import { fetchFresh } from './http-fixture.js';-/** Invoke one real CLI command without retaining stderr or exposing private command output. */+after(cleanupFixtureChildren);++/** Invoke one real CLI command and retain only redacted child diagnostics on failure. */function runCli(root, env, cli, args) {- return new Promise((resolveResult, reject) => {- const child = spawn(process.execPath, [cli, ...args, '--json'], { cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'] });- let stdout = '';- const timer = setTimeout(() => child.kill('SIGKILL'), 25000);- child.stdout.setEncoding('utf8').on('data', (part) => { stdout += part; });- child.stderr.resume();- child.once('error', (error) => { clearTimeout(timer); reject(error); });- child.once('close', (code, signal) => {- clearTimeout(timer);- if (signal) return reject(new Error('private agent CLI exceeded its deadline'));- try { resolveResult({ code, document: JSON.parse(stdout) }); }- catch { reject(new Error(`private agent CLI ${args[0]} did not return JSON (exit ${code ?? 'signal'})`)); }- });+ return runFixtureChildAsync(process.execPath, [cli, ...args, '--json'], { cwd: root, env }).then((result) => {+ if (result.error) throw new Error(result.failure);+ try { return { code: result.status, document: JSON.parse(result.stdout), stderr: result.failure ?? result.stderr, failure: result.failure }; }+ catch { throw new Error(result.failure ?? result.context); }});}/** Run Git in a private fixture and keep all diagnostics credential-free. */function git(root, env, args) {- const result = spawnSync('git', args, { cwd: root, env, encoding: 'utf8' });- assert.equal(result.status, 0, `private Git fixture ${args[0]} succeeds: ${result.stderr}`);+ const result = runFixtureChild('git', args, { cwd: root, env, encoding: 'utf8' });+ assert.equal(result.status, 0, result.failure ?? `private Git fixture ${args[0]} succeeds: ${result.stderr}`);}/** Return private Git output for a structural assertion without surfacing command diagnostics. */function gitText(root, env, args) {- const result = spawnSync('git', args, { cwd: root, env, encoding: 'utf8' });- assert.equal(result.status, 0, `private Git fixture ${args[0]} succeeds`);+ const result = runFixtureChild('git', args, { cwd: root, env, encoding: 'utf8' });+ assert.equal(result.status, 0, result.failure ?? `private Git fixture ${args[0]} succeeds`);return result.stdout;}@@ -90,9 +84,9 @@ test('ordered agent joins mint scoped tokens and retain authenticated native actconst oneItem = await box.cli('add', box.lane, 'agent one private review', '--criterion', 'the first verifier records its own decision');const twoItem = await box.cli('add', box.lane, 'agent two private review', '--criterion', 'the second verifier records its own decision');const workItem = await box.cli('add', box.lane, 'token-only agent work');- assert.equal(oneItem.code, 0);- assert.equal(twoItem.code, 0);- assert.equal(workItem.code, 0);+ assert.equal(oneItem.code, 0, oneItem.failure ?? oneItem.stderr);+ assert.equal(twoItem.code, 0, twoItem.failure ?? twoItem.stderr);+ assert.equal(workItem.code, 0, workItem.failure ?? workItem.stderr);git(box.root, box.env, ['add', '-A']);git(box.root, box.env, ['commit', '-q', '-m', 'test: prepare private agent fixture']);@@ -122,7 +116,7 @@ test('ordered agent joins mint scoped tokens and retain authenticated native actawait box.link();const firstStart = box.calls.length;const firstJoin = await runCli(firstRoot, box.env, cli, ['join', box.lane, '--family', 'codex-fixture']);- assert.equal(firstJoin.code, 0, 'the first worktree joins through the real linked CLI');+ assert.equal(firstJoin.code, 0, firstJoin.failure ?? 'the first worktree joins through the real linked CLI');const firstAgent = firstJoin.document.agent;const firstCalls = box.calls.slice(firstStart);const firstRegistration = firstCalls.findIndex((call) => call.method === 'POST' && call.path.endsWith('/moves'));@@ -131,7 +125,7 @@ test('ordered agent joins mint scoped tokens and retain authenticated native actconst secondStart = box.calls.length;const secondJoin = await runCli(secondRoot, box.env, cli, ['join', box.lane, '--family', 'codex-fixture']);- assert.equal(secondJoin.code, 0, 'the second worktree joins through the real linked CLI');+ assert.equal(secondJoin.code, 0, secondJoin.failure ?? 'the second worktree joins through the real linked CLI');const secondAgent = secondJoin.document.agent;const secondCalls = box.calls.slice(secondStart);const secondRegistration = secondCalls.findIndex((call) => call.method === 'POST' && call.path.endsWith('/moves'));@@ -142,7 +136,7 @@ test('ordered agent joins mint scoped tokens and retain authenticated native actconst firstToken = scopedToken(box.linkFile, firstAgent);const secondToken = scopedToken(box.linkFile, secondAgent);const list = await box.cli('relay', 'tokens');- assert.equal(list.code, 0);+ assert.equal(list.code, 0, list.failure ?? list.stderr);assert.deepEqual(list.document.tokens.map((row) => row.agent).sort(), [firstAgent, secondAgent].sort());const personState = JSON.parse(readFileSync(box.linkFile, 'utf8'));const boardKey = readFileSync(box.keyFile, 'utf8').trim();@@ -176,13 +170,13 @@ test('ordered agent joins mint scoped tokens and retain authenticated native actconst firstVerify = await runCli(firstRoot, { ...box.env, PULLBOARD_RELAY_TOKEN: firstToken }, cli,['verify', String(oneItem.document.item.item_id), 'accept', '--note', 'checked the private submitted proof']);- assert.equal(firstVerify.code, 0, `the first agent gives an ACCEPT verdict using only its scoped token (${firstVerify.document.error?.code ?? 'no refusal'})`);+ assert.equal(firstVerify.code, 0, firstVerify.failure ?? `the first agent gives an ACCEPT verdict using only its scoped token (${firstVerify.document.error?.code ?? 'no refusal'})`);const secondVerify = await runCli(secondRoot, { ...box.env, PULLBOARD_RELAY_TOKEN: secondToken }, cli,['verify', String(twoItem.document.item.item_id), 'accept', '--note', 'checked the other private submitted proof']);- assert.equal(secondVerify.code, 0, `the second agent gives an ACCEPT verdict using only its scoped token (${secondVerify.document.error?.code ?? 'no refusal'})`);+ assert.equal(secondVerify.code, 0, secondVerify.failure ?? `the second agent gives an ACCEPT verdict using only its scoped token (${secondVerify.document.error?.code ?? 'no refusal'})`);const revoke = await box.cli('relay', 'revoke', firstTokenRow.id);- assert.equal(revoke.code, 0, 'CLI revokes one listed opaque token id');+ assert.equal(revoke.code, 0, revoke.failure ?? 'CLI revokes one listed opaque token id');const apiRevokeResponse = await fetchFresh(tokenUrl, {method: 'POST', headers: apiHeaders, body: JSON.stringify({ id: firstTokenRow.id }),});@@ -233,9 +227,9 @@ test('ordered agent joins mint scoped tokens and retain authenticated native actconst secondEnv = { ...box.env, PULLBOARD_RELAY_TOKEN: secondToken };const tokenOnlyRead = await runCli(secondRoot, secondEnv, cli, ['list', '--all']);- assert.equal(tokenOnlyRead.code, 0, 'the other agent reads through its scoped token after person revocation');+ assert.equal(tokenOnlyRead.code, 0, tokenOnlyRead.failure ?? 'the other agent reads through its scoped token after person revocation');const tokenOnlyWrite = await runCli(secondRoot, secondEnv, cli, ['claim', String(workItem.document.item.item_id)]);- assert.equal(tokenOnlyWrite.code, 0, 'the other agent writes through its scoped token after person revocation');+ assert.equal(tokenOnlyWrite.code, 0, tokenOnlyWrite.failure ?? 'the other agent writes through its scoped token after person revocation');const native = nativeEvents(boardFile);assert.ok(native.some((row) => row.event_by === secondAgent && row.event_kind === 'claim' && row.item_id === workItem.document.item.item_id),@@ -281,7 +275,7 @@ test('a token mint failure after registration preserves the agent for one cleanchmodSync(shim, 0o700);const boardFile = join(box.root, '.git', 'pullboard', 'board.sqlite');const item = await box.cli('add', box.lane, 'retry registered agent token fixture');- assert.equal(item.code, 0);+ assert.equal(item.code, 0, item.failure ?? item.stderr);git(box.root, box.env, ['add', '-A']);git(box.root, box.env, ['commit', '-q', '-m', 'test: prepare token retry fixture']);await box.link();@@ -304,7 +298,7 @@ test('a token mint failure after registration preserves the agent for one cleanconst retryStart = box.calls.length;const retry = await runCli(agentRoot, box.env, cli, ['join', box.lane, '--family', 'codex-fixture']);- assert.equal(retry.code, 0, 'the same registered worktree can retry token minting');+ assert.equal(retry.code, 0, retry.failure ?? 'the same registered worktree can retry token minting');assert.equal(retry.document.agent, agent);assert.equal(box.calls.slice(retryStart).filter((call) => call.method === 'POST' && call.path === '/auth/tokens').length, 1);assert.equal(nativeEvents(boardFile).filter((row) => row.event_by === agent && row.event_kind === 'join').length, 1);@@ -313,10 +307,10 @@ test('a token mint failure after registration preserves the agent for one cleanassert.deepEqual(Object.keys(linkState.agentTokens), [agent], 'the private link cache holds one usable token for the registered agent');const token = scopedToken(box.linkFile, agent);const listed = await box.cli('relay', 'tokens');- assert.equal(listed.code, 0);+ assert.equal(listed.code, 0, listed.failure ?? listed.stderr);assert.deepEqual(listed.document.tokens.map((row) => row.agent), [agent]);assertMetadataOnly(listed.document, [token, linkState.token], 'retry inventory exposes metadata only');const usable = await runCli(agentRoot, { ...box.env, PULLBOARD_RELAY_TOKEN: token }, cli,['claim', String(item.document.item.item_id)]);- assert.equal(usable.code, 0, 'the single token from the successful retry authorizes an agent action');+ assert.equal(usable.code, 0, usable.failure ?? 'the single token from the successful retry authorizes an agent action');});diff --git a/test/relay-client-fixture.js b/test/relay-client-fixture.jsindex b2365f25..a6e2ee31 100644--- a/test/relay-client-fixture.js+++ b/test/relay-client-fixture.js@@ -1,7 +1,8 @@/** Private real CLI, auth and relay fixture; credentials never enter assertion messages [H1,H7,H18]. */import assert from 'node:assert/strict';import { createHash } from 'node:crypto';-import { spawn, spawnSync } from 'node:child_process';+import { spawn } from 'node:child_process';+import { performance } from 'node:perf_hooks';import { createServer } from 'node:http';import { Transform } from 'node:stream';import { once } from 'node:events';@@ -15,6 +16,7 @@ import { createRelayHandler } from '../relay/service.js';import { createGitHubClient } from '../relay/github.js';import { githubFixture } from './relay-fixture.js';import { relayWorkBudgetMs, MAX_SNAPSHOT_ATTEMPTS } from './relay-budget.js';+import { reportFixtureChildFailure, runFixtureChild } from './fixture-child.js';const CLI = resolve(import.meta.dirname, '../bin/pullboard.js');const MAX_OBSERVED_SNAPSHOT_UPLOADS = MAX_SNAPSHOT_ATTEMPTS;@@ -63,12 +65,13 @@ export function assertSnapshotCheckpoints(trace, expected) {/** Capture a real child result without exposing its private output in failure diagnostics. */function childResult(root, env, argv, observedSnapshotUploads, initialSnapshotUploads = DEFAULT_SNAPSHOT_UPLOADS) {return new Promise((resolveResult, reject) => {- const startedAt = Date.now();- const command = argv[0] === CLI ? (argv[1] ?? 'CLI') : (argv[0] ?? 'script');+ const startedAt = performance.now();let deadlineAt = startedAt + cliChildDeadlineMs(initialSnapshotUploads);const child = spawn(process.execPath, argv, { cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'] });let stdout = '';+ let stderr = '';let exceededDeadline = false;+ let settled = false;const timer = setInterval(() => {const count = observedSnapshotUploads?.() ?? initialSnapshotUploads;if (count > MAX_OBSERVED_SNAPSHOT_UPLOADS) {@@ -77,20 +80,32 @@ function childResult(root, env, argv, observedSnapshotUploads, initialSnapshotUpreturn;}deadlineAt = Math.max(deadlineAt, startedAt + cliChildDeadlineMs(count));- if (Date.now() >= deadlineAt) { exceededDeadline = true; child.kill('SIGKILL'); }+ if (performance.now() >= deadlineAt) { exceededDeadline = true; child.kill('SIGKILL'); }}, 20);child.stdout.setEncoding('utf8').on('data', part => { stdout += part; });- child.stderr.resume();- child.once('error', error => { clearInterval(timer); reject(error); });+ child.stderr.setEncoding('utf8').on('data', part => { stderr += part; });+ /** Retain the exact command and work-derived bound without exposing credentials. */+ const reportFailure = (code, signal, detail = '') => reportFixtureChildFailure({+ command: process.execPath, args: argv, status: code, signal,+ elapsedMs: performance.now() - startedAt, stderr, env, detail,+ });+ child.once('error', error => {+ if (settled) return;+ settled = true;+ clearInterval(timer);+ reject(new Error(reportFailure(null, null, error.message)));+ });child.once('close', (code, signal) => {+ if (settled) return;+ settled = true;clearInterval(timer);- if (signal) return reject(new Error(exceededDeadline- ? `Private relay fixture ${command} exceeded its ${deadlineAt - startedAt}ms upload-derived deadline after ${Date.now() - startedAt}ms.`- : `Private relay fixture ${command} ended with signal ${signal} after ${Date.now() - startedAt}ms.`));+ if (signal) return reject(new Error(reportFailure(code, signal, exceededDeadline+ ? `upload-derived child deadline ${deadlineAt - startedAt}ms exceeded` : '')));+ const failure = code === 0 ? null : reportFailure(code, signal);let document;try { document = JSON.parse(stdout); }- catch { return reject(new Error('private relay fixture child did not return JSON')); }- resolveResult({ code, document, snapshotUploads: observedSnapshotUploads?.() ?? initialSnapshotUploads,+ catch (error) { return reject(new Error(reportFailure(code, signal, `private relay fixture child did not return JSON: ${error.message}`))); }+ resolveResult({ code, document, failure, snapshotUploads: observedSnapshotUploads?.() ?? initialSnapshotUploads,snapshotDeadlineMs: deadlineAt - startedAt });});});@@ -429,12 +444,12 @@ globalThis.fetch = function tracedFetch(input, init) {cliChildDeadlineMs(snapshotUploads);return runCliChild(args, snapshotUploads, true);}- assert.equal(spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: root, env }).status, 0);+ assert.equal(runFixtureChild('git', ['init', '-q', '-b', 'main'], { cwd: root, env, encoding: 'utf8' }).status, 0);writeFileSync(join(root, 'README.md'), 'private relay fixture project\n', { mode: 0o600 });- assert.equal(spawnSync('git', ['add', 'README.md'], { cwd: root, env }).status, 0);- assert.equal(spawnSync('git', ['commit', '-q', '-m', 'fixture base'], { cwd: root, env }).status, 0, 'fixture clone starts from a committed project');+ assert.equal(runFixtureChild('git', ['add', 'README.md'], { cwd: root, env, encoding: 'utf8' }).status, 0);+ assert.equal(runFixtureChild('git', ['commit', '-q', '-m', 'fixture base'], { cwd: root, env, encoding: 'utf8' }).status, 0, 'fixture clone starts from a committed project');assert.equal((await cli('init')).code, 0);- assert.equal(spawnSync('git', ['remote', 'add', 'origin', '[email protected]:fixture/repository.git'], { cwd: root, env }).status, 0);+ assert.equal(runFixtureChild('git', ['remote', 'add', 'origin', '[email protected]:fixture/repository.git'], { cwd: root, env, encoding: 'utf8' }).status, 0);const lane = Object.keys(JSON.parse(readFileSync(join(root, 'pullboard.json'), 'utf8')).lanes)[0];assert.equal((await cli('add', lane, 'private cleanup fixture item')).code, 0);const before = (await cli('export')).document;@@ -462,9 +477,9 @@ globalThis.fetch = function tracedFetch(input, init) {const otherEnv = { ...env, HOME: otherHome, PULLBOARD_HOME: join(otherHome, '.pullboard') };/** Invoke the independent device's production CLI without retaining its output in diagnostics. */const run = (...args) => childResult(otherRoot, otherEnv, [CLI, ...args, '--json']);- assert.equal(spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: otherRoot, env: otherEnv }).status, 0);+ assert.equal(runFixtureChild('git', ['init', '-q', '-b', 'main'], { cwd: otherRoot, env: otherEnv, encoding: 'utf8' }).status, 0);assert.equal((await run('init')).code, 0);- assert.equal(spawnSync('git', ['remote', 'add', 'origin', '[email protected]:fixture/repository.git'], { cwd: otherRoot, env: otherEnv }).status, 0);+ assert.equal(runFixtureChild('git', ['remote', 'add', 'origin', '[email protected]:fixture/repository.git'], { cwd: otherRoot, env: otherEnv, encoding: 'utf8' }).status, 0);const snapshot = join(scratch, 'snapshot.json');writeFileSync(snapshot, JSON.stringify(before), { mode: 0o600 });assert.equal((await run('import', snapshot)).code, 0, 'second device imports the same real board');@@ -478,9 +493,9 @@ globalThis.fetch = function tracedFetch(input, init) {const otherHome = join(scratch, 'paired-home');mkdirSync(otherHome, { mode: 0o700 });const otherEnv = { ...env, HOME: otherHome, PULLBOARD_HOME: join(otherHome, '.pullboard'), PULLBOARD_MACHINE_HOME: join(scratch, 'paired-machine') };- assert.equal(spawnSync('git', ['clone', '--bare', root, bare], { cwd: scratch, env: otherEnv }).status, 0, 'fixture project creates a private bare remote');- assert.equal(spawnSync('git', ['clone', bare, otherRoot], { cwd: scratch, env: otherEnv }).status, 0, 'second device is a real clone');- assert.equal(spawnSync('git', ['remote', 'set-url', 'origin', '[email protected]:fixture/repository.git'], { cwd: otherRoot, env: otherEnv }).status, 0, 'clone names the same authorized repository');+ assert.equal(runFixtureChild('git', ['clone', '--bare', root, bare], { cwd: scratch, env: otherEnv, encoding: 'utf8' }).status, 0, 'fixture project creates a private bare remote');+ assert.equal(runFixtureChild('git', ['clone', bare, otherRoot], { cwd: scratch, env: otherEnv, encoding: 'utf8' }).status, 0, 'second device is a real clone');+ assert.equal(runFixtureChild('git', ['remote', 'set-url', 'origin', '[email protected]:fixture/repository.git'], { cwd: otherRoot, env: otherEnv, encoding: 'utf8' }).status, 0, 'clone names the same authorized repository');const run = (...args) => childResult(otherRoot, otherEnv, [CLI, ...args, '--json']);assert.equal((await run('init')).code, 0, 'the cloned project initializes its private local board');const joined = await run('relay', 'join', code, '--url', origin);@@ -509,9 +524,9 @@ globalThis.fetch = function tracedFetch(input, init) {const nextEnv = { ...env, HOME: nextHome, PULLBOARD_HOME: join(nextHome, '.pullboard') };/** Run this separate board without retaining credentials in diagnostic output. */const run = (...args) => childResult(nextRoot, nextEnv, [CLI, ...args, '--json']);- assert.equal(spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: nextRoot, env: nextEnv }).status, 0);+ assert.equal(runFixtureChild('git', ['init', '-q', '-b', 'main'], { cwd: nextRoot, env: nextEnv, encoding: 'utf8' }).status, 0);assert.equal((await run('init')).code, 0);- assert.equal(spawnSync('git', ['remote', 'add', 'origin', '[email protected]:fixture/repository.git'], { cwd: nextRoot, env: nextEnv }).status, 0);+ assert.equal(runFixtureChild('git', ['remote', 'add', 'origin', '[email protected]:fixture/repository.git'], { cwd: nextRoot, env: nextEnv, encoding: 'utf8' }).status, 0);assert.equal((await run('add', lane, title)).code, 0);assert.equal((await run('relay', 'on', '--url', origin)).code, 0);const state = JSON.parse(readFileSync(join(nextRoot, '.git', 'pullboard', 'relay.json'), 'utf8'));diff --git a/test/relay-client.test.js b/test/relay-client.test.jsindex 9dd7891b..9c1e8af5 100644--- a/test/relay-client.test.js+++ b/test/relay-client.test.js@@ -1,12 +1,13 @@/** Real device-flow CLI ordering through the opaque relay [H1,H7,H15]. */import assert from 'node:assert/strict';-import { spawn, spawnSync } from 'node:child_process';+import { spawnSync } from 'node:child_process';import { createServer } from 'node:http';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs';import { delimiter, join, resolve } from 'node:path';import { tmpdir } from 'node:os';-import { test } from 'node:test';+import { after, test } from 'node:test';import { gunzipSync } from 'node:zlib';+import { cleanupFixtureChildren, runFixtureChildAsync, runFixtureGit, safeFixtureDiagnostic } from './fixture-child.js';import { DatabaseSync } from 'node:sqlite';import { createAuthHandler } from '../relay/auth-http.js';import { createRelayAuth } from '../relay/auth.js';@@ -26,6 +27,7 @@ import { presentationShout } from '../src/relay-presentation.js';import { fetchFresh } from './http-fixture.js';const SIGN_INS = new Map();+after(cleanupFixtureChildren);/** Read native gzip snapshots while retaining checks against historical uncompressed records. */function snapshotDocument(plain) {@@ -34,36 +36,29 @@ function snapshotDocument(plain) {/** Run the actual CLI asynchronously so this process can continue serving its HTTP requests. */function cliResult(root, env, ...args) {- return new Promise((resolveResult, reject) => {- const child = spawn(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json'], {- cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'],- });- let stdout = '';- let stderr = '';- const timer = setTimeout(() => child.kill('SIGKILL'), 25_000);- child.stdout.setEncoding('utf8').on('data', (part) => { stdout += part; });- let signInStarted = false;- child.stderr.setEncoding('utf8').on('data', (part) => {- stderr += part;- if (!signInStarted && stderr.includes('enter TEST-ONLY') && SIGN_INS.has(root)) {+ let signInStarted = false;+ let observedStderr = '';+ return runFixtureChildAsync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json'], {+ cwd: root, env,+ onStderrChunk(part, child) {+ observedStderr += part;+ if (!signInStarted && observedStderr.includes('enter TEST-ONLY') && SIGN_INS.has(root)) {signInStarted = true;Promise.resolve(SIGN_INS.get(root)()).catch(() => child.kill('SIGKILL'));}- });- child.once('error', (error) => { clearTimeout(timer); reject(error); });- child.once('close', (code, signal) => {- clearTimeout(timer);- if (signal) return reject(new Error(`pullboard ${args.join(' ')} was killed by ${signal}: ${stderr}`));- try { resolveResult({ status: code, document: JSON.parse(stdout), stderr }); }- catch { reject(new Error(`pullboard ${args.join(' ')} did not print JSON: ${stdout}\n${stderr}`)); }- });+ },+ }).then((result) => {+ if (result.error) throw new Error(result.failure);+ try { return { status: result.status, document: JSON.parse(result.stdout), stderr: result.stderr, failure: result.failure }; }+ catch { throw new Error(result.failure ?? result.context); }});}/** Run a successful actual CLI command and retain refusal diagnostics on failure. */async function cli(root, env, ...args) {const result = await cliResult(root, env, ...args);- assert.equal(result.status, 0, `pullboard ${args.join(' ')} exited ${result.status}: ${result.stderr}\n${JSON.stringify(result.document)}`);+ const refusal = safeFixtureDiagnostic(JSON.stringify(result.document), env);+ assert.equal(result.status, 0, `${result.failure ?? `pullboard ${args.join(' ')} exited ${result.status}: ${result.stderr}`}\n${refusal}`);return result.document;}@@ -168,13 +163,11 @@ test('[H1,H3,H7,H15,H16] relay on snapshots and orders ciphertext, refuses offliconst callback = new URL(authorization.headers.get('location'));const person = await auth.finishWeb(callback.searchParams.get('state'), callback.searchParams.get('code'), flow.binding);- const git = spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: root, env, encoding: 'utf8' });- assert.equal(git.status, 0, git.stderr);+ runFixtureGit(['init', '-q', '-b', 'main'], { cwd: root, env, encoding: 'utf8' });await cli(root, env, 'init');writeFileSync(join(root, 'SPEC.md'), '# Spec\n\n## G · Goals\n- G1 [approved, must] A lost reply has one original outcome. | gate: review\n');const config = JSON.parse(readFileSync(join(root, 'pullboard.json'), 'utf8'));- const originRemote = spawnSync('git', ['remote', 'add', 'origin', '[email protected]:fixture/repository.git'], { cwd: root, env, encoding: 'utf8' });- assert.equal(originRemote.status, 0, originRemote.stderr);+ runFixtureGit(['remote', 'add', 'origin', '[email protected]:fixture/repository.git'], { cwd: root, env, encoding: 'utf8' });const marker = 'RELAY_CLIENT_KNOWN_PRIVATE_CRITERION';const lane = Object.keys(config.lanes)[0];await cli(root, env, 'add', lane, 'initial private item', '--criterion', marker);@@ -381,9 +374,7 @@ test('[H3,H16] three cloned linked replicas order competing claims and recover l/** Run fixture Git with an isolated identity and report its stderr on failure. */function gitAt(root, env, ...args) {- const result = spawnSync('git', args, { cwd: root, env, encoding: 'utf8' });- assert.equal(result.status, 0, `git ${args.join(' ')}: ${result.stderr}`);- return result.stdout.trim();+ return runFixtureGit(args, { cwd: root, env, encoding: 'utf8' });}/** Resolve the common Git directory used by a clone and its worktree. */diff --git a/test/relay-deploy.test.js b/test/relay-deploy.test.jsindex 34e7f668..a93aae29 100644--- a/test/relay-deploy.test.js+++ b/test/relay-deploy.test.js@@ -1,6 +1,7 @@/** Exercise the deploy smoke script against a private loopback relay [H5,H18]. */import assert from 'node:assert/strict';import { spawn } from 'node:child_process';+import { performance } from 'node:perf_hooks';import { createServer } from 'node:http';import { existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, rmSync, statSync, copyFileSync } from 'node:fs';import { join, resolve } from 'node:path';@@ -9,6 +10,7 @@ import { test } from 'node:test';import { ENGINE_VERSION } from '../src/machine.js';import { relayClientFixture } from './relay-client-fixture.js';import { githubFixture } from './relay-fixture.js';+import { reportFixtureChildFailure, safeFixtureDiagnostic } from './fixture-child.js';const SMOKE = resolve(import.meta.dirname, '../relay/smoke.mjs');const SERVER = resolve(import.meta.dirname, '../relay/server.mjs');@@ -62,9 +64,19 @@ function copiedServer(t, image, port, provider) {};mkdirSync(env.HOME, { recursive: true, mode: 0o700 });t.after(() => rmSync(privateHome, { recursive: true, force: true }));- const child = spawn(process.execPath, [join(image, 'relay/server.mjs')], { cwd: image, env, stdio: ['ignore', 'ignore', 'ignore'] });+ const command = process.execPath;+ const args = [join(image, 'relay/server.mjs')];+ const started = performance.now();+ const child = spawn(command, args, { cwd: image, env, stdio: ['ignore', 'ignore', 'pipe'] });+ let stderr = '';+ child.stderr.setEncoding('utf8').on('data', part => { stderr += part; });+ child.once('close', (status, signal) => {+ if (child.fixtureExpectedStop || (status === 0 && !signal)) return;+ child.fixtureFailure = reportFixtureChildFailure({ command, args, status, signal, elapsedMs: performance.now() - started, stderr, env });+ });t.after(async () => {if (child.exitCode !== null || child.signalCode !== null) return;+ child.fixtureExpectedStop = true;child.kill('SIGTERM');if (await childClosesWithin(child, 5000)) return;child.kill('SIGKILL');@@ -125,22 +137,37 @@ function setting(text, pattern, description) {/** Run the checked-in smoke script in a private real repository without retaining its output. */function runSmoke(box, address) {return new Promise((resolveResult, reject) => {- const child = spawn(process.execPath, [SMOKE, address], { cwd: box.root, env: box.env, stdio: ['ignore', 'pipe', 'pipe'] });+ const command = process.execPath;+ const args = [SMOKE, address];+ const started = performance.now();+ const child = spawn(command, args, { cwd: box.root, env: box.env, stdio: ['ignore', 'pipe', 'pipe'] });let stdout = '';+ let stderr = '';let safeFailure = '';- const timer = setTimeout(() => child.kill('SIGKILL'), 90_000);child.stdout.setEncoding('utf8').on('data', (part) => { stdout += part; });child.stderr.setEncoding('utf8').on('data', (part) => {+ stderr += part;const line = part.split('\n').find((entry) => entry.startsWith('relay smoke failed:'));- if (line) safeFailure = line;+ if (line) safeFailure = safeFixtureDiagnostic(line, box.env);+ });+ child.once('error', (error) => {+ reportFixtureChildFailure({ command, args, status: null, signal: null, elapsedMs: performance.now() - started, stderr, env: box.env, detail: error.message });+ reject(error);});- child.once('error', (error) => { clearTimeout(timer); reject(error); });child.once('close', (code, signal) => {- clearTimeout(timer);- if (signal) return reject(new Error('private relay deployment smoke did not complete'));- if (code !== 0) return resolveResult({ code, failure: safeFailure });+ if (signal) {+ const failure = reportFixtureChildFailure({ command, args, status: code, signal, elapsedMs: performance.now() - started, stderr, env: box.env, detail: safeFailure || 'smoke process ended before producing a safe summary' });+ return reject(new Error(failure));+ }+ if (code !== 0) {+ const failure = reportFixtureChildFailure({ command, args, status: code, signal, elapsedMs: performance.now() - started, stderr, env: box.env, detail: safeFailure });+ return resolveResult({ code, failure });+ }try { resolveResult({ code, result: JSON.parse(stdout) }); }- catch { reject(new Error('private relay deployment smoke did not return its safe summary')); }+ catch (error) {+ const failure = reportFixtureChildFailure({ command, args, status: code, signal, elapsedMs: performance.now() - started, stderr, env: box.env, detail: `smoke produced invalid safe summary: ${error.message}` });+ reject(new Error(failure));+ }});});}@@ -271,10 +298,18 @@ test('[H5,H18] the container entry point serves readiness and stays available',GITHUB_APP_CLIENT_SECRET: provider.config.clientSecret,GITHUB_APP_PRIVATE_KEY: provider.config.privateKey,};- const child = spawn(process.execPath, [SERVER], { cwd: resolve(import.meta.dirname, '..'), env, stdio: ['ignore', 'ignore', 'pipe'] });- child.stderr.resume();+ const command = process.execPath;+ const args = [SERVER];+ const started = performance.now();+ const child = spawn(command, args, { cwd: resolve(import.meta.dirname, '..'), env, stdio: ['ignore', 'ignore', 'pipe'] });+ let stderr = '';+ child.stderr.setEncoding('utf8').on('data', part => { stderr += part; });+ child.once('close', (status, signal) => {+ if (child.fixtureExpectedStop || (status === 0 && !signal)) return;+ child.fixtureFailure = reportFixtureChildFailure({ command, args, status, signal, elapsedMs: performance.now() - started, stderr, env });+ });t.after(async () => {- if (child.exitCode === null) child.kill('SIGTERM');+ if (child.exitCode === null) { child.fixtureExpectedStop = true; child.kill('SIGTERM'); }if (child.exitCode === null) await new Promise((ready) => {const timer = setTimeout(() => { child.kill('SIGKILL'); ready(); }, 5000);child.once('close', () => { clearTimeout(timer); ready(); });diff --git a/test/relay-journal.test.js b/test/relay-journal.test.jsindex cd46759a..bdd6c33a 100644--- a/test/relay-journal.test.js+++ b/test/relay-journal.test.js@@ -1,15 +1,16 @@/** Opaque relay transport ordering, independent of the pending record interpretation [A4,H7]. */import assert from 'node:assert/strict';-import { spawn } from 'node:child_process';import { mkdtempSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';-import { test } from 'node:test';+import { after, test } from 'node:test';+import { cleanupFixtureChildren, runFixtureChildAsync } from './fixture-child.js';import { createRelayJournal } from '../relay/journal.js';const ID = 'a'.repeat(32);const AGENT = { kind: 'agent', userId: '101', agent: 'client-one' };const PERSON = { kind: 'person', userId: '101' };+after(cleanupFixtureChildren);/** Give each test a private directory and close every journal before deleting its files. */function fixture(t, options = {}) {@@ -97,19 +98,10 @@ test('[A4,H7] two real processes cannot publish the same next sequence', async (].join('\n'));/** Capture only the synthetic sequence/refusal result of one owned worker. */function run(label) {- return new Promise((done, fail) => {- const child = spawn(process.execPath, [worker, box.directory, ID, label], { stdio: ['ignore', 'pipe', 'pipe'] });- let out = '';- let diagnostics = '';- child.stdout.on('data', (chunk) => { out += chunk; });- child.stderr.on('data', (chunk) => { diagnostics += chunk; });- const timer = setTimeout(() => { child.kill('SIGKILL'); fail(new Error('journal worker timed out')); }, 10_000);- child.once('error', (error) => { clearTimeout(timer); fail(error); });- child.once('exit', (code) => {- clearTimeout(timer);- if (code !== 0) return fail(new Error('journal worker failed: ' + diagnostics));- try { done(JSON.parse(out)); } catch (error) { fail(error); }- });+ return runFixtureChildAsync(process.execPath, [worker, box.directory, ID, label]).then((result) => {+ if (result.failure) throw new Error(result.failure);+ try { return JSON.parse(result.stdout); }+ catch { throw new Error(result.context); }});}const results = await Promise.all([run('first record'), run('second record')]);diff --git a/test/relay-person-recovery.test.js b/test/relay-person-recovery.test.jsindex b8937491..0f7f7593 100644--- a/test/relay-person-recovery.test.js+++ b/test/relay-person-recovery.test.js@@ -1,10 +1,11 @@/** A second linked native device safely takes over an expired person request [H12,H16]. */import assert from 'node:assert/strict';-import { spawn, spawnSync } from 'node:child_process';+import { after } from 'node:test';import { mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { join, resolve } from 'node:path';import { pathToFileURL } from 'node:url';import { test } from 'node:test';+import { cleanupFixtureChildren, runFixtureChildAsync, runFixtureGit } from './fixture-child.js';import * as store from '../src/board.js';import { preparePersonRequest } from '../src/person-request.js';import { personRequestRecords, personRequestStatuses } from '../src/relay-requests.js';@@ -17,22 +18,14 @@ const EXCHANGE_MODULE = pathToFileURL(resolve(import.meta.dirname, '../src/exchaconst RELAY_MODULE = pathToFileURL(resolve(import.meta.dirname, '../src/relay.js')).href;const CONFIG_MODULE = pathToFileURL(resolve(import.meta.dirname, '../src/config.js')).href;const LANES_MODULE = pathToFileURL(resolve(import.meta.dirname, '../src/lanes.js')).href;+after(cleanupFixtureChildren);/** Run an isolated fixture child without copying its private output into assertion diagnostics. */function child(cwd, env, argv) {- return new Promise((done, fail) => {- const processChild = spawn(process.execPath, argv, { cwd, env, stdio: ['ignore', 'pipe', 'pipe'] });- let stdout = '';- const timer = setTimeout(() => processChild.kill('SIGKILL'), 25000);- processChild.stdout.setEncoding('utf8').on('data', part => { stdout += part; });- processChild.stderr.resume();- processChild.once('error', error => { clearTimeout(timer); fail(error); });- processChild.once('close', (code, signal) => {- clearTimeout(timer);- if (signal) return fail(new Error('private request recovery child exceeded its deadline'));- try { done({ code, document: JSON.parse(stdout) }); }- catch { fail(new Error('private request recovery child did not return its result')); }- });+ return runFixtureChildAsync(process.execPath, argv, { cwd, env }).then((result) => {+ if (result.error) throw new Error(result.failure);+ try { return { code: result.status, document: JSON.parse(result.stdout), stderr: result.failure ?? result.stderr, failure: result.failure }; }+ catch { throw new Error(result.failure ?? result.context); }});}@@ -92,7 +85,7 @@ test('[H12,H16] an expired native executor lease transfers once and the old deviassert.equal((await posted.json()).event.kind, 'request');const originalClaim = await claimOnly(box.root, box.env, requestId);- assert.equal(originalClaim.code, 0);+ assert.equal(originalClaim.code, 0, originalClaim.failure ?? originalClaim.stderr);assert.equal(originalClaim.document.result, true);const originalExecutor = originalClaim.document.executor;@@ -109,11 +102,13 @@ test('[H12,H16] an expired native executor lease transfers once and the old deviPULLBOARD_HOME: join(secondHome, '.pullboard'),PULLBOARD_MACHINE_HOME: join(secondHome, 'machine'),};- assert.equal(spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: secondRoot, env: secondEnv }).status, 0);- assert.equal((await cli(secondRoot, secondEnv, 'init')).code, 0);+ runFixtureGit(['init', '-q', '-b', 'main'], { cwd: secondRoot, env: secondEnv });+ const initialized = await cli(secondRoot, secondEnv, 'init');+ assert.equal(initialized.code, 0, initialized.failure ?? initialized.stderr);const snapshot = join(secondRoot, 'native-board.json');writeFileSync(snapshot, JSON.stringify(await privateExport(box.root, box.env)), { mode: 0o600 });- assert.equal((await cli(secondRoot, secondEnv, 'import', snapshot)).code, 0);+ const imported = await cli(secondRoot, secondEnv, 'import', snapshot);+ assert.equal(imported.code, 0, imported.failure ?? imported.stderr);const secondState = JSON.parse(readFileSync(box.linkFile, 'utf8'));delete secondState.requestDevice;@@ -125,7 +120,8 @@ test('[H12,H16] an expired native executor lease transfers once and the old deviwriteFileSync(join(keyDirectory, link.board + '.key'), readFileSync(box.keyFile), { mode: 0o600 });// Before the ten-minute lease expires, the independent device cannot run the request.- assert.equal((await cli(secondRoot, secondEnv, 'status')).code, 0);+ const status = await cli(secondRoot, secondEnv, 'status');+ assert.equal(status.code, 0, status.failure ?? status.stderr);const beforeExpiry = await privateExport(secondRoot, secondEnv);assert.equal(beforeExpiry.tables.shout.filter(row => row.shout_text === 'RECOVERY_SHOUT_ONCE').length, 0);let board = store.openBoard(join(secondRoot, '.git', 'pullboard', 'board.sqlite'));@@ -133,8 +129,8 @@ test('[H12,H16] an expired native executor lease transfers once and the old devifinally { store.closeBoard(board); }box.advance(11 / 1440);- assert.equal((await cli(secondRoot, secondEnv, 'status')).code, 0,- 'the next native command after expiry claims and executes through the production CLI');+ const resumed = await cli(secondRoot, secondEnv, 'status');+ assert.equal(resumed.code, 0, resumed.failure ?? 'the next native command after expiry claims and executes through the production CLI');const afterTakeover = await privateExport(secondRoot, secondEnv);assert.equal(afterTakeover.tables.shout.filter(row => row.shout_text === 'RECOVERY_SHOUT_ONCE').length, 1);const secondExecutor = JSON.parse(readFileSync(secondLinkFile, 'utf8')).requestDevice;diff --git a/test/relay-sealed.test.js b/test/relay-sealed.test.jsindex 27bc40e2..88767b66 100644--- a/test/relay-sealed.test.js+++ b/test/relay-sealed.test.js@@ -1,13 +1,14 @@/** Two real clients and encrypted CLI records exercise the relay without sharing their key [A4,H7]. */import assert from 'node:assert/strict';import { createCipheriv, createDecipheriv, createHash, randomBytes } from 'node:crypto';-import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { execFileSync, spawnSync } from 'node:child_process';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { delimiter, join, resolve } from 'node:path';import { pathToFileURL } from 'node:url';import { createServer } from 'node:http';-import { test } from 'node:test';+import { after, test } from 'node:test';+import { cleanupFixtureChildren, runFixtureChild, runFixtureGit, runFixtureChildAsync } from './fixture-child.js';import { serveRelay } from '../relay/service.js';import { createRelayAuth } from '../relay/auth.js';import { createGitHubClient } from '../relay/github.js';@@ -18,6 +19,8 @@ import { checkpointSequence, engineReceipt, prepareEngineMove } from '../src/engimport { seal as sealMove } from '../src/seal.js';import { ENGINE_VERSION } from '../src/machine.js';+after(cleanupFixtureChildren);+/** Seal on the test client only; nonce, authentication tag and ciphertext are opaque to the server. */function seal(key, value, binding) {const nonce = randomBytes(12);@@ -53,12 +56,11 @@ async function fixture(t) {writeFileSync(pullboardPath, `#!/bin/sh\nexec ${quoteShell(process.execPath)} ${quoteShell(cliPath)} "$@"\n`);chmodSync(pullboardPath, 0o755);env.PATH = [privateBin, env.PATH].filter(Boolean).join(delimiter);- const git = spawnSync('git', ['init', '-q', '-b', 'main'], { cwd: root, env, encoding: 'utf8' });- assert.equal(git.status, 0, git.stderr);+ runFixtureGit(['init', '-q', '-b', 'main'], { cwd: root, env, encoding: 'utf8' });/** Run the current CLI only in the fixture's private home and Git repository. */function cli(...args) {- const result = spawnSync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, encoding: 'utf8' });- assert.equal(result.status, 0, result.stderr);+ const result = runFixtureChild(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, encoding: 'utf8' });+ assert.equal(result.status, 0, result.failure ?? result.stderr);return result.stdout;}cli('init');@@ -99,19 +101,12 @@ async function fixture(t) {/** Run a linked CLI asynchronously so the real relay can serve it, keeping credentials out of diagnostics. */function replayClient(root, env, ...args) {- return new Promise((done, fail) => {- const child = spawn(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json'], { cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'] });- let stdout = '';- const timer = setTimeout(() => child.kill('SIGKILL'), 25000);- child.stdout.setEncoding('utf8').on('data', part => { stdout += part; });- child.stderr.resume();- child.once('error', error => { clearTimeout(timer); fail(error); });- child.once('close', code => {- clearTimeout(timer);- if (code !== 0) return fail(new Error('isolated linked CLI command failed'));- try { done(JSON.parse(stdout)); } catch { fail(new Error('isolated linked CLI did not return JSON')); }+ return runFixtureChildAsync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json'], { cwd: root, env })+ .then((result) => {+ if (result.failure) throw new Error(result.failure);+ try { return JSON.parse(result.stdout); }+ catch { throw new Error(result.failure ?? result.context); }});- });}/** Replay through the native CLI while acknowledging but suppressing checkpoint writes to the fixture relay. */@@ -134,18 +129,10 @@ function replayClientWithoutCheckpoint(root, env) {const code = await main(['export', '--json'], { cwd: process.cwd(), stdout: { write(part) { output += part; } }, stderr: { write(part) { diagnostics += part; } } });console.log(JSON.stringify({ code, checkpointWrites, document: JSON.parse(output), diagnosticCount: diagnostics.length }));`;- return new Promise((done, fail) => {- const child = spawn(process.execPath, ['--input-type=module', '-e', script], { cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'] });- let stdout = '';- const timer = setTimeout(() => child.kill('SIGKILL'), 25000);- child.stdout.setEncoding('utf8').on('data', part => { stdout += part; });- child.stderr.resume();- child.once('error', error => { clearTimeout(timer); fail(error); });- child.once('close', code => {- clearTimeout(timer);- if (code !== 0) return fail(new Error('isolated native client failed during checkpoint-suppressed replay'));- try { done(JSON.parse(stdout)); } catch { fail(new Error('checkpoint-suppressed native client returned invalid JSON')); }- });+ return runFixtureChildAsync(process.execPath, ['--input-type=module', '-e', script], { cwd: root, env }).then((result) => {+ if (result.failure) throw new Error(result.failure);+ try { return JSON.parse(result.stdout); }+ catch { throw new Error(result.failure ?? result.context); }});}@@ -177,20 +164,12 @@ async function independentReplayOrigin(t, origin) {/** Capture a real linked command's warnings and structured refusal without changing its exit status. */function replayResult(root, env, ...args) {- return new Promise((done, fail) => {- const child = spawn(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json'], { cwd: root, env, stdio: ['ignore', 'pipe', 'pipe'] });- let stdout = '', stderr = '';- const timer = setTimeout(() => child.kill('SIGKILL'), 25000);- child.stdout.setEncoding('utf8').on('data', part => { stdout += part; });- child.stderr.setEncoding('utf8').on('data', part => { stderr += part; });- child.once('error', error => { clearTimeout(timer); fail(error); });- child.once('close', code => {- clearTimeout(timer);- if (code === null) return fail(new Error('isolated relay command did not finish'));- try { done({ document: JSON.parse(stdout), stderr, status: code }); }- catch { fail(new Error('isolated relay read did not return JSON')); }+ return runFixtureChildAsync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json'], { cwd: root, env })+ .then((result) => {+ if (result.error) throw new Error(result.failure);+ try { return { document: JSON.parse(result.stdout), stderr: result.failure ?? result.stderr, status: result.status, failure: result.failure }; }+ catch { throw new Error(result.failure ?? result.context); }});- });}test('sealed agent shout cannot answer a person decision on either independent client [H16,B26]', async t => {diff --git a/test/release.test.js b/test/release.test.jsindex 1645f96f..e8cee67f 100644--- a/test/release.test.js+++ b/test/release.test.js@@ -5,6 +5,7 @@*/import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -27,7 +28,7 @@ test('a packed release installs with no network and runs the whole loop from a fassert.deepEqual(tops, PUBLISHED, 'the tarball holds the package and nothing else: no tests, no board');const prefix = join(dir, 'prefix');- const install = spawnSync('npm', ['install', '--global', '--prefix', prefix, '--offline', '--no-audit', '--no-fund', join(dir, packed.filename)], { env: npmEnv, encoding: 'utf8' });+ const install = runFixtureChild('npm', ['install', '--global', '--prefix', prefix, '--offline', '--no-audit', '--no-fund', join(dir, packed.filename)], { env: npmEnv, encoding: 'utf8' });assert.equal(install.status, 0, `installs with no network: ${install.stderr}`);const installed = join(prefix, 'lib', 'node_modules', 'pullboard');assert.equal(JSON.parse(readFileSync(join(installed, 'package.json'), 'utf8')).dependencies, undefined, 'no dependencies');@@ -45,10 +46,10 @@ test('a packed release installs with no network and runs the whole loop from a fGIT_COMMITTER_EMAIL: '[email protected]',PULLBOARD_HOME: join(dir, 'home'),};- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env });/** Run the installed pullboard and require it to succeed. */const pullboard = (cwd, ...args) => {- const result = spawnSync(bin, args, { cwd, env, encoding: 'utf8', timeout: 120_000 });+ const result = runFixtureChild(bin, args, { cwd, env, encoding: 'utf8' });assert.equal(result.status, 0, `pullboard ${args.join(' ')}: ${result.stderr}${result.stdout}`);return result.stdout;};diff --git a/test/resources.test.js b/test/resources.test.jsindex 5bf8ad13..aa4e5fb1 100644--- a/test/resources.test.js+++ b/test/resources.test.js@@ -1,6 +1,8 @@/** Real-process resource queue and lease coverage [Q1,Q2,Q3]. */import assert from 'node:assert/strict';import { spawn, spawnSync } from 'node:child_process';+import { performance } from 'node:perf_hooks';+import { reportFixtureChildFailure, runFixtureChild } from './fixture-child.js';import { once } from 'node:events';import { chmodSync, existsSync, mkdtempSync, mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';@@ -57,8 +59,8 @@ function fixture() {const second = join(dir, 'repo-b');for (const repo of [first, second]) {mkdirSync(repo);- const result = spawnSync('git', ['init', '-q', repo], { encoding: 'utf8' });- assert.equal(result.status, 0, result.stderr);+ const result = runFixtureChild('git', ['init', '-q', repo], { encoding: 'utf8' });+ assert.equal(result.status, 0, result.failure);}return { dir, home, first, second, env: { ...process.env, PULLBOARD_HOME: home } };}@@ -112,20 +114,33 @@ function worker(box, { name = 'gate', capacity = 1, scope = 'machine', root = boconst workerArgs = ['--input-type=module', '-e', WORKER, name, String(capacity), scope, root, agent, String(stallMs), String(landing)];const executable = sandboxProcessInfo ? '/usr/bin/sandbox-exec' : process.execPath;const args = sandboxProcessInfo ? ['-p', PROCESS_INFO_POLICY, process.execPath, ...workerArgs] : workerArgs;+ const startedAt = performance.now();+ const workerEnv = { ...box.env, ...env };const child = spawn(executable, args, {- env: { ...box.env, ...env }, stdio: ['pipe', 'pipe', 'pipe'],+ env: workerEnv, stdio: ['pipe', 'pipe', 'pipe'],});+ child.startedAt = startedAt;+ child.spawnEnv = workerEnv;child.lines = createInterface({ input: child.stdout });child.errors = '';child.pendingLines = [];child.lineWaiters = [];child.exitResult = null;- child.finished = new Promise((resolveExit) => child.once('exit', (code, signal) => {+ child.failureReported = false;+ let spawnError = null;+ child.once('error', (error) => { spawnError = error; });+ child.finished = new Promise((resolveExit) => child.once('close', (code, signal) => {child.exitResult = { code, signal };CHILDREN.delete(child);+ if ((code !== 0 || signal || spawnError) && !child.failureReported) {+ child.failureReported = true;+ child.failure = reportFixtureChildFailure({ command: executable, args, status: code, signal,+ elapsedMs: performance.now() - startedAt, stderr: child.errors, env: workerEnv,+ detail: spawnError?.message ?? '' });+ }for (const waiter of child.lineWaiters.splice(0)) {clearTimeout(waiter.timer);- waiter.reject(new Error(`worker exited ${code}/${signal}: ${child.errors}`));+ waiter.reject(new Error(child.failure ?? `worker exited ${code}/${signal}: ${child.errors}`));}resolveExit(child.exitResult);}));@@ -142,11 +157,16 @@ function worker(box, { name = 'gate', capacity = 1, scope = 'machine', root = bo/** Read the next worker event, failing promptly with its stderr if it exits unexpectedly. */async function event(child, timeoutMs = 10_000) {if (child.pendingLines.length) return JSON.parse(child.pendingLines.shift());- if (child.exitResult) throw new Error(`worker exited ${child.exitResult.code}/${child.exitResult.signal}: ${child.errors}`);+ if (child.exitResult) throw new Error(child.failure ?? `worker exited ${child.exitResult.code}/${child.exitResult.signal}: ${child.errors}`);const line = await new Promise((resolveLine, reject) => {const waiter = { resolve: resolveLine, reject, timer: setTimeout(() => {child.lineWaiters.splice(child.lineWaiters.indexOf(waiter), 1);- reject(new Error(`worker timed out: ${child.errors}`));+ child.failureReported = true;+ const failure = reportFixtureChildFailure({ command: child.spawnfile, args: child.spawnargs.slice(1),+ status: child.exitResult?.code ?? null, signal: child.exitResult?.signal ?? null,+ elapsedMs: performance.now() - child.startedAt, stderr: child.errors, env: child.spawnEnv,+ detail: `worker event wait expired after ${timeoutMs}ms` });+ reject(new Error(failure));}, timeoutMs) };child.lineWaiters.push(waiter);});diff --git a/test/review-queue-cli.test.js b/test/review-queue-cli.test.jsindex 651167c2..04ec4033 100644--- a/test/review-queue-cli.test.js+++ b/test/review-queue-cli.test.js@@ -1,7 +1,7 @@/** Real CLI and authenticated API review suggestions preserve explicit build and review intent [Q1,V15,A1,A2]. */import assert from 'node:assert/strict';import { createHash, randomUUID } from 'node:crypto';-import { execFileSync } from 'node:child_process';+import { runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -40,7 +40,7 @@ async function project(t, ratio = 3) {GIT_AUTHOR_NAME: 'Review fixture', GIT_AUTHOR_EMAIL: '[email protected]',GIT_COMMITTER_NAME: 'Review fixture', GIT_COMMITTER_EMAIL: '[email protected]' };/** Execute private Git commands with synthetic identity and the actual hook shim. */- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, stdio: 'pipe', encoding: 'utf8' });+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env, stdio: 'pipe', encoding: 'utf8' });let at = Date.parse('2026-10-08T12:00:00.000Z');const clock = { now: () => new Date(at), advance: (ms) => { at += ms; } };const box = { root, dir, clock, git };diff --git a/test/row-decisions.test.js b/test/row-decisions.test.jsindex 93830a19..412b1952 100644--- a/test/row-decisions.test.js+++ b/test/row-decisions.test.js@@ -1,6 +1,8 @@/** Person-authored row decisions stay on the board until a coordinator applies them [B26,S18,S19,C7]. */import assert from 'node:assert/strict';-import { execFileSync, spawn, spawnSync } from 'node:child_process';+import { spawn, spawnSync } from 'node:child_process';+import { performance } from 'node:perf_hooks';+import { reportFixtureChildFailure, runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -74,12 +76,12 @@ function sandbox() {Object.assign(env, FIXTURE_GIT_ENV);/** Run Git with the fixture's private identity and configuration. */function git(cwd, ...args) {- return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ return runFixtureGit(args, { cwd, env });}/** Run the real CLI with a clean person environment and optional explicit markers. */function run(cwd, args, extraEnv = {}) {- return spawnSync(process.execPath, [BIN, ...args], {- cwd, env: { ...personEnvironment(env), ...FIXTURE_GIT_ENV, ...extraEnv }, encoding: 'utf8', timeout: 15_000,+ return runFixtureChild(process.execPath, [BIN, ...args], {+ cwd, env: { ...personEnvironment(env), ...FIXTURE_GIT_ENV, ...extraEnv }, encoding: 'utf8',});}return { dir, env, git, run };@@ -163,8 +165,11 @@ function sourceRow(box, file, id) {/** Start the private real view with clean person credentials and expose authenticated requests. */async function startView(t, box, extraEnv = {}) {- const child = spawn(process.execPath, [BIN, 'view', '--no-open', '--port', '0', '--json'], {- cwd: box.root, env: { ...personEnvironment(box.env), ...extraEnv, CODEX_SHELL: 'private-agent-view-host' }, stdio: ['ignore', 'pipe', 'pipe'],+ const args = [BIN, 'view', '--no-open', '--port', '0', '--json'];+ const env = { ...personEnvironment(box.env), ...extraEnv, CODEX_SHELL: 'private-agent-view-host' };+ const startedAt = performance.now();+ const child = spawn(process.execPath, args, {+ cwd: box.root, env, stdio: ['ignore', 'pipe', 'pipe'],});let stdout = '';let stderrTail = [];@@ -201,14 +206,29 @@ async function startView(t, box, extraEnv = {}) {if (child.exitCode === null && child.signalCode === null) await stopView('SIGKILL');});const document = await new Promise((resolveDocument, rejectDocument) => {- const timer = setTimeout(() => rejectDocument(new Error(`view did not start: ${stderrTail.join('\n')}\n${stderrPartial}`)), 10_000);+ let settled = false;+ const failStartup = (detail, status = child.exitCode, signal = child.signalCode) => {+ if (settled) return;+ settled = true;+ clearTimeout(timer);+ const stderr = [...stderrTail, ...(stderrPartial ? [stderrPartial] : [])].slice(-20).join('\n');+ rejectDocument(new Error(reportFixtureChildFailure({ command: process.execPath, args, status, signal,+ elapsedMs: performance.now() - startedAt, stderr, env, detail })));+ };+ const timer = setTimeout(() => failStartup('view readiness deadline (10000ms) expired'), 10_000);child.stdout.on('data', (chunk) => {stdout += chunk;- try { resolveDocument(JSON.parse(stdout)); clearTimeout(timer); }+ try {+ const value = JSON.parse(stdout);+ if (settled) return;+ settled = true;+ clearTimeout(timer);+ resolveDocument(value);+ }catch { /* Wait until the one JSON document is complete. */ }});- child.once('error', rejectDocument);- child.once('close', () => rejectDocument(new Error(`view exited early: ${stderrTail.join('\n')}\n${stderrPartial}`)));+ child.once('error', (error) => failStartup(error.message, null, null));+ child.once('close', (code, signal) => failStartup('view exited before readiness', code, signal));});const address = new URL(document.url);const key = address.searchParams.get('k');@@ -412,7 +432,8 @@ test('[B26,S18,S19] stale row text refuses apply without changing any approved r/** Create a real SSH Ed25519 key pair for the required-signer decision case. */function makeKey(path) {- execFileSync('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-C', '[email protected]', '-f', path], { stdio: 'pipe' });+ const generated = runFixtureChild('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-C', '[email protected]', '-f', path], { encoding: 'utf8' });+ assert.equal(generated.status, 0, generated.failure);return { privateKey: path, publicKey: `${path}.pub` };}diff --git a/test/settings.test.js b/test/settings.test.jsindex 2b1879f8..68bc9496 100644--- a/test/settings.test.js+++ b/test/settings.test.js@@ -3,14 +3,14 @@ import assert from 'node:assert/strict';import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';-import { spawnSync } from 'node:child_process';import { test } from 'node:test';+import { runFixtureChild } from './fixture-child.js';const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');/** Run settings in an isolated machine home, returning its structured CLI result. */function settings(home, ...args) {- return spawnSync(process.execPath, [BIN, 'settings', ...args, '--json'], {+ return runFixtureChild(process.execPath, [BIN, 'settings', ...args, '--json'], {encoding: 'utf8', env: { ...process.env, PULLBOARD_HOME: home },});}diff --git a/test/show.test.js b/test/show.test.jsindex 57ff15d7..250aad23 100644--- a/test/show.test.js+++ b/test/show.test.js@@ -3,7 +3,8 @@* note in full on --history or --json.*/import assert from 'node:assert/strict';-import { execFileSync, spawnSync } from 'node:child_process';+import { execFileSync } from 'node:child_process';+import { runFixtureChild } from './fixture-child.js';import { mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -98,7 +99,7 @@ test('show prints the latest verdict in full and earlier ones as one line; --hisstore.closeBoard(board);}- const run = (...args) => spawnSync(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });const plain = run('show', '1');assert.equal(plain.status, 0, plain.stderr);const verdictLines = plain.stdout.split('\n').filter((line) => /^(REJECT|ACCEPT) /.test(line));diff --git a/test/signoff.test.js b/test/signoff.test.jsindex 2ae6fefc..04dd9796 100644--- a/test/signoff.test.js+++ b/test/signoff.test.js@@ -1,6 +1,7 @@/** SSH sign-off opt-in, rotation, row requirements and tamper rejection [S17,S18,S19,S20,S21]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { fixtureChildMessage, runFixtureChild, runFixtureGit } from './fixture-child.js';import { createHash } from 'node:crypto';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';@@ -20,7 +21,8 @@ function shellWord(value) { return `'${value.replaceAll("'", "'\\''")}'`; }/** Create a throwaway OpenSSH Ed25519 private and public key pair. */function makeKey(path) {- execFileSync('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-C', '[email protected]', '-f', path], { stdio: 'pipe' });+ const result = runFixtureChild('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-C', '[email protected]', '-f', path], { encoding: 'utf8' });+ assert.equal(result.status, 0, fixtureChildMessage(result));return { privateKey: path, publicKey: `${path}.pub` };}@@ -49,8 +51,8 @@ function fixture(t) {GIT_COMMITTER_EMAIL: '[email protected]',PULLBOARD_HOME: join(dir, 'home'),};- const git = (...args) => execFileSync('git', args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' }).trim();- const run = (...args) => spawnSync(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });+ const git = (...args) => runFixtureGit(args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' });+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });git('init', '-q', '-b', 'main');git('config', 'user.name', 'CO');git('config', 'user.email', '[email protected]');diff --git a/test/spec.test.js b/test/spec.test.jsindex fd04c80d..23c8e1ec 100644--- a/test/spec.test.js+++ b/test/spec.test.js@@ -3,6 +3,7 @@*/import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -144,8 +145,8 @@ test('spec check lists primary-branch collisions as known warnings [A5]', (t) =>test('spec check uses the retained trunk after its coordinator checkout detaches [A5]', (t) => {const practice = '# Practice\n\n## P\n- P1 [draft] A local rule.\n';const box = specBox(t, { practice });- const gitAt = (cwd, ...args) => execFileSync('git', args, { cwd, env: box.env, encoding: 'utf8', stdio: 'pipe' });- const runAt = (cwd, ...args) => spawnSync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], {+ const gitAt = (cwd, ...args) => runFixtureGit(args, { cwd, env: box.env, encoding: 'utf8', stdio: 'pipe' });+ const runAt = (cwd, ...args) => runFixtureChild(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], {cwd, env: box.env, encoding: 'utf8',});gitAt(box.root, 'branch', '-m', 'trunk');@@ -194,8 +195,8 @@ test('a grammar-1 repair can commit after grammar 2 was already recorded [A5,S8]GIT_COMMITTER_EMAIL: '[email protected]',PULLBOARD_HOME: join(root, '.home'),};- const git = (...args) => execFileSync('git', args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' });- const command = (...args) => spawnSync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, encoding: 'utf8' });+ const git = (...args) => runFixtureGit(args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' });+ const command = (...args) => runFixtureChild(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, encoding: 'utf8' });git('init', '-q', '-b', 'main');git('config', 'user.name', 'Test Agent');git('config', 'user.email', '[email protected]');@@ -369,8 +370,8 @@ function specBox(t, { specName = 'SPEC.md', practiceName = 'PRACTICE.md', practidelete env.PULLBOARD_RELAY_TOKEN;// These isolated signoff fixtures model the same person terminal as the suite runner.for (const marker of [...AGENT_SHELL_MARKERS, ...SSH_SHELL_MARKERS]) delete env[marker];- const git = (...args) => execFileSync('git', args, { cwd: root, env, stdio: 'pipe', encoding: 'utf8' });- const command = (...args) => spawnSync(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, encoding: 'utf8' });+ const git = (...args) => runFixtureGit(args, { cwd: root, env, stdio: 'pipe', encoding: 'utf8' });+ const command = (...args) => runFixtureChild(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, encoding: 'utf8' });const run = (...args) => command('spec', ...args);git('init', '-q', '-b', 'main');git('config', 'user.name', 'Test Agent');diff --git a/test/stale-frozen-items.test.js b/test/stale-frozen-items.test.jsindex 214e2b71..03f5688d 100644--- a/test/stale-frozen-items.test.js+++ b/test/stale-frozen-items.test.js@@ -1,6 +1,7 @@/** Approved row edits identify every affected frozen item without rewriting receipts [S19,V3]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -52,13 +53,13 @@ function project(t) {GIT_CONFIG_GLOBAL: '/dev/null',GIT_CONFIG_NOSYSTEM: '1',});- /** Run a bounded real Pullboard CLI process in one fixture checkout. */+ /** Run the real Pullboard CLI in one fixture checkout; the test runner owns the hang bound. */function pullboard(cwd, ...args) {- return spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 30_000 });+ return runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });}/** Run real Git with isolated identity while preserving hook-provided index variables. */function git(cwd, ...args) {- return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ return runFixtureGit(args, { cwd, env });}git(root, 'init', '-q', '-b', 'main');git(root, 'config', 'user.name', 'Stale-frozen fixture');@@ -72,7 +73,7 @@ function project(t) {writeFileSync(join(root, 'SPEC.md'), OLD_SPEC);mkdirSync(join(root, 'web'));git(root, 'add', '-A');- const initial = spawnSync('git', ['commit', '-q', '-m', 'chore: initialize stale-frozen fixture'], { cwd: root, env, encoding: 'utf8', timeout: 30_000 });+ const initial = runFixtureChild('git', ['commit', '-q', '-m', 'chore: initialize stale-frozen fixture'], { cwd: root, env, encoding: 'utf8' });assert.equal(initial.status, 0, `${initial.stdout}${initial.stderr}`);git(root, 'worktree', 'add', '-q', web, '-b', 'web/stale-frozen');const joined = pullboard(web, 'join', 'web');@@ -106,7 +107,7 @@ function submit(box, id, name) {mkdirSync(join(box.web, 'web'), { recursive: true });writeFileSync(join(box.web, relative), `${name}\n`);box.git(box.web, 'add', relative);- const committed = spawnSync('git', ['commit', '-m', `feat(web): build ${name} [G1]`], { cwd: box.web, env: box.env, encoding: 'utf8', timeout: 30_000 });+ const committed = runFixtureChild('git', ['commit', '-m', `feat(web): build ${name} [G1]`], { cwd: box.web, env: box.env, encoding: 'utf8' });assert.equal(committed.status, 0, `${committed.stdout}${committed.stderr}`);const head = box.git(box.web, 'rev-parse', 'HEAD');succeeds(box, box.web, 'submit', String(id));@@ -176,7 +177,7 @@ test('[S19,V3] doctor and resume list stale frozen items in every lifecycle statassert.equal(decision.status, 0, `${decision.stdout}${decision.stderr}`);succeeds(box, box.root, 'spec', 'apply', '--json');box.git(box.root, 'add', 'SPEC.md');- const appliedCommit = spawnSync('git', ['commit', '-m', 'docs: update approved G1 wording [G1]'], { cwd: box.root, env: box.env, encoding: 'utf8', timeout: 30_000 });+ const appliedCommit = runFixtureChild('git', ['commit', '-m', 'docs: update approved G1 wording [G1]'], { cwd: box.root, env: box.env, encoding: 'utf8' });assert.equal(appliedCommit.status, 0, `${appliedCommit.stdout}${appliedCommit.stderr}`);assert.ok(readFileSync(join(box.root, 'SPEC.md'), 'utf8').includes(NEW_TEXT));diff --git a/test/stats-cli.test.js b/test/stats-cli.test.jsindex 187ea65d..9fc45160 100644--- a/test/stats-cli.test.js+++ b/test/stats-cli.test.js@@ -1,6 +1,6 @@/** Event-derived proof numbers have the same data in text and versioned JSON [R1,R2,A1]. */import assert from 'node:assert/strict';-import { execFileSync } from 'node:child_process';+import { runFixtureGit } from './fixture-child.js';import { mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';@@ -25,7 +25,7 @@ async function run(root, args) {function fixture(t) {const root = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-stats-cli-')));t.after(() => rmSync(root, { recursive: true, force: true }));- execFileSync('git', ['init', '-q', '-b', 'main'], { cwd: root, stdio: 'pipe' });+ runFixtureGit(['init', '-q', '-b', 'main'], { cwd: root, stdio: 'pipe' });writeFileSync(join(root, 'pullboard.json'), JSON.stringify({ lanes: { web: { owns: ['web/'] } } }));writeFileSync(join(root, 'PRACTICE.md'), '');const clock = { now: () => new Date('2026-10-08T12:00:00.000Z') };diff --git a/test/submit-gate.test.js b/test/submit-gate.test.jsindex f0f8e675..dc8a2f26 100644--- a/test/submit-gate.test.js+++ b/test/submit-gate.test.js@@ -4,6 +4,7 @@*/import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { appendFileSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { dirname, join, resolve } from 'node:path';@@ -45,11 +46,11 @@ function privateRepo(t) {delete env.PULLBOARD_RELAY_TOKEN;delete env.NODE_TEST_CONTEXT;/** Run real Git in this fixture with only the fixture's configured identity. */- const git = (...args) => execFileSync('git', args, { cwd: root, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (...args) => runFixtureGit(args, { cwd: root, env });/** Run the real local CLI, retaining JSON stdout and refusal stderr separately. */const run = (...args) => {- const result = spawnSync(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8', timeout: 90_000 });- return { code: result.status, out: result.stdout ?? '', err: result.stderr ?? '' };+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout ?? '', err: result.failure ?? result.stderr ?? '', failure: result.failure };};git('init', '-q', '-b', 'main');assert.equal(run('init').code, 0);@@ -71,11 +72,11 @@ function builderRepo(box) {assert.equal(made.code, 0, made.err);const root = JSON.parse(made.out).path;/** Run Git only in the joined builder. */- const git = (...args) => execFileSync('git', args, { cwd: root, env: box.env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (...args) => runFixtureGit(args, { cwd: root, env: box.env });/** Run the real CLI with the joined builder identity. */const run = (...args) => {- const result = spawnSync(process.execPath, [BIN, ...args], { cwd: root, env: box.env, encoding: 'utf8', timeout: 90_000 });- return { code: result.status, out: result.stdout ?? '', err: result.stderr ?? '' };+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd: root, env: box.env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout ?? '', err: result.failure ?? result.stderr ?? '', failure: result.failure };};return { ...box, root, git, run, coordinator: box.run };}@@ -216,7 +217,7 @@ test('submit runs the frozen check and affected test only; landing and explicitconst remote = join(box.dir, 'remote.git');box.git('init', '-q', '--bare', remote);box.git('remote', 'add', 'origin', remote);- const landing = spawnSync('git', ['push', '-q', 'origin', 'HEAD:main'], { cwd: box.root, env: box.env, encoding: 'utf8', timeout: 90_000 });+ const landing = runFixtureChild('git', ['push', '-q', 'origin', 'HEAD:main'], { cwd: box.root, env: box.env, encoding: 'utf8' });assert.notEqual(landing.status, 0, 'the landing pre-push hook still runs the full gate');assert.match(`${landing.stdout ?? ''}\n${landing.stderr ?? ''}`, /gate is red|not ok 2/);assert.equal(existsSync(stamp), false, 'neither subset nor red full gate leaves a green full-gate stamp');@@ -412,7 +413,7 @@ for (const mode of ['topic parent', 'merge commit']) {assert.equal(box.git('rev-list', '--parents', '-n', '1', 'HEAD').split(' ').length, 3, 'the candidate really has two parents');const marker = join(box.dir, 'merged-test-ran.log');box.env.AFFECTED_MARKER = marker;- const standalone = spawnSync(process.execPath, ['--test', 'test/a.test.js'], { cwd: box.root, env: box.env, encoding: 'utf8' });+ const standalone = runFixtureChild(process.execPath, ['--test', 'test/a.test.js'], { cwd: box.root, env: box.env, encoding: 'utf8' });assert.equal(standalone.status, 1, 'the unchanged importer detects the merged source regression');assert.match(standalone.stdout, /ERR_ASSERTION/u);rmSync(marker);@@ -526,7 +527,7 @@ for (const mode of ['deleted source', 'topic parent', 'merge commit']) {assert.equal(box.git('branch', '--show-current'), 'main', 'submit runs in the actual main checkout');const marker = join(box.dir, 'main-importer-ran.log');box.env.AFFECTED_MARKER = marker;- const standalone = spawnSync(process.execPath, ['--test', 'test/a.test.js'], { cwd: box.root, env: box.env, encoding: 'utf8' });+ const standalone = runFixtureChild(process.execPath, ['--test', 'test/a.test.js'], { cwd: box.root, env: box.env, encoding: 'utf8' });assert.equal(standalone.status, 1, 'the unchanged importer detects the source regression');assert.match(standalone.stdout, mode === 'deleted source' ? /ERR_MODULE_NOT_FOUND/u : /ERR_ASSERTION/u);rmSync(marker, { force: true });diff --git a/test/thread.test.js b/test/thread.test.jsindex 54caaf7b..72008968 100644--- a/test/thread.test.js+++ b/test/thread.test.js@@ -1,6 +1,7 @@/** Exercise typed item threads and deterministic replication on isolated SQLite boards [B29,B30,B31,B32]. */import assert from 'node:assert/strict';-import { execFileSync, spawnSync } from 'node:child_process';+import { execFileSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -225,9 +226,9 @@ function threadHttpFixture(t) {};mkdirSync(env.HOME);/** Run Git only in this disposable repository and return trimmed output. */- const git = (...args) => execFileSync('git', args, { cwd: root, env, stdio: 'pipe', encoding: 'utf8' }).trim();+ const git = (...args) => runFixtureGit(args, { cwd: root, env, stdio: 'pipe', encoding: 'utf8' });/** Invoke the actual CLI with the private environment. */- const run = (cwd, ...args) => spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ const run = (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });/** Decode one successful JSON command. */function cli(cwd, ...args) {const result = run(cwd, ...args, '--json');diff --git a/test/trunk.test.js b/test/trunk.test.jsindex ef39acad..4c26fe07 100644--- a/test/trunk.test.js+++ b/test/trunk.test.js@@ -1,6 +1,7 @@/** Branch-name-independent check baselines and lane merge ownership [B34,P2,L3]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -42,12 +43,12 @@ function sandbox() {});/** Run isolated Git commands. */function git(cwd, ...args) {- return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ return runFixtureGit(args, { cwd, env });}/** Run a real Pullboard CLI process in the fixture environment. */function run(cwd, ...args) {- const result = spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 30_000 });- return { code: result.status, out: result.stdout, err: result.stderr };+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout, err: result.failure ?? result.stderr, failure: result.failure };}return { dir, env, git, run };}@@ -106,8 +107,8 @@ for (const branch of ['master', 'trunk']) {box.git(box.repo, 'add', 'web/result.txt', 'coordinator.txt');box.git(box.repo, 'commit', '-q', '-m', 'chore: update trunk fixture');const trunkHead = box.git(box.repo, 'rev-parse', 'HEAD');- const merged = spawnSync('git', ['merge', '--no-ff', '--no-commit', branch], {- cwd: web, env: box.env, encoding: 'utf8', timeout: 30_000,+ const merged = runFixtureChild('git', ['merge', '--no-ff', '--no-commit', branch], {+ cwd: web, env: box.env, encoding: 'utf8',});assert.equal(merged.status, 1, `${merged.stdout}${merged.stderr}`);assert.equal(box.git(web, 'rev-parse', 'MERGE_HEAD'), trunkHead, 'the merge is against the primary checkout tip');@@ -115,8 +116,8 @@ for (const branch of ['master', 'trunk']) {writeFileSync(join(web, 'web', 'result.txt'), `resolved by web lane from ${branch}\n`);box.git(web, 'add', 'web/result.txt');- const committed = spawnSync('git', ['commit', '-m', `Merge ${branch} into web/agent`], {- cwd: web, env: box.env, encoding: 'utf8', timeout: 30_000,+ const committed = runFixtureChild('git', ['commit', '-m', `Merge ${branch} into web/agent`], {+ cwd: web, env: box.env, encoding: 'utf8',});assert.equal(committed.status, 0, `${committed.stdout}${committed.stderr}`);assert.equal(box.git(web, 'show', 'HEAD:web/result.txt'), `resolved by web lane from ${branch}`);diff --git a/test/verdict-check.test.js b/test/verdict-check.test.jsindex c4d3b8aa..067a5898 100644--- a/test/verdict-check.test.js+++ b/test/verdict-check.test.js@@ -1,6 +1,7 @@/** The frozen check outcome travels with accepts without changing the board schema [V19,V8]. */import assert from 'node:assert/strict';-import { execFileSync, spawnSync } from 'node:child_process';+import { execFileSync } from 'node:child_process';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';@@ -32,11 +33,11 @@ function sandbox() {});mkdirSync(env.HOME);/** Run isolated Git commands for this fixture. */- const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env, encoding: 'utf8', stdio: 'pipe' });/** Run the checked-out CLI without invoking any shared board. */const run = (cwd, ...args) => {- const result = spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });- return { code: result.status, out: result.stdout, err: result.stderr };+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout, err: result.failure ?? result.stderr, failure: result.failure };};return { dir, env, git, run };}@@ -63,7 +64,7 @@ function project(box) {/** Run a fixture command and fail with its captured diagnostics if it refuses. */function succeeds(box, cwd, ...args) {const result = box.run(cwd, ...args);- assert.equal(result.code, 0, `${result.out}\n${result.err}`);+ assert.equal(result.code, 0, result.failure ?? `${result.out}\n${result.err}`);return result.out;}diff --git a/test/view-port.test.js b/test/view-port.test.jsindex 4cb00671..f92cf5b6 100644--- a/test/view-port.test.js+++ b/test/view-port.test.js@@ -1,6 +1,6 @@/** Keep the view's exact named-port refusal covered in a core-owned file [N26]. */import assert from 'node:assert/strict';-import { spawnSync } from 'node:child_process';+import { runFixtureChild } from './fixture-child.js';import { createServer } from 'node:net';import { mkdtempSync, rmSync } from 'node:fs';import { tmpdir } from 'node:os';@@ -24,8 +24,8 @@ test("a named port that is busy is refused with the way out, not a stack trace [GIT_CONFIG_GLOBAL: '/dev/null',GIT_CONFIG_NOSYSTEM: '1',};- const result = spawnSync(process.execPath, [BIN, 'view', '--no-open', '--port', String(port)], {- cwd: dir, env, encoding: 'utf8', timeout: 20000,+ const result = runFixtureChild(process.execPath, [BIN, 'view', '--no-open', '--port', String(port)], {+ cwd: dir, env, encoding: 'utf8',});assert.equal(result.status, 1, `a refusal, not a crash or a hang: ${result.stderr}`);assert.equal(result.stderr.trim(), `pullboard: [PORT_BUSY] port ${port} is in use: name another with --port, or leave --port out to take any free one`);