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): skip admission for idle landings [E25,E26]
Corey Olson63802eec637a
diff --git a/src/land.js b/src/land.jsindex ca62e8e6..eba64232 100644--- a/src/land.js+++ b/src/land.js@@ -42,6 +42,7 @@ import {} from './gate-run-receipt.js';import { laneOf } from './lanes.js';import { takeResource } from './resources.js';+import { landingLeaseState, requireConfirmedLanding } from './landing-lease.js';import { runLandingWorker } from './landing-worker.js';import { Refused } from './refused.js';import { policyAt } from './trusted-policy.js';@@ -659,11 +660,44 @@ async function finishTrunk(state) {state.say(`landed ${state.batch.items.map((entry) => `#${entry.id}`).join(', ')} at ${state.batch.tip} on the local trunk; pullboard publish pushes it once the whole suite passes`);}+/** Skip admission only when no queued owner, interrupted batch or recorded Git repair needs it. */+function idleLanding(board, trunk) {+ const lease = landingLeaseState(board);+ if (lease.holder || lease.line.length) return false;+ return !store.landingBatches(board).some(batch =>+ (batch.state !== 'landed' && batch.state !== 'blocked')+ || (batch.state === 'landed' && batch.base === trunk));+}++/** Preserve the existing empty selection's refusal, blocked reports and result shape. */+function emptyLanding(selected, say) {+ const stale = selected.blocked.find(item => item.code === 'STALE_VERDICT');+ if (stale) throw staleVerdictRefusal({ item_id: stale.id }, stale);+ for (const entry of selected.blocked) say(`${entry.code} #${entry.id}${entry.stacked ? ` carries #${entry.stacked}` : ''}`);+ return { batch: null, landed: [], conflicts: [], blocked: selected.blocked, culprits: [], flakes: [] };+}+/** Build, gate, diagnose and durably land one coordinator batch; all external actions stay in its worktree. */export async function land(options) {if (options.dryRun) return runLandingBatch(options);- const branch = mainCheckout(options.root)?.branch;+ invalidateGitFacts();+ const trunk = mainCheckout(options.root);+ const branch = trunk?.branch;if (!branch) throw new Refused('LAND_TRUNK', 'landing needs the coordinator’s primary branch; return its checkout to the trunk');+ if (trunk.commit && !options.adopt && idleLanding(options.board, trunk.commit)) {+ requireConfirmedLanding(options.board);+ // Only accepted trunk policy may inform this read-only preflight.+ const config = policyAt(options.root, trunk.commit).config;+ options.board.quarantineEnabled = () => config.flakes?.quarantine === true;+ const selected = candidates(options.board, options.root, trunk.commit, options.maximum ?? Infinity);+ invalidateGitFacts();+ const current = mainCheckout(options.root);+ if (!selected.ready.length && current?.commit === trunk.commit && current.branch === branch+ && idleLanding(options.board, trunk.commit)) {+ requireConfirmedLanding(options.board);+ return emptyLanding(selected, options.say);+ }+ }let lastWait = '';const controller = new AbortController();const lease = await takeResource({ name: 'landing', scope: 'board', capacity: 1, board: options.board, write: options.write, branch,@@ -750,10 +784,7 @@ export async function runLandingBatch({ root, board, config, write, say, owner,await write('recordLandingBatch', [{ agentId: 'coordinator', batch: { ...batch, state: 'blocked', supersededByMain: trunk.commit }, revision: batch.revision }]);batch = null;}- if (!batch && !selected.ready.length) {- for (const entry of selected.blocked) say(`${entry.code} #${entry.id}${entry.stacked ? ` carries #${entry.stacked}` : ''}`);- return { batch: null, landed: [], conflicts: [], blocked: selected.blocked, culprits: [], flakes: [] };- }+ if (!batch && !selected.ready.length) return emptyLanding(selected, say);if (!batch) {if (!landsOnTrunk(config)) requirePushTarget(root, trunk.branch);const id = randomUUID();diff --git a/test/landing-noop.test.js b/test/landing-noop.test.jsnew file mode 100644index 00000000..f500d401--- /dev/null+++ b/test/landing-noop.test.js@@ -0,0 +1,65 @@+/** Empty landings preserve history without bypassing an existing landing owner [E25,E26,B3]. */+import assert from 'node:assert/strict';+import { randomUUID } from 'node:crypto';+import { join } from 'node:path';+import { after, test } from 'node:test';+import * as store from '../src/board.js';+import { createE2eHelpers } from './e2e-helpers.js';+import { startFixtureChild } from './fixture-child.js';++const helpers = createE2eHelpers();+after(helpers.cleanup);++/** Use production board functions only within this test's private fixture. */+function onBoard(box, work) {+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));+ try { return work(board); } finally { store.closeBoard(board); }+}++test('an idle empty land takes no lease and writes no event [E25,E26,B3]', () => {+ const box = helpers.project('true');+ const before = onBoard(box, board => ({ events: store.events(board), lease: store.landingLeaseState(board) }));+ const head = box.git(box.repo, 'rev-parse', 'HEAD');+ const result = box.run(box.repo, 'land', '--json');+ assert.equal(result.code, 0, result.err);+ assert.deepEqual(JSON.parse(result.out).landed, []);+ assert.deepEqual(onBoard(box, board => ({ events: store.events(board), lease: store.landingLeaseState(board) })), before,+ 'neither an admission generation nor any board event changes');+ assert.equal(box.git(box.repo, 'rev-parse', 'HEAD'), head);+ assert.equal(onBoard(box, board => store.landingBatches(board).length), 0);+ const adopted = box.run(box.repo, 'land', '--adopt', '--json');+ assert.equal(adopted.code, 1, 'an explicit adoption is not a successful empty landing');+ assert.equal(JSON.parse(adopted.out).error.code, 'LAND_ADOPT');+});++test('an empty land still queues behind a live landing owner [E25,B3]', async t => {+ const box = helpers.project('true');+ const token = randomUUID();+ const held = onBoard(box, board => store.landingLeaseMove(board,+ { agentId: 'coordinator', action: 'request', token, branch: 'main', pid: process.pid }));+ const release = () => onBoard(box, board => store.landingLeaseMove(board,+ { agentId: 'coordinator', action: 'release', token, generation: held.generation }));+ const child = startFixtureChild(process.execPath, [helpers.BIN, 'land'],+ { cwd: box.repo, env: box.env, stdio: ['ignore', 'pipe', 'pipe'] });+ let stdout = ''; let stderr = '';+ child.stdout.setEncoding('utf8').on('data', part => { stdout += part; });+ child.stderr.setEncoding('utf8').on('data', part => { stderr += part; });+ const closed = new Promise(resolveClose => child.once('close', code => resolveClose(code)));+ t.after(async () => {+ release();+ if (child.exitCode === null && child.signalCode === null) child.kill('SIGTERM');+ await closed;+ });+ await helpers.waitFor(() => /landing waiting:/u.test(stdout + stderr), 'the empty land to name its live holder');+ assert.equal(child.exitCode, null, 'an empty selection cannot bypass an occupied landing lease');+ const queued = onBoard(box, board => store.landingLeaseState(board));+ assert.equal(queued.holder.token, token);+ assert.equal(queued.line.length, 1);+ release();+ assert.equal(await closed, 0, stderr);+ assert.match(stdout, /no verified items ready to land/u);+ const finished = onBoard(box, board => store.landingLeaseState(board));+ assert.equal(finished.holder, null);+ assert.deepEqual(finished.line, []);+ assert.equal(finished.generation, held.generation + 1, 'the waiter really acquired its own admission');+});