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): adopt pending corrections in a live claim [V2,H16]
Corey Olson3f761f3068cb
diff --git a/docs/api.md b/docs/api.mdindex a4e65299..d5557015 100644--- a/docs/api.md+++ b/docs/api.md@@ -232,6 +232,8 @@ Only the coordinator runs `spec apply`. It preflights every pending row againstTo approve new wording, the person uses `spec approve <one-id> --text "exact proposed text"`, or `spec-approve` with `args: {ids: "G1", text: "exact proposed text"}`. This records the same exact-row receipt; files wait for coordinator apply. Text must be one nonempty line without a field separator. Pre-commit checks the staged row against that person decision or a verified staged SSH sign-off; unstaged receipts cannot authorize a commit.+A coordinator criterion or check correction on a live claim remains pending until its holder or the coordinator runs `pullboard refreeze <id>`. Renewal and submission refuse with `PENDING_REFREEZE` until then. This refreeze keeps the holder, lease and claim base, and returns `retainedClaim: true` in JSON.+Doctor and resume report every stale frozen item after cited text changes. Open, claimed and submitted items suggest coordinator refreeze. Verified and merged items keep their receipts, report that they shipped against the old text, and suggest adding a follow-up citing the changed row. Resume JSON includes these findings in `stale`.The SQLite schema marker is now `PRAGMA user_version = 2`. Opening an older board upgrades it in place: `board_meta` stores the id as `meta_key = "board_id"` and a 32-character hexadecimal `meta_value`; `shout_request` and `shout_request_outcome` mark requests and their answers. Existing items, agents and events remain intact. The HTTP envelope stays at version 1 independently of the SQLite schema marker.diff --git a/docs/formats.md b/docs/formats.mdindex c0d572ff..dc10a3de 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -79,7 +79,7 @@ The board file is in the repository's Git common directory at `.git/pullboard/bo| `move engine` | `8` | `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. 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.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.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, includingdiff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex dbc7d92f..bc61a65d 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -27,6 +27,7 @@ stateDiagram-v2open --> open: refreezeclaimed --> open: refreezesubmitted --> open: refreeze+ claimed --> claimed: refreezeopen --> withdrawn: withdrawclaimed --> withdrawn: withdrawsubmitted --> withdrawn: withdraw@@ -50,16 +51,17 @@ Each move checks its guards in this order and refuses with the first one that do| Move | From | To | Who | Guards, in order || --- | --- | --- | --- | --- |-| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), laneOpen (LANE_HELD), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG) |+| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), correctionRefrozen (PENDING_REFREEZE), laneOpen (LANE_HELD), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG) || release | claimed | open | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), reviewReleaseExplained (NOTE_REQUIRED) || 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), 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), gateConfigured (NO_GATE), gateGreen (GATE_RED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |+| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), 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), gateConfigured (NO_GATE), 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), 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) || 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 | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG) |+| 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) |+| 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) || withdraw | open, claimed, submitted | withdrawn | coordinator | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), inState (CLOSED) |## Exit guards@@ -82,6 +84,7 @@ Each move checks its guards in this order and refuses with the first one that do| NOT_SUBMITTED | reopen: the item is in submitted | 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> || CLOSED | withdraw: the item is in open, claimed, submitted | pullboard show <id> || NOT_JOINED | the caller is the main checkout, or a worktree that joined a lane | pullboard join <lane> --model "<model name>" (see: pullboard lanes) || NO_ITEM | the item exists | pullboard list --all |@@ -96,6 +99,7 @@ Each move checks its guards in this order and refuses with the first one that do| HELD | no other agent holds it under a live lease | pullboard next || LANE_HELD | nobody holds its lane, unless the caller is renewing its own live claim | pullboard next --wait 9 (minutes) || ITEM_HELD | the coordinator has not put this item on hold, unless the caller is renewing its own live claim | the coordinator lifts it with pullboard hold <id> --off |+| PENDING_REFREEZE | no coordinator correction to a claimed criterion or check is waiting to be frozen | pullboard refreeze <id> || ONE_CLAIM | the caller holds no other live top-level claim, reworks of its own rejected items aside | submit or release the other item first; child items are free || UNKNOWN_SPEC | every row the item cites exists and is in force, only where the criterion freezes: claiming an item with no frozen criterion, and refreeze | fix the spec, or the coordinator withdraws the item || A5_GRAMMAR_VERSION | every row the item cites exists and is in force, only where the criterion freezes: claiming an item with no frozen criterion, and refreeze | upgrade Pullboard or use a file written for grammar 1 |diff --git a/src/board.js b/src/board.jsindex 94128826..128f2e7a 100644--- a/src/board.js+++ b/src/board.js@@ -647,11 +647,9 @@ export function validateItemAddition(board, { by, lane, title, criterion = '', p}/**- * Change an item's brief, route, criterion or check (B10, B13, B14). The brief says how to build it- * and may change until the item is verified or withdrawn. The route, the criterion and the check- * change only while nobody holds the item; changing the criterion or the check drops the frozen- * bar, so the next claim freezes the new one, in the log for anyone to see. The coordinator or the- * agent that added the item may edit it.+ * Change an item's brief, route, criterion or check (B10, B13, B14). The coordinator may make a+ * claimed criterion/check correction at engine 8; the live holder must refreeze before renewal or+ * submission, and keeps the claim while adopting the new frozen bar.** @param {any} board* @param {number} id@@ -663,7 +661,13 @@ export function editItem(board, id, { agentId, brief, route, criterion, check, cconst expiredHolder = stored.item_status === 'claimed' && !isHeld(board, stored) ? stored.item_owner : null;const { item, next, command, unfreeze } = validateItemEdit(board, id, { agentId, brief, route, criterion, check });const baseline = normalizeCheckBaseline(agentId, command, checkBaseline);- const clearFrozen = unfreeze || Boolean(expiredHolder);+ const pendingFields = [+ ...(next.item_criterion !== item.item_criterion ? ['criterion'] : []),+ ...(command !== undefined && next.item_check !== item.item_check ? ['check'] : []),+ ];+ const pendingRefreeze = (board.executionEngineVersion ?? ENGINE_VERSION) >= 8+ && item.item_status === 'claimed' && agentId === COORDINATOR && pendingFields.length > 0;+ const clearFrozen = (unfreeze && !pendingRefreeze) || Boolean(expiredHolder);if (expiredHolder) {moveItem(board, id, 'lapse', { checks: {}, set: () => ({ item_owner: null, item_lease_until: null }) });}@@ -675,19 +679,32 @@ export function editItem(board, id, { agentId, brief, route, criterion, check, c...(next.item_criterion !== item.item_criterion ? { criterion: next.item_criterion } : {}),...(command !== undefined ? { check: next.item_check } : {}),...(baseline ? { checkBaseline: baseline } : {}),+ ...(pendingRefreeze ? { pendingRefreeze: pendingFields } : {}),...(clearFrozen && item.item_frozen_digest ? { unfrozen: item.item_frozen_digest } : {}),...(expiredHolder ? { expiredHolder } : {}),});+ if (pendingRefreeze) {+ insertShout(board, {+ from: COORDINATOR,+ to: item.item_owner,+ text: `The coordinator has a pending ${pendingFields.join(' and ')} correction for #${id}; refreeze it before renewing or submitting.\nnext: pullboard refreeze ${id}`,+ lanes: [],+ });+ }});}/** Validate an edit without side effects, so a refused change never starts a shell baseline. */export function validateItemEdit(board, id, { agentId, brief, route, criterion, check }) {+ let item = (board.executionEngineVersion ?? ENGINE_VERSION) >= 8 ? current(board, itemById(board, id)) : null;+ if (item?.item_status === 'claimed' && agentId !== COORDINATOR) {+ throw new Refused('HELD', `item #${id} is claimed; only the coordinator may edit it while held; shout coordinator`);+ }const command = coordinatorCheck(agentId, check);if ([brief, route, criterion, check].every((value) => value === undefined)) {throw new Refused('USAGE', 'say what changes: --brief "...", --brief-file <file>, --route light|mid|strong, --criterion "..." or --check "<command>"');}- const item = current(board, itemById(board, id));+ item ??= current(board, itemById(board, id));if (agentId !== COORDINATOR && agentId !== item.item_created_by) {throw new Refused('NOT_YOURS', `only the coordinator or ${item.item_created_by}, who added #${id}, edits it; shout them instead`);}@@ -702,7 +719,11 @@ export function validateItemEdit(board, id, { agentId, brief, route, criterion,};checkRoute(next.item_route);const moved = ['item_route', 'item_criterion', 'item_check'].filter((key) => next[key] !== item[key]);- if (moved.length && item.item_status !== 'open') {+ const routeChanged = next.item_route !== item.item_route;+ const correctionWhileClaimed = (board.executionEngineVersion ?? ENGINE_VERSION) >= 8+ && item.item_status === 'claimed' && agentId === COORDINATOR+ && (next.item_criterion !== item.item_criterion || next.item_check !== item.item_check);+ if (moved.length && item.item_status !== 'open' && (routeChanged || !correctionWhileClaimed)) {throw new Refused('HELD', `item #${id} is ${item.item_status}; change its route, criterion or check only while it is open`);}checkRouted({ brief: next.item_brief, route: next.item_route, criterion: next.item_criterion, check: next.item_check });@@ -820,11 +841,11 @@ function declaredCodes(move, id) {* @param {any} board* @param {number} id* @param {string} verb- * @param {{ checks: Record<string, ((item: any) => Refused | null) | null>, set?: (item: any) => object, before?: (item: any) => void }} how+ * @param {{ checks: Record<string, ((item: any) => Refused | null) | null>, set?: (item: any) => object, before?: (item: any) => void, transition?: object }} how* @returns {any} The item as it was before the move.*/-function moveItem(board, id, verb, { checks, set = () => ({}), before = () => {} }) {- const move = MOVES.find((entry) => entry.verb === verb);+function moveItem(board, id, verb, { checks, set = () => ({}), before = () => {}, transition = null }) {+ const move = transition ?? MOVES.find((entry) => entry.verb === verb);if (!move) throw new Refused(UNKNOWN_MOVE.refuse, `${UNKNOWN_MOVE.rule}: ${UNKNOWN_MOVE.next}`);let item = null;for (const guard of effectiveGuards(move)) {@@ -965,6 +986,7 @@ export function claim(board, id, { agentId, lane, leaseMs, freeze, head = null,return null;},notHeldByAnother: (found) => (isHeld(board, found) && found.item_owner !== agentId ? new Refused('HELD', `item #${id} is held by ${found.item_owner} until ${found.item_lease_until}`) : null),+ correctionRefrozen: () => pendingRefreezeProblem(board, id),laneOpen: (found) => {// Declared: not checked when the caller renews its own live claim.const paused = laneHold(board, found.item_lane);@@ -1074,6 +1096,7 @@ export function submit(board, id, { agentId, commit, tree, files = [], policyComjoined: null,[IN_STATE]: notYours,isHolder: (found) => (found.item_owner === agentId ? null : notYours()),+ correctionRefrozen: () => pendingRefreezeProblem(board, id),criterionUnchanged: null,treeClean: null,nothingUntracked: null,@@ -1451,22 +1474,33 @@ export function withdraw(board, id, { agentId, reason }) {}/**- * Freeze an item's criterion again after its spec rows changed, and reopen it, so the next claim- * builds against the text a verdict will check (V3). Explicit and logged: the bar moves only in- * the open.+ * Freeze the current criterion and rows again (V2,V3). A pending coordinator correction is+ * adopted within its live claim, keeping the holder, lease and base; other refreezes reopen the+ * item so its next claim builds against the bar a verdict will check.** @param {any} board* @param {number} id* @param {{ agentId: string, freeze: (item: any) => { text: string, digest: string } }} who- * @returns {{ before: string | null, after: string }}+ * @returns {{ before: string | null, after: string, retainedClaim?: true }}*/export function refreeze(board, id, { agentId, freeze }) {return atomic(board, () => {let frozen = null;+ const currentItem = board.db.prepare('SELECT * FROM item WHERE item_id=?').get(id);+ const pending = currentItem ? pendingRefreeze(board, id) : [];+ const retainsClaim = (board.executionEngineVersion ?? ENGINE_VERSION) >= 8+ && currentItem?.item_status === 'claimed' && isHeld(board, currentItem) && pending.length > 0;+ const transition = MOVES.find((move) => move.verb === 'refreeze' && move.to === (retainsClaim ? 'claimed' : 'open'));const item = moveItem(board, id, 'refreeze', {checks: {joined: null,coordinatorOnly: () => onlyCoordinator(agentId, 'refreezes a criterion'),+ holderOrCoordinator: (found) => {+ const live = current(board, found);+ return live.item_owner === agentId || agentId === COORDINATOR+ ? null+ : new Refused('NOT_YOURS', `item #${id} is not claimed by you; only its holder or the coordinator refreezes it`);+ },[IN_STATE]: (found) => new Refused('CLOSED', `item #${id} is ${found.item_status}`),rowsInForce: (found) => {try {@@ -1478,13 +1512,39 @@ export function refreeze(board, id, { agentId, freeze }) {}},},- set: () => ({ item_frozen: frozen.text, item_frozen_digest: frozen.digest, item_owner: null, item_lease_until: null }),+ set: () => ({+ item_frozen: frozen.text,+ item_frozen_digest: frozen.digest,+ ...(!retainsClaim ? { item_owner: null, item_lease_until: null } : {}),+ }),+ transition,});- logEvent(board, agentId, 'refreeze', id, { before: item.item_frozen_digest, after: frozen.digest });- return { before: item.item_frozen_digest, after: frozen.digest };+ logEvent(board, agentId, 'refreeze', id, { before: item.item_frozen_digest, after: frozen.digest, ...(retainsClaim ? { retainedClaim: true } : {}) });+ return { before: item.item_frozen_digest, after: frozen.digest, ...(retainsClaim ? { retainedClaim: true } : {}) };});}+/** Return a pending coordinator correction until a later refreeze event adopts it [V2]. */+export function pendingRefreeze(board, id) {+ const lastRefreeze = board.db.prepare("SELECT COALESCE(MAX(event_id), 0) AS event_id FROM event WHERE item_id = ? AND event_kind = 'refreeze'").get(id).event_id;+ const edits = board.db.prepare("SELECT event_detail FROM event WHERE item_id = ? AND event_kind = 'edit' AND event_id > ? ORDER BY event_id DESC").all(id, lastRefreeze);+ const fields = new Set();+ for (const edit of edits) {+ const details = JSON.parse(edit.event_detail);+ for (const field of details.pendingRefreeze ?? []) if (['criterion', 'check'].includes(field)) fields.add(field);+ }+ return [...fields].sort();+}++/** Refuse a stale claim action with the exact coordinator repair command [V2]. */+export function pendingRefreezeProblem(board, id) {+ if ((board.executionEngineVersion ?? ENGINE_VERSION) < 8) return null;+ const fields = pendingRefreeze(board, id);+ return fields.length+ ? new Refused('PENDING_REFREEZE', `item #${id} has a pending ${fields.join(' and ')} correction; refreeze it before renewing or submitting.\nnext: pullboard refreeze ${id}`)+ : null;+}+/*** Items, newest first, as a reader should see them. Closed items (verified, withdrawn) only when* asked.diff --git a/src/cli.js b/src/cli.jsindex af79f611..70bb5e2a 100644--- a/src/cli.js+++ b/src/cli.js@@ -1586,6 +1586,8 @@ async function submitHere(ctx, id) {const me = whoAmI(ctx, board);const item = store.getItem(board, id);if (item.item_status !== 'claimed' || item.item_owner !== me.id) throw new Refused('NOT_YOURS', 'claim this item before submitting it');+ const correction = store.pendingRefreezeProblem(board, id);+ if (correction) throw correction;return item;});const policy = itemPolicy(root, held);@@ -2206,7 +2208,7 @@ function workCommands(io, args) {refreeze: () => act(async (ctx, board, me) => {const result = await ordered(ctx, board, 'refreeze', [idArg(first), { agentId: me.id, freeze: freezer(ctx, { captureVerifyPolicy: true }) }]);io.result?.({ id: idArg(first), ...result });- io.say(`#${first} refrozen ${String(result.before).slice(0, 12)} -> ${result.after.slice(0, 12)}; open again`);+ io.say(`#${first} refrozen ${String(result.before).slice(0, 12)} -> ${result.after.slice(0, 12)}; ${result.retainedClaim ? 'claim retained' : 'open again'}`);return 0;}),reopen: () => act(async (ctx, board, me) => {diff --git a/src/help.js b/src/help.jsindex 8ffec3fc..1fa7c666 100644--- a/src/help.js+++ b/src/help.js@@ -94,7 +94,7 @@ Coordinatorfile one item per file a linter, type checker or test reporter flagspullboard merged <id> <commit> record where verified work landedpullboard withdraw <id> <reason> drop an item nobody should build- pullboard refreeze <id> re-freeze a criterion after its spec rows changed+ pullboard refreeze <id> adopt a corrected criterion or changed spec rowspullboard reopen <id> --note "why" return a submission for criterion correction without a verdictpullboard hold <lane> --reason "..." pause a lane: next there claims nothing and names the reasonpullboard hold <id> "reason" hold one item so next skips itdiff --git a/src/machine.js b/src/machine.jsindex e3e18235..0fa01be3 100644--- a/src/machine.js+++ b/src/machine.js@@ -109,6 +109,7 @@ export const GUARDS = [{ id: 'notHeldByAnother', refuse: 'HELD', rule: 'no other agent holds it under a live lease', next: 'pullboard next', source: 'board' },{ id: 'laneOpen', refuse: 'LANE_HELD', rule: 'nobody holds its lane', next: 'pullboard next --wait 9 (minutes)', source: 'board', when: 'unless the caller is renewing its own live claim' },{ id: 'itemNotHeld', refuse: 'ITEM_HELD', rule: 'the coordinator has not put this item on hold', next: 'the coordinator lifts it with pullboard hold <id> --off', source: 'board', when: 'unless the caller is renewing its own live claim' },+ { id: 'correctionRefrozen', refuse: 'PENDING_REFREEZE', rule: 'no coordinator correction to a claimed criterion or check is waiting to be frozen', next: 'pullboard refreeze <id>', source: 'board' },{ id: 'oneLiveClaim', refuse: 'ONE_CLAIM', rule: 'the caller holds no other live top-level claim, reworks of its own rejected items aside', next: 'submit or release the other item first; child items are free', source: 'board' },{ id: 'rowsInForce', refuse: 'UNKNOWN_SPEC', alsoRefuses: [{ code: 'A5_GRAMMAR_VERSION', next: 'upgrade Pullboard or use a file written for grammar 1' }, { code: 'NO_POLICY', next: 'restore the committed coordinator policy' }, { code: 'BAD_CONFIG', next: 'repair and commit the coordinator configuration' }], rule: 'every row the item cites exists and is in force', next: 'fix the spec, or the coordinator withdraws the item', source: 'board', when: 'only where the criterion freezes: claiming an item with no frozen criterion, and refreeze' },{ id: 'criterionUnchanged', refuse: 'CRITERIA_CHANGED', rule: 'the criterion and the rows it cites read as they did at claim', next: 'the coordinator runs pullboard refreeze <id>', source: 'cli' },@@ -142,7 +143,7 @@ export const GUARDS = [export const MOVES = [{verb: 'claim', from: ['open', 'claimed'], to: 'claimed', by: ['agent', 'coordinator'], refuse: 'NOT_CLAIMABLE',- guards: ['joined', 'itemExists', IN_STATE, 'itemNotHeld', 'inLane', 'routeAllows', 'dependenciesVerified', 'notHeldByAnother', 'laneOpen', 'oneLiveClaim', 'rowsInForce'],+ guards: ['joined', 'itemExists', IN_STATE, 'itemNotHeld', 'inLane', 'routeAllows', 'dependenciesVerified', 'notHeldByAnother', 'correctionRefrozen', 'laneOpen', 'oneLiveClaim', 'rowsInForce'],sets: ['item_owner', 'item_lease_until', 'item_frozen_digest'], command: 'pullboard claim <id>',},{@@ -152,7 +153,7 @@ export const MOVES = [{ verb: 'lapse', from: ['claimed'], to: 'open', by: ['clock'], guards: [], when: 'its lease runs out' },{verb: 'submit', from: ['claimed'], to: 'submitted', by: ['agent', 'coordinator'], refuse: 'NOT_YOURS',- guards: ['joined', 'itemExists', IN_STATE, 'isHolder', 'criterionUnchanged', 'treeClean', 'nothingUntracked', 'hasCommit', 'withinLane', 'trunkMergeClean', 'noUnverifiedStack', 'gateConfigured', 'gateGreen', 'treeStillDuringGate', 'childrenDone', 'headIsNew'],+ guards: ['joined', 'itemExists', IN_STATE, 'isHolder', 'correctionRefrozen', 'criterionUnchanged', 'treeClean', 'nothingUntracked', 'hasCommit', 'withinLane', 'trunkMergeClean', 'noUnverifiedStack', 'gateConfigured', 'gateGreen', 'treeStillDuringGate', 'childrenDone', 'headIsNew'],sets: ['item_built_by', 'item_commit'], command: 'pullboard submit <id>',},{@@ -183,8 +184,15 @@ export const MOVES = [{verb: 'refreeze', from: ['open', 'claimed', 'submitted'], to: 'open', by: ['coordinator'], refuse: 'CLOSED',guards: ['joined', 'coordinatorOnly', 'itemExists', IN_STATE, 'rowsInForce'],+ when: 'there is no live claim awaiting a coordinator correction',sets: ['item_frozen_digest'], command: 'pullboard refreeze <id>',},+ {+ verb: 'refreeze', from: ['claimed'], to: 'claimed', by: ['agent', 'coordinator'], refuse: 'CLOSED',+ guards: ['joined', 'itemExists', 'holderOrCoordinator', IN_STATE, 'rowsInForce'],+ when: 'a live claim has a pending coordinator correction',+ sets: ['item_frozen', 'item_frozen_digest'], command: 'pullboard refreeze <id>',+ },{verb: 'withdraw', from: ['open', 'claimed', 'submitted'], to: 'withdrawn', by: ['coordinator'], refuse: 'CLOSED',guards: ['joined', 'coordinatorOnly', 'noteGiven', 'itemExists', IN_STATE],@@ -570,8 +578,10 @@ export function lifecycleMarkdown(machine = MACHINE) {export function lifecycleHelp(machine = MACHINE) {const lines = machine.roles.map((role) => {const moves = machine.moves.filter((move) => move.by.includes(role));- const when = moves.filter((move) => move.when).map((move) => `${move.verb} (when ${move.when})`);- const plain = moves.filter((move) => !move.when).map((move) => move.verb);+ const counts = new Map();+ for (const move of moves) counts.set(move.verb, (counts.get(move.verb) ?? 0) + 1);+ const when = moves.filter((move) => move.when && counts.get(move.verb) === 1).map((move) => `${move.verb} (when ${move.when})`);+ const plain = [...new Set(moves.filter((move) => !move.when || counts.get(move.verb) > 1).map((move) => move.verb))];return ` ${role.padEnd(13)} ${[...plain, ...when].join(', ')}`;});return ['Lifecycle, read from src/machine.js', ' pullboard lifecycle the states, moves, guards and refusals as a markdown page, with a diagram', ...lines].join('\n');diff --git a/test/board.test.js b/test/board.test.jsindex 60a95116..851406cd 100644--- a/test/board.test.js+++ b/test/board.test.js@@ -592,7 +592,7 @@ test('an item carries a brief; editing it changes how to build, never what [B10]store.editItem(board, id, { agentId: 'coordinator', brief: 'Copy how add prints; test it like add.' });assert.equal(store.getItem(board, id).item_brief, 'Copy how add prints; test it like add.');assert.equal(store.getItem(board, id).item_frozen_digest, digest);- assert.throws(() => store.editItem(board, id, { agentId: 'api-1', brief: 'mine now' }), /NOT_YOURS.*coordinator/);+ assert.throws(() => store.editItem(board, id, { agentId: 'api-1', brief: 'mine now' }), /HELD.*coordinator/);assert.throws(() => store.editItem(board, id, { agentId: 'coordinator' }), /USAGE/);assert.throws(() => store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Huge', brief: 'x'.repeat(8001) }), /BRIEF_TOO_LONG/);assert.deepEqual(JSON.parse(store.events(board, { itemId: id }).find((event) => event.event_kind === 'edit').event_detail), { brief: '38 characters', model: 'unknown' });@@ -646,7 +646,6 @@ test('below strong, an item is buildable cold: files, a test, a criterion and atest('changing a criterion or a check drops the frozen bar, in the open; the next claim freezes anew [B14]', () => {const id = store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Page' });claimAs(id, 'web-1', 'web');- assert.throws(() => store.editItem(board, id, { agentId: 'coordinator', check: 'npm test' }), /HELD/);store.release(board, id, 'web-1');store.editItem(board, id, { agentId: 'coordinator', check: 'npm test', criterion: 'renders' });assert.equal(store.getItem(board, id).item_frozen_digest, null);@@ -687,7 +686,7 @@ test('edit after an expired claim reopens it and names its holder [B13]', () =>});claimAs(live, 'web-1', 'web');const digest = store.itemById(board, live).item_frozen_digest;- assert.throws(() => store.editItem(board, live, { agentId: 'coordinator', criterion: 'not yet' }), /HELD/);+ assert.throws(() => store.editItem(board, live, { agentId: 'coordinator', route: 'mid' }), /HELD/);assert.deepEqual([store.itemById(board, live).item_status, store.itemById(board, live).item_owner, store.itemById(board, live).item_frozen_digest],['claimed', 'web-1', digest],diff --git a/test/machine.test.js b/test/machine.test.jsindex ae56075f..8b9d6ad3 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -364,7 +364,7 @@ test('the declared lifecycle is sound: reachable, no traps, no second door, everassert.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.moves.map((move) => move.verb), ['claim', 'release', 'lapse', 'submit', 'reserve', 'accept', 'reject', 'reopen', 'escalate', 'refreeze', 'withdraw']);+ assert.deepEqual(MACHINE.moves.map((move) => move.verb), ['claim', 'release', 'lapse', 'submit', 'reserve', 'accept', 'reject', 'reopen', 'escalate', 'refreeze', 'refreeze', 'withdraw']);});for (const broken of BROKEN) {@@ -773,7 +773,7 @@ test('pullboard help lists each role\'s moves from the declaration, and pullboarconst line = help.stdout.split('\n').find((text) => text.startsWith(` ${role} `));assert.ok(line, `help has a line for ${role}`);const listed = line.slice(role.length + 2).split(',').map((part) => part.trim().split(' ')[0]).filter(Boolean);- assert.deepEqual(listed.sort(), MACHINE.moves.filter((move) => move.by.includes(role)).map((move) => move.verb).sort(), `${role}'s moves`);+ assert.deepEqual(listed.sort(), [...new Set(MACHINE.moves.filter((move) => move.by.includes(role)).map((move) => move.verb))].sort(), `${role}'s moves`);}assert.ok(HELP.all.includes(lifecycleHelp()), 'the full help screen carries the generated section, not a typed copy');const printed = runFixtureChild(process.execPath, [BIN, 'lifecycle'], { encoding: 'utf8' });@@ -860,7 +860,10 @@ test('claim refuses in the declared order, one failure peeled at a time, on a refired.push(claimAs(target, light, 'api'), claimAs(target, light, 'web'), claimAs(target, strong, 'web'));verdictOn(board, dependency, 'web-2', 'ACCEPT');fired.push(claimAs(target, strong, 'web'));+ store.editItem(board, target, { agentId: 'coordinator', criterion: 'Pending correction before the lane guard.' });store.release(board, target, 'web-2');+ fired.push(claimAs(target, strong, 'web'));+ store.refreeze(board, target, { agentId: 'coordinator', freeze });store.editItem(board, target, { agentId: 'coordinator', criterion: 'A new bar, so the next claim freezes it.' });fired.push(claimAs(target, strong, 'web'));store.releaseLane(board, 'web', { agentId: 'coordinator' });@@ -868,7 +871,7 @@ test('claim refuses in the declared order, one failure peeled at a time, on a restore.release(board, spare, strong);fired.push(claimAs(target, strong, 'web'), claimAs(target, strong, 'web', freeze));assert.deepEqual(fired, [...declaredBoardOrder('claim'), 'ok']);- assert.deepEqual(fired, ['NO_ITEM', 'NOT_CLAIMABLE', 'ITEM_HELD', 'WRONG_LANE', 'ROUTE', 'BLOCKED', 'HELD', 'LANE_HELD', 'ONE_CLAIM', 'UNKNOWN_SPEC', 'ok']);+ assert.deepEqual(fired, ['NO_ITEM', 'NOT_CLAIMABLE', 'ITEM_HELD', 'WRONG_LANE', 'ROUTE', 'BLOCKED', 'HELD', 'PENDING_REFREEZE', 'LANE_HELD', 'ONE_CLAIM', 'UNKNOWN_SPEC', 'ok']);} finally {lab.done();}@@ -884,6 +887,10 @@ test('submit, accept and reject refuse in the declared order, one failure peeledconst submits = [submitAs(999, 'web-1', SHA_A), submitAs(piece, 'web-1', SHA_A)];store.claim(board, piece, { agentId: 'web-1', lane: 'web', leaseMs: 7_200_000, freeze });submits.push(submitAs(piece, 'web-2', SHA_A));+ store.editItem(board, piece, { agentId: 'coordinator', criterion: 'A correction before submission.' });+ submits.push(submitAs(piece, 'web-1', SHA_A));+ assert.equal(submits.at(-1), 'PENDING_REFREEZE', 'a pending correction stops the board submission before later guards');+ store.refreeze(board, piece, { agentId: 'web-1', freeze });store.submit(board, piece, { agentId: 'web-1', commit: SHA_A, tree: 'tree' });verdictOn(board, piece, 'web-2', 'REJECT');store.claim(board, piece, { agentId: 'web-1', lane: 'web', leaseMs: 7_200_000, freeze });@@ -1153,7 +1160,7 @@ test('the lifecycle page and the help show the reservation: reserve, and reviewFassert.match(page, /^\| reserve \| submitted \| submitted \| agent, coordinator \| .*reviewFree \(REVIEW_HELD\) \|$/m);for (const verb of ['accept', 'reject']) assert.match(page, new RegExp(`^\\| ${verb} \\| submitted \\| .*policyAllows \\(COORDINATOR_VERIFIES\\), familyAllows \\(O2_FAMILY_MATCH\\), reviewFree \\(REVIEW_HELD\\), criterionUnchanged`, 'm'));assert.match(page, /^\| REVIEW_HELD \| no other agent holds its review under a live lease \| pullboard next --verify/m);- assert.match(HELP.all, /^ {2}agent +claim, release, submit, reserve, accept, reject, escalate$/m);+ assert.match(HELP.all, /^ {2}agent +claim, release, submit, reserve, accept, reject, escalate, refreeze \(when a live claim has a pending coordinator correction\)$/m);assert.match(HELP.all, /pullboard next --verify +reserve the next submitted item you can check/);});diff --git a/test/pending-refreeze.test.js b/test/pending-refreeze.test.jsnew file mode 100644index 00000000..c5df6447--- /dev/null+++ b/test/pending-refreeze.test.js@@ -0,0 +1,225 @@+/** Pending coordinator corrections keep a live claim until its frozen bar is adopted [V2,H16]. */+import assert from 'node:assert/strict';+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { test } from 'node:test';+import * as store from '../src/board.js';+import { applyRelayMove, prepareEngineMove } from '../src/engine.js';+import { exportBoard, importBoard } from '../src/exchange.js';+import { createE2eHelpers } from './e2e-helpers.js';++const e2e = createE2eHelpers();++/** Parse one private CLI refusal and require its exact next-step suffix. */+function refusal(result, code, itemId, pendingFields) {+ assert.equal(result.code, 1, `${result.out}${result.err}`);+ const document = JSON.parse(result.out);+ assert.equal(document.error.code, code);+ if (code === 'PENDING_REFREEZE') {+ assert.ok(Array.isArray(pendingFields) && pendingFields.length > 0, 'pending refusals name their expected corrected fields');+ assert.ok(document.error.message.includes(`pending ${[...pendingFields].sort().join(' and ')} correction`), document.error.message);+ assert.ok(document.error.message.endsWith(`next: pullboard refreeze ${itemId}`), document.error.message);+ }+ return document.error;+}++test("the coordinator corrects a claimed item's criterion without release [V2]", (t) => {+ const box = e2e.project('true');+ t.after(e2e.cleanup);+ const board = store.openBoard(join(box.repo, '.git/pullboard/board.sqlite'));+ t.after(() => store.closeBoard(board));++ const added = box.run(box.repo, 'add', 'web', 'Correct a live bar', '--specs', 'G1', '--route', 'strong', '--criterion', 'the original criterion', '--check', 'true', '--json');+ assert.equal(added.code, 0, added.err || added.out);+ const id = JSON.parse(added.out).item.item_id;+ const claim = box.run(box.web, 'claim', String(id), '--json');+ assert.equal(claim.code, 0, claim.err || claim.out);+ const before = store.getItem(board, id);++ const routeEdit = box.run(box.repo, 'edit', String(id), '--route', 'mid', '--json');+ assert.match(refusal(routeEdit, 'HELD', id).message, /change its route, criterion or check only while it is open/u);+ assert.equal(store.getItem(board, id).item_route, before.item_route, 'a claimed route remains unchanged after refusal');+ const agentEdit = box.run(box.web, 'edit', String(id), '--criterion', 'an agent cannot change the frozen bar', '--json');+ assert.match(refusal(agentEdit, 'HELD', id).message, /only the coordinator may edit it while held/u);++ const corrected = box.run(box.repo, 'edit', String(id), '--criterion', 'the corrected criterion', '--check', 'true && true', '--json');+ assert.equal(corrected.code, 0, corrected.err || corrected.out);+ const pending = store.getItem(board, id);+ assert.equal(pending.item_criterion, 'the corrected criterion');+ assert.equal(pending.item_check, 'true && true');+ assert.equal(pending.item_frozen_digest, before.item_frozen_digest, 'the original frozen bar remains until refreeze');+ assert.equal(pending.item_owner, before.item_owner);+ assert.equal(pending.item_lease_until, before.item_lease_until);+ const notice = store.inbox(board, before.item_owner).find((entry) => entry.shout_text.includes(`pending criterion and check correction for #${id}`));+ assert.ok(notice, 'the holder receives the pending correction and refreeze command');+ assert.ok(notice.shout_text.endsWith(`next: pullboard refreeze ${id}`));++ refusal(box.run(box.web, 'claim', String(id), '--json'), 'PENDING_REFREEZE', id, ['criterion', 'check']);+ refusal(box.run(box.web, 'submit', String(id), '--json'), 'PENDING_REFREEZE', id, ['criterion', 'check']);+ assert.equal(store.getItem(board, id).item_claim_head, before.item_claim_head, 'neither refusal changes the claim base');++ const refrozen = box.run(box.web, 'refreeze', String(id), '--json');+ assert.equal(refrozen.code, 0, refrozen.err || refrozen.out);+ const result = JSON.parse(refrozen.out);+ assert.equal(result.retainedClaim, true);+ const adopted = store.getItem(board, id);+ assert.equal(adopted.item_status, 'claimed');+ assert.equal(adopted.item_owner, before.item_owner);+ assert.equal(adopted.item_lease_until, before.item_lease_until);+ assert.equal(adopted.item_claim_head, before.item_claim_head);+ assert.deepEqual(JSON.parse(adopted.item_frozen), {+ title: 'Correct a live bar',+ criterion: 'the corrected criterion',+ check: 'true && true',+ rows: [{ id: 'G1', text: 'The page renders.', gate: 'web test' }],+ policy: { version: 1, commit: JSON.parse(before.item_frozen).policy.commit, verify: { policy: 'any', family: 'off' } },+ });++ const page = join(box.web, 'web', 'page.js');+ mkdirSync(join(box.web, 'web'), { recursive: true });+ writeFileSync(page, 'export const corrected = true;\n');+ box.git(box.web, 'add', 'web/page.js');+ box.git(box.web, 'commit', '-q', '-m', 'feat(web): use corrected criterion [G1]');+ const submitted = box.run(box.web, 'submit', String(id), '--json');+ assert.equal(submitted.code, 0, submitted.err || submitted.out);+ const finalItem = store.getItem(board, id);+ assert.equal(finalItem.item_status, 'submitted');+ assert.equal(finalItem.item_check, 'true && true');+ assert.equal(JSON.parse(finalItem.item_frozen).criterion, 'the corrected criterion');+ assert.equal(finalItem.item_commit, box.git(box.web, 'rev-parse', 'HEAD'));++ const checkAdd = box.run(box.repo, 'add', 'web', 'Correct only a check', '--specs', 'G1', '--criterion', 'unchanged criterion', '--check', 'true', '--json');+ assert.equal(checkAdd.code, 0, checkAdd.err || checkAdd.out);+ const checkId = JSON.parse(checkAdd.out).item.item_id;+ const checkClaim = box.run(box.web, 'claim', String(checkId), '--json');+ assert.equal(checkClaim.code, 0, checkClaim.err || checkClaim.out);+ const checkBefore = store.getItem(board, checkId);+ const checkEdit = box.run(box.repo, 'edit', String(checkId), '--check', 'true && true', '--json');+ assert.equal(checkEdit.code, 0, checkEdit.err || checkEdit.out);+ const checkPending = store.getItem(board, checkId);+ assert.equal(checkPending.item_criterion, checkBefore.item_criterion);+ assert.equal(checkPending.item_check, 'true && true');+ assert.equal(checkPending.item_frozen_digest, checkBefore.item_frozen_digest);+ assert.equal(checkPending.item_owner, checkBefore.item_owner);+ assert.deepEqual(store.pendingRefreeze(board, checkId), ['check']);+ const checkNotice = store.inbox(board, checkBefore.item_owner).find((entry) => entry.shout_text.includes(`pending check correction for #${checkId}`));+ assert.ok(checkNotice, 'the holder is told that the check correction needs refreezing');+ assert.ok(checkNotice.shout_text.endsWith(`next: pullboard refreeze ${checkId}`));+ refusal(box.run(box.web, 'claim', String(checkId), '--json'), 'PENDING_REFREEZE', checkId, ['check']);+ refusal(box.run(box.web, 'submit', String(checkId), '--json'), 'PENDING_REFREEZE', checkId, ['check']);+ const checkRefreeze = box.run(box.web, 'refreeze', String(checkId), '--json');+ assert.equal(checkRefreeze.code, 0, checkRefreeze.err || checkRefreeze.out);+ assert.equal(JSON.parse(checkRefreeze.out).retainedClaim, true);+ assert.equal(store.getItem(board, checkId).item_owner, checkBefore.item_owner);+ assert.equal(store.getItem(board, checkId).item_status, 'claimed');+ assert.equal(store.pendingRefreeze(board, checkId).length, 0);++});++test('ordered refreeze corrections retain engine-7 history and engine-8 live claims [V2,H16]', (t) => {+ const replicaDirectory = mkdtempSync(join(tmpdir(), 'pullboard-refreeze-replicas-'));+ const replicaBoards = [];+ const legacyClock = '2026-10-10T12:00:00.000Z';+ const currentClock = '2026-10-10T13:00:00.000Z';+ /** Open and track one isolated file-backed replica with its deterministic clock. */+ const openBoardWithClock = (name, at) => {+ const board = store.openBoard(join(replicaDirectory, `${name}.sqlite`), { now: () => new Date(at) });+ replicaBoards.push(board);+ return board;+ };+ t.after(() => {+ for (const replica of replicaBoards) store.closeBoard(replica);+ rmSync(replicaDirectory, { recursive: true, force: true });+ });+ const legacy = openBoardWithClock('legacy', legacyClock);+ store.register(legacy, { lane: 'coordinator', path: '/legacy/coordinator' });+ store.register(legacy, { lane: 'web', path: '/legacy/web' });+ const legacyId = store.addItem(legacy, {+ by: 'web-1', lane: 'web', title: 'Legacy claim', route: 'strong', criterion: 'legacy criterion',+ brief: e2e.LIGHT_BRIEF,+ });+ const legacyReplica = openBoardWithClock('legacy-replica', legacyClock);+ importBoard(legacyReplica, exportBoard(legacy));+ const sender = { kind: 'agent', userId: 'fixture-user', agent: 'web-1' };+ const coordinatorSender = { kind: 'agent', userId: 'fixture-user', agent: 'coordinator' };+ /** Replay one move on both real board replicas and compare its receipt and event history. */+ const applyBoth = (move, sequence, moveSender = sender) => {+ const receipt = applyRelayMove(legacy, move, { sequence, at: `2026-10-10T12:00:0${sequence}.000Z`, sender: moveSender, kind: 'move' });+ assert.deepEqual(applyRelayMove(legacyReplica, move, { sequence, at: `2026-10-10T12:00:0${sequence}.000Z`, sender: moveSender, kind: 'move' }), receipt);+ assert.deepEqual(store.events(legacyReplica), store.events(legacy), 'replicas retain the same ordered event history');+ return receipt;+ };+ const legacyClaim = prepareEngineMove(legacy, 'claim', [legacyId, {+ agentId: 'web-1', lane: 'web', leaseMs: 60_000, head: 'a'.repeat(40),+ freeze: (item) => ({ text: item.item_criterion, digest: 'a'.repeat(64) }),+ }]);+ legacyClaim.engine = 7;+ applyBoth(legacyClaim, 1);+ const legacyBrief = `${e2e.LIGHT_BRIEF.trim()}\nExtra recovery evidence.\n`;+ const legacyEdit = prepareEngineMove(legacy, 'editItem', [legacyId, { agentId: 'web-1', brief: legacyBrief }]);+ legacyEdit.engine = 7;+ assert.equal(applyBoth(legacyEdit, 2).error, undefined, 'engine 7 still permits the creator brief edit');+ assert.equal(store.getItem(legacy, legacyId).item_brief, legacyBrief.trim(),+ 'engine 7 retains its historical creator edit of the brief while claimed');+ const legacyUnauthorized = prepareEngineMove(legacy, 'editItem', [legacyId, { agentId: 'other-agent', criterion: 'unauthorized' }]);+ legacyUnauthorized.engine = 7;+ assert.equal(applyBoth(legacyUnauthorized, 3, { kind: 'agent', userId: 'fixture-user', agent: 'other-agent' }).error.code, 'NOT_YOURS',+ 'engine 7 retains its prior refusal precedence for a non-owner');+ const legacyRefreezeMove = prepareEngineMove(legacy, 'refreeze', [legacyId, {+ agentId: 'coordinator', freeze: () => ({ text: 'legacy-frozen-again', digest: 'b'.repeat(64) }),+ }]);+ legacyRefreezeMove.engine = 7;+ const legacyRefreeze = applyBoth(legacyRefreezeMove, 4, coordinatorSender);+ assert.deepEqual(legacyRefreeze.result, { before: 'a'.repeat(64), after: 'b'.repeat(64) });+ assert.deepEqual(Object.keys(legacyRefreeze.result).sort(), ['after', 'before']);+ assert.equal(store.getItem(legacy, legacyId).item_status, 'open', 'engine 7 keeps the original release-on-refreeze behavior');+ const unknownLegacyRefreeze = structuredClone(legacyRefreezeMove);+ unknownLegacyRefreeze.id = 'legacy-unknown-refreeze';+ unknownLegacyRefreeze.args[0] = 999999;+ unknownLegacyRefreeze.args[1].agentId = 'web-1';+ assert.equal(applyBoth(unknownLegacyRefreeze, 5).error.code, 'COORDINATOR_ONLY',+ 'engine 7 checks coordinator authority before looking up an unknown refreeze item');++ const current = openBoardWithClock('current', currentClock);+ store.register(current, { lane: 'coordinator', path: '/current/coordinator' });+ store.register(current, { lane: 'web', path: '/current/web' });+ const currentId = store.addItem(current, {+ by: 'coordinator', lane: 'web', title: 'Current ordered correction', route: 'mid',+ criterion: 'original current criterion', brief: e2e.LIGHT_BRIEF, check: 'true',+ });+ const currentReplica = openBoardWithClock('current-replica', currentClock);+ importBoard(currentReplica, exportBoard(current));+ /** Replay one engine-8 move on both replicas and require identical ordered results. */+ const applyCurrentBoth = (move, sequence, moveSender) => {+ const at = `2026-10-10T13:00:0${sequence}.000Z`;+ const receipt = applyRelayMove(current, move, { sequence, at, sender: moveSender, kind: 'move' });+ assert.deepEqual(applyRelayMove(currentReplica, move, { sequence, at, sender: moveSender, kind: 'move' }), receipt);+ assert.deepEqual(store.events(currentReplica), store.events(current), 'both replicas agree after each current-engine move');+ return receipt;+ };+ const currentClaim = prepareEngineMove(current, 'claim', [currentId, {+ agentId: 'web-1', lane: 'web', leaseMs: 60_000, head: 'b'.repeat(40),+ freeze: (item) => ({ text: item.item_criterion, digest: 'c'.repeat(64) }),+ }]);+ applyCurrentBoth(currentClaim, 1, sender);+ const correction = prepareEngineMove(current, 'editItem', [currentId, {+ agentId: 'coordinator', criterion: 'corrected by an ordered coordinator move',+ }]);+ applyCurrentBoth(correction, 2, coordinatorSender);+ for (const replica of [current, currentReplica]) {+ assert.equal(store.getItem(replica, currentId).item_status, 'claimed');+ assert.equal(store.pendingRefreeze(replica, currentId).join(','), 'criterion');+ assert.equal(store.getItem(replica, currentId).item_frozen_digest, 'c'.repeat(64));+ }+ const currentRefreeze = prepareEngineMove(current, 'refreeze', [currentId, {+ agentId: 'web-1', freeze: () => ({ text: 'corrected by an ordered coordinator move', digest: 'd'.repeat(64) }),+ }]);+ const retained = applyCurrentBoth(currentRefreeze, 3, sender);+ assert.equal(retained.result.retainedClaim, true);+ for (const replica of [current, currentReplica]) {+ assert.equal(store.getItem(replica, currentId).item_status, 'claimed');+ assert.equal(store.pendingRefreeze(replica, currentId).length, 0);+ assert.equal(store.getItem(replica, currentId).item_frozen_digest, 'd'.repeat(64));+ }+});