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(land): prove the configured timeout needs custody [E27,E29]
Corey Olson36a32364aa7a
diff --git a/src/config.js b/src/config.jsindex 44febc63..b46837ae 100644--- a/src/config.js+++ b/src/config.js@@ -203,9 +203,15 @@ export function configProblems(config) {problems.push('"landingShards" is a whole number from 1 to 64: how many shards the landing gate splits its test files into');}if (typeof config.staticChecks !== 'string') problems.push('"staticChecks" is an optional project static-check command');- if (config.landing !== undefined && (typeof config.landing !== 'object' || config.landing === null || Object.keys(config.landing).some(key => key !== 'publish') || ![undefined, 'separate'].includes(config.landing.publish))) {+ if (config.landing !== undefined && (typeof config.landing !== 'object' || config.landing === null || Object.keys(config.landing).some(key => !['publish', 'timeout', 'cadence'].includes(key)) || ![undefined, 'separate'].includes(config.landing.publish))) {problems.push('"landing" is optional; { "publish": "separate" } lands on the local trunk and pushes only through pullboard publish');}+ for (const key of ['timeout', 'cadence']) {+ const value = config.landing?.[key];+ const match = typeof value === 'string' ? CHECK_TIMEOUT_RE.exec(value) : null;+ const ms = match ? Number(match[1]) * CHECK_TIMEOUT_MS[match[2]] : NaN;+ if (value !== undefined && (!Number.isFinite(ms) || ms <= 0 || ms > MAX_CHECK_TIMEOUT_MS)) problems.push(`"landing.${key}" is a positive duration no longer than 2,147,483,647ms, like "2s"`);+ }if (config.positiveControl !== undefined && (typeof config.positiveControl !== 'string' || !config.positiveControl.trim())) {problems.push('"positiveControl" is a nonempty command for a known-good case the gate must pass, like "node --test test/known-good.test.js"');}@@ -325,6 +331,7 @@ export function configFromSource(source) {return {...config,check: { ...config.check, timeoutMs: Number(timeout[1]) * CHECK_TIMEOUT_MS[timeout[2]] },+ ...(config.landing ? { landing: { ...config.landing, ...Object.fromEntries(['timeout', 'cadence'].filter(key => config.landing[key] !== undefined).map(key => { const value = CHECK_TIMEOUT_RE.exec(config.landing[key]); return [`${key}Ms`, Number(value[1]) * CHECK_TIMEOUT_MS[value[2]]]; })) } } : {}),leaseMs: durationMs(config.lease),reviewLeaseMs: durationMs(config.reviewLease, 'reviewLease'),};diff --git a/test/land.test.js b/test/land.test.jsindex c00aaa9b..258d7661 100644--- a/test/land.test.js+++ b/test/land.test.js@@ -11,6 +11,7 @@ import { createE2eHelpers } from './e2e-helpers.js';import { startFixtureChild, runFixtureChild } from './fixture-child.js';import { assertNoRemoteLanding } from './land-no-remote-fixture.js';+import { landingTimeoutFixture } from './landing-timeout-fixture.js';const e2e = createE2eHelpers();after(e2e.cleanup);const { sandbox, project, commitFile, waitFor, BIN } = e2e;@@ -20,7 +21,6 @@ const MARKER_NOT_YET = Symbol('marker not yet written');test('a repo with no remote lands into the local trunk and status reads as normal [I1,B3,R3,H5]', () => {assertNoRemoteLanding(sandbox, commitFile);});-/** Read a complete marker, treating a missing or mid-write file as unpublished. */function readMarker(file) {try { return JSON.parse(readFileSync(file, 'utf8')); }@@ -1497,3 +1497,4 @@ test('a publish gate run is recorded and a red and green pair it sees files theassert.equal(flakes().length, 1, 'another publish receipt creates no duplicate flake item');assert.equal(calls(box).length - before, 3, 'each receipt represents one actual full publish gate');});+test('a landing gate past its timeout stops cleanly [E27,E29]', () => landingTimeoutFixture({ landProject, itemWorktree, submitItem, acceptItem, onBoard, json }));diff --git a/test/landing-timeout-fixture.js b/test/landing-timeout-fixture.jsnew file mode 100644index 00000000..f992238f--- /dev/null+++ b/test/landing-timeout-fixture.js@@ -0,0 +1,44 @@+/** Exercise landing timeout custody and cadence against a private real board [E27,E29]. */+import assert from 'node:assert/strict';+import { existsSync, readFileSync, writeFileSync } from 'node:fs';+import { join } from 'node:path';+import { landingLeaseState } from '../src/landing-lease.js';++/** A configured timeout must stop the gate and its detached child before releasing the trunk. */+export function landingTimeoutFixture({ landProject, itemWorktree, submitItem, acceptItem, onBoard, json }) {+ const box = landProject();+ const armed = join(box.dir, 'timeout-armed');+ const identities = join(box.dir, 'timeout-processes.json');+ const gate = join(box.dir, 'timeout-gate.cjs');+ writeFileSync(gate, [+ "const fs = require('node:fs'); const { spawn } = require('node:child_process');",+ `if (!fs.existsSync(${JSON.stringify(armed)})) { console.log('TAP version 13\\nok 1 - fixture gate\\n1..1\\n# tests 1\\n# pass 1\\n# fail 0'); process.exit(0); }`,+ "const child = spawn(process.execPath, ['-e', 'setTimeout(() => {}, 6000)'], { detached: true, stdio: 'ignore' });",+ `fs.writeFileSync(${JSON.stringify(identities)}, JSON.stringify([process.pid, child.pid]));`,+ "setTimeout(() => { console.log('TAP version 13\\nok 1 - fixture gate\\n1..1\\n# tests 1\\n# pass 1\\n# fail 0'); }, 6000);",+ ].join('\n'));+ const configFile = join(box.repo, 'pullboard.json');+ const config = JSON.parse(readFileSync(configFile, 'utf8'));+ config.gate = `node '${gate.replaceAll("'", "'\\''")}'`;+ config.landing = { timeout: '2s', cadence: '1m' };+ writeFileSync(configFile, JSON.stringify(config, null, 2));+ box.git(box.repo, 'add', 'pullboard.json');+ box.git(box.repo, 'commit', '-q', '-m', 'chore: configure timed landing');+ const entry = itemWorktree(box, 1);+ submitItem(box, entry);+ acceptItem(box, entry);+ writeFileSync(armed, 'armed');+ const result = json(box, box.repo, 'land');+ assert.ok(existsSync(identities), 'the real stand-in gate started');+ assert.equal(result.batch.gateResults.at(-1).timedOut, true, 'the 2s budget records a timed-out red');+ assert.equal(result.batch.state, 'blocked');+ assert.deepEqual(result.culprits, [], 'timeout does not accuse the candidate');+ for (const pid of JSON.parse(readFileSync(identities, 'utf8'))) {+ assert.throws(() => process.kill(pid, 0), { code: 'ESRCH' }, `owned gate process ${pid} is gone`);+ }+ assert.equal(onBoard(box, board => landingLeaseState(board).holder), null, 'cleanup precedes trunk release');+ const deferred = json(box, box.repo, 'land');+ assert.equal(deferred.batch, null);+ assert.ok(Date.parse(deferred.deferredUntil) > Date.now(), 'cadence gives the next admission time');+ assert.equal(onBoard(box, board => landingLeaseState(board).holder), null, 'cadence never holds the lease');+}