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): accept names the land step; dry run checks origin [I1,B3]
Corey Olsone4f39fa8d489
diff --git a/src/cli.js b/src/cli.jsindex 9ccc8f9c..38cbfdae 100644--- a/src/cli.js+++ b/src/cli.js@@ -85,7 +85,7 @@ import { readRelayMachine } from './relay-machine.js';import { relayJoin, relayPair } from './relay-pairing-client.js';import { executePersonRequests } from './relay-request-execution.js';import { engineReceipt } from './engine.js';-import { land } from './land.js';+import { land, landingRemote, landingSubject } from './land.js';const CHECKOUT_LEASES = new WeakMap();const CHECKOUT_BOARD_ONLY = new WeakMap();@@ -2190,7 +2190,9 @@ async function verifyHere(ctx, id, { second, values }) {if (!decision) throw new Refused('USAGE', 'pullboard verify <id> accept, or reject --reason CODE --note "..."');const { root } = ctx.info;let verificationProfile = null;- const result = await withBoard(ctx, async (board) => {+ let accepted = null;+ /** Record one verdict on the open board. */+ const decide = async (board) => {checkMainVerifier(ctx, board, values);const me = whoAmI(ctx, board);const recovered = relayRecovered(root);@@ -2255,6 +2257,11 @@ async function verifyHere(ctx, id, { second, values }) {familyPolicy: ctx.config.verify.family,...(decision === 'ACCEPT' ? { check: check.checked ? 'green' : 'none' } : {}),}]);+ };+ const result = await withBoard(ctx, async (board) => {+ const verdict = await decide(board);+ if (verdict.decision === 'ACCEPT') accepted = store.getItem(board, id);+ return verdict;});ctx.io.result?.({ id, ...result });const verifiedSummary = timingDigest(verificationProfile);@@ -2262,9 +2269,26 @@ async function verifyHere(ctx, id, { second, values }) {ctx.io.say(result.decision === 'ACCEPT'? `verified #${id}: ${result.reason}${result.check === 'none' ? '; no frozen check ran' : ''}${verifiedTiming}`: `rejected #${id}: ${result.reason}; it is open again for rework`);+ if (accepted) ctx.io.say(landNext(ctx.info, accepted));return 0;}+/**+ * Say the exact command that lands an accepted item in this repo [B3].+ * A repo with a push remote lands through pullboard land; one without merges by hand,+ * because pullboard land would refuse LAND_PUSH there.+ *+ * @param {any} info+ * @param {any} item+ * @returns {string}+ */+function landNext(info, item) {+ const mainRoot = resolve(info.commonDir, '..');+ const branch = mainCheckout(info.root)?.branch ?? '';+ if (landingRemote(info.root, branch)) return `next: the coordinator lands it: ${cdTo(mainRoot)} pullboard land`;+ return `next: this repo has no remote for pullboard land to push to, so the coordinator merges it on ${branch.replace(/^refs\/heads\//u, '') || 'the trunk'}: ${cdTo(mainRoot)} git merge --no-ff ${item.item_commit} -m ${shellWord(landingSubject(item))} && pullboard merged ${item.item_id} HEAD`;+}+/*** One loop of `next`: claim the next free item, or reserve the next review (V15). A claim that loses* a race to another agent is not an error; the caller looks again. A review is looked for anddiff --git a/src/land.js b/src/land.jsindex 03816629..5531fc00 100644--- a/src/land.js+++ b/src/land.js@@ -221,10 +221,41 @@ async function fileFlakes(state, gate, files) {state.say(`flake: ${files.join(', ')}; nothing landed; fix the test or ask the person for an expiring waiver`);}+/** Name the remote a landing pushes the trunk to: the trunk branch's own remote, else origin [B3]. */+function landingRemoteName(root, branch) {+ return tryGit(root, ['config', '--get', `branch.${branch.replace(/^refs\/heads\//u, '')}.remote`]).stdout || 'origin';+}++/**+ * Name the configured remote a landing would push the trunk to, or null when this repo has none [B3].+ * An accept uses it to say which landing command fits this repo; the landing itself refuses on null.+ */+export function landingRemote(root, branch) {+ const remote = landingRemoteName(root, branch);+ return tryGit(root, ['remote', 'get-url', remote]).status === 0 ? remote : null;+}++/** Build the one LAND_PUSH refusal every landing push failure reports, real or previewed [B3]. */+function pushRefused(reason, next = 'inspect the remote and hooks, then run pullboard land --adopt') {+ return new Refused('LAND_PUSH', `the landing push failed: ${reason}; ${next}`);+}++/**+ * Return the remote a landing pushes to, refusing LAND_PUSH when it does not exist [B3].+ * The dry run and the real landing both call this, so a preview cannot say "would land" for a push that must fail.+ */+function requirePushTarget(root, branch) {+ const remote = landingRemote(root, branch);+ if (remote) return remote;+ const missing = landingRemoteName(root, branch);+ throw pushRefused(`this repo has no ${missing} remote to push ${branch.replace(/^refs\/heads\//u, '')} to`,+ `add one with git remote add ${missing} <url> and run pullboard land again, or merge each verified commit on the trunk with git merge --no-ff and record it with pullboard merged <id> <commit>`);+}+/** Push the exact gated tip before recording receipts, then fast-forward only a clean unchanged main. */async function publish(state) {let batch = state.batch;- const remote = tryGit(state.root, ['config', '--get', `branch.${batch.branch.replace(/^refs\/heads\//u, '')}.remote`]).stdout || 'origin';+ const remote = requirePushTarget(state.root, batch.branch);if (batch.proof?.failures?.length && batch.state !== 'pushed') {const failures = batch.proof.failures.map((failure) => ({ ...failure, waiver: store.landingWaiverFor(state.board, failure)?.id }));if (!failures.every((failure) => failure.waiver)) throw new Refused('LAND_WAIVER', 'the landing proof has an expired or missing person waiver; ask the person for a new expiring waiver, then adopt the batch');@@ -237,7 +268,7 @@ async function publish(state) {const alreadyPushed = tryGit(batch.root, ['ls-remote', remote, batch.branch]).stdout.split(/\s+/u)[0] === batch.tip;if (!alreadyPushed) {const pushed = tryGit(batch.root, ['push', remote, `HEAD:${batch.branch}`]);- if (pushed.status !== 0) throw new Refused('LAND_PUSH', `the landing push failed: ${pushed.stderr || pushed.stdout}; inspect the remote and hooks, then run pullboard land --adopt`);+ if (pushed.status !== 0) throw pushRefused(pushed.stderr || pushed.stdout);}await save(state, { state: 'pushed' });}@@ -263,6 +294,7 @@ export async function land({ root, board, config, write, say, owner, maximum = Iconst unfinished = store.landingBatches(board).findLast((batch) => batch.state !== 'landed' && batch.state !== 'blocked');const selected = candidates(board, root, trunk.commit, maximum);if (dryRun) {+ if (selected.ready.length) requirePushTarget(root, trunk.branch);const conflicts = [];for (const item of selected.ready) {const merge = tryGit(root, ['merge-tree', '--write-tree', '--name-only', '-z', trunk.commit, item.item_commit]);@@ -294,6 +326,7 @@ export async function land({ root, board, config, write, say, owner, maximum = Ireturn { batch: null, landed: [], conflicts: [], blocked: selected.blocked, culprits: [], flakes: [] };}if (!batch) {+ 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'),diff --git a/test/land-next.test.js b/test/land-next.test.jsnew file mode 100644index 00000000..69a897cd--- /dev/null+++ b/test/land-next.test.js@@ -0,0 +1,81 @@+/** An accept names the exact landing step for its repo, and a dry run refuses a push the real land would refuse [I1,B3]. */+import assert from 'node:assert/strict';+import { spawnSync } from 'node:child_process';+import { join } from 'node:path';+import { after, test } from 'node:test';+import { createE2eHelpers } from './e2e-helpers.js';++const e2e = createE2eHelpers();+after(e2e.cleanup);+const { project, commitFile } = e2e;++/** Escape literal text, such as a sandbox path, for a regular expression. */+const literal = (text) => text.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&');++/** File, build, submit and accept one web item through the real CLI and hooks, returning the accept output. */+function acceptedItem(box, file) {+ const added = box.run(box.repo, 'add', 'web', `Write ${file}`, '--specs', 'G1', '--criterion', `${file} exists`, '--check', `test -f ${file}`, '--json');+ assert.equal(added.code, 0, added.err);+ const id = JSON.parse(added.out).item.item_id;+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');+ assert.equal(box.run(box.web, 'claim', String(id)).code, 0);+ const committed = commitFile(box, box.web, file, 'built\n', `feat(web): write ${file.split('/').pop()} [G1]`);+ assert.equal(committed.status, 0, committed.stderr);+ const commit = box.git(box.web, 'rev-parse', 'HEAD');+ const submitted = box.run(box.web, 'submit', String(id));+ assert.equal(submitted.code, 0, submitted.err);+ box.git(box.review, 'switch', '-q', '--detach', commit);+ const verdict = box.run(box.review, 'verify', String(id), 'accept', '--note', 'the file exists at the submitted commit');+ assert.equal(verdict.code, 0, verdict.err);+ return { id, commit, out: verdict.out };+}++/** Add a reviewer in its own worktree, so the main checkout stays on main as it does for a real accept. */+function withReviewer(box) {+ const review = join(box.dir, 'review');+ box.git(box.repo, 'worktree', 'add', '-q', review, '-b', 'api/review');+ assert.equal(box.run(review, 'join', 'api').code, 0);+ return { ...box, review };+}++/** Run one CLI command for its JSON refusal. */+function refusal(box, ...args) {+ const result = box.run(box.repo, ...args, '--json');+ assert.notEqual(result.code, 0, `${args.join(' ')} should refuse: ${result.out}`);+ return JSON.parse(result.out).error;+}++test('an accept says how to land, and a dry run catches a missing origin [I1,B3]', () => {+ const box = withReviewer(project());++ // Clause 1, repo without a remote: the accept prints the exact git merge command for this repo.+ const first = acceptedItem(box, 'web/first.txt');+ const merge = new RegExp(`^next: this repo has no remote for pullboard land to push to, so the coordinator merges it on main: (cd ${literal(box.repo)} && git merge --no-ff ${first.commit} -m 'chore\\(merge\\): write web/first\\.txt \\[G1\\]' && pullboard merged ${first.id} HEAD)$`, 'mu');+ const printed = merge.exec(first.out);+ assert.ok(printed, `the accept names the hand merge for a repo without origin:\n${first.out}`);++ // Clause 2: the dry run refuses LAND_PUSH, with exactly the refusal the real land gives.+ const dry = refusal(box, 'land', '--dry-run');+ assert.equal(dry.code, 'LAND_PUSH', JSON.stringify(dry));+ assert.match(dry.message, /the landing push failed: this repo has no origin remote to push main to; add one with git remote add origin <url>/u);+ const real = refusal(box, 'land');+ assert.deepEqual(real, dry, 'the real land refuses the same way, before it gates anything');++ // The printed command is exact: running it lands the item and records the merge.+ const ran = spawnSync('/bin/sh', ['-c', printed[1]], { cwd: box.dir, env: box.env, encoding: 'utf8' });+ assert.equal(ran.status, 0, `${ran.stdout}${ran.stderr}`);+ assert.equal(box.tryGit(box.repo, 'merge-base', '--is-ancestor', first.commit, 'main').status, 0, 'main now carries the accepted commit');+ const shown = JSON.parse(box.run(box.repo, 'show', String(first.id), '--json').out);+ assert.equal(shown.item_merged_commit, box.git(box.repo, 'rev-parse', 'main'));++ // Clause 1, repo with origin: the accept prints pullboard land, and the dry run previews it.+ const remote = join(box.dir, 'origin.git');+ box.git(box.dir, 'init', '-q', '--bare', remote);+ box.git(box.repo, 'remote', 'add', 'origin', remote);+ box.git(box.repo, 'push', '-q', '-u', 'origin', 'main');+ const second = acceptedItem(box, 'web/second.txt');+ assert.match(second.out, new RegExp(`^next: the coordinator lands it: cd ${literal(box.repo)} && pullboard land$`, 'mu'));+ const preview = box.run(box.repo, 'land', '--dry-run', '--json');+ assert.equal(preview.code, 0, preview.out);+ assert.deepEqual(JSON.parse(preview.out).items, [second.id]);+});