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
Merge branch 'main' into HEAD
Corey Olson4d0b4c36e7cd
diff --cc src/config.jsindex 1355b9c8,62381069..cfbb7ba1--- a/src/config.js+++ b/src/config.js@@@ -204,12 -203,15 +204,18 @@@ 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 => !['publish', 'timeout', 'cadence'].includes(key)) || ![undefined, 'separate'].includes(config.landing.publish))) {- problems.push('"landing" has optional "timeout" and "cadence" durations, and "publish": "separate" to land locally and push through pullboard publish');+ if (config.landing !== undefined && (typeof config.landing !== 'object' || config.landing === null || Array.isArray(config.landing)- || Object.keys(config.landing).some(key => !['publish', 'environment'].includes(key)) || ![undefined, 'separate'].includes(config.landing.publish))) {- problems.push('"landing" has optional publish: "separate" and environment: { platform, arch, node }');++ || Object.keys(config.landing).some(key => !['publish', 'environment', 'timeout', 'cadence'].includes(key)) || ![undefined, 'separate'].includes(config.landing.publish))) {++ problems.push('"landing" has optional environment: { platform, arch, node }, "timeout" and "cadence" durations, and "publish": "separate" to land locally and push through pullboard publish');+ } else if (config.landing?.environment !== undefined && environmentProblem(config.landing.environment)) {+ problems.push(`"landing.environment" ${environmentProblem(config.landing.environment)}`);}+ 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"');}diff --cc src/gate.jsindex 08595dd4,83c179ac..a4544b9b--- a/src/gate.js+++ b/src/gate.js@@@ -266,12 -261,11 +266,12 @@@ export function isStampedGreen(root)** @param {string} root* @param {string} command- * @param {{ pipefail?: boolean, env?: NodeJS.ProcessEnv, stages?: boolean }} [options] - Gate-only pipefail, additional child environment values and per-stage accounting.+ * @param {{ pipefail?: boolean, env?: NodeJS.ProcessEnv, stages?: boolean, timeoutMs?: number }} [options] - Gate-only pipefail, additional child environment values and per-stage accounting.* @returns {{ isGreen: boolean, output: string, seconds: number, sandboxBlocked: string|null, stages?: Array<{ status: number|null, output: string, pipeline?: Array<{ status: number|null, output: string|null }> }> | null }}*/- export function runShell(root, command, { pipefail = false, env = {}, stages = false } = {}) {+ export function runShell(root, command, { pipefail = false, env = {}, stages = false, timeoutMs } = {}) {const started = Date.now();+ const environment = executionEnvironment();const options = { cwd: root, env: { ...gitChildEnv(root), ...env }, shell: true, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', maxBuffer: 2 ** 30 };let prefix = '';if (pipefail) {@@@ -293,12 -296,12 +302,12 @@@const raw = `${result.stdout ?? ''}${result.stderr ?? ''}`;const seconds = Math.round((Date.now() - started) / 1000);const blocked = (output) => (result.status === 0 ? null : sandboxBlockedOperation(root, output));- if (!stages) return { isGreen: result.status === 0, output: raw, seconds, environment, sandboxBlocked: blocked(raw) };- if (!split) return { isGreen: result.status === 0, output: raw, seconds, environment, stages: null, sandboxBlocked: blocked(raw) };- if (!stages) return { isGreen: result.status === 0, output: raw, seconds, ...(timed ? { timedOut: result.timedOut } : {}), sandboxBlocked: blocked(raw) };- if (!split) return { isGreen: result.status === 0, output: raw, seconds, stages: null, ...(timed ? { timedOut: result.timedOut } : {}), sandboxBlocked: blocked(raw) };++ if (!stages) return { isGreen: result.status === 0, output: raw, seconds, environment, ...(timed ? { timedOut: result.timedOut } : {}), sandboxBlocked: blocked(raw) };++ if (!split) return { isGreen: result.status === 0, output: raw, seconds, environment, ...(timed ? { timedOut: result.timedOut } : {}), stages: null, sandboxBlocked: blocked(raw) };const staged = readStages(raw, marker, split.length);// Each pipeline component's own status rides on its stage, so no failing producer hides behind a later one.const withPipes = staged.stages.map((stage, index) => (pipeStatuses?.[index] ? { ...stage, pipeline: pipeStatuses[index] } : stage));- return { isGreen: result.status === 0, seconds, environment, ...staged, stages: withPipes, sandboxBlocked: blocked(staged.output) };- return { isGreen: result.status === 0, seconds, ...(timed ? { timedOut: result.timedOut } : {}), ...staged, stages: withPipes, sandboxBlocked: blocked(staged.output) };++ return { isGreen: result.status === 0, seconds, environment, ...(timed ? { timedOut: result.timedOut } : {}), ...staged, stages: withPipes, sandboxBlocked: blocked(staged.output) };}/** Refuse an environment-blocked proof after its ordinary raw logs and timings are persisted. */@@@ -338,10 -341,9 +347,10 @@@ export function runProfiledShell(root,// The registered worker returns the same complete stage/component accounting as a local run.gateLease?.tracker?.mark('runAt');const run = gateLease?.runner ? { ...runOnRunner(root, command, { runner: gateLease.runner, source: gateLease.source,- browser: gateLease.browser, pipefail, stages, waivers: landing ? waivers : [], metadata: { ...(gateLease.runMetadata ?? {}), landing } }) }- : runShell(root, command, { pipefail, env: inherited, stages });+ browser: gateLease.browser, pipefail, stages, waivers: landing ? waivers : [], metadata: { ...(gateLease.runMetadata ?? {}), landing, ...(timeoutMs ? { timeoutMs } : {}) } }) }+ : runShell(root, command, { pipefail, env: inherited, stages, timeoutMs });gateLease?.tracker?.mark('ranAt');+ if (gateLease) gateLease.environment = run.environment ?? null;const sandboxBlocked = run.isGreen ? null : run.sandboxBlocked ?? (run.executionRunner// The controller cannot realpath remote files; retain the network denial signal without treating remote paths as local paths.? sandboxBlockedOperation(root, run.output, { includeFilePaths: false })@@@ -693,7 -689,7 +702,7 @@@ function fullGateRun(root, config, trusconst receiptId = run.sandboxBlocked ? null : leaveRunReceipt(root, config, run, { before, kind });refuseSandboxBlocked(run);if (isGreen && before !== null && committedTree(root) === before) writeFileSync(gitPath(root, STAMP), `${before}\n`);- return { isGreen, isCached: false, output, seconds, log, profile, profilePath, receiptId, environment: run.environment ?? null, ...(run.executionRoot ? { executionRoot: run.executionRoot } : {}),- return { isGreen, isCached: false, output, seconds, log, profile, profilePath, receiptId, ...(run.timedOut ? { timedOut: true } : {}), ...(run.executionRoot ? { executionRoot: run.executionRoot } : {}),++ return { isGreen, isCached: false, output, seconds, log, profile, profilePath, receiptId, ...(run.timedOut ? { timedOut: true } : {}), environment: run.environment ?? null, ...(run.executionRoot ? { executionRoot: run.executionRoot } : {}),// A remote run's host load and pinned main reach the flake diagnostics with it (#925)....(run.executionRunner ? { executionRunner: run.executionRunner, executionMain: run.executionMain ?? null, executionLoad: run.executionLoad ?? null } : {}), ...(stages ? { stages: run.stages } : {}) };}diff --cc src/land.jsindex e72a68aa,78219dfa..b7d0d5fc--- a/src/land.js+++ b/src/land.js@@@ -357,12 -329,14 +358,16 @@@ async function gateGroup(state, label)submissions: state.batch.items.map(({ id, commit }) => ({ id, commit })),failures: [...new Set(landingFailures(gate.output, state.batch.root, { excludeCancelled: true }).map(failure => failure.file).filter(Boolean))],fileTimes: landingFileTimes(state.batch.root, gate.profile) };- await save(state, { gateResults: [...state.gates.values()].map(({ tree: testedTree, isGreen, failures, accounted, complete, requiresGreen, logPath: log, flakeDiagnostics, timedOut }) =>+ const warnings = gate.environment ? environmentWarnings(state.board, state.batch.items, gate.environment) : [];+ for (const warning of warnings) state.say(`#${warning.item} was checked on ${environmentLabel(warning.recorded)}; this landing ran on ${environmentLabel(warning.landing)}`);- await save(state, { environmentWarnings: warnings, gateResults: [...state.gates.values()].map(({ tree: testedTree, isGreen, failures, accounted, complete, requiresGreen, logPath: log, flakeDiagnostics, environment: executor }) =>- ({ tree: testedTree, isGreen, failures, accounted: accounted ?? null, complete: complete ?? null, requiresGreen: Boolean(requiresGreen), logPath: log,++ await save(state, { environmentWarnings: warnings, gateResults: [...state.gates.values()].map(({ tree: testedTree, isGreen, failures, accounted, complete, requiresGreen, logPath: log, flakeDiagnostics, environment: executor, timedOut }) =>+ ({ tree: testedTree, isGreen, ...(timedOut ? { timedOut: true } : {}), failures, accounted: accounted ?? null, complete: complete ?? null, requiresGreen: Boolean(requiresGreen), logPath: log,- ...(flakeDiagnostics ? { flakeDiagnostics } : {}) })),+ environment: executor ?? null, ...(flakeDiagnostics ? { flakeDiagnostics } : {}) })),invariantEvidence: { ...evidence, gates: [...evidence.gates, tested] } });+ if (gate.timedOut) {+ await save(state, { state: 'blocked', timedOut: true });+ throw new Refused('LAND_GATE_TIMEOUT', 'the landing gate timed out; its process tree is stopped and no candidate is a culprit');+ }return result;}@@@ -880,9 -852,10 +901,13 @@@ export async function runLandingBatch(// Pin accepted policy after any recorded-landed repair, never before admission or from candidate files.config ??= policyAt(root, trunk.commit).config;board.quarantineEnabled = () => config.flakes?.quarantine === true;+ const environment = dryRun ? null : requireLandingHost(store.boardId(board), config);+ const testDefects = heldTestDefects(root, board, trunk);+ if (!dryRun && testDefects.length) throw new Refused('LAND_TEST_DEFECT', `this trunk is held by ${testDefects.map(defect => `#${defect.item} (${defect.test})`).join(', ')}; correct the committed test or ask an approver for an expiring waiver`);+ if (!dryRun && !adopt && !unfinished) {+ const deferred = cadenceDeferral(board, config, trunk.branch, say);+ if (deferred) return deferred;+ }const selected = candidates(board, root, trunk.commit, maximum);const stale = selected.blocked.find(item => item.code === 'STALE_VERDICT');if (!selected.ready.length && stale) throw staleVerdictRefusal({ item_id: stale.id }, stale);@@@ -919,8 -892,7 +944,8 @@@if (!landsOnTrunk(config)) requirePushTarget(root, trunk.branch);const id = randomUUID();const directory = join(repoInfo(root).commonDir, 'pullboard', 'landings', id);- batch = { version: 1, id, base: trunk.commit, tip: trunk.commit, branch: trunk.branch, root: join(directory, 'worktree'),+ batch = { version: 1, id, startedAt: new Date().toISOString(), base: trunk.commit, tip: trunk.commit, branch: trunk.branch, root: join(directory, 'worktree'),+ ...(environment ? { environment } : {}),candidates: selected.ready.map(landingEntry),items: selected.ready.map(landingEntry), conflicts: [], blocked: selected.blocked,state: 'merging', owner, logPath: join(directory, 'logs', 'batch.log'), revision: 0 };@@@ -929,54 -901,56 +954,59 @@@git(root, ['worktree', 'add', '--detach', batch.root, batch.base]);}const state = { root, board, config, write, say, onWait, checkLease, checkLeaseNow, batch, culprits: batch.culprits ?? [], flaky: false, gates: new Map((batch.gateResults ?? []).map((result) => [result.tree, result])), diagnosed: new Map((batch.diagnostics ?? []).map((result) => [result.test, result.isGreen])) };- await save(state, { owner });- await returnCulprits(state);- if (state.batch.state === 'trunk') await finishTrunk(state);- else if (state.batch.state === 'pushed' || state.batch.state === 'ready') await publish(state);- else {- const initialItems = (state.batch.candidates ?? state.batch.items)- .filter((entry) => !state.culprits.some((culprit) => culprit.id === entry.id && culprit.commit === entry.commit));- if (!existsSync(state.batch.root)) throw new Refused('LAND_WORKTREE', `the recorded landing worktree is missing at ${state.batch.root}; restore it before adopting`);- const build = await mergeGroup(state, initialItems);- await save(state, { ...build, conflicts: [...state.batch.conflicts, ...build.conflicts] });- for (const entry of state.batch.blocked ?? []) say(`${entry.code} #${entry.id}${entry.stacked ? ` carries #${entry.stacked}` : ''}`);- if (!build.items.length) await save(state, { state: 'blocked' });- else if (landsOnTrunk(state.config)) await landOnTrunk(state);- else if (!await inlineDeferredGuards(state)) await save(state, { state: 'blocked' });+ try {+ await save(state, { owner });+ await returnCulprits(state);+ if (state.batch.state === 'trunk') await finishTrunk(state);+ else if (state.batch.state === 'pushed' || state.batch.state === 'ready') await publish(state);else {- let gate = await gateGroup(state, 'batch');- let proof = gate.isGreen ? null : waivedProof(state, gate);- if (!gate.isGreen && !proof) {- const flakyFiles = await diagnose(state, gate.failures, gate);- if (flakyFiles.length) { await fileFlakes(state, gate, flakyFiles); state.flaky = true; }- else {- const green = await bisect(state, build.items, gate.failures);- if (!state.flaky && green.length) {- const rebuilt = await mergeGroup(state, green);- await save(state, { ...rebuilt, culprits: state.culprits });- // The smaller final tree lost the removed items' changes, so the kept items' deferred files run again on it.- if (!await inlineDeferredGuards(state)) {- await save(state, { state: 'blocked', culprits: state.culprits });- gate = null;- } else {- gate = await gateGroup(state, 'green-items');- proof = gate.isGreen ? null : waivedProof(state, gate);- if (!gate.isGreen && !proof) {- if (!state.culprits.length) { await fileTestDefects(state, gate); state.flaky = true; }- else {- await save(state, { state: 'blocked', failures: gate.failures, culprits: state.culprits });- throw new Refused('LAND_INTERACTION', 'the individually green items fail together; nothing retries or lands; inspect the batch’s failing tests');+ const initialItems = (state.batch.candidates ?? state.batch.items)+ .filter((entry) => !state.culprits.some((culprit) => culprit.id === entry.id && culprit.commit === entry.commit));+ if (!existsSync(state.batch.root)) throw new Refused('LAND_WORKTREE', `the recorded landing worktree is missing at ${state.batch.root}; restore it before adopting`);+ const build = await mergeGroup(state, initialItems);+ await save(state, { ...build, conflicts: [...state.batch.conflicts, ...build.conflicts] });+ for (const entry of state.batch.blocked ?? []) say(`${entry.code} #${entry.id}${entry.stacked ? ` carries #${entry.stacked}` : ''}`);+ if (!build.items.length) await save(state, { state: 'blocked' });+ else if (landsOnTrunk(state.config)) await landOnTrunk(state);+ else if (!await inlineDeferredGuards(state)) await save(state, { state: 'blocked' });+ else {+ let gate = await gateGroup(state, 'batch');+ let proof = gate.isGreen ? null : waivedProof(state, gate);+ if (!gate.isGreen && !proof) {+ const flakyFiles = await diagnose(state, gate.failures, gate);+ if (flakyFiles.length) { await fileFlakes(state, gate, flakyFiles); state.flaky = true; }+ else {+ const green = await bisect(state, build.items, gate.failures);+ if (!state.flaky && green.length) {+ const rebuilt = await mergeGroup(state, green);+ await save(state, { ...rebuilt, culprits: state.culprits });+ // The smaller final tree lost the removed items' changes, so the kept items' deferred files run again on it.+ if (!await inlineDeferredGuards(state)) {+ await save(state, { state: 'blocked', culprits: state.culprits });+ gate = null;+ } else {+ gate = await gateGroup(state, 'green-items');+ proof = gate.isGreen ? null : waivedProof(state, gate);+ if (!gate.isGreen && !proof) {- await save(state, { state: 'blocked', failures: gate.failures, culprits: state.culprits });- throw new Refused('LAND_INTERACTION', 'the individually green items fail together; nothing retries or lands; inspect the batch’s failing tests');++ if (!state.culprits.length) { await fileTestDefects(state, gate); state.flaky = true; }++ else {++ await save(state, { state: 'blocked', failures: gate.failures, culprits: state.culprits });++ throw new Refused('LAND_INTERACTION', 'the individually green items fail together; nothing retries or lands; inspect the batch’s failing tests');++ }}}- }- } else if (!state.flaky) await save(state, { state: 'blocked', culprits: state.culprits });+ } else if (!state.flaky) await save(state, { state: 'blocked', culprits: state.culprits });+ }+ }+ if (!state.flaky && gate && (gate.isGreen || proof)) {+ await save(state, { state: 'ready', proof: proof ?? { tree: gate.tree, failures: [], logPath: gate.logPath }, culprits: state.culprits });+ await publish(state);}- }- if (!state.flaky && gate && (gate.isGreen || proof)) {- await save(state, { state: 'ready', proof: proof ?? { tree: gate.tree, failures: [], logPath: gate.logPath }, culprits: state.culprits });- await publish(state);}}+ } catch (error) {+ if (!(error instanceof Refused) || error.code !== 'LAND_GATE_TIMEOUT') throw error;+ say(error.message);}return { batch: state.batch, landed: state.batch.state === 'landed' ? state.batch.items.map((entry) => entry.id) : [],conflicts: state.batch.conflicts ?? [], blocked: state.batch.blocked ?? [], culprits: state.culprits, flakes: state.batch.flakes ?? [] };diff --cc src/runners.jsindex de7af454,82f9aa3e..728c526a--- a/src/runners.js+++ b/src/runners.js@@@ -557,8 -557,7 +559,8 @@@ function resultFrom(request, result)refused.runnerAttempt = { host: request.runner.host, exitCode: receipt.code, output: text };throw refused;}- return { isGreen: receipt.code === 0 && !receipt.signal, output: text, sandboxBlocked,+ return { isGreen: receipt.code === 0 && !receipt.signal, output: text, sandboxBlocked, ...(receipt.timedOut ? { timedOut: true } : {}),+ environment: receipt.environment ?? null,...(request.spec.stageMarker ? { stages: staged?.stages ?? null } : {}),seconds: Math.round(receipt.wallMs / 1000), exitCode: receipt.code,executionRunner: request.runner.host, executionRoot: receipt.root, remoteWallMs: receipt.wallMs,