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(review): compose checked reviews at engine 33 [E8,H16,D1]

Corey Olson9642338cc040
diff --cc docs/api.md
index 8c4330a8,89c8beb2..047e6c82
--- a/docs/api.md
+++ b/docs/api.md
@@@ -437,14 -440,4 +446,14 @@@ Each checkout with a committed npm lock
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. Coordinator resume derives `item_checked_commit` on its pending-merge cards. Merge groups, active integration claims and the printed merge command use that accepted composition; `item_commit` remains the immutable submitted identity, and stale cards still stay out of `toMerge`. 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 starts at engine 25 on this composition, as assigned by the coordinator. Before landing, merge the actual trunk; if trunk has passed 25, use its next engine number and notify the coordinator. Earlier records retain their original meaning.
++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. Coordinator resume derives `item_checked_commit` on its pending-merge cards. Merge groups, active integration claims and the printed merge command use that accepted composition; `item_commit` remains the immutable submitted identity, and stale cards still stay out of `toMerge`. 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 starts at engine 33 on this composition, as assigned by the coordinator. Merge the actual trunk before landing. Earlier records retain their original meaning.
+
+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.
+
+Device-sealed presentations carry the same derived `verdictState`, including Git-only trunk movement and re-review, without changing native tables. Browser snapshot decoding preserves it. Repeated unchanged sealed snapshots reuse derived values and start no Git process after warm-up; staged supplied boards bypass that cache.
+
+Cold freshness reads query first-parent history limited to the item’s literal paths, then inspect matching commits. Unrelated main revisions do not each start a file-diff process; merge and revert changes still count.
+
+Unavailable Git-object verdict projections are retried on the next read, so fetching the sealed reviewed commit clears that uncertainty without a board event or trunk move. Known freshness projections remain cached.
+
When the runner's own resource pool refuses the run's setup, the run fails at once with `RUNNER_SETUP_REFUSED`, naming the runner host and the pool's refusal code. It is not retried, and it leaves no holder or waiter on either machine.
diff --cc docs/formats.md
index 1cb05ba3,df5ecd04..e6137d4b
--- a/docs/formats.md
+++ b/docs/formats.md
@@@ -113,7 -113,7 +113,7 @@@ The board file is in the repository's G
| `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` | `25` | `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` | `30` | `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` | `33` | `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. Pullboard 0.8.8 released engine 9, which 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.
@@@ -124,9 -124,7 +124,9 @@@ Engine 11 permits resubmitting the sam
Engine 12 records declined person row decisions without replacing the exact source text: the row becomes `wont` and the reason stays in the decision record. Engine-11 decline receipts retain their original reason-as-row-text validation and replay outcome. Engine-11 clients refuse engine-12 moves before interpreting them; upgrade linked clients before recording new decline decisions.
-Engine 19 makes a corrected bar record why the old one was wrong. Once an item has ever been claimed, an `editItem` that changes its criterion or check must carry `reason`, the text of what the old bar got wrong; without one it is refused with `BAR_REASON`, naming `--reason`. The edit event then records `reason` and `barCorrection: {fields, reject}`: `fields` lists `criterion` and/or `check`, and `reject` is `{verdict, by, reason, at}` when the item's newest verdict is a reject no earlier correction already explained, or `null`. That reject is counted as caused by the bar. The board derives `barCorrection` from its own rows; a move supplies only `reason`. An edit before any claim needs no reason and records one only if given. `pullboard stats` JSON adds `bars`, keyed by agent: `{corrections, barRejects, buildRejects}`. Corrections and the rejects they explain count to the agent who corrected the bar; any other reject counts as the build's, to the agent who added the item. An `editItem` move carrying `reason` requires engine 19, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor. Moves recorded under engines 18 and earlier replay without the reason rule. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.
+Engine 19 makes a corrected bar record why the old one was wrong. Once an item has ever been claimed, an `editItem` that changes its criterion or check must carry `reason`, the text of what the old bar got wrong; without one it is refused with `BAR_REASON`, naming `--reason`. The edit event then records `reason` and `barCorrection: {fields, reject}`: `fields` lists `criterion` and/or `check`, and `reject` is `{verdict, by, reason, at}` when the item's newest verdict is a reject no earlier correction already explained, or `null`. That reject is counted as caused by the bar. The board derives `barCorrection` from its own rows; a move supplies only `reason`. An edit before any claim needs no reason and records one only if given. `pullboard stats` JSON adds `bars`, keyed by agent: `{corrections, barRejects, buildRejects}`. Corrections and the rejects they explain count to the agent who corrected the bar; any other reject counts as the build's, to the agent who added the item. An `editItem` move carrying `reason` requires engine 19, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor. Moves recorded under engines 18 and earlier replay without the reason rule. Trunk skipped engine numbers 13 through 18. A later engine change takes the current trunk's next number, keeping every earlier recorded engine's replay unchanged.
+
- Engine 25 binds a review to the immutable submitted commit, the exact checked composition, its reviewed trunk and sorted candidate paths. A stale, unmerged acceptance can be re-reviewed without rewriting the submission; landing uses its accepted checked composition. New review metadata and landing batches carrying `reviewedCommit` require engine 25, including later updates to those batches. Previously recorded outcomes replay before this state-dependent version check, and previously released engines retain their original review and landing behavior. Older clients refuse engine-25 moves before changing their board or replay cursor; upgrade linked clients before using checked-composition reviews. The coordinator assigned engine 25 to this change. Before landing, merge the actual trunk; if trunk has passed 25, use its next engine number and notify the coordinator.
++Engine 33 binds a review to the immutable submitted commit, the exact checked composition, its reviewed trunk and sorted candidate paths. A stale, unmerged acceptance can be re-reviewed without rewriting the submission; landing uses its accepted checked composition. New review metadata and landing batches carrying `reviewedCommit` require engine 33, including later updates to those batches. Previously recorded outcomes replay before this state-dependent version check, and previously released engines retain their original review and landing behavior. Older clients refuse engine-33 moves before changing their board or replay cursor; upgrade linked clients before using checked-composition reviews. The coordinator assigned engine 33 to this change. Merge the actual trunk before landing.
Engine 20 lets a decision name the items it changes. An `appendFact`, `answerDecision` or `verify` move may carry `implies`, a list of existing item ids, and an `answerDecision` move may carry `supersedes`, the shout id of an earlier answer. Either makes the move an engine-20 move: an older engine refuses it with `RELAY_MOVE` before changing its board or cursor, and a board replaying an older engine refuses `implies` with `ENGINE_VERSION`. Engine 20 also tells implied items when a decision is superseded: by a fact's `supersedes`, by an answer's `supersedes`, or by the next verdict on the same item. Moves recorded under engines 19 and earlier replay without these notices. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.
@@@ -330,8 -330,8 +332,8 @@@ The `event` table is a SQLite schema ob
| `release` | builder | — |
| `submit` | builder | `commit`, `tree`, `policyCommit`, engine-9 `criterionDigest` |
| `reserve` | reviewer | `until` |
- | `accept` | reviewer | `reason`, `commit`, engine-20 `implies`, engine-25 `review` |
- | `reject` | reviewer | `reason`, `commit`, engine-20 `implies`, engine-25 `review` |
-| `accept` | reviewer | `reason`, `commit`, engine-20 `implies` |
-| `reject` | reviewer | `reason`, `commit`, engine-20 `implies` |
++| `accept` | reviewer | `reason`, `commit`, engine-20 `implies`, engine-33 `review` |
++| `reject` | reviewer | `reason`, `commit`, engine-20 `implies`, engine-33 `review` |
| `reopen` | coordinator | `commit`, `note`, `judgment`, engine-10 `supersedes`, `landingFailure` |
| `merged` | coordinator | `commit` |
| `landing_batch` | coordinator | `batch` |
@@@ -407,6 -406,6 +409,6 @@@ The schema, trigger and parser tables a
### 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. 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.
-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-33 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 --cc docs/lifecycle.md
index 4aded3f3,12fe1ac1..4fec2d60
--- a/docs/lifecycle.md
+++ b/docs/lifecycle.md
@@@ -58,9 -56,9 +58,9 @@@ Each move checks its guards in this ord
| lapse | claimed | open | clock, when its lease runs out | none |
| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), checkProvesSomething (CRITERION_PROVES_NOTHING), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT), withinLane (OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), gateGreen (GATE_RED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |
| 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), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED), result (LAND_HEADER), result (ENGINE_VERSION) |
-| 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), causeWellFormed (BAD_CAUSE), result (LAND_HEADER), result (ENGINE_VERSION) |
+| accept | submitted, verified | 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), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), 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), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED), result (LAND_HEADER), result (ENGINE_VERSION) |
- | reject | submitted, verified | 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), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), result (LAND_HEADER), result (ENGINE_VERSION) |
- | 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) |
++| reject | submitted, verified | 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), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), result (LAND_HEADER), result (ENGINE_VERSION) |
+ | reopen | submitted, verified | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), 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) |
diff --cc src/board.js
index 01bc5717,07046735..3fa71643
--- a/src/board.js
+++ b/src/board.js
@@@ -15,9 -13,11 +15,11 @@@ import { DatabaseSync } from 'node:sqli
import { boardNotWritable } from './board-access.js';
import { briefFiles, briefSections } from './brief.js';
import { COORDINATOR } from './config.js';
-import { ENGINE_VERSION, GUARDS, IN_STATE, MOVES, STATES, UNKNOWN_MOVE, effectiveGuards, storeTriggers } from './machine.js';
+import { ENGINE_VERSION, VERDICT_REVIEW_ENGINE, GUARDS, IN_STATE, MOVES, STATES, UNKNOWN_MOVE, effectiveGuards, storeTriggers } from './machine.js';
import { Refused } from './refused.js';
+ import { causeProblem, requireNeverAgain } from './rigor.js';
import { barCorrectionFields } from './bar-corrections.js';
+ import { factReference } from './fact-reference.js';
import { factFromEvent, requestAnswerRefusal, tellAnswerImplications, tellFactImplications, tellVerdictImplications } from './implies.js';
import { parseSpec } from './spec.js';
export { acceptCheck } from './check-accept.js';
@@@ -1485,10 -1484,10 +1487,10 @@@ function reserveWithin(board, id, { age
*
* @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, head?: string, trunk: string, paths: string[]}, implies?: number[], impliesId?: string }} verdict - implies: items this verdict changes (B29)
- * @param {{ agentId: string, decision: string, reason?: string, note?: string, cause?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green', implies?: number[], impliesId?: string }} verdict - implies: items this verdict changes (B29)
++ * @param {{ agentId: string, decision: string, reason?: string, note?: string, cause?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green', review?: {commit: string, head?: string, trunk: string, paths: string[]}, implies?: number[], impliesId?: string }} verdict - implies: items this verdict changes (B29)
* @returns {{ decision: string, reason: string, check?: 'none' | 'green' }}
*/
- export function verify(board, id, { agentId, decision, reason, note = '', head, digest, policy, familyPolicy = 'off', check, review, implies, impliesId }) {
-export function verify(board, id, { agentId, decision, reason, note = '', cause, head, digest, policy, familyPolicy = 'off', check, implies, impliesId }) {
++export function verify(board, id, { agentId, decision, reason, note = '', cause, head, digest, policy, familyPolicy = 'off', check, review, implies, impliesId }) {
const verb = { ACCEPT: 'accept', REJECT: 'reject' }[decision];
if (!verb) throw new Refused('BAD_DECISION', 'the decision is accept or reject');
const isAccept = verb === 'accept';
@@@ -1539,9 -1528,8 +1542,9 @@@
},
set: (found) => ({ item_verdict: decision, item_verified_by: isAccept ? agentId : null, item_owner: isAccept ? found.item_owner : null }),
});
- const detail = { reason: code, commit: item.item_commit };
+ const detail = { reason: code, commit: item.item_commit, ...(!isAccept && cause !== undefined && cause !== null ? { cause } : {}) };
if (isAccept && check !== undefined) detail.check = check;
+ 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, implies?.length ? { ...detail, implies } : detail);
tellVerdictImplications(board, (by, itemId, fact) => logEvent(board, by, 'fact', itemId, fact), id, { seed: impliesId, implies });
return { decision, reason: code, ...(isAccept && check !== undefined ? { check } : {}) };
diff --cc src/engine.js
index 13b6deea,bfdaaf96..a88943bd
--- a/src/engine.js
+++ b/src/engine.js
@@@ -5,7 -5,7 +5,7 @@@ import { recordedRefusal } from './reco
import { BAR_ENGINE, carriesBarReason } from './bar-corrections.js';
import { carriesImplies, IMPLIES_ENGINE } from './implies.js';
import { CHECK_ACCEPT_ENGINE } from './check-accept.js';
- import { ENGINE_VERSION, VERDICT_REVIEW_ENGINE } from './machine.js';
-import { CAUSE_ENGINE, ENGINE_VERSION } from './machine.js';
++import { CAUSE_ENGINE, ENGINE_VERSION, VERDICT_REVIEW_ENGINE } from './machine.js';
import { Refused } from './refused.js';
import { requestMoveProblem, recordRequestMove } from './relay-requests.js';
import { relayMoveActor, relaySenderProblem, validRelaySender } from './relay-sender.js';
@@@ -25,17 -25,13 +25,19 @@@ export const ENGINE_OPERATIONS = Object
/** Engine version at which each ordered operation first has stable replay semantics. */
const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8, acceptCheck: CHECK_ACCEPT_ENGINE });
-/** Dependency edits add engine-10 meaning, edit reasons engine-19, implied items engine-20, and a
- * cause key on a reject, reopen or person fact engine-30 (#713), without changing ordinary historical envelopes.
- */
-function minimumOperationEngine(operation, args) {
+/** Dependency edits, bar reasons and sealed review metadata retain their distinct recorded engine meanings. */
+function minimumOperationEngine(operation, args, board) {
const options = args[1];
+ const given = (name) => Boolean(options && typeof options === 'object' && Object.hasOwn(options, name) && options[name] !== undefined && options[name] !== null && options[name] !== false);
+ 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;
+ if (['verify', 'reopen', 'appendFact'].includes(operation) && (given('cause') || given('neverAgain') || given('asPerson'))) return CAUSE_ENGINE;
if (carriesImplies(operation, args)) return IMPLIES_ENGINE;
if (carriesBarReason(operation, args)) return BAR_ENGINE;
return operation === 'editItem' && options && Object.hasOwn(options, 'after') && options.after !== undefined
diff --cc src/machine.js
index 28a89449,14be3e95..d569abe7
--- a/src/machine.js
+++ b/src/machine.js
@@@ -10,11 -10,11 +10,14 @@@
*/
/** Executable move semantics, carried by every sealed move and retained during replay [H16]. */
- export const ENGINE_VERSION = 25;
-export const ENGINE_VERSION = 30;
++export const ENGINE_VERSION = 33;
+
+ /** The engine at which a reject, reopen or person fact can carry a cause key (#713); older moves replay unchanged [D1,H16]. */
+ export const CAUSE_ENGINE = 30;
+/** First released engine binding the checked composition, review trunk and paths [E8,H16]. */
- export const VERDICT_REVIEW_ENGINE = 25;
++export const VERDICT_REVIEW_ENGINE = 33;
+
/** @typedef {'agent' | 'coordinator' | 'clock'} Role */
/**
@@@ -179,8 -178,8 +183,8 @@@ export const MOVES =
sets: ['item_verified_by'], command: 'pullboard verify <id> accept --note "..."',
},
{
- verb: 'reject', from: ['submitted'], to: 'open', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',
- guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven', 'causeWellFormed'],
+ verb: 'reject', from: ['submitted', 'verified'], to: 'open', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',
- guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notMerged', 'verdictReviewRecorded', 'reviewTreeCurrent', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven'],
++ guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notMerged', 'verdictReviewRecorded', 'reviewTreeCurrent', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven', 'causeWellFormed'],
alsoRefuses: [{ code: 'LAND_HEADER', rule: 'a displayed merge command fits the commit-header limit', next: 'shorten the item title or cited rows so the merge header fits' }, { code: 'ENGINE_VERSION', rule: 'a verdict that implies items replays only under engine 20 or later', next: 'upgrade Pullboard on every linked device before using --implies' }],
command: 'pullboard verify <id> reject --reason CODE --note "..."',
},
diff --cc test/agent-model-engine.test.js
index f1059499,f3b39a11..d0bca12b
--- a/test/agent-model-engine.test.js
+++ b/test/agent-model-engine.test.js
@@@ -10,9 -10,9 +10,9 @@@ import { mkdtempSync, rmSync, writeFile
import { tmpdir } from 'node:os';
import { join } from 'node:path';
- test('model declarations and event snapshots retain engines 1 through 24 semantics [O8,O3,H16]', (t) => {
- assert.equal(ENGINE_VERSION, 25, 'the next writer preserves every historical model snapshot through main engine 24');
-test('model declarations and event snapshots retain engines 1 through 11 semantics [O8,O3,H16]', (t) => {
- assert.equal(ENGINE_VERSION, 30, 'engine 30 preserves the released engine-8 through engine-11 model behavior');
- for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ENGINE_VERSION]) {
++test('model declarations and event snapshots retain engines 1 through 33 semantics [O8,O3,H16]', (t) => {
++ assert.equal(ENGINE_VERSION, 33, 'the next writer preserves every historical model snapshot through main engine 30');
+ for (const version of Array.from({ length: ENGINE_VERSION }, (_, index) => index + 1)) {
const board = store.openBoard(':memory:');
t.after(() => store.closeBoard(board));
const registration = prepareEngineMove(board, 'register', [{ lane: 'web', path: '/web', model: 'First Model' }]);
diff --cc test/pending-refreeze.test.js
index e260ef66,710c1495..03fb0767
--- a/test/pending-refreeze.test.js
+++ b/test/pending-refreeze.test.js
@@@ -261,7 -261,7 +261,7 @@@ async function checkDependencyLegacyCli
}
test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {
- assert.equal(ENGINE_VERSION, 25, 'the next writer retains all recorded dependency-edit behavior');
- assert.equal(ENGINE_VERSION, 30);
++ assert.equal(ENGINE_VERSION, 33, 'the next writer retains all recorded dependency-edit behavior');
const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));
const cleanup = [];
t.after(() => {
diff --cc test/rigor.test.js
index 00000000,77c1b3ae..5e7cb4e2
mode 000000,100644..100644
--- a/test/rigor.test.js
+++ b/test/rigor.test.js
@@@ -1,0 -1,291 +1,292 @@@
+ /** Rigor: a repeated failure cause is noticed from structured fields, never from notes [D1,V1]. */
+ import assert from 'node:assert/strict';
+ import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
+ import { tmpdir } from 'node:os';
+ import { join, resolve } from 'node:path';
+ import { pathToFileURL } from 'node:url';
+ import { after, test } from 'node:test';
+ import { runFixtureChild, runFixtureGit } from './fixture-child.js';
+ import * as store from '../src/board.js';
+ import { applyEngineMove, prepareEngineMove } from '../src/engine.js';
-import { CAUSE_ENGINE } from '../src/machine.js';
++import { CAUSE_ENGINE, ENGINE_VERSION } from '../src/machine.js';
+ import { rigorReport } from '../src/rigor.js';
+ import { unpackRelease } from './release-archive.js';
+
+ const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
+ const MARKERS = ['CLAUDECODE', 'CLAUDE_CODE_ENTRYPOINT', 'CLAUDE_CODE_SESSION_ID', 'AI_AGENT', 'CODEX_THREAD_ID', 'CODEX_SESSION_ID', 'CODEX_CI', 'CODEX_SHELL', 'SSH_CONNECTION', 'SSH_TTY'];
+ const DIRS = [];
+ const HOUR = 3_600_000;
+ const MERGE = 'c'.repeat(40);
+
+ after(() => { for (const dir of DIRS) rmSync(dir, { recursive: true, force: true }); });
+
+ /** A freshly initialized repo with a private board, Pullboard home and Git identity, run as the person's terminal. */
+ function freshBoard() {
+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-rigor-'));
+ DIRS.push(dir);
+ // The hooks init installs call pullboard by name, so this checkout's CLI is the one on PATH.
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ writeFileSync(join(bin, 'pullboard'), `#!/bin/sh\nexec '${process.execPath.replaceAll("'", "'\\''")}' '${BIN.replaceAll("'", "'\\''")}' "$@"\n`);
+ chmodSync(join(bin, 'pullboard'), 0o755);
+ const env = { ...process.env };
+ for (const key of Object.keys(env)) if (key.startsWith('GIT_') || key.startsWith('PULLBOARD_') || MARKERS.includes(key)) delete env[key];
+ Object.assign(env, {
+ PATH: `${bin}:${process.env.PATH}`,
+ PULLBOARD_HOME: join(dir, 'home'), PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),
+ GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',
+ GIT_AUTHOR_NAME: 'Rigor fixture', GIT_AUTHOR_EMAIL: '[email protected]',
+ GIT_COMMITTER_NAME: 'Rigor fixture', GIT_COMMITTER_EMAIL: '[email protected]',
+ });
+ const repo = join(dir, 'repo');
+ mkdirSync(repo);
+ const git = (...args) => runFixtureGit(args, { cwd: repo, env });
+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });
+ git('init', '-q', '-b', 'main');
+ const init = run('init', '--model', 'Rigor coordinator');
+ assert.equal(init.status, 0, init.stdout + init.stderr);
+ const config = join(repo, 'pullboard.json');
+ writeFileSync(config, `${JSON.stringify({ ...JSON.parse(readFileSync(config, 'utf8')), gate: 'true' }, null, 2)}\n`);
+ git('add', '-A');
+ git('commit', '-q', '-m', 'chore: set up rigor fixture');
+ const file = join(repo, '.git', 'pullboard', 'board.sqlite');
+ return { dir, repo, run, git, file, env };
+ }
+
+ /** Run one command with --json and return its document, failing with its output. */
+ function json(box, ...args) {
+ const result = box.run(...args, '--json');
+ assert.equal(result.status, 0, `${args.join(' ')}: ${result.stdout}${result.stderr}`);
+ return JSON.parse(result.stdout);
+ }
+
+ /** Assert a CLI run refused with one code, naming the rule it proves when it did not. */
+ function refused(result, code, why) {
+ const document = JSON.parse(result.stdout || '{}');
+ assert.equal(document.error?.code, code, `${why}: ${result.stdout}${result.stderr}`);
+ }
+
+ /**
+ * Build board history straight through the board's own moves on the real SQLite file: a builder
+ * and a reviewer in one lane, and helpers to submit, reject and land-reopen an item.
+ */
+ function history(file) {
+ const board = store.openBoard(file);
+ const builder = store.register(board, { lane: 'app', path: '/fixture/app-1', model: 'Builder model' });
+ const reviewer = store.register(board, { lane: 'app', path: '/fixture/app-2', model: 'Reviewer model' });
+ /** Freeze the item's title, as the real freezer digests its criterion. */
+ const freeze = (item) => ({ text: item.item_title, digest: `digest:${item.item_title}` });
+ let next = 0;
+ /** A fresh 40-character commit id for each submission. */
+ const commit = () => (++next).toString(16).padStart(40, '0');
+ /** Claim and submit an item at a new commit, returning that commit. */
+ const submit = (id) => {
+ store.claim(board, id, { agentId: builder, lane: 'app', leaseMs: 2 * HOUR, freeze });
+ const sha = commit();
+ store.submit(board, id, { agentId: builder, commit: sha, tree: `tree-${sha}` });
+ return sha;
+ };
+ /** Reject the current submission, naming a cause key or none. */
+ const reject = (id, cause, note = 'the named test failed at this commit') => store.verify(board, id, {
+ agentId: reviewer, decision: 'REJECT', reason: 'TEST_FAILURE', note, ...(cause === undefined ? {} : { cause }),
+ head: store.getItem(board, id).item_commit, digest: `digest:${store.getItem(board, id).item_title}`, policy: 'any',
+ });
+ /** Accept, then reopen after a red landing whose failing test the note names in the landing format. */
+ const landReopen = (id, test) => {
+ store.verify(board, id, { agentId: reviewer, decision: 'ACCEPT', note: 'broke the fix; its test failed; restored it',
+ head: store.getItem(board, id).item_commit, digest: `digest:${store.getItem(board, id).item_title}`, policy: 'any' });
+ return store.reopen(board, id, { agentId: 'coordinator', note: `${test.file}: ${test.name}; merge commit ${MERGE}` });
+ };
+ /** Add one item in the fixture lane. */
+ const add = (title) => store.addItem(board, { by: 'coordinator', lane: 'app', title });
+ return { board, add, submit, reject, landReopen, close: () => store.closeBoard(board) };
+ }
+
+ test('a repeated failure cause is noticed [D1,V1]', () => {
+ const box = freshBoard();
+ const before = json(box, 'rigor');
+ assert.deepEqual(before.causes, [], 'an empty board has no repeated cause');
+
+ const catalog = 'test:test/api.test.js::[A1] every catalog command and subcommand has a real CLI exercise';
+ const board = history(box.file);
+ const [first, second, third, single, conflictA, conflictB] = ['First', 'Second', 'Third', 'Single', 'Conflict A', 'Conflict B'].map(board.add);
+ // A repeat: the same failing test sends back two items.
+ board.submit(first); board.reject(first, catalog);
+ board.submit(second); board.reject(second, catalog);
+ // A repeat on one item at two different commits.
+ const firstSha = board.submit(third); board.reject(third, 'refusal:UNDECLARED_REFUSAL');
+ const secondSha = board.submit(third); board.reject(third, 'refusal:UNDECLARED_REFUSAL');
+ // A single: one failure on one item at one commit never lists.
+ board.submit(single); board.reject(single, 'row:G1');
+ // An uncaused reject: no structured cause and no --cause, so it records no key and is counted.
+ const uncausedItem = board.add('Uncaused');
+ board.submit(uncausedItem); board.reject(uncausedItem, undefined, `${catalog.slice('test:'.length).replace('::', ': ')} failed`);
+ // Merge conflicts on two items never list, however often they recur.
+ board.submit(conflictA); board.landReopen(conflictA, { file: 'src/help.js', name: 'conflicts with main 8b8dc50e (0.8.29), merge main and resubmit' });
+ board.submit(conflictB); board.landReopen(conflictB, { file: 'src/help.js', name: 'conflicts with main 8b8dc50e (0.8.29), merge main and resubmit' });
+ board.close();
+
+ const repeated = json(box, 'rigor');
+ assert.deepEqual(repeated.causes.map((cause) => cause.key), [catalog, 'refusal:UNDECLARED_REFUSAL'],
+ 'the two repeats list, the single and the merge conflicts do not');
+ const [test, refusal] = repeated.causes;
+ assert.deepEqual(test.items.map((item) => item.id), [first, second], 'a repeat lists both its items');
+ assert.equal(test.reads, 'both', 'a failing test reads as work or product, so the person picks');
+ assert.equal(test.occurrences, 2);
+ assert.deepEqual(refusal.items, [{ id: third, commits: [firstSha, secondSha] }], 'one item at two commits is a repeat');
+ assert.equal(refusal.reads, 'work', 'a refusal is about how the work is done');
+ assert.ok(!repeated.causes.some((cause) => cause.key === 'row:G1'), 'a single failure does not list');
+ assert.ok(!repeated.causes.some((cause) => /conflicts with/u.test(cause.key)), 'a merge conflict never lists');
+ assert.equal(repeated.uncaused, 1, 'the uncaused reject is counted, and its note naming the catalog test is never read as a key');
+ assert.equal(test.items.length, 2, 'the uncaused reject does not join the catalog cause');
+
+ // A person's never-again lists at once, from one fact and no failure at all.
+ const marked = json(box, 'fact', String(single), 'root-cause', 'Every function keeps its JSDoc block', '--cause', 'doctrine:C3', '--never-again', '--as', 'person');
+ assert.equal(marked.fact.by, store.PERSON, 'the fact is the person’s');
+ assert.equal(marked.fact.neverAgain, true);
+ const never = json(box, 'rigor');
+ assert.deepEqual(never.causes[0], { key: 'doctrine:C3', reads: 'work', occurrences: 0, neverAgain: true, items: [{ id: single, commits: [] }] },
+ 'the never-again lists first, at once');
+ assert.equal(never.causes.length, 3);
+
+ const text = box.run('rigor');
+ assert.equal(text.status, 0, text.stderr);
+ const lines = text.stdout.trim().split('\n');
+ assert.match(lines[0], /^doctrine:C3 {2}reads as work {2}never again \(the person\) {2}items #\d+$/u);
+ assert.equal(lines[1], `${catalog} reads as both 2 failures items #${first}, #${second}`);
+ assert.equal(lines[2], `refusal:UNDECLARED_REFUSAL reads as work 2 failures items #${third} (2 commits)`);
+ assert.equal(lines[3], '1 rejects and reopens carry no cause key; name one with --cause <key> (test:<file>::<title>, refusal:<CODE>, row:<id>, doctrine:<id>)',
+ 'rigor says how many rejects and reopens are uncaused');
+ assert.equal(lines.length, 4);
+ });
+
+ test('rigor reads old events by their structured fields only, never by their notes [D1,V1]', () => {
+ const box = freshBoard();
+ const board = history(box.file);
+ const [first, second, third, fourth] = ['First', 'Second', 'Third', 'Fourth'].map(board.add);
+ const landing = { file: 'test/machine.test.js', name: 'the declaration matches the refusals board.js and cli.js raise [M1]' };
+ // Reopens after a red landing carry their failing tests as structured fields, with no cause key.
+ board.submit(first); board.landReopen(first, landing);
+ board.submit(second); board.landReopen(second, landing);
+ // Rejects recorded without a cause key: their notes name the same test, and are never parsed.
+ const note = `${landing.file}: ${landing.name} failed again`;
+ board.submit(third); board.reject(third, undefined, note);
+ board.submit(fourth); board.reject(fourth, undefined, note);
+ board.close();
+ const report = json(box, 'rigor');
+ assert.deepEqual(report.causes.map((cause) => [cause.key, cause.items.map((item) => item.id)]),
+ [[`test:${landing.file}::${landing.name}`, [first, second]]], 'only the structured landing tests count');
+ assert.equal(report.uncaused, 2, 'the two causeless rejects are counted as uncaused');
+ const text = box.run('rigor');
+ assert.match(text.stdout, /^2 rejects and reopens carry no cause key; name one with --cause <key>/mu);
+ });
+
+ test('a cause key is checked, recorded on reject and reopen, and the person alone marks never-again [D1,V1,H16]', () => {
+ const box = freshBoard();
+ const board = history(box.file);
+ const id = board.add('Checked');
+ board.submit(id);
+ for (const [bad, named] of [['the catalog test failed', '"the catalog test failed"'], ['cause:G1', '"cause:G1"'], ['', 'an empty key']]) {
+ assert.throws(() => board.reject(id, bad), (error) => error.code === 'BAD_CAUSE' && error.message.startsWith(`[BAD_CAUSE] ${named} is not a cause key`)
+ && ['test:<file>::<title>', 'refusal:<CODE>', 'row:<id>', 'doctrine:<id>'].every((form) => error.message.includes(form)),
+ `${named} is refused by name, with the four forms`);
+ }
+ assert.equal(store.getItem(board.board, id).item_status, 'submitted', 'a refused reject leaves the item submitted');
+ board.reject(id, 'row:G1');
+ const rejected = store.events(board.board, { itemId: id }).at(-1);
+ assert.equal(JSON.parse(rejected.event_detail).cause, 'row:G1', 'the reject records its cause key');
+
+ // A sealed move that carries a cause needs the cause engine; an older envelope cannot carry it.
+ const second = board.add('Sealed');
+ board.submit(second);
+ const move = prepareEngineMove(board.board, 'verify', [second, { agentId: 'app-2', decision: 'REJECT', reason: 'TEST_FAILURE', note: 'red', cause: 'row:G1', head: store.getItem(board.board, second).item_commit, digest: 'digest:Sealed', policy: 'any' }]);
- assert.equal(move.engine, CAUSE_ENGINE);
++ assert.equal(CAUSE_ENGINE, 30, 'cause moves keep their stable minimum engine');
++ assert.equal(move.engine, ENGINE_VERSION, 'new envelopes declare the current engine independently of the feature minimum');
+ for (const older of [19, CAUSE_ENGINE - 1]) {
+ assert.throws(() => applyEngineMove(board.board, { ...move, engine: older }, { sequence: 1, at: new Date().toISOString() }),
+ (error) => error.code === 'RELAY_MOVE', `an engine-${older} move cannot carry a cause key`);
+ assert.equal(store.getItem(board.board, second).item_status, 'submitted', `the engine-${older} refusal changes nothing`);
+ }
+ board.close();
+
+ // The coordinator's reopen records --cause through the CLI.
+ const reopenItem = json(box, 'add', 'coordinator', 'Reopen with a cause', '--criterion', 'Reopen records its cause.', '--check', 'true').item;
+ // The private person's acceptance permits this intentionally pre-green fixture check.
+ json(box, 'check', 'accept', String(reopenItem.item_id));
+ json(box, 'claim', String(reopenItem.item_id));
+ json(box, 'submit', String(reopenItem.item_id));
+ refused(box.run('reopen', String(reopenItem.item_id), '--note', 'wrong bar', '--cause', 'wrong bar', '--json'), 'BAD_CAUSE', 'a reopen refuses a malformed cause');
+ json(box, 'reopen', String(reopenItem.item_id), '--note', 'the bar cites the wrong row', '--cause', 'row:G1');
+ const reopened = json(box, 'log', String(reopenItem.item_id)).events.at(-1);
+ assert.equal(reopened.event_kind, 'reopen');
+ assert.equal(JSON.parse(reopened.event_detail).cause, 'row:G1', 'the reopen records its cause key');
+
+ // Only the person marks never-again; the coordinator alone, or without a cause, is refused.
+ refused(box.run('fact', String(id), 'root-cause', 'never again', '--cause', 'row:G1', '--never-again', '--json'), 'RIGOR_PERSON_ONLY', 'the coordinator alone cannot mark never-again');
+ const agentShell = runFixtureChild(process.execPath, [BIN, 'fact', String(id), 'root-cause', 'never again', '--cause', 'row:G1', '--never-again', '--as', 'person', '--json'],
+ { cwd: box.repo, env: { ...box.env, CLAUDECODE: '1' }, encoding: 'utf8' });
+ refused(agentShell, 'B26_PERSON_CHANNEL', 'an agent shell cannot act as the person');
+ refused(box.run('fact', String(id), 'root-cause', 'never again', '--never-again', '--as', 'person', '--json'), 'BAD_CAUSE', 'a never-again names its cause');
+ const logged = json(box, 'log').events.length;
+ const report = json(box, 'rigor');
+ assert.deepEqual(report.causes.map((cause) => cause.key), ['row:G1'], 'row:G1 on two items repeats');
+ assert.equal(report.causes[0].reads, 'product');
+ assert.equal(json(box, 'log').events.length, logged, 'rigor is read-only: it records no move');
+ });
+
+ test('reject, reopen and fact moves without a cause replay unchanged from engines 11 and 12 [D1,H16]', async (t) => {
+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-rigor-replay-'));
+ DIRS.push(directory);
+ const fixed = { now: () => new Date('2026-10-16T12:00:00.000Z') };
+ /** Freeze with the captured verify policy that released verify replay requires. */
+ const freeze = (item) => ({
+ text: JSON.stringify({ criterion: item.item_title, policy: { version: 1, commit: 'a'.repeat(40), verify: { policy: 'any', family: 'off' } } }),
+ digest: `digest:${item.item_title}`,
+ });
+ const landed = { file: 'test/machine.test.js', name: 'the declaration matches the refusals [M1]' };
+ for (const [version, tag] of [[11, 'v0.8.27'], [12, 'v0.8.29']]) {
+ const source = join(directory, `client-${version}`);
+ mkdirSync(source);
+ unpackRelease(tag, source);
+ const legacyStore = await import(pathToFileURL(join(source, 'src/board.js')).href);
+ const legacyEngine = await import(pathToFileURL(join(source, 'src/engine.js')).href);
+ const legacyMachine = await import(pathToFileURL(join(source, 'src/machine.js')).href);
+ assert.equal(legacyMachine.ENGINE_VERSION, version, 'the archived executable has the claimed engine');
+ const old = legacyStore.openBoard(join(directory, `old-${version}.sqlite`), fixed);
+ const current = store.openBoard(join(directory, `current-${version}.sqlite`), fixed);
+ t.after(() => { legacyStore.closeBoard(old); store.closeBoard(current); });
+ for (const [replica, module] of [[old, legacyStore], [current, store]]) {
+ module.register(replica, { lane: 'coordinator', path: '/fixture/main' });
+ module.register(replica, { lane: 'app', path: '/fixture/app-1', model: 'Builder model' });
+ module.register(replica, { lane: 'app', path: '/fixture/app-2', model: 'Reviewer model' });
+ }
+ const first = '1'.repeat(40);
+ const second = '2'.repeat(40);
+ const journal = [
+ ['addItem', [{ by: 'coordinator', lane: 'app', title: 'Replayed' }]],
+ ['claim', [1, { agentId: 'app-1', lane: 'app', leaseMs: 2 * HOUR, freeze }]],
+ ['submit', [1, { agentId: 'app-1', commit: first, tree: 'tree-1' }]],
+ ['verify', [1, { agentId: 'app-2', decision: 'REJECT', reason: 'TEST_FAILURE', note: `${landed.file}: ${landed.name}`, head: first, digest: 'digest:Replayed', policy: 'any' }]],
+ ['claim', [1, { agentId: 'app-1', lane: 'app', leaseMs: 2 * HOUR, freeze }]],
+ ['submit', [1, { agentId: 'app-1', commit: second, tree: 'tree-2' }]],
+ ['verify', [1, { agentId: 'app-2', decision: 'ACCEPT', note: 'broke the fix; its test failed; restored it', head: second, digest: 'digest:Replayed', policy: 'any' }]],
+ ['reopen', [1, { agentId: 'coordinator', note: `${landed.file}: ${landed.name}; merge commit ${MERGE}` }]],
+ ['appendFact', [1, { agentId: 'coordinator', kind: 'root-cause', text: 'the refusal was never declared' }]],
+ ];
+ journal.forEach(([operation, args], index) => {
+ const move = legacyEngine.prepareEngineMove(old, operation, args, { id: `engine-${version}-rigor-${index}` });
+ assert.equal(move.engine, version);
+ const receipt = { sequence: index + 1, at: `2026-10-16T12:00:0${index}.000Z` };
+ const oldOutcome = legacyEngine.applyEngineMove(old, move, receipt);
+ assert.equal(oldOutcome.error, undefined, `released engine-${version} ${operation} applies: ${JSON.stringify(oldOutcome)}`);
+ assert.deepEqual(applyEngineMove(current, move, receipt), oldOutcome, `engine-${version} ${operation} replays identically`);
+ });
+ assert.deepEqual(store.events(current), legacyStore.events(old), `engine-${version} reject, reopen and fact events replay with no cause field`);
+ assert.ok(store.events(current).every((event) => !Object.hasOwn(JSON.parse(event.event_detail), 'cause')));
+ const report = rigorReport(store.events(current), { person: store.PERSON });
+ assert.deepEqual(report, { causes: [], uncaused: 1 }, 'the old reject has no key, and one landing failure on one commit is no repeat');
+ const caused = prepareEngineMove(current, 'appendFact', [1, { agentId: 'coordinator', kind: 'root-cause', text: 'never again', cause: 'refusal:UNDECLARED', neverAgain: true, asPerson: true, channel: 'terminal' }]);
+ assert.throws(() => legacyEngine.applyEngineMove(old, caused, { sequence: journal.length + 1, at: '2026-10-16T12:01:00.000Z' }),
+ (error) => error.code === 'ENGINE_VERSION', `the engine-${version} client refuses a cause move before interpreting it`);
+ }
+ });
diff --cc test/team-engine.test.js
index be6e232a,00000000..104b1245
mode 100644,000000..100644
--- a/test/team-engine.test.js
+++ b/test/team-engine.test.js
@@@ -1,244 -1,0 +1,260 @@@
+/** Sealed re-reviews bind the original work without changing released receipts [E8,H16,V8]. */
+import assert from 'node:assert/strict';
+import { mkdtempSync, mkdirSync, rmSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { pathToFileURL } from 'node:url';
+import { test } from 'node:test';
+import * as store from '../src/board.js';
+import { exportBoard, importBoard } from '../src/exchange.js';
+import { applyEngineMove, appliedSequence, engineReceipt, prepareEngineMove } from '../src/engine.js';
+import { VERDICT_REVIEW_ENGINE } from '../src/machine.js';
+import { unpackRelease } from './release-archive.js';
+
+const BASE = 'a'.repeat(40);
+const COMMIT = 'b'.repeat(40);
+const TRUNK = 'c'.repeat(40);
+const DIGEST = 'd'.repeat(64);
+const AT = '2026-10-16T00:00:00.000Z';
+
+/** Build a submitted, registered board entirely through public engine/store operations. */
+function submitted(t) {
+ const board = store.openBoard(':memory:', { now: () => new Date(AT) });
+ t.after(() => store.closeBoard(board));
+ store.register(board, { lane: 'coordinator', path: '/fixture' });
+ store.register(board, { lane: 'web', path: '/fixture/web-1' });
+ store.register(board, { lane: 'web', path: '/fixture/web-2' });
+ const id = store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Sealed review fixture' });
+ store.claim(board, id, { agentId: 'web-1', lane: 'web', leaseMs: 3_600_000, head: BASE,
+ freeze: () => ({ text: JSON.stringify({ rows: [], policy: { version: 1, commit: BASE, verify: { policy: 'any', family: 'off' } } }), digest: DIGEST }) });
+ store.submit(board, id, { agentId: 'web-1', commit: COMMIT, tree: TRUNK, files: ['web/feature.js'], policyCommit: BASE });
+ return board;
+}
+
+/** Produce one independent replica through the public board exchange format. */
+function replica(t, seed) {
+ const board = store.openBoard(':memory:');
+ t.after(() => store.closeBoard(board));
+ importBoard(board, exportBoard(seed));
+ return board;
+}
+
+/** The normal verifier's typed arguments, with optional new review metadata. */
+function verdict(review) {
+ return { agentId: 'web-2', decision: 'ACCEPT', note: 'The verifier checked the original work with the known trunk.',
+ head: COMMIT, digest: DIGEST, policy: 'any', familyPolicy: 'off', check: 'green',
+ ...(review === undefined ? {} : { review }) };
+}
+
+/** A writer-version marker is intentionally newer; all historical semantic rows must still match. */
+function withoutWriterMarker(document) {
+ const copy = structuredClone(document);
+ copy.tables.board_meta = copy.tables.board_meta.filter(row => row.meta_key !== 'relay_engine_version');
+ return copy;
+}
+
+test('engine 12 acceptance receipts stay exact and sealed re-review needs a newer engine [E8,H16,V8]', async t => {
+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-review-engines-'));
+ 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, 'this is the actual released executable, not a retagged new engine');
+ const seed = submitted(t);
+ const one = replica(t, seed);
+ const two = replica(t, seed);
+ 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: 'old-engine12-accept' });
+ const repeated = oldEngine.prepareEngineMove(old, 'verify', [1, verdict()], { id: 'old-engine12-repeated-accept' });
+ for (const [index, move] of [accept, repeated].entries()) {
+ const order = { sequence: index + 1, at: `2026-10-16T00:00:0${index + 1}.000Z` };
+ const original = oldEngine.applyEngineMove(old, move, order);
+ assert.equal(original.error?.code, index === 0 ? undefined : 'NOT_SUBMITTED');
+ for (const board of [one, two]) {
+ assert.deepEqual(applyEngineMove(board, move, order), original);
+ assert.deepEqual(engineReceipt(board, move.id), oldEngine.engineReceipt(old, move.id));
+ assert.deepEqual(withoutWriterMarker(exportBoard(board)), withoutWriterMarker(oldExchange.exportBoard(old)));
+ }
+ }
+ const originalVerdicts = store.verdictsFor(one, 1);
+ 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, 25, 'the feature replays at its introduction version even after a later writer upgrade');
++ assert.equal(reReview.engine, 33, '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' });
+ assert.deepEqual(oldExchange.exportBoard(old), oldBefore, 'an actual old client refuses the future envelope before changing its prefix');
+ const before = exportBoard(one);
+ assert.throws(() => applyEngineMove(one, { ...reReview, engine: 12 }, { sequence: 3, at: AT }), { code: 'RELAY_MOVE' });
+ assert.deepEqual(exportBoard(one), before, 'new metadata cannot acquire old-engine meaning by changing the tag');
+ const order = { sequence: 3, at: '2026-10-16T00:00:03.000Z' };
+ assert.deepEqual(applyEngineMove(one, reReview, order), applyEngineMove(two, reReview, order));
+ assert.equal(appliedSequence(one), 3);
+ assert.equal(store.verdictsFor(one, 1).length, 2);
+ assert.deepEqual(store.verdictsFor(one, 1).slice(0, 1), originalVerdicts, 'the old proof remains byte-for-byte unchanged');
+ assert.deepEqual(exportBoard(one), exportBoard(two));
+});
+
++test('a rejection carrying both cause and checked review keeps the newer review minimum [E8,H16,D1]', t => {
++ const board = submitted(t);
++ const move = prepareEngineMove(board, 'verify', [1, {
++ ...verdict({ commit: COMMIT, head: COMMIT, trunk: TRUNK, paths: ['web/feature.js'] }),
++ decision: 'REJECT', reason: 'TEST_FAILURE', note: 'the checked feature failed', cause: 'row:G1',
++ }], { id: 'cause-and-checked-review' });
++ const before = exportBoard(board);
++ assert.throws(() => applyEngineMove(board, { ...move, engine: 30 }, { sequence: 1, at: AT }), { code: 'RELAY_MOVE' });
++ assert.deepEqual(exportBoard(board), before, 'a cause key cannot downgrade checked-review metadata or advance the prefix');
++ const result = applyEngineMove(board, move, { sequence: 1, at: AT });
++ assert.equal(result.error, undefined);
++ const event = store.events(board, { itemId: 1 }).findLast(event => event.event_kind === 'reject');
++ assert.equal(JSON.parse(event.event_detail).cause, 'row:G1');
++ assert.deepEqual(JSON.parse(event.event_detail).review, move.args[1].review);
++});
++
+test('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, 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'] },
+ { ...valid, unexpected: true }];
+ for (const [index, review] of invalid.entries()) {
+ const move = prepareEngineMove(one, 'verify', [1, verdict(review)], { id: `invalid-review-${index}` });
+ const order = { sequence: index + 1, at: AT };
+ const first = applyEngineMove(one, move, order);
+ assert.equal(first.error?.code, 'BAD_VERDICT_REVIEW', JSON.stringify(first));
+ assert.deepEqual(first, applyEngineMove(two, move, order));
+ assert.deepEqual(store.verdictsFor(one, 1), []);
+ assert.equal(store.getItem(one, 1).item_status, 'submitted');
+ assert.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);
+});
+
+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));
+});