Skip to content

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.

fix(land): block failed generators without conflict returns [B3,R3,C7]

Corey Olsonb2364cb8dd29
diff --git a/src/land.js b/src/land.js
index 3242bcd7..9b7b65cd 100644
--- a/src/land.js
+++ b/src/land.js
@@ -277,6 +277,10 @@ async function mergeGroup(state, items) {
const files = tryGit(batch.root, ['diff', '--name-only', '--diff-filter=U']).stdout.split('\n').filter(Boolean);
if (!files.length) throw new Refused('LAND_MERGE', `merge of #${item.item_id} failed outside a conflict: ${result.stderr || result.stdout}; inspect ${batch.root} and its hooks before adopting`);
const resolution = resolveMechanicalIndex(batch.root, files);
+ if (resolution.failed) {
+ git(batch.root, ['merge', '--abort']);
+ throw new Refused('LAND_MERGE', `item #${item.item_id}: generator ${resolution.failed.generator} failed for ${resolution.failed.path} (exit ${resolution.failed.status ?? 'unavailable'}); repair the generator before adopting this landing`);
+ }
if (!resolution.files.length) {
git(batch.root, ['add', '--', ...files]);
git(batch.root, ['commit', '--no-edit']);
diff --git a/src/mechanical-merge.js b/src/mechanical-merge.js
index 5f2f9164..171118c5 100644
--- a/src/mechanical-merge.js
+++ b/src/mechanical-merge.js
@@ -241,7 +241,9 @@ export function resolveMechanicalIndex(root, files) {
for (const entry of resolutions.filter(entry => entry.kind === 'generated')) {
const generated = spawnSync(process.execPath, GENERATED.get(entry.path),
{ cwd: root, env: cleanGitEnvironment(), timeout: 30_000, maxBuffer: 32 * 1024 * 1024 });
- if (generated.status !== 0) return { files: [entry.path], entries: [] };
+ if (generated.status !== 0) return { files: [], entries: [], failed: {
+ path: entry.path, generator: GENERATED.get(entry.path).join(' '), status: generated.status,
+ } };
writeFileSync(join(root, entry.path), generated.stdout);
}
return { files: [], entries: resolutions.map(({ path, keys, kind }) => ({ path, keys, kind })) };
@@ -250,6 +252,6 @@ export function resolveMechanicalIndex(root, files) {
/** Preserve the legacy all-or-nothing landing API and its resolution receipt entries. */
export function resolveMechanicalMerge(root, files) {
const result = resolveMechanicalIndex(root, files);
- return result.files.length ? null : result.entries;
+ return result.failed || result.files.length ? null : result.entries;
}
diff --git a/test/mechanical-merge.test.js b/test/mechanical-merge.test.js
index 3f5950f1..fde292dd 100644
--- a/test/mechanical-merge.test.js
+++ b/test/mechanical-merge.test.js
@@ -3,7 +3,7 @@ import assert from 'node:assert/strict';
import { after, test } from 'node:test';
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
-import { tmpdir } from 'node:os';
+import { hostname, tmpdir } from 'node:os';
import { runFixtureChild, runFixtureGit } from './fixture-child.js';
import { cleanGitEnvironment } from '../src/git.js';
import { conflictFiles } from '../src/health.js';
@@ -20,6 +20,9 @@ import reopenMove from '../src/moves/reopen.js';
import { MECHANICAL_MERGE_ENGINE } from '../src/mechanical-merge-engine.js';
import { AGENT_GRANT_ENGINE } from '../src/agent-grant-engine.js';
+console.log('# MECHANICAL_RUNTIME ' + JSON.stringify({ node: process.version, execPath: process.execPath,
+ platform: process.platform, arch: process.arch, host: hostname(), binarySha256: createHash('sha256').update(readFileSync(process.execPath)).digest('hex') }));
+
const directories = [];
after(() => directories.forEach(root => rmSync(root, { recursive: true, force: true })));
const e2e = createE2eHelpers();