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): let coordinators hold items [N2,N22,H16,M1]
Corey Olson99019a59e608
diff --git a/docs/api.md b/docs/api.mdindex db354ee5..03ac1617 100644--- a/docs/api.md+++ b/docs/api.md@@ -257,3 +257,5 @@ Local `GET /api/v1/boards/:board/state` and the device-decrypted relay presentatA browser action's decoded response is `{version: 1, event, result: {request}}`; `request` has the same status shape. `event` is the opaque acknowledgement, or `null` when reconciliation finds the earlier acknowledgement already in a sealed checkpoint. Direct actions become `done` when their actual CLI move commits. A refused add, for example, retains `UNKNOWN_SPEC` and the same explanation and next step as the terminal command, without creating an item. Answers always use the person channel; holds and releases keep the coordinator's execution guard while attributing the decision and event to the person.Row approval and decline first record the person's exact decision through the same authenticated view boundary as the local view, without editing any file. They then create a person-to-coordinator request to run `spec apply`. That request is first in coordinator `resume` and `inbox`. Its status stays `waiting` until the coordinator applies it and answers `done`, or answers `declined <reason>`. Decline resolves the request as `refused` with `REQUEST_DECLINED`, the coordinator's reason and a next step. The browser and relay never run `spec apply`.++`pullboard hold <id> "reason"` holds one open or claimed item; `pullboard hold <id> --off` lifts that hold. Both retain the `hold` JSON shape (`lane`, `held`) and add `id` and `reason` (null when lifted). Held open items are skipped by `next` and refuse new claims with `ITEM_HELD`; an existing live holder can renew and submit. `show` and `list` include the hold actor and reason. Successful `next --json` results may include `reasons` naming skipped holds.diff --git a/docs/formats.md b/docs/formats.mdindex 4382c896..f51a35e1 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` | `6` | `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. Engine 6 adds board-scoped machine credentials and permits machine execution only for one exact, earlier authenticated phone request, including its payload digest. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new 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. Engine 6 adds ordered item holds through `holdItem` and `releaseItemHold`, and board-scoped machine credentials. It permits machine execution only for one exact, earlier authenticated phone request, including its payload digest. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new 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, including@@ -172,6 +172,9 @@ The following live SQLite declarations include nullability, defaults, primary an| `item` | `item_verified_by` | `TEXT` | `nullable` || `item` | `item_merged_commit` | `TEXT` | `nullable` || `item` | `item_withdrawn_reason` | `TEXT` | `nullable` |+| `item` | `item_hold_reason` | `TEXT` | `nullable` |+| `item` | `item_hold_by` | `TEXT` | `nullable` |+| `item` | `item_hold_at` | `TEXT` | `nullable` || `item` | `item_created_by` | `TEXT` | `NOT NULL` || `item` | `item_created_at` | `TEXT` | `NOT NULL` || `item` | `item_updated_at` | `TEXT` | `NOT NULL` |@@ -274,6 +277,8 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `refreeze` | coordinator | `before`, `after` || `hold` | coordinator | `lane`, `reason` || `unhold` | coordinator | `lane` |+| `hold_item` | coordinator | `reason` |+| `unhold_item` | coordinator | `reason` || `guards` | board | `missing`, `changed`, `stale` || `shout` | sender | `shout`, `to`, `decision`, `request`, `answers` || `pass` | coordinator | `shout`, `to`, `decision`, `request`, `answers` |diff --git a/docs/formats.test.js b/docs/formats.test.jsindex b36d529e..0752aba5 100644--- a/docs/formats.test.js+++ b/docs/formats.test.js@@ -23,6 +23,7 @@ import {escalate,events,holdLane,+ holdItem,merged,openBoard,passDecision,@@ -34,6 +35,7 @@ import {register,release,releaseLane,+ releaseItemHold,reserveReview,SCHEMA_VERSION,submit,@@ -250,6 +252,8 @@ function recordEventContract() {const fact = appendFact(board, first, { agentId: builder, kind: 'note', text: 'Captured evidence', ref: 'docs/formats.md:1-3@' + 'a'.repeat(40) });appendFact(board, first, { agentId: coordinator, kind: 'measurement', text: 'Corrected evidence', supersedes: fact.id });editItem(board, first, { agentId: coordinator, brief: 'Files: docs/formats.md\nTest: docs/formats.test.js', route: 'mid', criterion: 'Changed', check: 'node test' });+ holdItem(board, first, { agentId: coordinator, reason: 'fixture item hold' });+ releaseItemHold(board, first, { agentId: coordinator });recordAttempt(board, first, { agentId: builder, n: 1, seconds: 2, result: 'failed' });claim(board, first, { agentId: builder, lane: 'docs', leaseMs: 60_000, freeze: freeze('first') });claim(board, first, { agentId: builder, lane: 'docs', leaseMs: 60_000, freeze: freeze('unused') });diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex e14b9e4c..6f71e816 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -49,7 +49,7 @@ 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), 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), 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), gateConfigured (NO_GATE), gateGreen (GATE_RED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |@@ -91,6 +91,7 @@ Each move checks its guards in this order and refuses with the first one that do| BLOCKED | every item it waits on is verified | claim another item, or shout the lane it waits on || 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 || 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 6a7738d8..3481ac4d 100644--- a/src/board.js+++ b/src/board.js@@ -91,6 +91,9 @@ const SCHEMA = `item_verified_by TEXT,item_merged_commit TEXT,item_withdrawn_reason TEXT,+ item_hold_reason TEXT,+ item_hold_by TEXT,+ item_hold_at TEXT,item_created_by TEXT NOT NULL,item_created_at TEXT NOT NULL,item_updated_at TEXT NOT NULL@@ -240,6 +243,9 @@ function migrate(db) {['item', 'item_files', "TEXT NOT NULL DEFAULT ''"],['item', 'item_review_by', 'TEXT'],['item', 'item_review_until', 'TEXT'],+ ['item', 'item_hold_reason', 'TEXT'],+ ['item', 'item_hold_by', 'TEXT'],+ ['item', 'item_hold_at', 'TEXT'],['shout', 'shout_decision', 'INTEGER NOT NULL DEFAULT 0'],['shout', 'shout_answers', 'INTEGER'],['shout', 'shout_evidence_kind', 'TEXT'],@@ -935,6 +941,12 @@ export function claim(board, id, { agentId, lane, leaseMs, freeze, head = null,? new Refused('LANE_HELD', `${paused.hold_by} holds the ${found.item_lane} lane: ${paused.hold_reason}. Wait for it: pullboard next --wait 9 (minutes)`): null;},+ itemNotHeld: (found) => {+ const held = itemHold(board, found.item_id);+ return held && !isRenewal(found)+ ? new Refused('ITEM_HELD', `item #${id} is held by coordinator: ${held.item_hold_reason}; wait for the coordinator to lift it with pullboard hold ${id} --off`)+ : null;+ },oneLiveClaim: (found) => {if (found.item_parent_id !== null || isRework(found)) return null;const other = board.db@@ -1782,8 +1794,8 @@ export function appendFact(board, id, { agentId, kind, text, ref = null, superseexport function nextFor(board, { agentId, lane, verify = false, policy = 'any', familyPolicy = 'off', runnable = false, routes = ROUTES, warm = [] }) {const route = routeOf(board, agentId);const tier = (entry) => ROUTES.indexOf(entry.item_route);- const items = listItems(board)- .reverse()+ const allItems = listItems(board).reverse();+ const items = allItems.filter((entry) => canTake(route, entry.item_route) && routes.includes(entry.item_route) && (!runnable || entry.item_check)).sort((first, second) => tier(second) - tier(first));const tiers = route === 'strong' ? '' : `${ROUTES.slice(0, ROUTES.indexOf(route) + 1).reverse().join(' or ')} `;@@ -1811,24 +1823,26 @@ export function nextFor(board, { agentId, lane, verify = false, policy = 'any',}const held = items.find((entry) => entry.item_status === 'claimed' && entry.item_owner === agentId && entry.item_parent_id === null);if (held) return { item: held, reasons: [] };+ const reasons = allItems.filter((entry) => entry.item_status === 'open' && entry.item_lane === lane && entry.item_hold_reason)+ .map((entry) => `#${entry.item_id} is held by coordinator: ${entry.item_hold_reason}`);const paused = laneHold(board, lane);- if (paused) return { item: null, reasons: [`${paused.hold_by} holds the ${lane} lane: ${paused.hold_reason}`] };+ if (paused) return { item: null, reasons: [`${paused.hold_by} holds the ${lane} lane: ${paused.hold_reason}`, ...reasons] };const recent = new Set(warm);- const mine = items- .filter((entry) => entry.item_status === 'open' && entry.item_lane === lane)+ const laneItems = items.filter((entry) => entry.item_status === 'open' && entry.item_lane === lane);+ const mine = laneItems+ .filter((entry) => !itemHold(board, entry.item_id)).map((entry, order) => ({ entry, order, shared: itemFiles(entry).filter((path) => recent.has(path)) })).sort((first, second) => tier(second.entry) - tier(first.entry) || second.shared.length - first.shared.length || first.order - second.order);- const reasons = [];for (const { entry, shared } of mine) {const waiting = (entry.item_after ? entry.item_after.split(',').map(Number) : []).map((id) => current(board, itemById(board, id))).filter((before) => before.item_status !== 'verified');- if (!waiting.length) return { item: entry, reasons: [], shared };+ if (!waiting.length) return { item: entry, reasons, shared };reasons.push(`#${entry.item_id} waits on ${waiting.map(waitingOn).join(', ')}`);}- if (!mine.length) reasons.push(idleReason(items, lane, routed));+ if (!mine.length && !reasons.length) reasons.push(idleReason(items, lane, routed));// Nothing to claim, yet work above the agent's tier is open: name it and the ways through (B16).- for (const entry of listItems(board).filter((open) => open.item_status === 'open' && open.item_lane === lane && !canTake(route, open.item_route))) {+ for (const entry of listItems(board).filter((open) => open.item_status === 'open' && open.item_lane === lane && !open.item_hold_reason && !canTake(route, open.item_route))) {reasons.push(`#${entry.item_id} (${entry.item_route}) is open in the ${lane} lane, above your ${route} route: a ${entry.item_route} agent takes it, or, if ${route} can build it, the coordinator reroutes it: pullboard edit ${entry.item_id} --route ${route}`);}return { item: null, reasons };@@ -1960,6 +1974,43 @@ export function laneHolds(board) {return board.db.prepare('SELECT * FROM hold ORDER BY hold_lane').all();}+/** Read an item's coordinator hold, or null when it is available for claims. */+export function itemHold(board, id) {+ const item = getItem(board, id);+ return item.item_hold_reason ? {+ item_id: item.item_id, item_hold_reason: item.item_hold_reason,+ item_hold_by: item.item_hold_by, item_hold_at: item.item_hold_at,+ } : null;+}++/** Hold an open or already-claimed item without changing its current lifecycle state. */+export function holdItem(board, id, { agentId, reason }) {+ coordinatorOnly(agentId, 'holds an item');+ const text = String(reason ?? '').trim();+ if (!text) throw new Refused('USAGE', `a hold needs a reason: pullboard hold ${id} "why"`);+ return atomic(board, () => {+ const item = getItem(board, id);+ if (!['open', 'claimed'].includes(item.item_status)) {+ throw new Refused('ITEM_NOT_OPEN', `item #${id} is ${item.item_status}; only open or claimed items can be held`);+ }+ const at = now(board);+ setItem(board, id, { item_hold_reason: text, item_hold_by: agentId, item_hold_at: at });+ logEvent(board, agentId, 'hold_item', id, { reason: text });+ return itemHold(board, id);+ });+}++/** Lift an item's coordinator hold without changing any other item state. */+export function releaseItemHold(board, id, { agentId }) {+ coordinatorOnly(agentId, 'lifts an item hold');+ return atomic(board, () => {+ const held = itemHold(board, id);+ if (!held) throw new Refused('NOT_HELD', `item #${id} is not held`);+ setItem(board, id, { item_hold_reason: null, item_hold_by: null, item_hold_at: null });+ logEvent(board, agentId, 'unhold_item', id, { reason: held.item_hold_reason });+ });+}+/** Read named milestones from board metadata; older boards simply have none. */export function milestones(board) {const row = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key = ?').get('milestones');diff --git a/src/cli.js b/src/cli.jsindex e9c51ddd..49016048 100644--- a/src/cli.js+++ b/src/cli.js@@ -204,7 +204,8 @@ Coordinatorpullboard withdraw <id> <reason> drop an item nobody should buildpullboard refreeze <id> re-freeze a criterion after its spec rows changedpullboard hold <lane> --reason "..." pause a lane: next there claims nothing and names the reason- pullboard hold <lane> --off release it+ pullboard hold <id> "reason" hold one item so next skips it+ pullboard hold <lane|id> --off lift a lane or item holdReceiptspullboard stats [--since <date>] proof numbers from the event log; --json for sites and tools@@ -892,7 +893,8 @@ function itemLine(item) {const after = item.item_after ? ` after ${item.item_after.split(',').map((id) => `#${id}`).join(',')}` : '';const rejected = item.item_status === 'open' && item.item_verdict === 'REJECT' ? ' (rejected)' : '';const light = item.item_route === 'strong' ? '' : ` ${item.item_route}`;- return `#${item.item_id} ${item.item_status}${holder}${verifier}${rejected} ${item.item_lane} ${item.item_title}${specs}${parent}${after}${light}`;+ const hold = item.item_hold_reason ? ` held by ${item.item_hold_by}: ${item.item_hold_reason}` : '';+ return `#${item.item_id} ${item.item_status}${holder}${verifier}${rejected} ${item.item_lane} ${item.item_title}${specs}${parent}${after}${light}${hold}`;}/**@@ -1864,10 +1866,10 @@ async function nextOnce(ctx, values) {try {await ordered(ctx, board, 'claim', [item.item_id, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: freezer(ctx), head: headCommit(ctx.info.root), reviewSkipped }]);} catch (error) {- if (error instanceof Refused && ['HELD', 'BLOCKED', 'ONE_CLAIM'].includes(error.code)) return { retry: true };+ if (error instanceof Refused && ['HELD', 'ITEM_HELD', 'BLOCKED', 'ONE_CLAIM'].includes(error.code)) return { retry: true };throw error;}- return { item: store.getItem(board, item.item_id), shared, held, reviewSkipped };+ return { item: store.getItem(board, item.item_id), shared, held, reviewSkipped, reasons };});}@@ -1917,7 +1919,8 @@ async function nextHere(io, values) {if (found.item) {if (found.offer) { sayReviewOffer(ctx, found); return 0; }const item = found.item;- io.result?.({ item, review: Boolean(values.verify), held: Boolean(found.held), shared: found.shared ?? [] });+ io.result?.({ item, review: Boolean(values.verify), held: Boolean(found.held), shared: found.shared ?? [], reasons: found.reasons ?? [] });+ for (const reason of found.reasons ?? []) io.say(reason);const here = cdTo(ctx.info.root);const as = ctx.info.isMain ? ' --as coordinator' : '';if (values.verify) {@@ -2196,6 +2199,20 @@ function workCommands(io, args) {return 0;}),hold: () => act(async (ctx, board, me) => {+ const itemTarget = /^#?\d+$/u.test(first ?? '');+ if (itemTarget) {+ const id = idArg(first);+ const reason = values.reason ?? [second, ...rest].filter(Boolean).join(' ');+ if (values.off) {+ await ordered(ctx, board, 'releaseItemHold', [id, { agentId: me.id }]);+ io.say(`lifted the hold on #${id}`);+ } else {+ await ordered(ctx, board, 'holdItem', [id, { agentId: me.id, reason }]);+ io.say(`holding #${id}: ${reason}. Lift it with: pullboard hold ${id} --off`);+ }+ io.result?.({ id, lane: store.getItem(board, id).item_lane, held: !values.off, reason: values.off ? null : reason });+ return 0;+ }if (!first || !isLane(ctx.config, first)) throw new Refused('NO_LANE', `no lane "${first ?? ''}"; see: pullboard lanes`);if (values.off) {await ordered(ctx, board, 'releaseLane', [first, { agentId: me.id, asPerson: io.personChannel === 'view', channel: io.personChannel ?? 'terminal' }]);diff --git a/src/engine.js b/src/engine.jsindex de2df0e1..87e52c24 100644--- a/src/engine.js+++ b/src/engine.js@@ -11,7 +11,7 @@ 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',+ 'withdraw', 'refreeze', 'shout', 'passDecision', 'answerDecision', 'holdLane', 'releaseLane', 'holdItem', 'releaseItemHold','addMilestone', 'editMilestoneItems', 'moveMilestone', 'editMilestone', 'removeMilestone','recordRowDecisions', 'applyRowDecisions', 'appendFact',]);diff --git a/src/machine.js b/src/machine.jsindex af8f5040..a829c0bd 100644--- a/src/machine.js+++ b/src/machine.js@@ -107,6 +107,7 @@ export const GUARDS = [{ id: 'dependenciesVerified', refuse: 'BLOCKED', rule: 'every item it waits on is verified', next: 'claim another item, or shout the lane it waits on', source: 'board' },{ 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: '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' },@@ -139,7 +140,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, 'inLane', 'routeAllows', 'dependenciesVerified', 'notHeldByAnother', 'laneOpen', 'oneLiveClaim', 'rowsInForce'],+ guards: ['joined', 'itemExists', IN_STATE, 'itemNotHeld', 'inLane', 'routeAllows', 'dependenciesVerified', 'notHeldByAnother', 'laneOpen', 'oneLiveClaim', 'rowsInForce'],sets: ['item_owner', 'item_lease_until', 'item_frozen_digest'], command: 'pullboard claim <id>',},{diff --git a/src/relay-sender.js b/src/relay-sender.jsindex bf4bd2ea..e0d0135e 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', 'editMilestoneItems', 'moveMilestone', 'editMilestone', 'removeMilestone'].includes(move.operation)) return args[1]?.agentId ?? null;+ 'passDecision', 'answerDecision', 'holdLane', 'releaseLane', 'holdItem', 'releaseItemHold', 'editMilestoneItems', 'moveMilestone', 'editMilestone', 'removeMilestone'].includes(move.operation)) return args[1]?.agentId ?? null;return null;}diff --git a/test/item-hold.test.js b/test/item-hold.test.jsnew file mode 100644index 00000000..8f4c0f6a--- /dev/null+++ b/test/item-hold.test.js@@ -0,0 +1,161 @@+/** Coordinator item holds preserve routing, claims and ordered replay [N2,N22,H16,M1]. */+import assert from 'node:assert/strict';+import { test } from 'node:test';+import { createE2eHelpers } from './e2e-helpers.js';+import * as store from '../src/board.js';+import { applyRelayMove, prepareEngineMove } from '../src/engine.js';+import { exportBoard, importBoard } from '../src/exchange.js';++const e2e = createE2eHelpers();++/** Add a runnable mid item to a real private board. */+function addMidItem(board, lane, title) {+ return store.addItem(board, { by: 'coordinator', lane, title, route: 'mid',+ criterion: 'The private fixture proves the hold.', brief: e2e.LIGHT_BRIEF, check: 'true' });+}++/** Read a successful private CLI JSON result without hiding its diagnostic on failure. */+function jsonSuccess(box, cwd, ...args) {+ const result = box.run(cwd, ...args, '--json');+ assert.equal(result.code, 0, result.err || result.out);+ return JSON.parse(result.out);+}++/** Read the item fields that a hold must leave unchanged. */+function withoutHold(item) {+ const { item_hold_reason, item_hold_by, item_hold_at, item_updated_at, ...unchanged } = item;+ return unchanged;+}++test('a held item is never offered or claimed [N2,N22,M1]', t => {+ const box = e2e.project('true');+ t.after(e2e.cleanup);+ const board = store.openBoard(`${box.repo}/.git/pullboard/board.sqlite`);+ t.after(() => store.closeBoard(board));+ const held = new Map();+ const actors = [];+ for (const lane of ['web', 'api']) {+ const id = addMidItem(board, lane, `Held ${lane} item`);+ const before = store.getItem(board, id);+ const reason = `waiting for the person in ${lane}`;+ const result = jsonSuccess(box, box.repo, 'hold', String(id), reason);+ assert.equal(result.id, id);+ assert.equal(result.lane, lane);+ assert.equal(result.held, true);+ assert.equal(result.reason, reason);+ assert.deepEqual(withoutHold(store.getItem(board, id)), withoutHold(before));+ assert.match(box.run(box.repo, 'show', String(id)).out, new RegExp(`held by coordinator: ${reason}`));+ assert.match(box.run(box.repo, 'list', lane).out, new RegExp(`held by coordinator: ${reason}`));+ held.set(lane, { id, reason });+ for (const route of ['light', 'mid', 'strong']) {+ const actor = jsonSuccess(box, box.repo, 'worktree', lane, '--route', route);+ actors.push({ ...actor, lane, route });+ const next = store.nextFor(board, { agentId: actor.agent, lane });+ assert.equal(next.item, null, `${lane}/${route} cannot offer a held item`);+ assert.ok(next.reasons.includes(`#${id} is held by coordinator: ${reason}`));+ const attempted = box.run(actor.path, 'next', '--build', '--json');+ assert.equal(attempted.code, 1);+ const refusal = JSON.parse(attempted.out);+ assert.equal(refusal.error.code, 'NOTHING_FREE');+ assert.ok(refusal.error.message.includes(`#${id} is held by coordinator: ${reason}`));+ }+ }+ jsonSuccess(box, box.repo, 'hold', 'web', '--reason', 'lane release review');+ const webActor = actors.find(value => value.lane === 'web' && value.route === 'strong');+ const paused = box.run(webActor.path, 'next', '--build', '--json');+ assert.equal(paused.code, 1);+ const pausedReason = JSON.parse(paused.out).error.message;+ assert.ok(pausedReason.includes('lane release review'));+ assert.ok(pausedReason.includes(`#${held.get('web').id} is held by coordinator: ${held.get('web').reason}`),+ 'a lane hold does not mask the item hold reason');+ jsonSuccess(box, box.repo, 'hold', 'web', '--off');+ for (const actor of actors) {+ for (const { id, reason } of held.values()) {+ const attempted = box.run(actor.path, 'claim', String(id), '--json');+ assert.equal(attempted.code, 1);+ const refusal = JSON.parse(attempted.out);+ assert.equal(refusal.error.code, 'ITEM_HELD', `${actor.lane}/${actor.route} cannot claim a held item in either lane`);+ assert.ok(refusal.error.message.includes(reason));+ assert.equal(store.getItem(board, id).item_status, 'open');+ assert.equal(store.getItem(board, id).item_owner, null);+ }+ }+ const actor = actors.find(value => value.lane === 'web' && value.route === 'mid');+ const free = addMidItem(board, 'web', 'Available work after a held item');+ const selected = jsonSuccess(box, actor.path, 'next', '--build');+ assert.equal(selected.item.item_id, free, 'next passes the held item to claim available work');+ assert.ok(selected.reasons.includes(`#${held.get('web').id} is held by coordinator: ${held.get('web').reason}`));+ const unauthorized = box.run(actor.path, 'hold', String(free), 'an agent cannot hold work', '--json');+ assert.equal(unauthorized.code, 1);+ assert.match(unauthorized.out + unauthorized.err, /COORDINATOR_ONLY/u);+});++test('lifting a hold makes the item offerable again [N2,N22,H16,M1]', t => {+ const box = e2e.project('true');+ t.after(e2e.cleanup);+ const board = store.openBoard(`${box.repo}/.git/pullboard/board.sqlite`);+ t.after(() => store.closeBoard(board));+ const id = addMidItem(board, 'web', 'Held item');+ const peer = store.openBoard(':memory:');+ t.after(() => store.closeBoard(peer));+ store.register(peer, { lane: 'coordinator', path: '/peer' });+ store.register(peer, { lane: 'web', path: '/peer-web' });+ assert.equal(addMidItem(peer, 'web', 'Held item'), id);+ const initial = store.getItem(board, id);+ const hold = prepareEngineMove(board, 'holdItem', [id, { agentId: 'coordinator', reason: 'review the release' }]);+ const at = '2026-10-09T12:00:00.000Z';+ const transport = { kind: 'move', sender: { kind: 'agent', userId: 'fixture-user', agent: 'coordinator' } };+ const applied = applyRelayMove(board, hold, { ...transport, sequence: 1, at });+ assert.deepEqual(applyRelayMove(peer, hold, { ...transport, sequence: 1, at }), applied);+ assert.equal(store.getItem(peer, id).item_hold_reason, 'review the release');+ const holdEvent = store.events(peer, { itemId: id }).at(-1);+ assert.equal(holdEvent.event_kind, 'hold_item');+ assert.equal(JSON.parse(holdEvent.event_detail).reason, 'review the release');+ const restored = store.openBoard(':memory:');+ t.after(() => store.closeBoard(restored));+ importBoard(restored, exportBoard(board));+ assert.deepEqual(store.getItem(restored, id), store.getItem(board, id), 'snapshot sync preserves the complete held item');+ assert.deepEqual(store.events(restored), store.events(board), 'snapshot sync preserves the hold event');+ assert.equal(store.nextFor(restored, { agentId: 'web-1', lane: 'web' }).item, null);+ const legacyExport = exportBoard(board);+ for (const item of legacyExport.tables.item) {+ delete item.item_hold_reason;+ delete item.item_hold_by;+ delete item.item_hold_at;+ }+ const incompatible = store.openBoard(':memory:');+ t.after(() => store.closeBoard(incompatible));+ assert.throws(() => importBoard(incompatible, legacyExport), error => error.code === 'IMPORT_SCHEMA'+ && error.message === '[IMPORT_SCHEMA] a item row does not have exactly its board columns; export it again',+ 'a pre-hold export retains the existing strict-schema refusal');+ const release = prepareEngineMove(board, 'releaseItemHold', [id, { agentId: 'coordinator' }]);+ const releaseAt = '2026-10-09T12:01:00.000Z';+ const released = applyRelayMove(board, release, { ...transport, sequence: 2, at: releaseAt });+ assert.deepEqual(applyRelayMove(peer, release, { ...transport, sequence: 2, at: releaseAt }), released);+ assert.equal(store.events(peer, { itemId: id }).at(-1).event_kind, 'unhold_item');+ for (const replica of [board, peer]) {+ const item = store.getItem(replica, id);+ assert.equal(item.item_hold_reason, null);+ assert.equal(item.item_hold_by, null);+ assert.equal(item.item_hold_at, null);+ assert.equal(store.nextFor(replica, { agentId: 'web-1', lane: 'web' }).item.item_id, id);+ }+ assert.deepEqual(withoutHold(store.getItem(board, id)), withoutHold(initial));+ jsonSuccess(box, box.repo, 'hold', String(id), 'CLI hold and lift');+ const lifted = jsonSuccess(box, box.repo, 'hold', String(id), '--off');+ assert.equal(lifted.held, false);+ assert.equal(lifted.reason, null);+ assert.equal(store.nextFor(board, { agentId: 'web-1', lane: 'web' }).item.item_id, id);+ assert.equal(jsonSuccess(box, box.web, 'next', '--build').item.item_id, id);+ jsonSuccess(box, box.repo, 'hold', String(id), 'finish your current work');+ assert.equal(store.getItem(board, id).item_owner, 'web-1');+ const heldClaimCopy = store.openBoard(':memory:');+ t.after(() => store.closeBoard(heldClaimCopy));+ importBoard(heldClaimCopy, exportBoard(board));+ assert.deepEqual(store.getItem(heldClaimCopy, id), store.getItem(board, id), 'snapshot sync preserves the held claim and reason');+ assert.equal(store.getItem(heldClaimCopy, id).item_owner, 'web-1');+ assert.equal(jsonSuccess(box, box.web, 'claim', String(id)).renewed, true);+ box.git(box.web, 'commit', '--allow-empty', '-qm', 'feat(web): finish held work [G1]');+ assert.equal(jsonSuccess(box, box.web, 'submit', String(id)).id, id);+ assert.equal(store.getItem(board, id).item_status, 'submitted', 'the existing live holder can still submit');+});diff --git a/test/machine.test.js b/test/machine.test.jsindex 64a956a3..369837c1 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -853,7 +853,10 @@ test('claim refuses in the declared order, one failure peeled at a time, on a restore.claim(board, dependency, { agentId: 'web-1', lane: 'web', leaseMs: 7_200_000, freeze });store.submit(board, dependency, { agentId: 'web-1', commit: SHA_A, tree: 'tree' });store.holdLane(board, 'web', { agentId: 'coordinator', reason: 'pause' });- const fired = [claimAs(999, light, 'api'), claimAs(done, light, 'api'), claimAs(target, light, 'api'), claimAs(target, light, 'web'), claimAs(target, strong, 'web')];+ store.holdItem(board, target, { agentId: 'coordinator', reason: 'item pause' });+ const fired = [claimAs(999, light, 'api'), claimAs(done, light, 'api'), claimAs(target, light, 'api')];+ store.releaseItemHold(board, target, { agentId: 'coordinator' });+ fired.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.release(board, target, 'web-2');@@ -864,7 +867,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', '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', 'LANE_HELD', 'ONE_CLAIM', 'UNKNOWN_SPEC', 'ok']);} finally {lab.done();}