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): retain the reason a timed gate cannot drain [E27]
Corey Olsone7edccf347d7
diff --git a/src/timed-shell-worker.js b/src/timed-shell-worker.jsindex 697c0065..6154401b 100644--- a/src/timed-shell-worker.js+++ b/src/timed-shell-worker.js@@ -8,7 +8,10 @@ import {writeFileSync,} from 'node:fs';import { tmpdir } from 'node:os';-import { join } from 'node:path';+import {+ dirname,+ join,+} from 'node:path';import { createDescendantTracker } from './runner-custody.js';const request = JSON.parse(readFileSync(0, 'utf8'));@@ -16,11 +19,23 @@ if (!Number.isSafeInteger(request.timeoutMs) || request.timeoutMs < 1 || request// A spool that cannot be created must refuse before there is any command to stop.writeFileSync(request.outputFile, '', { mode: 0o600, flag: 'wx' });const directory = mkdtempSync(join(tmpdir(), 'pullboard-timed-shell-'));-const tracker = createDescendantTracker(directory);+let tracker;+let phase = 'starting';+let lastState = 0;+const stateFile = join(dirname(request.outputFile), 'cleanup-state.json');+/** Persist the current custody reason so an unresolved drain remains inspectable without weakening it. */+function reportState(force = false) {+ if (!force && Date.now() - lastState < 1_000) return;+ lastState = Date.now();+ try { writeFileSync(stateFile, JSON.stringify({ at: new Date().toISOString(), phase, ...(tracker?.cleanupState() ?? {}) }) + '\n', { mode: 0o600 }); }+ catch { process.stderr.write('timed gate: cleanup state could not be written; retain the worker and inspect its private output directory\n'); }+}+tracker = createDescendantTracker(directory, { tick: () => reportState(), warn: () => reportState(true) });const env = { ...process.env, NODE_OPTIONS: [process.env.NODE_OPTIONS, tracker.nodeOptions].filter(Boolean).join(' '), PULLBOARD_RUNNER_PRELOAD: tracker.nodeOptions };const child = spawn('/bin/sh', ['-c', request.command], { env, detached: true, stdio: ['ignore', 'pipe', 'pipe'] });tracker.registerRoot(child.pid);tracker.observe();+reportState(true);let timedOut = false;let overflow = false;let error = null;@@ -34,7 +49,9 @@ const closed = new Promise(resolveClose => {/** Drain only currently proven descendants and root groups; ambiguity keeps custody rather than freeing a lease. */function stop() {stopping ??= (async () => {+ phase = 'descendants'; reportState(true);await tracker.stopDescendants();+ phase = 'root group'; reportState(true);for (const signal of ['SIGTERM', 'SIGKILL']) {const deadline = Date.now() + 2_000;for (;;) {@@ -45,7 +62,9 @@ function stop() {}}await closed;+ phase = 'verification'; reportState(true);await tracker.verifyAfterGroups();+ phase = 'drained'; reportState(true);})();return stopping;}