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(core): withdraw an accept before landing [V2,V6,H16]
Corey Olsonf4c7136d7077
diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex 7d339ae3..943ff79c 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -61,7 +61,7 @@ Each move checks its guards in this order and refuses with the first one that do| reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or SESSION_LEDGER), roadmapReadable (MILESTONES_CORRUPT), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) || accept | submitted, verified | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or SESSION_LEDGER), 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 or VERIFIER_STANDING or SELF_SESSION_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 SLOT_DB_LOCKED or TIMING_SLOT_REQUIRED or CHECK_UNVERIFIED or GUARD_CANNOT_FAIL or GUARD_NOT_FOUND), proofNoted (PROOF_REQUIRED), result (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION) || reject | submitted, verified | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or SESSION_LEDGER), 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 or VERIFIER_STANDING or SELF_SESSION_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 (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION), result (NOT_YOURS), result (CLOSED) |-| reopen | submitted, verified | open | coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED), trunkConflicts (NOT_CONFLICTING or CONFLICT_FILES or NO_TRUNK or MERGE_CHECK_FAILED), conflictAccepted (NOT_ACCEPTED or BAD_CONFLICT or ENGINE_VERSION), result (BAD_CONFIG) |+| reopen | submitted, verified | open | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reopenAuthority (COORDINATOR_ONLY or VERDICT_WITHDRAW_FORBIDDEN or VERDICT_WITHDRAW_STATE), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED), trunkConflicts (NOT_CONFLICTING or CONFLICT_FILES or NO_TRUNK or MERGE_CHECK_FAILED), conflictAccepted (NOT_ACCEPTED or BAD_CONFLICT or ENGINE_VERSION), result (BAD_VERDICT_WITHDRAW), result (ENGINE_VERSION), result (BAD_CONFIG) || escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED or SESSION_LEDGER), 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 or SESSION_LEDGER), 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 or AGENT_APPROVAL_REQUIRED) || refreeze | claimed | claimed | agent, coordinator, when a live claim has a pending coordinator correction | joined (NOT_JOINED or SESSION_LEDGER), 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 or AGENT_APPROVAL_REQUIRED) |@@ -92,6 +92,9 @@ Each move checks its guards in this order and refuses with the first one that do| NOT_JOINED | the caller is the main checkout, or a worktree that joined a lane; an agent session's claims, submits and verdicts can be checked against its local ledger | pullboard join <lane> --model "<model name>" (see: pullboard lanes) || SESSION_LEDGER | the caller is the main checkout, or a worktree that joined a lane; an agent session's claims, submits and verdicts can be checked against its local ledger | make the agent-session ledger named in the message readable and writable by this user, then run the command again || NO_ITEM | the item exists | pullboard list --all |+| COORDINATOR_ONLY | the coordinator reopens, a joined seat reports a submitted trunk conflict, or the exact accepting reviewer withdraws its verdict | ask the coordinator or the reviewer who recorded the accept |+| VERDICT_WITHDRAW_FORBIDDEN | the coordinator reopens, a joined seat reports a submitted trunk conflict, or the exact accepting reviewer withdraws its verdict | ask the accepting reviewer or coordinator to withdraw the verdict |+| VERDICT_WITHDRAW_STATE | the coordinator reopens, a joined seat reports a submitted trunk conflict, or the exact accepting reviewer withdraws its verdict | refresh the item; only a current acceptance before landing can be withdrawn || COORDINATOR_ONLY | the caller is the coordinator | run it from the main checkout || MILESTONES_CORRUPT | the roadmap is readable when selecting the next review, only next --verify selection; a review reserved by id does not consult the roadmap | restore board metadata from a known-good board export || MAIN_IS_COORDINATOR | in the main checkout, the caller says it is the coordinator | verify from your own worktree; the coordinator adds --as coordinator |@@ -194,6 +197,8 @@ Each move checks its guards in this order and refuses with the first one that do| ENGINE_VERSION | a verdict that implies items replays only under engine 20 or later (reject result) | upgrade Pullboard on every linked device before using --implies || NOT_YOURS | the automatic escalation is authorized as the coordinator or item holder (reject result) | ask the coordinator to inspect the item and its route || CLOSED | the rejected item remains open or claimed when automatic escalation starts (reject result) | pullboard show <id>, then ask the coordinator to inspect its current state |+| BAD_VERDICT_WITHDRAW | the explicit withdrawal flag is boolean and is not combined with a conflict (reopen result) | use --withdraw-verdict with --note only, or report a conflict separately |+| ENGINE_VERSION | the withdrawal move is replayed by an engine defining its meaning (reopen result) | update Pullboard before withdrawing a verdict || BAD_CONFIG | the configured first-refusal duration fits a valid UTC deadline (reopen result) | set claim.reopenFirstRefusalMinutes to a non-negative whole number within the supported date range, or 0 to disable || BAD_DECISION | a verdict is accept or reject | pullboard verify <id> accept, or reject --reason CODE --note "..." |diff --git a/src/api-moves.js b/src/api-moves.jsindex 18bc03e6..6e924741 100644--- a/src/api-moves.js+++ b/src/api-moves.js@@ -20,7 +20,7 @@ const MOVES = {merged: { item: true, positions: ['commit'] },withdraw: { item: true, positions: ['reason'] },refreeze: { item: true },- reopen: { item: true, flags: ['note', 'cause'], lists: ['conflict'] },+ reopen: { item: true, flags: ['note', 'cause'], lists: ['conflict'], booleans: ['withdraw-verdict'] },escalate: { item: true, flags: ['note'] },hold: { positions: ['lane'], flags: ['reason'], booleans: ['off'] },shout: { positions: ['to', 'text'], optional: ['to'], booleans: ['decision'], flags: ['evidence', 'outcome', 'item', 'commit'] },diff --git a/src/board-query.js b/src/board-query.jsindex e53f5b04..0d9464f0 100644--- a/src/board-query.js+++ b/src/board-query.js@@ -6,6 +6,7 @@ import {unreadShoutBindings,} from './shout-audience.js';/** Canonical board queries shared by reads and the synchronous write store [C7]. */+import { verdictWithdrawals } from './verdict-withdrawal.js';import { COORDINATOR } from './config.js';import { itemFiles } from './item-files.js';import { parseSpec } from './spec.js';@@ -225,9 +226,11 @@ export function events(board, { itemId } = {}) {/** Read every move and fact in append order, including superseded facts and full original text [B31,B32]. */export function itemThread(board, id) {itemById(board, id);+ const withdrawals = new Map([...verdictWithdrawals(board, id).values()].map(row => [row.acceptEventId, row]));return events(board, { itemId: id }).map((event) => event.event_kind === 'fact'? { type: 'fact', ...factFromEvent(event) }: { type: 'move', eventId: event.event_id, kind: event.event_kind, by: event.event_by,+ ...(withdrawals.has(event.event_id) ? { withdrawn: true, withdrawal: withdrawals.get(event.event_id) } : {}),at: event.event_at, detail: JSON.parse(event.event_detail) });}diff --git a/src/board.js b/src/board.jsindex 10ef0917..5b42811d 100644--- a/src/board.js+++ b/src/board.js@@ -5,6 +5,8 @@ import {readEventLogVersion,systemClock,} from './board-read-open.js';+import { VERDICT_WITHDRAW_ENGINE } from './verdict-withdraw-engine.js';+import { verdictWithdrawalTarget } from './verdict-withdrawal.js';import {BOARD_BUSY_TIMEOUT_MS,EVENT_LOG_VERSION,@@ -1446,16 +1448,20 @@ export function verify(board, id, { agentId, decision, reason, note = '', cause,** @param {any} board* @param {number} id- * @param {{ agentId: string, note: string, cause?: string }} request+ * @param {{ agentId: string, note: string, cause?: string, withdrawVerdict?: boolean }} request* @returns {{ id: number, commit: string, supersedes?: number, landingFailure?: object }}*/-export function reopen(board, id, { agentId, note = '', conflict, cause, reopenFirstRefusalMinutes }) {+export function reopen(board, id, { agentId, note = '', conflict, cause, reopenFirstRefusalMinutes, withdrawVerdict }) {return atomic(board, () => {let submittedCommit = null;const forMerge = conflict !== undefined && conflict !== null;let supersedes;- let landingFailure;+ let landingFailure, withdrawnVerdict;+ const forWithdrawal = withdrawVerdict === true;const currentEngine = board.executionEngineVersion ?? ENGINE_VERSION;+ if (withdrawVerdict !== undefined && typeof withdrawVerdict !== 'boolean') throw new Refused('BAD_VERDICT_WITHDRAW', 'withdrawVerdict must be a boolean; use --withdraw-verdict');+ if (forWithdrawal && currentEngine < VERDICT_WITHDRAW_ENGINE) throw new Refused('ENGINE_VERSION', 'update Pullboard before withdrawing a verdict');+ if (forWithdrawal && forMerge) throw new Refused('BAD_VERDICT_WITHDRAW', 'withdraw a verdict or report a trunk conflict, not both');const declaredTransition = MOVES.find((entry) => entry.verb === 'reopen');const transition = currentEngine >= 10 ? declaredTransition : { ...declaredTransition, from: ['submitted'] };const item = moveItem(board, id, 'reopen', {@@ -1464,14 +1470,18 @@ export function reopen(board, id, { agentId, note = '', conflict, cause, reopenFjoined: null,[IN_STATE]: (found) => new Refused('NOT_SUBMITTED', `item #${id} is ${current(board, found).item_status}, not submitted`),// Any joined seat returns a submitted head that no longer merges, with Git's files and trunk (#807).- coordinatorOnly: (found) => (forMerge && found.item_status === 'submitted' && currentEngine >= SUBMITTED_CONFLICT_ENGINE && listAgents(board).some((agent) => agent.agent_id === agentId)- ? null : onlyCoordinator(agentId, 'reopens submissions')),+ reopenAuthority: (found) => {+ if (forWithdrawal) { withdrawnVerdict = verdictWithdrawalTarget(board, found, agentId); return null; }+ return (forMerge && found.item_status === 'submitted' && currentEngine >= SUBMITTED_CONFLICT_ENGINE && listAgents(board).some((agent) => agent.agent_id === agentId)+ ? null : onlyCoordinator(agentId, 'reopens submissions'));+ },noteGiven: () => (forMerge || note.trim() ? null : new Refused('NOTE_REQUIRED', 'say why the criterion needs correction: --note "why"')),causeWellFormed: () => causeProblem(cause),notMerged: (found) => found.item_status !== 'verified' || !found.item_merged_commit? null: new Refused('ALREADY_MERGED', `item #${id} was merged as ${found.item_merged_commit}; merged items cannot be reopened`),landingFailureRecorded: (found) => {+ if (forWithdrawal) { supersedes = withdrawnVerdict.acceptEventId; return null; }if (found.item_status !== 'verified' || forMerge) return null;const accepted = events(board, { itemId: id }).findLast((event) => {if (event.event_kind !== 'accept') return false;@@ -1505,9 +1515,9 @@ export function reopen(board, id, { agentId, note = '', conflict, cause, reopenF};},});- const returnedAt = (forMerge || landingFailure) && currentEngine >= REOPEN_FIRST_REFUSAL_ENGINE && reopenFirstRefusalMinutes > 0 && item.item_built_by ? board.clock.now() : undefined;- const reservation = (forMerge || landingFailure) && currentEngine >= REOPEN_FIRST_REFUSAL_ENGINE ? firstRefusalDetail(board, item, reopenFirstRefusalMinutes, returnedAt) : {};- const returned = forMerge ? { supersedes, ...conflictDetail(conflict) } : supersedes ? { supersedes, landingFailure } : {};+ const returnedAt = (forMerge || landingFailure || forWithdrawal) && currentEngine >= REOPEN_FIRST_REFUSAL_ENGINE && reopenFirstRefusalMinutes > 0 && item.item_built_by ? board.clock.now() : undefined;+ const reservation = (forMerge || landingFailure || forWithdrawal) && currentEngine >= REOPEN_FIRST_REFUSAL_ENGINE ? firstRefusalDetail(board, item, reopenFirstRefusalMinutes, returnedAt) : {};+ const returned = forWithdrawal ? { supersedes, withdrawnVerdict } : forMerge ? { supersedes, ...conflictDetail(conflict) } : supersedes ? { supersedes, landingFailure } : {};logEvent(board, agentId, 'reopen', id, { commit: submittedCommit, note: note.trim() || conflictNote(conflict), judgment: null, ...reservation,...(cause !== undefined && cause !== null ? { cause } : {}), ...returned }, returnedAt);const trigger = board.lastEvent;diff --git a/src/cli-main.js b/src/cli-main.jsindex d9a3edf9..c417a7fd 100644--- a/src/cli-main.js+++ b/src/cli-main.js@@ -125,6 +125,7 @@ const OPTIONS = {ref: { type: 'string' },supersedes: { type: 'string' },conflict: { type: 'string', multiple: true },+ 'withdraw-verdict': { type: 'boolean' },cause: { type: 'string' },'never-again': { type: 'boolean' },'draft-splits': { type: 'boolean' },diff --git a/src/commands/reopen.js b/src/commands/reopen.jsindex 87d8e7b1..2094e8cd 100644--- a/src/commands/reopen.js+++ b/src/commands/reopen.js@@ -22,6 +22,7 @@ export async function run(io, { first, values }) {const act = (work) => actOn(io, work);return act(async (ctx, board, me) => {const result = await ordered(ctx, board, 'reopen', [idArg(first), { agentId: me.id, note: textArg(io, values, 'note') ?? '',+ ...(values['withdraw-verdict'] === undefined ? {} : { withdrawVerdict: values['withdraw-verdict'] }),...(values.cause !== undefined ? { cause: values.cause } : {}),...(values.conflict === undefined ? {} : { conflict: reopenConflict({ item: store.getItem(board, idArg(first)), coordinator: me.id === COORDINATOR, values: values.conflict, trunkMerge: (commit) => trunkMerge(ctx.info.root, commit) }) }) }]);io.result?.(result);diff --git a/src/engine.js b/src/engine.jsindex 42a75ca8..97727bd0 100644--- a/src/engine.js+++ b/src/engine.js@@ -1,5 +1,6 @@import { ITEM_SHOUT_ENGINE } from './item-shout-engine.js';/** Versioned, deterministic replay through the CLI's existing board engine [H3,H16]. */+import { VERDICT_WITHDRAW_ENGINE } from './verdict-withdraw-engine.js';import {createHash,randomUUID,@@ -94,6 +95,7 @@ const OPERATION_ENGINE = Object.freeze({ draftSpecRow: ROW_DRAFT_ENGINE, orderMi/** Dependency edits, causes, sealed reviews, submission proofs, trunk conflicts, health observations and milestone targets retain distinct recorded engine meanings. */function minimumOperationEngine(operation, args, board, at) {+ if (operation === 'reopen' && args[1]?.withdrawVerdict === true) return VERDICT_WITHDRAW_ENGINE;if (operation === 'recordPublishFinding') return PR_BRIDGE_ENGINE;if (operation === 'recordLandingTestDefect' || operation === 'verify' && args[1]?.environment !== undefined|| operation === 'recordGateRun' && Object.hasOwn(args[0]?.receipt ?? {}, 'environment')diff --git a/src/help.js b/src/help.jsindex 5b099785..6b015e05 100644--- a/src/help.js+++ b/src/help.js@@ -160,7 +160,8 @@ Coordinatorpullboard merged <id> <commit> record where verified work landedpullboard withdraw <id> <reason> drop an item nobody should buildpullboard refreeze <id> adopt a corrected criterion or changed spec rows- pullboard reopen <id> --note "why" [--cause <key>] return a submission for criterion correction without a verdict+ pullboard reopen <id> [--withdraw-verdict] --note "why" [--cause <key>]+ withdraw your own accept before landing, or coordinator-return a submissionpullboard reopen <id> --conflict <file> [--conflict <file>]return accepted work that conflicts with the trunk for a main mergepullboard hold <lane> --reason "..." pause a lane: next there claims nothing and names the reasondiff --git a/src/machine.js b/src/machine.jsindex 16101613..66772a6e 100644--- a/src/machine.js+++ b/src/machine.js@@ -98,6 +98,7 @@ export const GUARDS = [{ id: IN_STATE, refuse: '', rule: "the move can start from the item's current state", next: 'pullboard show <id>', source: 'board' },{ id: 'joined', refuse: 'NOT_JOINED', alsoRefuses: [{ code: 'SESSION_LEDGER', next: 'make the agent-session ledger named in the message readable and writable by this user, then run the command again' }], rule: 'the caller is the main checkout, or a worktree that joined a lane; an agent session\'s claims, submits and verdicts can be checked against its local ledger', next: 'pullboard join <lane> --model "<model name>" (see: pullboard lanes)', source: 'cli' },{ id: 'itemExists', refuse: 'NO_ITEM', rule: 'the item exists', next: 'pullboard list --all', source: 'board' },+ { id: 'reopenAuthority', refuse: 'COORDINATOR_ONLY', rule: 'the coordinator reopens, a joined seat reports a submitted trunk conflict, or the exact accepting reviewer withdraws its verdict', next: 'ask the coordinator or the reviewer who recorded the accept', source: 'board', alsoRefuses: [{ code: 'VERDICT_WITHDRAW_FORBIDDEN', next: 'ask the accepting reviewer or coordinator to withdraw the verdict' }, { code: 'VERDICT_WITHDRAW_STATE', next: 'refresh the item; only a current acceptance before landing can be withdrawn' }] },{ id: 'coordinatorOnly', refuse: 'COORDINATOR_ONLY', rule: 'the caller is the coordinator', next: 'run it from the main checkout', source: 'board' },{ id: 'roadmapReadable', refuse: 'MILESTONES_CORRUPT', rule: 'the roadmap is readable when selecting the next review', next: 'restore board metadata from a known-good board export', source: 'board', when: 'only next --verify selection; a review reserved by id does not consult the roadmap' },{ id: 'coordinatorSaysAs', refuse: 'MAIN_IS_COORDINATOR', rule: 'in the main checkout, the caller says it is the coordinator', next: 'verify from your own worktree; the coordinator adds --as coordinator', source: 'cli' },@@ -188,11 +189,11 @@ export const MOVES = [command: 'pullboard verify <id> reject --reason CODE --note "..."',},{- verb: 'reopen', from: ['submitted', 'verified'], to: 'open', by: ['coordinator'], refuse: 'NOT_SUBMITTED',- guards: ['joined', 'itemExists', IN_STATE, 'coordinatorOnly', 'noteGiven', 'causeWellFormed', 'notMerged', 'landingFailureRecorded', 'trunkConflicts', 'conflictAccepted'],- alsoRefuses: [{ code: 'BAD_CONFIG', rule: 'the configured first-refusal duration fits a valid UTC deadline', next: 'set claim.reopenFirstRefusalMinutes to a non-negative whole number within the supported date range, or 0 to disable' }],+ verb: 'reopen', from: ['submitted', 'verified'], to: 'open', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',+ guards: ['joined', 'itemExists', IN_STATE, 'reopenAuthority', 'noteGiven', 'causeWellFormed', 'notMerged', 'landingFailureRecorded', 'trunkConflicts', 'conflictAccepted'],+ alsoRefuses: [{ code: 'BAD_VERDICT_WITHDRAW', rule: 'the explicit withdrawal flag is boolean and is not combined with a conflict', next: 'use --withdraw-verdict with --note only, or report a conflict separately' }, { code: 'ENGINE_VERSION', rule: 'the withdrawal move is replayed by an engine defining its meaning', next: 'update Pullboard before withdrawing a verdict' }, { code: 'BAD_CONFIG', rule: 'the configured first-refusal duration fits a valid UTC deadline', next: 'set claim.reopenFirstRefusalMinutes to a non-negative whole number within the supported date range, or 0 to disable' }],sets: ['item_verdict', 'item_verified_by', 'item_owner', 'item_lease_until', 'item_review_by', 'item_review_until'],- command: 'pullboard reopen <id> --note "why" | --conflict <file> [--conflict <file>]',+ command: 'pullboard reopen <id> [--withdraw-verdict] --note "why" | --conflict <file> [--conflict <file>]',},{verb: 'escalate', from: ['open', 'claimed'], to: 'open', by: ['agent', 'coordinator'], refuse: 'CLOSED',diff --git a/src/next-step-words.js b/src/next-step-words.jsindex 28a65a86..e0c2b9e8 100644--- a/src/next-step-words.js+++ b/src/next-step-words.js@@ -56,6 +56,9 @@ export function personRequestGuidance(message, { caller, leading = false } = {})/** @type {Readonly<Record<string, string>>} */export const NEXT_STEPS = Object.freeze({+ BAD_VERDICT_WITHDRAW: 'use --withdraw-verdict with a note, or report a conflict separately',+ VERDICT_WITHDRAW_FORBIDDEN: 'ask the accepting reviewer or coordinator to withdraw this verdict',+ VERDICT_WITHDRAW_STATE: 'refresh the item; withdraw only a current acceptance before landing',PUBLISH_GITHUB: 'inspect gh auth status and the configured GitHub remote, then publish again',PUBLISH_STATE: 'preserve publish-pr.json and ask the coordinator to recover its recorded PR identities',PUBLISH_UNPROVEN: 'restore the item’s acceptance at its exact submitted commit before publishing',diff --git a/src/trunk-conflict.js b/src/trunk-conflict.jsindex 163ccf05..a48a207a 100644--- a/src/trunk-conflict.js+++ b/src/trunk-conflict.js@@ -199,6 +199,7 @@ export function mainMergesFor(board, items) {* @returns {string}*/export function reopenedLine(id, result) {+ if (result.withdrawnVerdict) return `reopened #${id} after verdict withdrawal; the earlier accept stays in history marked withdrawn`;if (result.conflict) return `reopened #${id} for a main merge: conflicts with the trunk at ${result.conflict.trunk.slice(0, 12)} in ${shownPaths(result.conflict.files)}; the accept at ${result.commit.slice(0, 12)} stays recorded`;return result.landingFailure? `reopened #${id} after landing failure; previous accept remains recorded at ${result.commit.slice(0, 12)}`diff --git a/src/verdict-reviews.js b/src/verdict-reviews.jsindex 5c9d1137..12915ff6 100644--- a/src/verdict-reviews.js+++ b/src/verdict-reviews.js@@ -1,4 +1,5 @@/** Sealed review validation and immutable acceptance projections [E8,H16]. */+import { verdictWithdrawals } from './verdict-withdrawal.js';import { Refused } from './refused.js';/** Validate a sealed review without consulting Git or changing either replica [E8,H16]. */@@ -25,10 +26,11 @@ export function verdictReviewProblem(review, commit, { checked } = {}) {export function verdictsFor(board, id) {const verdicts = board.db.prepare('SELECT * FROM verdict WHERE item_id = ? ORDER BY verdict_id').all(id);const receipts = board.db.prepare("SELECT event_kind, event_detail FROM event WHERE item_id = ? AND event_kind IN ('accept', 'reject') ORDER BY event_id").all(id);+ const withdrawals = verdictWithdrawals(board, id);return verdicts.map((verdict, index) => {let detail = {};try { detail = JSON.parse(receipts[index]?.event_detail ?? '{}'); } catch { /* Malformed legacy details remain unknown. */ }- return { ...verdict, assurance: verdictAssurance(board, verdict), check: detail.check ?? 'unknown', ...(detail.review ? { review: detail.review } : {}),+ return { ...verdict, ...(withdrawals.has(verdict.verdict_id) ? { withdrawn: true, withdrawal: withdrawals.get(verdict.verdict_id) } : {}), assurance: verdictAssurance(board, verdict), check: detail.check ?? 'unknown', ...(detail.review ? { review: detail.review } : {}),...(Object.hasOwn(detail, 'environment') ? { environment: detail.environment } : {}) };});}@@ -36,7 +38,7 @@ export function verdictsFor(board, id) {/** The latest matching acceptance; the submission stays immutable through later re-reviews. */export function acceptedVerdict(board, item) {return verdictsFor(board, item.item_id).findLast(verdict =>- verdict.verdict_decision === 'ACCEPT' && verdict.verdict_commit === item.item_commit);+ verdict.verdict_decision === 'ACCEPT' && !verdict.withdrawn && verdict.verdict_commit === item.item_commit);}/** The exact checked composition for a new acceptance, or the historical submitted candidate. */diff --git a/src/verdict-withdraw-engine.js b/src/verdict-withdraw-engine.jsnew file mode 100644index 00000000..68fc8d18--- /dev/null+++ b/src/verdict-withdraw-engine.js@@ -0,0 +1,4 @@+/** Explicit verdict withdrawal has a distinct ordered meaning; older reopens retain their meaning [V2,V6]. */+import { unassignedEngine } from './engine-next.js';++export const VERDICT_WITHDRAW_ENGINE = unassignedEngine();diff --git a/src/verdict-withdrawal.js b/src/verdict-withdrawal.jsnew file mode 100644index 00000000..067afbd5--- /dev/null+++ b/src/verdict-withdrawal.js@@ -0,0 +1,39 @@+/** Append-only withdrawal bindings and derived review-history annotations [V2,V6,H16]. */+import { Refused } from './refused.js';++/** Pair immutable verdict rows with their corresponding immutable acceptance/rejection events. */+function verdictPairs(board, id) {+ const verdicts = board.db.prepare('SELECT * FROM verdict WHERE item_id = ? ORDER BY verdict_id').all(id);+ const events = board.db.prepare("SELECT * FROM event WHERE item_id = ? AND event_kind IN ('accept', 'reject') ORDER BY event_id").all(id);+ return verdicts.map((verdict, index) => ({ verdict, event: events[index] }));+}++/** Only a later reopen naming both exact immutable identities marks an acceptance withdrawn. */+export function verdictWithdrawals(board, id) {+ const pairs = verdictPairs(board, id), result = new Map();+ for (const row of board.db.prepare("SELECT * FROM event WHERE item_id = ? AND event_kind = 'reopen' ORDER BY event_id").all(id)) {+ const detail = JSON.parse(row.event_detail), binding = detail.withdrawnVerdict;+ if (!binding) continue;+ const pair = pairs.find(({ verdict, event }) => verdict.verdict_id === binding.verdictId+ && verdict.verdict_decision === 'ACCEPT' && event?.event_id === binding.acceptEventId+ && event.event_kind === 'accept' && event.event_id < row.event_id+ && verdict.verdict_commit === detail.commit);+ if (!pair) continue;+ result.set(pair.verdict.verdict_id, { eventId: row.event_id, acceptEventId: pair.event.event_id,+ at: row.event_at, by: row.event_by, note: detail.note });+ }+ return result;+}++/** Bind the latest current acceptance and authorize only its own reviewer or the coordinator. */+export function verdictWithdrawalTarget(board, item, agentId) {+ if (item.item_status !== 'verified') throw new Refused('VERDICT_WITHDRAW_STATE', 'withdraw an accepted, unmerged item; use ordinary reopen for a submitted item');+ const withdrawn = verdictWithdrawals(board, item.item_id);+ const pair = verdictPairs(board, item.item_id).findLast(({ verdict, event }) => verdict.verdict_decision === 'ACCEPT'+ && verdict.verdict_commit === item.item_commit && event?.event_kind === 'accept' && !withdrawn.has(verdict.verdict_id));+ if (!pair) throw new Refused('VERDICT_WITHDRAW_STATE', 'this item has no current acceptance to withdraw; refresh its recorded history');+ if (agentId !== 'coordinator' && agentId !== pair.verdict.verdict_by) {+ throw new Refused('VERDICT_WITHDRAW_FORBIDDEN', 'only the accepting reviewer or coordinator can withdraw this verdict; ask that reviewer or the coordinator');+ }+ return { verdictId: pair.verdict.verdict_id, acceptEventId: pair.event.event_id };+}diff --git a/test/verdict-withdraw-engine.test.js b/test/verdict-withdraw-engine.test.jsnew file mode 100644index 00000000..76945798--- /dev/null+++ b/test/verdict-withdraw-engine.test.js@@ -0,0 +1,69 @@+/** Ordered withdrawal preserves old reopen meanings and binds immutable review identities [V2,V6,H16]. */+import assert from 'node:assert/strict';+import { mkdtempSync, rmSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { after, 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 { moveArgs } from '../src/api-moves.js';+import { VERDICT_WITHDRAW_ENGINE } from '../src/verdict-withdraw-engine.js';+import { createE2eHelpers } from './e2e-helpers.js';++const e2e = createE2eHelpers();+after(e2e.cleanup);++/** Obtain an accepted snapshot through actual joined Git checkouts and native submission/review. */+function acceptedSnapshot() {+ const box = e2e.project();+ assert.equal(box.run(box.repo, 'add', 'web', 'Withdrawal engine fixture', '--specs', 'G1', '--criterion', 'The page renders.').code, 0);+ assert.equal(box.run(box.web, 'claim', '1').code, 0);+ assert.equal(e2e.commitFile(box, box.web, 'web/page.html', '<h1>Page</h1>', 'feat(web): page [G1]').status, 0);+ assert.equal(box.run(box.web, 'submit', '1').code, 0);+ const reviewer = join(box.dir, 'reviewer');+ box.git(box.repo, 'worktree', 'add', '-q', reviewer, '-b', 'api/reviewer');+ assert.equal(box.run(reviewer, 'join', 'api').code, 0);+ assert.equal(box.run(reviewer, 'next', '--verify', '1').code, 0);+ box.git(reviewer, 'switch', '-q', '--detach', box.git(box.web, 'rev-parse', 'HEAD'));+ const accepted = box.run(reviewer, 'verify', '1', 'accept', '--note', 'native private check passed', '--json');+ assert.equal(accepted.code, 0, accepted.err + accepted.out);+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));+ try { return exportBoard(board); } finally { store.closeBoard(board); }+}++test('withdrawal true is engine-fenced while false retains historical reopen meaning [V2,V6,H16]', t => {+ const snapshot = acceptedSnapshot(), directory = mkdtempSync(join(tmpdir(), 'pullboard-withdraw-engine-'));+ const boards = ['false', 'old-true', 'current'].map(name => {+ const board = store.openBoard(join(directory, name + '.sqlite'));+ importBoard(board, snapshot);+ return board;+ });+ t.after(() => { for (const board of boards) store.closeBoard(board); rmSync(directory, { recursive: true, force: true }); });+ const receipt = { sequence: 1, at: new Date().toISOString(), kind: 'move',+ sender: { kind: 'agent', userId: 'fixture-user', agent: 'coordinator' } };+ const ordinary = prepareEngineMove(boards[0], 'reopen', [1, { agentId: 'coordinator', note: 'ordinary correction', withdrawVerdict: false }],+ { id: 'legacy-false', actor: 'coordinator' });+ const oldResult = applyRelayMove(boards[0], { ...ordinary, engine: VERDICT_WITHDRAW_ENGINE - 1 }, receipt);+ assert.equal(oldResult.error.code, 'LANDING_FAILURE_REQUIRED');+ assert.equal(store.getItem(boards[0], 1).item_status, 'verified');+ assert.equal(store.verdictsFor(boards[0], 1)[0].withdrawn, undefined);+ const withdraw = prepareEngineMove(boards[1], 'reopen', [1, { agentId: 'coordinator', note: 'recorded ruling missed', withdrawVerdict: true }],+ { id: 'withdraw-current', actor: 'coordinator' });+ const before = exportBoard(boards[1]);+ assert.throws(() => applyRelayMove(boards[1], { ...withdraw, engine: VERDICT_WITHDRAW_ENGINE - 1 }, receipt), error => error.code === 'ENGINE_VERSION');+ assert.deepEqual(exportBoard(boards[1]), before, 'an impossible older tag refuses before any row or cursor changes');+ const current = applyRelayMove(boards[2], withdraw, receipt);+ assert.equal(current.error, undefined, JSON.stringify(current));+ assert.equal(store.getItem(boards[2], 1).item_status, 'open');+ assert.equal(store.verdictsFor(boards[2], 1)[0].withdrawn, true);+ const after = exportBoard(boards[2]);+ applyRelayMove(boards[2], withdraw, receipt);+ assert.deepEqual(exportBoard(boards[2]), after, 'a duplicate ordered withdrawal does not add another event');+});++test('the API carries withdrawal as a boolean without changing note boundaries [A2,H16]', () => {+ assert.deepEqual(moveArgs({ verb: 'reopen', item: 7, args: { 'withdraw-verdict': true, note: 'a note --conflict literal' } }),+ ['reopen', '7', '--note=a note --conflict literal', '--withdraw-verdict', '--json', '--']);+ assert.throws(() => moveArgs({ verb: 'reopen', item: 7, args: { 'withdraw-verdict': 'true', note: 'why' } }), /BAD_REQUEST/u);+});