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(core): land the checked review composition [E8,H16,V8]
Corey Olsond05bec67d037
diff --git a/docs/api.md b/docs/api.mdindex 71a1a040..1a04b9af 100644--- a/docs/api.md+++ b/docs/api.md@@ -335,3 +335,7 @@ Runner storage keeps one repository object cache and creates an isolated checkouEach checkout with a committed npm lockfile runs `npm ci`, including lifecycle scripts. Only npm's content cache is shared; installed dependencies and generated files stay in the fresh checkout. Other lock managers are refused. Combined command output and transport diagnostics are bounded at 64 MiB; exceeding that limit refuses the run.Post-run cleanup reports `RUNNER_CLEANUP_TIMEOUT` after 30 seconds instead of leaving the controller waiting indefinitely. That failure does not retry the command. The physical runner slot is released after its known children have drained and no unresolved live process remains; an unresolved live process keeps the slot occupied until cleanup can be verified.++New acceptances seal the exact checked commit in `review.head`. A stale re-review lands that checked composition while retaining the original submitted commit as the item identity; landing snapshots record `reviewedCommit` when it differs. Adoption and publishing refuse if that proof changes. Historical released-engine receipts retain their original replay meaning. The checked commit is pinned at `refs/pullboard/items/<id>/<first-12-sha>`; another replica must fetch that ref's Git objects before the sealed re-review can clear its stale state. Missing objects fail closed. The checked-head meaning uses the next free release engine number, currently 13 on this candidate.++A re-review seals the union of the original item paths and paths changed by the checked repair against its reviewed trunk. Files added by a repair therefore participate in later stale-verdict detection.diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex faff46c4..c48d8443 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -134,7 +134,7 @@ Each move checks its guards in this order and refuses with the first one that do| NO_POLICY | the caller's checkout contains the submitted commit | restore the frozen policy objects || BAD_CONFIG | the caller's checkout contains the submitted commit | repair the committed coordinator configuration || GIT_GRAFTS | the caller's checkout contains the submitted commit | ask the coordinator to remove the Git graft file before retrying |-| BAD_VERDICT_REVIEW | a new review binds the submitted commit, a valid trunk commit and canonical candidate paths | restore the submitted Git objects and retry the review with current Pullboard |+| BAD_VERDICT_REVIEW | a new review binds the submitted commit, its exact checked commit, a valid trunk commit and canonical candidate paths | restore the submitted Git objects and retry the review with current Pullboard || STALE_VERDICT | a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check | merge current main into the submitted commit and re-review it || DIRTY | a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check | commit the reviewed composition before re-reviewing || UNTRACKED | a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check | commit or ignore untracked files before re-reviewing |diff --git a/src/board.js b/src/board.jsindex a8394992..e7bfb622 100644--- a/src/board.js+++ b/src/board.js@@ -1466,15 +1466,17 @@ function reserveWithin(board, id, { agentId, leaseMs, policy, familyPolicy = 'of}/** Validate a sealed review without consulting Git or changing either replica [E8,H16]. */-export function verdictReviewProblem(review, commit) {+export function verdictReviewProblem(review, commit, { checked } = {}) {const valid = review && typeof review === 'object' && !Array.isArray(review)- && Object.keys(review).sort().join(',') === 'commit,paths,trunk'+ && Object.keys(review).sort().join(',') === (checked === false ? 'commit,paths,trunk' : checked === true || Object.hasOwn(review, 'head') ? 'commit,head,paths,trunk' : 'commit,paths,trunk')+ && (!checked || Object.hasOwn(review, 'head'))+ && (!Object.hasOwn(review, 'head') || /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(review.head ?? ''))&& review.commit === commit && /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(review.commit ?? '')&& /^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u.test(review.trunk ?? '')&& Array.isArray(review.paths) && review.paths.every(path => typeof path === 'string' && !path.includes('\0')&& path.split('/').every(part => part && part !== '.' && part !== '..'))&& JSON.stringify(review.paths) === JSON.stringify([...new Set(review.paths)].sort());- return valid ? null : new Refused('BAD_VERDICT_REVIEW', 'the review must bind the current submitted commit, its reviewed trunk and sorted unique candidate paths; use current Pullboard to review it again');+ return valid ? null : new Refused('BAD_VERDICT_REVIEW', checked ? 'the review must bind the current submitted commit, its checked commit, reviewed trunk and sorted unique candidate paths; use current Pullboard to review it again' : 'the review must bind the current submitted commit, its reviewed trunk and sorted unique candidate paths; use current Pullboard to review it again');}/**@@ -1491,7 +1493,7 @@ export function verdictReviewProblem(review, commit) {** @param {any} board* @param {number} id- * @param {{ agentId: string, decision: string, reason?: string, note?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green', review?: {commit: string, trunk: string, paths: string[]} }} verdict+ * @param {{ agentId: string, decision: string, reason?: string, note?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green', review?: {commit: string, head?: string, trunk: string, paths: string[]} }} verdict* @returns {{ decision: string, reason: string, check?: 'none' | 'green' }}*/export function verify(board, id, { agentId, decision, reason, note = '', head, digest, policy, familyPolicy = 'off', check, review }) {@@ -1515,7 +1517,7 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,atSubmittedCommit: null,notMerged: found => !found.item_merged_commit ? null: new Refused('ALREADY_MERGED', `item #${id} already landed; only unlanded acceptances can be re-reviewed`),- verdictReviewRecorded: found => verdictReviewProblem(review, found.item_commit),+ verdictReviewRecorded: found => verdictReviewProblem(review, found.item_commit, { checked: engine >= VERDICT_REVIEW_ENGINE }),reviewTreeCurrent: null,...reviewerChecks(board, { agentId, policy, familyPolicy }),criterionUnchanged: (found) =>@@ -1547,7 +1549,7 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,});const detail = { reason: code, commit: item.item_commit };if (isAccept && check !== undefined) detail.check = check;- if (newReview) detail.review = { commit: review.commit, trunk: review.trunk, paths: [...review.paths] };+ if (newReview) detail.review = { commit: review.commit, ...(Object.hasOwn(review, 'head') ? { head: review.head } : {}), trunk: review.trunk, paths: [...review.paths] };logEvent(board, agentId, verb, id, detail);return { decision, reason: code, ...(isAccept && check !== undefined ? { check } : {}) };});@@ -1826,6 +1828,17 @@ export function verdictsFor(board, id) {});}+/** The latest matching acceptance; the submission stays immutable through later re-reviews. */+export function acceptedVerdict(board, item) {+ return verdictsFor(board, item.item_id).findLast(verdict =>+ verdict.verdict_decision === 'ACCEPT' && verdict.verdict_commit === item.item_commit);+}++/** The exact checked composition for a new acceptance, or the historical submitted candidate. */+export function checkedLandingCommit(board, item) {+ return acceptedVerdict(board, item)?.review?.head ?? item.item_commit;+}+/*** Insert a shout within the caller's transaction.*@@ -2711,7 +2724,8 @@ export function recordLandingBatch(board, { agentId, batch, revision = 0 }) {|| !['merging', 'gating', 'bisecting', 'flaky', 'blocked', 'ready', 'pushed', 'landed'].includes(batch.state)|| !/^[a-f0-9]{40,64}$/u.test(batch.base ?? '') || !/^[a-f0-9]{40,64}$/u.test(batch.tip ?? '')|| typeof batch.root !== 'string' || !batch.root || typeof batch.branch !== 'string' || !batch.branch.startsWith('refs/heads/')- || !Array.isArray(batch.items) || batch.items.some((entry) => !Number.isSafeInteger(entry?.id) || entry.id < 1 || !/^[a-f0-9]{40,64}$/u.test(entry.commit ?? ''))+ || !Array.isArray(batch.items) || batch.items.some((entry) => !Number.isSafeInteger(entry?.id) || entry.id < 1 || !/^[a-f0-9]{40,64}$/u.test(entry.commit ?? '')+ || ((board.executionEngineVersion ?? ENGINE_VERSION) >= VERDICT_REVIEW_ENGINE && Object.hasOwn(entry, 'reviewedCommit') && !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(entry.reviewedCommit ?? '')))|| typeof batch.owner !== 'string' || !batch.owner || typeof batch.logPath !== 'string' || !batch.logPath|| !Number.isSafeInteger(revision) || revision < 0) {throw new Refused('LAND_BATCH', 'a landing batch needs its exact base, tip, items, state, owner and log path; run pullboard land');@@ -2810,6 +2824,10 @@ export function finishLandingBatch(board, { agentId, id, tip }) {if (item.item_commit !== entry.commit || item.item_status !== 'verified') {throw new Refused('LAND_ITEM_MOVED', `item #${entry.id} changed after the batch was gated; rebuild its landing`);}+ if ((board.executionEngineVersion ?? ENGINE_VERSION) >= VERDICT_REVIEW_ENGINE+ && (entry.reviewedCommit ?? entry.commit) !== checkedLandingCommit(board, item)) {+ throw new Refused('LAND_ITEM_MOVED', `item #${entry.id} was re-reviewed after the batch was gated; rebuild its landing`);+ }if (item.item_merged_commit && item.item_merged_commit !== entry.merge) {throw new Refused('LAND_ITEM_MOVED', `item #${entry.id} already has another landing receipt; read pullboard show ${entry.id}`);}diff --git a/src/cli.js b/src/cli.jsindex 5daf6987..27b97605 100644--- a/src/cli.js+++ b/src/cli.js@@ -2430,7 +2430,7 @@ async function verifyHere(ctx, id, { second, values }) {if (untracked(root).length) throw new Refused('UNTRACKED', 'commit or ignore untracked files before re-reviewing the stale verdict');if (!contains(root, trunk.commit, head)) throw staleVerdictRefusal(item, stale);}- review = captureVerdictReview(root, board, item, trunk.commit);+ review = captureVerdictReview(root, board, item, trunk.commit, checkedCommit);refuseUnverifiedStack(root, board, item, checkedCommit, trunk);const checkedItem = reReview ? { ...item, item_commit: checkedCommit } : item;const browser = !browserFreeChecksEnabled() || await checkNeedsBrowser(root, frozenCheck(item), { commit: checkedCommit, onFallback: browserAdmissionReporter(ctx.io, ctx.io.relayJson) });@@ -2454,6 +2454,7 @@ async function verifyHere(ctx, id, { second, values }) {refuseUnverifiedStack(root, board, item, checkedCommit, currentTrunk);}review ??= captureVerdictReview(root, board, item, verdictTrunk(root));+ if (decision === 'ACCEPT') git(root, ['update-ref', `refs/pullboard/items/${id}/${review.head.slice(0, 12)}`, review.head]);return await ordered(ctx, board, 'verify', [id, {agentId: me.id,decision,diff --git a/src/engine.js b/src/engine.jsindex cc1b1cb2..37ca6398 100644--- a/src/engine.js+++ b/src/engine.js@@ -23,9 +23,16 @@ export const ENGINE_OPERATIONS = Object.freeze([const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8 });/** Dependency edits and sealed review metadata need their own engine meanings; historical envelopes retain theirs. */-function minimumOperationEngine(operation, args) {+function minimumOperationEngine(operation, args, board) {const options = args[1];+ if (board && ['recordLandingBatch', 'finishLandingBatch'].includes(operation)) {+ const id = operation === 'recordLandingBatch' ? args[0]?.batch?.id : args[0]?.id;+ const prior = id && store.landingBatches(board).find(batch => batch.id === id);+ if (prior && ['items', 'candidates'].some(key => Array.isArray(prior[key]) && prior[key].some(entry => entry && Object.hasOwn(entry, 'reviewedCommit')))) return VERDICT_REVIEW_ENGINE;+ }if (operation === 'verify' && options && Object.hasOwn(options, 'review')) return VERDICT_REVIEW_ENGINE;+ if (operation === 'recordLandingBatch' && args[0]?.batch+ && ['items', 'candidates'].some(key => Array.isArray(args[0].batch[key]) && args[0].batch[key].some(entry => entry && typeof entry === 'object' && Object.hasOwn(entry, 'reviewedCommit')))) return VERDICT_REVIEW_ENGINE;return operation === 'editItem' && options && Object.hasOwn(options, 'after') && options.after !== undefined? 10 : OPERATION_ENGINE[operation] ?? 1;}@@ -66,7 +73,7 @@ export function startRelayEpoch(board) {/** Turn caller-only callbacks into deterministic values before sealing an executable operation. */export function prepareEngineMove(board, operation, args, { id = randomUUID(), actor } = {}) {if (!ENGINE_OPERATIONS.includes(operation) || !Array.isArray(args)) throw new Refused('RELAY_MOVE', 'use a supported board-engine operation with its argument array');- const minimumEngine = minimumOperationEngine(operation, args);+ const minimumEngine = minimumOperationEngine(operation, args, board);if (ENGINE_VERSION < minimumEngine) throw new Refused('ENGINE_VERSION', `${operation} requires engine version ${minimumEngine}; this pullboard uses engine ${ENGINE_VERSION}; upgrade before sending it`);const values = args.map((value) => value && typeof value === 'object' ? { ...value } : value);if (operation === 'release') {@@ -208,6 +215,9 @@ export function applyEngineMove(board, move, { sequence, at }) {if (sequence !== cursor + 1) throw new Refused('RELAY_ORDER', `relay sequence ${sequence} does not follow applied sequence ${cursor}; fetch and apply the missing prefix first`);let outcome = previous?.outcome;if (!outcome) {+ // Existing receipts replay before consulting newer snapshot semantics.+ const minimumEngine = minimumOperationEngine(move.operation, move.args, board);+ if (move.engine < minimumEngine) throw new Refused('RELAY_MOVE', `${move.operation} cannot act on a checked-composition snapshot from engine ${move.engine}; use engine ${minimumEngine} or newer`);const clock = board.clock;const engineVersion = board.executionEngineVersion;board.clock = { now: () => new Date(at) };diff --git a/src/land.js b/src/land.jsindex 79cc3c24..8b39453a 100644--- a/src/land.js+++ b/src/land.js@@ -57,6 +57,12 @@ export function landingSubject(item) {return `${prefix}${subject.replace(/\.$/u, '')}${suffix}`;}+/** Keep the submitted identity and, when different, its sealed checked composition. */+function landingEntry(item) {+ return { id: item.item_id, commit: item.item_commit,+ ...(item.item_landing_commit !== item.item_commit ? { reviewedCommit: item.item_landing_commit } : {}) };+}+/** Select verified, unmerged candidates in verdict order, retaining dependency order [B3,R3]. */function candidates(board, root, base, maximum) {const all = store.listItems(board, { all: true });@@ -68,10 +74,12 @@ function candidates(board, root, base, maximum) {const ready = [];const blocked = [];const knownReds = store.landingBatches(board).flatMap((batch) => batch.culprits ?? []);- for (const item of pending) {+ for (const original of pending) {+ const item = { ...original, item_landing_commit: store.checkedLandingCommit(board, original) };const stale = projector.state(item);if (stale) { blocked.push({ id: item.item_id, ...stale }); continue; }- const known = knownReds.find((entry) => entry.id === item.item_id && entry.commit === item.item_commit);+ const known = knownReds.find((entry) => entry.id === item.item_id && entry.commit === item.item_commit+ && (entry.reviewedCommit ?? entry.commit) === item.item_landing_commit);if (known && !known.tests.every((failure) => store.landingWaiverFor(board, failure))) {blocked.push({ id: item.item_id, code: 'LAND_KNOWN_RED', tests: known.tests });continue;@@ -79,7 +87,7 @@ function candidates(board, root, base, maximum) {const dependencies = (item.item_after || '').split(',').filter(Boolean).map(Number);if (dependencies.some((id) => !all.find((other) => other.item_id === id)?.item_merged_commit && !ready.some((other) => other.item_id === id))) continue;const stacked = store.unverifiedSubmissions(board).find((other) => other.item_id !== item.item_id- && tryGit(root, ['merge-base', '--is-ancestor', other.item_commit, item.item_commit]).status === 0+ && tryGit(root, ['merge-base', '--is-ancestor', other.item_commit, item.item_landing_commit]).status === 0&& tryGit(root, ['merge-base', '--is-ancestor', other.item_commit, base]).status !== 0);if (stacked) {blocked.push({ id: item.item_id, code: 'STACKED_UNVERIFIED', stacked: stacked.item_id });@@ -107,9 +115,11 @@ async function mergeGroup(state, items) {for (const entry of items) {const item = store.getItem(state.board, entry.id ?? entry.item_id);if (item.item_status !== 'verified' || item.item_commit !== (entry.commit ?? item.item_commit)) throw new Refused('LAND_ITEM_MOVED', `item #${item.item_id} changed; rebuild the batch from current verified work`);+ const checked = store.checkedLandingCommit(state.board, item);+ if (checked !== (entry.reviewedCommit ?? entry.commit ?? item.item_commit)) throw new Refused('LAND_ITEM_MOVED', `item #${item.item_id} was re-reviewed; rebuild its landing from the checked commit`);const stale = verdictProjector(state.root, state.board, { main: batch.base }).state(item);if (stale) throw staleVerdictRefusal(item, stale);- const result = tryGit(batch.root, ['merge', '--no-ff', item.item_commit, '-m', landingSubject(item)]);+ const result = tryGit(batch.root, ['merge', '--no-ff', checked, '-m', landingSubject(item)]);if (result.status !== 0) {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`);@@ -119,8 +129,8 @@ async function mergeGroup(state, items) {continue;}const first = git(batch.root, ['rev-list', '--first-parent', '--reverse', 'HEAD']).split('\n')- .find((commit) => tryGit(batch.root, ['merge-base', '--is-ancestor', item.item_commit, commit]).status === 0);- merged.push({ id: item.item_id, commit: item.item_commit, merge: first });+ .find((commit) => tryGit(batch.root, ['merge-base', '--is-ancestor', checked, commit]).status === 0);+ merged.push({ id: item.item_id, commit: item.item_commit, ...(checked !== item.item_commit ? { reviewedCommit: checked } : {}), merge: first });}return { items: merged, conflicts, tip: headCommit(batch.root) };}@@ -177,7 +187,7 @@ async function bisect(state, items, failures, label = 'split') {await state.write('appendFact', [item.id, { agentId: 'coordinator', kind: 'measurement', text }]);}const mergeCommit = state.batch.tip;- if (!state.culprits.some((entry) => entry.id === item.id)) state.culprits.push({ id: item.id, commit: item.commit, mergeCommit, tests: failures });+ if (!state.culprits.some((entry) => entry.id === item.id)) state.culprits.push({ id: item.id, commit: item.commit, ...(item.reviewedCommit ? { reviewedCommit: item.reviewedCommit } : {}), mergeCommit, tests: failures });await save(state, { culprits: state.culprits });await returnCulprits(state);state.say(`culprit #${item.id}: ${failures.map((failure) => failure.name).join(', ')}`);@@ -208,6 +218,7 @@ async function returnCulprits(state) {for (const culprit of state.culprits) {const item = store.getItem(state.board, culprit.id);if (item.item_status !== 'verified' || item.item_merged_commit || item.item_commit !== culprit.commit+ || (culprit.reviewedCommit ?? culprit.commit) !== store.checkedLandingCommit(state.board, item)|| !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(culprit.mergeCommit ?? '')) continue;const note = `Landing batch ${state.batch.id} failed ${culprit.tests.map((failure) => `${failure.file}: ${failure.name}`).join('; ')}; merge commit ${culprit.mergeCommit}`;await state.write('reopen', [culprit.id, { agentId: 'coordinator', note }]);@@ -230,6 +241,13 @@ async function fileFlakes(state, gate, files) {/** Push the exact gated tip before recording receipts, then fast-forward only a clean unchanged main. */async function publish(state) {let batch = state.batch;+ for (const entry of batch.items) {+ const item = store.getItem(state.board, entry.id);+ if (item.item_status !== 'verified' || item.item_commit !== entry.commit+ || store.checkedLandingCommit(state.board, item) !== (entry.reviewedCommit ?? entry.commit)) {+ throw new Refused('LAND_ITEM_MOVED', `item #${entry.id} changed its checked composition; rebuild the landing before publishing`);+ }+ }const remote = tryGit(state.root, ['config', '--get', `branch.${batch.branch.replace(/^refs\/heads\//u, '')}.remote`]).stdout || 'origin';if (batch.proof?.failures?.length && batch.state !== 'pushed') {const failures = batch.proof.failures.map((failure) => ({ ...failure, waiver: store.landingWaiverFor(state.board, failure)?.id }));@@ -273,7 +291,7 @@ export async function land({ root, board, config, write, say, owner, maximum = Iif (dryRun) {const conflicts = [];for (const item of selected.ready) {- const merge = tryGit(root, ['merge-tree', '--write-tree', '--name-only', '-z', trunk.commit, item.item_commit]);+ const merge = tryGit(root, ['merge-tree', '--write-tree', '--name-only', '-z', trunk.commit, item.item_landing_commit]);if (merge.status === 1) {const parts = merge.stdout.split('\0').slice(1);const end = parts.indexOf('');@@ -305,8 +323,8 @@ export async function land({ root, board, config, write, say, owner, maximum = Iconst 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'),- candidates: selected.ready.map((item) => ({ id: item.item_id, commit: item.item_commit })),- items: selected.ready.map((item) => ({ id: item.item_id, commit: item.item_commit })), conflicts: [], blocked: selected.blocked,+ candidates: selected.ready.map(landingEntry),+ items: selected.ready.map(landingEntry), conflicts: [], blocked: selected.blocked,state: 'merging', owner, logPath: join(directory, 'logs', 'batch.log'), revision: 0 };batch = await write('recordLandingBatch', [{ agentId: 'coordinator', batch }]);mkdirSync(directory, { recursive: true });diff --git a/src/machine.js b/src/machine.jsindex 11ce2e18..314f3bca 100644--- a/src/machine.js+++ b/src/machine.js@@ -12,9 +12,10 @@/** Executable move semantics, carried by every sealed move and retained during replay [H16]. */export const ENGINE_VERSION = 13;-/** First engine sealing reviewed trunk/path metadata and append-only re-review [E8,H16]. */+/** First released engine binding the checked composition, review trunk and paths [E8,H16]. */export const VERDICT_REVIEW_ENGINE = 13;+/** @typedef {'agent' | 'coordinator' | 'clock'} Role *//**@@ -130,7 +131,7 @@ export const GUARDS = [{ id: 'childrenDone', refuse: 'CHILDREN_OPEN', rule: 'every child item is verified or withdrawn', next: 'finish the child items, or the coordinator withdraws them', source: 'board' },{ id: 'headIsNew', refuse: 'HEAD_NOT_NEW', rule: 'a verifier has not rejected this commit at this bar; after a no-verdict reopen, the bar was refrozen', next: 'commit the rework, or refreeze the bar after a no-verdict reopen before resubmitting the same commit', source: 'board' },{ id: 'atSubmittedCommit', refuse: 'NOT_AT_COMMIT', alsoRefuses: [{ code: 'OUTSIDE_LANE', next: 'restore foreign paths before accepting' }, { code: 'NO_POLICY', next: 'restore the frozen policy objects' }, { code: 'BAD_CONFIG', next: 'repair the committed coordinator configuration' }, { code: 'GIT_GRAFTS', next: 'ask the coordinator to remove the Git graft file before retrying' }], rule: "the caller's checkout contains the submitted commit", next: 'git switch --detach <commit>', source: 'cli' },- { id: 'verdictReviewRecorded', refuse: 'BAD_VERDICT_REVIEW', rule: 'a new review binds the submitted commit, a valid trunk commit and canonical candidate paths', next: 'restore the submitted Git objects and retry the review with current Pullboard', source: 'board' },+ { id: 'verdictReviewRecorded', refuse: 'BAD_VERDICT_REVIEW', rule: 'a new review binds the submitted commit, its exact checked commit, a valid trunk commit and canonical candidate paths', next: 'restore the submitted Git objects and retry the review with current Pullboard', source: 'board' },{ id: 'reviewTreeCurrent', refuse: 'STALE_VERDICT', alsoRefuses: [{ code: 'DIRTY', next: 'commit the reviewed composition before re-reviewing' }, { code: 'UNTRACKED', next: 'commit or ignore untracked files before re-reviewing' }, { code: 'VERDICT_TRUNK_MOVED', next: 'merge the latest main and re-review the clean composition' }], rule: 'a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check', next: 'merge current main into the submitted commit and re-review it', source: 'cli' },{ id: 'notBuilder', refuse: 'SELF_VERIFY', rule: 'the caller did not build it', next: 'another agent verifies it: pullboard next --verify', source: 'board' },{ id: 'policyAllows', refuse: 'COORDINATOR_VERIFIES', rule: "the repo's verify policy lets the caller verify this lane's work", next: 'the coordinator verifies it', source: 'board' },diff --git a/src/verdict-freshness.js b/src/verdict-freshness.jsindex b9983514..9db4a3e7 100644--- a/src/verdict-freshness.js+++ b/src/verdict-freshness.js@@ -25,8 +25,8 @@ export function verdictTrunk(root) {}}-/** Capture the review's trunk and candidate delta against its submitted coordinator snapshot. */-export function captureVerdictReview(root, board, item, trunk = verdictTrunk(root)) {+/** Capture the exact checked commit, review trunk and candidate delta against its submitted coordinator snapshot. */+export function captureVerdictReview(root, board, item, trunk = verdictTrunk(root), head = item.item_commit) {const receipt = store.events(board, { itemId: item.item_id }).findLast(event => {if (event.event_kind !== 'submit') return false;return JSON.parse(event.event_detail).commit === item.item_commit;@@ -36,9 +36,14 @@ export function captureVerdictReview(root, board, item, trunk = verdictTrunk(rooif (!base) throw new Refused('BAD_VERDICT_REVIEW', 'the submitted base is unavailable; restore its Git objects before reviewing');try {const ancestor = readGit(root, ['merge-base', base, item.item_commit]).trim();- const paths = readGit(root, ['diff', '--no-renames', '--name-only', '-z', ancestor, item.item_commit, '--'])+ let paths = readGit(root, ['diff', '--no-renames', '--name-only', '-z', ancestor, item.item_commit, '--']).split('\0').filter(Boolean).sort();- return { commit: item.item_commit, trunk, paths };+ if (head !== item.item_commit) {+ readGit(root, ['merge-base', '--is-ancestor', trunk, head]);+ const repairs = readGit(root, ['diff', '--no-renames', '--name-only', '-z', trunk, head, '--']).split('\0').filter(Boolean);+ paths = [...new Set([...paths, ...repairs])].sort();+ }+ return { commit: item.item_commit, head, trunk, paths };} catch {throw new Refused('BAD_VERDICT_REVIEW', 'the submitted paths cannot be read; restore the submitted commit and base objects before reviewing');}@@ -82,14 +87,21 @@ export function verdictProjector(root, board, { main } = {}) {tip = verdictTrunk(root);}if (!tip) throw new Error('The known trunk is unavailable');- // A physical landing is final even before its board merge receipt reaches this replica.- const landed = spawnSync('git', ['--no-replace-objects', 'merge-base', '--is-ancestor', item.item_commit, tip],+ const accepted = store.acceptedVerdict(board, item);+ review = accepted?.review;+ if (review && store.verdictReviewProblem(review, item.item_commit)) throw new Error('The sealed review is invalid');+ const checked = review?.head ?? item.item_commit;+ // A physical landing is final only when it includes the checked composition.+ const landed = spawnSync('git', ['--no-replace-objects', 'merge-base', '--is-ancestor', checked, tip],{ cwd: root, env: cleanGitEnvironment(), encoding: 'utf8' });if (landed.status === 0) return null;- if (landed.status !== 1) throw new Error('The submitted commit is unavailable');- const accepted = store.verdictsFor(board, item.item_id).findLast(verdict =>- verdict.verdict_decision === 'ACCEPT' && verdict.verdict_commit === item.item_commit);- review = accepted?.review;+ if (landed.status !== 1) throw new Error('The checked commit is unavailable');+ if (review && !review.head) return { code: 'STALE_VERDICT', file: null, commit: null,+ reviewedTrunk: review.trunk, main: tip, reason: 'this acceptance predates checked-commit binding; re-review the clean composition with current Pullboard' };+ if (review?.head && review.head !== item.item_commit) {+ readGit(root, ['merge-base', '--is-ancestor', item.item_commit, review.head]);+ readGit(root, ['merge-base', '--is-ancestor', review.trunk, review.head]);+ }if (!review) {// Legacy receipts did not seal a reviewed trunk. Use a conservative claim-base bound,// never invent a capture time or rewrite those immutable receipts.diff --git a/test/machine.test.js b/test/machine.test.jsindex cfac6959..8388ece4 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -962,7 +962,7 @@ test('submit, accept and reject refuse in the declared order, one failure peeledconst open = store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Page' });store.reserveReview(board, built, { agentId: 'web-2', leaseMs: 3_600_000, policy: 'any' });const judge = (id, agentId, fields) =>- outcome(() => store.verify(board, id, { agentId, decision, head: SHA_A, digest: 'wrong', policy: 'coordinator', note: '', review: { commit: SHA_A, trunk: SHA_B, paths: ['web/page.js'] }, ...fields }));+ outcome(() => store.verify(board, id, { agentId, decision, head: SHA_A, digest: 'wrong', policy: 'coordinator', note: '', review: { commit: SHA_A, head: SHA_A, trunk: SHA_B, paths: ['web/page.js'] }, ...fields }));const bad = verb === 'accept' ? 'TEST_FAILURE' : 'NOPE';const good = verb === 'accept' ? undefined : 'TEST_FAILURE';const fired = [diff --git a/test/team-engine.test.js b/test/team-engine.test.jsindex 5856d5c3..28acae09 100644--- a/test/team-engine.test.js+++ b/test/team-engine.test.js@@ -82,7 +82,7 @@ test('engine 12 acceptance receipts stay exact and sealed re-review needs a newe}}const originalVerdicts = store.verdictsFor(one, 1);- const reReview = { ...prepareEngineMove(one, 'verify', [1, verdict({ commit: COMMIT, trunk: TRUNK, paths: ['web/feature.js'] })], { id: 'sealed-new-review' }), engine: VERDICT_REVIEW_ENGINE };+ const reReview = { ...prepareEngineMove(one, 'verify', [1, verdict({ commit: COMMIT, head: COMMIT, trunk: TRUNK, paths: ['web/feature.js'] })], { id: 'sealed-new-review' }), engine: VERDICT_REVIEW_ENGINE };assert.equal(reReview.engine, 13, 'the feature replays at its introduction version even after a later writer upgrade');const oldBefore = oldExchange.exportBoard(old);assert.throws(() => oldEngine.applyEngineMove(old, reReview, { sequence: 3, at: AT }), { code: 'ENGINE_VERSION' });@@ -101,8 +101,8 @@ test('engine 12 acceptance receipts stay exact and sealed re-review needs a newetest('malformed sealed reviews cannot append proof or bind a different submission [E8,H16,V8]', t => {const one = submitted(t);const two = replica(t, one);- const valid = { commit: COMMIT, trunk: TRUNK, paths: ['web/feature.js'] };- const invalid = [null, { ...valid, commit: BASE }, { ...valid, trunk: 'not-a-commit' },+ const valid = { commit: COMMIT, head: COMMIT, trunk: TRUNK, paths: ['web/feature.js'] };+ const invalid = [{ commit: COMMIT, trunk: TRUNK, paths: ['web/feature.js'] }, { ...valid, head: 'not-a-commit' }, null, { ...valid, commit: BASE }, { ...valid, trunk: 'not-a-commit' },{ ...valid, paths: 'web/feature.js' }, { ...valid, paths: ['web/feature.js', 'web/feature.js'] },{ ...valid, paths: ['web/z.js', 'web/a.js'] }, { ...valid, paths: ['/web/feature.js'] },{ ...valid, paths: ['web/../feature.js'] }, { ...valid, paths: ['web//feature.js'] },@@ -118,3 +118,69 @@ test('malformed sealed reviews cannot append proof or bind a different submissioassert.deepEqual(exportBoard(one), exportBoard(two));}});+++test('a landing snapshot binds the checked composition through replay and final receipts [E8,H16,R3]', t => {+ const one = submitted(t);+ const two = replica(t, one);+ const reviewed = { commit: COMMIT, head: TRUNK, trunk: BASE, paths: ['web/feature.js'] };+ /** Capture the same acceptance timestamp in both replicas through their ordered public engine. */+ const acceptAt = (head, sequence) => {+ const move = prepareEngineMove(one, 'verify', [1, { ...verdict({ ...reviewed, head }), head }], { id: `checked-review-${sequence}` });+ const first = applyEngineMove(one, move, { sequence, at: AT });+ assert.equal(first.error, undefined, JSON.stringify(first));+ assert.deepEqual(first, applyEngineMove(two, move, { sequence, at: AT }));+ };+ acceptAt(TRUNK, 1);+ const entry = { id: 1, commit: COMMIT, reviewedCommit: TRUNK, merge: TRUNK };+ const batch = { version: 1, id: 'reviewed-landing', state: 'pushed', base: BASE, tip: TRUNK,+ branch: 'refs/heads/main', root: '/fixture/landing', owner: 'fixture', logPath: '/fixture/landing.log',+ candidates: [entry], items: [entry], revision: 0 };+ const record = prepareEngineMove(one, 'recordLandingBatch', [{ agentId: 'coordinator', batch }], { id: 'checked-landing-snapshot' });+ assert.equal(record.engine, VERDICT_REVIEW_ENGINE);+ const before = exportBoard(one);+ assert.throws(() => applyEngineMove(one, { ...record, engine: 12 }, { sequence: 2, at: AT }), { code: 'RELAY_MOVE' });+ assert.deepEqual(exportBoard(one), before, 'a downgraded checked-head snapshot cannot mutate the prefix');+ assert.deepEqual(applyEngineMove(one, record, { sequence: 2, at: AT }), applyEngineMove(two, record, { sequence: 2, at: AT }));+ acceptAt(COMMIT, 3);+ const finish = prepareEngineMove(one, 'finishLandingBatch', [{ agentId: 'coordinator', id: batch.id, tip: TRUNK }], { id: 'stale-checked-landing' });+ const beforeFinish = exportBoard(one);+ assert.throws(() => applyEngineMove(one, { ...finish, engine: 12 }, { sequence: 4, at: AT }), { code: 'RELAY_MOVE' });+ assert.deepEqual(exportBoard(one), beforeFinish, 'a legacy-tagged finish cannot bypass the checked snapshot binding');+ const refused = applyEngineMove(one, finish, { sequence: 4, at: AT });+ assert.equal(refused.error?.code, 'LAND_ITEM_MOVED', 'a later re-review cannot inherit a prior checked tree gate');+ assert.deepEqual(refused, applyEngineMove(two, finish, { sequence: 4, at: AT }));+ assert.equal(store.getItem(one, 1).item_merged_commit, null);+ assert.equal(store.landingBatches(one)[0].state, 'pushed', 'a refused receipt leaves the exact prior snapshot intact');+ acceptAt(TRUNK, 5);+ const restored = { ...finish, id: 'matching-checked-landing' };+ const landed = applyEngineMove(one, restored, { sequence: 6, at: AT });+ assert.equal(landed.error, undefined, JSON.stringify(landed));+ assert.deepEqual(landed, applyEngineMove(two, restored, { sequence: 6, at: AT }));+ assert.equal(store.getItem(one, 1).item_commit, COMMIT);+ assert.equal(store.getItem(one, 1).item_merged_commit, TRUNK);+ assert.equal(store.landingBatches(one)[0].items[0].reviewedCommit, TRUNK);+ assert.deepEqual(exportBoard(one), exportBoard(two));+});++test('an older landing refusal remains exact after its snapshot acquires checked-head binding [E8,H16,R3]', t => {+ const board = submitted(t);+ store.verify(board, 1, verdict({ commit: COMMIT, head: COMMIT, trunk: BASE, paths: ['web/feature.js'] }));+ const batch = { version: 1, id: 'upgraded-snapshot', state: 'gating', base: BASE, tip: COMMIT,+ branch: 'refs/heads/main', root: '/fixture/landing', owner: 'fixture', logPath: '/fixture/landing.log',+ candidates: [{ id: 1, commit: COMMIT }], items: [{ id: 1, commit: COMMIT }], revision: 0 };+ const legacy = { ...prepareEngineMove(board, 'recordLandingBatch', [{ agentId: 'coordinator', batch }], { id: 'legacy-snapshot' }), engine: 12 };+ assert.equal(applyEngineMove(board, legacy, { sequence: 1, at: AT }).error, undefined);+ const finish = { ...prepareEngineMove(board, 'finishLandingBatch', [{ agentId: 'coordinator', id: batch.id, tip: COMMIT }], { id: 'legacy-not-pushed' }), engine: 12 };+ const original = applyEngineMove(board, finish, { sequence: 2, at: AT });+ assert.equal(original.error?.code, 'LAND_NOT_PUSHED');+ const saved = engineReceipt(board, finish.id);+ const checked = { ...batch, revision: 1, candidates: [{ id: 1, commit: COMMIT, reviewedCommit: TRUNK }], items: [{ id: 1, commit: COMMIT, reviewedCommit: TRUNK }] };+ const update = prepareEngineMove(board, 'recordLandingBatch', [{ agentId: 'coordinator', batch: checked, revision: 1 }], { id: 'checked-snapshot' });+ assert.equal(applyEngineMove(board, update, { sequence: 3, at: AT }).error, undefined);+ assert.deepEqual(applyEngineMove(board, finish, { sequence: 2, at: AT }), original);+ assert.deepEqual(engineReceipt(board, finish.id), saved, 'a new snapshot meaning cannot alter an existing refusal receipt');+ const before = exportBoard(board);+ assert.throws(() => applyEngineMove(board, { ...finish, id: 'new-legacy-attempt' }, { sequence: 4, at: AT }), { code: 'RELAY_MOVE' });+ assert.deepEqual(exportBoard(board), before);+});diff --git a/test/team.test.js b/test/team.test.jsindex e583be13..0714e59a 100644--- a/test/team.test.js+++ b/test/team.test.js@@ -175,6 +175,10 @@ test('a verdict reads stale when main moves under its files [E8]', { timeout: 12return applyEngineMove(board, move, { sequence: 1, at: verdict.verdict_at });});assert.equal(outcome.error, undefined, JSON.stringify(outcome));+ const reviewPin = `refs/pullboard/items/1/${composed.slice(0, 12)}`;+ assert.equal(box.git(box.repo, 'rev-parse', reviewPin), composed, 'the checked commit is pinned durably for other replicas to fetch');+ assert.equal(items()[1].item_verdict_state?.code, 'STALE_VERDICT', 'a replica without the checked Git objects fails closed');+ box.git(peer, 'fetch', '-q', 'origin', reviewPin);assert.ok(items().every(item => !item.item_verdict_state), 'the same sealed re-review clears both replicas');assert.equal((await http('/state')).state.items[0].verdictState, undefined, 'a newer acceptance invalidates stale cached state');assert.equal((await http('/items/1')).item.verdictState, undefined);@@ -222,3 +226,49 @@ test('a checkout or trunk moving during verification cannot acquire proof [E8]',run(box, reviewer, 'verify', '1', 'accept', '--note', 'The candidate and known trunk stayed fixed through the complete frozen check.');assert.equal(withBoard(box.repo, board => store.verdictsFor(board, 1)).length, 1);});+++test('landing retains the exact repair that passed stale re-review [E8,V8,R3]', () => {+ const box = helpers.project();+ const source = (feature, expected) => `feature = ${feature}\n${'// independent caller line\n'.repeat(12)}expected = ${expected}\n`;+ assert.equal(helpers.commitFile(box, box.repo, 'web/feature.txt', source(0, 1), 'feat(web): baseline caller [G1]').status, 0);+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');+ const check = `test "$(sed -n 's/^feature = //p' web/feature.txt)" = "$(sed -n 's/^expected = //p' web/feature.txt)"`;+ run(box, box.repo, 'add', 'web', 'Repair follows its review', '--specs', 'G1', '--check', check, '--wait');+ run(box, box.web, 'claim', '1');+ assert.equal(helpers.commitFile(box, box.web, 'web/feature.txt', source(1, 1), 'feat(web): original feature [G1]').status, 0);+ const submitted = box.git(box.web, 'rev-parse', 'HEAD');+ run(box, box.web, 'submit', '1');+ const reviewer = join(box.dir, 'repair-reviewer');+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', reviewer, submitted);+ run(box, reviewer, 'join', 'web');+ run(box, reviewer, 'verify', '1', 'accept', '--note', 'The original feature matches the original caller.');+ const original = withBoard(box.repo, board => store.verdictsFor(board, 1));+ assert.equal(helpers.commitFile(box, box.repo, 'web/feature.txt', source(0, 2), 'feat(web): caller now requires two [G1]').status, 0);+ assert.equal(JSON.parse(run(box, box.repo, 'show', '1', '--json')).item_verdict_state?.code, 'STALE_VERDICT');+ box.git(reviewer, 'merge', '-q', '--no-edit', 'main');+ assert.equal(helpers.commitFile(box, reviewer, 'web/feature.txt', source(2, 2), 'feat(web): repair against the new caller [G1]').status, 0);+ assert.equal(helpers.commitFile(box, reviewer, 'web/repair.txt', 'ready\n', 'feat(web): add the repair companion [G1]').status, 0);+ const checked = box.git(reviewer, 'rev-parse', 'HEAD');+ run(box, reviewer, 'verify', '1', 'accept', '--note', 'The repaired composition matches the new caller; the original feature does not.');+ const reviewed = withBoard(box.repo, board => store.verdictsFor(board, 1));+ assert.deepEqual(reviewed.slice(0, original.length), original);+ assert.equal(reviewed.at(-1).verdict_head, checked);+ const probe = join(box.dir, 'repair-path-replica');+ box.git(box.dir, 'clone', '-q', box.repo, probe);+ withBoard(probe, board => importBoard(board, withBoard(box.repo, exportBoard)));+ box.git(probe, 'fetch', '-q', 'origin', `refs/pullboard/items/1/${checked.slice(0, 12)}`);+ assert.equal(helpers.commitFile(box, probe, 'web/repair.txt', 'main changed the repair\n', 'feat(web): main changes a repair file [G1]').status, 0);+ const changedRepair = JSON.parse(run(box, probe, 'show', '1', '--json'));+ assert.equal(changedRepair.item_verdict_state?.file, 'web/repair.txt', 'a file introduced by the checked repair must participate in later freshness');++ const remote = join(box.dir, 'landing-remote.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 landed = JSON.parse(run(box, box.repo, 'land', '--json'));+ assert.deepEqual(landed.landed, [1], JSON.stringify(landed));+ assert.equal(box.git(box.repo, 'show', landed.batch.tip + ':web/feature.txt'), source(2, 2).trim(), 'landing must retain the exact repaired file that passed the frozen check');+ assert.equal(box.git(box.remote ?? remote, 'rev-parse', 'main'), landed.batch.tip);+ assert.equal(withBoard(box.repo, board => store.getItem(board, 1)).item_commit, submitted, 'the original submission remains the immutable item identity');+});