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): run deferred tests in every landing mode, pinned [C7]
Corey Olson2ab7c7124097
diff --git a/src/land.js b/src/land.jsindex d514ccc0..ee6279f0 100644--- a/src/land.js+++ b/src/land.js@@ -636,9 +636,15 @@ async function deferredGuards(state) {const deferred = deferredSelections(state);if (!deferred.length) return;const files = [...new Set(deferred.flatMap((row) => row.files))].sort();+ const tree = headTree(root);+ const commit = headCommit(root);const browser = !browserFreeChecksEnabled() || await testsNeedBrowser(root, files);const run = await withGateSlot(root, lease => runProfiledShell(root, `${state.config.affectedTests} ${files.map(quote).join(' ')}`, { waitMs: lease.waitMs, gateLease: lease, stages: true }),{ agent: 'coordinator', kind: 'gate', landing: true, browser, onWait: state.onWait });+ // The same pin as the full landing gate: a result only counts for the exact merged tree it ran on.+ if (headCommit(root) !== commit || headTree(root) !== tree || !isClean(root)) {+ throw new Refused('LAND_SOURCE_CHANGED', 'the landing source changed while the deferred affected tests ran; restore the recorded batch before adopting');+ }state.say(`deferred affected tests: ${files.length} file(s) ${run.isGreen ? 'green' : 'red'} on the merged tree`);if (run.isGreen) return;const failures = landingFailures(run.output, root);@@ -653,6 +659,15 @@ async function deferredGuards(state) {throw new Refused('GATE_RED', `the deferred affected tests are red on the merged tree: ${[...failed].join(', ') || 'no failing file was named; inspect the merged tree'}`);}+/** Run the deferred affected tests before an inline landing's gate; false when they are red and nothing may land. */+async function inlineDeferredGuards(state) {+ try { await deferredGuards(state); return true; } catch (error) {+ if (!(error instanceof Refused) || error.code !== 'GATE_RED') throw error;+ state.say(`nothing landed: ${error.message}`);+ return false;+ }+}+/*** Tier 1 (#801): after a clean merge and its quick guards, the batch lands on the local trunk in seconds, with each* item's merged receipt; nothing is pushed. pullboard publish runs the whole suite on the trunk head and pushes it.@@ -755,6 +770,7 @@ export async function land({ root, board, config, write, say, owner, maximum = Ifor (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);diff --git a/test/gate.test.js b/test/gate.test.jsindex f2909cb6..c5125089 100644--- a/test/gate.test.js+++ b/test/gate.test.js@@ -780,11 +780,16 @@ test('a hand-recorded run never quarantines a test [C7,D1]', async (t) => {});/** A web project whose one source file is imported by thirty test files, each recording its own run. */-function largeSelectionProject(deferAbove) {+function largeSelectionProject(deferAbove, { inline = false } = {}) {const box = e2e.project('true');const config = JSON.parse(readFileSync(join(box.repo, 'pullboard.json'), 'utf8'));writeFileSync(join(box.repo, 'pullboard.json'), JSON.stringify({ ...config, submitGate: 'landing', affectedTests: 'node --test',- submitInvariants: ['web/guard.test.js'], landing: { publish: 'separate' }, ...(deferAbove ? { submitDeferAbove: deferAbove } : {}) }, null, 2));+ submitInvariants: ['web/guard.test.js'], ...(inline ? {} : { landing: { publish: 'separate' } }), ...(deferAbove ? { submitDeferAbove: deferAbove } : {}) }, null, 2));+ if (inline) {+ // An inline landing pushes its gated tip, so it needs a remote; its gate (true) would pass anything.+ box.git(box.dir, 'init', '-q', '--bare', join(box.dir, 'origin.git'));+ box.git(box.repo, 'remote', 'add', 'origin', join(box.dir, 'origin.git'));+ }writeFileSync(join(box.repo, 'package.json'), '{"type":"module"}\n');mkdirSync(join(box.repo, 'web'), { recursive: true });writeFileSync(join(box.repo, 'web/core.js'), 'export const value = 1;\n');@@ -859,6 +864,18 @@ test('a large affected selection is deferred to landing at submit [C7]', () => {assert.equal(reopened.item_merged_commit, null);assert.ok(reopened.thread.some(entry => entry.kind === 'reopen' && /web\/selected-00\.test\.js/u.test(entry.detail.note)), 'the reopen names the failing deferred file');+ const inline = largeSelectionProject(20, { inline: true });+ const inlineRed = inline.submitChange('red');+ assert.deepEqual(inlineRed.ran, ['guard']);+ inline.accept(inlineRed.id, inlineRed.receipt.commit);+ const inlineLanding = inline.box.run(inline.box.repo, 'land', '--json');+ assert.equal(inlineLanding.code, 0, inlineLanding.err + inlineLanding.out);+ assert.deepEqual(JSON.parse(inlineLanding.out).landed, [], 'an inline landing whose gate passes anything still runs the deferred files and lands nothing on red');+ const inlineItem = JSON.parse(inline.box.run(inline.box.repo, 'show', String(inlineRed.id), '--json').out);+ assert.notEqual(inlineItem.item_status, 'verified', 'the inline red item is sent back');+ assert.equal(inlineItem.item_merged_commit, null);+ assert.ok(inline.ran().length > 1, 'the inline landing ran the deferred files');+const off = largeSelectionProject(null).submitChange(2);assert.equal(off.proof.submissionProof.deferredFiles, undefined);assert.deepEqual(off.ran.sort(), all, 'with the setting off, submit runs all thirty as today');