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
feat(board): return red landings to builders [B3,V4]
Corey Olson899af44ff2ea
diff --git a/docs/formats.md b/docs/formats.mdindex 333f26db..1db34ba8 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -102,10 +102,12 @@ The board file is in the repository's Git common directory at `.git/pullboard/bo| `row grammar` | `1` | `SPEC_GRAMMAR_VERSION` in `src/spec.js`; optional `<!-- pullboard-grammar N -->` line in either file (absence means the current grammar) | Both files share the version. A declared version must match; an incompatible grammar change requires a coordinated version bump and compatible files. No automatic conversion occurs. || `board schema` | `2` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | Create missing tables and indexes, add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. || `event log` | `1` | `EVENT_LOG_VERSION` in `src/board.js`, persisted in `board_meta` as `event_log_version` | Older event-log versions upgrade in place; newer versions are refused with `EVENT_LOG_VERSION`. Preserve event rows when the board schema changes. |-| `move engine` | `9` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |+| `move engine` | `10` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |<!-- format-versions:end -->-Pullboard 0.6.1 released engine 1. Engine 2 records a fresh explicit-build claim's skipped-review snapshot. Pullboard 0.8.1 released engine 3, including lane-sensitive graft refusals and authenticated relay senders. Engine 4 adds captured background-baseline completions through `completeCheckBaseline`; released engine-3 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Engine 5 requires a one-line reason when releasing a review and gives that reviewer a one-hour cooldown for the current submission. Each sealed move replays under its recorded engine version: engines 1 through 4 retain the original release event and review-reservation behavior. Engine 5 retains support for older moves, including engine-4 baseline completions. Pullboard 0.8.3 released engine 6, adding board-scoped machine credentials and permitting machine execution only for one exact, earlier authenticated phone request, including its payload digest. Engine 7 adds ordered item holds through `holdItem` and `releaseItemHold`; engine-6 clients stop with `ENGINE_VERSION` before interpreting either operation or advancing their replay cursor. Engine 8, shared by the 0.8.5 move changes, retains merged-item exception notes, selects the next review in roadmap order, and adds coordinator-only `reopen` for a submission returned without a verdict; engine-7 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Recorded engines 1 through 7 retain their original tier-first review selection. Engine 8 also adds durable refusal recovery for blocked relay positions; each explicit skip publishes the readable prefix even when another unsupported record follows. Engine 8 also permits coordinator criterion/check edits on a live claim as pending corrections; the holder cannot renew or submit until a refreeze adopts the correction while preserving the claim. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new moves. Each release shares one engine bump across its changed moves. Engine 8 also retains declared model labels on registration and records each registered agent move's model snapshot; engines 1 through 7 retain their original registration and event details without these model fields. Engine 9, shared with the 0.8.10 move changes, allows resubmitting the same rejected commit after a corrected criterion is refrozen, but only when the rejection names a different frozen digest. Engine 8 retains its HEAD_NOT_NEW refusal and prior submit-event detail. Engine-9 submit events add `criterionDigest`, and engine-8 boards replay with the original refusal and event history.+Pullboard 0.6.1 released engine 1. Engine 2 records a fresh explicit-build claim's skipped-review snapshot. Pullboard 0.8.1 released engine 3, including lane-sensitive graft refusals and authenticated relay senders. Engine 4 adds captured background-baseline completions through `completeCheckBaseline`; released engine-3 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Engine 5 requires a one-line reason when releasing a review and gives that reviewer a one-hour cooldown for the current submission. Each sealed move replays under its recorded engine version: engines 1 through 4 retain the original release event and review-reservation behavior. Engine 5 retains support for older moves, including engine-4 baseline completions. Pullboard 0.8.3 released engine 6, adding board-scoped machine credentials and permitting machine execution only for one exact, earlier authenticated phone request, including its payload digest. Engine 7 adds ordered item holds through `holdItem` and `releaseItemHold`; engine-6 clients stop with `ENGINE_VERSION` before interpreting either operation or advancing their replay cursor. Engine 8, shared by the 0.8.5 move changes, retains merged-item exception notes, selects the next review in roadmap order, and adds coordinator-only `reopen` for a submission returned without a verdict; engine-7 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Recorded engines 1 through 7 retain their original tier-first review selection. Engine 8 also adds durable refusal recovery for blocked relay positions; each explicit skip publishes the readable prefix even when another unsupported record follows. Engine 8 also permits coordinator criterion/check edits on a live claim as pending corrections; the holder cannot renew or submit until a refreeze adopts the correction while preserving the claim. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new moves. Each release shares one engine bump across its changed moves. Engine 8 also retains declared model labels on registration and records each registered agent move's model snapshot; engines 1 through 7 retain their original registration and event details without these model fields. Engine 9, shared with the 0.8.8 move changes, allows resubmitting the same rejected commit after a corrected criterion is refrozen, but only when the rejection names a different frozen digest. Engine 8 retains its HEAD_NOT_NEW refusal and prior submit-event detail. Engine-9 submit events add `criterionDigest`, and engine-8 boards replay with the original refusal and event history.++Engine 10 adds coordinator-only reopening for an unmerged verified item after a red landing candidate. Its append-only `reopen` event names the superseded accept, failing test and landing merge commit; the original accept and verdict remain in history. Engines 8 and 9 retain their submitted-only `reopen` behavior: a verified-item reopen is refused without changing the replayed board. Only engine 10 may return a verified item to open, with a failing test and landing merge commit in the note.The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.A linked board requires at least engine 3 after issuing any agent token, including@@ -305,6 +307,7 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `reserve` | reviewer | `until` || `accept` | reviewer | `reason`, `commit` || `reject` | reviewer | `reason`, `commit` |+| `reopen` | coordinator | `commit`, `note`, `judgment`, engine-10 `supersedes`, `landingFailure` || `merged` | coordinator | `commit` || `landing_batch` | coordinator | `batch` || `landing_waiver` | person | `waiver` |@@ -326,6 +329,8 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its apA CLI `accept` event includes `check: "none"` when no frozen item check ran or `check: "green"` when it passed. Older accept events and records without this field read as `unknown`; the result stays in event detail and does not change the board schema or event-log version.+An engine-10 `reopen` of a verified item adds `supersedes` with the earlier accept event id and `landingFailure` with `{batch, tests: [{file, name}], mergeCommit}`. For a recorded red batch, `batch` is its id and the tests and merge commit come from that batch. For a hand-run landing, `batch` is `null`; the coordinator's note supplies a test path and name plus merge commit, which are recorded without checking that commit against the repository. The accept event and verdict row remain append-only, and merged items cannot be reopened. Engine-8 and engine-9 `reopen` events keep their original `{commit, note, judgment}` detail and submitted-only behavior.+Item facts use the existing append-only `event` table and event-log version 1. A `fact` event's actor and timestamp stamp its author and time; its detail carries a stable string `id`, typed `kind`, exact `text`, optional `ref` binding or `null`, and superseded fact id or `null`. Allowed kinds are `capture`, `measurement`, `note`, `diff`, `decision`, `rejection`, `supersession` and `root-cause`. Judgement kinds and any correction using `supersedes` require the item's live holder or the coordinator. A correction must refer to a fact on the same item; it adds a new event and preserves every earlier fact.A binding is `{path, start, end, commit}`: a relative repository path, a positive ascending inclusive line range and a full 40-character hexadecimal commit id. It identifies code without storing source or requiring Git on a replica. Fact ids are generated UUIDs locally. A sealed `appendFact` operation uses its executable move id as its fact id, so replicas keep corrections bound to the same fact even when local event sequence ids differ. Native export/import retains these event rows without a separate fact table or schema upgrade.diff --git a/docs/formats.test.js b/docs/formats.test.jsindex deb9ae06..682652a4 100644--- a/docs/formats.test.js+++ b/docs/formats.test.js@@ -40,6 +40,7 @@ import {release,releaseLane,releaseItemHold,+ reopen,reserveReview,SCHEMA_VERSION,submit,@@ -309,13 +310,25 @@ function recordEventContract() {assert.deepEqual(JSON.parse(events(board).filter((row) => row.event_kind === 'edit').at(-1).event_detail).pendingRefreeze, ['criterion']);refreeze(board, corrected, { agentId: builder, freeze: freeze('adopted-correction') });+ const returnedBuilder = register(board, { lane: 'docs', path: '/returned-builder', model: 'builder' });+ const returned = addItem(board, { by: coordinator, lane: 'docs', title: 'Returned landing example' });+ claim(board, returned, { agentId: returnedBuilder, lane: 'docs', leaseMs: 60_000, freeze: freeze('returned') });+ const returnedCommit = 'f'.repeat(40);+ submit(board, returned, { agentId: returnedBuilder, commit: returnedCommit, tree: 'e'.repeat(40) });+ verify(board, returned, { agentId: reviewer, decision: 'ACCEPT', reason: ACCEPT_REASON, note: 'checked the returned example', head: returnedCommit, digest: 'returned', policy: 'agents' });+ const failureBatch = recordLandingBatch(board, { agentId: coordinator, batch: { version: 1, id: 'format-red-example', base: 'a'.repeat(40), tip: 'c'.repeat(40),+ root: '/landing-red', branch: 'refs/heads/main', state: 'blocked', owner: 'format-red-example', logPath: '/landing-red.log',+ items: [{ id: returned, commit: returnedCommit }], culprits: [{ id: returned, commit: returnedCommit, mergeCommit: 'c'.repeat(40),+ tests: [{ file: 'test/format.test.js', name: 'keeps the example' }] }] } });+ reopen(board, returned, { agentId: coordinator, note: `Landing batch ${failureBatch.id} failed test/format.test.js: keeps the example; merge commit ${'c'.repeat(40)}` });+const withdrawn = addItem(board, { by: coordinator, lane: 'docs', title: 'Withdrawn example' });withdraw(board, withdrawn, { agentId: coordinator, reason: 'duplicate fixture' });holdLane(board, 'view', { agentId: coordinator, reason: 'fixture hold' });releaseLane(board, 'view', { agentId: coordinator });const rows = events(board).map((row) => ({ ...row, detail: JSON.parse(row.event_detail) }));closeBoard(board);- return { rows, actors: { [coordinator]: 'coordinator', [builder]: 'builder', [reviewer]: 'reviewer', [PERSON]: 'person', board: 'board' } };+ return { rows, actors: { [coordinator]: 'coordinator', [builder]: 'builder', [returnedBuilder]: 'builder', [reviewer]: 'reviewer', [PERSON]: 'person', board: 'board' } };}/** Reopen a file after removing old-format objects and report the repaired guard event. */@@ -424,6 +437,8 @@ test('[A5,H16] grammar and executable engine versions match the format guide', (assert.equal(versionOf('move engine'), ENGINE_VERSION);assert.match(versions, /Bump when a move's meaning changes/);assert.match(versions, /`ENGINE_VERSION`.*naming both versions/);+ assert.match(guide, /Engine 10 adds coordinator-only reopening for an unmerged verified item after a red landing candidate/u);+ assert.match(guide, /Engines 8 and 9 retain their submitted-only `reopen` behavior/u);assert.match(versions, /`SPEC_GRAMMAR_VERSION`/);assert.match(versions, /`JSON_SHAPES\.version`/);assert.match(versions, /`SCHEMA_VERSION`/);diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex f9731d2d..33d1a5ce 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -2,7 +2,7 @@Generated from src/machine.js by `pullboard lifecycle`. Do not edit it by hand: change the declaration, then run `pullboard lifecycle > docs/lifecycle.md`.-An item starts open. Its final states, verified and withdrawn, cannot be left, and every way into them passes the same exit guards, whatever command gets there. The board file itself refuses any move not declared here.+An item starts open. Its final states, withdrawn, cannot be left. Every move into a guarded state passes the same transition guards, whatever command gets there. The board file itself refuses any move not declared here.## Frozen check policy@@ -22,6 +22,7 @@ stateDiagram-v2submitted --> verified: acceptsubmitted --> open: rejectsubmitted --> open: reopen+ verified --> open: reopenopen --> open: escalateclaimed --> open: escalateopen --> open: refreeze@@ -31,7 +32,6 @@ stateDiagram-v2open --> withdrawn: withdrawclaimed --> withdrawn: withdrawsubmitted --> withdrawn: withdraw- verified --> [*]withdrawn --> [*]```@@ -42,7 +42,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 | built and gated green at a pinned commit, waiting for another agent | item_built_by, item_commit, item_frozen_digest |-| verified (final) | another agent accepted it at the submitted commit | item_verified_by, item_commit |+| verified | another agent accepted it at the submitted commit | item_verified_by, item_commit || withdrawn (final) | nobody should build it; the reason stays on it | item_withdrawn_reason |## Moves@@ -58,15 +58,15 @@ Each move checks its guards in this order and refuses with the first one that do| reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), roadmapReadable (MILESTONES_CORRUPT), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) || accept | submitted | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED) || reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED) |-| reopen | submitted | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED) |+| reopen | submitted, verified | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED) || escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED) || refreeze | open, claimed, submitted | open | coordinator, when there is no live claim awaiting a coordinator correction | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) || refreeze | claimed | claimed | agent, coordinator, when a live claim has a pending coordinator correction | joined (NOT_JOINED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) || withdraw | open, claimed, submitted | withdrawn | coordinator | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), inState (CLOSED) |-## Exit guards+## Required transition guards-| Final state | Every move into it passes |+| State entered | Every move into it passes || --- | --- || verified | atSubmittedCommit, notBuilder, criterionUnchanged, proofNoted || withdrawn | coordinatorOnly, noteGiven |@@ -81,7 +81,7 @@ Each move checks its guards in this order and refuses with the first one that do| NOT_SUBMITTED | reserve: the item is in submitted | pullboard show <id> || NOT_SUBMITTED | accept: the item is in submitted | pullboard show <id> || NOT_SUBMITTED | reject: the item is in submitted | pullboard show <id> |-| NOT_SUBMITTED | reopen: the item is in submitted | pullboard show <id> |+| NOT_SUBMITTED | reopen: the item is in submitted, verified | pullboard show <id> || CLOSED | escalate: the item is in open, claimed | pullboard show <id> || CLOSED | refreeze: the item is in open, claimed, submitted | pullboard show <id> || CLOSED | refreeze: the item is in claimed | pullboard show <id> |@@ -142,6 +142,8 @@ Each move checks its guards in this order and refuses with the first one that do| NOTE_REQUIRED | a review release gives a nonempty one-line reason, engine 5 or newer, only when freeing a submitted review reservation | release with --note "why", or --note-file <file> || REVIEW_COOLDOWN | the reviewer has not released this submission within the past hour, engine 5 or newer, only for the same reviewer and current submission | let another reviewer take it, or wait an hour or for a new submission || NOTE_REQUIRED | the move carries a note: what failed, what was tried, or why | --note "..." or --note-file <file> |+| ALREADY_MERGED | the item has no recorded merge receipt | a merged item cannot be reopened |+| LANDING_FAILURE_REQUIRED | a verified item note names the failing test and landing merge commit | cite the recorded batch, or name the test and merge commit in a manual note || BAD_DECISION | a verdict is accept or reject | pullboard verify <id> accept, or reject --reason CODE --note "..." |For check diagnostics, a refusal from a failed or unverifiable check includes an output digest, sanitized tail, and a private full-output path in the CLI message (also `error.message` in JSON). The artifact is owner-readable only. If it cannot be saved, the tail remains available and the message names the storage error instead of claiming a path.diff --git a/src/board.js b/src/board.jsindex 0b6ac522..91bfe211 100644--- a/src/board.js+++ b/src/board.js@@ -1420,23 +1420,51 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,});}-/** Return a submission for criterion correction without recording a verifier's judgment [V2,V6].- * The prior commit remains as the base the builder must change before resubmitting.+/** Return a submission for correction, or a verified item after a recorded red landing, without+ * rewriting its prior verdict [V2,V6]. The prior commit remains the builder's rework base.** @param {any} board* @param {number} id* @param {{ agentId: string, note: string }} request- * @returns {{ id: number, commit: string }}+ * @returns {{ id: number, commit: string, supersedes?: number, landingFailure?: object }}*/export function reopen(board, id, { agentId, note }) {return atomic(board, () => {let submittedCommit = null;+ let supersedes;+ let landingFailure;+ const currentEngine = board.executionEngineVersion ?? ENGINE_VERSION;+ const declaredTransition = MOVES.find((entry) => entry.verb === 'reopen');+ const transition = currentEngine >= 10 ? declaredTransition : { ...declaredTransition, from: ['submitted'] };const item = moveItem(board, id, 'reopen', {+ transition,checks: {joined: null,[IN_STATE]: (found) => new Refused('NOT_SUBMITTED', `item #${id} is ${current(board, found).item_status}, not submitted`),coordinatorOnly: () => onlyCoordinator(agentId, 'reopens submissions'),noteGiven: () => (note.trim() ? null : new Refused('NOTE_REQUIRED', 'say why the criterion needs correction: --note "why"')),+ notMerged: (found) => found.item_status !== 'verified' || !found.item_merged_commit+ ? null+ : new Refused('ALREADY_MERGED', `item #${id} was merged as ${found.item_merged_commit}; merged items cannot be reopened`),+ landingFailureRecorded: (found) => {+ if (found.item_status !== 'verified') return null;+ const accepted = events(board, { itemId: id }).findLast((event) => {+ if (event.event_kind !== 'accept') return false;+ return JSON.parse(event.event_detail).commit === found.item_commit;+ });+ const recorded = landingBatches(board).flatMap((batch) => (batch.culprits ?? []).map((culprit) => ({ batch, culprit })))+ .find(({ culprit }) => culprit.id === id && culprit.commit === found.item_commit && /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(culprit.mergeCommit ?? '')+ && Array.isArray(culprit.tests) && culprit.tests.length+ && culprit.tests.every((failure) => typeof failure.file === 'string' && typeof failure.name === 'string'+ && note.includes(`${failure.file}: ${failure.name}`) && note.includes(culprit.mergeCommit)));+ const manual = manualLandingFailure(note);+ if (!accepted || (!recorded && !manual)) return new Refused('LANDING_FAILURE_REQUIRED', `reopening verified item #${id} needs a failing test and merge commit in --note`);+ supersedes = accepted.event_id;+ landingFailure = recorded+ ? { batch: recorded.batch.id, tests: recorded.culprit.tests, mergeCommit: recorded.culprit.mergeCommit }+ : { batch: null, tests: [manual.test], mergeCommit: manual.mergeCommit };+ return null;+ },},set: (found) => {submittedCommit = found.item_commit;@@ -1450,11 +1478,20 @@ export function reopen(board, id, { agentId, note }) {};},});- logEvent(board, agentId, 'reopen', id, { commit: submittedCommit, note: note.trim(), judgment: null });- return { id: item.item_id, commit: submittedCommit };+ logEvent(board, agentId, 'reopen', id, { commit: submittedCommit, note: note.trim(), judgment: null,+ ...(supersedes ? { supersedes, landingFailure } : {}) });+ return { id: item.item_id, commit: submittedCommit, ...(supersedes ? { supersedes, landingFailure } : {}) };});}+/** Read test and merge-commit evidence from a Studio/manual landing note without checking Git. */+function manualLandingFailure(note) {+ const test = note.match(/(?<file>(?:[\w.-]+\/)+[\w.-]+):\s*(?<name>[^;\n]+?)(?=\s*;\s*merge commit\b|$)/iu);+ const mergeCommit = note.match(/\bmerge commit\s+([a-f0-9]{40}|[a-f0-9]{64})\b/iu)?.[1];+ if (!test || !test.groups.name.trim() || !mergeCommit) return null;+ return { test: { file: test.groups.file, name: test.groups.name.trim() }, mergeCommit };+}+/*** Refuse unless the acting agent is the coordinator.*diff --git a/src/cli.js b/src/cli.jsindex 8de793a1..01ea6f9b 100644--- a/src/cli.js+++ b/src/cli.js@@ -2395,7 +2395,9 @@ function workCommands(io, args) {reopen: () => act(async (ctx, board, me) => {const result = await ordered(ctx, board, 'reopen', [idArg(first), { agentId: me.id, note: textArg(io, values, 'note') ?? '' }]);io.result?.(result);- io.say(`reopened #${first} without a verdict; previous commit ${result.commit.slice(0, 12)} remains recorded`);+ io.say(result.landingFailure+ ? `reopened #${first} after landing failure; previous accept remains recorded at ${result.commit.slice(0, 12)}`+ : `reopened #${first} without a verdict; previous commit ${result.commit.slice(0, 12)} remains recorded`);return 0;}),shout: () => act(async (ctx, board, me) => {diff --git a/src/land.js b/src/land.jsindex 307942cf..aef3839a 100644--- a/src/land.js+++ b/src/land.js@@ -170,8 +170,10 @@ async function bisect(state, items, failures, label = 'split') {if (!store.itemThread(state.board, item.id).some((entry) => entry.type === 'fact' && entry.text === text)) {await state.write('appendFact', [item.id, { agentId: 'coordinator', kind: 'measurement', text }]);}- if (!state.culprits.some((entry) => entry.id === item.id)) state.culprits.push({ id: item.id, commit: item.commit, tests: failures });+ 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 });await save(state, { culprits: state.culprits });+ await returnCulprits(state);state.say(`culprit #${item.id}: ${failures.map((failure) => failure.name).join(', ')}`);return [];}@@ -195,6 +197,17 @@ async function bisect(state, items, failures, label = 'split') {return green;}+/** Return recorded red candidates once, including a saved failure interrupted before its move. */+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+ || !/^(?:[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 }]);+ }+}+/** File a flake once against its named test and leave the batch stopped. */async function fileFlakes(state, gate, files) {const flakes = [];@@ -293,9 +306,11 @@ export async function land({ root, board, config, write, say, owner, maximum = I}const state = { root, board, config, write, say, onWait, batch, culprits: batch.culprits ?? [], flaky: false, gates: new Map((batch.gateResults ?? []).map((result) => [result.tree, result])), diagnosed: new Map((batch.diagnostics ?? []).map((result) => [result.test, result.isGreen])) };await save(state, { owner });+ await returnCulprits(state);if (state.batch.state === 'pushed' || state.batch.state === 'ready') await publish(state);else {- const initialItems = state.batch.candidates ?? state.batch.items;+ const initialItems = (state.batch.candidates ?? state.batch.items)+ .filter((entry) => !state.culprits.some((culprit) => culprit.id === entry.id && culprit.commit === entry.commit));if (!existsSync(state.batch.root)) throw new Refused('LAND_WORKTREE', `the recorded landing worktree is missing at ${state.batch.root}; restore it before adopting`);const build = await mergeGroup(state, initialItems);await save(state, { ...build, conflicts: [...state.batch.conflicts, ...build.conflicts] });diff --git a/src/machine.js b/src/machine.jsindex 6c12da3f..8515c14e 100644--- a/src/machine.js+++ b/src/machine.js@@ -10,7 +10,7 @@*//** Executable move semantics, carried by every sealed move and retained during replay [H16]. */-export const ENGINE_VERSION = 9;+export const ENGINE_VERSION = 10;/** @typedef {'agent' | 'coordinator' | 'clock'} Role */@@ -57,7 +57,7 @@ export const ENGINE_VERSION = 9;* @property {State[]} states* @property {Guard[]} guards* @property {Move[]} moves- * @property {Record<string, string[]>} exitGuards - Per final state, the guards every move into it names.+ * @property {Record<string, string[]>} exitGuards - Per target state, guards every move into it must name.* @property {{ refuse: string, rule: string, next: string }} unknownMove - The refusal for a move that does not exist.*/@@ -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: 'built and gated green at a pinned commit, waiting for another agent', requires: ['item_built_by', 'item_commit', 'item_frozen_digest'] },{- id: 'verified', final: true, means: 'another agent accepted it at the submitted commit', requires: ['item_verified_by', 'item_commit'],+ id: 'verified', means: 'another agent accepted it at the submitted commit', requires: ['item_verified_by', 'item_commit'],proof: {says: 'an ACCEPT at the submitted commit, on the frozen criterion, by the agent it names as verifier, who did not build it',sql: "EXISTS (SELECT 1 FROM verdict v WHERE v.item_id = NEW.item_id AND v.verdict_decision = 'ACCEPT' AND v.verdict_commit = NEW.item_commit AND v.verdict_digest = NEW.item_frozen_digest AND v.verdict_by = NEW.item_verified_by AND v.verdict_by <> NEW.item_built_by)",@@ -137,6 +137,8 @@ export const GUARDS = [{ id: 'reviewReleaseExplained', refuse: 'NOTE_REQUIRED', rule: 'a review release gives a nonempty one-line reason', next: 'release with --note "why", or --note-file <file>', source: 'board', when: 'engine 5 or newer, only when freeing a submitted review reservation' },{ id: 'reviewCooldownElapsed', refuse: 'REVIEW_COOLDOWN', rule: 'the reviewer has not released this submission within the past hour', next: 'let another reviewer take it, or wait an hour or for a new submission', source: 'board', when: 'engine 5 or newer, only for the same reviewer and current submission' },{ id: 'noteGiven', refuse: 'NOTE_REQUIRED', rule: 'the move carries a note: what failed, what was tried, or why', next: '--note "..." or --note-file <file>', source: 'board' },+ { id: 'notMerged', refuse: 'ALREADY_MERGED', rule: 'the item has no recorded merge receipt', next: 'a merged item cannot be reopened', source: 'board' },+ { id: 'landingFailureRecorded', refuse: 'LANDING_FAILURE_REQUIRED', rule: 'a verified item note names the failing test and landing merge commit', next: 'cite the recorded batch, or name the test and merge commit in a manual note', source: 'board' },];/** @type {Move[]} */@@ -172,8 +174,8 @@ export const MOVES = [command: 'pullboard verify <id> reject --reason CODE --note "..."',},{- verb: 'reopen', from: ['submitted'], to: 'open', by: ['coordinator'], refuse: 'NOT_SUBMITTED',- guards: ['joined', 'itemExists', IN_STATE, 'coordinatorOnly', 'noteGiven'],+ verb: 'reopen', from: ['submitted', 'verified'], to: 'open', by: ['coordinator'], refuse: 'NOT_SUBMITTED',+ guards: ['joined', 'itemExists', IN_STATE, 'coordinatorOnly', 'noteGiven', 'notMerged', 'landingFailureRecorded'],sets: ['item_verdict', 'item_verified_by', 'item_owner', 'item_lease_until', 'item_review_by', 'item_review_until'],command: 'pullboard reopen <id> --note "why"',},@@ -201,7 +203,7 @@ export const MOVES = [];/**- * What every move into a final state must pass, whatever the command (M2). The interpreter adds+ * Guards shared by every move into a target state, whatever the command (M2). The interpreter adds* any a move leaves out, and `machineProblems` reports the move anyway: a guard nobody can see in* a move's list is a guard nobody reviews.*@@ -302,7 +304,8 @@ function unreachable(machine) {}/**- * Properties 3 and 4: every final state has exit guards, and every move into it names them all.+ * Properties 3 and 4: every final state has exit guards, and every guarded target requires all+ * moves into it to name those guards.* A move that leaves one out is a second door (M2).** @param {Machine} machine@@ -496,7 +499,7 @@ function guardLabel(machine, move, id) {/*** The lifecycle as a markdown page: a Mermaid state diagram, every move with its guards in the- * order they are checked (exit guards included), each final state's exit guards, and every refusal+ * order they are checked (transition guards included), each guarded target's required guards, and every refusal* with the rule behind it and the next step (M1, P4). docs/lifecycle.md is this page, written by* `pullboard lifecycle`, and a test fails when the two differ, so the page cannot drift from the code.*@@ -506,6 +509,7 @@ function guardLabel(machine, move, id) {export function lifecycleMarkdown(machine = MACHINE) {const cell = (text) => String(text).replaceAll('|', '\\|');const finals = machine.states.filter((state) => state.final);+ const transitionGuards = Object.entries(machine.exitGuards);const edges = machine.moves.flatMap((move) => move.from.map((from) => ` ${from} --> ${move.to}: ${move.verb}${move.by.includes('clock') ? ' (clock)' : ''}`));const moves = machine.moves.map((move) => {const who = move.when ? `${move.by.join(', ')}, when ${move.when}` : move.by.join(', ');@@ -523,7 +527,7 @@ export function lifecycleMarkdown(machine = MACHINE) {'','Generated from src/machine.js by `pullboard lifecycle`. Do not edit it by hand: change the declaration, then run `pullboard lifecycle > docs/lifecycle.md`.','',- `An item starts ${machine.initial}. Its final states, ${finals.map((state) => state.id).join(' and ')}, cannot be left, and every way into them passes the same exit guards, whatever command gets there. The board file itself refuses any move not declared here.`,+ `An item starts ${machine.initial}. Its final states, ${finals.map((state) => state.id).join(' and ')}, cannot be left. Every move into a guarded state passes the same transition guards, whatever command gets there. The board file itself refuses any move not declared here.`,'','## Frozen check policy','',@@ -552,11 +556,11 @@ export function lifecycleMarkdown(machine = MACHINE) {'| --- | --- | --- | --- | --- |',...moves,'',- '## Exit guards',+ '## Required transition guards','',- '| Final state | Every move into it passes |',+ '| State entered | Every move into it passes |','| --- | --- |',- ...finals.map((state) => `| ${state.id} | ${(machine.exitGuards[state.id] ?? []).join(', ')} |`),+ ...transitionGuards.map(([state, guards]) => `| ${state} | ${guards.join(', ')} |`),'','## Refusals','',diff --git a/test/agent-model-engine.test.js b/test/agent-model-engine.test.jsindex deca2a0f..f52b8050 100644--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@ -11,8 +11,8 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';test('model declarations and event snapshots retain engines 1 through 9 semantics [O8,O3,H16]', (t) => {- assert.equal(ENGINE_VERSION, 9, 'model moves remain supported by the 0.8.10 engine');- for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9]) {+ assert.equal(ENGINE_VERSION, 10, 'engine 10 preserves the released engine-8 and engine-9 model behavior');+ for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, ENGINE_VERSION]) {const board = store.openBoard(':memory:');t.after(() => store.closeBoard(board));const registration = prepareEngineMove(board, 'register', [{ lane: 'web', path: '/web', model: 'First Model' }]);diff --git a/test/land.test.js b/test/land.test.jsindex 5e69ce45..579f0ffa 100644--- a/test/land.test.js+++ b/test/land.test.js@@ -194,7 +194,8 @@ test('land bisects a real red, skips named conflicts and refuses an unverified sconst afterCalls = calls(box).length;const again = json(box, box.repo, 'land');assert.deepEqual(again.landed, []);- assert.ok(again.blocked.some((entry) => entry.code === 'LAND_KNOWN_RED' && entry.id === entries[2].item));+ assert.equal(json(box, box.repo, 'show', String(entries[2].item)).item_status, 'open', 'the known red is returned to its builder');+ assert.ok(!again.blocked.some((entry) => entry.id === entries[2].item), 'returned work is not offered as a verified landing candidate');assert.equal(calls(box).length, afterCalls, 'known unchanged red is not retried');});diff --git a/test/machine.test.js b/test/machine.test.jsindex f149d165..2228972f 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -289,15 +289,15 @@ const BROKEN = [},{property: 'nothing leaves a final state',- breaks: (machine) => machine.moves.push({ verb: 'reopen', from: ['verified'], to: 'open', by: ['agent', 'coordinator'], refuse: 'NOT_VERIFIED', guards: ['joined', 'itemExists', IN_STATE] }),- says: /final state verified has a move out/,+ breaks: (machine) => machine.moves.push({ verb: 'restore', from: ['withdrawn'], to: 'open', by: ['agent', 'coordinator'], refuse: 'CLOSED', guards: ['joined', 'coordinatorOnly', 'itemExists', IN_STATE] }),+ says: /final state withdrawn has a move out/,},{property: 'every final state has exit guards',breaks: (machine) => {- machine.exitGuards.verified = [];+ machine.exitGuards.withdrawn = [];},- says: /final state verified has no exit guards/,+ says: /final state withdrawn has no exit guards/,},{property: 'accept names every exit guard of verified',@@ -372,7 +372,7 @@ const BROKEN = [test('the declared lifecycle is sound: reachable, no traps, no second door, every refusal with a next step [M1, M2, M4]', () => {assert.deepEqual(machineProblems(), []);assert.deepEqual(MACHINE.states.map((state) => state.id), ['open', 'claimed', 'submitted', 'verified', 'withdrawn']);- assert.deepEqual(MACHINE.states.filter((state) => state.final).map((state) => state.id), ['verified', 'withdrawn']);+ assert.deepEqual(MACHINE.states.filter((state) => state.final).map((state) => state.id), ['withdrawn']);assert.deepEqual(MACHINE.moves.map((move) => move.verb), ['claim', 'release', 'lapse', 'submit', 'reserve', 'accept', 'reject', 'reopen', 'escalate', 'refreeze', 'refreeze', 'withdraw']);});diff --git a/test/reopen.test.js b/test/reopen.test.jsindex 1c82f7dd..b5f6df93 100644--- a/test/reopen.test.js+++ b/test/reopen.test.js@@ -1,6 +1,6 @@/** Real Git, SQLite and ordered-engine coverage for coordinator criterion reopen [V2,V6,H16]. */import assert from 'node:assert/strict';-import { mkdtempSync, rmSync } from 'node:fs';+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { pathToFileURL } from 'node:url';@@ -65,6 +65,135 @@ function reserveFixtureReview(box) {return reviewPath;}+/** Configure a real private main, joined builder, failing landing test and bare origin. */+function landingProject() {+ const box = project('node --test web/landing.test.js');+ // The private landing runs a real nested Node test runner, not the parent's test worker.+ delete box.env.NODE_TEST_CONTEXT;+ mkdirSync(join(box.repo, 'web'), { recursive: true });+ writeFileSync(join(box.repo, 'web', 'feature.js'), 'export const status = "PASS";\n');+ writeFileSync(join(box.repo, 'web', 'landing.test.js'), [+ "import assert from 'node:assert/strict';",+ "import { readFileSync } from 'node:fs';",+ "import { test } from 'node:test';",+ "test('keeps the landed behavior', () => assert.match(readFileSync(new URL('./feature.js', import.meta.url), 'utf8'), /export const status/u));",+ '',+ ].join('\n'));+ const configPath = join(box.repo, 'pullboard.json');+ const config = JSON.parse(readFileSync(configPath, 'utf8'));+ config.affectedTests = 'node --test';+ writeFileSync(configPath, JSON.stringify(config, null, 2));+ box.git(box.repo, 'add', 'web/landing.test.js', 'web/feature.js', 'pullboard.json');+ box.git(box.repo, 'commit', '-q', '-m', 'test(web): add landing behavior check');+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');+ 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');+ return { ...box, remote };+}++/** Add a real trunk regression after review, so only combining it with the candidate turns red. */+function requireLandingBehavior(box) {+ const file = join(box.repo, 'web', 'landing.test.js');+ const previous = readFileSync(file, 'utf8');+ writeFileSync(file, previous.replace('assert.match', 'assert.doesNotMatch').replace('/export const status/u', '/RED/u'));+ box.git(box.repo, 'add', 'web/landing.test.js');+ box.git(box.repo, 'commit', '-q', '-m', 'test(web): check behavior during integration [G1]');+ box.git(box.repo, 'push', '-q', 'origin', 'main');+}++/** Add and submit an item using its real joined Git worktree and frozen syntax check. */+function submitLandingFixture(box, number, contents, cwd = box.web) {+ if (cwd !== box.web) {+ box.git(box.repo, 'worktree', 'add', '-q', '-b', `web/landing-${number}`, cwd, 'main');+ assert.match(box.run(cwd, 'join', 'web').out, /joined as web-/u);+ }+ const added = box.run(box.repo, 'add', 'web', `Landing fixture ${number}`, '--specs', 'G1', '--criterion', `landing fixture ${number} remains valid`,+ '--check', 'node --check web/feature.js', '--json');+ assert.equal(added.code, 0, added.err);+ const id = JSON.parse(added.out).item.item_id;+ assert.equal(box.run(cwd, 'claim', String(id)).code, 0);+ const committed = commitFile(box, cwd, 'web/feature.js', contents, `feat(web): submit landing fixture ${number} [G1]`);+ assert.equal(committed.status, 0, committed.stderr);+ const commit = box.git(cwd, 'rev-parse', 'HEAD');+ const submitted = box.run(cwd, 'submit', String(id));+ assert.equal(submitted.code, 0, submitted.err);+ return { id, cwd, commit };+}++/** Accept an item at its actual submitted commit, then restore the coordinator's main checkout. */+function acceptLandingFixture(box, item) {+ box.git(box.repo, 'switch', '-q', '--detach', item.commit);+ try {+ const result = box.run(box.repo, 'verify', String(item.id), 'accept', '--as', 'coordinator', '--note', 'private landing fixture passed its frozen check');+ assert.equal(result.code, 0, result.err);+ } finally { box.git(box.repo, 'switch', '-q', 'main'); }+}++/** Read a complete public item projection through a short-lived board connection. */+function readItem(box, id) {+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));+ try { return { ...store.getItem(board, id), thread: store.itemThread(board, id), verdicts: store.verdictsFor(board, id) }; }+ finally { store.closeBoard(board); }+}++/** Accepted engine-9 source before verified-item reopening; the 0.8.8 tag is not yet published. */+const engine9Source = '314ef28751c44c96186b337cc4ace0fd8bf33d42';++/** Assert both older sealed engines preserve their submitted-only verified-item refusal. */+async function assertLegacyVerifiedReopen(t, box, item, note) {+ for (const [version, reference] of [[8, 'v0.8.6'], [9, engine9Source]]) {+ const directory = mkdtempSync(join(tmpdir(), `pullboard-engine-${version}-verified-reopen-`));+ t.after(() => rmSync(directory, { recursive: true, force: true }));+ const source = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));+ const snapshot = exportBoard(source);+ store.closeBoard(source);+ const move = { version: 1, engine: version, id: `legacy-verified-reopen-${version}`, operation: 'reopen',+ args: [item.id, { agentId: 'coordinator', note }], actor: 'coordinator' };+ const receipt = { sequence: 1, at: '2026-10-11T12:00:00.000Z', kind: 'move',+ sender: { kind: 'agent', userId: 'fixture-user', agent: 'coordinator' } };++ const currentReceiver = store.openBoard(join(directory, 'current.sqlite'));+ t.after(() => store.closeBoard(currentReceiver));+ importBoard(currentReceiver, snapshot);+ const before = store.getItem(currentReceiver, item.id);+ const currentResult = applyRelayMove(currentReceiver, move, receipt);+ assert.equal(currentResult.error?.code, 'NOT_SUBMITTED');+ assert.deepEqual(store.getItem(currentReceiver, item.id), before, `engine-${version} replay leaves the verified item row unchanged`);+ assert.equal(currentResult.error?.message, `item #${item.id} is verified, not submitted`, `the current engine preserves engine-${version} refusal ordering and message`);++ const oldDirectory = join(directory, 'old-client');+ mkdirSync(oldDirectory);+ unpackRelease(reference, oldDirectory);+ const legacyEngine = await import(pathToFileURL(join(oldDirectory, 'src/engine.js')).href);+ const legacyStore = await import(pathToFileURL(join(oldDirectory, 'src/board.js')).href);+ const legacyExchange = await import(pathToFileURL(join(oldDirectory, 'src/exchange.js')).href);+ const legacyReceiver = legacyStore.openBoard(join(directory, 'legacy.sqlite'));+ t.after(() => legacyStore.closeBoard(legacyReceiver));+ legacyExchange.importBoard(legacyReceiver, snapshot);+ assert.equal((await import(pathToFileURL(join(oldDirectory, 'src/machine.js')).href)).ENGINE_VERSION, version);+ const legacyBefore = legacyStore.getItem(legacyReceiver, item.id);+ const legacyResult = legacyEngine.applyRelayMove(legacyReceiver, move, receipt);+ assert.equal(legacyResult.error?.code, 'NOT_SUBMITTED');+ assert.deepEqual(currentResult.error, legacyResult.error, `engine-${version} preserves the older refusal envelope`);+ assert.deepEqual(store.events(currentReceiver), legacyStore.events(legacyReceiver), `engine-${version} preserves the older refusal event history`);+ assert.deepEqual(legacyStore.getItem(legacyReceiver, item.id), legacyBefore, `the engine-${version} client keeps its submitted-only rule`);++ const nextMove = prepareEngineMove(currentReceiver, 'reopen', [item.id, { agentId: 'coordinator', note }],+ { id: `engine10-verified-reopen-after-${version}`, actor: 'coordinator' });+ assert.equal(nextMove.engine, 10);+ const beforeFuture = legacyExchange.exportBoard(legacyReceiver);+ assert.throws(() => legacyEngine.applyRelayMove(legacyReceiver, nextMove, { ...receipt, sequence: 2 }),+ (error) => error.code === 'ENGINE_VERSION');+ assert.deepEqual(legacyExchange.exportBoard(legacyReceiver), beforeFuture, `engine ${version} refuses before applying the engine-10 return`);+ const nextResult = applyRelayMove(currentReceiver, nextMove, { ...receipt, sequence: 2 });+ assert.equal(nextResult.error, undefined, JSON.stringify(nextResult));+ assert.equal(store.getItem(currentReceiver, item.id).item_status, 'open');+ assert.equal(nextResult.result.landingFailure.mergeCommit, note.match(/merge commit ([a-f0-9]{40})/u)[1]);+ }+}+test('the coordinator reopens a submitted item without a verdict [V2,V6,O8]', (t) => {const box = project();const submitted = submitFixture(box);@@ -112,12 +241,129 @@ test('the coordinator reopens a submitted item without a verdict [V2,V6,O8]', (tassert.equal(store.getItem(board, 1).item_criterion, 'The page renders a heading.');});+test('a red landing gate returns a verified item to its builder [B3,V4]', async (t) => {+ const box = landingProject();+ const item = submitLandingFixture(box, 1, 'export const status = "RED";\n');+ acceptLandingFixture(box, item);+ const initial = readItem(box, item.id);+ const originalAccept = initial.thread.find((event) => event.type === 'move' && event.kind === 'accept');+ assert.ok(originalAccept, 'the item begins with an actual accept event');+ requireLandingBehavior(box);++ const nonCoordinator = box.run(item.cwd, 'reopen', String(item.id), '--note', 'coordinator only', '--json');+ assert.equal(JSON.parse(nonCoordinator.out).error.code, 'COORDINATOR_ONLY');++ const landing = box.run(box.repo, 'land', '--max', '1', '--json');+ assert.equal(landing.code, 0, landing.err);+ const landingResult = JSON.parse(landing.out);+ assert.deepEqual(landingResult.culprits.map((culprit) => culprit.id), [item.id], JSON.stringify(landingResult));+ assert.equal(landingResult.culprits[0].mergeCommit, landingResult.batch.tip);+ assert.equal(landingResult.culprits[0].tests[0].file, 'web/landing.test.js');+ const returned = readItem(box, item.id);+ assert.equal(returned.item_status, 'open', 'land reopens its named culprit automatically');+ const automaticReopen = returned.thread.find((event) => event.type === 'move' && event.kind === 'reopen');+ assert.ok(automaticReopen);+ assert.equal(automaticReopen.detail.supersedes, originalAccept.eventId);+ assert.equal(automaticReopen.detail.landingFailure.mergeCommit, landingResult.batch.tip);+ assert.deepEqual(automaticReopen.detail.landingFailure.tests, landingResult.culprits[0].tests);+ assert.ok(returned.thread.some((event) => event.type === 'move' && event.eventId === originalAccept.eventId && event.kind === 'accept'),+ 'the original accept remains in append-only item history');+ assert.deepEqual(returned.thread.find((event) => event.eventId === originalAccept.eventId), originalAccept,+ 'returning the item does not rewrite its earlier accept event');+ assert.deepEqual(returned.verdicts, initial.verdicts, 'the prior verdict receipt stays byte-for-byte unchanged');+ const landingNote = automaticReopen.detail.note;++ const firstClaim = box.run(item.cwd, 'claim', String(item.id));+ assert.equal(firstClaim.code, 0, firstClaim.err);+ assert.equal(box.tryGit(item.cwd, 'merge-base', '--is-ancestor', item.commit, 'HEAD').status, 0,+ 'the builder reclaims on top of the accepted commit');+ const firstFix = commitFile(box, item.cwd, 'web/feature.js', 'export const status = "PASS";\n', 'fix(web): restore landing behavior [G1]');+ assert.equal(firstFix.status, 0, firstFix.stderr);+ item.commit = box.git(item.cwd, 'rev-parse', 'HEAD');+ const firstSubmit = box.run(item.cwd, 'submit', String(item.id));+ assert.equal(firstSubmit.code, 0, firstSubmit.err);+ const awaitingFreshAccept = readItem(box, item.id);+ assert.equal(awaitingFreshAccept.item_status, 'submitted');+ assert.equal(awaitingFreshAccept.item_verified_by, null, 'the older accept does not verify the resubmission');+ const firstDryLand = box.run(box.repo, 'land', '--dry-run', '--json');+ assert.equal(firstDryLand.code, 0, firstDryLand.err);+ assert.ok(!JSON.parse(firstDryLand.out).items.includes(item.id), 'the earlier accept cannot make the resubmission eligible to land');+ acceptLandingFixture(box, item);+ const firstResubmission = readItem(box, item.id);+ const firstFreshAccept = firstResubmission.thread.filter((event) => event.type === 'move' && event.kind === 'accept').at(-1);+ assert.notEqual(firstFreshAccept.detail.commit, originalAccept.detail.commit);++ await assertLegacyVerifiedReopen(t, box, item, landingNote);+ const manualBox = landingProject();+ const manualItem = submitLandingFixture(manualBox, 1, 'export const status = "PASS_MANUAL";\n');+ acceptLandingFixture(manualBox, manualItem);+ const manualBoard = store.openBoard(join(manualBox.repo, '.git', 'pullboard', 'board.sqlite'));+ try { assert.deepEqual(store.landingBatches(manualBoard), [], 'hand-run landing evidence starts with no recorded batch'); }+ finally { store.closeBoard(manualBoard); }+ const manualAccept = readItem(manualBox, manualItem.id).thread.find((event) => event.type === 'move' && event.kind === 'accept');+ const noNamedTest = manualBox.run(manualBox.repo, 'reopen', String(manualItem.id), '--note', `merge commit ${'d'.repeat(40)}`, '--json');+ assert.equal(noNamedTest.code, 1);+ assert.equal(JSON.parse(noNamedTest.out).error.code, 'LANDING_FAILURE_REQUIRED');+ const manualNote = `web/landing.test.js: keeps the landed behavior; merge commit ${'d'.repeat(40)}`;+ const manual = manualBox.run(manualBox.repo, 'reopen', String(manualItem.id), '--note', manualNote, '--json');+ assert.equal(manual.code, 0, manual.err);+ const manuallyReturned = readItem(manualBox, manualItem.id);+ assert.equal(manuallyReturned.item_status, 'open');+ const manualEvent = manuallyReturned.thread.filter((event) => event.type === 'move' && event.kind === 'reopen').at(-1);+ assert.equal(manualEvent.detail.supersedes, manualAccept.eventId);+ assert.deepEqual(manualEvent.detail.landingFailure, {+ batch: null,+ tests: [{ file: 'web/landing.test.js', name: 'keeps the landed behavior' }],+ mergeCommit: 'd'.repeat(40),+ });+ assert.ok(manuallyReturned.thread.some((event) => event.eventId === manualAccept.eventId && event.kind === 'accept'),+ 'the prior manual accept remains immutable in history');++ const nextManualNote = `web/landing.test.js: keeps the landed behavior; merge commit ${'e'.repeat(40)}`;+ const returnedAgain = box.run(box.repo, 'reopen', String(item.id), '--note', nextManualNote, '--json');+ assert.equal(returnedAgain.code, 0, returnedAgain.err);+ const returnedAgainItem = readItem(box, item.id);+ const returnedAgainEvent = returnedAgainItem.thread.filter((event) => event.type === 'move' && event.kind === 'reopen').at(-1);+ assert.equal(returnedAgainEvent.detail.supersedes, firstFreshAccept.eventId);+ assert.equal(returnedAgainEvent.detail.landingFailure.batch, null);++ const secondClaim = box.run(item.cwd, 'claim', String(item.id));+ assert.equal(secondClaim.code, 0, secondClaim.err);+ const secondFix = commitFile(box, item.cwd, 'web/feature.js', 'export const status = "PASS_AGAIN";\n', 'fix(web): finish landing rework [G1]');+ assert.equal(secondFix.status, 0, secondFix.stderr);+ item.commit = box.git(item.cwd, 'rev-parse', 'HEAD');+ const secondSubmit = box.run(item.cwd, 'submit', String(item.id));+ assert.equal(secondSubmit.code, 0, secondSubmit.err);+ const secondAwaitingAccept = readItem(box, item.id);+ assert.equal(secondAwaitingAccept.item_status, 'submitted');+ assert.equal(secondAwaitingAccept.item_verified_by, null, 'the prior accepts do not verify the second resubmission');+ const secondDryLand = box.run(box.repo, 'land', '--dry-run', '--json');+ assert.equal(secondDryLand.code, 0, secondDryLand.err);+ assert.ok(!JSON.parse(secondDryLand.out).items.includes(item.id), 'the earlier accepts cannot make the second resubmission eligible to land');+ acceptLandingFixture(box, item);+ const readyToLand = readItem(box, item.id);+ assert.equal(readyToLand.thread.filter((event) => event.type === 'move' && event.kind === 'accept').length, 3,+ 'the resubmitted work has a fresh accept');+ assert.equal(JSON.parse(box.run(item.cwd, 'reopen', String(item.id), '--note', landingNote, '--json').out).error.code, 'COORDINATOR_ONLY');++ const greenLanding = box.run(box.repo, 'land', '--max', '1', '--json');+ assert.equal(greenLanding.code, 0, greenLanding.err);+ assert.deepEqual(JSON.parse(greenLanding.out).landed, [item.id]);+ const merged = readItem(box, item.id);+ assert.equal(merged.item_status, 'verified');+ assert.ok(merged.item_merged_commit);+ const mergedReopen = box.run(box.repo, 'reopen', String(item.id), '--note', landingNote, '--json');+ assert.equal(mergedReopen.code, 1);+ assert.equal(JSON.parse(mergedReopen.out).error.code, 'ALREADY_MERGED');+});+test('a reopened item resubmits at a new head after a criterion edit [V2,V6,H16]', async (t) => {const box = project();const submitted = submitFixture(box);const reviewPath = reserveFixtureReview(box);const copies = replicaPair(t, box);assert.ok(ENGINE_VERSION >= 8, 'engine 8 introduces ordered reopen semantics');+ assert.ok(ENGINE_VERSION >= 10, 'engine 10 adds verified-item landing reopens');const move = prepareEngineMove(copies[0], 'reopen', [1, {agentId: 'coordinator', note: 'replay the no-verdict return',}], { id: 'reopen-engine-roundtrip', actor: 'coordinator' });@@ -131,12 +377,12 @@ test('a reopened item resubmits at a new head after a criterion edit [V2,V6,H16]unpackRelease('v0.8.4', oldDirectory);const oldEngine = await import(pathToFileURL(join(oldDirectory, 'src/engine.js')).href);const oldMachine = await import(pathToFileURL(join(oldDirectory, 'src/machine.js')).href);- assert.equal(oldMachine.ENGINE_VERSION, 7, 'exercise the actual released engine-7 client');+ assert.equal(oldMachine.ENGINE_VERSION, 7, 'retain coverage for the actual released engine-7 client');const sender = { kind: 'agent', userId: 'fixture-user', agent: 'coordinator' };assert.throws(() => oldEngine.applyRelayMove(oldReceiver, move, {sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender,}), (error) => error.code === 'ENGINE_VERSION');- assert.deepEqual(exportBoard(oldReceiver), beforeOldReceiver, 'the actual engine-7 client refuses before changing rows or replay state');+ assert.deepEqual(exportBoard(oldReceiver), beforeOldReceiver, 'the actual engine-7 client refuses the future move before changing rows or replay state');assert.equal(appliedSequence(oldReceiver), 0);assert.throws(() => applyRelayMove(oldReceiver, { ...move, engine: 7 }, {@@ -144,6 +390,40 @@ test('a reopened item resubmits at a new head after a criterion edit [V2,V6,H16]}), (error) => error.code === 'RELAY_MOVE');assert.deepEqual(exportBoard(oldReceiver), beforeOldReceiver, 'the current receiver rejects an impossible pre-introduction tag without mutation');+ for (const [version, reference] of [[8, 'v0.8.6'], [9, engine9Source]]) {+ const legacyDirectory = mkdtempSync(join(tmpdir(), `pullboard-engine-${version}-reopen-`));+ t.after(() => rmSync(legacyDirectory, { recursive: true, force: true }));+ unpackRelease(reference, legacyDirectory);+ const legacyEngine = await import(pathToFileURL(join(legacyDirectory, 'src/engine.js')).href);+ const legacyStore = await import(pathToFileURL(join(legacyDirectory, 'src/board.js')).href);+ const legacyExchange = await import(pathToFileURL(join(legacyDirectory, 'src/exchange.js')).href);+ const legacyMachine = await import(pathToFileURL(join(legacyDirectory, 'src/machine.js')).href);+ assert.equal(legacyMachine.ENGINE_VERSION, version, `exercise the actual engine-${version} source`);+ const legacyReceiver = legacyStore.openBoard(join(box.dir, `engine-${version}-reopen.sqlite`));+ t.after(() => legacyStore.closeBoard(legacyReceiver));+ const submittedSnapshot = exportBoard(copies[0]);+ legacyExchange.importBoard(legacyReceiver, submittedSnapshot);+ assert.throws(() => legacyEngine.applyRelayMove(legacyReceiver, move, {+ sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender,+ }), (error) => error.code === 'ENGINE_VERSION');+ const legacyMove = { ...move, id: `legacy-engine${version}-reopen`, engine: version };+ const legacyResult = legacyEngine.applyRelayMove(legacyReceiver, legacyMove, {+ sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender,+ });+ assert.equal(legacyResult.error, undefined, JSON.stringify(legacyResult));+ assert.deepEqual(legacyResult.result, { id: 1, commit: submitted.commit });+ const currentLegacyReceiver = store.openBoard(join(box.dir, `current-engine-${version}-reopen.sqlite`));+ t.after(() => store.closeBoard(currentLegacyReceiver));+ importBoard(currentLegacyReceiver, submittedSnapshot);+ const currentLegacyResult = applyRelayMove(currentLegacyReceiver, legacyMove, {+ sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender,+ });+ assert.equal(currentLegacyResult.error, undefined, JSON.stringify(currentLegacyResult));+ assert.deepEqual(currentLegacyResult.result, legacyResult.result);+ assert.deepEqual(store.getItem(currentLegacyReceiver, 1), legacyStore.getItem(legacyReceiver, 1),+ `the current engine replays a submitted engine-${version} reopen as its older client did`);+ }+const first = applyRelayMove(copies[0], move, { sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender });const second = applyRelayMove(copies[1], move, { sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender });assert.deepEqual(first, second);