Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
fix(land): spool timed gate output outside the custody protocol [E27]
Corey Olsonec0b4fbe5599
diff --git a/src/gate.js b/src/gate.jsindex 621c58c5..cf6497e0 100644--- a/src/gate.js+++ b/src/gate.js@@ -281,10 +281,13 @@ export function runShell(root, command, { pipefail = false, env = {}, stages = fconst pipes = split?.some((stage) => stage.pipeline.length > 1) ? mkdtempSync(join(tmpdir(), 'pullboard-pipes-')) : null;// Newlines, not spaces, around the command, so a trailing comment in it cannot swallow the `)`.const script = `${prefix}(\n${split ? stagedScript(split, marker, pipes) : command}\n) 2>&1`;- const timed = timeoutMs ? spawnSync(process.execPath, [fileURLToPath(new URL('./timed-shell-worker.js', import.meta.url))], { ...options, shell: false, stdio: ['pipe', 'pipe', 'pipe'], input: JSON.stringify({ command: script, timeoutMs }) }) : null;+ const timedDirectory = timeoutMs ? mkdtempSync(join(tmpdir(), 'pullboard-timed-output-')) : null;+ const outputFile = timedDirectory ? join(timedDirectory, 'output.log') : null;+ const timed = timeoutMs ? spawnSync(process.execPath, [fileURLToPath(new URL('./timed-shell-worker.js', import.meta.url))], { ...options, shell: false, stdio: ['pipe', 'pipe', 'pipe'], input: JSON.stringify({ command: script, timeoutMs, outputFile }) }) : null;if (timed && (timed.status !== 0 || timed.error)) throw new Refused('LAND_TIMEOUT_CUSTODY', 'the timed gate worker did not prove cleanup; inspect its owned processes before landing again');const result = timed ? { ...JSON.parse(timed.stdout || '{}'), stdout: '', stderr: timed.stderr } : spawnSync(script, options);- if (timed) result.stdout = result.output + (result.timedOut ? `\n[LAND_GATE_TIMEOUT] landing gate exceeded ${timeoutMs}ms; its owned processes are stopped\n` : '');+ if (timed) result.stdout = readFileSync(outputFile, 'utf8') + (result.timedOut ? `\n[LAND_GATE_TIMEOUT] landing gate exceeded ${timeoutMs}ms; its owned processes are stopped\n` : '');+ if (timedDirectory) rmSync(timedDirectory, { recursive: true, force: true });if (result.timedOut || result.overflow || result.error) result.status = 1;invalidateGitFacts();const pipeStatuses = pipes ? readPipes(split, pipes) : null;diff --git a/src/timed-shell-worker.js b/src/timed-shell-worker.jsindex 1517166a..2b404d73 100644--- a/src/timed-shell-worker.js+++ b/src/timed-shell-worker.js@@ -1,6 +1,6 @@/** Run a bounded shell under identity-checked process custody before returning its result [E27]. */import { spawn } from 'node:child_process';-import { mkdtempSync, readFileSync, rmSync } from 'node:fs';+import { appendFileSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { createDescendantTracker } from './runner-custody.js';@@ -18,7 +18,7 @@ let overflow = false;let error = null;let bytes = 0;let stopping;-const chunks = [];+writeFileSync(request.outputFile, '', { mode: 0o600, flag: 'wx' });const closed = new Promise(resolveClose => {child.once('error', cause => { error = cause.message; resolveClose({ status: null, signal: null }); });child.once('close', (status, signal) => resolveClose({ status, signal }));@@ -47,7 +47,7 @@ function stop() {function capture(chunk) {bytes += chunk.length;if (bytes > 2 ** 30) { overflow = true; void stop(); }- else chunks.push(chunk);+ else appendFileSync(request.outputFile, chunk);}child.stdout.on('data', capture);child.stderr.on('data', capture);@@ -60,4 +60,4 @@ clearTimeout(timer);await stop();tracker.stopMonitoring();rmSync(directory, { recursive: true, force: true });-process.stdout.write(JSON.stringify({ ...result, timedOut, overflow, error, output: Buffer.concat(chunks).toString('utf8') }));+process.stdout.write(JSON.stringify({ ...result, timedOut, overflow, error }));