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(merge): replay carry once and reprove at landing [H16,V4]
Corey Olsonc72690278c6d
diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex 8fb0bb1f..929af598 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -47,7 +47,7 @@ stateDiagram-v2| open | waiting for a builder; claimable once what it waits on is verified | none || claimed | an agent holds it under a lease, its criterion frozen | item_owner, item_lease_until, item_frozen_digest || submitted | a native build gated green, or an intaken outside commit awaiting sandbox verification, at a pinned commit | item_built_by, item_commit, item_frozen_digest |-| verified | another agent accepted the frozen work at this commit or its locally proved trunk-only merge | item_verified_by, item_commit |+| verified | another agent accepted the frozen work at this commit or its canonically recorded trunk-only merge | item_verified_by, item_commit || withdrawn (final) | nobody should build it; the reason stays on it | item_withdrawn_reason |## Moves@@ -95,7 +95,7 @@ Each move checks its guards in this order and refuses with the first one that do| CLOSED | refreeze: the item is in open, claimed, submitted | pullboard show <id> || CLOSED | refreeze: the item is in claimed | pullboard show <id> || CLOSED | withdraw: the item is in open, claimed, submitted | pullboard show <id> |-| MERGE_ONLY_PROOF | real local Git proves the exact gated merge carries the unwithdrawn acceptance and records its conflict resolution; serialized builder facts never authorize it | submit normally for outside review if local Git cannot prove the merge |+| MERGE_ONLY_PROOF | the sealed submit records the origin’s Git-derived carry, unchanged bar and original verifier; landing re-proves its heads, trees and resolution hash before merging | submit normally for outside review if the origin cannot prove the merge || OUTSIDE_SOURCE | an outside author and exact fetched commit/tree are recorded with a trusted frozen criterion, without pretending a native builder gated it | fetch and intake the exact GitHub pull request again || NOT_JOINED | the caller is the main checkout, or an unreplaced worktree seat that joined a lane; an agent session's claims, submits and verdicts can be checked against its local ledger | pullboard join <lane> --model "<model name>" (see: pullboard lanes) || AGENT_REPLACED | the caller is the main checkout, or an unreplaced worktree seat that joined a lane; an agent session's claims, submits and verdicts can be checked against its local ledger | read the takeover and only shout on its exact hand-off item; continue work from the incoming agent worktree |diff --git a/src/board.js b/src/board.jsindex 69342c2b..7419afea 100644--- a/src/board.js+++ b/src/board.js@@ -1122,6 +1122,14 @@ export function release(board, id, agentId, note = '') {});}+/** Derive the origin’s carry before sealing; caller-supplied carry facts are discarded. */+export function prepareMergeOnlySubmit(board, id, options) {+ const item = getItem(board, id);+ const basis = options?.gateGreen === true ? mergeOnlyBasis(board, item) : null;+ return basis && !itemAuthorProblem(board, item, basis.by)+ ? deriveMergeOnly(board.gitRoot, basis, options) : null;+}+/*** Submit your claimed item at a commit (V4, V6). The caller has already checked the tree is clean* and run the gate green at that commit.@@ -1134,7 +1142,7 @@ export function release(board, id, agentId, note = '') {* @param {{ agentId: string, commit: string, tree: string, files?: string[], policyCommit?: string, note?: string }} at - `files`: what the* item's own commits changed since its claim; a rework adds to what the first attempt changed.*/-export function submit(board, id, { agentId, commit, tree, files = [], policyCommit = null, note, submissionProof: proof, infra = null, gateGreen }) {+export function submit(board, id, { agentId, commit, tree, files = [], policyCommit = null, note, submissionProof: proof, infra = null, gateGreen, mergeOnly: recordedCarry }) {let recordedProof;if (note !== undefined && (typeof note !== 'string' || !note.trim() || /[\r\n\u2028\u2029]/u.test(note))) {throw new Refused('USAGE', 'a submission note, when present, is one nonempty line');@@ -1142,8 +1150,9 @@ export function submit(board, id, { agentId, commit, tree, files = [], policyComatomic(board, () => {const modern = (board.executionEngineVersion ?? ENGINE_VERSION) >= MERGE_ONLY_VERDICT_ENGINE;const basis = modern && gateGreen === true ? mergeOnlyBasis(board, getItem(board, id)) : null;- const mergeOnly = basis && !itemAuthorProblem(board, getItem(board, id), basis.by)- ? deriveMergeOnly(board.gitRoot, basis, { commit, tree, policyCommit }) : null;+ const mergeOnly = modern ? board.executionEngineVersion === undefined+ ? prepareMergeOnlySubmit(board, id, { commit, tree, policyCommit, gateGreen })+ : recordedCarry ?? null : null;const carry = Boolean(mergeOnly);const carriedProblem = found => mergeOnlyProblem(board, found, mergeOnly, { commit, tree, policyCommit });const notYours = () => new Refused('NOT_YOURS', `item #${id} is not claimed by you; claim it first`);diff --git a/src/engine.js b/src/engine.jsindex e9ebf895..4e23e7cc 100644--- a/src/engine.js+++ b/src/engine.js@@ -36,6 +36,7 @@ import {SUBMISSION_PROOF_ENGINE,submissionProof,} from './submit-invariants.js';+import { MERGE_ONLY_VERDICT_ENGINE } from './merge-only-verdict-engine.js';import { requireCoordinatorHold } from './coordinator-hold.js';import {@@ -92,6 +93,10 @@ export function prepareEngineMove(board, operation, args, { id = randomUUID(), aif (operation === 'reopen' && values[1] && typeof values[1] === 'object'&& manualLandingFailureQuoted(values[1].note)) values[1].quotedLandingFailure = true;if (operation === 'submit' && ENGINE_VERSION >= SUBMISSION_PROOF_ENGINE) submissionProof(values[1]?.submissionProof);+ // Derive once before sealing; replicas never re-decide a recorded carry from their local objects.+ if (operation === 'submit' && ENGINE_VERSION >= MERGE_ONLY_VERDICT_ENGINE && values[1]) {+ values[1].mergeOnly = store.prepareMergeOnlySubmit(board, values[0], values[1]);+ }if (operation === 'claim' && ['wipPerReviewer', 'takeoverMinutes'].some(key => typeof lineSettings(board)[key] === 'number')) {values[1] = { ...values[1], lineCapacity: true };}diff --git a/src/land.js b/src/land.jsindex 6a0c5943..2ec8dd36 100644--- a/src/land.js+++ b/src/land.js@@ -1,3 +1,4 @@+import { mergeOnlyLandingProblem } from './merge-only-verdict.js';import { requireOutsideOwner } from './outside-source.js';import {landingChangedFiles,@@ -966,6 +967,7 @@ function requirePushTarget(root, branch) {/** Recheck immutable publication inputs after the last awaited canonical operation. */function publicationInputs(state, batch) {+ requireLandingCarries(state, batch);for (const entry of batch.items) {const item = store.getItem(state.board, entry.id);requireOutsideOwner(state.board, item);@@ -1005,6 +1007,7 @@ function parallelPublicationRoot(state, batch) {/** Push the exact gated tip before recording receipts, then fast-forward only a clean unchanged main. */async function publish(state) {let batch = state.batch;+ requireLandingCarries(state, batch);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 }));@@ -1127,8 +1130,17 @@ async function landOnTrunk(state) {await finishTrunk(state);}+/** Reject forged or stale canonical carries even when resuming an already-gated batch. */+function requireLandingCarries(state, batch) {+ for (const entry of batch.items) {+ const problem = mergeOnlyLandingProblem(state.root, state.board, store.getItem(state.board, entry.id));+ if (problem) throw problem;+ }+}+/** Record a tier-1 batch's merged receipts and move the local trunk to it; an adopted 'trunk' batch resumes here (#801). */async function finishTrunk(state) {+ requireLandingCarries(state, state.batch);state.batch = await state.write('finishLandingBatch', [{ agentId: 'coordinator', id: state.batch.id, tip: state.batch.tip }]);await state.checkLease();const main = mainCheckout(state.root);diff --git a/src/machine.js b/src/machine.jsindex 26009aef..556ad1b5 100644--- a/src/machine.js+++ b/src/machine.js@@ -84,7 +84,7 @@ export const STATES = [{ id: 'claimed', means: 'an agent holds it under a lease, its criterion frozen', requires: ['item_owner', 'item_lease_until', 'item_frozen_digest'] },{ id: 'submitted', means: 'a native build gated green, or an intaken outside commit awaiting sandbox verification, at a pinned commit', requires: ['item_built_by', 'item_commit', 'item_frozen_digest'] },{- id: 'verified', means: 'another agent accepted the frozen work at this commit or its locally proved trunk-only merge', requires: ['item_verified_by', 'item_commit'],+ id: 'verified', means: 'another agent accepted the frozen work at this commit or its canonically recorded trunk-only merge', requires: ['item_verified_by', 'item_commit'],proof: {says: 'an immutable ACCEPT on the frozen criterion by its independent verifier, at this commit or bound by an ordered merge-only receipt',sql: "EXISTS (SELECT 1 FROM verdict v WHERE v.item_id = NEW.item_id AND v.verdict_decision = 'ACCEPT' AND v.verdict_digest = NEW.item_frozen_digest AND v.verdict_by = NEW.item_verified_by AND v.verdict_by <> NEW.item_built_by AND (v.verdict_commit = NEW.item_commit OR EXISTS (SELECT 1 FROM event e WHERE e.item_id = NEW.item_id AND e.event_kind = 'merge-only-accept' AND json_extract(e.event_detail,'$.verdict') = v.verdict_id AND json_extract(e.event_detail,'$.commit') = NEW.item_commit AND json_extract(e.event_detail,'$.tree') = NEW.item_tree AND json_extract(e.event_detail,'$.digest') = NEW.item_frozen_digest AND json_extract(e.event_detail,'$.by') = v.verdict_by)))",@@ -95,7 +95,7 @@ export const STATES = [/** @type {Guard[]} */export const GUARDS = [- { id: 'mergeOnlyRecorded', refuse: 'MERGE_ONLY_PROOF', rule: 'real local Git proves the exact gated merge carries the unwithdrawn acceptance and records its conflict resolution; serialized builder facts never authorize it', next: 'submit normally for outside review if local Git cannot prove the merge', source: 'board' },+ { id: 'mergeOnlyRecorded', refuse: 'MERGE_ONLY_PROOF', rule: 'the sealed submit records the origin’s Git-derived carry, unchanged bar and original verifier; landing re-proves its heads, trees and resolution hash before merging', next: 'submit normally for outside review if the origin cannot prove the merge', source: 'board' },{ id: 'outsideSubmission', refuse: 'OUTSIDE_SOURCE', rule: 'an outside author and exact fetched commit/tree are recorded with a trusted frozen criterion, without pretending a native builder gated it', next: 'fetch and intake the exact GitHub pull request again', source: 'board' },{ id: IN_STATE, refuse: '', rule: "the move can start from the item's current state", next: 'pullboard show <id>', source: 'board' },{ id: 'joined', refuse: 'NOT_JOINED', alsoRefuses: [{ code: 'AGENT_REPLACED', next: 'read the takeover and only shout on its exact hand-off item; continue work from the incoming agent worktree' }, { code: 'SESSION_LEDGER', next: 'make the agent-session ledger named in the message readable and writable by this user, then run the command again' }], rule: 'the caller is the main checkout, or an unreplaced worktree seat that joined a lane; an agent session\'s claims, submits and verdicts can be checked against its local ledger', next: 'pullboard join <lane> --model "<model name>" (see: pullboard lanes)', source: 'cli' },diff --git a/src/merge-only-source.js b/src/merge-only-source.jsindex 968a8a22..f8ccdfc9 100644--- a/src/merge-only-source.js+++ b/src/merge-only-source.js@@ -1,4 +1,5 @@/** Bounded Git proof that a resubmission adds only trunk and actual conflict resolutions [V1,V4]. */+import { createHash } from 'node:crypto';import { spawnSync } from 'node:child_process';import {cleanGitEnvironment,@@ -81,7 +82,8 @@ export function captureMergeOnly(root, basis, { commit, tree, trunk }) {['diff', '--no-renames', '--name-only', '-z', trunk, commit, '--']).split('\0').filter(Boolean)])].sort();return { version: 1, acceptedCommit: basis.acceptedCommit, acceptedHead: basis.acceptedHead,acceptedTree, commit, tree, trunk, mergeTree, digest: basis.digest, verdict: basis.verdict,- reopen: basis.reopen, paths, resolutionDiff };+ reopen: basis.reopen, paths, resolutionDiff,+ resolutionHash: createHash('sha256').update(resolutionDiff).digest('hex') };} catch { return null; }}diff --git a/src/merge-only-verdict.js b/src/merge-only-verdict.jsindex e3240625..2e6f7283 100644--- a/src/merge-only-verdict.js+++ b/src/merge-only-verdict.js@@ -1,12 +1,14 @@/** Immutable acceptance provenance for a narrowly proved trunk merge [V1,V4,H16]. */+import { createHash } from 'node:crypto';+import { captureMergeOnly } from './merge-only-source.js';import { Refused } from './refused.js';import { acceptedVerdict } from './verdict-reviews.js';const SHA = /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u;/** Find only the latest conflict return and the exact unwithdrawn verdict it superseded. */-export function mergeOnlyBasis(board, item) {- const last = board.db.prepare("SELECT event_id, event_kind, event_detail FROM event WHERE item_id = ? AND event_kind IN ('reopen','accept','reject','refreeze','merge-only-accept') ORDER BY event_id DESC LIMIT 1").get(item.item_id);+export function mergeOnlyBasis(board, item, { before = Number.MAX_SAFE_INTEGER } = {}) {+ const last = board.db.prepare("SELECT event_id, event_kind, event_detail FROM event WHERE item_id = ? AND event_id < ? AND event_kind IN ('reopen','accept','reject','refreeze','merge-only-accept') ORDER BY event_id DESC LIMIT 1").get(item.item_id, before);if (last?.event_kind !== 'reopen') return null;const returned = JSON.parse(last.event_detail);if ((!returned.conflict && !returned.landingFailure) || !Number.isSafeInteger(returned.supersedes)) return null;@@ -31,6 +33,21 @@ export function mergeOnlyProblem(board, item, proof, { commit, tree, policyCommi&& ['acceptedCommit','acceptedHead','acceptedTree','commit','tree','trunk','mergeTree'].every(key => SHA.test(proof[key] ?? ''))&& Array.isArray(proof.paths) && proof.paths.every(path => typeof path === 'string' && path && !path.includes('\0'))&& JSON.stringify(proof.paths) === JSON.stringify([...new Set(proof.paths)].sort())- && typeof proof.resolutionDiff === 'string' && proof.resolutionDiff.length <= 1024 * 1024;+ && typeof proof.resolutionDiff === 'string' && proof.resolutionDiff.length <= 1024 * 1024+ && proof.resolutionHash === createHash('sha256').update(proof.resolutionDiff).digest('hex');return valid ? null : new Refused('MERGE_ONLY_PROOF', 'the carried acceptance must name the current conflict return, immutable verdict, unchanged frozen bar and exact gated merge; submit normally for outside review');}++/** Re-prove a canonical carry against immutable Git before physical landing, including adoption. */+export function mergeOnlyLandingProblem(root, board, item) {+ const accepted = acceptedVerdict(board, item);+ if (!accepted?.carried) return null;+ const proof = accepted.carried;+ const event = board.db.prepare("SELECT event_id FROM event WHERE item_id = ? AND event_kind = 'merge-only-accept' AND json_extract(event_detail,'$.commit') = ? ORDER BY event_id DESC LIMIT 1")+ .get(item.item_id, item.item_commit);+ const basis = event && mergeOnlyBasis(board, { ...item, item_commit: proof.acceptedCommit }, { before: event.event_id });+ const actual = basis && basis.by === proof.by && proof.digest === item.item_frozen_digest+ ? captureMergeOnly(root, basis, { commit: item.item_commit, tree: item.item_tree, trunk: proof.trunk }) : null;+ return actual && Object.entries(actual).every(([key, value]) => JSON.stringify(value) === JSON.stringify(proof[key]))+ ? null : new Refused('STALE_VERDICT', `item #${item.item_id}: the recorded merge-only acceptance does not match real Git heads, trees and resolution diff; obtain an ordinary outside review before landing`);+}diff --git a/src/verdict-freshness.js b/src/verdict-freshness.jsindex bea430bd..cba04be2 100644--- a/src/verdict-freshness.js+++ b/src/verdict-freshness.js@@ -1,4 +1,5 @@/** Acceptance stays append-only; freshness is derived from the known Git trunk [E8,V8]. */+import { mergeOnlyLandingProblem } from './merge-only-verdict.js';import { spawnSync } from 'node:child_process';import * as store from './board-query.js';import {@@ -95,6 +96,8 @@ export function verdictProjector(root, board, { main } = {}) {const state = item => {if (item.item_status !== 'verified') return null;const accepted = store.acceptedVerdict(board, item);+ const carryProblem = !item.item_merged_commit && mergeOnlyLandingProblem(root, board, item);+ if (carryProblem) return { code: 'STALE_VERDICT', reason: carryProblem.message, main: tip ?? null };const mismatch = item.item_merged_commit && store.events(board, { itemId: item.item_id }).findLast(event => {if (event.event_kind !== 'landing-review-moved') return false;const detail = JSON.parse(event.event_detail);diff --git a/test/merge-only-verdict.test.js b/test/merge-only-verdict.test.jsindex 621443ed..b9e138e3 100644--- a/test/merge-only-verdict.test.js+++ b/test/merge-only-verdict.test.js@@ -1,6 +1,8 @@/** Real public submission, Git conflict resolution and immutable verdict coverage [V1,V4,H16]. */import assert from 'node:assert/strict';-import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { createHash } from 'node:crypto';+import { land } from '../src/land.js';+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { after, test } from 'node:test';@@ -39,8 +41,12 @@ function content(box, cwd, value, message) {return box.git(cwd, 'rev-parse', 'HEAD');}-test('a merge-only resubmission keeps its accept and records the resolution diff [V1,V4,H16]', () => {+test('a merge-only resubmission keeps its accept and records the resolution diff [V1,V4,H16]', async () => {const box = e2e.project();+ const config = JSON.parse(readFileSync(join(box.repo, 'pullboard.json'), 'utf8'));+ const configured = e2e.commitFile(box, box.repo, 'pullboard.json',+ JSON.stringify({ ...config, landing: { publish: 'separate' } }, null, 2), 'chore: configure local landing');+ assert.equal(configured.status, 0, configured.stderr);mkdirSync(join(box.repo, 'web'), { recursive: true });content(box, box.repo, 'base', 'feat(web): initial choice [G1]');box.git(box.web, 'merge', '-q', '--no-edit', 'main');@@ -79,6 +85,7 @@ test('a merge-only resubmission keeps its accept and records the resolution diffassert.equal(detail.verdict, original.verdicts.at(-1).verdict_id);assert.match(detail.resolutionDiff, /web\/feature\.js/u);assert.match(detail.resolutionDiff, /resolved/u);+ assert.equal(detail.resolutionHash, createHash('sha256').update(detail.resolutionDiff).digest('hex'));const shown = succeeds(box, box.repo, 'show', String(id));assert.match(shown.out, /verified/u);assert.doesNotMatch(shown.out, /re-review: main merge only/u);@@ -98,6 +105,13 @@ test('a merge-only resubmission keeps its accept and records the resolution diffassert.equal(store.getItem(origin, id).item_status, 'verified');assert.deepEqual(withoutObjects, withObjects, 'one canonical move must emit identical events and event IDs without Git objects');assert.deepEqual(exportBoard(objectless), exportBoard(origin), 'replicas must retain exactly identical native state');+ const subsequent = prepareEngineMove(origin, 'reopen', [id, { agentId: 'coordinator', withdrawVerdict: true,+ note: 'withdraw the original acceptance after canonical carry' }]);+ const next = applyEngineMove(origin, subsequent, { sequence: 2, at });+ assert.deepEqual(applyEngineMove(objectless, subsequent, { sequence: 2, at }), next,+ 'a later verdict-ID-bound move must retain the same outcome and event IDs');+ assert.deepEqual(exportBoard(objectless), exportBoard(origin));+} finally { store.closeBoard(origin); store.closeBoard(objectless); }for (const key of ['commit', 'tree', 'policyCommit']) {const replica = store.openBoard(':memory:', undefined, { gitRoot: box.web });@@ -150,9 +164,17 @@ test('a merge-only resubmission keeps its accept and records the resolution diffmove.args[1] = { ...options, commit: extraHead, tree: extraTree,mergeOnly: { ...detail, commit: extraHead, tree: extraTree } };applyEngineMove(forged, move, { sequence: 1, at: '2026-01-01T00:00:00.000Z' });- assert.equal(store.getItem(forged, id).item_status, 'submitted',- 'a serialized builder claim cannot lend the original verdict to unrelated same-file behavior');- assert.equal(store.events(forged, { itemId: id }).filter(event => event.event_kind === 'merge-only-accept').length, 0);+ assert.equal(store.getItem(forged, id).item_status, 'verified',+ 'canonical replay records the sealed decision consistently; landing is the authoritative Git backstop');+ const beforeLanding = box.git(box.repo, 'rev-parse', 'HEAD');+ await assert.rejects(land({ root: box.repo, board: forged, dryRun: true, say: () => {},+ config: { landing: { publish: 'separate' } } }), error => error.code === 'STALE_VERDICT'+ && /recorded merge-only acceptance/u.test(error.message),+ 'forged canonical carry must not reach a physical merge');+ assert.equal(box.git(box.repo, 'rev-parse', 'HEAD'), beforeLanding);+ assert.deepEqual(store.verdictsFor(forged, id), original.verdicts);+ assert.deepEqual(store.landingBatches(forged), []);+} finally { store.closeBoard(forged); }const absent = store.openBoard(':memory:');try {@@ -160,7 +182,7 @@ test('a merge-only resubmission keeps its accept and records the resolution diffconst move = prepareEngineMove(absent, 'submit', [id, { ...options, gitRoot: box.web }]);applyEngineMove(absent, move,{ sequence: 1, at: '2026-01-01T00:00:00.000Z' });- assert.equal(store.getItem(absent, id).item_status, 'submitted', 'coordinator28566: replay without local Git needs ordinary review');+ assert.equal(store.getItem(absent, id).item_status, 'submitted', 'an objectless origin cannot derive carry from caller fields or a serialized gitRoot');} finally { store.closeBoard(absent); }const historical = store.openBoard(':memory:', undefined, { gitRoot: box.web });try {@@ -185,6 +207,10 @@ test('a merge-only resubmission keeps its accept and records the resolution diffassert.equal(store.getItem(replay, id).item_status, 'open');assert.equal(store.acceptedVerdict(replay, store.getItem(replay, id)), undefined, 'a carry cannot resurrect a withdrawn original verdict');} finally { store.closeBoard(replay); }+ const landed = succeeds(box, box.repo, 'land', '--json');+ assert.equal(state(box, id).item.item_status, 'verified');+ assert.ok(state(box, id).item.item_merged_commit, landed.out);+ assert.equal(box.tryGit(box.repo, 'merge-base', '--is-ancestor', head, 'HEAD').status, 0);});/** Make a small real Git conflict without pretending these synthetic identities are live reviewers. */