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
chore(merge): integrate accepted trunk conflicts [B3,D1,H16]
Corey Olson80832f09248f
diff --cc docs/formats.mdindex 3ae1cff1,31a2239e..54abc1aa--- a/docs/formats.md+++ b/docs/formats.md@@@ -113,7 -113,7 +113,7 @@@ The board file is in the repository's G| `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` | `36` | `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` | `42` | `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` | `47` | `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.@@@ -134,8 -134,10 +134,12 @@@ Engine 24 adds the person's `acceptChecEngine 30 lets a reject and a reopen carry a cause key (`cause`: `test:<file>::<title>`, `refusal:<CODE>`, `row:<id>` or `doctrine:<id>`) and lets the person record a never-again fact with `cause` and `neverAgain: true`, for `pullboard rigor`. Only a move that carries one of these needs engine 30; engine-29 and older moves replay unchanged, and clients on an older engine refuse an engine-30 move with `RELAY_MOVE` before changing their board or cursor. Engine 20 is the implied-items engine above; engine numbers 21 through 29 are allocated to other changes.- Engine 36 reopens an accepted item that conflicts with the trunk for a main merge. A `reopen` move may carry `conflict: {files, trunk}`: the files that conflict, and the full trunk commit they conflict with. The CLI takes one exact path per `--conflict <file>` flag and splits or trims nothing inside it, so a path with spaces or commas is named as Git reports it in `git merge-tree --write-tree --name-only -z`; `files` holds those exact paths, nonempty and without NUL. The CLI fills `trunk` from Git and refuses `NOT_CONFLICTING` when the accepted commit merges cleanly, or `CONFLICT_FILES` when a named file is not one Git reports as conflicting. The board refuses `NOT_ACCEPTED` unless the item is verified with an accept at its commit, and `BAD_CONFLICT` for a malformed conflict. A conflict needs no note and no landing failure; the event records `supersedes`, the accept it sets aside, `conflict`, and `cause: "refusal:MERGE_CONFLICT"`, never `landingFailure`, so rigor counts it as a merge conflict and never as a failing test. The item reads `needs main merge` until its next verdict, and the re-review checks the frozen check at the new head. A `reopen` move carrying `conflict` requires engine 36, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor; a board replaying an older engine refuses it with `ENGINE_VERSION`. Moves recorded under engines 35 and earlier replay unchanged. Engines 34 and 35 are allocated to other changes; a gap is fine, a reused number is not.+ Engine 38 records submission test selections and normalized landing evidence. A `submit` carrying `submissionProof` or a `recordLandingBatch` carrying `invariantEvidence` requires engine 38; earlier engines refuse these envelopes before applying them, and a missing or malformed proof is refused with `SUBMISSION_PROOF` on a modern submit before its item or events change. Moves recorded under engines 37 and earlier replay without inferred coverage. Recorded invariant evidence is append-only when a landing batch is adopted; adopting or finishing a batch already carrying that evidence requires engine 38, even when the incoming move omits the evidence field. Engine slots 25 through 37 are allocated to earlier train changes; preserve their semantics when composing this item.++ Engine 42 adds ordered `recordHealthFindings` observations. A scan retains its board event revision, emits new and resolved sentinel notices once, and records `health-failure` receipts under their refusal cause keys. Rigor counts repeated health episodes without inventing a changed code commit. Older engines refuse this operation before replay; earlier move meanings and feature minima stay unchanged.+++Engine 47 reopens an accepted item that conflicts with the trunk for a main merge. A `reopen` move may carry `conflict: {files, trunk}`: the files that conflict, and the full trunk commit they conflict with. The CLI takes one exact path per `--conflict <file>` flag and splits or trims nothing inside it, so a path with spaces or commas is named as Git reports it in `git merge-tree --write-tree --name-only -z`; `files` holds those exact paths, nonempty and without NUL. The CLI fills `trunk` from Git and refuses `NOT_CONFLICTING` when the accepted commit merges cleanly, or `CONFLICT_FILES` when a named file is not one Git reports as conflicting. The board refuses `NOT_ACCEPTED` unless the item is verified with an accept at its commit, and `BAD_CONFLICT` for a malformed conflict. A conflict needs no note and no landing failure; the event records `supersedes`, the accept it sets aside, `conflict`, and `cause: "refusal:MERGE_CONFLICT"`, never `landingFailure`, so rigor counts it as a merge conflict and never as a failing test. The item reads `needs main merge` until its next verdict, and the re-review checks the frozen check at the new head. A `reopen` move carrying `conflict` requires engine 47, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor; a board replaying an older engine refuses it with `ENGINE_VERSION`. Moves recorded under engines 46 and earlier replay unchanged. The unlanded feature’s previous allocation was 36; it moved to 47 after the trunk reached engine 42, preserving every landed feature’s engine.+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, includingrevoked or expired tokens. Issuing any machine credential raises that board’s minimum to engine 6, including after revocation or expiry. The minimum survives reopening the auth database;diff --cc docs/lifecycle.mdindex 0b427b54,8f5550ff..5d1d9792--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@@ -159,14 -159,8 +159,15 @@@ Each move checks its guards in this ord| NOTE_REQUIRED | the move carries a note: what failed, what was tried, or why | --note "..." or --note-file <file> || BAD_CAUSE | a cause, when given, is test:<file>::<title>, refusal:<CODE>, row:<id> or doctrine:<id> | fix --cause, or leave it out || ALREADY_MERGED | the item has no recorded merge receipt | a merged item cannot be reopened |+ | SUBMISSION_PROOF | recorded test selection names literal project files and its full-fallback policy, engine 38 or later; absent legacy selection remains unknown | rerun submit with the current CLI |-| LANDING_FAILURE_REQUIRED | a verified item note names the failing test and landing merge commit | cite the recorded batch, or name the test and merge commit in a manual note |+| LANDING_FAILURE_REQUIRED | a verified item note names the failing test and landing merge commit, unless the reopen names a trunk conflict | cite the recorded batch, or name the test and merge commit in a manual note; work that only conflicts with the trunk reopens with --conflict <file> for each conflicting file |+| NOT_CONFLICTING | the accepted commit no longer merges onto the trunk, and every named file is one that conflicts, only for reopen --conflict by the coordinator on accepted, unmerged work | merge it, or reopen after a red landing with --note "<test file>: <test name>; merge commit <sha>" |+| CONFLICT_FILES | the accepted commit no longer merges onto the trunk, and every named file is one that conflicts, only for reopen --conflict by the coordinator on accepted, unmerged work | name only files Git reports as conflicting with the trunk |+| NO_TRUNK | the accepted commit no longer merges onto the trunk, and every named file is one that conflicts, only for reopen --conflict by the coordinator on accepted, unmerged work | check out the trunk branch in the main checkout once and run pullboard inbox |+| MERGE_CHECK_FAILED | the accepted commit no longer merges onto the trunk, and every named file is one that conflicts, only for reopen --conflict by the coordinator on accepted, unmerged work | use Git 2.38 or newer, restore its objects and retry |- | NOT_ACCEPTED | a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 36 or later, only for reopen --conflict | reopen a submission with --note "why" |- | BAD_CONFLICT | a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 36 or later, only for reopen --conflict | run pullboard reopen <id> --conflict <file> from the main checkout |- | ENGINE_VERSION | a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 36 or later, only for reopen --conflict | upgrade Pullboard on every linked device before using --conflict |++| NOT_ACCEPTED | a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 47 or later, only for reopen --conflict | reopen a submission with --note "why" |++| BAD_CONFLICT | a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 47 or later, only for reopen --conflict | run pullboard reopen <id> --conflict <file> from the main checkout |++| ENGINE_VERSION | a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 47 or later, only for reopen --conflict | upgrade Pullboard on every linked device before using --conflict || LAND_HEADER | a displayed merge command fits the commit-header limit (accept result) | shorten the item title or cited rows so the merge header fits || ENGINE_VERSION | a verdict that implies items replays only under engine 20 or later (accept result) | upgrade Pullboard on every linked device before using --implies || LAND_HEADER | a displayed merge command fits the commit-header limit (reject result) | shorten the item title or cited rows so the merge header fits |diff --cc src/board.jsindex ff439337,832eee7b..c8521a3f--- a/src/board.js+++ b/src/board.js@@@ -47,7 -47,12 +47,17 @@@ importrequireNeverAgain,} from './rigor.js';import { barCorrectionFields } from './bar-corrections.js';- import { conflictDetail, conflictNote, conflictProblem } from './trunk-conflict.js';++import {++ conflictDetail,++ conflictNote,++ conflictProblem,++} from './trunk-conflict.js';+ import {+ HEALTH_SENTINEL_ENGINE,+ healthFindingIdentity,+ healthFindingNotice,+ normalizedHealthFindings,+ } from './health-receipts.js';import { factReference } from './fact-reference.js';import {factFromEvent,diff --cc src/engine.jsindex db90f128,67c9f68a..7052c3b3--- a/src/engine.js+++ b/src/engine.js@@@ -13,11 -13,8 +13,12 @@@ importcarriesImplies,IMPLIES_ENGINE,} from './implies.js';+import {+ carriesConflict,+ CONFLICT_ENGINE,+} from './trunk-conflict.js';import { CHECK_ACCEPT_ENGINE } from './check-accept.js';+ import { HEALTH_SENTINEL_ENGINE } from './health-receipts.js';import {CAUSE_ENGINE,ENGINE_VERSION,@@@ -50,10 -52,12 +56,13 @@@ export const ENGINE_OPERATIONS = Object/** Engine version at which each ordered operation first has stable replay semantics. */const OPERATION_ENGINE = Object.freeze({ orderMilestoneItems: MILESTONE_RANK_ENGINE, reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8, acceptCheck: CHECK_ACCEPT_ENGINE });- /** Dependency edits, bar reasons, sealed review metadata and trunk conflicts retain their distinct recorded engine meanings. */-/** Dependency edits, causes, sealed reviews and submission proofs retain distinct recorded engine meanings. */++/** Dependency edits, causes, sealed reviews, submission proofs and trunk conflicts retain distinct recorded engine meanings. */function minimumOperationEngine(operation, args, board) {+ if (operation === 'recordHealthFindings') return HEALTH_SENTINEL_ENGINE;const options = args[1];+ if (carriesConflict(operation, args)) return 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);if (board && ['recordLandingBatch', 'finishLandingBatch'].includes(operation)) {const id = operation === 'recordLandingBatch' ? args[0]?.batch?.id : args[0]?.id;diff --cc src/machine.jsindex c73a6509,e11f776b..ba43fefe--- a/src/machine.js+++ b/src/machine.js@@@ -10,7 -10,7 +10,7 @@@*//** Executable move semantics, carried by every sealed move and retained during replay [H16]. */- export const ENGINE_VERSION = 36;-export const ENGINE_VERSION = 42;++export const ENGINE_VERSION = 47;/** The engine at which a reject, reopen or person fact can carry a cause key (#713); older moves replay unchanged [D1,H16]. */export const CAUSE_ENGINE = 30;@@@ -154,9 -154,8 +154,10 @@@ export const GUARDS ={ id: 'noteGiven', refuse: 'NOTE_REQUIRED', rule: 'the move carries a note: what failed, what was tried, or why', next: '--note "..." or --note-file <file>', source: 'board' },{ id: 'causeWellFormed', refuse: 'BAD_CAUSE', rule: 'a cause, when given, is test:<file>::<title>, refusal:<CODE>, row:<id> or doctrine:<id>', next: 'fix --cause, or leave it out', source: 'board' },{ id: 'notMerged', refuse: 'ALREADY_MERGED', rule: 'the item has no recorded merge receipt', next: 'a merged item cannot be reopened', source: 'board' },+ { id: 'submissionProofValid', refuse: 'SUBMISSION_PROOF', rule: 'recorded test selection names literal project files and its full-fallback policy', next: 'rerun submit with the current CLI', source: 'board', when: 'engine 38 or later; absent legacy selection remains unknown' },- { id: 'landingFailureRecorded', refuse: 'LANDING_FAILURE_REQUIRED', rule: 'a verified item note names the failing test and landing merge commit', next: 'cite the recorded batch, or name the test and merge commit in a manual note', source: 'board' },+ { id: 'landingFailureRecorded', refuse: 'LANDING_FAILURE_REQUIRED', rule: 'a verified item note names the failing test and landing merge commit', next: 'cite the recorded batch, or name the test and merge commit in a manual note; work that only conflicts with the trunk reopens with --conflict <file> for each conflicting file', source: 'board', when: 'unless the reopen names a trunk conflict' },+ { id: 'trunkConflicts', refuse: 'NOT_CONFLICTING', alsoRefuses: [{ code: 'CONFLICT_FILES', next: 'name only files Git reports as conflicting with the trunk' }, { code: 'NO_TRUNK', next: 'check out the trunk branch in the main checkout once and run pullboard inbox' }, { code: 'MERGE_CHECK_FAILED', next: 'use Git 2.38 or newer, restore its objects and retry' }], rule: 'the accepted commit no longer merges onto the trunk, and every named file is one that conflicts', next: 'merge it, or reopen after a red landing with --note "<test file>: <test name>; merge commit <sha>"', source: 'cli', when: 'only for reopen --conflict by the coordinator on accepted, unmerged work' },- { id: 'conflictAccepted', refuse: 'NOT_ACCEPTED', alsoRefuses: [{ code: 'BAD_CONFLICT', next: 'run pullboard reopen <id> --conflict <file> from the main checkout' }, { code: 'ENGINE_VERSION', next: 'upgrade Pullboard on every linked device before using --conflict' }], rule: 'a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 36 or later', next: 'reopen a submission with --note "why"', source: 'board', when: 'only for reopen --conflict' },++ { id: 'conflictAccepted', refuse: 'NOT_ACCEPTED', alsoRefuses: [{ code: 'BAD_CONFLICT', next: 'run pullboard reopen <id> --conflict <file> from the main checkout' }, { code: 'ENGINE_VERSION', next: 'upgrade Pullboard on every linked device before using --conflict' }], rule: 'a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 47 or later', next: 'reopen a submission with --note "why"', source: 'board', when: 'only for reopen --conflict' },];/** @type {Move[]} */diff --cc src/trunk-conflict.jsindex 4bb74515,00000000..618d324fmode 100644,000000..100644--- a/src/trunk-conflict.js+++ b/src/trunk-conflict.js@@@ -1,195 -1,0 +1,195 @@@+/**+ * An accepted item that conflicts with the trunk reopens for a main merge [B3,D1].+ *+ * When two accepted items touch the same lines, the second no longer merges onto the trunk. That+ * is not a failed test and not a reject: the work was accepted and only needs main merged into+ * it. `pullboard reopen <id> --conflict <file>` (once per file) records exactly that, naming the conflicting+ * files and the trunk commit they conflict with, and keeps the original accept on record. The+ * 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 { Refused } from './refused.js';++/** The engine whose reopen may carry a trunk conflict; older engines refuse it before replay. */- export const CONFLICT_ENGINE = 36;++export const CONFLICT_ENGINE = 47;++/** The label an item carries from a conflict reopen until its next verdict. */+export const MAIN_MERGE_LABEL = 'needs main merge';++/**+ * True when a sealed move carries this engine's meaning, a trunk conflict on a reopen.+ *+ * @param {string} operation+ * @param {any[]} args+ * @returns {boolean}+ */+export function carriesConflict(operation, args) {+ return operation === 'reopen' && args?.[1]?.conflict !== undefined && args?.[1]?.conflict !== null;+}++/**+ * The file paths `--conflict` names: one exact path per flag, in order, without repeats. Nothing is+ * split or trimmed inside a value, because a Git path may hold spaces, commas or any byte but NUL,+ * and it must match the path `git merge-tree -z` reports byte for byte.+ *+ * @param {string | string[] | undefined} values - one value per --conflict flag+ * @returns {string[]}+ */+export function conflictFiles(values) {+ return [...new Set([values ?? []].flat())];+}++/**+ * A path as a reader sees it in a message or line: plain when it holds only ordinary path+ * characters, otherwise JSON-quoted, so a space or comma inside a name never reads as two names.+ *+ * @param {string} path+ * @returns {string}+ */+export function shownPath(path) {+ return /^[\w./@+-]+$/u.test(path) ? path : JSON.stringify(path);+}++/** Paths for a message or line, each shown unambiguously, separated by commas. */+const shownPaths = (paths) => paths.map(shownPath).join(', ');++/**+ * Check the trunk for the conflict the coordinator names, so --conflict cannot stand in for a+ * landing failure note on work that merges cleanly. Every named file must be one Git reports as+ * conflicting; the trunk commit comes from Git, never from the caller.+ *+ * @param {(commit: string) => { ref: string, commit: string, files: string[] | null }} trunkMerge - merges onto the trunk in memory+ * @param {string} commit - the accepted commit+ * @param {string[]} files - the files the coordinator names+ * @returns {{ files: string[], trunk: string }}+ */+export function requireTrunkConflict(trunkMerge, commit, files) {+ if (!files.length || files.some((file) => !file || file.includes('\0'))) throw new Refused('CONFLICT_FILES', 'name each file that conflicts with its own flag: pullboard reopen <id> --conflict <file> [--conflict <file>]');+ const merge = trunkMerge(commit);+ const branch = merge.ref.replace(/^refs\/heads\//u, '');+ if (!merge.files) throw new Refused('NOT_CONFLICTING', `${commit.slice(0, 12)} merges cleanly onto ${branch} at ${merge.commit.slice(0, 12)}; merge it, or reopen with --note "<test file>: <test name>; merge commit <sha>" after a red landing`);+ const unknown = files.filter((file) => !merge.files.includes(file));+ if (unknown.length) throw new Refused('CONFLICT_FILES', `${shownPaths(unknown)} ${unknown.length === 1 ? 'does' : 'do'} not conflict with ${branch} at ${merge.commit.slice(0, 12)}; the conflicting files are ${shownPaths(merge.files) || 'unnamed'}; name each with its own --conflict <file>`);+ return { files, trunk: merge.commit };+}++/**+ * The conflict a coordinator's `--conflict` names, with the trunk commit Git reports. Anyone else,+ * or an item that is not accepted and unmerged, gets the files alone, so the board's own guards+ * refuse it in their declared order (COORDINATOR_ONLY, NOT_SUBMITTED, ALREADY_MERGED, NOT_ACCEPTED).+ *+ * @param {{ item: any, coordinator: boolean, values: string | string[] | undefined, trunkMerge: (commit: string) => { ref: string, commit: string, files: string[] | null } }} request+ * @returns {{ files: string[], trunk: string | null }}+ */+export function reopenConflict({ item, coordinator, values, trunkMerge }) {+ const files = conflictFiles(values);+ if (!coordinator || item.item_status !== 'verified' || item.item_merged_commit || !item.item_commit) return { files, trunk: null };+ return requireTrunkConflict(trunkMerge, item.item_commit, files);+}++/**+ * The refusal for a conflict reopen the board cannot record, or null. A conflict reopens only an+ * accepted item, and only under this engine; it names its files and a full trunk commit.+ *+ * @param {any} board+ * @param {any} item+ * @param {unknown} conflict+ * @param {(accept: number) => void} found - receives the id of the accept the reopen sets aside+ * @returns {Refused | null}+ */+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"`);+ 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');+ }+ 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);+ return null;+}++/**+ * The cause key a trunk conflict records: the refusal Pullboard gives work that no longer merges.+ * Rigor (#713) reads cause keys and never counts a merge conflict, so a conflict reopen is never a+ * failing test, nor an uncaused reopen; two branches touching the same lines is no rule to learn.+ */+export const TRUNK_CONFLICT_CAUSE = 'refusal:MERGE_CONFLICT';++/**+ * The event fields a conflict reopen records: the conflict itself and its cause key.+ *+ * @param {{ files: string[], trunk: string }} conflict+ * @returns {{ conflict: { files: string[], trunk: string }, cause: string }}+ */+export function conflictDetail({ files, trunk }) {+ return { conflict: { files, trunk }, cause: TRUNK_CONFLICT_CAUSE };+}++/** The note a conflict reopen records when the coordinator gives none. */+export function conflictNote({ files, trunk }) {+ return `conflicts with the trunk at ${trunk.slice(0, 12)} in ${shownPaths(files)}; merge main and resubmit`;+}++/**+ * The trunk conflict an item still carries, or null: the newest reopen, accept or reject on it is+ * a conflict reopen. It names the accept it set aside, so the re-review knows what already passed.+ *+ * @param {any} board+ * @param {number} id+ * @returns {{ files: string[], trunk: string, commit: string, at: string, accept: { by: string, commit: string } | null } | null}+ */+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,+ accept: accept ? { by: accept.event_by, commit: JSON.parse(accept.event_detail).commit } : null };+}++/**+ * The lines `pullboard show` prints for an item that needs a main merge: what conflicts, then+ * what to do now, for the builder before resubmitting and for the reviewer after.+ *+ * @param {any} item+ * @param {NonNullable<ReturnType<typeof mainMergeFor>>} merge+ * @param {(id: string) => string} [name]+ * @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 head = `${MAIN_MERGE_LABEL}: ${accepted}; conflicts with the trunk at ${merge.trunk.slice(0, 12)} in ${shownPaths(merge.files)}`;+ 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}`];+}++/**+ * The items among `items` that still need a main merge, each with its conflict, for resume.+ *+ * @param {any} board+ * @param {any[]} items+ * @returns {{ item: any, merge: NonNullable<ReturnType<typeof mainMergeFor>> }[]}+ */+export function mainMergesFor(board, items) {+ return items.map((item) => ({ item, merge: mainMergeFor(board, item.item_id) })).filter(({ merge }) => merge);+}++/**+ * The line `pullboard reopen` prints: for a main merge, after a landing failure, or without a verdict.+ *+ * @param {string} id+ * @param {{ commit: string, conflict?: { files: string[], trunk: string }, landingFailure?: object }} result+ * @returns {string}+ */+export function reopenedLine(id, result) {+ if (result.conflict) return `reopened #${id} for a main merge: conflicts with the trunk at ${result.conflict.trunk.slice(0, 12)} in ${shownPaths(result.conflict.files)}; the accept at ${result.commit.slice(0, 12)} stays recorded`;+ return result.landingFailure+ ? `reopened #${id} after landing failure; previous accept remains recorded at ${result.commit.slice(0, 12)}`+ : `reopened #${id} without a verdict; previous commit ${result.commit.slice(0, 12)} remains recorded`;+}diff --cc test/agent-model-engine.test.jsindex 3d6edd00,31861391..ea5a441b--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@@ -1,3 -1,4 +1,5 @@@++import { CONFLICT_ENGINE } from '../src/trunk-conflict.js';+ import { HEALTH_SENTINEL_ENGINE } from '../src/health-receipts.js';/** Declared models replay with their recorded engine and survive board exchange [O8,O3,H16]. */import assert from 'node:assert/strict';import { test } from 'node:test';@@@ -10,8 -11,8 +12,9 @@@ import { mkdtempSync, rmSync, writeFileimport { tmpdir } from 'node:os';import { join } from 'node:path';- test('model declarations and event snapshots retain engines 1 through 33 semantics [O8,O3,H16]', (t) => {- assert.equal(ENGINE_VERSION, 36, 'the next writer preserves every historical model snapshot through engine 36');+ test('model declarations and event snapshots retain engines 1 through 34 semantics [O8,O3,H16]', (t) => {+ assert.ok(ENGINE_VERSION >= HEALTH_SENTINEL_ENGINE, 'the current writer retains the sentinel minimum and historical behavior');++ assert.ok(ENGINE_VERSION >= CONFLICT_ENGINE, 'the writer retains the trunk-conflict feature minimum');for (const version of Array.from({ length: ENGINE_VERSION }, (_, index) => index + 1)) {const board = store.openBoard(':memory:');t.after(() => store.closeBoard(board));diff --cc test/pending-refreeze.test.jsindex a06023be,f9a15d76..3c23eff1--- a/test/pending-refreeze.test.js+++ b/test/pending-refreeze.test.js@@@ -1,3 -1,4 +1,5 @@@++import { CONFLICT_ENGINE } from '../src/trunk-conflict.js';+ import { HEALTH_SENTINEL_ENGINE } from '../src/health-receipts.js';/** Pending coordinator corrections keep a live claim until its frozen bar is adopted [V2,H16]. */import assert from 'node:assert/strict';import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';@@@ -261,7 -262,7 +263,8 @@@ async function checkDependencyLegacyCli}test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {- assert.equal(ENGINE_VERSION, 36, 'the next writer retains all recorded dependency-edit behavior');+ assert.ok(ENGINE_VERSION >= HEALTH_SENTINEL_ENGINE, 'the current writer retains the sentinel minimum and historical behavior');++ assert.ok(ENGINE_VERSION >= CONFLICT_ENGINE, 'the writer retains the trunk-conflict feature minimum');const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));const cleanup = [];t.after(() => {