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(rigor): notice a repeated failure cause [D1,V1]
Corey Olson313d14edf229
diff --git a/docs/api.md b/docs/api.mdindex fd626f8b..639d98e1 100644--- a/docs/api.md+++ b/docs/api.md@@ -74,6 +74,7 @@ For example: `flow: review wait average 61 min (1 measured; > 60 min); bottlenec| `decisions` | `version:number`, `decisions:array` || `ledger` | `version:number`, `items:array`, `stats:object` || `log` | `version:number`, `events:array` |+| `rigor` | `version:number`, `causes:array`, `uncaused:number` || `add` | `version:number`, `item:object` || `edit` | `version:number`, `item:object` || `fact` | `version:number`, `item:number`, `fact:object` |@@ -152,6 +153,14 @@ A correction is a new fact with `--supersedes <fact-id>`. It requires the live hThe HTTP move is `{verb: "fact", item: 12, agent: "web-1", args: {kind: "measurement", text: "The check takes 8 seconds", ref: "src/file.js:12-30@<full-sha>"}}`. Omit `agent` to act as the coordinator; `args.supersedes` supplies a correction's earlier fact identity. The response carries the committed `fact` event and the CLI result. The event-log format stays at version 1 because facts use its existing immutable event rows; exports and imports preserve those rows. The sealed move engine advances to version 3 for this release so older engines refuse the new operation before replay.+## Rigor++Rigor is how errors become doctrine or specs. It starts by noticing a failure cause that repeats. A cause key comes only from structured fields: `test:<file>::<title>`, `refusal:<CODE>`, `row:<id>` or `doctrine:<id>`. A reject (`verify <id> reject ... --cause <key>`) and a `reopen <id> --note "..." --cause <key>` record the key they name as `cause` in their event detail. A reopen after a red landing also gives one `test:` key per failing test in its `landingFailure.tests`, including reopens recorded before cause keys existed. Notes are never parsed, so an older reject with no cause counts as uncaused. A malformed key is refused with `BAD_CAUSE` before the move. Merge conflicts never count: a landing test whose name starts with `conflicts with`, and `refusal:MERGE_CONFLICT`.++`pullboard rigor` is read-only. It lists each cause that repeated: on 2 items, or on 1 item at 2 different commits. Each line shows the key, how it reads (`work` for `doctrine:` and `refusal:`, `product` for `row:`, `both` for `test:`), its failure count and its items. Its JSON result is `{version, causes: [{key, reads, occurrences, neverAgain, items: [{id, commits}]}], uncaused}`; `uncaused` counts rejects and reopens with no cause key.++The person can mark a cause never-again from the main checkout's terminal: `pullboard fact <id> root-cause "<why>" --cause <key> --never-again --as person`. The fact is recorded as the person's, carries `cause` and `neverAgain: true`, and `rigor` lists its cause at once. An agent or a fact without `--as person` is refused with `RIGOR_PERSON_ONLY`. A move that carries a cause key needs move engine 13; moves without one replay as before.+## RefusalsA refusal keeps the command's existing exit status and prints exactly one versioned document to stdout. In JSON mode stderr stays empty except for sign-in instructions and check consent notices. The command-specific `code` identifies the rule; `message` explains what happened; `next` gives the next step.@@ -265,7 +274,7 @@ The coordinator maintains the roadmap with `milestone add <name> [--note ...] [-| `stream` | `version:number`, `event:object` |<!-- api-http-shapes:end -->-A move body is `{verb, item, args, agent}`. `item` is the positive integer id when the move needs one. `args` names its CLI positional arguments and flags; text values stay literal, including leading dashes. Omit `agent` to act as the coordinator, or name a registered agent to run in its worktree. Coordinator verification takes `args.as: "coordinator"`, matching the CLI's explicit identity check. The local session secret may act as any agent on that board. `result` is the CLI's JSON result. `next` claims work atomically; when a claim is already held it renews it and returns the renewal event. With no work available it returns the CLI's `NOTHING_FREE` refusal. Waiting remains a CLI option. `reopen` is coordinator-only: `args.note` is required, and it returns a submitted item to open without adding a verdict or replacing its last submitted commit.+A move body is `{verb, item, args, agent}`. `item` is the positive integer id when the move needs one. `args` names its CLI positional arguments and flags; text values stay literal, including leading dashes. Omit `agent` to act as the coordinator, or name a registered agent to run in its worktree. Coordinator verification takes `args.as: "coordinator"`, matching the CLI's explicit identity check. The local session secret may act as any agent on that board. `result` is the CLI's JSON result. `next` claims work atomically; when a claim is already held it renews it and returns the renewal event. With no work available it returns the CLI's `NOTHING_FREE` refusal. Waiting remains a CLI option. `reopen` is coordinator-only: `args.note` is required, and it returns a submitted item to open without adding a verdict or replacing its last submitted commit. A reject (`verify` with `decision: "reject"`) and a `reopen` may name `args.cause`, the failure's cause key for `pullboard rigor`.Decision moves keep the CLI's routing: `shout` with `args.decision: true` may omit `args.to`; agents ask their coordinator, and the coordinator asks the person. `pass` takes the decision's id as `item` and `args.note`. Answering a decision addressed to the person requires `answer` with `args.as: "person"` from the coordinator's main checkout. Other callers receive the CLI's refusal.diff --git a/docs/formats.md b/docs/formats.mdindex c3797a6c..e1d1cd7d 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -102,7 +102,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` | `12` | `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` | `13` | `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.@@ -113,6 +113,8 @@ Engine 11 permits resubmitting the same commit after a coordinator no-verdict reEngine 12 records declined person row decisions without replacing the exact source text: the row becomes `wont` and the reason stays in the decision record. Engine-11 decline receipts retain their original reason-as-row-text validation and replay outcome. Engine-11 clients refuse engine-12 moves before interpreting them; upgrade linked clients before recording new decline decisions.+Engine 13 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 13; engine-12 and older moves replay unchanged, and engine-12 clients refuse an engine-13 move before interpreting it.+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 --git a/docs/lifecycle.md b/docs/lifecycle.mdindex b2af58f0..4842b510 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -57,8 +57,8 @@ Each move checks its guards in this order and refuses with the first one that do| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), 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), noUnverifiedStack (STACKED_ON_UNVERIFIED), gateConfigured (NO_GATE), gateGreen (GATE_RED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) || reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), roadmapReadable (MILESTONES_CORRUPT), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) || accept | submitted | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED) |-| reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED) |-| reopen | submitted, verified | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED) |+| reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE) |+| reopen | submitted, verified | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED) || escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED) || refreeze | open, claimed, submitted | open | coordinator, when there is no live claim awaiting a coordinator correction | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) || refreeze | claimed | claimed | agent, coordinator, when a live claim has a pending coordinator correction | joined (NOT_JOINED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |@@ -142,6 +142,7 @@ Each move checks its guards in this order and refuses with the first one that do| NOTE_REQUIRED | a review release gives a nonempty one-line reason, engine 5 or newer, only when freeing a submitted review reservation | release with --note "why", or --note-file <file> || REVIEW_COOLDOWN | the reviewer has not released this submission within the past hour, engine 5 or newer, only for the same reviewer and current submission | let another reviewer take it, or wait an hour or for a new submission || 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 || 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 || BAD_DECISION | a verdict is accept or reject | pullboard verify <id> accept, or reject --reason CODE --note "..." |diff --git a/src/api-moves.js b/src/api-moves.jsindex 51dc394c..14975502 100644--- a/src/api-moves.js+++ b/src/api-moves.js@@ -12,11 +12,11 @@ const MOVES = {release: { item: true, flags: ['note'] },submit: { item: true },done: { item: true },- verify: { item: true, positions: ['decision'], flags: ['reason', 'note', 'as'] },+ verify: { item: true, positions: ['decision'], flags: ['reason', 'note', 'cause', 'as'] },merged: { item: true, positions: ['commit'] },withdraw: { item: true, positions: ['reason'] },refreeze: { item: true },- reopen: { item: true, flags: ['note'] },+ reopen: { item: true, flags: ['note', 'cause'] },escalate: { item: true, flags: ['note'] },hold: { positions: ['lane'], flags: ['reason'], booleans: ['off'] },shout: { positions: ['to', 'text'], optional: ['to'], booleans: ['decision'], flags: ['evidence', 'outcome', 'item', 'commit'] },diff --git a/src/board.js b/src/board.jsindex 025ae554..043a1367 100644--- a/src/board.js+++ b/src/board.js@@ -14,6 +14,7 @@ import { briefFiles, briefSections } from './brief.js';import { COORDINATOR } from './config.js';import { ENGINE_VERSION, GUARDS, IN_STATE, MOVES, STATES, UNKNOWN_MOVE, effectiveGuards, storeTriggers } from './machine.js';import { Refused } from './refused.js';+import { causeProblem, requireNeverAgain } from './rigor.js';import { parseSpec } from './spec.js';export const ACCEPT_REASON = 'CRITERION_MET';@@ -1474,14 +1475,14 @@ function reserveWithin(board, id, { agentId, leaseMs, policy, familyPolicy = 'of* claimed again. The builder never verifies; under `verify: "coordinator"`, lane work is the* coordinator's to verify; an agent verifies items at its tier or below, and not while another* agent holds the review (V15). An accept means CRITERION_MET and says how it was proved; a reject- * names one of the reject reasons and says what failed.+ * names one of the reject reasons and says what failed, and may name its cause key for rigor (#713).** @param {any} board* @param {number} id- * @param {{ agentId: string, decision: string, reason?: string, note?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green' }} verdict+ * @param {{ agentId: string, decision: string, reason?: string, note?: string, cause?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green' }} verdict* @returns {{ decision: string, reason: string, check?: 'none' | 'green' }}*/-export function verify(board, id, { agentId, decision, reason, note = '', head, digest, policy, familyPolicy = 'off', check }) {+export function verify(board, id, { agentId, decision, reason, note = '', cause, head, digest, policy, familyPolicy = 'off', check }) {const verb = { ACCEPT: 'accept', REJECT: 'reject' }[decision];if (!verb) throw new Refused('BAD_DECISION', 'the decision is accept or reject');const isAccept = verb === 'accept';@@ -1508,6 +1509,7 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,: new Refused('PROOF_REQUIRED', 'an accept says how you proved it: --note "what you broke or which edge you tried, and what happened"; passing tests alone are not proof'),reasonCoded: () => (reason && REJECT_REASONS.includes(reason) ? null : new Refused('BAD_REASON', `a reject names one of: ${REJECT_REASONS.join(', ')}`)),noteGiven: () => (note.trim() ? null : new Refused('NOTE_REQUIRED', 'a reject says what failed: --note "..."')),+ causeWellFormed: () => causeProblem(cause),},before: (found) => {const family = board.db.prepare('SELECT agent_family FROM agent WHERE agent_id = ?').get(agentId)?.agent_family ?? null;@@ -1521,7 +1523,7 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,},set: (found) => ({ item_verdict: decision, item_verified_by: isAccept ? agentId : null, item_owner: isAccept ? found.item_owner : null }),});- const detail = { reason: code, commit: item.item_commit };+ const detail = { reason: code, commit: item.item_commit, ...(!isAccept && cause !== undefined && cause !== null ? { cause } : {}) };if (isAccept && check !== undefined) detail.check = check;logEvent(board, agentId, verb, id, detail);return { decision, reason: code, ...(isAccept && check !== undefined ? { check } : {}) };@@ -1533,10 +1535,10 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,** @param {any} board* @param {number} id- * @param {{ agentId: string, note: string }} request+ * @param {{ agentId: string, note: string, cause?: string }} request* @returns {{ id: number, commit: string, supersedes?: number, landingFailure?: object }}*/-export function reopen(board, id, { agentId, note }) {+export function reopen(board, id, { agentId, note, cause }) {return atomic(board, () => {let submittedCommit = null;let supersedes;@@ -1551,6 +1553,7 @@ export function reopen(board, id, { agentId, note }) {[IN_STATE]: (found) => new Refused('NOT_SUBMITTED', `item #${id} is ${current(board, found).item_status}, not submitted`),coordinatorOnly: () => onlyCoordinator(agentId, 'reopens submissions'),noteGiven: () => (note.trim() ? null : new Refused('NOTE_REQUIRED', 'say why the criterion needs correction: --note "why"')),+ causeWellFormed: () => causeProblem(cause),notMerged: (found) => found.item_status !== 'verified' || !found.item_merged_commit? null: new Refused('ALREADY_MERGED', `item #${id} was merged as ${found.item_merged_commit}; merged items cannot be reopened`),@@ -1587,7 +1590,7 @@ export function reopen(board, id, { agentId, note }) {},});logEvent(board, agentId, 'reopen', id, { commit: submittedCommit, note: note.trim(), judgment: null,- ...(supersedes ? { supersedes, landingFailure } : {}) });+ ...(supersedes ? { supersedes, landingFailure } : {}), ...(cause !== undefined && cause !== null ? { cause } : {}) });return { id: item.item_id, commit: submittedCommit, ...(supersedes ? { supersedes, landingFailure } : {}) };});}@@ -2074,11 +2077,11 @@ export function factReference(ref) {return { path, start, end, commit: commit.toLowerCase() };}-/** Give facts the same stamped identity on CLI, API, export and replica reads [B29,B31]. */+/** Give facts the same stamped identity on CLI, API, export and replica reads; a never-again keeps its cause [B29,B31,D1]. */function factFromEvent(event) {const detail = JSON.parse(event.event_detail);return { id: detail.id, eventId: event.event_id, kind: detail.kind, text: detail.text,- by: event.event_by, at: event.event_at, ref: detail.ref ?? null, supersedes: detail.supersedes ?? null };+ by: event.event_by, at: event.event_at, ref: detail.ref ?? null, supersedes: detail.supersedes ?? null, ...(detail.neverAgain ? { cause: detail.cause, neverAgain: true } : {}) };}/** Read every move and fact in append order, including superseded facts and full original text [B31,B32]. */@@ -2097,8 +2100,8 @@ export function projectItemThreads(board, state) {/** Append a typed fact atomically; a correction never edits the original event [B29,B30,B31,B32].* The internal factId is set from a sealed move's identity during replay, rather than replica-local sequence ids.- */-export function appendFact(board, id, { agentId, kind, text, ref = null, supersedes = null, factId = randomUUID() }) {+ * A never-again with its cause is the person's alone, and rigor lists it at once (#713) [D1]. */+export function appendFact(board, id, { agentId, kind, text, ref = null, supersedes = null, factId = randomUUID(), cause = null, neverAgain = false, asPerson = false, channel = 'terminal' }) {return atomic(board, () => {const item = current(board, itemById(board, id));if (!board.db.prepare('SELECT 1 FROM agent WHERE agent_id = ?').get(agentId)) throw new Refused('NO_AGENT', `no registered agent ${agentId}; join a worktree before appending a fact`);@@ -2113,7 +2116,8 @@ export function appendFact(board, id, { agentId, kind, text, ref = null, supersethrow new Refused('NO_FACT', `no fact ${String(supersedes)} on item #${id}; use a fact id from pullboard show ${id} --json`);}const binding = factReference(ref);- logEvent(board, agentId, 'fact', id, { id: factId, kind, text, ref: binding, supersedes });+ if (neverAgain || asPerson || cause !== null) requireNeverAgain(id, { agentId, cause, neverAgain, asPerson, channel });+ logEvent(board, neverAgain ? PERSON : agentId, 'fact', id, { id: factId, kind, text, ref: binding, supersedes, ...(neverAgain ? { cause, neverAgain: true, channel } : {}) });return factFromEvent(board.lastEvent);});}diff --git a/src/cli.js b/src/cli.jsindex 950ef125..c182b7f0 100644--- a/src/cli.js+++ b/src/cli.js@@ -70,6 +70,7 @@ import { tour } from './tour.js';import { commandOutput, refusalDocument } from './json.js';import { forgetProject, listApiProjects, registerProjectAndLink } from './projects.js';import { milestoneRoadmap } from './roadmap.js';+import { rigorLines, rigorReport } from './rigor.js';import { listResources, runnerResourceStatus } from './resources.js';import { citedTestFiles, rowEvidence, rowStage } from './evidence.js';import { exportView, serveView } from './serve.js';@@ -298,6 +299,8 @@ const OPTIONS = {commit: { type: 'string' },ref: { type: 'string' },supersedes: { type: 'string' },+ cause: { type: 'string' },+ 'never-again': { type: 'boolean' },help: { type: 'boolean', short: 'h' },version: { type: 'boolean', short: 'v' },};@@ -439,7 +442,7 @@ function checkMainVerifier(ctx, board, values) {*/function personMode(ctx, me, values) {if (values.as === undefined) return false;- if (values.as !== 'person') throw new Refused('USAGE', '--as person is supported for answer and decisions');+ if (values.as !== 'person') throw new Refused('USAGE', '--as person is supported for answer, decisions and fact --never-again');if (!ctx.info.isMain || me.id !== COORDINATOR) {throw new Refused('B26_PERSON_ANSWER', 'only the main checkout can act as the person; ask your coordinator to answer or pass this decision');}@@ -2135,6 +2138,14 @@ function readCommands(io, { first, second, rest, values }) {}return 0;},+ rigor: () => {+ if (first || second || rest.length) throw new Refused('USAGE', 'pullboard rigor takes no arguments');+ const ctx = context(io);+ const report = withBoard(ctx, (board) => rigorReport(store.events(board), { person: store.PERSON }));+ io.result?.(report);+ for (const line of rigorLines(report)) io.say(line);+ return 0;+ },log: () => {const ctx = context(io);const itemId = first ? idArg(first) : undefined;@@ -2397,7 +2408,7 @@ async function verifyHere(ctx, id, { second, values }) {const previous = recovered?.args[1];if (recovered?.operation === 'verify' && recovered.args[0] === id && previous?.agentId === me.id &&previous.decision === decision && previous.reason === values.reason &&- previous.note === (textArg(ctx.io, values, 'note') ?? '')) {+ previous.note === (textArg(ctx.io, values, 'note') ?? '') && previous.cause === (decision === 'REJECT' ? values.cause : undefined)) {if (decision === 'ACCEPT' && !recordedRecovery(board, recovered)) {const item = store.getItem(board, id);const commit = resolveCommit(root, item.item_commit);@@ -2449,6 +2460,7 @@ async function verifyHere(ctx, id, { second, values }) {decision,reason: values.reason,note: textArg(ctx.io, values, 'note') ?? '',+ ...(decision === 'REJECT' && values.cause !== undefined ? { cause: values.cause } : {}),head,digest,policy: ctx.config.verify.policy,@@ -2676,10 +2688,14 @@ function workCommands(io, args) {return 0;}),fact: () => act(async (ctx, board, me) => {- if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha]');+ if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha] [--cause <key> --never-again --as person]');const id = idArg(first);+ const asPerson = values.as === 'person' && personMode(ctx, me, values);+ if (asPerson) requirePersonChannel(ctx.io.personChannel);+ const marked = asPerson || values['never-again'] || values.cause !== undefined+ ? { cause: values.cause ?? null, neverAgain: Boolean(values['never-again']), asPerson, channel: ctx.io.personChannel ?? 'terminal' } : {};const fact = await ordered(ctx, board, 'appendFact', [id, { agentId: me.id, kind: second,- text: rest[0], supersedes: values.supersedes ?? null, ref: values.ref ?? null }]);+ text: rest[0], supersedes: values.supersedes ?? null, ref: values.ref ?? null, ...marked }]);io.result?.({ item: id, fact });io.say(`fact ${fact.id} appended to #${id} as ${fact.kind}`);return 0;@@ -2977,7 +2993,8 @@ function workCommands(io, args) {return 0;}),reopen: () => act(async (ctx, board, me) => {- const result = await ordered(ctx, board, 'reopen', [idArg(first), { agentId: me.id, note: textArg(io, values, 'note') ?? '' }]);+ const result = await ordered(ctx, board, 'reopen', [idArg(first), { agentId: me.id, note: textArg(io, values, 'note') ?? '',+ ...(values.cause !== undefined ? { cause: values.cause } : {}) }]);io.result?.(result);io.say(result.landingFailure? `reopened #${first} after landing failure; previous accept remains recorded at ${result.commit.slice(0, 12)}`@@ -3500,8 +3517,8 @@ async function runCommand(argv, io) {}const args = { first, second, rest, values };try {- if (values.as === 'person' && !['answer', 'decisions'].includes(command)) {- throw new Refused('USAGE', '--as person works only with pullboard answer or decisions');+ if (values.as === 'person' && !['answer', 'decisions', 'fact'].includes(command)) {+ throw new Refused('USAGE', '--as person works only with pullboard answer, decisions, or fact --never-again');}if (command === 'tour') return tour(io);if (command === 'lifecycle') {diff --git a/src/engine.js b/src/engine.jsindex 4948b094..5b6dc297 100644--- a/src/engine.js+++ b/src/engine.js@@ -2,7 +2,7 @@import { createHash, randomUUID } from 'node:crypto';import * as store from './board.js';import { recordedRefusal } from './recorded-refusal.js';-import { ENGINE_VERSION } from './machine.js';+import { CAUSE_ENGINE, ENGINE_VERSION } from './machine.js';import { Refused } from './refused.js';import { requestMoveProblem, recordRequestMove } from './relay-requests.js';import { relayMoveActor, relaySenderProblem, validRelaySender } from './relay-sender.js';@@ -22,9 +22,13 @@ export const ENGINE_OPERATIONS = Object.freeze([/** Engine version at which each ordered operation first has stable replay semantics. */const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8 });-/** Dependency edits add engine-10 meaning without changing ordinary historical edit envelopes. */+/** Dependency edits add engine-10 meaning without changing ordinary historical edit envelopes;+ * a cause key on a reject, reopen or person fact adds engine-13 meaning the same way (#713).+ */function minimumOperationEngine(operation, args) {const options = args[1];+ const given = (name) => Boolean(options && typeof options === 'object' && Object.hasOwn(options, name) && options[name] !== undefined && options[name] !== null && options[name] !== false);+ if (['verify', 'reopen', 'appendFact'].includes(operation) && (given('cause') || given('neverAgain') || given('asPerson'))) return CAUSE_ENGINE;return operation === 'editItem' && options && Object.hasOwn(options, 'after') && options.after !== undefined? 10 : OPERATION_ENGINE[operation] ?? 1;}diff --git a/src/help.js b/src/help.jsindex 7d2958d2..5197abe7 100644--- a/src/help.js+++ b/src/help.js@@ -75,6 +75,7 @@ Workearlier ones as one line; --history prints every note in fullpullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha]append an observation or a holder/coordinator judgement to its thread+ the person adds --cause <key> --never-again --as person: rigor lists it at oncepullboard next [--wait <minutes>] offer an eligible review when reviews pile up, otherwise claim workpullboard next --build claim a build explicitly, recording a skipped review offerpullboard next --verify reserve the next submitted item you can check;@@ -86,7 +87,8 @@ Workpullboard release <id> [--note "why"] hand it back; a review release needs a one-line reasonpullboard submit <id> needs a clean tree, item check and affected tests green at HEAD (alias: done)pullboard verify <id> accept --note "what you broke or which edge you tried, and what happened"- pullboard verify <id> reject --reason TEST_FAILURE --note "what failed"+ pullboard verify <id> reject --reason TEST_FAILURE --note "what failed" [--cause <key>]+ a cause is test:<file>::<title>, refusal:<CODE>, row:<id> or doctrine:<id>any --note can be --note-file <file>, which keeps quotes, $ and backticks intactpullboard shout <lane|agent|person|all> <text> pullboard inboxpullboard shout [<to>] <text> --decision ask for a decision; defaults to your coordinator or the person@@ -106,7 +108,7 @@ Coordinatorpullboard merged <id> <commit> record where verified work landedpullboard withdraw <id> <reason> drop an item nobody should buildpullboard refreeze <id> adopt a corrected criterion or changed spec rows- pullboard reopen <id> --note "why" return a submission for criterion correction without a verdict+ pullboard reopen <id> --note "why" [--cause <key>] return a submission for criterion correction without a verdictpullboard hold <lane> --reason "..." pause a lane: next there claims nothing and names the reasonpullboard hold <id> "reason" hold one item so next skips itpullboard hold <lane|id> --off lift a lane or item hold@@ -143,6 +145,8 @@ Receiptswhen that queue is empty, the action says none waiting or waits for open workpullboard ledger markdown: what was built, by whom, verified by whompullboard log [id] every move, in order+ pullboard rigor failure causes that repeated: on 2 items, or 1 item at 2 commits;+ each with its items and whether it reads as work, product or bothSpecpullboard spec --json parsed SPEC.md and doctrine rows as JSON@@ -180,7 +184,7 @@ const HELP_NAMES = ['tour', 'init', 'worktree', 'join', 'takeover', 'whoami', 'lanes', 'status', 'resources', 'settings', 'view', 'view export','serve', 'mcp', 'relay', 'relay recover', 'resume', 'hooks', 'add', 'edit', 'escalate', 'run', 'list', 'doctor', 'skills', 'show', 'next', 'land','check', 'claim', 'release', 'submit', 'done', 'verify', 'fact', 'shout', 'answer', 'pass', 'decisions', 'inbox', 'export', 'import',- 'sweep', 'merged', 'withdraw', 'refreeze', 'reopen', 'hold', 'stats', 'ledger', 'log', 'spec', 'spec check', 'spec view',+ 'sweep', 'merged', 'withdraw', 'refreeze', 'reopen', 'hold', 'stats', 'ledger', 'log', 'rigor', 'spec', 'spec check', 'spec view','spec show', 'spec unmet', 'spec signoff', 'spec draft', 'spec signers', 'spec signers add', 'forget', 'prompt', 'gate', 'hook','hook pre-commit', 'hook pre-merge-commit', 'hook commit-msg', 'hook pre-push', 'view export', 'version', 'lifecycle', 'help','roadmap', 'milestone', 'runner', 'runner add', 'blueprint', 'blueprint add', 'blueprint save',@@ -202,7 +206,7 @@ const HELP_EXAMPLES = {verify: 'pullboard verify 12 accept --note "removed the fix; the test failed"',answer: 'pullboard answer 12 "done"', pass: 'pullboard pass 12 "please decide"',status: 'pullboard status', view: 'pullboard view', mcp: 'pullboard mcp', stats: 'pullboard stats --since 2026-10-08', log: 'pullboard log 12', ledger: 'pullboard ledger',- roadmap: 'pullboard roadmap', milestone: 'pullboard milestone add "0.7.0" --items 12,13',+ roadmap: 'pullboard roadmap', rigor: 'pullboard rigor', milestone: 'pullboard milestone add "0.7.0" --items 12,13',runner: 'pullboard runner add studio --slots 2 --browser 1', 'runner add': 'pullboard runner add studio --slots 2 --browser 1',edit: 'pullboard edit 12 --brief "Add the upload page"', release: 'pullboard release 12',land: 'pullboard land --max 4',diff --git a/src/json.js b/src/json.jsindex 3cef0d18..69d11144 100644--- a/src/json.js+++ b/src/json.js@@ -40,6 +40,7 @@ export const JSON_SHAPES = {decisions: shape({ decisions: 'array' }),ledger: shape({ items: 'array', stats: 'object' }),log: shape({ events: 'array' }),+ rigor: shape({ causes: 'array', uncaused: 'number' }),add: shape({ item: 'object' }),edit: shape({ item: 'object' }),fact: shape({ item: 'number', fact: 'object' }),diff --git a/src/machine.js b/src/machine.jsindex 605bf80b..7ddfeb23 100644--- a/src/machine.js+++ b/src/machine.js@@ -10,7 +10,10 @@*//** Executable move semantics, carried by every sealed move and retained during replay [H16]. */-export const ENGINE_VERSION = 12;+export const ENGINE_VERSION = 13;++/** 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 = 13;/** @typedef {'agent' | 'coordinator' | 'clock'} Role */@@ -137,6 +140,7 @@ export const GUARDS = [{ id: 'reviewReleaseExplained', refuse: 'NOTE_REQUIRED', rule: 'a review release gives a nonempty one-line reason', next: 'release with --note "why", or --note-file <file>', source: 'board', when: 'engine 5 or newer, only when freeing a submitted review reservation' },{ id: 'reviewCooldownElapsed', refuse: 'REVIEW_COOLDOWN', rule: 'the reviewer has not released this submission within the past hour', next: 'let another reviewer take it, or wait an hour or for a new submission', source: 'board', when: 'engine 5 or newer, only for the same reviewer and current submission' },{ 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: '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' },];@@ -170,12 +174,12 @@ export const MOVES = [},{verb: 'reject', from: ['submitted'], to: 'open', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',- guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven'],+ guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven', 'causeWellFormed'],command: 'pullboard verify <id> reject --reason CODE --note "..."',},{verb: 'reopen', from: ['submitted', 'verified'], to: 'open', by: ['coordinator'], refuse: 'NOT_SUBMITTED',- guards: ['joined', 'itemExists', IN_STATE, 'coordinatorOnly', 'noteGiven', 'notMerged', 'landingFailureRecorded'],+ guards: ['joined', 'itemExists', IN_STATE, 'coordinatorOnly', 'noteGiven', 'causeWellFormed', 'notMerged', 'landingFailureRecorded'],sets: ['item_verdict', 'item_verified_by', 'item_owner', 'item_lease_until', 'item_review_by', 'item_review_until'],command: 'pullboard reopen <id> --note "why"',},diff --git a/src/next-steps.js b/src/next-steps.jsindex d8afe8fe..617d07b3 100644--- a/src/next-steps.js+++ b/src/next-steps.js@@ -36,6 +36,7 @@ export const NEXT_STEPS = Object.freeze({BAD_DEPENDENCIES: 'use --after with item ids, such as --after 1,2, or --after none',BAD_EVIDENCE: 'pass the evidence fields the message names, then retry',BAD_FACT_ID: 'upgrade to the current Pullboard engine, then retry the original fact operation',+ BAD_CAUSE: 'name the cause as test:<file>::<title>, refusal:<CODE>, row:<id> or doctrine:<id>, or leave --cause out',BAD_FACT_KIND: 'use a supported kind, such as note: pullboard fact <id> note "<what you observed>"',BAD_FACT_REF: 'cite code as path:line[-line]@<full 40-character commit>, from git rev-parse HEAD',BAD_FIRST_COMMIT: 'commit the repository first, then run pullboard spec signers add',@@ -191,6 +192,7 @@ export const NEXT_STEPS = Object.freeze({NOT_VERIFIED: 'merge only verified items; see pullboard list --all',NOT_YOURS: 'shout its holder or the coordinator: pullboard shout coordinator "<what you need>"',NOT_YOUR_CHECKOUT: 'make an independent checkout with git worktree add -b <lane>/<n> ../<repo>-<lane>-<n>, then run pullboard join <lane> --model "<model name>" there; the same agent in a new session should run pullboard takeover from its own shell',+ RIGOR_PERSON_ONLY: 'ask the person to mark it from the main checkout: pullboard fact <id> root-cause "<why>" --cause <key> --never-again --as person',SANDBOX_BLOCKED: 'ask the person to allow the named operation, or run the gate outside the sandbox; keep the tests unchanged',NOT_YOUR_DECISION: 'answer only decisions addressed to you; see pullboard inbox',NO_AGENT: 'create and join a lane worktree: pullboard worktree <lane> --model "<model name>"',diff --git a/src/rigor.js b/src/rigor.jsnew file mode 100644index 00000000..fcf56319--- /dev/null+++ b/src/rigor.js@@ -0,0 +1,187 @@+/**+ * Rigor: how errors become doctrine or specs. The first step is noticing a failure cause that+ * repeats [D1,V1]. A cause key comes only from structured fields, never from free-text notes,+ * because typed reasons almost never repeat word for word while structured causes do.+ */+import { COORDINATOR } from './config.js';+import { Refused } from './refused.js';++/** The four kinds of cause key and their shapes, in the order help and refusals name them. */+export const CAUSE_FORMS = Object.freeze(['test:<file>::<title>', 'refusal:<CODE>', 'row:<id>', 'doctrine:<id>']);++const CAUSE = /^(?:test:(?<file>[^\s:][^\r\n:]*)::(?<title>\S[^\r\n]*)|refusal:(?<code>[A-Z][A-Z0-9_]*)|row:(?<row>[A-Z][A-Za-z0-9.]*)|doctrine:(?<doctrine>[A-Z][A-Za-z0-9.]*))$/u;++/** Refusal codes that name a merge conflict: a collision between branches, never a repeated error. */+const CONFLICT_CODES = new Set(['MERGE_CONFLICT']);++/**+ * The refusal for a malformed cause key, or null when it is well formed or absent.+ *+ * @param {unknown} cause+ * @returns {Refused | null}+ */+export function causeProblem(cause) {+ if (cause === undefined || cause === null) return null;+ if (typeof cause === 'string' && CAUSE.test(cause) && cause === cause.trim()) return null;+ const given = typeof cause === 'string' ? (cause.trim() ? `"${cause}"` : 'an empty key') : `a ${typeof cause}`;+ return new Refused('BAD_CAUSE', `${given} is not a cause key; use one of ${CAUSE_FORMS.join(', ')}, for example --cause "refusal:MERGE_CONFLICT"`);+}++/**+ * Refuse a never-again fact that is not the person's or names no cause. Only the person, from the+ * main checkout's terminal or the view, marks a cause never-again.+ *+ * @param {number} id+ * @param {{ agentId: string, cause: string | null, neverAgain: boolean, asPerson: boolean, channel: string }} fact+ */+export function requireNeverAgain(id, { agentId, cause, neverAgain, asPerson, channel }) {+ const problem = neverAgainProblem(id, { agentId, cause, neverAgain, asPerson, channel });+ if (problem) throw problem;+}++/** The refusal for a never-again fact requireNeverAgain refuses, or null. */+function neverAgainProblem(id, { agentId, cause, neverAgain, asPerson, channel }) {+ if (!neverAgain || !asPerson || agentId !== COORDINATOR) return new Refused('RIGOR_PERSON_ONLY', `only the person marks a cause never-again, from the main checkout: pullboard fact ${id} root-cause "<why>" --cause <key> --never-again --as person`);+ if (!['terminal', 'view'].includes(channel)) return new Refused('B26_PERSON_CHANNEL', 'a never-again is the person’s; record it through the terminal or the view; run pullboard view');+ if (cause === null) return new Refused('BAD_CAUSE', `a never-again names its cause: --cause with one of ${CAUSE_FORMS.join(', ')}`);+ return causeProblem(cause);+}++/**+ * The cause key for one failing test.+ *+ * @param {{ file: string, name: string }} test+ * @returns {string}+ */+export function testCause({ file, name }) {+ return `test:${file}::${String(name).trim()}`;+}++/**+ * True when a cause names a merge conflict. A landing records a conflict as a "test" whose name+ * says so; a reviewer can name the conflict refusal. Either way, two branches touching the same+ * lines is not an error anyone can make a rule against, so rigor never counts it.+ *+ * @param {string} key+ * @returns {boolean}+ */+export function isMergeConflict(key) {+ const parts = CAUSE.exec(key)?.groups;+ if (!parts) return false;+ if (parts.code) return CONFLICT_CODES.has(parts.code);+ return Boolean(parts.title && /^(?:merge )?conflicts? with\b/iu.test(parts.title));+}++/**+ * How a cause reads: a doctrine row or a refusal is about how the work is done (work), a spec row+ * is about what the product must do (product), and a failing test can be either (both), so the+ * person picks.+ *+ * @param {string} key+ * @returns {'work' | 'product' | 'both'}+ */+export function causeReading(key) {+ if (key.startsWith('doctrine:') || key.startsWith('refusal:')) return 'work';+ if (key.startsWith('row:')) return 'product';+ return 'both';+}++/**+ * The cause keys one recorded reject or reopen carries. A move recorded with --cause names its key;+ * a reopen after a red landing names its failing tests in structured fields, so those give keys+ * even for events recorded before cause keys existed. A note is never parsed.+ *+ * @param {{ event_kind: string, event_detail: string }} event+ * @returns {string[]}+ */+export function eventCauses(event) {+ if (!['reject', 'reopen'].includes(event.event_kind)) return [];+ const detail = JSON.parse(event.event_detail);+ const keys = [];+ if (typeof detail.cause === 'string' && !causeProblem(detail.cause)) keys.push(detail.cause);+ const tests = Array.isArray(detail.landingFailure?.tests) ? detail.landingFailure.tests : [];+ for (const test of tests) {+ if (typeof test?.file !== 'string' || typeof test?.name !== 'string' || !test.name.trim()) continue;+ const key = testCause(test);+ if (!causeProblem(key) && !keys.includes(key)) keys.push(key);+ }+ return keys;+}++/**+ * The person's never-again: a fact the person recorded with a cause and marked never-again. It+ * lists at once, without waiting for a second failure.+ *+ * @param {{ event_kind: string, event_by: string, event_detail: string }} event+ * @param {string} person+ * @returns {string | null}+ */+function neverAgainCause(event, person) {+ if (event.event_kind !== 'fact' || event.event_by !== person) return null;+ const detail = JSON.parse(event.event_detail);+ return detail.neverAgain === true && typeof detail.cause === 'string' && !causeProblem(detail.cause) ? detail.cause : null;+}++/**+ * Every cause that repeated: on 2 items, or on 1 item at 2 different commits, or named never-again+ * by the person. Merge conflicts never list. Read-only: it reads the event log and changes nothing.+ *+ * @param {any[]} events - the board's event log, oldest first+ * @param {{ person: string }} who+ * @returns {{ causes: { key: string, reads: string, items: { id: number, commits: string[] }[], occurrences: number, neverAgain: boolean }[], uncaused: number }}+ */+export function rigorReport(events, { person }) {+ const byKey = new Map();+ let uncaused = 0;+ /** The running record for one cause key. */+ const entry = (key) => {+ if (!byKey.has(key)) byKey.set(key, { key, reads: causeReading(key), items: new Map(), occurrences: 0, neverAgain: false });+ return byKey.get(key);+ };+ for (const event of events) {+ const never = neverAgainCause(event, person);+ if (never && !isMergeConflict(never)) {+ const found = entry(never);+ found.neverAgain = true;+ if (event.item_id !== null && !found.items.has(event.item_id)) found.items.set(event.item_id, new Set());+ continue;+ }+ if (!['reject', 'reopen'].includes(event.event_kind)) continue;+ const keys = eventCauses(event);+ if (!keys.length) {+ uncaused += 1;+ continue;+ }+ const commit = JSON.parse(event.event_detail).commit ?? null;+ for (const key of keys.filter((candidate) => !isMergeConflict(candidate))) {+ const found = entry(key);+ found.occurrences += 1;+ const commits = found.items.get(event.item_id) ?? new Set();+ if (commit) commits.add(commit);+ found.items.set(event.item_id, commits);+ }+ }+ const causes = [...byKey.values()]+ .map((found) => ({ key: found.key, reads: found.reads, occurrences: found.occurrences, neverAgain: found.neverAgain,+ items: [...found.items].map(([id, commits]) => ({ id, commits: [...commits] })).sort((a, b) => a.id - b.id) }))+ .filter((found) => found.neverAgain || found.items.length >= 2 || found.items.some((item) => item.commits.length >= 2))+ .sort((a, b) => Number(b.neverAgain) - Number(a.neverAgain) || b.items.length - a.items.length || b.occurrences - a.occurrences || a.key.localeCompare(b.key));+ return { causes, uncaused };+}++/**+ * The report as lines a person reads: one line per repeated cause with its items and how it reads.+ *+ * @param {ReturnType<typeof rigorReport>} report+ * @returns {string[]}+ */+export function rigorLines({ causes, uncaused }) {+ const lines = causes.length+ ? causes.map((cause) => {+ const items = cause.items.map((item) => `#${item.id}${item.commits.length > 1 ? ` (${item.commits.length} commits)` : ''}`).join(', ');+ return `${cause.key} reads as ${cause.reads} ${cause.neverAgain ? 'never again (the person)' : `${cause.occurrences} failures`} items ${items || 'none'}`;+ })+ : ['no failure cause has repeated'];+ if (uncaused) lines.push(`${uncaused} rejects and reopens carry no cause key; name one with --cause <key> (${CAUSE_FORMS.join(', ')})`);+ return lines;+}diff --git a/src/templates.js b/src/templates.jsindex 99097bd1..3aabc5e2 100644--- a/src/templates.js+++ b/src/templates.js@@ -122,6 +122,7 @@ It prints the folder to work in and what to run there first. Every join needs th3. Build inside your lane's folders (\`pullboard lanes\`). Pre-commit refuses anything else; shout the owner instead.4. Commit, then \`pullboard submit <id>\`. It needs a clean tree and the gate green at HEAD.5. A different agent verifies: \`pullboard next --verify\` names the next item to check. It checks out the submitted commit and runs \`pullboard verify <id> accept --note "how it proved it"\`, or \`pullboard verify <id> reject --reason TEST_FAILURE --note "what failed"\`.+When a reject names a structured cause, add \`--cause <key>\` (\`test:<file>::<title>\`, \`refusal:<CODE>\`, \`row:<id>\` or \`doctrine:<id>\`) so \`pullboard rigor\` can notice when the same cause repeats.6. A reject reopens the item. Fix it, commit, claim, submit again; the same head is refused. If you cannot get an item green, do not force it: \`pullboard escalate <id> --note "what you tried and how it failed"\` hands it one tier up.7. Your lane is done when its items are verified, not when they are submitted. After your last submit, keep running \`pullboard next --wait 9\`: a rejected item comes back to your lane.diff --git a/test/agent-model-engine.test.js b/test/agent-model-engine.test.jsindex e85e2e8d..3a577ef1 100644--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@ -11,8 +11,8 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';test('model declarations and event snapshots retain engines 1 through 11 semantics [O8,O3,H16]', (t) => {- assert.equal(ENGINE_VERSION, 12, 'engine 12 preserves the released engine-8 through engine-11 model behavior');- for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ENGINE_VERSION]) {+ assert.ok(ENGINE_VERSION >= 12, 'engine 12 and later preserve the released engine-8 through engine-11 model behavior');+ for (const version of new Set([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ENGINE_VERSION])) {const board = store.openBoard(':memory:');t.after(() => store.closeBoard(board));const registration = prepareEngineMove(board, 'register', [{ lane: 'web', path: '/web', model: 'First Model' }]);diff --git a/test/api.test.js b/test/api.test.jsindex bc4f56d0..cca19e75 100644--- a/test/api.test.js+++ b/test/api.test.js@@ -964,6 +964,7 @@ test('[A1] every catalog command and subcommand has a real CLI exercise', () =>assert.deepEqual(landing.landed, []);assert.deepEqual(landing.items, []);json(source, source.repo, 'roadmap');+ json(source, source.repo, 'rigor');json(source, source.repo, 'milestone', ['add', 'Catalog', '--items', String(catalog.item_id)], 'add');json(source, source.repo, 'milestone', ['items', 'Catalog', '--remove', String(catalog.item_id)], 'items');json(source, source.repo, 'milestone', ['items', 'Catalog', '--add', String(catalog.item_id)], 'items');diff --git a/test/machine.test.js b/test/machine.test.jsindex 985d8fc1..2b9a2039 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -973,6 +973,8 @@ test('submit, accept and reject refuse in the declared order, one failure peeledjudge(built, 'web-2', { reason: bad, policy: 'any' }),judge(built, 'web-2', { reason: bad, policy: 'any', digest: 'digest:Page' }),judge(built, 'web-2', { reason: good, policy: 'any', digest: 'digest:Page' }),+ // Only a reject reads a cause key, so only its order has the malformed-cause step (#713).+ ...(verb === 'reject' ? [judge(built, 'web-2', { reason: good, policy: 'any', digest: 'digest:Page', note: 'reverted the fix; its test went red', cause: 'free text' })] : []),judge(built, 'web-2', { reason: good, policy: 'any', digest: 'digest:Page', note: 'reverted the fix; its test went red' }),];assert.deepEqual(fired, [...declaredBoardOrder(verb), 'ok'], verb);diff --git a/test/pending-refreeze.test.js b/test/pending-refreeze.test.jsindex 15ad01aa..a60496da 100644--- a/test/pending-refreeze.test.js+++ b/test/pending-refreeze.test.js@@ -252,7 +252,7 @@ async function checkDependencyLegacyClients(cleanup, directory, snapshot, targetconst oldSnapshot = legacyExchange.exportBoard(old);const currentSnapshot = exportBoard(current);assert.equal(oldSnapshot.tables.board_meta.find((row) => row.meta_key === 'relay_engine_version').meta_value, '10');- assert.equal(currentSnapshot.tables.board_meta.find((row) => row.meta_key === 'relay_engine_version').meta_value, '12');+ assert.equal(currentSnapshot.tables.board_meta.find((row) => row.meta_key === 'relay_engine_version').meta_value, String(ENGINE_VERSION));assert.deepEqual(withoutEngineMarker(currentSnapshot), withoutEngineMarker(oldSnapshot),'the sole snapshot difference is the intentionally newer writer-version marker');}@@ -261,7 +261,7 @@ async function checkDependencyLegacyClients(cleanup, directory, snapshot, target}test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {- assert.equal(ENGINE_VERSION, 12);+ assert.ok(ENGINE_VERSION >= 12);const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));const cleanup = [];t.after(() => {diff --git a/test/rigor.test.js b/test/rigor.test.jsnew file mode 100644index 00000000..046deab7--- /dev/null+++ b/test/rigor.test.js@@ -0,0 +1,279 @@+/** Rigor: a repeated failure cause is noticed from structured fields, never from notes [D1,V1]. */+import assert from 'node:assert/strict';+import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';+import { pathToFileURL } from 'node:url';+import { after, test } from 'node:test';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';+import * as store from '../src/board.js';+import { applyEngineMove, prepareEngineMove } from '../src/engine.js';+import { CAUSE_ENGINE } from '../src/machine.js';+import { rigorReport } from '../src/rigor.js';+import { unpackRelease } from './release-archive.js';++const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');+const MARKERS = ['CLAUDECODE', 'CLAUDE_CODE_ENTRYPOINT', 'CLAUDE_CODE_SESSION_ID', 'AI_AGENT', 'CODEX_THREAD_ID', 'CODEX_SESSION_ID', 'CODEX_CI', 'CODEX_SHELL', 'SSH_CONNECTION', 'SSH_TTY'];+const DIRS = [];+const HOUR = 3_600_000;+const MERGE = 'c'.repeat(40);++after(() => { for (const dir of DIRS) rmSync(dir, { recursive: true, force: true }); });++/** A freshly initialized repo with a private board, Pullboard home and Git identity, run as the person's terminal. */+function freshBoard() {+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-rigor-'));+ DIRS.push(dir);+ // The hooks init installs call pullboard by name, so this checkout's CLI is the one on PATH.+ const bin = join(dir, 'bin');+ mkdirSync(bin);+ writeFileSync(join(bin, 'pullboard'), `#!/bin/sh\nexec '${process.execPath.replaceAll("'", "'\\''")}' '${BIN.replaceAll("'", "'\\''")}' "$@"\n`);+ chmodSync(join(bin, 'pullboard'), 0o755);+ const env = { ...process.env };+ for (const key of Object.keys(env)) if (key.startsWith('GIT_') || key.startsWith('PULLBOARD_') || MARKERS.includes(key)) delete env[key];+ Object.assign(env, {+ PATH: `${bin}:${process.env.PATH}`,+ PULLBOARD_HOME: join(dir, 'home'), PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),+ GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',+ GIT_AUTHOR_NAME: 'Rigor fixture', GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Rigor fixture', GIT_COMMITTER_EMAIL: '[email protected]',+ });+ const repo = join(dir, 'repo');+ mkdirSync(repo);+ const git = (...args) => runFixtureGit(args, { cwd: repo, env });+ const run = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });+ git('init', '-q', '-b', 'main');+ const init = run('init', '--model', 'Rigor coordinator');+ assert.equal(init.status, 0, init.stdout + init.stderr);+ const config = join(repo, 'pullboard.json');+ writeFileSync(config, `${JSON.stringify({ ...JSON.parse(readFileSync(config, 'utf8')), gate: 'true' }, null, 2)}\n`);+ git('add', '-A');+ git('commit', '-q', '-m', 'chore: set up rigor fixture');+ const file = join(repo, '.git', 'pullboard', 'board.sqlite');+ return { dir, repo, run, git, file, env };+}++/** Run one command with --json and return its document, failing with its output. */+function json(box, ...args) {+ const result = box.run(...args, '--json');+ assert.equal(result.status, 0, `${args.join(' ')}: ${result.stdout}${result.stderr}`);+ return JSON.parse(result.stdout);+}++/** Assert a CLI run refused with one code, naming the rule it proves when it did not. */+function refused(result, code, why) {+ const document = JSON.parse(result.stdout || '{}');+ assert.equal(document.error?.code, code, `${why}: ${result.stdout}${result.stderr}`);+}++/**+ * Build board history straight through the board's own moves on the real SQLite file: a builder+ * and a reviewer in one lane, and helpers to submit, reject and land-reopen an item.+ */+function history(file) {+ const board = store.openBoard(file);+ const builder = store.register(board, { lane: 'app', path: '/fixture/app-1', model: 'Builder model' });+ const reviewer = store.register(board, { lane: 'app', path: '/fixture/app-2', model: 'Reviewer model' });+ /** Freeze the item's title, as the real freezer digests its criterion. */+ const freeze = (item) => ({ text: item.item_title, digest: `digest:${item.item_title}` });+ let next = 0;+ /** A fresh 40-character commit id for each submission. */+ const commit = () => (++next).toString(16).padStart(40, '0');+ /** Claim and submit an item at a new commit, returning that commit. */+ const submit = (id) => {+ store.claim(board, id, { agentId: builder, lane: 'app', leaseMs: 2 * HOUR, freeze });+ const sha = commit();+ store.submit(board, id, { agentId: builder, commit: sha, tree: `tree-${sha}` });+ return sha;+ };+ /** Reject the current submission, naming a cause key or none. */+ const reject = (id, cause, note = 'the named test failed at this commit') => store.verify(board, id, {+ agentId: reviewer, decision: 'REJECT', reason: 'TEST_FAILURE', note, ...(cause === undefined ? {} : { cause }),+ head: store.getItem(board, id).item_commit, digest: `digest:${store.getItem(board, id).item_title}`, policy: 'any',+ });+ /** Accept, then reopen after a red landing whose failing test the note names in the landing format. */+ const landReopen = (id, test) => {+ store.verify(board, id, { agentId: reviewer, decision: 'ACCEPT', note: 'broke the fix; its test failed; restored it',+ head: store.getItem(board, id).item_commit, digest: `digest:${store.getItem(board, id).item_title}`, policy: 'any' });+ return store.reopen(board, id, { agentId: 'coordinator', note: `${test.file}: ${test.name}; merge commit ${MERGE}` });+ };+ /** Add one item in the fixture lane. */+ const add = (title) => store.addItem(board, { by: 'coordinator', lane: 'app', title });+ return { board, add, submit, reject, landReopen, close: () => store.closeBoard(board) };+}++test('a repeated failure cause is noticed [D1,V1]', () => {+ const box = freshBoard();+ const before = json(box, 'rigor');+ assert.deepEqual(before.causes, [], 'an empty board has no repeated cause');++ const catalog = 'test:test/api.test.js::[A1] every catalog command and subcommand has a real CLI exercise';+ const board = history(box.file);+ const [first, second, third, single, conflictA, conflictB] = ['First', 'Second', 'Third', 'Single', 'Conflict A', 'Conflict B'].map(board.add);+ // A repeat: the same failing test sends back two items.+ board.submit(first); board.reject(first, catalog);+ board.submit(second); board.reject(second, catalog);+ // A repeat on one item at two different commits.+ const firstSha = board.submit(third); board.reject(third, 'refusal:UNDECLARED_REFUSAL');+ const secondSha = board.submit(third); board.reject(third, 'refusal:UNDECLARED_REFUSAL');+ // A single: one failure on one item at one commit never lists.+ board.submit(single); board.reject(single, 'row:G1');+ // Merge conflicts on two items never list, however often they recur.+ board.submit(conflictA); board.landReopen(conflictA, { file: 'src/help.js', name: 'conflicts with main 8b8dc50e (0.8.29), merge main and resubmit' });+ board.submit(conflictB); board.landReopen(conflictB, { file: 'src/help.js', name: 'conflicts with main 8b8dc50e (0.8.29), merge main and resubmit' });+ board.close();++ const repeated = json(box, 'rigor');+ assert.deepEqual(repeated.causes.map((cause) => cause.key), [catalog, 'refusal:UNDECLARED_REFUSAL'],+ 'the two repeats list, the single and the merge conflicts do not');+ const [test, refusal] = repeated.causes;+ assert.deepEqual(test.items.map((item) => item.id), [first, second], 'a repeat lists both its items');+ assert.equal(test.reads, 'both', 'a failing test reads as work or product, so the person picks');+ assert.equal(test.occurrences, 2);+ assert.deepEqual(refusal.items, [{ id: third, commits: [firstSha, secondSha] }], 'one item at two commits is a repeat');+ assert.equal(refusal.reads, 'work', 'a refusal is about how the work is done');+ assert.ok(!repeated.causes.some((cause) => cause.key === 'row:G1'), 'a single failure does not list');+ assert.ok(!repeated.causes.some((cause) => /conflicts with/u.test(cause.key)), 'a merge conflict never lists');++ // A person's never-again lists at once, from one fact and no failure at all.+ const marked = json(box, 'fact', String(single), 'root-cause', 'Every function keeps its JSDoc block', '--cause', 'doctrine:C3', '--never-again', '--as', 'person');+ assert.equal(marked.fact.by, store.PERSON, 'the fact is the person’s');+ assert.equal(marked.fact.neverAgain, true);+ const never = json(box, 'rigor');+ assert.deepEqual(never.causes[0], { key: 'doctrine:C3', reads: 'work', occurrences: 0, neverAgain: true, items: [{ id: single, commits: [] }] },+ 'the never-again lists first, at once');+ assert.equal(never.causes.length, 3);++ const text = box.run('rigor');+ assert.equal(text.status, 0, text.stderr);+ const lines = text.stdout.trim().split('\n');+ assert.match(lines[0], /^doctrine:C3 {2}reads as work {2}never again \(the person\) {2}items #\d+$/u);+ assert.equal(lines[1], `${catalog} reads as both 2 failures items #${first}, #${second}`);+ assert.equal(lines[2], `refusal:UNDECLARED_REFUSAL reads as work 2 failures items #${third} (2 commits)`);+ assert.equal(lines.length, 3, 'every reject and reopen here carries a cause, so no uncaused line');+});++test('rigor reads old events by their structured fields only, never by their notes [D1,V1]', () => {+ const box = freshBoard();+ const board = history(box.file);+ const [first, second, third, fourth] = ['First', 'Second', 'Third', 'Fourth'].map(board.add);+ const landing = { file: 'test/machine.test.js', name: 'the declaration matches the refusals board.js and cli.js raise [M1]' };+ // Reopens after a red landing carry their failing tests as structured fields, with no cause key.+ board.submit(first); board.landReopen(first, landing);+ board.submit(second); board.landReopen(second, landing);+ // Rejects recorded without a cause key: their notes name the same test, and are never parsed.+ const note = `${landing.file}: ${landing.name} failed again`;+ board.submit(third); board.reject(third, undefined, note);+ board.submit(fourth); board.reject(fourth, undefined, note);+ board.close();+ const report = json(box, 'rigor');+ assert.deepEqual(report.causes.map((cause) => [cause.key, cause.items.map((item) => item.id)]),+ [[`test:${landing.file}::${landing.name}`, [first, second]]], 'only the structured landing tests count');+ assert.equal(report.uncaused, 2, 'the two causeless rejects are counted as uncaused');+ const text = box.run('rigor');+ assert.match(text.stdout, /^2 rejects and reopens carry no cause key; name one with --cause <key>/mu);+});++test('a cause key is checked, recorded on reject and reopen, and the person alone marks never-again [D1,V1,H16]', () => {+ const box = freshBoard();+ const board = history(box.file);+ const id = board.add('Checked');+ board.submit(id);+ for (const [bad, named] of [['the catalog test failed', '"the catalog test failed"'], ['cause:G1', '"cause:G1"'], ['', 'an empty key']]) {+ assert.throws(() => board.reject(id, bad), (error) => error.code === 'BAD_CAUSE' && error.message.startsWith(`[BAD_CAUSE] ${named} is not a cause key`)+ && ['test:<file>::<title>', 'refusal:<CODE>', 'row:<id>', 'doctrine:<id>'].every((form) => error.message.includes(form)),+ `${named} is refused by name, with the four forms`);+ }+ assert.equal(store.getItem(board.board, id).item_status, 'submitted', 'a refused reject leaves the item submitted');+ board.reject(id, 'row:G1');+ const rejected = store.events(board.board, { itemId: id }).at(-1);+ assert.equal(JSON.parse(rejected.event_detail).cause, 'row:G1', 'the reject records its cause key');++ // A sealed move that carries a cause needs the cause engine; an older envelope cannot carry it.+ const second = board.add('Sealed');+ board.submit(second);+ const move = prepareEngineMove(board.board, 'verify', [second, { agentId: 'app-2', decision: 'REJECT', reason: 'TEST_FAILURE', note: 'red', cause: 'row:G1', head: store.getItem(board.board, second).item_commit, digest: 'digest:Sealed', policy: 'any' }]);+ assert.equal(move.engine, CAUSE_ENGINE);+ assert.throws(() => applyEngineMove(board.board, { ...move, engine: CAUSE_ENGINE - 1 }, { sequence: 1, at: new Date().toISOString() }),+ (error) => error.code === 'RELAY_MOVE', 'an engine-12 move cannot carry a cause key');+ board.close();++ // The coordinator's reopen records --cause through the CLI.+ const reopenItem = json(box, 'add', 'coordinator', 'Reopen with a cause', '--criterion', 'Reopen records its cause.', '--check', 'true').item;+ json(box, 'claim', String(reopenItem.item_id));+ json(box, 'submit', String(reopenItem.item_id));+ refused(box.run('reopen', String(reopenItem.item_id), '--note', 'wrong bar', '--cause', 'wrong bar', '--json'), 'BAD_CAUSE', 'a reopen refuses a malformed cause');+ json(box, 'reopen', String(reopenItem.item_id), '--note', 'the bar cites the wrong row', '--cause', 'row:G1');+ const reopened = json(box, 'log', String(reopenItem.item_id)).events.at(-1);+ assert.equal(reopened.event_kind, 'reopen');+ assert.equal(JSON.parse(reopened.event_detail).cause, 'row:G1', 'the reopen records its cause key');++ // Only the person marks never-again; the coordinator alone, or without a cause, is refused.+ refused(box.run('fact', String(id), 'root-cause', 'never again', '--cause', 'row:G1', '--never-again', '--json'), 'RIGOR_PERSON_ONLY', 'the coordinator alone cannot mark never-again');+ const agentShell = runFixtureChild(process.execPath, [BIN, 'fact', String(id), 'root-cause', 'never again', '--cause', 'row:G1', '--never-again', '--as', 'person', '--json'],+ { cwd: box.repo, env: { ...box.env, CLAUDECODE: '1' }, encoding: 'utf8' });+ refused(agentShell, 'B26_PERSON_CHANNEL', 'an agent shell cannot act as the person');+ refused(box.run('fact', String(id), 'root-cause', 'never again', '--never-again', '--as', 'person', '--json'), 'BAD_CAUSE', 'a never-again names its cause');+ const logged = json(box, 'log').events.length;+ const report = json(box, 'rigor');+ assert.deepEqual(report.causes.map((cause) => cause.key), ['row:G1'], 'row:G1 on two items repeats');+ assert.equal(report.causes[0].reads, 'product');+ assert.equal(json(box, 'log').events.length, logged, 'rigor is read-only: it records no move');+});++test('reject, reopen and fact moves without a cause replay unchanged from engines 11 and 12 [D1,H16]', async (t) => {+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-rigor-replay-'));+ DIRS.push(directory);+ const fixed = { now: () => new Date('2026-10-16T12:00:00.000Z') };+ /** Freeze with the captured verify policy that released verify replay requires. */+ const freeze = (item) => ({+ text: JSON.stringify({ criterion: item.item_title, policy: { version: 1, commit: 'a'.repeat(40), verify: { policy: 'any', family: 'off' } } }),+ digest: `digest:${item.item_title}`,+ });+ const landed = { file: 'test/machine.test.js', name: 'the declaration matches the refusals [M1]' };+ for (const [version, tag] of [[11, 'v0.8.27'], [12, 'v0.8.29']]) {+ const source = join(directory, `client-${version}`);+ mkdirSync(source);+ unpackRelease(tag, source);+ const legacyStore = await import(pathToFileURL(join(source, 'src/board.js')).href);+ const legacyEngine = await import(pathToFileURL(join(source, 'src/engine.js')).href);+ const legacyMachine = await import(pathToFileURL(join(source, 'src/machine.js')).href);+ assert.equal(legacyMachine.ENGINE_VERSION, version, 'the archived executable has the claimed engine');+ const old = legacyStore.openBoard(join(directory, `old-${version}.sqlite`), fixed);+ const current = store.openBoard(join(directory, `current-${version}.sqlite`), fixed);+ t.after(() => { legacyStore.closeBoard(old); store.closeBoard(current); });+ for (const [replica, module] of [[old, legacyStore], [current, store]]) {+ module.register(replica, { lane: 'coordinator', path: '/fixture/main' });+ module.register(replica, { lane: 'app', path: '/fixture/app-1', model: 'Builder model' });+ module.register(replica, { lane: 'app', path: '/fixture/app-2', model: 'Reviewer model' });+ }+ const first = '1'.repeat(40);+ const second = '2'.repeat(40);+ const journal = [+ ['addItem', [{ by: 'coordinator', lane: 'app', title: 'Replayed' }]],+ ['claim', [1, { agentId: 'app-1', lane: 'app', leaseMs: 2 * HOUR, freeze }]],+ ['submit', [1, { agentId: 'app-1', commit: first, tree: 'tree-1' }]],+ ['verify', [1, { agentId: 'app-2', decision: 'REJECT', reason: 'TEST_FAILURE', note: `${landed.file}: ${landed.name}`, head: first, digest: 'digest:Replayed', policy: 'any' }]],+ ['claim', [1, { agentId: 'app-1', lane: 'app', leaseMs: 2 * HOUR, freeze }]],+ ['submit', [1, { agentId: 'app-1', commit: second, tree: 'tree-2' }]],+ ['verify', [1, { agentId: 'app-2', decision: 'ACCEPT', note: 'broke the fix; its test failed; restored it', head: second, digest: 'digest:Replayed', policy: 'any' }]],+ ['reopen', [1, { agentId: 'coordinator', note: `${landed.file}: ${landed.name}; merge commit ${MERGE}` }]],+ ['appendFact', [1, { agentId: 'coordinator', kind: 'root-cause', text: 'the refusal was never declared' }]],+ ];+ journal.forEach(([operation, args], index) => {+ const move = legacyEngine.prepareEngineMove(old, operation, args, { id: `engine-${version}-rigor-${index}` });+ assert.equal(move.engine, version);+ const receipt = { sequence: index + 1, at: `2026-10-16T12:00:0${index}.000Z` };+ const oldOutcome = legacyEngine.applyEngineMove(old, move, receipt);+ assert.equal(oldOutcome.error, undefined, `released engine-${version} ${operation} applies: ${JSON.stringify(oldOutcome)}`);+ assert.deepEqual(applyEngineMove(current, move, receipt), oldOutcome, `engine-${version} ${operation} replays identically`);+ });+ assert.deepEqual(store.events(current), legacyStore.events(old), `engine-${version} reject, reopen and fact events replay with no cause field`);+ assert.ok(store.events(current).every((event) => !Object.hasOwn(JSON.parse(event.event_detail), 'cause')));+ const report = rigorReport(store.events(current), { person: store.PERSON });+ assert.deepEqual(report, { causes: [], uncaused: 1 }, 'the old reject has no key, and one landing failure on one commit is no repeat');+ const caused = prepareEngineMove(current, 'appendFact', [1, { agentId: 'coordinator', kind: 'root-cause', text: 'never again', cause: 'refusal:UNDECLARED', neverAgain: true, asPerson: true, channel: 'terminal' }]);+ assert.throws(() => legacyEngine.applyEngineMove(old, caused, { sequence: journal.length + 1, at: '2026-10-16T12:01:00.000Z' }),+ (error) => error.code === 'ENGINE_VERSION', `the engine-${version} client refuses a cause move before interpreting it`);+ }+});diff --git a/test/row-decisions-replay.test.js b/test/row-decisions-replay.test.jsindex 8f048ccf..8d471ca0 100644--- a/test/row-decisions-replay.test.js+++ b/test/row-decisions-replay.test.js@@ -144,7 +144,7 @@ test('captured person decisions and coordinator apply replay identically without});test('engine 12 records preserved decline text and replays a separate reason [S18,S19,H16]', (t) => {- assert.equal(ENGINE_VERSION, 12);+ assert.ok(ENGINE_VERSION >= 12, 'engine 12 and later record preserved decline text');const { source, copies: [one, two] } = decisionCopies(t);const preserved = {kind: 'spec', file: 'SPEC.md', id: 'G2',