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(review): reopen submissions without a verdict [V2,V6,H16]
Corey Olson5977de4143c8
diff --git a/docs/api.md b/docs/api.mdindex f547c4f0..d1f08993 100644--- a/docs/api.md+++ b/docs/api.md@@ -70,6 +70,7 @@ The board-state API's item projection includes `check` and, when recorded, `chec| `merged` | `version:number`, `id:number`, `commit:string` || `withdraw` | `version:number`, `id:number`, `reason:string` || `refreeze` | `version:number`, `id:number`, `after:string` |+| `reopen` | `version:number`, `id:number`, `commit:string` || `shout` | `version:number`, `id:number`, `decision:boolean` || `answer` | `version:number`, `id:number`, `answers:number` || `pass` | `version:number`, `id:number`, `answers:number` |@@ -203,7 +204,7 @@ The coordinator maintains the roadmap with `milestone add <name> [--note ...] [-| `stream` | `version:number`, `event:object` |<!-- api-http-shapes:end -->-A move body is `{verb, item, args, agent}`. `item` is the positive integer id when the move needs one. `args` names its CLI positional arguments and flags; text values stay literal, including leading dashes. Omit `agent` to act as the coordinator, or name a registered agent to run in its worktree. Coordinator verification takes `args.as: "coordinator"`, matching the CLI's explicit identity check. The local session secret may act as any agent on that board. `result` is the CLI's JSON result. `next` claims work atomically; when a claim is already held it renews it and returns the renewal event. With no work available it returns the CLI's `NOTHING_FREE` refusal. Waiting remains a CLI option.+A move body is `{verb, item, args, agent}`. `item` is the positive integer id when the move needs one. `args` names its CLI positional arguments and flags; text values stay literal, including leading dashes. Omit `agent` to act as the coordinator, or name a registered agent to run in its worktree. Coordinator verification takes `args.as: "coordinator"`, matching the CLI's explicit identity check. The local session secret may act as any agent on that board. `result` is the CLI's JSON result. `next` claims work atomically; when a claim is already held it renews it and returns the renewal event. With no work available it returns the CLI's `NOTHING_FREE` refusal. Waiting remains a CLI option. `reopen` is coordinator-only: `args.note` is required, and it returns a submitted item to open without adding a verdict or replacing its last submitted commit.Decision moves keep the CLI's routing: `shout` with `args.decision: true` may omit `args.to`; agents ask their coordinator, and the coordinator asks the person. `pass` takes the decision's id as `item` and `args.note`. Answering a decision addressed to the person requires `answer` with `args.as: "person"` from the coordinator's main checkout. Other callers receive the CLI's refusal.diff --git a/docs/formats.md b/docs/formats.mdindex cbd00789..cd542f03 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 and selects the next review in roadmap order; recorded engines 1 through 7 retain their original tier-first review selection. 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.+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. 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.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 73916873..f5267eb9 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -21,6 +21,7 @@ stateDiagram-v2submitted --> submitted: reservesubmitted --> verified: acceptsubmitted --> open: reject+ submitted --> open: reopenopen --> open: escalateclaimed --> open: escalateopen --> open: refreeze@@ -56,6 +57,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), 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) || withdraw | open, claimed, submitted | withdrawn | coordinator | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), inState (CLOSED) |@@ -77,6 +79,7 @@ Each move checks its guards in this order and refuses with the first one that do| NOT_SUBMITTED | reserve: the item is in submitted | pullboard show <id> || NOT_SUBMITTED | accept: the item is in submitted | pullboard show <id> || NOT_SUBMITTED | reject: the item is in submitted | pullboard show <id> |+| NOT_SUBMITTED | reopen: the item is in submitted | pullboard show <id> || CLOSED | escalate: the item is in open, claimed | pullboard show <id> || CLOSED | refreeze: the item is in open, claimed, submitted | pullboard show <id> || CLOSED | withdraw: the item is in open, claimed, submitted | pullboard show <id> |diff --git a/src/api-moves.js b/src/api-moves.jsindex f95efac3..afe4d787 100644--- a/src/api-moves.js+++ b/src/api-moves.js@@ -16,6 +16,7 @@ const MOVES = {merged: { item: true, positions: ['commit'] },withdraw: { item: true, positions: ['reason'] },refreeze: { item: true },+ reopen: { item: true, flags: ['note'] },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.js b/src/board.jsindex c3de3946..d75e496a 100644--- a/src/board.js+++ b/src/board.js@@ -1059,9 +1059,12 @@ export function submit(board, id, { agentId, commit, tree, files = [], policyCom.get(id);return total ? new Refused('CHILDREN_OPEN', `item #${id} has ${total} unfinished child items`) : null;},- headIsNew: () => {+ headIsNew: (found) => {const wasRejected = board.db.prepare("SELECT 1 FROM verdict WHERE item_id = ? AND verdict_decision = 'REJECT' AND verdict_commit = ?").get(id, commit);- return wasRejected ? new Refused('HEAD_NOT_NEW', `#${id} was rejected at ${commit.slice(0, 12)}; commit the rework first`) : null;+ const sameReopenedHead = found.item_verdict === null && found.item_commit === commit;+ return wasRejected || sameReopenedHead+ ? new Refused('HEAD_NOT_NEW', `#${id} already has a submission at ${commit.slice(0, 12)}; commit the rework first`)+ : null;},},set: (found) => ({@@ -1329,6 +1332,41 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,});}+/** Return a submission for criterion correction without recording a verifier's judgment [V2,V6].+ * The prior commit remains as the base the builder must change before resubmitting.+ *+ * @param {any} board+ * @param {number} id+ * @param {{ agentId: string, note: string }} request+ * @returns {{ id: number, commit: string }}+ */+export function reopen(board, id, { agentId, note }) {+ return atomic(board, () => {+ let submittedCommit = null;+ const item = moveItem(board, id, 'reopen', {+ checks: {+ joined: null,+ [IN_STATE]: (found) => new Refused('NOT_SUBMITTED', `item #${id} is ${current(board, found).item_status}, not submitted`),+ coordinatorOnly: () => onlyCoordinator(agentId, 'reopens submissions'),+ noteGiven: () => (note.trim() ? null : new Refused('NOTE_REQUIRED', 'say why the criterion needs correction: --note "why"')),+ },+ set: (found) => {+ submittedCommit = found.item_commit;+ return {+ item_verdict: null,+ item_verified_by: null,+ item_owner: null,+ item_lease_until: null,+ item_review_by: null,+ item_review_until: null,+ };+ },+ });+ logEvent(board, agentId, 'reopen', id, { commit: submittedCommit, note: note.trim(), judgment: null });+ return { id: item.item_id, commit: submittedCommit };+ });+}+/*** Refuse unless the acting agent is the coordinator.*diff --git a/src/cli.js b/src/cli.jsindex 5448d2e7..dedbb941 100644--- a/src/cli.js+++ b/src/cli.js@@ -485,7 +485,7 @@ async function bindCheckoutSession(io, positionals, values) {throw new Refused('USAGE', 'pullboard takeover takes no arguments; run pullboard takeover [--json]');}const writes = ['init', 'join', 'worktree', 'hooks', 'hook', 'add', 'edit', 'fact', 'escalate', 'run', 'sweep',- 'next', 'claim', 'hold', 'release', 'submit', 'done', 'verify', 'merged', 'withdraw', 'refreeze', 'shout', 'answer', 'pass', 'import', 'milestone', 'takeover', 'forget'];+ 'next', 'claim', 'hold', 'release', 'submit', 'done', 'verify', 'merged', 'withdraw', 'refreeze', 'reopen', 'shout', 'answer', 'pass', 'import', 'milestone', 'takeover', 'forget'];if (!writes.includes(command) && !(command === 'settings' && first) && !(command === 'spec' && first === 'apply') && !(command === 'relay' && ['on', 'off'].includes(first))) return;if (command === 'answer' && values.as === 'person') return;const digest = agentSessionDigest();@@ -2095,6 +2095,12 @@ function workCommands(io, args) {io.say(`#${first} refrozen ${String(result.before).slice(0, 12)} -> ${result.after.slice(0, 12)}; open again`);return 0;}),+ reopen: () => act(async (ctx, board, me) => {+ const result = await ordered(ctx, board, 'reopen', [idArg(first), { agentId: me.id, note: textArg(io, values, 'note') ?? '' }]);+ io.result?.(result);+ io.say(`reopened #${first} without a verdict; previous commit ${result.commit.slice(0, 12)} remains recorded`);+ return 0;+ }),shout: () => act(async (ctx, board, me) => {const evidence = values.evidence === undefined ? null : evidenceFrom(ctx, values);const recipients = ['all', 'person', ...laneNames(ctx.config), ...board.db.prepare('SELECT agent_id FROM agent').all().map((agent) => agent.agent_id)];diff --git a/src/engine.js b/src/engine.jsindex 87e52c24..c9d1cd1f 100644--- a/src/engine.js+++ b/src/engine.js@@ -11,11 +11,14 @@ import { relayMoveActor, relaySenderProblem } from './relay-sender.js';export const ENGINE_OPERATIONS = Object.freeze(['register', 'ensureCoordinator', 'addItem', 'editItem', 'completeCheckBaseline', 'escalate', 'recordAttempt','claim', 'release', 'submit', 'reserveReview', 'reserveNextReview', 'verify', 'merged',- 'withdraw', 'refreeze', 'shout', 'passDecision', 'answerDecision', 'holdLane', 'releaseLane', 'holdItem', 'releaseItemHold',+ 'withdraw', 'refreeze', 'reopen', 'shout', 'passDecision', 'answerDecision', 'holdLane', 'releaseLane', 'holdItem', 'releaseItemHold','addMilestone', 'editMilestoneItems', 'moveMilestone', 'editMilestone', 'removeMilestone','recordRowDecisions', 'applyRowDecisions', 'appendFact',]);+/** Engine version at which each ordered operation first has stable replay semantics. */+const OPERATION_ENGINE = Object.freeze({ reopen: 8 });+/** Read a replica's committed prefix without trusting an independently saved transport cursor. */export function appliedSequence(board) {const row = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get('relay_applied_sequence');@@ -52,6 +55,8 @@ export function startRelayEpoch(board) {/** Turn caller-only callbacks into deterministic values before sealing an executable operation. */export function prepareEngineMove(board, operation, args, { id = randomUUID(), actor } = {}) {if (!ENGINE_OPERATIONS.includes(operation) || !Array.isArray(args)) throw new Refused('RELAY_MOVE', 'use a supported board-engine operation with its argument array');+ const minimumEngine = OPERATION_ENGINE[operation] ?? 1;+ if (ENGINE_VERSION < minimumEngine) throw new Refused('ENGINE_VERSION', `${operation} requires engine version ${minimumEngine}; this pullboard uses engine ${ENGINE_VERSION}; upgrade before sending it`);const values = args.map((value) => value && typeof value === 'object' ? { ...value } : value);if (operation === 'release') {const problem = store.reviewReleaseNoteProblem(board, values[0], values[1], values[2]);@@ -88,6 +93,8 @@ function validateMove(move) {if (!move || move.version !== 1 || !Number.isSafeInteger(move.engine) || move.engine < 1) throw new Refused('RELAY_MOVE', 'this executable move format is invalid; upgrade pullboard or restore a consistent relay snapshot');requireSupportedEngine(move);if (typeof move.id !== 'string' || !/^[A-Za-z0-9_-]{1,80}$/.test(move.id) || !ENGINE_OPERATIONS.includes(move.operation) || !Array.isArray(move.args)) throw new Refused('RELAY_MOVE', 'this sealed operation is invalid; use a supported board-engine operation');+ const minimumEngine = OPERATION_ENGINE[move.operation] ?? 1;+ if (move.engine < minimumEngine) throw new Refused('RELAY_MOVE', `${move.operation} cannot be replayed from engine version ${move.engine}; it was introduced in engine ${minimumEngine}; restore a consistent relay prefix`);}/** Restore only the frozen criterion callback; no receiver runs another machine's Git or shell. */diff --git a/src/help.js b/src/help.jsindex 821b4fca..09a924be 100644--- a/src/help.js+++ b/src/help.js@@ -92,6 +92,7 @@ Coordinatorpullboard merged <id> <commit> record where verified work landedpullboard withdraw <id> <reason> drop an item nobody should buildpullboard refreeze <id> re-freeze a criterion after its spec rows changed+ pullboard 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 itpullboard hold <lane|id> --off lift a lane or item hold@@ -130,7 +131,7 @@ const HELP_NAMES = ['tour', 'init', 'worktree', 'join', 'takeover', 'whoami', 'lanes', 'status', 'resources', 'settings', 'view', 'view export','serve', 'relay', 'resume', 'hooks', 'add', 'edit', 'escalate', 'run', 'list', 'doctor', 'show', 'next','check', 'claim', 'release', 'submit', 'done', 'verify', 'fact', 'shout', 'answer', 'pass', 'decisions', 'inbox', 'export', 'import',- 'sweep', 'merged', 'withdraw', 'refreeze', 'hold', 'stats', 'ledger', 'log', 'spec', 'spec check', 'spec view',+ 'sweep', 'merged', 'withdraw', 'refreeze', 'reopen', 'hold', 'stats', 'ledger', 'log', 'spec', 'spec check', 'spec view','spec show', 'spec unmet', 'spec signoff', 'spec signers', 'spec signers add', 'forget', 'prompt', 'gate', 'hook','hook pre-commit', 'hook pre-merge-commit', 'hook commit-msg', 'hook pre-push', 'view export', 'version', 'lifecycle', 'help','roadmap', 'milestone',@@ -153,6 +154,7 @@ const HELP_EXAMPLES = {status: 'pullboard status', view: 'pullboard view', stats: 'pullboard stats --since 2026-10-08', log: 'pullboard log 12', ledger: 'pullboard ledger',roadmap: 'pullboard roadmap', milestone: 'pullboard milestone add "0.7.0" --items 12,13',edit: 'pullboard edit 12 --brief "Add the upload page"', release: 'pullboard release 12',+ reopen: 'pullboard reopen 12 --note "correct the frozen criterion"',escalate: 'pullboard escalate 12 --note "needs a manual step"', next: 'pullboard next',run: 'pullboard run --agent "node agent.js"', 'view export': 'pullboard view --export ./site','spec check': 'pullboard spec check',diff --git a/src/json.js b/src/json.jsindex 3ded1a14..c06063ad 100644--- a/src/json.js+++ b/src/json.js@@ -54,6 +54,7 @@ export const JSON_SHAPES = {merged: shape({ id: 'number', commit: 'string' }),withdraw: shape({ id: 'number', reason: 'string' }),refreeze: shape({ id: 'number', after: 'string' }),+ reopen: shape({ id: 'number', commit: 'string' }),shout: shape({ id: 'number', decision: 'boolean' }),answer: shape({ id: 'number', answers: 'number' }),pass: shape({ id: 'number', answers: 'number' }),diff --git a/src/machine.js b/src/machine.jsindex e95c2285..6ebc3308 100644--- a/src/machine.js+++ b/src/machine.js@@ -170,6 +170,12 @@ export const MOVES = [guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven'],command: 'pullboard verify <id> reject --reason CODE --note "..."',},+ {+ verb: 'reopen', from: ['submitted'], to: 'open', by: ['coordinator'], refuse: 'NOT_SUBMITTED',+ guards: ['joined', 'itemExists', IN_STATE, 'coordinatorOnly', 'noteGiven'],+ sets: ['item_verdict', 'item_verified_by', 'item_owner', 'item_lease_until', 'item_review_by', 'item_review_until'],+ command: 'pullboard reopen <id> --note "why"',+ },{verb: 'escalate', from: ['open', 'claimed'], to: 'open', by: ['agent', 'coordinator'], refuse: 'CLOSED',guards: ['joined', 'noteGiven', 'itemExists', 'holderOrCoordinator', IN_STATE], command: 'pullboard escalate <id> --note "..."',diff --git a/src/relay-sender.js b/src/relay-sender.jsindex e0d0135e..6c93fc58 100644--- a/src/relay-sender.js+++ b/src/relay-sender.js@@ -11,7 +11,7 @@ export function relayMoveActor(move) {if (move.operation === 'release') return args[1] ?? null;if (['reserveNextReview', 'addMilestone', 'recordRowDecisions', 'applyRowDecisions'].includes(move.operation)) return args[0]?.agentId ?? null;if (['completeCheckBaseline', 'appendFact', 'editItem', 'escalate', 'recordAttempt', 'claim', 'submit', 'reserveReview', 'verify', 'merged', 'withdraw', 'refreeze',- 'passDecision', 'answerDecision', 'holdLane', 'releaseLane', 'holdItem', 'releaseItemHold', 'editMilestoneItems', 'moveMilestone', 'editMilestone', 'removeMilestone'].includes(move.operation)) return args[1]?.agentId ?? null;+ 'passDecision', 'answerDecision', 'holdLane', 'releaseLane', 'holdItem', 'releaseItemHold', 'reopen', 'editMilestoneItems', 'moveMilestone', 'editMilestone', 'removeMilestone'].includes(move.operation)) return args[1]?.agentId ?? null;return null;}diff --git a/test/api.test.js b/test/api.test.jsindex e4e01c44..dc0be591 100644--- a/test/api.test.js+++ b/test/api.test.js@@ -603,9 +603,14 @@ test('[A1] every catalog command and subcommand has a real CLI exercise', () =>json(source, source.repo, 'milestone', ['edit', 'Catalog', '--name', 'Release', '--note', 'Catalog coverage'], 'edit');json(source, source.repo, 'milestone', ['remove', 'Later'], 'remove');json(source, source.repo, 'milestone', ['remove', 'Release'], 'remove');+ const reopenItem = json(source, source.repo, 'add', ['coordinator', 'Reopen catalog item', '--criterion', 'Exercise the versioned reopen result.', '--check', 'true'], 'add').item;+ json(source, source.repo, 'claim', [String(reopenItem.item_id)]);+ json(source, source.repo, 'submit', [String(reopenItem.item_id)]);+ json(source, source.repo, 'reopen', [String(reopenItem.item_id), '--note', 'exercise the versioned reopen result']);json(source, source.repo, 'spec', ['approve', 'G1'], 'approve');json(source, source.repo, 'spec', ['decline', 'G1', '--reason', 'Catalog decline'], 'decline');json(source, source.repo, 'spec', ['apply'], 'apply');+/** Exercise the agent-only takeover with a private explicit session, leaving later terminal calls markerless. */const sessionSource = { ...source, run: (cwd, ...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd, env: { ...source.env, CODEX_SESSION_ID: 'api-catalog-session' }, encoding: 'utf8' }) };json(sessionSource, source.repo, 'takeover');diff --git a/test/machine.test.js b/test/machine.test.jsindex 3b50dfd3..2be4a8e0 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -47,6 +47,7 @@ const ENTRY_POINTS = [{ verbs: ['escalate'], at: ['board.js#escalate'] },{ verbs: ['withdraw'], at: ['board.js#withdraw'] },{ verbs: ['refreeze'], at: ['board.js#refreeze'] },+ { verbs: ['reopen'], at: ['board.js#reopen'] },];/** Board functions handed a function to call, and the one the CLI and the runner hand them. */@@ -363,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', 'escalate', 'refreeze', 'withdraw']);+ assert.deepEqual(MACHINE.moves.map((move) => move.verb), ['claim', 'release', 'lapse', 'submit', 'reserve', 'accept', 'reject', 'reopen', 'escalate', 'refreeze', 'withdraw']);});for (const broken of BROKEN) {diff --git a/test/reopen.test.js b/test/reopen.test.jsnew file mode 100644index 00000000..85a4a04e--- /dev/null+++ b/test/reopen.test.js@@ -0,0 +1,185 @@+/** Real Git, SQLite and ordered-engine coverage for coordinator criterion reopen [V2,V6,H16]. */+import assert from 'node:assert/strict';+import { runFixtureExecFile as execFileSync } from './fixture-child.js';+import { mkdtempSync, rmSync } 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 * as store from '../src/board.js';+import { appliedSequence, applyRelayMove, engineReceipt, prepareEngineMove } from '../src/engine.js';+import { exportBoard, importBoard } from '../src/exchange.js';+import { ENGINE_VERSION } from '../src/machine.js';+import { createE2eHelpers } from './e2e-helpers.js';++const e2e = createE2eHelpers();+after(e2e.cleanup);+const { project, commitFile } = e2e;++/** Open the real board SQLite file created by the CLI fixture and close it with the test. */+function openFixtureBoard(t, box) {+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));+ t.after(() => store.closeBoard(board));+ return board;+}++/** Create two isolated SQLite replicas from the submitted fixture's real board snapshot. */+function replicaPair(t, box) {+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-reopen-relay-'));+ const source = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));+ const snapshot = exportBoard(source);+ store.closeBoard(source);+ const copies = ['one', 'two'].map((name) => {+ const replica = store.openBoard(join(directory, `${name}.sqlite`));+ importBoard(replica, snapshot);+ return replica;+ });+ t.after(() => {+ for (const replica of copies) store.closeBoard(replica);+ rmSync(directory, { recursive: true, force: true });+ });+ return copies;+}++/** Add, claim and submit a real item through its joined Git worktree. */+function submitFixture(box) {+ const added = box.run(box.repo, 'add', 'web', 'Corrected criterion', '--specs', 'G1', '--criterion', 'The page renders.');+ assert.equal(added.code, 0, added.err);+ const claimed = box.run(box.web, 'claim', '1');+ assert.equal(claimed.code, 0, claimed.err);+ const commit = commitFile(box, box.web, 'web/page.html', '<h1>Page</h1>', 'feat(web): page [G1]');+ assert.equal(commit.status, 0, commit.stderr);+ const submitted = box.run(box.web, 'submit', '1');+ assert.equal(submitted.code, 0, submitted.err);+ return { commit: box.git(box.web, 'rev-parse', 'HEAD'), tree: box.git(box.web, 'rev-parse', 'HEAD^{tree}') };+}++/** Reserve the real submission from a separate joined reviewer checkout. */+function reserveFixtureReview(box) {+ const reviewPath = join(box.dir, 'reviewer');+ box.git(box.repo, 'worktree', 'add', '-q', reviewPath, '-b', 'review/one');+ const joined = box.run(reviewPath, 'join', 'api');+ assert.equal(joined.code, 0, joined.err);+ const reserved = box.run(reviewPath, 'next', '--verify', '1');+ assert.equal(reserved.code, 0, reserved.err);+ return reviewPath;+}++test('the coordinator reopens a submitted item without a verdict [V2,V6]', (t) => {+ const box = project();+ const submitted = submitFixture(box);+ reserveFixtureReview(box);++ const wrongCaller = box.run(box.web, 'reopen', '1', '--note', 'criterion wording needs correction', '--json');+ assert.equal(wrongCaller.code, 1);+ assert.equal(JSON.parse(wrongCaller.out).error.code, 'COORDINATOR_ONLY');+ const missingNote = box.run(box.repo, 'reopen', '1', '--note', ' ', '--json');+ assert.equal(missingNote.code, 1);+ assert.equal(JSON.parse(missingNote.out).error.code, 'NOTE_REQUIRED');++ assert.notEqual(box.git(box.repo, 'rev-parse', 'HEAD'), submitted.commit, 'the coordinator stays at its own head');+ const reopened = box.run(box.repo, 'reopen', '1', '--note', 'correct the frozen criterion, not the work', '--json');+ assert.equal(reopened.code, 0, reopened.err);+ const result = JSON.parse(reopened.out);+ assert.equal(result.version, 1);+ assert.equal(result.id, 1);+ assert.equal(result.commit, submitted.commit);+ const alreadyOpen = box.run(box.repo, 'reopen', '1', '--note', 'try twice', '--json');+ assert.equal(alreadyOpen.code, 1);+ assert.equal(JSON.parse(alreadyOpen.out).error.code, 'NOT_SUBMITTED');++ const board = openFixtureBoard(t, box);+ const item = store.getItem(board, 1);+ assert.equal(item.item_status, 'open');+ assert.equal(item.item_commit, submitted.commit, 'the builder’s submitted commit remains on record');+ assert.equal(item.item_built_by, 'web-1');+ assert.equal(item.item_verdict, null, 'reopen records no verifier judgment');+ assert.equal(item.item_verified_by, null);+ assert.equal(item.item_review_by, null, 'the old review reservation is cleared without a release/cooldown');+ assert.deepEqual(store.stats(board), {+ items: { open: 1, claimed: 0, submitted: 0, verified: 0, withdrawn: 0 }, accepted: 0, rejected: 0,+ });+ const last = store.events(board).at(-1);+ assert.equal(last.event_kind, 'reopen');+ assert.equal(last.event_by, 'coordinator');+ assert.deepEqual(JSON.parse(last.event_detail), {+ commit: submitted.commit, note: 'correct the frozen criterion, not the work', judgment: null,+ });+ assert.equal(store.events(board).some((event) => event.event_kind === 'release' && JSON.parse(event.event_detail).review), false);++ const edited = box.run(box.repo, 'edit', '1', '--criterion', 'The page renders a heading.');+ assert.equal(edited.code, 0, edited.err);+ assert.equal(store.getItem(board, 1).item_criterion, 'The page renders a heading.');+});++test('a reopened item resubmits at a new head after a criterion edit [V2,V6,H16]', async (t) => {+ const box = project();+ const submitted = submitFixture(box);+ const reviewPath = reserveFixtureReview(box);+ const copies = replicaPair(t, box);+ assert.ok(ENGINE_VERSION >= 8, 'engine 8 introduces ordered reopen semantics');+ const move = prepareEngineMove(copies[0], 'reopen', [1, {+ agentId: 'coordinator', note: 'replay the no-verdict return',+ }], { id: 'reopen-engine-roundtrip', actor: 'coordinator' });+ assert.equal(move.engine, 8);+ const oldReceiver = store.openBoard(join(box.dir, 'old-engine.sqlite'));+ t.after(() => store.closeBoard(oldReceiver));+ importBoard(oldReceiver, exportBoard(copies[0]));+ const beforeOldReceiver = exportBoard(oldReceiver);+ const oldDirectory = mkdtempSync(join(tmpdir(), 'pullboard-engine-7-reopen-'));+ t.after(() => rmSync(oldDirectory, { recursive: true, force: true }));+ const archive = execFileSync('git', ['archive', 'v0.8.4'], {+ cwd: resolve(import.meta.dirname, '..'), maxBuffer: 32 * 1024 * 1024,+ });+ execFileSync('tar', ['-x', '-C', oldDirectory], { input: archive });+ const oldEngine = await import(pathToFileURL(join(oldDirectory, 'src/engine.js')).href);+ const oldMachine = await import(pathToFileURL(join(oldDirectory, 'src/machine.js')).href);+ assert.equal(oldMachine.ENGINE_VERSION, 7, 'exercise the actual released engine-7 client');+ const sender = { kind: 'agent', userId: 'fixture-user', agent: 'coordinator' };+ assert.throws(() => oldEngine.applyRelayMove(oldReceiver, move, {+ sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender,+ }), (error) => error.code === 'ENGINE_VERSION');+ assert.deepEqual(exportBoard(oldReceiver), beforeOldReceiver, 'the actual engine-7 client refuses before changing rows or replay state');+ assert.equal(appliedSequence(oldReceiver), 0);++ assert.throws(() => applyRelayMove(oldReceiver, { ...move, engine: 7 }, {+ sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender,+ }), (error) => error.code === 'RELAY_MOVE');+ assert.deepEqual(exportBoard(oldReceiver), beforeOldReceiver, 'the current receiver rejects an impossible pre-introduction tag without mutation');++ const first = applyRelayMove(copies[0], move, { sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender });+ const second = applyRelayMove(copies[1], move, { sequence: 1, at: '2026-10-10T12:00:00.000Z', kind: 'move', sender });+ assert.deepEqual(first, second);+ assert.deepEqual(first.result, { id: 1, commit: submitted.commit });+ for (const replica of copies) {+ assert.equal(store.getItem(replica, 1).item_status, 'open');+ assert.equal(store.getItem(replica, 1).item_commit, submitted.commit);+ assert.equal(store.events(replica).at(-1).event_kind, 'reopen');+ assert.equal(JSON.parse(store.events(replica).at(-1).event_detail).judgment, null);+ assert.equal(appliedSequence(replica), 1);+ assert.equal(engineReceipt(replica, move.id).sequence, 1);+ }++ const reopened = box.run(box.repo, 'reopen', '1', '--note', 'correct the frozen criterion');+ assert.equal(reopened.code, 0, reopened.err);+ const edited = box.run(box.repo, 'edit', '1', '--criterion', 'The page renders a heading.');+ assert.equal(edited.code, 0, edited.err);++ const claimed = box.run(box.web, 'claim', '1');+ assert.equal(claimed.code, 0, claimed.err);+ const sameHead = box.run(box.web, 'submit', '1', '--json');+ assert.equal(sameHead.code, 1);+ assert.equal(JSON.parse(sameHead.out).error.code, 'HEAD_NOT_NEW');+ const treeBefore = box.git(box.web, 'rev-parse', 'HEAD^{tree}');+ box.git(box.web, 'commit', '--allow-empty', '-m', 'chore(web): resend corrected criterion at a new head [G1]');+ const newHead = box.git(box.web, 'rev-parse', 'HEAD');+ assert.notEqual(newHead, submitted.commit);+ assert.equal(box.git(box.web, 'rev-parse', 'HEAD^{tree}'), treeBefore, 'an empty commit keeps the measured tree unchanged');+ const resubmission = box.run(box.web, 'submit', '1', '--json');+ assert.equal(resubmission.code, 0, resubmission.err);+ assert.equal(JSON.parse(resubmission.out).commit, newHead);+ const board = openFixtureBoard(t, box);+ assert.equal(store.getItem(board, 1).item_commit, newHead);+ const freshReview = box.run(reviewPath, 'next', '--verify', '1');+ assert.equal(freshReview.code, 0, `reopen starts no reviewer cooldown: ${freshReview.err}`);+});