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): a landing run keeps going past a waived failure [B3]
Corey Olson26676c6883a4
diff --git a/bin/run-tests.js b/bin/run-tests.jsindex 7ffdfcef..048f1d1f 100644--- a/bin/run-tests.js+++ b/bin/run-tests.js@@ -3,7 +3,7 @@* Run the test suite with a private home, no inherited Git identity or config, and a refusing CLI shim.*/import { appendFileSync, chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';-import { basename, delimiter, dirname, join, resolve } from 'node:path';+import { basename, delimiter, dirname, join, relative, resolve } from 'node:path';import { fileURLToPath } from 'node:url';import { execFile, execFileSync, spawnSync } from 'node:child_process';import { tmpdir } from 'node:os';@@ -17,6 +17,7 @@ const runner = fileURLToPath(import.meta.url);const LANDING_RUN_ENV = 'PULLBOARD_LANDING_RUN';const LANDING_WORKER_STARTS_ENV = 'PULLBOARD_LANDING_WORKER_STARTS';const LANDING_ATTEMPT_ENV = 'PULLBOARD_LANDING_ATTEMPT';+const LANDING_WAIVERS_ENV = 'PULLBOARD_LANDING_WAIVERS';export const DEFAULT_TEST_TIMEOUT_MS = 660_000;export const DEFAULT_TEST_FILE_TIMEOUT_MS = 30_000;// Worker identity startup retries stay below the ordinary per-file ceiling even if ps is unavailable.@@ -775,12 +776,34 @@ async function drainLandingWorkerDescendants(ownedDescendants, refreshOwnedDesce}/** Run a landing check with execution-ordered failure detection and native runner reporters. */+/**+ * Read the live person waivers Pullboard projects into a landing run, as `{kind, test}` pairs.+ * The projection only decides whether the run keeps going past a failure; whether the run is+ * waived is decided afterwards by Pullboard against the board, so a forged list only makes a run+ * longer, never greener. Anything unreadable projects nothing, and the run stops as before [B3].+ */+function landingWaiverProjection(text) {+ try {+ const parsed = JSON.parse(text ?? '[]');+ return Array.isArray(parsed) ? parsed.filter(entry => ['file', 'name'].includes(entry?.kind) && typeof entry.test === 'string' && entry.test) : [];+ } catch { return []; }+}++/** True when a projected waiver covers this failing test by its file or by its exact name. */+function landingFailureWaived(waivers, file, name) {+ const path = typeof file === 'string' ? relative(process.cwd(), file.startsWith('file:') ? fileURLToPath(file) : file) : null;+ return waivers.some(waiver => waiver.kind === 'file' ? waiver.test === path : waiver.test === name);+}+async function runLandingTests(args, env, concurrency) {+ const waivers = landingWaiverProjection(process.env[LANDING_WAIVERS_ENV]);+ const waivedFiles = new Map();const { run } = await import('node:test');const { PassThrough } = await import('node:stream');const { createWriteStream } = await import('node:fs');const { pathToFileURL } = await import('node:url');const { options, env: testEnv } = await landingTestOptions(args, env, concurrency);+ delete testEnv[LANDING_WAIVERS_ENV];if (options.isolation !== 'process') {throw new Error('landing gate early-stop requires --test-isolation=process so started files and owned children can be tracked safely');}@@ -1028,6 +1051,9 @@ async function runLandingTests(args, env, concurrency) {tests.on('test:complete', data => {const { file, name, details } = data;if (file && details?.type === 'test' && details.passed === false && !firstFailure) {+ // A failure a live person waiver covers does not stop the run; every other file still runs.+ if (landingFailureWaived(waivers, file, name)) { waivedFiles.set(file, waivedFiles.get(file) ?? true); return; }+ waivedFiles.set(file, false);firstFailure = { file, name, error: details.error };abortLandingRun();}@@ -1037,7 +1063,7 @@ async function runLandingTests(args, env, concurrency) {if (data.file) {startedFiles.add(data.file);completedFiles.add(data.file);- if (data.success === false && !firstFailure) {+ if (data.success === false && !firstFailure && waivedFiles.get(data.file) !== true) {firstFailure = { file: data.file, name: 'test file failed before a test completed' };abortLandingRun();}diff --git a/src/cli.js b/src/cli.jsindex ee4a2296..39515736 100644--- a/src/cli.js+++ b/src/cli.js@@ -85,7 +85,7 @@ import { readRelayMachine } from './relay-machine.js';import { relayJoin, relayPair } from './relay-pairing-client.js';import { executePersonRequests } from './relay-request-execution.js';import { engineReceipt } from './engine.js';-import { accountedFailures, land, waivedFailures, waiverLine } from './land.js';+import { accountedFailures, land, liveWaiverProjection, waivedFailures, waiverLine } from './land.js';const CHECKOUT_LEASES = new WeakMap();const CHECKOUT_BOARD_ONLY = new WeakMap();@@ -3408,7 +3408,8 @@ async function runCommand(argv, io) {}throw error;}- const gate = await runGate(ctx.info.root, config, { landing: values.landing, agent: resourceAgent(ctx), onWait: gateWaitReporter(io), stages: Boolean(values.landing) });+ const waivers = values.landing ? withBoard(ctx, (board) => liveWaiverProjection(board)) : [];+ const gate = await runGate(ctx.info.root, config, { landing: values.landing, agent: resourceAgent(ctx), onWait: gateWaitReporter(io), stages: Boolean(values.landing), waivers });// A landing gate honours the person's live waivers exactly as land does; a red run never stamps, so it stays waived, not green [B3,R3].const waived = values.landing && !gate.isGreen ? withBoard(ctx, (board) => waivedFailures(board, accountedFailures(gate, ctx.info.root))) : null;if (waived) {diff --git a/src/gate.js b/src/gate.jsindex 6c58c693..8fa52c3d 100644--- a/src/gate.js+++ b/src/gate.js@@ -21,6 +21,8 @@ import { timingFromOutput, timingRunner } from './timing.js';const STAMP = 'pullboard-gate-green';const LOG = 'pullboard-gate.log';const LANDING_RUN_ENV = 'PULLBOARD_LANDING_RUN';+// Live person waivers, as {kind, test}, so a landing run does not stop early on a waived failure.+const LANDING_WAIVERS_ENV = 'PULLBOARD_LANDING_WAIVERS';const DIGEST_CHARS = 3000;const TAIL_CHARS = 1000;const LINE_CHARS = 300;@@ -248,9 +250,9 @@ function safeLog(output) {/** Run the unchanged caller command and profile only timings already present in its output.* @param {string} root* @param {string} command- * @param {{ waitMs?: number, artifactDirectory?: string, artifactPrefix?: string, persistLog?: boolean, profileFile?: string, pipefail?: boolean, gateSlotHeld?: boolean, gateLease?: object, landing?: boolean, stages?: boolean }} [options]+ * @param {{ waitMs?: number, artifactDirectory?: string, artifactPrefix?: string, persistLog?: boolean, profileFile?: string, pipefail?: boolean, gateSlotHeld?: boolean, gateLease?: object, landing?: boolean, stages?: boolean, waivers?: Array<{ kind: string, test: string }> }} [options]*/-export function runProfiledShell(root, command, { waitMs = 0, artifactDirectory, artifactPrefix = 'pullboard-gate', persistLog = false, profileFile, pipefail = false, gateSlotHeld = false, gateLease, landing = false, stages = false } = {}) {+export function runProfiledShell(root, command, { waitMs = 0, artifactDirectory, artifactPrefix = 'pullboard-gate', persistLog = false, profileFile, pipefail = false, gateSlotHeld = false, gateLease, landing = false, stages = false, waivers = [] } = {}) {const directory = artifactDirectory ?? dirname(gitPath(root, LOG));mkdirSync(directory, { recursive: true, mode: 0o700 });const id = randomUUID();@@ -260,6 +262,7 @@ export function runProfiledShell(root, command, { waitMs = 0, artifactDirectory,const inherited = {...(gateLease ? gateSlotEnvironment(gateLease) : gateSlotHeld ? { [GATE_SLOT_HELD_ENV]: '1' } : {}),[LANDING_RUN_ENV]: landing ? '1' : '0',+ [LANDING_WAIVERS_ENV]: landing ? JSON.stringify(waivers) : '[]',};const run = runShell(root, command, { pipefail, env: inherited, stages });const profile = writeTimingProfile(profilePath, {@@ -405,21 +408,21 @@ export async function withGateSlot(root, action, { landing = false, itemCheck =* @param {{ trustStamp?: boolean, onWait?: (state: object) => void, landing?: boolean, agent?: string, item?: string|number }} [options]* @returns {Promise<{ isGreen: boolean, isCached: boolean, output: string, seconds: number, log: string, profile?: object, profilePath?: string }>}*/-export async function runGate(root, config, { trustStamp = true, onWait, landing = false, agent, item = '', stages = false } = {}) {+export async function runGate(root, config, { trustStamp = true, onWait, landing = false, agent, item = '', stages = false, waivers = [] } = {}) {if (!config.gate.trim()) {throw new Refused('NO_GATE', 'no gate configured; set "gate" in pullboard.json, e.g. "npm test"');}if (trustStamp && isStampedGreen(root)) return { isGreen: true, isCached: true, output: '', seconds: 0, log: '' };- return await withGateSlot(root, (lease) => fullGateRun(root, config, trustStamp, { waitMs: lease.waitMs, gateLease: lease, landing, stages }), {+ return await withGateSlot(root, (lease) => fullGateRun(root, config, trustStamp, { waitMs: lease.waitMs, gateLease: lease, landing, stages, waivers }), {landing, browser: true, agent, item, kind: landing ? 'landing' : 'gate', onWait,});}/** Run a full gate while its caller owns the queue lease; only a full run may stamp its tree. */-function fullGateRun(root, config, trustStamp = false, { waitMs = 0, log = gitPath(root, LOG), gateLease, landing = false, stages = false } = {}) {+function fullGateRun(root, config, trustStamp = false, { waitMs = 0, log = gitPath(root, LOG), gateLease, landing = false, stages = false, waivers = [] } = {}) {if (trustStamp && isStampedGreen(root)) return { isGreen: true, isCached: true, output: '', seconds: 0, log: '' };const before = committedTree(root);- const run = runProfiledShell(root, config.gate, { waitMs, pipefail: true, profileFile: `${log}.profile.json`, gateLease, landing, stages });+ const run = runProfiledShell(root, config.gate, { waitMs, pipefail: true, profileFile: `${log}.profile.json`, gateLease, landing, stages, waivers });const { isGreen, output, seconds, profile, profilePath } = run;writeFileSync(log, output);if (isGreen && before !== null && committedTree(root) === before) writeFileSync(gitPath(root, STAMP), `${before}\n`);diff --git a/src/land.js b/src/land.jsindex bf79ea5a..9b7ae1aa 100644--- a/src/land.js+++ b/src/land.js@@ -127,7 +127,7 @@ async function gateGroup(state, label) {mkdirSync(directory, { recursive: true });const logPath = join(directory, `${label}-${state.batch.revision}.log`);await save(state, { state: 'gating', tip: headCommit(state.batch.root), logPath });- const gate = await runGate(state.batch.root, state.config, { trustStamp: false, landing: true, agent: 'coordinator', onWait: state.onWait, stages: true });+ const gate = await runGate(state.batch.root, state.config, { trustStamp: false, landing: true, agent: 'coordinator', onWait: state.onWait, stages: true, waivers: liveWaiverProjection(state.board) });copyFileSync(gate.log, logPath);if (gate.profilePath) copyFileSync(gate.profilePath, `${logPath}.profile.json`);const result = { ...gate, failures: landingFailures(gate.output, state.batch.root), accounted: accountedFailures(gate, state.batch.root), tree, logPath };@@ -230,6 +230,13 @@ export function waivedFailures(board, failures) {return covered.every((entry) => entry.waiver) ? covered : null;}+/** Project the live person waivers a landing run may read, so it does not stop early on one [B3]. */+export function liveWaiverProjection(board) {+ const now = board.clock.now().getTime();+ return store.landingWaivers(board).filter((waiver) => Date.parse(waiver.until) > now)+ .map((waiver) => ({ kind: waiver.kind ?? store.landingWaiverKind(waiver.test), test: waiver.test }));+}+/** Name one waived failure with the person's waiver, its reason and its expiry [B3]. */export function waiverLine(failure) {const { waiver } = failure;diff --git a/test/land.test.js b/test/land.test.jsindex c86f1620..06441f2a 100644--- a/test/land.test.js+++ b/test/land.test.js@@ -1,7 +1,7 @@/** Exercise landing against real private Git worktrees, hooks, SQLite and bare remotes [B3,R3]. */import assert from 'node:assert/strict';import { existsSync, readFileSync, rmSync, writeFileSync } from 'node:fs';-import { join, relative } from 'node:path';+import { dirname, join, relative } from 'node:path';import { after, test } from 'node:test';import * as store from '../src/board.js';import { applyRelayMove, prepareEngineMove } from '../src/engine.js';@@ -749,6 +749,23 @@ test("a person's waiver lets a submit and a landing gate through only the waivedconst passingStage = box.run(box.repo, 'gate', '--landing');assert.equal(passingStage.code, 0, `${passingStage.err}\n${passingStage.out}`);assert.match(passingStage.out, line, 'a passing stage leaves only the waived test to subtract');++ // A real landing run does not stop early on a waived failure: every other file still runs, then the waiver subtracts it.+ const laterRan = join(box.dir, 'later-file-ran');+ const waivedFile = 'test/landing-waived.test.cjs';+ assert.equal(commitFile(box, box.repo, waivedFile, "require('node:test').test('a flaky landing check', () => { throw new Error('known flake'); });\n", 'chore: add a flaky landing test').status, 0);+ assert.equal(commitFile(box, box.repo, 'test/landing-later.test.cjs', `require('node:test').test('a later landing check', () => { require('node:fs').writeFileSync(${JSON.stringify(laterRan)}, 'ran'); });\n`, 'chore: add a later landing test').status, 0);+ setGate(`node ${JSON.stringify(join(dirname(BIN), 'run-tests.js'))} --test-concurrency=1 ${waivedFile} test/landing-later.test.cjs`, 'chore: gate with the real test runner');+ const stopped = box.run(box.repo, 'gate', '--landing');+ assert.equal(stopped.code, 1, 'an unwaived failure still stops a landing run');+ assert.match(`${stopped.out}\n${stopped.err}`, /stopped early/u);+ assert.ok(!existsSync(laterRan), 'the early stop skipped the later file');+ const runnerWaiver = json(box, box.repo, 'land', '--waive', waivedFile, '--until', '2099-01-01', '--reason', 'known landing flake').waiver;+ const continued = box.run(box.repo, 'gate', '--landing');+ assert.equal(continued.code, 0, `${continued.err}\n${continued.out}`);+ assert.ok(existsSync(laterRan), 'every other file ran past the waived failure');+ assert.doesNotMatch(`${continued.out}\n${continued.err}`, /stopped early/u);+ assert.match(continued.out, new RegExp(`waived: a flaky landing check \\(${waivedFile.replaceAll('.', '\\.')}\\) by person waiver ${runnerWaiver.id} for file `, 'u'));setGate(gateCommand, 'chore: restore the single-stage gate');onBoard(box, (board) => {