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(core): preserve legacy landing proof mismatch [E8,H16,R3]

Corey Olsonfeff9be857eb
diff --git a/docs/formats.md b/docs/formats.md
index 9e34d54c..be2c4f34 100644
--- a/docs/formats.md
+++ b/docs/formats.md
@@ -335,6 +335,7 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap
| `reopen` | coordinator | `commit`, `note`, `judgment`, engine-10 `supersedes`, `landingFailure` |
| `merged` | coordinator | `commit` |
| `landing_batch` | coordinator | `batch` |
+| `landing-review-moved` | coordinator | `code`, `batch`, `verdict`, `checked`, `landed` |
| `landing_waiver` | person | `waiver` |
| `landing_flake` | coordinator | `flake` |
| `main-moved` | coordinator | `batch`, `items`, `sha` |
@@ -406,6 +407,6 @@ The schema, trigger and parser tables are checked against live `openBoard(':memo
### Landing records
-Engine 8 adds `recordLandingBatch`, `recordLandingWaiver`, `recordLandingFlake` and `finishLandingBatch`. Older engines stop before applying these operations. Their append-only events need no schema migration. A batch snapshot has version 1, identity, base and tip commits, trunk branch, landing worktree, items with their first-containing merge commits, state, owner, log path and revision. Additional owner-lease and environment fields can be added without changing version 1. A revision refuses stale updates. Successful push precedes the atomic merged receipts and single `main-moved` event.
+Engine 8 adds `recordLandingBatch`, `recordLandingWaiver`, `recordLandingFlake` and `finishLandingBatch`. Older engines stop before applying these operations. Their append-only events need no schema migration. A batch snapshot has version 1, identity, base and tip commits, trunk branch, landing worktree, items with their first-containing merge commits, state, owner, log path and revision. Additional owner-lease and environment fields can be added without changing version 1. A revision refuses stale updates. Successful push precedes the atomic merged receipts and single `main-moved` event. An engine-12 landing finish ordered after an engine-25 checked re-review still records the tree the older client actually pushed. If that legacy batch did not check the newer reviewed head, it also appends `landing-review-moved` with `code: "LAND_ITEM_MOVED"` and the exact verdict, checked head and landed merge. The newer review reads stale until its checked composition reaches the known trunk; the earlier landing receipt and verdicts remain immutable. Recovery creates a separate correction item rather than reopening or re-reviewing the already-landed original. Historical finishes ordered before the newer review retain their original receipts.
A person waiver records its identity, named test, expiry, reason and person channel. A distinct landing proof records the exact batch tree and each failing test with its covering waiver identity. Pre-push checks every waiver against the current time; this proof never writes an ordinary green-gate stamp. Flake records retain a test path, source digest, failing names and one defect item, so a repeated observation does not create another defect.
diff --git a/src/board.js b/src/board.js
index 0e6cf31c..45a87530 100644
--- a/src/board.js
+++ b/src/board.js
@@ -2789,6 +2789,16 @@ export function finishLandingBatch(board, { agentId, id, tip }) {
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}`);
}
+ const accepted = acceptedVerdict(board, item);
+ if ((board.executionEngineVersion ?? ENGINE_VERSION) < VERDICT_REVIEW_ENGINE
+ && accepted?.review?.head && accepted.review.head !== (entry.reviewedCommit ?? entry.commit)) {
+ // An old client may already have pushed B before a newer client checked C.
+ // Record physical history without lending C's proof to B or wedging replay.
+ logEvent(board, agentId, 'landing-review-moved', entry.id, {
+ code: 'LAND_ITEM_MOVED', batch: id, verdict: accepted.verdict_id,
+ checked: accepted.review.head, landed: entry.merge,
+ });
+ }
if (!item.item_merged_commit) merged(board, entry.id, { agentId, commit: entry.merge });
}
logEvent(board, agentId, 'main-moved', null, { sha: tip, batch: id, items: batch.items.map((entry) => entry.id) });
diff --git a/src/verdict-freshness.js b/src/verdict-freshness.js
index 49b470d1..805edf51 100644
--- a/src/verdict-freshness.js
+++ b/src/verdict-freshness.js
@@ -52,6 +52,8 @@ export function captureVerdictReview(root, board, item, trunk = verdictTrunk(roo
/** Name the concrete stale proof and the required re-review without changing the original verdict. */
export function staleVerdictRefusal(item, state) {
+ if (state.landingCode === 'LAND_ITEM_MOVED') return new Refused('STALE_VERDICT',
+ `item #${item.item_id}: ${state.reason}; keep its landing receipt and ask the coordinator to create a correction item, then have another agent verify that correction before landing it`);
const changed = state.file && state.commit
? `${JSON.stringify(state.file)} changed on main in ${state.commit}`
: state.reason ?? 'the reviewed Git history is unavailable';
@@ -86,9 +88,16 @@ export function verdictProjector(root, board, { main } = {}) {
readGit(root, ['diff', '--no-renames', '--name-only', '-z', `${commit}^1`, commit, '--']).split('\0').filter(Boolean));
return changes.get(commit);
};
- /** Return a derived state only for a verified item still waiting to land. */
+ /** Derive pending proof freshness and an older landing's explicitly recorded review mismatch. */
const state = item => {
- if (item.item_status !== 'verified' || item.item_merged_commit) return null;
+ if (item.item_status !== 'verified') return null;
+ const accepted = store.acceptedVerdict(board, item);
+ 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);
+ return detail.verdict === accepted?.verdict_id && detail.landed === item.item_merged_commit;
+ });
+ if (item.item_merged_commit && !mismatch) return null;
let review;
try {
if (!resolved) {
@@ -96,7 +105,6 @@ export function verdictProjector(root, board, { main } = {}) {
tip = verdictTrunk(root);
}
if (!tip) throw new Error('The known trunk is unavailable');
- 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;
@@ -105,6 +113,9 @@ export function verdictProjector(root, board, { main } = {}) {
{ cwd: root, env: cleanGitEnvironment(), encoding: 'utf8' });
if (landed.status === 0) return null;
if (landed.status !== 1) throw new Error('The checked commit is unavailable');
+ if (mismatch) return { code: 'STALE_VERDICT', file: null, commit: item.item_merged_commit,
+ reviewedTrunk: review.trunk, main: tip, landingCode: 'LAND_ITEM_MOVED', checked: review.head,
+ reason: `the older landing recorded ${item.item_merged_commit}, which does not contain checked composition ${review.head}` };
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) {
diff --git a/test/team-engine.test.js b/test/team-engine.test.js
index 08988eb5..be6e232a 100644
--- a/test/team-engine.test.js
+++ b/test/team-engine.test.js
@@ -184,3 +184,61 @@ test('an older landing refusal remains exact after its snapshot acquires checked
assert.throws(() => applyEngineMove(board, { ...finish, id: 'new-legacy-attempt' }, { sequence: 4, at: AT }), { code: 'RELAY_MOVE' });
assert.deepEqual(exportBoard(board), before);
});
+
+test('an actual engine 12 finish records its landing without borrowing a newer checked review [E8,H16,R3]', async t => {
+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-legacy-review-landing-'));
+ const archived = join(directory, 'engine12');
+ mkdirSync(archived);
+ unpackRelease('59a6e2b286ee852add0d68a659f1a1e6b3257c44', archived);
+ const oldStore = await import(pathToFileURL(join(archived, 'src/board.js')).href);
+ const oldEngine = await import(pathToFileURL(join(archived, 'src/engine.js')).href);
+ const oldExchange = await import(pathToFileURL(join(archived, 'src/exchange.js')).href);
+ const oldMachine = await import(pathToFileURL(join(archived, 'src/machine.js')).href);
+ assert.equal(oldMachine.ENGINE_VERSION, 12, 'prepare the in-flight move with the released executable');
+ const seed = submitted(t);
+ const old = oldStore.openBoard(join(directory, 'old.sqlite'));
+ t.after(() => { oldStore.closeBoard(old); rmSync(directory, { recursive: true, force: true }); });
+ oldExchange.importBoard(old, exportBoard(seed));
+ const accept = oldEngine.prepareEngineMove(old, 'verify', [1, verdict()], { id: 'legacy-landing-accept' });
+ assert.equal(oldEngine.applyEngineMove(old, accept, { sequence: 1, at: AT }).error, undefined);
+ const entry = { id: 1, commit: COMMIT, merge: COMMIT };
+ const batch = { version: 1, id: 'legacy-pushed', state: 'pushed', base: BASE, tip: COMMIT,
+ branch: 'refs/heads/main', root: '/fixture/landing', owner: 'fixture', logPath: '/fixture/log',
+ candidates: [entry], items: [entry], revision: 0 };
+ const record = oldEngine.prepareEngineMove(old, 'recordLandingBatch', [{ agentId: 'coordinator', batch }], { id: 'legacy-pushed-batch' });
+ assert.equal(oldEngine.applyEngineMove(old, record, { sequence: 2, at: AT }).error, undefined);
+ const finish = oldEngine.prepareEngineMove(old, 'finishLandingBatch', [{ agentId: 'coordinator', id: batch.id, tip: COMMIT }], { id: 'legacy-in-flight-finish' });
+ const one = store.openBoard(':memory:');
+ const two = store.openBoard(':memory:');
+ const historical = store.openBoard(':memory:');
+ t.after(() => { for (const board of [one, two, historical]) store.closeBoard(board); });
+ for (const board of [one, two, historical]) importBoard(board, oldExchange.exportBoard(old));
+
+ const historicalResult = oldEngine.applyEngineMove(old, finish, { sequence: 3, at: AT });
+ assert.deepEqual(applyEngineMove(historical, finish, { sequence: 3, at: AT }), historicalResult);
+ assert.deepEqual(withoutWriterMarker(exportBoard(historical)), withoutWriterMarker(oldExchange.exportBoard(old)),
+ 'a finish ordered before any new review retains every historical row and receipt');
+
+ const review = { commit: COMMIT, head: TRUNK, trunk: BASE, paths: ['web/feature.js'] };
+ const reReview = prepareEngineMove(one, 'verify', [1, { ...verdict(review), head: TRUNK }], { id: 'new-review-before-old-finish' });
+ for (const board of [one, two]) assert.equal(applyEngineMove(board, reReview, { sequence: 3, at: AT }).error, undefined);
+ const verdicts = store.verdictsFor(one, 1);
+ const landed = applyEngineMove(one, finish, { sequence: 4, at: AT });
+ assert.equal(landed.error, undefined, 'a physically pushed older landing must not wedge the ordered prefix');
+ assert.deepEqual(applyEngineMove(two, finish, { sequence: 4, at: AT }), landed);
+ for (const board of [one, two]) {
+ assert.equal(store.getItem(board, 1).item_merged_commit, COMMIT, 'record the actual older tree B');
+ assert.equal(store.checkedLandingCommit(board, store.getItem(board, 1)), TRUNK, 'retain the checked tree C');
+ assert.deepEqual(store.verdictsFor(board, 1), verdicts, 'neither the old acceptance nor the new review is rewritten');
+ const moved = store.events(board, { itemId: 1 }).filter(event => event.event_kind === 'landing-review-moved');
+ assert.equal(moved.length, 1);
+ assert.deepEqual(JSON.parse(moved[0].event_detail), { code: 'LAND_ITEM_MOVED', batch: batch.id,
+ verdict: verdicts.at(-1).verdict_id, checked: TRUNK, landed: COMMIT, model: 'unknown' });
+ const receipt = engineReceipt(board, finish.id);
+ assert.deepEqual(applyEngineMove(board, finish, { sequence: 4, at: AT }), landed);
+ assert.deepEqual(engineReceipt(board, finish.id), receipt, 'retrying the old move returns its original receipt');
+ assert.equal(store.events(board, { itemId: 1 }).filter(event => event.event_kind === 'landing-review-moved').length, 1);
+ assert.equal(appliedSequence(board), 4);
+ }
+ assert.deepEqual(exportBoard(one), exportBoard(two));
+});
diff --git a/test/team.test.js b/test/team.test.js
index e1f53a7c..73822ed5 100644
--- a/test/team.test.js
+++ b/test/team.test.js
@@ -2,8 +2,9 @@
import assert from 'node:assert/strict';
import childProcess from 'node:child_process';
import { syncBuiltinESMExports } from 'node:module';
-import { existsSync, readFileSync, writeFileSync, rmSync } from 'node:fs';
+import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'node:fs';
import { join } from 'node:path';
+import { pathToFileURL } from 'node:url';
import { after, test } from 'node:test';
import * as store from '../src/board.js';
import { exportBoard, importBoard } from '../src/exchange.js';
@@ -14,6 +15,7 @@ import { main } from '../src/cli.js';
import { fetchFresh } from './http-fixture.js';
import { relaySnapshot, presentationDigest } from '../src/relay-presentation.js';
import { snapshotState } from '../relay/browser-model.js';
+import { unpackRelease } from './release-archive.js';
const helpers = createE2eHelpers();
after(helpers.cleanup);
@@ -323,3 +325,80 @@ test('landing retains the exact repair that passed stale re-review [E8,V8,R3]',
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');
});
+
+test('an older pushed landing shows stale checked proof and a correction path across public views [E8,H16,R3]',
+ { timeout: 120_000 }, async t => { // budget: hang ceiling for real Git, private push and CLI verification; not a speed target.
+ const box = helpers.project();
+ assert.equal(helpers.commitFile(box, box.repo, 'web/feature.txt', 'feature = 0\n', 'feat(web): legacy landing base [G1]').status, 0);
+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');
+ const base = box.git(box.repo, 'rev-parse', 'HEAD');
+ run(box, box.repo, 'add', 'web', 'Legacy landing review', '--specs', 'G1', '--check', 'test -f web/feature.txt', '--wait');
+ run(box, box.web, 'claim', '1');
+ assert.equal(helpers.commitFile(box, box.web, 'web/feature.txt', 'feature = 1\n', 'feat(web): legacy pushed feature [G1]').status, 0);
+ const submitted = box.git(box.web, 'rev-parse', 'HEAD');
+ run(box, box.web, 'submit', '1');
+ const reviewer = join(box.dir, 'legacy-landing-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 submitted feature passed.');
+ const remote = join(box.dir, 'legacy-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');
+ // The older coordinator pushed B; this replica's retained main still has A.
+ box.git(box.web, 'push', '-q', 'origin', `${submitted}:refs/heads/main`);
+ const entry = { id: 1, commit: submitted, merge: submitted };
+ const batch = { version: 1, id: 'real-legacy-push', state: 'pushed', base, tip: submitted,
+ branch: 'refs/heads/main', root: box.repo, owner: 'fixture', logPath: join(box.dir, 'landing.log'),
+ candidates: [entry], items: [entry], revision: 0 };
+ withBoard(box.repo, board => store.recordLandingBatch(board, { agentId: 'coordinator', batch }));
+ const archived = join(box.dir, 'engine12');
+ mkdirSync(archived);
+ unpackRelease('59a6e2b286ee852add0d68a659f1a1e6b3257c44', archived);
+ const oldStore = await import(pathToFileURL(join(archived, 'src/board.js')).href);
+ const oldExchange = await import(pathToFileURL(join(archived, 'src/exchange.js')).href);
+ const oldEngine = await import(pathToFileURL(join(archived, 'src/engine.js')).href);
+ const old = oldStore.openBoard(join(box.dir, 'old.sqlite'));
+ t.after(() => oldStore.closeBoard(old));
+ oldExchange.importBoard(old, withBoard(box.repo, exportBoard));
+ const finish = oldEngine.prepareEngineMove(old, 'finishLandingBatch', [{ agentId: 'coordinator', id: batch.id, tip: submitted }], { id: 'actual-legacy-in-flight-finish' });
+ assert.equal(finish.engine, 12);
+
+ assert.equal(helpers.commitFile(box, box.repo, 'web/feature.txt', 'feature = 2\n', 'feat(web): newer main requirement [G1]').status, 0);
+ const conflict = box.tryGit(reviewer, 'merge', '-q', '--no-edit', 'main');
+ assert.notEqual(conflict.status, 0, 'the older feature conflicts with this replica\'s newer requirement');
+ assert.match(`${conflict.stdout ?? ''}${conflict.stderr ?? ''}`, /CONFLICT \(content\)/u);
+ assert.equal(helpers.commitFile(box, reviewer, 'web/feature.txt', 'feature = 3\n', 'fix(web): checked correction composition [G1]').status, 0);
+ const checked = box.git(reviewer, 'rev-parse', 'HEAD');
+ run(box, reviewer, 'verify', '1', 'accept', '--note', 'The newer checked composition passed its frozen check.');
+ const verdicts = withBoard(box.repo, board => store.verdictsFor(board, 1));
+ const outcome = withBoard(box.repo, board => applyEngineMove(board, finish, { sequence: 1, at: '2026-10-17T20:00:00.000Z' }));
+ assert.equal(outcome.error, undefined, JSON.stringify(outcome));
+ assert.equal(box.git(remote, 'rev-parse', 'main'), submitted, 'the immutable receipt names the actual earlier private push');
+ assert.equal(box.tryGit(box.repo, 'merge-base', '--is-ancestor', checked, 'main').status, 1, 'the newer checked composition has not landed');
+ const item = JSON.parse(run(box, box.repo, 'show', '1', '--json'));
+ assert.equal(item.item_merged_commit, submitted);
+ assert.equal(item.item_verdict_state?.code, 'STALE_VERDICT');
+ assert.equal(item.item_verdict_state?.landingCode, 'LAND_ITEM_MOVED');
+ assert.equal(item.item_verdict_state?.checked, checked);
+ const explanation = run(box, box.repo, 'show', '1');
+ assert.match(explanation, /create a correction item/u);
+ assert.match(explanation, new RegExp(checked));
+ assert.doesNotMatch(explanation, /then another agent runs pullboard verify 1 accept/u);
+ assert.deepEqual(withBoard(box.repo, board => store.verdictsFor(board, 1)), verdicts, 'presentation does not rewrite proof');
+ const api = await serveApi(box.repo);
+ t.after(() => api.close());
+ const address = new URL(api.url);
+ const detail = await fetchFresh(address.origin + '/api/v1/boards/' + withBoard(box.repo, store.boardId) + '/items/1',
+ { headers: { 'x-pullboard-key': address.searchParams.get('k') } });
+ assert.equal(detail.status, 200);
+ assert.equal((await detail.json()).item.verdictState?.landingCode, 'LAND_ITEM_MOVED');
+ assert.equal(snapshotState(relaySnapshot(box.repo), withBoard(box.repo, store.boardId)).items[0].verdictState?.landingCode, 'LAND_ITEM_MOVED');
+ const refused = box.run(reviewer, 'verify', '1', 'accept', '--note', 'Cannot rewrite the original landing.');
+ assert.equal(refused.code, 1);
+ assert.match(refused.err, /NOT_SUBMITTED|ALREADY_MERGED/u, 'the existing merged-receipt guards stay in force');
+ box.git(box.repo, 'merge', '-q', '--no-edit', checked);
+ assert.equal(JSON.parse(run(box, box.repo, 'show', '1', '--json')).item_verdict_state, undefined,
+ 'a later correction containing the checked composition clears the derived warning without rewriting the old landing');
+ assert.equal(withBoard(box.repo, board => store.getItem(board, 1)).item_merged_commit, submitted);
+ });