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): announce repeats and show proved drafts [D1,D3,S1]
Corey Olson32c2ebb359ba
diff --git a/docs/api.md b/docs/api.mdindex ab99a561..53955992 100644--- a/docs/api.md+++ b/docs/api.md@@ -472,3 +472,5 @@ Unavailable Git-object verdict projections are retried on the next read, so fetcWhen the runner's own resource pool refuses the run's setup, the run fails at once with `RUNNER_SETUP_REFUSED`, naming the runner host and the pool's refusal code. It is not retried, and it leaves no holder or waiter on either machine.Agents and the coordinator can set explicit item ranks with `milestone order <name> <ids>` (comma-separated ids from that milestone). It replaces that milestone’s `order` list in board metadata; other items stay unranked. `next` compares milestone, explicit rank, then its existing route/recent-file/age tie-breaks. A never-ranked board keeps its existing order. Removing an item drops its rank; adding it again leaves it unranked. This does not change newcomer help or person flows.++`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.diff --git a/docs/formats.md b/docs/formats.mdindex 49cd536f..9c896102 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -113,7 +113,7 @@ The board file is in the repository's Git common directory at `.git/pullboard/bo| `row grammar` | `1` | `SPEC_GRAMMAR_VERSION` in `src/spec.js`; optional `<!-- pullboard-grammar N -->` line in either file (absence means the current grammar) | Both files share the version. A declared version must match; an incompatible grammar change requires a coordinated version bump and compatible files. No automatic conversion occurs. || `board schema` | `2` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | Create missing tables and indexes, add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. || `event log` | `1` | `EVENT_LOG_VERSION` in `src/board.js`, persisted in `board_meta` as `event_log_version` | Older event-log versions upgrade in place; newer versions are refused with `EVENT_LOG_VERSION`. Preserve event rows when the board schema changes. |-| `move engine` | `34` | `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` | `43` | `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.@@ -326,7 +326,7 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `edit` | editor | `brief`, `route`, `criterion`, `check`, `unfrozen`, optional `after`, optional `pendingRefreeze`, engine-19 `reason`, `barCorrection` || `escalate` | builder | `from`, `to`, `note`, `attempt` || `attempt` | reporting agent | `n`, `seconds`, `result` |-| `fact` | author | `id`, `kind`, `text`, `ref`, `supersedes`, engine-20 `implies`, `decision`, `supersededBy` |+| `fact` | author | `id`, `kind`, `text`, `ref`, `supersedes`, engine-20 `implies`, `decision`, `supersededBy`, engine-30 `cause`, `neverAgain`, `channel` || `claim` | builder | `leaseUntil`, `digest` || `renew` | builder | `leaseUntil`, `digest` || `release` | builder | — |@@ -348,6 +348,7 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `hold_item` | coordinator | `reason` || `unhold_item` | coordinator | `reason` || `guards` | board | `missing`, `changed`, `stale` |+| `rigor-notice` | rigor | `cause`, `items`, `occurrences`, `neverAgain`, `engine` || `shout` | sender | `shout`, `to`, `decision`, `request`, `answers` || `pass` | coordinator | `shout`, `to`, `decision`, `request`, `answers` || `answer` | answerer | `shout`, `to`, `decision`, `request`, `answers`, `outcome`, `channel`, engine-20 `implies`, `supersedes` |@@ -414,3 +415,7 @@ Engine 8 adds `recordLandingBatch`, `recordLandingWaiver`, `recordLandingFlake`A person waiver records its identity, named test, expiry, reason and person channel. A distinct landing proof records the exact batch tree and each failing test with its covering waiver identity. Pre-push checks every waiver against the current time; this proof never writes an ordinary green-gate stamp. Flake records retain a test path, source digest, failing names and one defect item, so a repeated observation does not create another defect.Engine 34 adds the agent/coordinator `orderMilestoneItems` move, carrying a milestone name and its ordered subset of item ids. Earlier engines refuse it before changing the board or replay cursor. Ranked item ids stay with their milestone in its `order` metadata; old entries without it keep their prior queue order. Recorded next/reserve moves below engine 34 retain their original ordering even when later metadata contains ranks. The stable minimum is `MILESTONE_RANK_ENGINE` (34); engine slots 25 through 33 belong to their separately allocated train items.++Engine 43 (`RIGOR_NOTICE_ENGINE`) posts one coordinator shout and one typed `rigor-notice` receipt when a reject, reopen or person never-again fact makes a cause repeat. Both are part of that move’s transaction. Recorded engines through 42 retain their original event streams. A person’s exact row-decision receipt for a typed Rigor source silences that repeat until a new item repeats it; later commits on an already known item do not override the decline.++A 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.diff --git a/docs/formats.test.js b/docs/formats.test.jsindex 5886351f..84e0a5cb 100644--- a/docs/formats.test.js+++ b/docs/formats.test.js@@ -342,6 +342,7 @@ function recordEventContract() {withdraw(board, withdrawn, { agentId: coordinator, reason: 'duplicate fixture' });holdLane(board, 'view', { agentId: coordinator, reason: 'fixture hold' });releaseLane(board, 'view', { agentId: coordinator });+ appendFact(board, first, { agentId: coordinator, kind: 'root-cause', text: 'A typed immediate Rigor format example', cause: 'doctrine:C3', neverAgain: true, asPerson: true, channel: 'terminal' });const rows = events(board).map((row) => ({ ...row, detail: JSON.parse(row.event_detail) }));closeBoard(board);return { rows, actors: { [coordinator]: 'coordinator', [builder]: 'builder', [returnedBuilder]: 'builder', [reviewer]: 'reviewer', [PERSON]: 'person', board: 'board' } };@@ -610,6 +611,7 @@ test('[A5] schema, versions, event kinds and event detail fields match live behaattempt: 'reporting agent',fact: 'author',guards: 'board',+ 'rigor-notice': 'rigor',shout: 'sender',pass: 'coordinator',answer: 'answerer',diff --git a/src/board.js b/src/board.jsindex 3a482360..85582be4 100644--- a/src/board.js+++ b/src/board.js@@ -18,6 +18,8 @@ import { COORDINATOR } from './config.js';import { ENGINE_VERSION, VERDICT_REVIEW_ENGINE, MILESTONE_RANK_ENGINE, GUARDS, IN_STATE, MOVES, STATES, UNKNOWN_MOVE, effectiveGuards, storeTriggers } from './machine.js';import { Refused } from './refused.js';import { causeProblem, requireNeverAgain } from './rigor.js';+import { newRigorNotices, rigorNoticeText } from './rigor-notices.js';+import { RIGOR_NOTICE_ENGINE } from './rigor-source.js';import { barCorrectionFields } from './bar-corrections.js';import { factReference } from './fact-reference.js';import { factFromEvent, requestAnswerRefusal, tellAnswerImplications, tellFactImplications, tellVerdictImplications } from './implies.js';@@ -1548,7 +1550,9 @@ export function verify(board, id, { agentId, decision, reason, note = '', cause,if (isAccept && check !== undefined) detail.check = check;if (newReview) detail.review = { commit: review.commit, ...(Object.hasOwn(review, 'head') ? { head: review.head } : {}), trunk: review.trunk, paths: [...review.paths] };logEvent(board, agentId, verb, id, implies?.length ? { ...detail, implies } : detail);+ const trigger = board.lastEvent;tellVerdictImplications(board, (by, itemId, fact) => logEvent(board, by, 'fact', itemId, fact), id, { seed: impliesId, implies });+ if (!isAccept) postRigorNotices(board, trigger);return { decision, reason: code, ...(isAccept && check !== undefined ? { check } : {}) };});}@@ -1614,6 +1618,7 @@ export function reopen(board, id, { agentId, note, cause }) {});logEvent(board, agentId, 'reopen', id, { commit: submittedCommit, note: note.trim(), judgment: null,...(supersedes ? { supersedes, landingFailure } : {}), ...(cause !== undefined && cause !== null ? { cause } : {}) });+ postRigorNotices(board, board.lastEvent);return { id: item.item_id, commit: submittedCommit, ...(supersedes ? { supersedes, landingFailure } : {}) };});}@@ -1851,6 +1856,12 @@ function insertShout(board, { from, to, text, lanes, decision = false, answers =if (personAnswer && !['terminal', 'view'].includes(channel)) {throw new Refused('B26_PERSON_CHANNEL', 'record the person answer through the terminal or the view; run pullboard view');}+ return persistShout(board, { from, to, text, decision, answers, evidence, request, channel, detail, outcome, personAnswer });+}++/** Persist a validated message or a fixed internal notice inside the caller's transaction. */+function persistShout(board, { from, to, text, decision = false, answers = null, evidence = null, request = false,+ channel = 'terminal', detail = {}, outcome = '', personAnswer = false }) {const result = board.db.prepare(`INSERT INTO shout (shout_from, shout_to, shout_text, shout_at, shout_decision, shout_answers,@@ -2105,10 +2116,23 @@ export function appendFact(board, id, { agentId, kind, text, ref = null, superseconst binding = factReference(ref);if (neverAgain || asPerson || cause !== null) requireNeverAgain(id, { agentId, cause, neverAgain, asPerson, channel });logEvent(board, neverAgain ? PERSON : agentId, 'fact', id, { id: factId, kind, text, ref: binding, supersedes, ...(neverAgain ? { cause, neverAgain: true, channel } : {}), ...(implies?.length ? { implies } : {}) });- return tellFactImplications(board, (by, itemId, fact) => logEvent(board, by, 'fact', itemId, fact), factFromEvent(board.lastEvent), { id, implies, supersedes });+ const trigger = board.lastEvent;+ const result = tellFactImplications(board, (by, itemId, fact) => logEvent(board, by, 'fact', itemId, fact), factFromEvent(trigger), { id, implies, supersedes });+ if (neverAgain) postRigorNotices(board, trigger);+ return result;});}+/** 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;+ 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,+ occurrences: cause.occurrences, neverAgain: cause.neverAgain, engine: RIGOR_NOTICE_ENGINE });+ }+}+/*** Rank items by the first unfinished milestone that contains them, leaving unlisted work last.* A finished milestone no longer holds back later releases.diff --git a/src/cli.js b/src/cli.jsindex 21c9b757..9327cdd7 100644--- a/src/cli.js+++ b/src/cli.js@@ -1345,10 +1345,12 @@ function resumeHere(io, view) {const staleVerdicts = pendingMerges.filter(item => item.item_verdict_state);const decisionSections = isMain ? coordinatorDecisionSections(board, ctx) : null;const { shouts = [], ...decisions } = decisionSections ?? {};+ const needsState = personNeedsState(root, { board });return {me,all,- needsYou: personNeeds(personNeedsState(root, { board })),+ needsYou: personNeeds(needsState),+ ...(me.id === COORDINATOR ? { rigor: { undrafted: needsState.rigorUndrafted } } : {}),...(decisionSections ? { ...decisions, ...verifiedMergeGroups(root, pendingMerges, shouts, ctx.clock.now().getTime()),flow: proofStats(board, { now: ctx.clock.now().getTime() }).flow } : {}),requests: me.id === COORDINATOR ? store.openRequests(board) : [],@@ -1467,6 +1469,7 @@ function resumeHere(io, view) {section(card.needsYou, (need) => need.kind === 'decision'? `waiting on the person: #${need.id} from ${need.ref} (${span(ctx, need.at)}): ${firstLine(need.text)}`: `needs the person: ${need.ref}: ${firstLine(need.text)} (${need.what})`);+ section(card.rigor?.undrafted ?? [], (cause) => `Rigor needs a proved draft: ${cause.key}, items ${cause.items.map(item => `#${item.id}`).join(', ')}; pullboard rigor draft "${cause.key.replaceAll('"', '\\"')}" "<rule>" --check "<command>" --red <commit> --green <commit>`);if (card.toVerify.length) say('review queue:');section(card.toVerify, (item) => ` to verify: #${item.item_id} ${item.item_lane} (${span(ctx, item.item_updated_at)})`);if (card.toMerge.length) say('merge verified work, run the gate, then record each with pullboard merged <id> <commit>');diff --git a/src/machine.js b/src/machine.jsindex 95a77760..656c02ca 100644--- a/src/machine.js+++ b/src/machine.js@@ -10,7 +10,8 @@*//** Executable move semantics, carried by every sealed move and retained during replay [H16]. */-export const ENGINE_VERSION = 34;+import { RIGOR_NOTICE_ENGINE } from './rigor-source.js';+export const ENGINE_VERSION = RIGOR_NOTICE_ENGINE;/** The engine at which a reject, reopen or person fact can carry a cause key (#713); older moves replay unchanged [D1,H16]. */export const CAUSE_ENGINE = 30;diff --git a/src/needs-state.js b/src/needs-state.jsindex 659656b8..3a421a35 100644--- a/src/needs-state.js+++ b/src/needs-state.js@@ -5,13 +5,24 @@ import { repoInfo } from './git.js';import { projectRowDecisions } from './row-decisions.js';import { pendingFit, projectFit } from './blueprint-fit.js';import { projectState } from './serve.js';+import { loadConfig } from './config.js';+import { loadSpec } from './spec.js';+import { loadDoctrine } from './doctrine.js';+import { rigorDraftNeeds, undraftedRigor } from './rigor-notices.js';+import { personNeeds } from './needs.js';/** Borrow an existing connection or open a read-only one; retain exact row-decision matching. */export function personNeedsState(root, { board: providedBoard = null } = {}) {const info = repoInfo(root);const board = providedBoard ?? { db: store.openBoardReadOnly(join(info.commonDir, 'pullboard', 'board.sqlite')) };try {- return projectFit(pendingFit(info.commonDir), projectRowDecisions(store.rowDecisions(board), projectState(root, { board })));+ const decisions = store.rowDecisions(board);+ const state = projectFit(pendingFit(info.commonDir), projectRowDecisions(decisions, projectState(root, { board })));+ const config = loadConfig(root);+ const rows = projectRowDecisions(decisions, { spec: loadSpec(root, config).rows, practice: loadDoctrine(root, config).rows });+ const rigorDrafts = rigorDraftNeeds(rows);+ const projected = { ...state, rigorDrafts, rigorUndrafted: undraftedRigor(store.events(board), rows, { person: store.PERSON }) };+ return { ...projected, needs: personNeeds(projected) };} finally {if (!providedBoard) store.closeBoard(board);}diff --git a/src/needs.js b/src/needs.jsindex 2ef2e38b..4241e33a 100644--- a/src/needs.js+++ b/src/needs.js@@ -6,7 +6,8 @@ export function personNeeds(state) {return agent?.displayName || (agent ? `${id} (${agent.model || agent.agent_model || 'unknown'})` : id);};const rows = (state.spec ?? []).filter(row => !row.decision);- const drafts = rows.filter(row => row.status === 'draft').length;+ const rigorDrafts = state.rigorDrafts ?? [];+ const drafts = rows.filter(row => row.status === 'draft' && !rigorDrafts.some(draft => draft.target === `spec:${row.id}`)).length;return [...(state.decisions ?? []).map(ask => ({ kind: 'decision', id: ask.shout_id,ref: name(ask.shout_from), text: ask.shout_text, what: 'decision', at: ask.shout_at })),@@ -14,6 +15,7 @@ export function personNeeds(state) {ref: row.id, text: row.text, what: 'answer in SPEC.md' })),...(state.holds ?? []).map(hold => ({ kind: 'hold', id: hold.hold_lane,ref: hold.hold_lane, text: hold.hold_reason, what: 'lane held by ' + name(hold.hold_by) })),+ ...rigorDrafts,...(drafts ? [{ kind: 'draft', id: 'drafts', count: drafts, ref: String(drafts),text: 'draft spec rows to approve or drop', what: 'review in SPEC.md', target: 'tab:spec' }] : []),];diff --git a/src/rigor-draft.js b/src/rigor-draft.jsindex ce65b672..9e29a543 100644--- a/src/rigor-draft.js+++ b/src/rigor-draft.js@@ -9,6 +9,7 @@ import { Refused } from './refused.js';import { causeProblem, rigorReport } from './rigor.js';import { draftRow } from './spec-draft.js';import { proveCauseCheck } from './rigor-proof.js';+import { rigorSource } from './rigor-source.js';/*** Draft the rows for a repeated cause, after proving its check. Refused when the key is malformed,@@ -30,9 +31,10 @@ export async function rigorDraft({ root, config, events, person, agent }, { key,const items = cause.items.map((item) => `#${item.id}`).join(', ');const why = `Why: rigor ${key.replaceAll('|', '/')} ${cause.neverAgain ? 'was marked never again by the person' : `failed on ${items}`}; red at ${proof.red.commit}, green at ${proof.green.commit}.`;const rowText = `${text.trim()} ${why}`;+ const source = rigorSource(cause, proof);const drafts = [];- if (cause.reads !== 'product') drafts.push(draftRow(root, config, { target: 'doctrine', text: rowText, gate: `check ${proof.countCheck}`, fields: ['count: 0'], section }));- if (cause.reads !== 'work') drafts.push(draftRow(root, config, { target: 'spec', text: rowText, gate: proof.check, section }));+ if (cause.reads !== 'product') drafts.push(draftRow(root, config, { target: 'doctrine', text: rowText, gate: `check ${proof.countCheck}`, fields: ['count: 0', `source: ${source}`], section }));+ if (cause.reads !== 'work') drafts.push(draftRow(root, config, { target: 'spec', text: rowText, gate: proof.check, fields: [`source: ${source}`], section }));return { key, reads: cause.reads, evidence: { items: cause.items, occurrences: cause.occurrences, neverAgain: cause.neverAgain },proof: { check: proof.check, red: proof.red, green: proof.green }, drafts };}diff --git a/src/rigor-notices.js b/src/rigor-notices.jsnew file mode 100644index 00000000..a9a18c6a--- /dev/null+++ b/src/rigor-notices.js@@ -0,0 +1,82 @@+/** Automatic repeated-cause notices and proved rows waiting on the person [D1,D3,S1]. */+import { causeProblem, eventCauses, rigorReport } from './rigor.js';+import { parseSpec } from './spec.js';+import { readRigorSource, RIGOR_NOTICE_ENGINE } from './rigor-source.js';++/** Cause keys carried by this move, including the person's immediate never-again fact. */+export function rigorTriggerCauses(event, person) {+ if (event.event_kind === 'fact' && event.event_by === person) {+ const detail = JSON.parse(event.event_detail);+ if (detail.neverAgain === true && typeof detail.cause === 'string' && !causeProblem(detail.cause)) return [detail.cause];+ }+ return eventCauses(event);+}++/** Reconstruct notice and exact person-decline state from ordered receipts, never free text. */+function noticeState(events, person) {+ const seen = new Map();+ const notified = new Map();+ const declined = new Map();+ for (const event of events) {+ for (const key of rigorTriggerCauses(event, person)) {+ if (!seen.has(key)) seen.set(key, new Set());+ 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+ && 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 row = parseSpec(`## Source\n${detail.record.source}\n`).rows;+ if (row.length !== 1) continue;+ const source = readRigorSource(row[0].source);+ if (source) declined.set(source.key, { event: event.event_id, items: new Set(seen.get(source.key) ?? []) });+ }+ return { notified, declined };+}++/** A person's decline stays quiet until an item absent at that decision repeats the cause. */+function declinedRepeat(cause, state) {+ const decline = state.declined.get(cause.key);+ return Boolean(decline && !cause.items.some(item => !decline.items.has(item.id)));+}++/** The move that crosses the repeat threshold posts once, and a third failure stays quiet. */+export function newRigorNotices(events, trigger, { person }) {+ const keys = new Set(rigorTriggerCauses(trigger, person));+ const state = noticeState(events, person);+ return rigorReport(events, { person }).causes.filter(cause => {+ if (!keys.has(cause.key) || declinedRepeat(cause, state)) return false;+ const notice = state.notified.get(cause.key);+ const decline = state.declined.get(cause.key);+ return notice === undefined || Boolean(decline && notice < decline.event);+ });+}++/** Every typed Rigor row, across the spec and the repository's doctrine. */+function rigorRows(state) {+ return [...(state.spec ?? []).map(row => ({ ...row, kind: 'spec' })),+ ...(state.practice ?? []).filter(row => row.origin !== 'standard').map(row => ({ ...row, kind: 'doctrine' }))]+ .flatMap(row => { const source = readRigorSource(row.source); return source ? [{ row, source }] : []; });+}++/** 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 }) => ({+ 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 }) {+ 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));+ return rigorReport(events, { person }).causes.filter(cause => !drafted.has(cause.key) && !declinedRepeat(cause, notices));+}++/** One actionable notice names the cause and every item, with the ordinary proof-bearing draft command. */+export function rigorNoticeText(cause) {+ return `Repeated cause ${cause.key}: ${cause.items.map(item => `#${item.id}`).join(', ') || 'the person marked never again'}. Next: pullboard rigor draft "${cause.key.replaceAll('"', '\\"')}" "<rule>" --check "<command>" --red <commit> --green <commit>; prove the rule in this session, then the person approves or declines its draft.`;+}diff --git a/src/rigor-source.js b/src/rigor-source.jsnew file mode 100644index 00000000..03995794--- /dev/null+++ b/src/rigor-source.js@@ -0,0 +1,32 @@+/** Typed provenance of a proved Rigor row; prose alone never identifies a cause [D1,S1]. */+import { causeProblem } from './rigor.js';++/** First engine that posts deterministic repeated-cause notices [D1,H16]. */+export const RIGOR_NOTICE_ENGINE = 43;++/** Keep the cause, evidence and executed proof in one row-safe, portable source field. */+export function rigorSource(cause, proof) {+ return 'rigor:' + encodeURIComponent(JSON.stringify({ version: 1, key: cause.key,+ evidence: { items: cause.items, occurrences: cause.occurrences, neverAgain: cause.neverAgain },+ proof: { check: proof.check, red: proof.red, green: proof.green } }));+}++/** Read only a typed, proved source; malformed fields and ordinary notes are not provenance. */+export function readRigorSource(source) {+ if (typeof source !== 'string' || !source.startsWith('rigor:')) return null;+ try {+ const data = JSON.parse(decodeURIComponent(source.slice(6)));+ const commit = value => typeof value === 'string' && /^(?:[a-f0-9]{40}|[a-f0-9]{64})$/u.test(value);+ if (data?.version !== 1 || typeof data.key !== 'string' || causeProblem(data.key)+ || !Array.isArray(data.evidence?.items) || !Number.isSafeInteger(data.evidence.occurrences) || data.evidence.occurrences < 0+ || typeof data.evidence.neverAgain !== 'boolean' || data.evidence.items.some(item => !Number.isSafeInteger(item?.id) || item.id < 1+ || !Array.isArray(item.commits) || item.commits.some(value => !commit(value)))+ || typeof data.proof?.check !== 'string' || !data.proof.check.trim()+ || !commit(data.proof.red?.commit) || !commit(data.proof.green?.commit)+ || !Number.isInteger(data.proof.red.exit) || data.proof.green.exit !== 0) return null;+ const work = data.key.startsWith('doctrine:') || data.key.startsWith('refusal:');+ if (work ? ![0, 1].includes(data.proof.red.exit) || !(data.proof.red.problems > 0) || data.proof.green.problems !== 0+ : data.proof.red.exit === 0) return null;+ return data;+ } catch { return null; }+}diff --git a/test/agent-model-engine.test.js b/test/agent-model-engine.test.jsindex 5907aefc..916bd62f 100644--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@ -5,13 +5,14 @@ import * as store from '../src/board.js';import { applyEngineMove, prepareEngineMove } from '../src/engine.js';import { exportBoard, importBoard } from '../src/exchange.js';import { ENGINE_VERSION } from '../src/machine.js';+import { RIGOR_NOTICE_ENGINE } from '../src/rigor-source.js';import { configProblems, defaults, loadConfig } from '../src/config.js';import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';test('model declarations and event snapshots retain engines 1 through 34 semantics [O8,O3,H16]', (t) => {- assert.equal(ENGINE_VERSION, 34, 'the next writer preserves every historical model snapshot through main engine 33');+ assert.ok(ENGINE_VERSION >= RIGOR_NOTICE_ENGINE, 'the next writer preserves every historical model snapshot through main engine 33');for (const version of Array.from({ length: ENGINE_VERSION }, (_, index) => index + 1)) {const board = store.openBoard(':memory:');t.after(() => store.closeBoard(board));diff --git a/test/pending-refreeze.test.js b/test/pending-refreeze.test.jsindex ef73ed35..4afb5fb7 100644--- a/test/pending-refreeze.test.js+++ b/test/pending-refreeze.test.js@@ -9,6 +9,7 @@ import * as store from '../src/board.js';import { appliedSequence, applyRelayMove, engineReceipt, prepareEngineMove } from '../src/engine.js';import { exportBoard, importBoard } from '../src/exchange.js';import { ENGINE_VERSION } from '../src/machine.js';+import { RIGOR_NOTICE_ENGINE } from '../src/rigor-source.js';import { createE2eHelpers } from './e2e-helpers.js';import { unpackRelease } from './release-archive.js';@@ -261,7 +262,7 @@ async function checkDependencyLegacyClients(cleanup, directory, snapshot, target}test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {- assert.equal(ENGINE_VERSION, 34, 'the next writer retains all recorded dependency-edit behavior');+ assert.ok(ENGINE_VERSION >= RIGOR_NOTICE_ENGINE, 'the next writer retains all recorded dependency-edit behavior');const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));const cleanup = [];t.after(() => {diff --git a/test/rigor.test.js b/test/rigor.test.jsindex 93065f1c..db8e7bff 100644--- a/test/rigor.test.js+++ b/test/rigor.test.js@@ -16,6 +16,7 @@ import { main } from '../src/cli.js';import { refusePersonMove } from '../src/mcp.js';import { CAUSE_ENGINE, ENGINE_VERSION } from '../src/machine.js';import { rigorReport } from '../src/rigor.js';+import { readRigorSource, rigorSource, RIGOR_NOTICE_ENGINE } from '../src/rigor-source.js';import { unpackRelease } from './release-archive.js';const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');@@ -108,6 +109,119 @@ function history(file) {return { board, add, submit, reject, landReopen, close: () => store.closeBoard(board) };}+/** Two real commits for a proof, including the exact failing source noticed on the board. */+function noticeProof(box) {+ mkdirSync(join(box.repo, 'src'), { recursive: true });+ writeFileSync(join(box.repo, 'src', 'notice.js'), '// TODO: keep the rule\n');+ box.git('add', 'src/notice.js'); box.git('commit', '-q', '-m', 'chore: record noticed failure');+ const red = box.git('rev-parse', 'HEAD');+ writeFileSync(join(box.repo, 'src', 'notice.js'), '// The rule holds.\n');+ writeFileSync(join(box.repo, 'fixed.txt'), 'fixed\n');+ box.git('add', 'src/notice.js', 'fixed.txt'); box.git('commit', '-q', '-m', 'chore: fix noticed failure');+ return { red, green: box.git('rev-parse', 'HEAD') };+}++test('a repeated cause tells the coordinator once [D1,D3]', () => {+ const box = freshBoard();+ const proof = noticeProof(box);+ const historyBox = history(box.file);+ 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');+ historyBox.submit(ids[0], proof.red); historyBox.reject(ids[0], cause);+ assert.equal(notices().length, 0);+ historyBox.submit(ids[1], proof.red); historyBox.reject(ids[1], cause);+ assert.equal(notices().length, 1, 'the reject crossing the repeat threshold tells the coordinator');+ assert.equal(notices()[0].shout_to, 'coordinator');+ assert.ok(notices()[0].shout_text.includes(cause));+ for (const id of ids.slice(0, 2)) assert.ok(notices()[0].shout_text.includes(`#${id}`));+ assert.ok(notices()[0].shout_text.includes('pullboard rigor draft'));+ assert.ok(notices()[0].shout_text.includes('--red <commit> --green <commit>'));+ historyBox.submit(ids[2], proof.red); historyBox.reject(ids[2], cause);+ assert.equal(notices().length, 1, 'a third failure posts no duplicate');+ assert.equal(json(box, 'resume').rigor.undrafted.find(entry => entry.key === cause).items.length, 3);+ const text = box.run('resume');+ assert.equal(text.status, 0, text.stderr);+ assert.ok(text.stdout.includes(`Rigor needs a proved draft: ${cause}`));+ const draft = json(box, 'rigor', 'draft', cause, 'No TODO markers in source', '--check', 'grep -rn TODO src', '--red', proof.red, '--green', proof.green);+ assert.equal(json(box, 'resume').rigor.undrafted.some(entry => entry.key === cause), false);+ json(box, 'spec', 'decline', `doctrine:${draft.drafts[0].id}`, '--reason', 'This is not the rule we want');+ historyBox.submit(ids[0], proof.green); historyBox.reject(ids[0], cause);+ assert.equal(notices().length, 1, 'a new commit on an old item does not undo the person’s decline');+ assert.equal(json(box, 'resume').rigor.undrafted.some(entry => entry.key === cause), false);+ historyBox.submit(ids[3], proof.red); historyBox.reject(ids[3], cause);+ assert.equal(notices().length, 2, 'a new item repeating after the decline tells the coordinator once');+ historyBox.submit(ids[4], proof.red); historyBox.reject(ids[4], cause);+ assert.equal(notices().length, 2);+ const receipts = store.events(historyBox.board).filter(event => event.event_kind === 'rigor-notice');+ assert.equal(receipts.length, 2);+ assert.ok(receipts.every(event => event.event_by === 'rigor' && JSON.parse(event.event_detail).engine === RIGOR_NOTICE_ENGINE));+ historyBox.close();+});++test('a Rigor draft reaches Needs-you with its proof [D1,D3,S1,P6]', () => {+ const box = freshBoard();+ const proof = noticeProof(box);+ const historyBox = history(box.file);+ const ids = ['Product first', 'Product second'].map(historyBox.add);+ for (const id of ids) { historyBox.submit(id, proof.red); historyBox.reject(id, 'row:G1'); }+ historyBox.close();+ const draft = json(box, 'rigor', 'draft', 'row:G1', 'The fixed file exists', '--check', 'test -f fixed.txt', '--red', proof.red, '--green', proof.green);+ const source = readRigorSource(draft.drafts[0].line.split(' | source: ')[1]);+ assert.equal(source.key, 'row:G1');+ assert.deepEqual(source.evidence.items.map(item => item.id), ids);+ assert.deepEqual([source.proof.red.commit, source.proof.red.exit, source.proof.green.commit, source.proof.green.exit], [proof.red, 1, proof.green, 0]);+ const pending = json(box, 'resume');+ const need = pending.needsYou.find(entry => entry.kind === 'rigor-draft');+ assert.ok(need, 'the proved Rigor row is an individual Needs-you call');+ assert.equal(need.target, `spec:${draft.drafts[0].id}`);+ assert.equal(need.what, 'Approve or Decline');+ assert.equal(need.cause, source.key);+ assert.deepEqual(need.evidence, source.evidence);+ assert.deepEqual(need.proof, source.proof);+ assert.ok(need.text.includes('Rigor draft: The fixed file exists'));+ assert.ok(need.text.includes(proof.red) && need.text.includes(proof.green));+ assert.equal(pending.rigor.undrafted.length, 0);+ assert.equal(pending.needsYou.filter(entry => entry.kind === 'draft').reduce((sum, entry) => sum + entry.count, 0),+ json(box, 'spec').rows.filter(row => row.status === 'draft' && row.id !== draft.drafts[0].id).length, 'the generic draft count does not count the Rigor row twice');+ json(box, 'spec', 'approve', draft.drafts[0].id);+ assert.equal(json(box, 'resume').needsYou.some(entry => entry.kind === 'rigor-draft'), false, 'the person’s pending approval closes the call');+ json(box, 'spec', 'apply');+ const approved = json(box, 'spec').rows.find(row => row.id === draft.drafts[0].id);+ assert.equal(approved.status, 'approved');+ assert.equal(approved.gate, 'test -f fixed.txt');+ assert.equal(json(box, 'resume').rigor.undrafted.length, 0);+});++test('automatic Rigor notices retain old replay and include reopen and never-again [D1,H16]', () => {+ const box = freshBoard();+ const historyBox = history(box.file);+ historyBox.board.executionEngineVersion = RIGOR_NOTICE_ENGINE - 1;+ const old = ['Old first', 'Old second'].map(historyBox.add);+ for (const id of old) { historyBox.submit(id); historyBox.reject(id, 'row:G1'); }+ assert.equal(store.allShouts(historyBox.board).filter(shout => shout.shout_from === 'rigor').length, 0,+ 'engine42 replay keeps its old event stream without automatic notices');+ delete historyBox.board.executionEngineVersion;+ const fresh = ['Reopened first', 'Reopened second'].map(historyBox.add);+ for (const id of fresh) {+ historyBox.submit(id);+ store.reopen(historyBox.board, id, { agentId: 'coordinator', note: 'A typed product failure', cause: 'row:G2' });+ }+ assert.equal(store.allShouts(historyBox.board).filter(shout => shout.shout_from === 'rigor').length, 1);+ const one = historyBox.add('One item, two commits');+ historyBox.submit(one); historyBox.reject(one, 'refusal:UNDECLARED_REFUSAL');+ historyBox.submit(one); historyBox.reject(one, 'refusal:UNDECLARED_REFUSAL');+ assert.equal(store.allShouts(historyBox.board).filter(shout => shout.shout_from === 'rigor').length, 2);+ store.appendFact(historyBox.board, one, { agentId: 'coordinator', kind: 'root-cause', text: 'Never again',+ cause: 'doctrine:C4', neverAgain: true, asPerson: true, channel: 'terminal' });+ assert.equal(store.allShouts(historyBox.board).filter(shout => shout.shout_from === 'rigor').length, 3,+ 'a person never-again tells the coordinator without waiting for a second item');+ const conflicts = ['Conflict first', 'Conflict second'].map(historyBox.add);+ for (const id of conflicts) { historyBox.submit(id); historyBox.reject(id, 'refusal:MERGE_CONFLICT'); }+ assert.equal(store.allShouts(historyBox.board).filter(shout => shout.shout_from === 'rigor').length, 3);+ historyBox.close();+});+test('a repeated failure cause is noticed [D1,V1]', () => {const box = freshBoard();const before = json(box, 'rigor');@@ -368,7 +482,7 @@ test('a repeated cause becomes a draft row with its proof [D1,D3,S1,P6]', asyncassert.equal(work.drafts.length, 1);const [doctrineRow] = work.drafts;assert.equal(doctrineRow.file, 'DOCTRINE.md');- assert.equal(doctrineRow.line, `- ${doctrineRow.id} [draft, must] No TODO markers in shipped source Why: rigor doctrine:C3 failed on #${workA}, #${workB}; red at ${bad}, green at ${fix}. | gate: check grep -rn TODO src | count: 0`);+ assert.equal(doctrineRow.line.split(' | source: ')[0], `- ${doctrineRow.id} [draft, must] No TODO markers in shipped source Why: rigor doctrine:C3 failed on #${workA}, #${workB}; red at ${bad}, green at ${fix}. | gate: check grep -rn TODO src | count: 0`);assert.ok(readFileSync(join(box.repo, 'DOCTRINE.md'), 'utf8').includes(doctrineRow.line), 'the row is written into DOCTRINE.md');assert.equal(readFileSync(join(box.repo, 'SPEC.md'), 'utf8'), specBefore, 'a work cause writes no spec row');@@ -379,7 +493,8 @@ test('a repeated cause becomes a draft row with its proof [D1,D3,S1,P6]', asyncassert.equal(product.drafts.length, 1);const [specRow] = product.drafts;assert.equal(specRow.file, 'SPEC.md');- assert.equal(specRow.line, `- ${specRow.id} [draft, must] The fixed file exists Why: rigor row:G1 failed on #${productA}, #${productB}; red at ${bad}, green at ${fix}. | gate: test -f fixed.txt`);+ assert.equal(specRow.line.split(' | source: ')[0], `- ${specRow.id} [draft, must] The fixed file exists Why: rigor row:G1 failed on #${productA}, #${productB}; red at ${bad}, green at ${fix}. | gate: test -f fixed.txt`);+ assert.equal(readRigorSource(specRow.line.split(' | source: ')[1]).key, 'row:G1');// An unclear cause drafts both, and the person picks.const both = json(box, 'rigor', 'draft', bothKey, 'Page titles are escaped', ...flags("node --test test/page.test.js", bad, fix));