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): prove the merged batch affected tests [C7,V4]
Corey Olson7860cfedfe86
diff --git a/src/land.js b/src/land.jsindex db005017..ef77d52e 100644--- a/src/land.js+++ b/src/land.js@@ -55,6 +55,9 @@ import {receiptStore,} from './gate-run-receipt.js';import { testsNeedBrowser } from './browser-admission.js';+import { testsNeedGui } from './gui-admission.js';+import { selectAffectedTests } from './affected-tests.js';+import { selectRegistryGuards } from './registry-guards.js';import { laneOf } from './lanes.js';import { takeLandingResource } from './landing-resource.js';import {@@ -1080,18 +1083,35 @@ export function landsOnTrunk(config) {}/**- * The quick guards a tier-1 landing runs on its merged tree (#801): the project's static checks and its submit- * invariants. Each item's frozen check already ran at verify, and the whole suite runs at publish.+ * Prove a tier-1 batch's actual merged diff with submit's affected map (#1277). Fixed invariants and registry+ * guards remain a floor; an uncertain import graph requires the configured full gate before adoption.*/async function quickGuards(state) {const root = state.batch.root;await runStaticChecks(root, state.config, { agent: 'coordinator', onWait: state.onWait });- const invariants = [...new Set(state.config.submitInvariants ?? [])].sort();- if (!invariants.length) return;- const command = `${state.config.affectedTests} ${invariants.map(quote).join(' ')}`;- const run = await withGateSlot(root, lease => runProfiledShell(root, command, { waitMs: lease.waitMs, gateLease: lease }),- { agent: 'coordinator', kind: 'check', itemCheck: true, onWait: state.onWait });- if (!run.isGreen) throw new Refused('GATE_RED', `the submit invariants are red on the merged tree: ${invariants.join(', ')}`);+ const commit = headCommit(root);+ const tree = headTree(root);+ const selection = state.config.affectedTests+ ? selectAffectedTests(root, { base: state.batch.base, commit })+ : { full: true, reason: 'affected-test selection is not enabled for this project', files: [] };+ const registry = selectRegistryGuards(root, state.config.registryGuards, { base: state.batch.base });+ const files = [...new Set([...(state.config.submitInvariants ?? []), ...registry, ...(!selection.full ? selection.files : [])])].sort();+ if (files.length) {+ const command = `${state.config.affectedTests} ${files.map(quote).join(' ')}`;+ const browser = !browserFreeChecksEnabled() || await testsNeedBrowser(root, files);+ const run = await withLandingGateSlot(root, lease => runProfiledShell(root, command, { waitMs: lease.waitMs, gateLease: lease, stages: true }),+ { agent: 'coordinator', kind: 'gate', landing: true, browser, gui: testsNeedGui(root, files), onWait: state.onWait });+ if (headCommit(root) !== commit || headTree(root) !== tree || !isClean(root)) {+ throw new Refused('LAND_SOURCE_CHANGED', 'the landing source changed while its affected tests ran; restore the recorded batch before adopting');+ }+ state.say(`batch affected tests: ${files.length} file(s) ${run.isGreen ? 'green' : 'red'} on the merged tree`);+ if (!run.isGreen) throw new Refused('GATE_RED', `the batch affected tests are red on the merged tree: ${files.join(', ')}`);+ }+ if (selection.full) {+ state.say(`batch affected tests require the full gate: ${selection.reason}`);+ const gate = await gateGroup(state, 'affected');+ if (!gate.isGreen) throw new Refused('GATE_RED', 'the full affected gate is red on the merged tree; inspect its recorded failures before landing');+ }}/** The affected test files each batch item's submission moved to the landing gate, read from its exact submit. */diff --git a/test/land.test.js b/test/land.test.jsindex a9e899ae..f4b99600 100644--- a/test/land.test.js+++ b/test/land.test.js@@ -1402,7 +1402,7 @@ test('publish pushes only a head the whole suite passed and names every red [B3,assert.equal(box.git(box.remote, 'rev-parse', 'main'), fixed, 'only the head the whole suite passed reaches the remote');});-test('an accepted item lands on the local trunk before the whole suite runs [B3,R3]', () => {+test('an uncertain affected batch passes its full gate before local adoption [B3,R3,C7,V4]', () => {const box = landProject();const path = join(box.repo, 'pullboard.json');const config = JSON.parse(readFileSync(path, 'utf8'));@@ -1417,14 +1417,14 @@ test('an accepted item lands on the local trunk before the whole suite runs [B3,assert.equal(result.batch.state, 'landed');assert.equal(box.git(box.repo, 'rev-parse', 'main'), result.batch.tip, 'the local trunk holds the landed batch');assert.equal(box.git(box.remote, 'rev-parse', 'main'), remoteBefore, 'tier 1 pushes nothing');- assert.deepEqual(calls(box).slice(start), [], 'no whole-suite run before the items land');+ assert.equal(calls(box).length - start, 1, 'an unsupported fixture graph requires one full gate before adoption');const merges = box.git(box.repo, 'rev-list', '--first-parent', `${result.batch.base}..${result.batch.tip}`).split('\n');for (const entry of entries) assert.ok(merges.includes(json(box, box.repo, 'show', String(entry.item)).item_merged_commit), `#${entry.item} has its merged receipt on the local trunk`);// Tier 2 then runs the whole suite once on that exact head and pushes it.const published = json(box, box.repo, 'publish');assert.equal(published.published, true);assert.equal(box.git(box.remote, 'rev-parse', 'main'), result.batch.tip);- assert.equal(calls(box).length - start, 1, 'publish ran the whole suite once');+ assert.equal(calls(box).length - start, 2, 'publish also proves its exact trunk head before pushing');});test('a publish gate run is recorded and a red and green pair it sees files the flake [C7,D1]', () => {