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
Merge remote-tracking branch 'origin/main' into core/713-merge
Corey Olsona6c309312456
diff --cc docs/formats.mdindex e1d1cd7d,56cc62a3..ce3367e3--- a/docs/formats.md+++ b/docs/formats.md@@@ -102,7 -102,7 +102,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` | `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. |-| `move engine` | `19` | `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` | `23` | `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,8 -113,8 +113,10 @@@ Engine 11 permits resubmitting the samEngine 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.+ Engine 19 makes a corrected bar record why the old one was wrong. Once an item has ever been claimed, an `editItem` that changes its criterion or check must carry `reason`, the text of what the old bar got wrong; without one it is refused with `BAR_REASON`, naming `--reason`. The edit event then records `reason` and `barCorrection: {fields, reject}`: `fields` lists `criterion` and/or `check`, and `reject` is `{verdict, by, reason, at}` when the item's newest verdict is a reject no earlier correction already explained, or `null`. That reject is counted as caused by the bar. The board derives `barCorrection` from its own rows; a move supplies only `reason`. An edit before any claim needs no reason and records one only if given. `pullboard stats` JSON adds `bars`, keyed by agent: `{corrections, barRejects, buildRejects}`. Corrections and the rejects they explain count to the agent who corrected the bar; any other reject counts as the build's, to the agent who added the item. An `editItem` move carrying `reason` requires engine 19, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor. Moves recorded under engines 18 and earlier replay without the reason rule. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.+++Engine 23 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 23; engine-22 and older moves replay unchanged, and clients on an older engine refuse an engine-23 move with `RELAY_MOVE` before changing their board or cursor. Engine numbers 20 to 22 are allocated to other changes.+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 src/board.jsindex 8d9091bf,090581bb..2214797e--- a/src/board.js+++ b/src/board.js@@@ -14,7 -15,7 +15,9 @@@ import { briefFiles, briefSections } frimport { 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 { barCorrectionFields } from './bar-corrections.js';++import { factReference } from './fact-reference.js';import { parseSpec } from './spec.js';export const ACCEPT_REASON = 'CRITERION_MET';@@@ -2064,21 -2064,21 +2068,9 @@@ export function events(board, { itemId/** Fact labels distinguish observations from judgements reserved to an item's live holder [B29,B30]. */export const FACT_KINDS = Object.freeze(['capture', 'measurement', 'note', 'diff', 'decision', 'rejection', 'supersession', 'root-cause']);const FACT_JUDGEMENTS = new Set(['decision', 'rejection', 'supersession', 'root-cause']);-- /** Validate a portable code binding without reading source on replicas that hold only board data [B32,H7]. */- export function factReference(ref) {- if (ref === null || ref === undefined) return null;- const parts = typeof ref === 'string' && /^([^\r\n\0]+):(\d+)(?:-(\d+))?@([0-9a-f]{40})$/iu.exec(ref);- if (!parts) throw new Refused('BAD_FACT_REF', 'a fact reference needs path:line[-line]@full-sha with all 40 hexadecimal characters; use the full git commit id');- const [, path, first, last, commit] = parts;- const start = Number(first), end = Number(last ?? first);- if (path.startsWith('/') || path.includes('\\') || /^[A-Za-z]:/u.test(path) || path.split('/').some((part) => !part || part === '.' || part === '..') || !Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 1 || end < start) {- throw new Refused('BAD_FACT_REF', 'a fact reference needs a relative repo path and a positive ascending line range; use path:line[-line]@full-sha');- }- return { path, start, end, commit: commit.toLowerCase() };- }++export { factReference };-/** Validate a portable code binding without reading source on replicas that hold only board data [B32,H7]. */-export function factReference(ref) {- if (ref === null || ref === undefined) return null;- const parts = typeof ref === 'string' && /^([^\r\n\0]+):(\d+)(?:-(\d+))?@([0-9a-f]{40})$/iu.exec(ref);- if (!parts) throw new Refused('BAD_FACT_REF', 'a fact reference needs path:line[-line]@full-sha with all 40 hexadecimal characters; use the full git commit id');- const [, path, first, last, commit] = parts;- const start = Number(first), end = Number(last ?? first);- if (path.startsWith('/') || path.includes('\\') || /^[A-Za-z]:/u.test(path) || path.split('/').some((part) => !part || part === '.' || part === '..') || !Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 1 || end < start) {- throw new Refused('BAD_FACT_REF', 'a fact reference needs a relative repo path and a positive ascending line range; use path:line[-line]@full-sha');- }- 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,diff --cc src/cli.jsindex 8e2cb3b4,3c5fb08f..b1660847--- a/src/cli.js+++ b/src/cli.js@@@ -71,8 -73,7 +73,8 @@@ import { tour } from './tour.js'import { commandOutput, refusalDocument } from './json.js';import { forgetProject, listApiProjects, registerProjectAndLink, registeredProjectRootsSnapshot } from './projects.js';import { milestoneRoadmap } from './roadmap.js';+import { rigorLines, rigorReport } from './rigor.js';- import { listResources, runnerResourceStatus } from './resources.js';+ import { listResources, memoryVerdict, readMachineMemory, runnerResourceStatus } from './resources.js';import { citedTestFiles, rowEvidence, rowStage } from './evidence.js';import { exportView, serveView } from './serve.js';import { forgetView, rememberView, runningView } from './view-session.js';diff --cc src/engine.jsindex 5b6dc297,8f1c9ca0..aebb61bb--- a/src/engine.js+++ b/src/engine.js@@@ -2,7 -2,8 +2,8 @@@import { createHash, randomUUID } from 'node:crypto';import * as store from './board.js';import { recordedRefusal } from './recorded-refusal.js';+ import { BAR_ENGINE, carriesBarReason } from './bar-corrections.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,13 -23,10 +23,14 @@@ export const ENGINE_OPERATIONS = Object/** 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;- * a cause key on a reject, reopen or person fact adds engine-13 meaning the same way (#713).-/** Dependency edits add engine-10 meaning, and edit reasons engine-19 meaning, without changing ordinary historical edit envelopes. */++/** Dependency edits add engine-10 meaning, edit reasons engine-19 meaning, and a cause key on a++ * reject, reopen or person fact engine-23 meaning (#713), without changing ordinary historical envelopes.+ */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;+ if (carriesBarReason(operation, args)) return BAR_ENGINE;return operation === 'editItem' && options && Object.hasOwn(options, 'after') && options.after !== undefined? 10 : OPERATION_ENGINE[operation] ?? 1;}diff --cc src/fact-reference.jsindex 00000000,00000000..e2e83f25new file mode 100644--- /dev/null+++ b/src/fact-reference.js@@@ -1,0 -1,0 +1,25 @@@++/**++ * A fact's code reference, path:line[-line]@full-sha, checked without reading source [B32,H7].++ *++ * Why its own module: replicas that hold only board data validate the same binding, and++ * src/board.js keeps under its next 100-line block.++ */++import { Refused } from './refused.js';++++/**++ * Validate a portable code binding without reading source on replicas that hold only board data [B32,H7].++ *++ * @param {string | null | undefined} ref++ * @returns {{ path: string, start: number, end: number, commit: string } | null}++ */++export function factReference(ref) {++ if (ref === null || ref === undefined) return null;++ const parts = typeof ref === 'string' && /^([^\r\n\0]+):(\d+)(?:-(\d+))?@([0-9a-f]{40})$/iu.exec(ref);++ if (!parts) throw new Refused('BAD_FACT_REF', 'a fact reference needs path:line[-line]@full-sha with all 40 hexadecimal characters; use the full git commit id');++ const [, path, first, last, commit] = parts;++ const start = Number(first), end = Number(last ?? first);++ if (path.startsWith('/') || path.includes('\\') || /^[A-Za-z]:/u.test(path) || path.split('/').some((part) => !part || part === '.' || part === '..') || !Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 1 || end < start) {++ throw new Refused('BAD_FACT_REF', 'a fact reference needs a relative repo path and a positive ascending line range; use path:line[-line]@full-sha');++ }++ return { path, start, end, commit: commit.toLowerCase() };++}diff --cc src/machine.jsindex 7476ed8a,bbd1cfb9..c66dd9dd--- a/src/machine.js+++ b/src/machine.js@@@ -10,10 -10,7 +10,10 @@@*//** Executable move semantics, carried by every sealed move and retained during replay [H16]. */- export const ENGINE_VERSION = 13;-export const ENGINE_VERSION = 19;++export const ENGINE_VERSION = 23;++/** 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;++export const CAUSE_ENGINE = 23;/** @typedef {'agent' | 'coordinator' | 'clock'} Role */diff --cc test/agent-model-engine.test.jsindex 3a577ef1,ba92a56d..b6bc3962--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@@ -11,8 -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.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])) {- assert.equal(ENGINE_VERSION, 19, 'engine 19 preserves the released engine-8 through engine-11 model behavior');++ assert.equal(ENGINE_VERSION, 23, 'engine 23 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]) {const board = store.openBoard(':memory:');t.after(() => store.closeBoard(board));const registration = prepareEngineMove(board, 'register', [{ lane: 'web', path: '/web', model: 'First Model' }]);diff --cc test/pending-refreeze.test.jsindex a60496da,7191bfc2..e1f98045--- a/test/pending-refreeze.test.js+++ b/test/pending-refreeze.test.js@@@ -261,7 -261,7 +261,7 @@@ async function checkDependencyLegacyCli}test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {- assert.ok(ENGINE_VERSION >= 12);- assert.equal(ENGINE_VERSION, 19);++ assert.equal(ENGINE_VERSION, 23);const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));const cleanup = [];t.after(() => {diff --cc test/rigor.test.jsindex 6647bb75,00000000..ed5578e0mode 100644,000000..100644--- a/test/rigor.test.js+++ b/test/rigor.test.js@@@ -1,286 -1,0 +1,289 @@@+/** 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');+ // An uncaused reject: no structured cause and no --cause, so it records no key and is counted.+ const uncausedItem = board.add('Uncaused');+ board.submit(uncausedItem); board.reject(uncausedItem, undefined, `${catalog.slice('test:'.length).replace('::', ': ')} failed`);+ // 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');+ assert.equal(repeated.uncaused, 1, 'the uncaused reject is counted, and its note naming the catalog test is never read as a key');+ assert.equal(test.items.length, 2, 'the uncaused reject does not join the catalog cause');++ // 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[3], '1 rejects and reopens carry no cause key; name one with --cause <key> (test:<file>::<title>, refusal:<CODE>, row:<id>, doctrine:<id>)',+ 'rigor says how many rejects and reopens are uncaused');+ assert.equal(lines.length, 4);+});++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');++ for (const older of [19, CAUSE_ENGINE - 1]) {++ assert.throws(() => applyEngineMove(board.board, { ...move, engine: older }, { sequence: 1, at: new Date().toISOString() }),++ (error) => error.code === 'RELAY_MOVE', `an engine-${older} move cannot carry a cause key`);++ assert.equal(store.getItem(board.board, second).item_status, 'submitted', `the engine-${older} refusal changes nothing`);++ }+ 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`);+ }+});