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): a head that stops merging goes back to its builder [C7,V4]
Corey Olson30e1fca5f383
diff --git a/docs/formats.md b/docs/formats.mdindex 370b7e14..eb320cdc 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -113,7 +113,7 @@ The board file is in the repository's Git common directory at `.git/pullboard/bo| `row grammar` | `1` | `SPEC_GRAMMAR_VERSION` in `src/spec.js`; optional `<!-- pullboard-grammar N -->` line in either file (absence means the current grammar) | Both files share the version. A declared version must match; an incompatible grammar change requires a coordinated version bump and compatible files. No automatic conversion occurs. || `board schema` | `2` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | Create missing tables and indexes, add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. || `event log` | `1` | `EVENT_LOG_VERSION` in `src/board.js`, persisted in `board_meta` as `event_log_version` | Older event-log versions upgrade in place; newer versions are refused with `EVENT_LOG_VERSION`. Preserve event rows when the board schema changes. |-| `move engine` | `56` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |+| `move engine` | `60` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |<!-- format-versions:end -->Pullboard 0.6.1 released engine 1. Engine 2 records a fresh explicit-build claim's skipped-review snapshot. Pullboard 0.8.1 released engine 3, including lane-sensitive graft refusals and authenticated relay senders. Engine 4 adds captured background-baseline completions through `completeCheckBaseline`; released engine-3 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Engine 5 requires a one-line reason when releasing a review and gives that reviewer a one-hour cooldown for the current submission. Each sealed move replays under its recorded engine version: engines 1 through 4 retain the original release event and review-reservation behavior. Engine 5 retains support for older moves, including engine-4 baseline completions. Pullboard 0.8.3 released engine 6, adding board-scoped machine credentials and permitting machine execution only for one exact, earlier authenticated phone request, including its payload digest. Engine 7 adds ordered item holds through `holdItem` and `releaseItemHold`; engine-6 clients stop with `ENGINE_VERSION` before interpreting either operation or advancing their replay cursor. Engine 8, shared by the 0.8.5 move changes, retains merged-item exception notes, selects the next review in roadmap order, and adds coordinator-only `reopen` for a submission returned without a verdict; engine-7 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Recorded engines 1 through 7 retain their original tier-first review selection. Engine 8 also adds durable refusal recovery for blocked relay positions; each explicit skip publishes the readable prefix even when another unsupported record follows. Engine 8 also permits coordinator criterion/check edits on a live claim as pending corrections; the holder cannot renew or submit until a refreeze adopts the correction while preserving the claim. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new moves. Each release shares one engine bump across its changed moves. Engine 8 also retains declared model labels on registration and records each registered agent move's model snapshot; engines 1 through 7 retain their original registration and event details without these model fields. Pullboard 0.8.8 released engine 9, which allows resubmitting the same rejected commit after a corrected criterion is refrozen, but only when the rejection names a different frozen digest. Engine 8 retains its HEAD_NOT_NEW refusal and prior submit-event detail. Engine-9 submit events add `criterionDigest`, and engine-8 boards replay with the original refusal and event history.@@ -152,6 +152,8 @@ Engine 55 (`ROW_DRAFT_ENGINE`) adds `draftSpecRow`: an agent in a lane worktreeEngine 56 (`BOARD_SENTINEL_ENGINE`) adds board-owned watch proposals, exact person approve/decline decisions, ordered due-run claims and completed run receipts. Approval binds the entire execution definition; changing it creates a pending proposal. Replay records history without executing commands. Every non-cancelled red run records `sentinel:<name>` for Rigor; feed notices only mark failure and recovery transitions. Older engines refuse these operations and this new cause form before replay. Published engine-55 readers reject these moves by their newer engine number before interpreting an operation.+Engine 60 (`SUBMITTED_CONFLICT_ENGINE`) lets a conflict reopen return a submitted head, not only an accepted one, and lets any joined seat record it. Before it offers a review, `pullboard next --verify` merges every submitted head onto the trunk in memory, as landing does; a head that conflicts goes back to its builder, open and unreviewed, with Git's conflicting files and the trunk commit, and its builder is told which files and that the one step back is to claim it, merge main and submit again. The reopen sets no accept aside and records no verdict; its next review is a whole one. A hand-written `--conflict` on a submission, which names no trunk commit, is still refused. Engines 57 to 59 are allocated to other changes; older engines refuse this move before replay.+The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.A linked board requires at least engine 48 after issuing any agent token or machine credential, includingrevoked or expired ones; before engine 48 these minimums were 3 and 6. The minimum survives reopening the auth database;diff --git a/src/board.js b/src/board.jsindex 3c47a8e8..927af01f 100644--- a/src/board.js+++ b/src/board.js@@ -37,6 +37,7 @@ import {IN_STATE,MOVES,STATES,+ SUBMITTED_CONFLICT_ENGINE,UNKNOWN_MOVE,VERIFIER_STANDING_ENGINE,effectiveGuards,@@ -73,6 +74,7 @@ import {conflictDetail,conflictNote,conflictProblem,+ returnedHeadNotice,} from './trunk-conflict.js';import {HEALTH_SENTINEL_ENGINE,@@ -1625,7 +1627,9 @@ export function reopen(board, id, { agentId, note = '', conflict, cause }) {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'),+ // 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')),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@@ -1668,6 +1672,7 @@ export function reopen(board, id, { agentId, note = '', conflict, cause }) {const returned = forMerge ? { supersedes, ...conflictDetail(conflict) } : supersedes ? { supersedes, landingFailure } : {};logEvent(board, agentId, 'reopen', id, { commit: submittedCommit, note: note.trim() || conflictNote(conflict), judgment: null,...(cause !== undefined && cause !== null ? { cause } : {}), ...returned });+ if (forMerge && supersedes === undefined && item.item_built_by) persistShout(board, { from: agentId, to: item.item_built_by, text: returnedHeadNotice(id, submittedCommit, conflict) });postRigorNotices(board, board.lastEvent);return { id: item.item_id, commit: submittedCommit, ...returned };});diff --git a/src/cli.js b/src/cli.jsindex 5799fdb9..76d62df8 100644--- a/src/cli.js+++ b/src/cli.js@@ -340,6 +340,7 @@ import {reportView,} from './background-view.js';import { rigorDraftCommand } from './rigor-draft.js';+import { nextReview } from './next-review.js';import { serveApi } from './api.js';import { watchCommand } from './watch.js';import { serveMcp } from './mcp.js';@@ -3176,13 +3177,7 @@ async function nextOnce(ctx, values) {return await withBoard(ctx, async (board) => {if (values.verify) checkMainVerifier(ctx, board, values);const me = whoAmI(ctx, board);- if (values.verify) {- const reservation = { agentId: me.id, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify.policy, familyPolicy: ctx.config.verify.family };- if (values.verifyId !== undefined) {- return { item: await ordered(ctx, board, 'reserveReview', [idArg(values.verifyId, 'an item id after --verify'), reservation]), reasons: [] };- }- return await ordered(ctx, board, 'reserveNextReview', [{ agentId: me.id, lane: me.lane, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify.policy, familyPolicy: ctx.config.verify.family, runnable: values.runnable, routes: values.routes }]);- }+ if (values.verify) return nextReview(ctx, board, me, values, { ordered: (operation, args) => ordered(ctx, board, operation, args), idArg, trunkMerge });const warm = warmFiles(ctx, board, me);const seats = nextSessionSeats(ctx, board);const owners = new Set(seats?.map((seat) => seat.agent_id));diff --git a/src/engine.js b/src/engine.jsindex 1fa5abe8..d5afe4e9 100644--- a/src/engine.js+++ b/src/engine.js@@ -28,6 +28,7 @@ import {VERDICT_REVIEW_ENGINE,MILESTONE_RANK_ENGINE,ROW_DRAFT_ENGINE,+ SUBMITTED_CONFLICT_ENGINE,} from './machine.js';import {MILESTONE_SHIP_ENGINE,@@ -70,7 +71,7 @@ function minimumOperationEngine(operation, args, board) {if (['proposeSentinel', 'decideSentinel', 'beginSentinelRun', 'finishSentinelRun'].includes(operation) || typeof args[1]?.cause === 'string' && args[1].cause.startsWith('sentinel:')) return BOARD_SENTINEL_ENGINE;if (operation === 'recordHealthFindings') return HEALTH_SENTINEL_ENGINE;const options = args[1];- if (carriesConflict(operation, args)) return CONFLICT_ENGINE;+ if (carriesConflict(operation, args)) return board && store.itemById(board, args[0])?.item_status === 'submitted' ? SUBMITTED_CONFLICT_ENGINE : CONFLICT_ENGINE;if (operation === 'submit' && options?.submissionProof !== undefined|| operation === 'recordLandingBatch' && args[0]?.batch?.invariantEvidence !== undefined) return SUBMISSION_PROOF_ENGINE;const given = (name) => Boolean(options && typeof options === 'object' && Object.hasOwn(options, name) && options[name] !== undefined && options[name] !== null && options[name] !== false);diff --git a/src/machine.js b/src/machine.jsindex 652dd7e7..96cde24f 100644--- a/src/machine.js+++ b/src/machine.js@@ -24,7 +24,14 @@ export const ROW_DRAFT_ENGINE = 55;export const STRONG_REJECTION_NOTICE_ENGINE = 54;/** Executable move semantics, carried by every sealed move and retained during replay [H16]. */+/**+ * The engine at which a conflict reopen may return a submitted head, not only an accepted one, and any joined+ * seat may record it (#807; allocated by the coordinator, 19 Oct).+ */+export const SUBMITTED_CONFLICT_ENGINE = 60;+export const ENGINE_VERSION = Math.max(+ SUBMITTED_CONFLICT_ENGINE,ROW_DRAFT_ENGINE,AUTO_ESCALATE_ENGINE,RIGOR_NOTICE_ENGINE,diff --git a/src/next-review.js b/src/next-review.jsnew file mode 100644index 00000000..9f1bcaac--- /dev/null+++ b/src/next-review.js@@ -0,0 +1,52 @@+/**+ * pullboard next --verify (V15, #807): before a review is offered, every submitted head that no longer merges onto+ * the trunk goes back to its builder with Git's conflicting files, so no reviewer reserves work that cannot land.+ */+import * as store from './board.js';+import { Refused } from './refused.js';+import { shownPath } from './trunk-conflict.js';++/**+ * Return each submitted head that conflicts with the trunk to its builder, recorded as a conflict reopen (#807).+ * Git decides, in memory, exactly as landing does; a board with no recorded trunk keeps today's offers.+ *+ * @param {string} root+ * @param {any} board+ * @param {{ ordered: (operation: string, args: any[]) => Promise<any>, trunkMerge: (root: string, commit: string) => { commit: string, files: string[] | null } }} deps+ * @returns {Promise<{ id: number, files: string[] }[]>}+ */+export async function returnUnmergeable(root, board, me, { ordered, trunkMerge }) {+ const returned = [];+ for (const item of store.listItems(board).filter((entry) => entry.item_status === 'submitted' && entry.item_commit)) {+ let merge;+ try { merge = trunkMerge(root, item.item_commit); }+ catch (error) { if (error instanceof Refused) return returned; throw error; }+ if (!merge.files?.length) continue;+ try {+ await ordered('reopen', [item.item_id, { agentId: me.id, conflict: { files: merge.files, trunk: merge.commit } }]);+ returned.push({ id: item.item_id, files: merge.files });+ } catch (error) { if (!(error instanceof Refused)) throw error; }+ }+ return returned;+}++/**+ * The review half of one next loop: return heads that no longer merge, then reserve the named review or the next one.+ *+ * @param {any} ctx+ * @param {any} board+ * @param {{ id: string, lane: string }} me+ * @param {any} values+ * @param {{ ordered: (operation: string, args: any[]) => Promise<any>, idArg: (value: any, what: string) => number, trunkMerge: Function }} deps+ */+export async function nextReview(ctx, board, me, values, { ordered, idArg, trunkMerge }) {+ for (const { id, files } of await returnUnmergeable(ctx.info.root, board, me, { ordered, trunkMerge })) {+ // Stderr in every mode, so a --json caller still sees why the queue shrank.+ const line = `returned #${id} to its builder unreviewed: it no longer merges onto the trunk (${files.map(shownPath).join(', ')})`;+ if (ctx.io.stderr) ctx.io.stderr.write(line + '\n'); else ctx.io.err?.(line);+ }+ const reservation = { agentId: me.id, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify.policy, familyPolicy: ctx.config.verify.family };+ if (values.verifyId !== undefined) return { item: await ordered('reserveReview', [idArg(values.verifyId, 'an item id after --verify'), reservation]), reasons: [] };+ return await ordered('reserveNextReview', [{ agentId: me.id, lane: me.lane, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify.policy,+ familyPolicy: ctx.config.verify.family, runnable: values.runnable, routes: values.routes }]);+}diff --git a/src/trunk-conflict.js b/src/trunk-conflict.jsindex 744d5c6f..c12ca909 100644--- a/src/trunk-conflict.js+++ b/src/trunk-conflict.js@@ -8,7 +8,10 @@* builder claims it with its bar unchanged, merges main and resubmits; the re-review checks the* frozen check at the new head and nothing else.*/-import { ENGINE_VERSION } from './machine.js';+import {+ ENGINE_VERSION,+ SUBMITTED_CONFLICT_ENGINE,+} from './machine.js';import { Refused } from './refused.js';/** The engine whose reopen may carry a trunk conflict; older engines refuse it before replay. */@@ -101,13 +104,17 @@ export function reopenConflict({ item, coordinator, values, trunkMerge }) {export function conflictProblem(board, item, conflict, found) {const engine = board.executionEngineVersion ?? ENGINE_VERSION;if (engine < CONFLICT_ENGINE) return new Refused('ENGINE_VERSION', `a reopen for a main merge requires engine ${CONFLICT_ENGINE}; this board uses engine ${engine}; upgrade Pullboard before using --conflict`);- if (item.item_status !== 'verified') return new Refused('NOT_ACCEPTED', `item #${item.item_id} is ${item.item_status}; --conflict reopens accepted work for a main merge, and a submission reopens with --note "why"`);+ // A submitted head that no longer merges goes back to its builder before anyone reviews it (#807).+ // Only the automatic return names Git's trunk for a submission; a hand-written --conflict on one stays refused.+ const returning = item.item_status === 'submitted' && engine >= SUBMITTED_CONFLICT_ENGINE && /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(conflict?.trunk ?? '');+ if (item.item_status !== 'verified' && !returning) return new Refused('NOT_ACCEPTED', `item #${item.item_id} is ${item.item_status}; --conflict reopens accepted work for a main merge, and a submission reopens with --note "why"`);const shape = /** @type {any} */ (conflict);const files = Array.isArray(shape?.files) ? shape.files : [];if (!files.length || files.some((file) => typeof file !== 'string' || !file || file.includes('\0')) || new Set(files).size !== files.length|| !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(shape?.trunk ?? '')) {return new Refused('BAD_CONFLICT', 'a trunk conflict names its files and the full trunk commit; run pullboard reopen <id> --conflict <file> from the main checkout');}+ if (returning) return null;const accept = board.db.prepare("SELECT event_id FROM event WHERE item_id = ? AND event_kind = 'accept' AND json_extract(event_detail, '$.commit') = ? ORDER BY event_id DESC LIMIT 1").get(item.item_id, item.item_commit);if (!accept) return new Refused('NOT_ACCEPTED', `item #${item.item_id} has no accept at ${String(item.item_commit).slice(0, 12)}; --conflict reopens accepted work for a main merge`);found(accept.event_id);@@ -142,14 +149,16 @@ export function conflictNote({ files, trunk }) {** @param {any} board* @param {number} id- * @returns {{ files: string[], trunk: string, commit: string, at: string, accept: { by: string, commit: string } | null } | null}+ * @returns {{ files: string[], trunk: string, commit: string, at: string, accept: { by: string, commit: string } | null, returned: boolean } | null}+ * returned: a submission sent back before any review (#807), which sets no accept aside.*/export function mainMergeFor(board, id) {const last = board.db.prepare("SELECT event_detail, event_at FROM event WHERE item_id = ? AND event_kind IN ('reopen', 'accept', 'reject') ORDER BY event_id DESC LIMIT 1").get(id);const detail = last ? JSON.parse(last.event_detail) : null;if (!detail?.conflict) return null;- const accept = board.db.prepare('SELECT event_by, event_detail FROM event WHERE event_id = ?').get(detail.supersedes);- return { ...detail.conflict, commit: detail.commit, at: last.event_at,+ const returned = !Number.isSafeInteger(detail.supersedes);+ const accept = returned ? null : board.db.prepare('SELECT event_by, event_detail FROM event WHERE event_id = ?').get(detail.supersedes);+ return { ...detail.conflict, commit: detail.commit, at: last.event_at, returned,accept: accept ? { by: accept.event_by, commit: JSON.parse(accept.event_detail).commit } : null };}@@ -163,8 +172,10 @@ export function mainMergeFor(board, id) {* @returns {string[]}*/export function mainMergeLines(item, merge, name = (id) => id) {- const accepted = merge.accept ? `accepted by ${name(merge.accept.by)} at ${merge.accept.commit.slice(0, 12)}` : 'accepted';+ const accepted = merge.returned ? 'returned unreviewed' : merge.accept ? `accepted by ${name(merge.accept.by)} at ${merge.accept.commit.slice(0, 12)}` : 'accepted';const head = `${MAIN_MERGE_LABEL}: ${accepted}; conflicts with the trunk at ${merge.trunk.slice(0, 12)} in ${shownPaths(merge.files)}`;+ // A returned head was never reviewed, so its next review is a whole one.+ if (item.item_status === 'submitted' && merge.returned) return [head, `review: the whole criterion at ${item.item_commit.slice(0, 12)}; nothing was reviewed before it went back`];if (item.item_status === 'submitted') return [head, `re-review: main merge only; run the frozen check at ${item.item_commit.slice(0, 12)}; the accept above stands for the rest`];return [head, `next: pullboard claim ${item.item_id} (the bar is unchanged), merge main, resolve ${shownPaths(merge.files)}, commit, pullboard submit ${item.item_id}`];}@@ -193,3 +204,16 @@ export function reopenedLine(id, result) {? `reopened #${id} after landing failure; previous accept remains recorded at ${result.commit.slice(0, 12)}`: `reopened #${id} without a verdict; previous commit ${result.commit.slice(0, 12)} remains recorded`;}++/**+ * What the builder of a returned submission is told (#807): its head no longer merges onto the trunk, the files+ * that conflict, and the one step back: claim it, merge main and submit again.+ *+ * @param {number} id+ * @param {string} commit - the submitted head+ * @param {{ files: string[], trunk: string }} conflict+ * @returns {string}+ */+export function returnedHeadNotice(id, commit, conflict) {+ return `#${id} went back to you unreviewed: ${String(commit).slice(0, 12)} no longer merges onto the trunk at ${conflict.trunk.slice(0, 12)} (${shownPaths(conflict.files)}). Claim it, merge main, resolve ${conflict.files.length === 1 ? 'that file' : 'those files'} and submit again: pullboard claim ${id}`;+}diff --git a/test/review-queue.test.js b/test/review-queue.test.jsindex 2b0525ad..9f47289a 100644--- a/test/review-queue.test.js+++ b/test/review-queue.test.js@@ -4,6 +4,10 @@ import assert from 'node:assert/strict';import { createHash } from 'node:crypto';import { test } from 'node:test';import * as store from '../src/board.js';+import { mkdirSync } from 'node:fs';+import { writeFileSync } from 'node:fs';+import { join } from 'node:path';+import { createE2eHelpers } from './e2e-helpers.js';const HOUR = 60 * 60 * 1000;const REVIEW_LEASE = 1_000;@@ -141,3 +145,66 @@ test('[Q1,V15,O2,B13] policy, family and route rules still decide which revieweragentId: agents.lightReviewer, lane: 'review', policy: 'any', ratio: 1,}), null, 'a light reviewer cannot take a strong item');});++/**+ * A real board where web-1 submits #1, then main changes the same file (#807). A second seat in the api lane+ * reviews, so the builder never verifies its own work. Returns the box and helpers.+ */+function staleHeadFixture(t) {+ const helpers = createE2eHelpers();+ t.after(helpers.cleanup);+ const box = helpers.project('true');+ /** Demand real command success and its versioned result. */+ const json = (result) => { assert.equal(result.code, 0, result.out + result.err); return JSON.parse(result.out); };+ /** Add, claim, build and submit one web item from a web seat's worktree. */+ const build = (title, path, text, seat = box.web) => {+ const id = json(box.run(box.repo, 'add', 'web', title, '--criterion', `${path} exists`, '--json')).item.item_id;+ json(box.run(seat, 'claim', String(id), '--json'));+ mkdirSync(join(seat, 'web'), { recursive: true });+ writeFileSync(join(seat, path), text);+ box.git(seat, 'add', path);+ box.git(seat, 'commit', '-q', '-m', `feat(web): ${title.toLowerCase()} [G1]`);+ json(box.run(seat, 'submit', String(id), '--json'));+ return id;+ };+ const conflicted = build('Show the list', 'web/list.html', '<ul>from the branch</ul>\n');+ // The trunk moves: the same file lands on main with other lines.+ mkdirSync(join(box.repo, 'web'), { recursive: true });+ writeFileSync(join(box.repo, 'web/list.html'), '<ol>from main</ol>\n');+ box.git(box.repo, 'add', 'web/list.html');+ box.git(box.repo, 'commit', '-q', '-m', 'feat(web): main lands its own list [G1]');+ const reviewer = join(box.dir, 'api-1');+ box.git(box.repo, 'worktree', 'add', '-q', reviewer, '-b', 'api/review');+ json(box.run(reviewer, 'join', 'api', '--json'));+ return { box, json, build, conflicted, reviewer };+}++test('a submitted head that no longer merges is returned to its builder [C7,V4]', (t) => {+ const { box, json, conflicted, reviewer } = staleHeadFixture(t);+ assert.equal(json(box.run(box.repo, 'show', String(conflicted), '--json')).item_status, 'submitted', 'the head waits for review before the trunk check');+ const next = box.run(reviewer, 'next', '--verify', '--json');+ assert.match(next.err, new RegExp(`returned #${conflicted} to its builder unreviewed: it no longer merges onto the trunk \\(web/list\\.html\\)`, 'u'), next.out + next.err);+ const item = json(box.run(box.repo, 'show', String(conflicted), '--json'));+ assert.equal(item.item_status, 'open', 'the head that no longer merges goes back, unreviewed');+ assert.equal(item.item_review_by, null, 'no reviewer holds it');+ assert.equal(item.item_verdict, null, 'returning it is not a reject');+ const reopen = item.thread.findLast((entry) => entry.type === 'move' && entry.kind === 'reopen');+ assert.ok(reopen, 'the return is a recorded reopen');+ const inbox = box.run(box.web, 'inbox').out;+ assert.match(inbox, new RegExp(`#${conflicted} went back to you unreviewed: .* no longer merges onto the trunk at [0-9a-f]{12} \\(web/list\\.html\\)\\. Claim it, merge main, resolve that file and submit again: pullboard claim ${conflicted}`, 'u'),+ 'the builder is told the conflicting file and the one step back');+ json(box.run(box.web, 'claim', String(conflicted), '--json'));+});++test('next --verify skips a head that does not merge [C7,V4]', (t) => {+ const { box, json, build, conflicted, reviewer } = staleHeadFixture(t);+ // A second web seat on a fresh branch from main builds work that merges cleanly.+ const second = join(box.dir, 'web-2');+ box.git(box.repo, 'worktree', 'add', '-q', second, '-b', 'web/two', 'main');+ json(box.run(second, 'join', 'web', '--json'));+ const clean = build('Show the footer', 'web/footer.html', '<footer>clean</footer>\n', second);+ const next = json(box.run(reviewer, 'next', '--verify', '--json'));+ assert.equal(next.item.item_id, clean, 'the reviewer gets the head that merges, though the conflicting one is older');+ assert.equal(json(box.run(box.repo, 'show', String(conflicted), '--json')).item_status, 'open');+ assert.equal(json(box.run(box.repo, 'show', String(clean), '--json')).item_review_by !== null, true, 'the clean head is reserved for review');+});