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): draft repeated failures automatically [D1,D3,H16]
Corey Olson6645f4d726c4
diff --git a/docs/api.md b/docs/api.mdindex 8ae17676..e925b2a2 100644--- a/docs/api.md+++ b/docs/api.md@@ -280,6 +280,8 @@ The HTTP move is `{verb: "fact", item: 12, agent: "web-1", args: {kind: "measureRigor 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`.+New failure moves derive an omitted key from structured current-head review/landing evidence, exact conflict files (`conflict:<URI-escaped path>`), or the coded verdict/reopen category. A coded fallback is coarse grouping, not a demonstrated root cause. Explicit keys still win, and old recorded moves are not rewritten. When the existing repeat/hot-file threshold is reached, the move itself records an ordinary, unproved review-gated board draft with exact evidence. It edits no main-checkout file. Needs you shows the proposal immediately, and the coordinator shout is a receipt rather than a request to remember another drafting command. The proof-bearing command below still requires actual executed red/green evidence.+`pullboard flakes` lists recorded test failures: confirmed flake sightings, unclassified failures, possible regressions and stable red targets. Each observation retains the pinned source and complete raw/profile digests. Raw artifacts stay in the local common Git directory under `pullboard/flake-evidence/`; another device reading the board does not automatically receive those files. A paired pass never changes the original red verdict.The coordinator can run `pullboard flakes rerun on|off`, then commit `pullboard.json` to apply that policy. Paired diagnostics default off; recording remains on. On allows one exact-target pair for a supported structured Node target at unchanged source, with a pinned-main comparison. A green main is a possible regression. Unknown selectors, changed source and unsupported remote comparisons remain unclassified. A second confirmed sighting drafts ordinary strong repair work; it approves no spec or doctrine row. Off preserves the released landing diagnosis and its first legacy defect. Enabled landing consumes the saved pair, including after interruption, without another diagnostic measurement.@@ -605,6 +607,8 @@ Agents and the coordinator can set explicit item ranks with `milestone order <na`resume` on the coordinator seat includes `rigor: {undrafted: [...]}`, naming each repeated cause that has no live or approved proved draft. Each entry retains the ordinary Rigor cause key, item evidence and commits. The text resume names the proof-bearing `pullboard rigor draft` command. Declined repeats stay quiet until a new item repeats them. `needsYou` may contain an individual `kind: "rigor-draft"` call with `cause`, `evidence`, `proof`, a qualified spec or doctrine `target`, and `what: "Approve or Decline"`. An ordinary draft remains in the existing aggregate count; a Rigor draft is not counted twice. These fields add no person permission: the existing person-only approval and decline channels still apply.+Automatic evidence-only calls additionally carry `unproved: true`, `proof: null`, `materialized` and `collision`. Before materialization, `what` asks the coordinator to run `spec apply`; the browser labels the advice unproved and does not open a nonexistent file row. After materialization, the person uses the existing exact-row approval/decline path. A pending automatic proposal also satisfies the `undrafted` obligation. An unanswered automatic proposal appears once in each digest after the board's landing cadence (one day by default). No automatic proposal establishes a proved remedy or grants person authority.+A project may declare a `staticChecks` command in `pullboard.json` (empty by default). Submit uses the command from accepted main, and an explicit item check uses its accepted policy, so candidate settings cannot remove the guard. It runs before the frozen check and affected proof; a refusal retains the static log and reports the offending source. The existing queue and conservative browser classification still apply. Pullboard's own command checks actual CLI/View import bindings, the source-only prose command declaration, wall-clock budget explanations and doctrine counts. Browser prose behavior remains in the ordinary test suite.### Board-owned watchesdiff --git a/docs/formats.md b/docs/formats.mdindex 2a319385..a054b108 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -440,6 +440,7 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `unhold_item` | coordinator | `reason` || `guards` | board | `missing`, `changed`, `stale` || `rigor-notice` | rigor | `cause`, `items`, `occurrences`, `neverAgain`, `engine` |+| `rigor-draft` | rigor | `id`, `target`, `cause`, exact typed `source`, `unproved: true`, `items`, `occurrences`, `engine` || `shout` | sender | `shout`, `to`, `decision`, `request`, `answers` || `flake-observation` | reporting agent | `engine`, `observation` || `flake-repair` | reporting agent | `engine`, `key`, `item` |@@ -526,6 +527,12 @@ Engine 43 (`RIGOR_NOTICE_ENGINE`) posts one coordinator shout and one typed `rigA proved Rigor draft carries `source: rigor:<percent-encoded JSON>` with `version: 1`, its `key`, `evidence` (`items`, `occurrences`, `neverAgain`) and `proof` (`check`, `red`, `green`). The proof contains actual full commits, executed exit statuses and problem counts. The existing spec and doctrine row grammar reads this field; prose mentioning Rigor is not a typed source. The person uses ordinary Approve or Decline, and the coordinator applies the approved row without a new build item.+`RIGOR_AUTO_ENGINE` adds implicit evidence-only proposals to reject, reopen, person never-again and attributable conflict-hold moves. An omitted cause derives from a current-head structured reviewer failure, structured landing tests, exact conflict files, or a coarse coded verdict/reopen category; notes never identify tests. File keys use `conflict:<URI-escaped path>` and stay architectural advice rather than code-rule failures. Explicit `--cause` wins. Older recorded engines retain their original causes, notices and event streams.++The triggering transaction reserves ordinary `draftSpecRow` entries with `written: false`, `gate: review`, `tier: aim`, and a terminal `Source: rigor-auto:<percent-encoded JSON>` in their text. This distinct source has `version: 1`, `unproved: true`, `key` and exact repeat `evidence` (`items`, `occurrences`, `neverAgain`, event ids); it has no executed red/green proof. One receipt names the created drafts. It changes no repository file and approves no rule. Needs you exposes each pending proposal, including a visible collision if another row occupies its id with different fields. `spec apply` explicitly materializes these proposals after preflighting existing person decisions and all automatic row definitions across both files. The existing exact-file person approval/decline then applies. `rigor --draft-splits` prepares existing automatic split advice instead of creating a second proposal. An exact person replacement remains authoritative on later application; a stale or unrelated row cannot impersonate it.++Pending proposals are deduplicated per cause and target. A decline covers all items seen through the actual decision, and only a new item can re-propose that declined cause. The read-only digest restates each unanswered automatic draft once per briefing after `landing.cadence`, defaulting to one day when no cadence is configured. Creation is automatic on relevant new failure moves; this is not a historical backfill, a proof of causation, or an automatic remedy.+Engine 54 replaces the automatic strong-to-strong ceiling escalation with one coordinator notice per rejection pair, naming the builder and both rejection receipts. Ordinary rejection still reopens and clears the owner and lease. Light and mid routes keep engine-50 automatic escalation. Engines 50 through 53 retain their original ceiling escalation when replayed.## Approval provenancediff --git a/src/board-query.js b/src/board-query.jsindex e53f5b04..1fc224f2 100644--- a/src/board-query.js+++ b/src/board-query.js@@ -247,6 +247,12 @@ export function rowDecisions(board) {return row ? JSON.parse(row.meta_value) : [];}+/** The board's recorded row drafts, oldest first, without loading its mutation engine. */+export function rowDrafts(board) {+ const row = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get('row_drafts');+ return row ? JSON.parse(row.meta_value) : [];+}+/*** The SQL that picks an agent's unread shouts: to it, to its lane, or to all, from anyone else.*/diff --git a/src/board.js b/src/board.jsindex 892fd6c7..8991cf46 100644--- a/src/board.js+++ b/src/board.js@@ -158,6 +158,8 @@ import {rigorNoticeText,} from './rigor-notices.js';import { RIGOR_NOTICE_ENGINE } from './rigor-source.js';+import { RIGOR_AUTO_ENGINE } from './rigor-auto-engine.js';+import { deriveRigorCause, recordAutomaticRigorDrafts } from './rigor-auto.js';import {causeProblem,requireNeverAgain,@@ -1367,7 +1369,9 @@ export function verify(board, id, { agentId, decision, reason, note = '', cause,});const returnedAt = !isAccept && engine >= REOPEN_FIRST_REFUSAL_ENGINE && reopenFirstRefusalMinutes > 0 && item.item_built_by ? board.clock.now() : undefined;const reservation = !isAccept && engine >= REOPEN_FIRST_REFUSAL_ENGINE ? firstRefusalDetail(board, item, reopenFirstRefusalMinutes, returnedAt) : {};- const detail = { ...reservation, reason: code, commit: item.item_commit, ...(!isAccept && cause !== undefined && cause !== null ? { cause } : {}) };+ const derivedCause = !isAccept && engine >= RIGOR_AUTO_ENGINE+ ? deriveRigorCause(board, item, { cause, reason: code, agentId }) : !isAccept && cause != null ? { cause } : {};+ const detail = { ...reservation, reason: code, commit: item.item_commit, ...derivedCause };if (isAccept && engine >= SPEC_APPROVAL_ENGINE) detail.note = note.trim();if (isAccept && check !== undefined) detail.check = check;if (environment !== undefined) detail.environment = environment;@@ -1449,13 +1453,16 @@ export function reopen(board, id, { agentId, note = '', conflict, cause, reopenFconst returnedAt = (forMerge || landingFailure) && currentEngine >= REOPEN_FIRST_REFUSAL_ENGINE && reopenFirstRefusalMinutes > 0 && item.item_built_by ? board.clock.now() : undefined;const reservation = (forMerge || landingFailure) && currentEngine >= REOPEN_FIRST_REFUSAL_ENGINE ? firstRefusalDetail(board, item, reopenFirstRefusalMinutes, returnedAt) : {};const returned = forMerge ? { supersedes, ...conflictDetail(conflict) } : supersedes ? { supersedes, landingFailure } : {};+ const derivedCause = currentEngine >= RIGOR_AUTO_ENGINE+ ? deriveRigorCause(board, item, { cause, conflict, landingFailure, agentId }) : cause != null ? { cause } : {};+ const returnedWithCause = currentEngine >= RIGOR_AUTO_ENGINE ? { ...returned, ...derivedCause } : { ...derivedCause, ...returned };logEvent(board, agentId, 'reopen', id, { commit: submittedCommit, note: note.trim() || conflictNote(conflict), judgment: null, ...reservation,- ...(cause !== undefined && cause !== null ? { cause } : {}), ...returned }, returnedAt);+ ...returnedWithCause }, returnedAt);const trigger = board.lastEvent;tellFirstRefusal(board, item, reservation, persistShout);if (!reservation.reopenFirstRefusal && forMerge && supersedes === undefined && item.item_built_by) persistShout(board, { from: agentId, to: item.item_built_by, text: returnedHeadNotice(id, submittedCommit, conflict) });postRigorNotices(board, trigger);- return { id: item.item_id, commit: submittedCommit, ...returned };+ return { id: item.item_id, commit: submittedCommit, ...returnedWithCause };});}@@ -1916,6 +1923,10 @@ export function appendFact(board, id, { agentId, kind, text, ref = null, superse/** The enclosing move's transaction owns these implicit notices; older replay emits none. */function postRigorNotices(board, trigger) {if ((board.executionEngineVersion ?? ENGINE_VERSION) < RIGOR_NOTICE_ENGINE) return;+ if ((board.executionEngineVersion ?? ENGINE_VERSION) >= RIGOR_AUTO_ENGINE) {+ recordAutomaticRigorDrafts(board, trigger, persistShout);+ return;+ }for (const cause of newRigorNotices(events(board), trigger, { person: PERSON })) {persistShout(board, { from: 'rigor', to: COORDINATOR, text: rigorNoticeText(cause) });logEvent(board, 'rigor', 'rigor-notice', null, { cause: cause.key, items: cause.items,@@ -2186,6 +2197,7 @@ export function holdItem(board, id, { agentId, reason }) {const at = now(board);setItem(board, id, { item_hold_reason: text, item_hold_by: agentId, item_hold_at: at });logEvent(board, agentId, 'hold_item', id, { reason: text });+ if ((board.executionEngineVersion ?? ENGINE_VERSION) >= RIGOR_AUTO_ENGINE) postRigorNotices(board, board.lastEvent);return itemHold(board, id);});}diff --git a/src/commands/spec.js b/src/commands/spec.jsindex 54cac868..5a1de7c6 100644--- a/src/commands/spec.js+++ b/src/commands/spec.js@@ -1,4 +1,5 @@/** The pullboard spec command, in its own module so an item adding another command never edits these lines. */+import { planAutomaticRigorApply } from '../rigor-auto-apply.js';import {fitCommand,} from '../blueprint-fit-command.js';@@ -235,6 +236,11 @@ export async function specCommand(io, { first, second, rest, values }) {return withBoard(ctx, async (board) => {const me = whoAmI(ctx, board);if (!ctx.info.isMain || me.id !== COORDINATOR) throw new Refused('COORDINATOR_ONLY', 'only the coordinator applies row decisions; ask your coordinator to run pullboard spec apply');+ // Every automatic proposal is preflighted before any draft or decision changes a file.+ planRowApply(ctx.info.root, ctx.config, store.rowDecisions(board));+ const automatic = planAutomaticRigorApply(ctx.info.root, ctx.config, store.rowDrafts(board), store.rowDecisions(board));+ writeRowApply(ctx.info.root, automatic);+ automatic.files.forEach(file => io.say(`${file.file}: materialized unproved Rigor drafts for the person's review`));// A lane's board drafts (#878) reach SPEC.md as draft rows at their own ids; the person approves them there as before.const drafted = pendingRowDrafts(loadSpec(ctx.info.root, ctx.config), store.rowDrafts(board)).map((draft) => draftRow(ctx.info.root, ctx.config, { target: 'spec', text: draft.text, gate: draft.gate, tier: draft.tier, section: /^(.*?)\d+$/u.exec(draft.id)[1], id: draft.id }));drafted.forEach((row) => io.say(`${row.file}: ${row.id} drafted from a lane, for the person to approve`));diff --git a/src/digest.js b/src/digest.jsindex 365748cc..a46004c6 100644--- a/src/digest.js+++ b/src/digest.js@@ -40,6 +40,10 @@ import {import { healthReport } from './health.js';import { secretsIn } from './hooks.js';import { Refused } from './refused.js';+import { rowDrafts, rowDecisions } from './board-query.js';+import { automaticDecisionSource, automaticSourceFromText, rigorDecisionKey, readAutomaticRigorSource } from './rigor-auto-source.js';+import { rowDecisionContext, staleRowDecision } from './row-decision-state.js';+import { loadConfig } from './config.js';/** The briefing stays under 50 KB, counted in UTF-8 bytes. */export const DIGEST_MAX_BYTES = 50_000;@@ -223,6 +227,16 @@ function render(db, { name, now, root, config }) {const caughtEntries = caught.entries.slice().reverse().map((entry) =>`- ${caughtLabels.get(entry.kind)}: ${entry.item === null ? 'no item' : label(entry.item)}, ${text(entry.at, 40)}: ${text(entry.text, 400)}`);const caughtCounts = CAUGHT_KINDS.map(({ kind, label: words }) => `${caught.counts[kind]} ${words}`).join('; ');+ const draftDecisions = rowDecisions({ db });+ const cadence = (config ?? (root ? loadConfig(root) : null))?.landing?.cadenceMs ?? 86_400_000;+ const draftDecisionContext = root && draftDecisions.length ? rowDecisionContext(root, config ?? loadConfig(root)) : null;+ const unansweredRigor = rowDrafts({ db }).filter(draft => {+ const source = automaticSourceFromText(draft.text);+ return source && now.getTime() - Date.parse(draft.at) >= cadence+ && !draftDecisions.some(record => (!draftDecisionContext || !staleRowDecision(record, draftDecisionContext))+ && record.kind === draft.target && (record.id === draft.id && automaticDecisionSource(record) === source+ || record.event > draft.event && rigorDecisionKey(record) === readAutomaticRigorSource(source).key));+ }).map(draft => `- Rigor draft ${text(draft.id, 40)}: ${text(draft.text.slice(0, draft.text.lastIndexOf(' Source: ')), 700)}\n Unproved ${text(draft.target, 20)} proposal still waiting on the person; materialize with pullboard spec apply, then approve or decline.`);const sections = [section('Stuck and who moves it', stuck, stuck.length, 4_000, 'Nothing is stuck.'),section('Open work', open.slice(0, ROW_LIMIT).map(work), open.length, 8_000, 'Nothing is open.'),@@ -231,12 +245,13 @@ function render(db, { name, now, root, config }) {section('Recent decisions and answers', decisions.map((row) => row.entry), decisionTotal, 7_000, 'No decisions are recorded yet.'),section('Recent verdicts', verdicts, Number(db.prepare('SELECT count(*) AS n FROM verdict').get().n), 5_000, 'No work has been verified yet.'),section('Questions waiting on you', questions, Number(db.prepare(`SELECT count(*) AS n ${waiting}`).get().n), 4_500, 'No question waits on you.'),- section('Latest shouts to the coordinator', shouts, Number(db.prepare("SELECT count(*) AS n FROM shout WHERE shout_to = 'coordinator'").get().n), 5_000, 'No one has shouted the coordinator yet.'),+ section('Latest shouts to the coordinator', shouts, Number(db.prepare("SELECT count(*) AS n FROM shout WHERE shout_to = 'coordinator'").get().n), 3_000, 'No one has shouted the coordinator yet.'),section('Milestones', roadmap, roadmap.length, 4_000, 'No milestones are set.'),section(`What the board caught, last ${CAUGHT_DAYS} days`, caughtEntries, caught.total, 4_000, 'Nothing was caught in this window.'),+ section('Unanswered Rigor drafts', unansweredRigor, unansweredRigor.length, 2_000, 'No automatic draft is overdue.'),];// The per-kind counts sit under the heading, before the lines they count.- if (caught.total) sections.at(-1).text = sections.at(-1).text.replace('\n\n', `\n\n${caughtCounts}.\n\n`);+ if (caught.total) sections[9].text = sections[9].text.replace('\n\n', `\n\n${caughtCounts}.\n\n`);const sequence = Number(db.prepare('SELECT coalesce(max(event_id), 0) AS n FROM event').get().n);const glance = [`- ${landed} items landed and ${accepted} are accepted and wait to land.`,diff --git a/src/engine.js b/src/engine.jsindex 73181d83..9982ad43 100644--- a/src/engine.js+++ b/src/engine.js@@ -1,6 +1,7 @@import { BAR_READY_ENGINE } from './bar-ready-engine.js';import { barReadySetting } from './bar-readiness.js';import { ITEM_SHOUT_ENGINE } from './item-shout-engine.js';+import { RIGOR_AUTO_ENGINE } from './rigor-auto-engine.js';/** Versioned, deterministic replay through the CLI's existing board engine [H3,H16]. */import {createHash,@@ -96,6 +97,7 @@ const OPERATION_ENGINE = Object.freeze({ draftSpecRow: ROW_DRAFT_ENGINE, orderMi/** Dependency edits, causes, sealed reviews, submission proofs, trunk conflicts, health observations and milestone targets retain distinct recorded engine meanings. */function minimumOperationEngine(operation, args, board, at) {+ if (typeof args[1]?.cause === 'string' && args[1].cause.startsWith('conflict:')) return RIGOR_AUTO_ENGINE;if (['setBarReady', 'signBar'].includes(operation) || board && ['claim', 'submit', 'editItem', 'addItem', 'refreeze'].includes(operation) && barReadySetting(board).enabled) return BAR_READY_ENGINE;if (operation === 'recordPublishFinding') return PR_BRIDGE_ENGINE;if (operation === 'recordLandingTestDefect' || operation === 'verify' && args[1]?.environment !== undefineddiff --git a/src/needs-state.js b/src/needs-state.jsindex 86fe62ad..34d76906 100644--- a/src/needs-state.js+++ b/src/needs-state.js@@ -37,9 +37,10 @@ export function personNeedsState(root, { board: providedBoard = null, includeRigconst config = loadConfig(root);const state = projectSpecApprovals(projectFit(pendingFit(info.commonDir), projectRowDecisions(decisions, projectState(root, { board }))), specApprovalState(root, { board, config }));const rows = projectRowDecisions(decisions, { root, spec: loadSpec(root, config).rows, practice: loadDoctrine(root, config).rows });- const rigorDrafts = rigorDraftNeeds(rows);+ const drafts = store.rowDrafts(board);+ const rigorDrafts = rigorDraftNeeds(rows, drafts, decisions);const projected = { ...state, rigorDrafts, sentinelDrafts: sentinelDraftNeeds(sentinels(board)), blocks: recentBlocks(info.commonDir, board), ...(includeRigorUndrafted- ? { rigorUndrafted: undraftedRigor(store.events(board), rows, { person: store.PERSON }) } : {}) };+ ? { rigorUndrafted: undraftedRigor(store.events(board), rows, { person: store.PERSON, drafts, decisions }) } : {}) };return { ...projected, needs: personNeeds(projected) };} finally {if (!providedBoard) store.closeBoard(board);diff --git a/src/needs-summary.js b/src/needs-summary.jsindex 23f51232..e2dc27bb 100644--- a/src/needs-summary.js+++ b/src/needs-summary.js@@ -23,7 +23,7 @@ export function personNeedsSummary(root, { board, config }) {const projected = projectSpecApprovals({ ...rows,decisions: store.openDecisions(board, store.PERSON), holds: store.laneHolds(board),agents: store.listAgents(board).map(agent => ({ ...agent, displayName: displayAgentName(agent, config.agents.names) })),- rigorDrafts: rigorDraftNeeds(rows), sentinelDrafts: sentinelDraftNeeds(sentinels(board)), blocks: recentBlocks(repoInfo(root).commonDir, board),+ rigorDrafts: rigorDraftNeeds(rows, store.rowDrafts(board), store.rowDecisions(board)), sentinelDrafts: sentinelDraftNeeds(sentinels(board)), blocks: recentBlocks(repoInfo(root).commonDir, board),}, specApprovalState(root, { board, config, spec }));return projected;}diff --git a/src/rigor-auto-apply.js b/src/rigor-auto-apply.jsnew file mode 100644index 00000000..12acac7e--- /dev/null+++ b/src/rigor-auto-apply.js@@ -0,0 +1,45 @@+/** Explicitly materialize board proposals before the existing person-only exact-row decision [D1,S1]. */+import { readFileSync } from 'node:fs';+import { loadDoctrine } from './doctrine.js';+import { loadSpec, insertSectionRows } from './spec.js';+import { Refused } from './refused.js';+import { automaticDecisionSource, automaticSourceFromText, sameAutomaticRow } from './rigor-auto-source.js';+import { rowDecisionContext, staleRowDecision } from './row-decision-state.js';++/** Preflight every definition and both id namespaces before returning even the first file write. */+export function planAutomaticRigorApply(root, config, drafts, decisions = []) {+ const spec = loadSpec(root, config);+ const doctrine = loadDoctrine(root, config);+ const parsed = new Map([['spec', { ...spec, name: config.spec }], ['doctrine', { ...doctrine.repo, name: doctrine.name }]]);+ const pending = drafts.filter(draft => !draft.written && automaticSourceFromText(draft.text));+ if (!pending.length) return { records: [], files: [], signoffs: { receipts: [] } };+ const all = [...spec.rows.map(row => ({ ...row, target: 'spec' })), ...doctrine.repo.rows.map(row => ({ ...row, target: 'doctrine' }))];+ const byTarget = new Map();+ const decisionContext = rowDecisionContext(root, config);+ for (const draft of pending) {+ const file = parsed.get(draft.target);+ if (!file?.exists || file.problems.length) throw new Refused('ROW_DRAFT', `restore readable ${file?.name ?? draft.target} before materializing Rigor proposals`);+ const found = all.filter(row => row.id === draft.id);+ const decided = decisions.findLast(record => record.kind === draft.target && record.id === draft.id+ && automaticDecisionSource(record) === automaticSourceFromText(draft.text));+ // A person's exact replacement may deliberately change or remove the proposal source text.+ if (decided && found.length === 1 && found[0].target === draft.target && !staleRowDecision(decided, decisionContext)) continue;+ if (found.length) {+ if (found.length === 1 && found[0].target === draft.target && sameAutomaticRow(found[0], draft)) continue;+ throw new Refused('ROW_DRAFT', `${draft.id} already names different ${found.map(row => row.target).join('/')} text, gate or tier; resolve the collision before applying any automatic Rigor draft`);+ }+ if (!byTarget.has(draft.target)) byTarget.set(draft.target, []);+ byTarget.get(draft.target).push(draft);+ all.push(draft);+ }+ const files = [...byTarget].map(([target, entries]) => {+ const file = parsed.get(target);+ const before = readFileSync(file.file, 'utf8');+ const lines = entries.map(draft => `- ${draft.id} [draft, ${draft.tier}] ${draft.text} | gate: ${draft.gate}`);+ const section = file.sections.find(entry => /^RG\s*[·.:-]/u.test(entry.name));+ const after = section ? insertSectionRows(before, file, section, lines)+ : `${before}${before.endsWith('\n') ? '' : '\n'}\n## RG · Rigor proposals\n${lines.join('\n')}\n`;+ return { file: file.name, before, after };+ });+ return { records: [], files, signoffs: { receipts: [] } };+}diff --git a/src/rigor-auto-engine.js b/src/rigor-auto-engine.jsnew file mode 100644index 00000000..19f889c4--- /dev/null+++ b/src/rigor-auto-engine.js@@ -0,0 +1,3 @@+/** Automatic evidence-only Rigor drafts and derived cause receipts retain old replay [D1,H16]. */+import { unassignedEngine } from './engine-next.js';+export const RIGOR_AUTO_ENGINE = unassignedEngine();diff --git a/src/rigor-auto-source.js b/src/rigor-auto-source.jsnew file mode 100644index 00000000..09344e0c--- /dev/null+++ b/src/rigor-auto-source.js@@ -0,0 +1,86 @@+/** Evidence-only proposals are deliberately distinct from executed rigor: proofs [D1,S1]. */+import { causeProblem } from './rigor.js';+import { parseSpec } from './spec.js';+import { readRigorSource } from './rigor-source.js';+import { rowDecisionContext, staleRowDecision } from './row-decision-state.js';++/** Preserve exact repeat evidence in a portable one-line ordinary draft. */+export function automaticRigorSource(cause, eventIds) {+ return 'rigor-auto:' + encodeURIComponent(JSON.stringify({ version: 1, unproved: true, key: cause.key,+ evidence: { items: cause.items, occurrences: cause.occurrences, neverAgain: cause.neverAgain ?? false,+ events: [...new Set(eventIds)] } }));+}++/** Accept only typed evidence, never prose masquerading as a proof or a decided rule. */+export function readAutomaticRigorSource(source) {+ if (typeof source !== 'string' || !source.startsWith('rigor-auto:')) return null;+ try {+ const value = JSON.parse(decodeURIComponent(source.slice('rigor-auto:'.length)));+ if (value?.version !== 1 || value.unproved !== true || typeof value.key !== 'string' || causeProblem(value.key)+ || !Array.isArray(value.evidence?.items) || !Number.isSafeInteger(value.evidence.occurrences) || value.evidence.occurrences < 0+ || value.evidence.occurrences === 0 && value.evidence.neverAgain !== true+ || typeof value.evidence.neverAgain !== 'boolean' || !Array.isArray(value.evidence.events) || !value.evidence.events.length+ || value.evidence.events.some(id => !Number.isSafeInteger(id) || id < 1)+ || value.evidence.items.some(item => !Number.isSafeInteger(item?.id) || item.id < 1 || !Array.isArray(item.commits)+ || item.commits.some(commit => !/^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(commit)))) return null;+ return value;+ } catch { return null; /* Malformed historical metadata cannot establish a proposal. */ }+}++/** Read the complete terminal typed source without inferring identity from the surrounding advice. */+export function automaticSourceFromText(text) {+ const source = /(?:^| )Source: (rigor-auto:\S+)$/u.exec(text ?? '')?.[1];+ return readAutomaticRigorSource(source) ? source : null;+}++/** The exact automatic source captured in a person's existing file-backed row decision. */+export function automaticDecisionSource(record) {+ try {+ const rows = parseSpec(`## Decision\n${record.source ?? ''}\n`).rows;+ return rows.length === 1 ? automaticSourceFromText(rows[0].text) : null;+ } catch { return null; /* An unreadable old decision cannot decide a new proposal. */ }+}++/** A proved replacement decision also answers older unproved advice about that same cause. */+export function rigorDecisionKey(record) {+ try {+ const rows = parseSpec(`## Decision\n${record.source ?? ''}\n`).rows;+ return rows.length === 1 ? readRigorSource(rows[0].source)?.key+ ?? readAutomaticRigorSource(automaticSourceFromText(rows[0].text))?.key ?? null : null;+ } catch { return null; /* Only typed historical row provenance can answer a proposal. */ }+}++/** A materialized row must preserve the whole definition; merely occupying its id is a collision. */+export function sameAutomaticRow(row, draft) {+ const expected = parseSpec(`## Proposal\n- ${draft.id} [draft, ${draft.tier}] ${draft.text} | gate: ${draft.gate}\n`).rows[0];+ return expected && ['id', 'status', 'tier', 'text', 'gate', 'serves', 'signers', 'unknown', 'count', 'runs', 'mode', 'files', 'source']+ .every(key => JSON.stringify(row[key]) === JSON.stringify(expected[key]));+}++/** Show board-only drafts immediately, and keep mismatching file occupants visible until resolved. */+export function automaticRigorNeeds(state, drafts = [], decisions = []) {+ const rows = [...(state.spec ?? []).map(row => ({ ...row, target: 'spec' })),+ ...(state.practice ?? []).filter(row => row.origin !== 'standard').map(row => ({ ...row, target: 'doctrine' }))];+ const candidates = [...drafts.filter(draft => automaticSourceFromText(draft.text)),+ ...rows.filter(row => automaticSourceFromText(row.text) && !drafts.some(draft => draft.id === row.id && draft.target === row.target))];+ if (!candidates.length) return [];+ const context = state.root && decisions.length ? rowDecisionContext(state.root) : null;+ return candidates.flatMap(draft => {+ const source = automaticSourceFromText(draft.text);+ const parsed = readAutomaticRigorSource(source);+ if (rows.some(row => ['draft', 'pending', 'approved'].includes(row.status) && row.decision?.decision !== 'decline'+ && readRigorSource(row.source)?.key === parsed.key)) return [];+ const decided = decisions.some(record => context && !staleRowDecision(record, context)+ && (record.id === draft.id && record.kind === draft.target && automaticDecisionSource(record) === source+ || record.kind === draft.target && record.event > (draft.event ?? Infinity) && rigorDecisionKey(record) === parsed.key));+ const found = rows.filter(row => row.id === draft.id);+ const exact = found.length === 1 && found[0].target === draft.target && sameAutomaticRow(found[0], draft);+ if (decided || exact && found[0].decision) return [];+ const collision = found.length > 0 && !exact;+ return [{ kind: 'rigor-draft', id: `${draft.target}:${draft.id}`, ref: draft.target === 'doctrine' ? `doctrine:${draft.id}` : draft.id,+ target: `${draft.target}:${draft.id}`, text: `Rigor draft (unproved): ${draft.text.slice(0, draft.text.lastIndexOf(' Source: '))}`, cause: parsed.key,+ evidence: parsed.evidence, proof: null, unproved: true, materialized: exact, collision,+ what: collision ? 'Coordinator: resolve the row id collision before materializing this proposal'+ : exact ? 'Approve or Decline this unproved proposal' : 'Coordinator: materialize with pullboard spec apply; then the person approves or declines' }];+ });+}diff --git a/src/rigor-auto.js b/src/rigor-auto.jsnew file mode 100644index 00000000..57bcd705--- /dev/null+++ b/src/rigor-auto.js@@ -0,0 +1,87 @@+/** A failure move creates a durable, unproved proposal without writing a repository file [D1,H16]. */+import { events, logEvent, PERSON, rowDecisions } from './board.js';+import { draftSpecRow, rowDrafts } from './row-drafts.js';+import { causeProblem, eventCauses, rigorReport, testCause } from './rigor.js';+import { conflictNoteFiles, conflictReport, splitProposal } from './rigor-conflicts.js';+import { NATIVE_FLAKE_ENGINE } from './flake-engine.js';+import { automaticDecisionSource, automaticRigorSource, automaticSourceFromText, readAutomaticRigorSource, rigorDecisionKey } from './rigor-auto-source.js';+import { RIGOR_AUTO_ENGINE } from './rigor-auto-engine.js';++/** Prefer structured exact-head failures; a coded fallback is a coarse category, never a root-cause finding. */+export function deriveRigorCause(board, item, { cause, reason, conflict, landingFailure, agentId }) {+ if (cause !== undefined && cause !== null) return { cause };+ if (conflict?.files?.length) return { cause: `conflict:${encodeURI(conflict.files[0])}`,+ causes: [...new Set(conflict.files.map(file => `conflict:${encodeURI(file)}`))], causeDerivation: { kind: 'merge-conflict', files: [...conflict.files] } };+ const landing = landingFailure?.tests?.find(failure => !causeProblem(testCause(failure)));+ if (landing) return { cause: testCause(landing), causeDerivation: { kind: 'landing-failure', mergeCommit: landingFailure.mergeCommit } };+ const history = events(board);+ const submitted = history.findLast(event => event.item_id === item.item_id && event.event_kind === 'submit')?.event_id ?? 0;+ const failure = history.findLast(event => {+ if (event.event_id <= submitted || event.event_kind !== 'flake-observation' || event.event_by !== agentId) return false;+ const detail = JSON.parse(event.event_detail);+ const observation = detail.observation;+ return detail.engine === NATIVE_FLAKE_ENGINE && observation?.kind === 'verify' && observation.head === item.item_commit+ && observation.original?.green === false && typeof observation.file === 'string' && typeof observation.name === 'string'+ && !causeProblem(testCause(observation));+ });+ if (failure) return { cause: testCause(JSON.parse(failure.event_detail).observation),+ causeDerivation: { kind: 'recorded-failure', event: failure.event_id } };+ return { cause: `refusal:${reason ?? 'REOPENED'}`, causeDerivation: { kind: reason ? 'verdict-reason' : 'reopen-category', coarse: true } };+}++/** A decline covers every item seen by the actual decision, including repeats that preceded that decision. */+function proposalSuppressed(board, history, draft, cause) {+ const source = automaticSourceFromText(draft.text);+ if (readAutomaticRigorSource(source)?.key !== cause.key) return false;+ const decision = rowDecisions(board).findLast(record => record.kind === draft.target+ && (record.id === draft.id && automaticDecisionSource(record) === source+ || record.event > draft.event && rigorDecisionKey(record) === cause.key));+ if (!decision || decision.decision === 'approve') return true;+ const seen = new Set(history.filter(event => event.event_id <= decision.event).flatMap(event => {+ const detail = JSON.parse(event.event_detail);+ const matches = cause.key.startsWith('conflict:')+ ? event.event_kind === 'reopen' && detail.conflict?.files?.includes(cause.split.file)+ || event.event_kind === 'hold_item' && conflictNoteFiles(detail.reason)?.includes(cause.split.file)+ : eventCauses(event).includes(cause.key)+ || event.event_kind === 'fact' && event.event_by === PERSON && detail.neverAgain === true && detail.cause === cause.key;+ return matches && event.item_id !== null ? [event.item_id] : [];+ }));+ return !cause.items.some(item => !seen.has(item.id));+}++/** Draft the existing threshold's ordinary advice inside its triggering board transaction, never proving it. */+export function recordAutomaticRigorDrafts(board, trigger, shout) {+ const history = events(board);+ const detail = JSON.parse(trigger.event_detail);+ const keys = new Set(eventCauses(trigger));+ if (trigger.event_kind === 'fact' && trigger.event_by === PERSON && detail.neverAgain) keys.add(detail.cause);+ const causes = rigorReport(history, { person: PERSON }).causes.filter(cause => keys.has(cause.key));+ const conflicts = conflictReport(history, { now: board.clock.now() }).hotFiles+ .filter(file => trigger.event_kind === 'reopen' && detail.conflict?.files?.includes(file.file)+ || trigger.event_kind === 'hold_item' && conflictNoteFiles(detail.reason)?.includes(file.file))+ .map(file => ({ key: `conflict:${encodeURI(file.file)}`, reads: 'work', items: file.items.map(id => ({ id, commits: [] })),+ occurrences: file.events.length, neverAgain: false, split: file }));+ for (const cause of [...causes, ...conflicts]) {+ const eventIds = cause.split ? cause.split.events.map(event => event.id)+ : history.filter(event => eventCauses(event).includes(cause.key)+ || event.event_kind === 'fact' && event.event_by === PERSON && JSON.parse(event.event_detail).cause === cause.key).map(event => event.event_id);+ const targets = cause.reads === 'both' ? ['doctrine', 'spec'] : [cause.reads === 'product' ? 'spec' : 'doctrine'];+ const created = [];+ for (const target of targets) {+ if (rowDrafts(board).some(draft => draft.target === target && proposalSuppressed(board, history, draft, cause))) continue;+ const source = automaticRigorSource(cause, eventIds);+ const advice = cause.split ? splitProposal(cause.split).text+ : `Review how to prevent repeated ${JSON.stringify(cause.key).replaceAll('|', '\\u007c')} (${cause.items.map(item => `#${item.id}`).join(', ') || 'person-marked never again'}). No remedy or red/green proof has been established.`;+ const entry = draftSpecRow(board, { agentId: 'rigor', row: { id: `RG${trigger.event_id}1`, target,+ text: `${advice} Source: ${source}`, gate: 'review', tier: 'aim', section: 'RG' } });+ logEvent(board, 'rigor', 'rigor-draft', null, { engine: RIGOR_AUTO_ENGINE, id: entry.id, target, cause: cause.key,+ source, unproved: true, items: cause.items, occurrences: cause.occurrences });+ created.push({ id: entry.id, target });+ }+ if (created.length) {+ logEvent(board, 'rigor', 'rigor-notice', null, { engine: RIGOR_AUTO_ENGINE, cause: cause.key,+ items: cause.items, occurrences: cause.occurrences, neverAgain: cause.neverAgain, drafts: created });+ shout(board, { from: 'rigor', to: 'coordinator', text: `Rigor recorded unproved ${created.map(entry => `${entry.target} draft ${entry.id}`).join(' and ')} for ${cause.key}, from ${cause.items.map(item => `#${item.id}`).join(', ') || 'the person’s never-again decision'}. It is in Needs you; no rule was approved or applied.` });+ }+ }+}diff --git a/src/rigor-notices.js b/src/rigor-notices.jsindex 9a44e60a..a6e9092e 100644--- a/src/rigor-notices.js+++ b/src/rigor-notices.js@@ -6,6 +6,8 @@ import {rigorReport,} from './rigor.js';import { parseSpec } from './spec.js';+import { automaticRigorNeeds, automaticSourceFromText, readAutomaticRigorSource } from './rigor-auto-source.js';+import { RIGOR_AUTO_ENGINE } from './rigor-auto-engine.js';import {readRigorSource,RIGOR_NOTICE_ENGINE,@@ -26,7 +28,8 @@ function declinedRigorSource(source) {let rows;try { rows = parseSpec(`## Source\n${source}\n`).rows; }catch { return null; } // Historical metadata is optional; a parser refusal must never abort the original item move.- return rows.length === 1 ? readRigorSource(rows[0].source) : null;+ return rows.length === 1 ? readRigorSource(rows[0].source)+ ?? readAutomaticRigorSource(automaticSourceFromText(rows[0].text)) : null;}/** Reconstruct notice and exact person-decline state from ordered receipts, never free text. */@@ -40,7 +43,7 @@ function noticeState(events, person) {if (event.item_id !== null) seen.get(key).add(event.item_id);}const detail = JSON.parse(event.event_detail);- if (event.event_kind === 'rigor-notice' && event.event_by === 'rigor' && detail.engine === RIGOR_NOTICE_ENGINE+ if (event.event_kind === 'rigor-notice' && event.event_by === 'rigor' && [RIGOR_NOTICE_ENGINE, RIGOR_AUTO_ENGINE].includes(detail.engine)&& typeof detail.cause === 'string' && !causeProblem(detail.cause)) notified.set(detail.cause, event.event_id);if (event.event_kind !== 'row_decision' || event.event_by !== person || detail.record?.decision !== 'decline') continue;const source = declinedRigorSource(detail.record.source);@@ -76,19 +79,20 @@ function rigorRows(state) {}/** Proved drafts are individual person calls, with their real evidence and both executed commits. */-export function rigorDraftNeeds(state) {- return rigorRows(state).filter(({ row }) => row.status === 'draft' && !row.decision).map(({ row, source }) => ({+export function rigorDraftNeeds(state, drafts = [], decisions = []) {+ return [...automaticRigorNeeds(state, drafts, decisions), ...rigorRows(state).filter(({ row }) => row.status === 'draft' && !row.decision).map(({ row, source }) => ({kind: 'rigor-draft', id: `${row.kind}:${row.id}`, ref: row.kind === 'doctrine' ? `doctrine:${row.id}` : row.id,text: `Rigor draft: ${row.text}`, what: 'Approve or Decline', target: `${row.kind}:${row.id}`,cause: source.key, evidence: source.evidence, proof: source.proof,- }));+ }))];}/** Resume asks the coordinator to draft each repeated cause that has no live or approved proved row. */-export function undraftedRigor(events, state, { person }) {+export function undraftedRigor(events, state, { person, drafts = [], decisions = [] }) {const notices = noticeState(events, person);const drafted = new Set(rigorRows(state).filter(({ row }) => row.decision?.decision === 'approve'|| (!row.decision && ['draft', 'pending', 'approved'].includes(row.status))).map(({ source }) => source.key));+ for (const need of automaticRigorNeeds(state, drafts, decisions)) drafted.add(need.cause);return rigorReport(events, { person }).causes.filter(cause => !drafted.has(cause.key) && !declinedRepeat(cause, notices));}diff --git a/src/rigor-splits.js b/src/rigor-splits.jsindex eb2a7000..4638cdf9 100644--- a/src/rigor-splits.js+++ b/src/rigor-splits.js@@ -2,6 +2,9 @@import { loadDoctrine } from './doctrine.js';import { proposeDoctrine } from './doctrine-rulings.js';import { Refused } from './refused.js';+import { automaticSourceFromText, readAutomaticRigorSource } from './rigor-auto-source.js';+import { planAutomaticRigorApply } from './rigor-auto-apply.js';+import { writeRowApply } from './row-decisions.js';import {splitAlreadyProposed,splitProposal,@@ -24,6 +27,18 @@ export async function draftConflictSplits(ctx, report, { read, reserve }) {const splitDrafts = [];for (const file of report.hotFiles) {const doctrine = loadDoctrine(ctx.info.root, ctx.config);+ const automatic = state.rows.findLast(row => row.target === 'doctrine'+ && readAutomaticRigorSource(automaticSourceFromText(row.text))?.key === `conflict:${encodeURI(file.file)}`);+ if (automatic) {+ // The old explicit command prepares the already recorded advice, rather than asking twice.+ const plan = planAutomaticRigorApply(ctx.info.root, ctx.config, [automatic], state.decisions ?? []);+ if (plan.files.length) {+ writeRowApply(ctx.info.root, plan);+ const row = loadDoctrine(ctx.info.root, ctx.config).repo.rows.find(row => row.id === automatic.id);+ splitDrafts.push({ id: `doctrine:${row.id}`, row });+ }+ continue;+ }if (splitAlreadyProposed(doctrine.repo.rows, file)) continue;// A reservation is not a materialized draft: a crash between these two writes must be recoverable.const interrupted = state.rows.find(row => row.written && row.target === 'doctrine'diff --git a/src/rigor.js b/src/rigor.jsindex 624aaf0f..6aa544c6 100644--- a/src/rigor.js+++ b/src/rigor.js@@ -10,9 +10,9 @@ import { BOARD_SENTINEL_ENGINE } from './sentinel-engine.js';import { NATIVE_FLAKE_ENGINE } from './flake-engine.js';/** The 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>', 'sentinel:<name>']);+export const CAUSE_FORMS = Object.freeze(['test:<file>::<title>', 'refusal:<CODE>', 'row:<id>', 'doctrine:<id>', 'sentinel:<name>', 'conflict:<file>']);-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.]*)|sentinel:(?<sentinel>[a-z0-9][a-z0-9._-]{0,63}))$/u;+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.]*)|sentinel:(?<sentinel>[a-z0-9][a-z0-9._-]{0,63})|conflict:(?<conflict>[^\r\n\0]+))$/u;/** Refusal codes that name a merge conflict: a collision between branches, never a repeated error. */const CONFLICT_CODES = new Set(['MERGE_CONFLICT']);@@ -69,6 +69,7 @@ export function testCause({ file, name }) {* @returns {boolean}*/export function isMergeConflict(key) {+ if (key.startsWith('conflict:')) return true;const parts = CAUSE.exec(key)?.groups;if (!parts) return false;if (parts.code) return CONFLICT_CODES.has(parts.code);@@ -106,6 +107,9 @@ export function eventCauses(event) {if (event.event_kind === 'sentinel-failure' && (event.event_by !== 'sentinel' || detail.engine !== BOARD_SENTINEL_ENGINE)) return [];const keys = [];if (typeof detail.cause === 'string' && !causeProblem(detail.cause)) keys.push(detail.cause);+ if (Array.isArray(detail.causes)) for (const cause of detail.causes) {+ if (typeof cause === 'string' && !causeProblem(cause) && !keys.includes(cause)) keys.push(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;diff --git a/src/row-drafts.js b/src/row-drafts.jsindex a5d141ea..0b77ac7a 100644--- a/src/row-drafts.js+++ b/src/row-drafts.js@@ -21,12 +21,8 @@ import {} from './spec.js';import { cleanGitEnvironment } from './git.js';import { trunkRef } from './trusted-policy-read.js';--/** The board's recorded row drafts, oldest first. */-export function rowDrafts(board) {- const row = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get('row_drafts');- return row ? JSON.parse(row.meta_value) : [];-}+import { rowDrafts } from './board-query.js';+export { rowDrafts } from './board-query.js';/*** Reserve one new row's id on the board, and for a lane, record the drafted row itself. Every writerdiff --git a/test/digest.test.js b/test/digest.test.jsindex 67b58a71..ff24394e 100644--- a/test/digest.test.js+++ b/test/digest.test.js@@ -157,7 +157,7 @@ test('the digest is a readable briefing of one board [A2,N26]', (t) => {const body = (text) => text.slice(text.indexOf('## At a glance')).trimEnd();assert.equal(body(json.markdown), body(markdown), 'the JSON result carries the same briefing');assert.deepEqual(json.sections.map((entry) => entry.title), ['Stuck and who moves it', 'Open work', 'Blocked work', 'In review', 'Recent decisions and answers',- 'Recent verdicts', 'Questions waiting on you', 'Latest shouts to the coordinator', 'Milestones', 'What the board caught, last 30 days']);+ 'Recent verdicts', 'Questions waiting on you', 'Latest shouts to the coordinator', 'Milestones', 'What the board caught, last 30 days', 'Unanswered Rigor drafts']);const out = join(box.dir, 'briefing.md');writeFileSync(out, 'an older briefing');diff --git a/test/rigor-auto.test.js b/test/rigor-auto.test.jsnew file mode 100644index 00000000..91da5694--- /dev/null+++ b/test/rigor-auto.test.js@@ -0,0 +1,300 @@+/** @pullboard-test-loads src/board.js src/engine.js src/machine.js */+/** Automatic Rigor proposals retain evidence, never invent proof or person approval [D1,D3,H16]. */+import assert from 'node:assert/strict';+import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { after, test } from 'node:test';+import * as store from '../src/board.js';+import { personNeedsState } from '../src/needs-state.js';+import { readDigest } from '../src/digest.js';+import { submitFixture } from './board-submit-fixture.js';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';+import { planAutomaticRigorApply } from '../src/rigor-auto-apply.js';+import { planRowApply, prepareRowDecisions, writeRowApply } from '../src/row-decisions.js';+import { loadConfig } from '../src/config.js';+import { RIGOR_AUTO_ENGINE } from '../src/rigor-auto-engine.js';+import { prepareEngineMove, applyEngineMove } from '../src/engine.js';+import { conflictNote } from '../src/trunk-conflict.js';++const roots = [];+after(() => { for (const root of roots) rmSync(root, { recursive: true, force: true }); });++/** A real repository and private SQLite board; all failure receipts below are synthetic board fixtures. */+function fixture() {+ const root = mkdtempSync(join(tmpdir(), 'pullboard-rigor-auto-'));+ roots.push(root);+ const env = { ...process.env, 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]',+ PULLBOARD_HOME: join(root, 'private-home'), PULLBOARD_MACHINE_HOME: join(root, 'private-machine') };+ for (const key of Object.keys(env)) if (key.startsWith('GIT_') && !key.startsWith('GIT_CONFIG_')+ && !key.startsWith('GIT_AUTHOR_') && !key.startsWith('GIT_COMMITTER_')) delete env[key];+ /** Run Git only inside this private fixture. */+ const git = (...args) => runFixtureGit(args, { cwd: root, env, encoding: 'utf8' });+ /** Invoke only this checkout's CLI against the private fixture board. */+ const run = (...args) => runFixtureChild(process.execPath, [join(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd: root, env, encoding: 'utf8' });+ git('init', '-q', '-b', 'main');+ writeFileSync(join(root, 'pullboard.json'), JSON.stringify({ name: 'Rigor fixture', gate: 'true', spec: 'SPEC.md',+ lanes: { app: { owns: ['src/'] } }, landing: { cadence: '1h' } }));+ writeFileSync(join(root, 'SPEC.md'), '# Spec\n\n## G · Goals\n- G1 [approved, must] Keep the product coherent. | gate: review\n');+ writeFileSync(join(root, 'DOCTRINE.md'), '# Doctrine\n\n## DR · Rulings\n');+ git('add', '.'); git('commit', '-q', '-m', 'chore: prepare isolated Rigor fixture');+ const policy = { version: 1, commit: git('rev-parse', 'HEAD').trim(), verify: { policy: 'any', family: 'off' } };+ const directory = join(root, '.git', 'pullboard');+ mkdirSync(directory, { recursive: true });+ const file = join(directory, 'board.sqlite');+ let now = new Date('2026-10-24T12:00:00Z');+ const board = store.openBoard(file, { now: () => new Date(now) });+ store.ensureCoordinator(board, root);+ const builder = store.register(board, { lane: 'app', path: join(root, 'builder'), model: 'Fixture builder' });+ const reviewer = store.register(board, { lane: 'app', path: join(root, 'reviewer'), model: 'Fixture reviewer' });+ let serial = 0;+ /** Add and submit a distinct synthetic commit through the normal board moves. */+ const submit = (title) => {+ const id = store.addItem(board, { by: 'coordinator', lane: 'app', title });+ store.claim(board, id, { agentId: builder, lane: 'app', leaseMs: 7_200_000,+ freeze: item => ({ text: JSON.stringify({ criterion: item.item_title, policy }), digest: `fixture:${item.item_title}` }) });+ const commit = (++serial).toString(16).padStart(40, '0');+ submitFixture(board, id, { agentId: builder, commit, tree: 'e'.repeat(40) });+ return id;+ };+ /** Record an unclassified original failure, with no claim that this fixture executed a test. */+ const failure = (id, name = 'the same behavior fails') => store.recordFlakeObservation(board, { agentId: reviewer,+ lane: 'app', observation: { id: `fixture-${serial}`, head: store.getItem(board, id).item_commit,+ tree: 'e'.repeat(40), main: null, kind: 'verify', classification: 'unclassified',+ commandSha256: 'a'.repeat(64), reason: 'synthetic original failure; no gate execution', at: now.toISOString(),+ diagnosticMs: 0, load: { average: [0, 0, 0], cpus: 1, freeMB: 1 },+ file: 'test/example.test.js', name, paired: null, mainReceipt: null,+ original: { green: false, sha256: 'b'.repeat(64), bytes: 0,+ artifact: `flake-evidence/fixture-${serial}/original.log`, profileSha256: null } } });+ /** Reject with an optional explicit key, never deriving evidence from the prose note. */+ const reject = (id, options = {}) => store.verify(board, id, { agentId: reviewer, decision: 'REJECT',+ reason: 'TEST_FAILURE', note: 'synthetic failure receipt', head: store.getItem(board, id).item_commit,+ digest: store.getItem(board, id).item_frozen_digest, policy: 'any', ...options });+ return { root, file, board, git, run, submit, failure, reject,+ advance: ms => { now = new Date(now.getTime() + ms); }, close: () => store.closeBoard(board) };+}++test('a repeated cause becomes a draft row in Needs you with no command run [D1,D3,S1]', () => {+ const box = fixture();+ try {+ const before = ['SPEC.md', 'DOCTRINE.md', 'pullboard.json'].map(file => readFileSync(join(box.root, file), 'utf8'));+ const one = box.submit('First test failure'); box.failure(one); box.reject(one);+ assert.equal(JSON.parse(store.events(box.board, { itemId: one }).findLast(event => event.event_kind === 'reject').event_detail).cause,+ 'test:test/example.test.js::the same behavior fails');+ assert.equal(store.rowDrafts(box.board).length, 0, 'one occurrence is not a repeat');+ const two = box.submit('Second test failure'); box.failure(two); box.reject(two);+ const proposals = store.rowDrafts(box.board);+ assert.ok(proposals.length > 0, 'the second reject itself creates a durable proposal');+ assert.ok(proposals.every(row => !row.written && row.gate === 'review'), 'no automatic approval or file application');+ const needs = personNeedsState(box.root, { board: box.board }).needs.filter(need => need.kind === 'rigor-draft');+ assert.ok(needs.length > 0, 'the person sees the board-only draft immediately');+ assert.ok(needs.every(need => need.unproved === true && need.proof == null));+ assert.ok(needs.some(need => need.evidence.items.map(item => item.id).join(',') === `${one},${two}`));++ for (const title of ['First merge collision', 'Second merge collision']) {+ const id = box.submit(title);+ store.reopen(box.board, id, { agentId: 'coordinator', conflict: { files: ['src/shared.js'], trunk: 'd'.repeat(40) } });+ const event = store.events(box.board, { itemId: id }).findLast(entry => entry.event_kind === 'reopen');+ assert.equal(JSON.parse(event.event_detail).cause, 'conflict:src/shared.js');+ }+ const split = personNeedsState(box.root, { board: box.board }).needs.find(need => need.cause === 'conflict:src/shared.js');+ assert.ok(split?.unproved, 'the second merge reopen creates architectural advice for the person');+ assert.match(split.text, /splitting/iu);+ assert.deepEqual(['SPEC.md', 'DOCTRINE.md', 'pullboard.json'].map(file => readFileSync(join(box.root, file), 'utf8')), before);+ assert.equal(box.git('status', '--porcelain').trim(), '', 'the original moves leave the main checkout clean');+ assert.ok(store.allShouts(box.board).filter(shout => shout.shout_from === 'rigor').every(shout => !shout.shout_text.includes('Next: pullboard rigor draft')),+ 'automatic shouts are receipts, not remembered-command requests');+ } finally { box.close(); }+});++test('Rigor keeps explicit keys, ignores stale failures and does not duplicate a pending draft [D1,H16]', () => {+ const box = fixture();+ try {+ const first = box.submit('Explicit key'); box.failure(first); box.reject(first, { cause: 'row:G1' });+ assert.equal(JSON.parse(store.events(box.board, { itemId: first }).findLast(event => event.event_kind === 'reject').event_detail).cause, 'row:G1');+ const second = box.submit('No current failure'); box.reject(second);+ assert.equal(JSON.parse(store.events(box.board, { itemId: second }).findLast(event => event.event_kind === 'reject').event_detail).cause, 'refusal:TEST_FAILURE');+ const third = box.submit('Same coded reason'); box.reject(third);+ const count = store.rowDrafts(box.board).length;+ const fourth = box.submit('One more coded reason'); box.reject(fourth);+ assert.equal(store.rowDrafts(box.board).length, count, 'a pending proposal stays one person call');+ assert.ok(count > 0);+ assert.equal(store.listItems(box.board, { all: true }).filter(item => item.item_status === 'verified').length, 0);+ } finally { box.close(); }+});++test('an unanswered Rigor draft is restated once in each read-only digest after the board cadence [D1,A2]', () => {+ const box = fixture();+ try {+ for (const title of ['First', 'Second']) { const id = box.submit(title); box.reject(id); }+ box.advance(3_600_001);+ const before = store.events(box.board).length;+ const digest = readDigest(box.file, { root: box.root, now: box.board.clock.now() });+ assert.match(digest.markdown, /Unanswered Rigor drafts/u);+ const ids = store.rowDrafts(box.board).map(row => row.id);+ for (const id of ids) assert.equal(digest.markdown.split(`Rigor draft ${id}:`).length - 1, 1);+ assert.equal(store.events(box.board).length, before, 'reading a digest records no reminder move');+ } finally { box.close(); }+});++test('materialized Rigor advice uses the existing person decision and a decline covers every preceding item [D1,B26,S1]', () => {+ const box = fixture();+ try {+ for (const title of ['First', 'Second', 'Third before decline']) { const id = box.submit(title); box.reject(id); }+ const [draft] = store.rowDrafts(box.board);+ const ref = `doctrine:${draft.id}`;+ const config = loadConfig(box.root);+ assert.throws(() => prepareRowDecisions(box.root, config, { ids: [ref], decision: 'decline', reason: 'not the right remedy' }),+ error => error.code === 'NO_ROW', 'a board-only proposal cannot bypass the existing exact-file person decision');+ const need = personNeedsState(box.root, { board: box.board }).needs.find(entry => entry.id === ref);+ assert.equal(need.materialized, false);+ assert.match(need.what, /materialize/u);+ writeRowApply(box.root, planAutomaticRigorApply(box.root, config, store.rowDrafts(box.board)));+ assert.deepEqual(planAutomaticRigorApply(box.root, config, store.rowDrafts(box.board)).files, [], 'materialization is idempotent');+ assert.equal(personNeedsState(box.root, { board: box.board }).needs.find(entry => entry.id === ref).materialized, true);+ const records = prepareRowDecisions(box.root, config, { ids: [ref], decision: 'decline', reason: 'not the right remedy', on: box.board.clock.now().toISOString() });+ store.recordRowDecisions(box.board, { agentId: store.PERSON, channel: 'terminal', decisions: records });+ assert.equal(personNeedsState(box.root, { board: box.board }).needs.some(entry => entry.id === ref), false);+ const fourth = box.submit('New item after decline'); box.reject(fourth);+ assert.equal(store.rowDrafts(box.board).length, 2, 'a genuinely new item after the decision can reopen the question');+ const newNeed = personNeedsState(box.root, { board: box.board }).needs.find(entry => entry.kind === 'rigor-draft');+ assert.ok(newNeed.evidence.items.some(item => item.id === fourth));+ } finally { box.close(); }+});++test('a cross-file row collision stays visible and refuses before any automatic proposal is materialized [D1,S1]', () => {+ const box = fixture();+ try {+ for (const title of ['First', 'Second']) { const id = box.submit(title); box.failure(id); box.reject(id); }+ const draft = store.rowDrafts(box.board).find(row => row.target === 'doctrine');+ const spec = join(box.root, 'SPEC.md');+ writeFileSync(spec, readFileSync(spec, 'utf8') + `- ${draft.id} [approved, aim] ${draft.text} | gate: a different gate\n`);+ const before = ['SPEC.md', 'DOCTRINE.md'].map(file => readFileSync(join(box.root, file), 'utf8'));+ assert.throws(() => planAutomaticRigorApply(box.root, loadConfig(box.root), store.rowDrafts(box.board)),+ error => error.code === 'ROW_DRAFT' && /collision/u.test(error.message));+ assert.deepEqual(['SPEC.md', 'DOCTRINE.md'].map(file => readFileSync(join(box.root, file), 'utf8')), before);+ assert.equal(personNeedsState(box.root, { board: box.board }).needs.find(need => need.id === `doctrine:${draft.id}`).collision, true);+ } finally { box.close(); }+});++test('a person can replace automatic advice without breaking a later spec apply [D1,B26,S1]', () => {+ const box = fixture();+ try {+ for (const title of ['First', 'Second']) { const id = box.submit(title); box.reject(id); }+ const config = loadConfig(box.root);+ const drafts = store.rowDrafts(box.board);+ writeRowApply(box.root, planAutomaticRigorApply(box.root, config, drafts));+ const records = prepareRowDecisions(box.root, config, { ids: [`doctrine:${drafts[0].id}`], decision: 'approve',+ text: 'The person chooses a different remedy.', on: box.board.clock.now().toISOString() });+ store.recordRowDecisions(box.board, { agentId: store.PERSON, channel: 'terminal', decisions: records });+ const plan = planRowApply(box.root, config, store.rowDecisions(box.board));+ writeRowApply(box.root, plan);+ store.applyRowDecisions(box.board, { agentId: 'coordinator', events: plan.records.map(record => record.event) });+ assert.deepEqual(planAutomaticRigorApply(box.root, config, drafts, store.rowDecisions(box.board)).files, []);+ assert.match(readFileSync(join(box.root, 'DOCTRINE.md'), 'utf8'), /\[approved, aim\] The person chooses a different remedy\./u);+ assert.equal(personNeedsState(box.root, { board: box.board }).needs.some(need => need.kind === 'rigor-draft'), false);+ const doctrine = join(box.root, 'DOCTRINE.md');+ writeFileSync(doctrine, readFileSync(doctrine, 'utf8').replace(' | gate: review', ' | gate: a changed gate'));+ assert.equal(personNeedsState(box.root, { board: box.board }).needs.find(need => need.id === `doctrine:${drafts[0].id}`).collision, true,+ 'a later edit cannot hide behind the old person decision');+ assert.throws(() => planAutomaticRigorApply(box.root, config, drafts, store.rowDecisions(box.board)), error => error.code === 'ROW_DRAFT');+ box.advance(3_600_001);+ assert.ok(readDigest(box.file, { root: box.root, now: box.board.clock.now() }).markdown.includes(`Rigor draft ${drafts[0].id}:`),+ 'the overdue digest also retains a proposal whose old decision is stale');+ } finally { box.close(); }+});++test('a stale person decision refuses spec apply before any unrelated automatic draft is written [D1,B26,S1]', () => {+ const box = fixture();+ try {+ const config = loadConfig(box.root);+ const records = prepareRowDecisions(box.root, config, { ids: ['G1'], decision: 'approve', on: box.board.clock.now().toISOString() });+ store.recordRowDecisions(box.board, { agentId: store.PERSON, channel: 'terminal', decisions: records });+ const spec = join(box.root, 'SPEC.md');+ writeFileSync(spec, readFileSync(spec, 'utf8').replace('Keep the product coherent.', 'Changed after the decision.'));+ for (const title of ['First', 'Second']) { const id = box.submit(title); box.reject(id); }+ const before = ['SPEC.md', 'DOCTRINE.md'].map(file => readFileSync(join(box.root, file), 'utf8'));+ const applied = box.run('spec', 'apply', '--json');+ assert.equal(applied.status, 1, applied.stdout + applied.stderr);+ assert.equal(JSON.parse(applied.stdout).error.code, 'STALE_ROW_DECISION');+ assert.deepEqual(['SPEC.md', 'DOCTRINE.md'].map(file => readFileSync(join(box.root, file), 'utf8')), before);+ } finally { box.close(); }+});++test('declining a never-again proposal stays quiet for the same item and records no invented proof [D1,B26]', () => {+ const box = fixture();+ try {+ const id = box.submit('A person-marked responsibility');+ /** Record the person's explicit never-again move on this private board. */+ const mark = () => store.appendFact(box.board, id, { agentId: 'coordinator', kind: 'root-cause', text: 'Do not repeat this',+ cause: 'doctrine:C3', neverAgain: true, asPerson: true, channel: 'terminal' });+ mark();+ const drafts = store.rowDrafts(box.board);+ assert.equal(drafts.length, 1);+ const need = personNeedsState(box.root, { board: box.board }).needs.find(entry => entry.kind === 'rigor-draft');+ assert.equal(need.evidence.occurrences, 0);+ assert.equal(need.proof, null);+ const config = loadConfig(box.root);+ writeRowApply(box.root, planAutomaticRigorApply(box.root, config, drafts));+ const records = prepareRowDecisions(box.root, config, { ids: [`doctrine:${drafts[0].id}`], decision: 'decline',+ reason: 'No new rule is needed.', on: box.board.clock.now().toISOString() });+ store.recordRowDecisions(box.board, { agentId: store.PERSON, channel: 'terminal', decisions: records });+ mark();+ assert.equal(store.rowDrafts(box.board).length, 1);+ assert.equal(personNeedsState(box.root, { board: box.board }).needs.some(entry => entry.kind === 'rigor-draft'), false);+ } finally { box.close(); }+});++test('old ordered rejects replay without new causes or automatic drafts [D1,H16]', () => {+ const box = fixture();+ try {+ const id = box.submit('Old reject');+ const item = store.getItem(box.board, id);+ const move = prepareEngineMove(box.board, 'verify', [id, { agentId: 'app-2', decision: 'REJECT',+ reason: 'TEST_FAILURE', note: 'old coded verdict', head: item.item_commit, digest: item.item_frozen_digest, policy: 'any' }]);+ move.engine = RIGOR_AUTO_ENGINE - 1;+ const outcome = applyEngineMove(box.board, move, { sequence: 1, at: box.board.clock.now().toISOString() });+ assert.equal(outcome.error, undefined, JSON.stringify(outcome.error));+ const event = store.events(box.board, { itemId: id }).findLast(entry => entry.event_kind === 'reject');+ assert.equal(Object.hasOwn(JSON.parse(event.event_detail), 'cause'), false);+ assert.equal(store.rowDrafts(box.board).length, 0);+ } finally { box.close(); }+});++test('merge path identity survives spaces and line breaks without turning advice into a code rule [D1,C7]', () => {+ const box = fixture();+ try {+ const path = 'src/a b|c\n.js';+ for (const title of ['First conflict', 'Second conflict']) {+ const id = box.submit(title);+ store.reopen(box.board, id, { agentId: 'coordinator', conflict: { files: [path], trunk: 'd'.repeat(40) } });+ const event = store.events(box.board, { itemId: id }).findLast(entry => entry.event_kind === 'reopen');+ const detail = JSON.parse(event.event_detail);+ assert.equal(detail.cause, `conflict:${encodeURI(path)}`);+ assert.deepEqual(detail.causeDerivation.files, [path]);+ }+ const drafts = store.rowDrafts(box.board);+ assert.equal(drafts.length, 1);+ assert.equal(drafts[0].target, 'doctrine');+ assert.equal(drafts[0].gate, 'review');+ writeRowApply(box.root, planAutomaticRigorApply(box.root, loadConfig(box.root), drafts));+ assert.equal(personNeedsState(box.root, { board: box.board }).needs.find(entry => entry.kind === 'rigor-draft').materialized, true);+ } finally { box.close(); }+});++test('canonical conflict holds crossing the hot-file threshold also draft advice without a command [D1,C7]', () => {+ const box = fixture();+ try {+ for (const title of ['First held item', 'Second held item', 'Third held item']) {+ const id = store.addItem(box.board, { by: 'coordinator', lane: 'app', title });+ store.holdItem(box.board, id, { agentId: 'coordinator', reason: conflictNote({ files: ['src/shared.js'], trunk: 'd'.repeat(40) }) });+ }+ assert.equal(store.rowDrafts(box.board).length, 1, 'the third hold does not duplicate pending advice');+ const need = personNeedsState(box.root, { board: box.board }).needs.find(entry => entry.kind === 'rigor-draft');+ assert.equal(need.cause, 'conflict:src/shared.js');+ assert.equal(need.unproved, true);+ assert.equal(box.git('status', '--porcelain').trim(), '', 'the automatic holds do not edit the repository');+ } finally { box.close(); }+});diff --git a/test/rigor-checks.test.js b/test/rigor-checks.test.jsindex 9c09d721..9fb1db4c 100644--- a/test/rigor-checks.test.js+++ b/test/rigor-checks.test.js@@ -27,6 +27,7 @@ import { draftConflictSplits } from '../src/rigor-splits.js';import { proposeDoctrine } from '../src/doctrine-rulings.js';import { conflictNote } from '../src/trunk-conflict.js';import { conflictNoteFiles, conflictReport } from '../src/rigor-conflicts.js';+import { RIGOR_AUTO_ENGINE } from '../src/rigor-auto-engine.js';import {breachLine,changeRange,@@ -138,9 +139,10 @@ function fixture(name) {}/** Record synthetic conflict history through public board moves, without claiming gates ran. */-function conflictHistory() {+function conflictHistory({ automatic = true } = {}) {const box = conflictE2e.project('true');const board = store.openBoard(join(box.repo, '.git/pullboard/board.sqlite'));+ if (!automatic) board.executionEngineVersion = RIGOR_AUTO_ENGINE - 1;try {const builder = store.register(board, { lane: 'web', path: join(box.dir, 'history-builder'), model: 'Fixture builder' });const reviewer = store.register(board, { lane: 'web', path: join(box.dir, 'history-reviewer'), model: 'Fixture reviewer' });@@ -194,7 +196,7 @@ test('a hot file becomes a draft split proposal [D1,C7]', () => {assert.equal(row.gate, 'review', 'a suggestion has no fabricated executable proof');assert.match(row.text, /splitting "src\/cli\.js"/u);assert.match(row.text, /one module per command/u);- assert.match(row.text, /Source: conflict-split:/u);+ assert.match(row.text, /Source: rigor-auto:/u, 'the explicit command materializes the advice already created by the failure move');assert.doesNotMatch(row.text, /Source: rigor:/u);assert.deepEqual(doctrine.repo.rows.filter(row => row.id !== draft.row.id), original, 'existing judgments remain unchanged');assert.equal(readFileSync(join(box.repo, 'SPEC.md'), 'utf8'), beforeSpec);@@ -422,8 +424,8 @@ test('Pullboard\'s four checks count what main has [D1, C7]', async (t) => {});});-test('a split draft resumes after its row is reserved [D1]', async () => {- const box = conflictHistory();+test('a legacy split draft resumes after its row is reserved [D1,H16]', async () => {+ const box = conflictHistory({ automatic: false });const board = store.openBoard(join(box.repo, '.git/pullboard/board.sqlite'));try {const report = conflictReport(store.events(board));@@ -464,8 +466,8 @@ test('a split draft resumes after its row is reserved [D1]', async () => {});-test('concurrent split proposals keep one reserved row [D1]', async () => {- const box = conflictHistory();+test('concurrent legacy split proposals keep one reserved row [D1,H16]', async () => {+ const box = conflictHistory({ automatic: false });const board = store.openBoard(join(box.repo, '.git/pullboard/board.sqlite'));try {const report = conflictReport(store.events(board));diff --git a/test/rigor.test.js b/test/rigor.test.jsindex d0dc40bf..aefd8dcb 100644--- a/test/rigor.test.js+++ b/test/rigor.test.js@@ -134,10 +134,11 @@ function noticeHistory(box) {return history(box.file, { freeze: item => frozenCriterion(loadSpec(box.repo, config), item, loadDoctrine(box.repo, config)) });}-test('a repeated cause tells the coordinator once [D1,D3]', () => {+test('engine 43 repeated-cause notices retain their deferred proved-draft workflow [D1,D3,H16]', () => {const box = freshBoard();const proof = noticeProof(box);const historyBox = noticeHistory(box);+ historyBox.board.executionEngineVersion = RIGOR_NOTICE_ENGINE;const cause = 'doctrine:C3';const ids = ['First', 'Second', 'Third', 'After decline', 'Still quiet'].map(historyBox.add);const notices = () => store.allShouts(historyBox.board).filter(shout => shout.shout_from === 'rigor');@@ -353,7 +354,7 @@ test('a repeated failure cause is noticed [D1,V1]', () => {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.+ // No explicit cause or failure receipt: use the coarse coded verdict, never the test named in prose.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.@@ -372,7 +373,7 @@ test('a repeated failure cause is noticed [D1,V1]', () => {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(repeated.uncaused, 0, 'the coded verdict supplies a coarse key without parsing its note as test evidence');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.@@ -390,14 +391,14 @@ test('a repeated failure cause is noticed [D1,V1]', () => {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>, sentinel:<name>)',- 'rigor says how many rejects and reopens are uncaused');- assert.equal(lines.length, 4);+ assert.equal(lines[3], '0 rejects and reopens carry no cause key; name one with --cause <key> (test:<file>::<title>, refusal:<CODE>, row:<id>, doctrine:<id>, sentinel:<name>, conflict:<file>)');+ assert.equal(lines.length, 4, 'the single coarse verdict is not a repeat; the zero-uncaused footer remains explicit');});test('rigor reads old events by their structured fields only, never by their notes [D1,V1]', () => {const box = freshBoard();const board = history(box.file);+ board.board.executionEngineVersion = RIGOR_NOTICE_ENGINE;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.