Skip to content

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.

Merge remote-tracking branch 'origin/main' into core/713-merge

Corey Olson1d71b7dd9abd
diff --cc docs/api.md
index 92661d8e,29dc6d7e..e66c57d5
--- a/docs/api.md
+++ b/docs/api.md
@@@ -166,16 -207,10 +208,18 @@@ A correction is a new fact with `--supe
`show --json` retains its existing item fields and verdicts and adds `thread`. The HTTP item detail's `thread` field, also on each item in the full board state, has the same array. Entries are oldest first, ordered by the append-only event sequence. A fact entry is `{type: "fact", ...fact}`. A move entry is `{type: "move", eventId, kind, by, at, detail}`, with `detail` holding the original move's structured event detail. Text `show` prints these moves and facts as one timeline, including full references and both sides of a correction. Ordinary verdict summaries and `--history` remain available.
+ A decision names the items it changes with `--implies 12,13` on `fact`, `verify` or `answer`; the HTTP moves take the same value as `args.implies`, and `answer` also takes `args.supersedes`, the id of an earlier answer. Each named item must exist; an unknown one is refused with `NO_ITEM` naming it, before anything is recorded. Each named item's `thread` then gets a `note` fact with a `decision` citation `{source, id, item, by, line}`, and a second fact with `supersededBy` when that decision is superseded (docs/formats.md has the shapes). These optional fact fields appear only when set. `by` is read from the board's record of the decision, never from the arguments, and only the person supersedes the person's answer. `pullboard why <id>` returns `{version: 1, id, decisions: [...]}`, newest first; each entry is the citation plus `at`, `fact` (the implied fact's id) and `supersededBy` (a citation, or `null`). `resume --json` adds `decisions`: the implied facts on held items shown for the first time, each `{item, fact, text}`.
+
The HTTP move is `{verb: "fact", item: 12, agent: "web-1", args: {kind: "measurement", text: "The check takes 8 seconds", ref: "src/file.js:12-30@<full-sha>"}}`. Omit `agent` to act as the coordinator; `args.supersedes` supplies a correction's earlier fact identity. The response carries the committed `fact` event and the CLI result. The event-log format stays at version 1 because facts use its existing immutable event rows; exports and imports preserve those rows. The sealed move engine advances to version 3 for this release so older engines refuse the new operation before replay.
+## Rigor
+
+Rigor is how errors become doctrine or specs. It starts by noticing a failure cause that repeats. A cause key comes only from structured fields: `test:<file>::<title>`, `refusal:<CODE>`, `row:<id>` or `doctrine:<id>`. A reject (`verify <id> reject ... --cause <key>`) and a `reopen <id> --note "..." --cause <key>` record the key they name as `cause` in their event detail. A reopen after a red landing also gives one `test:` key per failing test in its `landingFailure.tests`, including reopens recorded before cause keys existed. Notes are never parsed, so an older reject with no cause counts as uncaused. A malformed key is refused with `BAD_CAUSE` before the move. Merge conflicts never count: a landing test whose name starts with `conflicts with`, and `refusal:MERGE_CONFLICT`.
+
+`pullboard rigor` is read-only. It lists each cause that repeated: on 2 items, or on 1 item at 2 different commits. Each line shows the key, how it reads (`work` for `doctrine:` and `refusal:`, `product` for `row:`, `both` for `test:`), its failure count and its items. Its JSON result is `{version, causes: [{key, reads, occurrences, neverAgain, items: [{id, commits}]}], uncaused}`; `uncaused` counts rejects and reopens with no cause key.
+
+The person can mark a cause never-again from the main checkout's terminal: `pullboard fact <id> root-cause "<why>" --cause <key> --never-again --as person`. The fact is recorded as the person's, carries `cause` and `neverAgain: true`, and `rigor` lists its cause at once. An agent or a fact without `--as person` is refused with `RIGOR_PERSON_ONLY`. Over the relay, a fact move with person mode, a never-again or a cause key is accepted only from an authenticated person sender; an agent, a coordinator seat or the machine credential is refused with `RELAY_PERSON_ONLY` whatever channel the move names, and nothing is recorded. A move that carries a cause key needs move engine 13; moves without one replay as before.
+
## Refusals
A refusal keeps the command's existing exit status and prints exactly one versioned document to stdout. In JSON mode stderr stays empty except for sign-in instructions and check consent notices. The command-specific `code` identifies the rule; `message` explains what happened; `next` gives the next step.
diff --cc docs/formats.md
index ce3367e3,425167f8..81bb905c
--- a/docs/formats.md
+++ b/docs/formats.md
@@@ -115,8 -126,8 +126,10 @@@ Engine 12 records declined person row d
Engine 19 makes a corrected bar record why the old one was wrong. Once an item has ever been claimed, an `editItem` that changes its criterion or check must carry `reason`, the text of what the old bar got wrong; without one it is refused with `BAR_REASON`, naming `--reason`. The edit event then records `reason` and `barCorrection: {fields, reject}`: `fields` lists `criterion` and/or `check`, and `reject` is `{verdict, by, reason, at}` when the item's newest verdict is a reject no earlier correction already explained, or `null`. That reject is counted as caused by the bar. The board derives `barCorrection` from its own rows; a move supplies only `reason`. An edit before any claim needs no reason and records one only if given. `pullboard stats` JSON adds `bars`, keyed by agent: `{corrections, barRejects, buildRejects}`. Corrections and the rejects they explain count to the agent who corrected the bar; any other reject counts as the build's, to the agent who added the item. An `editItem` move carrying `reason` requires engine 19, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor. Moves recorded under engines 18 and earlier replay without the reason rule. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.
- Engine 23 lets a reject and a reopen carry a cause key (`cause`: `test:<file>::<title>`, `refusal:<CODE>`, `row:<id>` or `doctrine:<id>`) and lets the person record a never-again fact with `cause` and `neverAgain: true`, for `pullboard rigor`. Only a move that carries one of these needs engine 23; engine-22 and older moves replay unchanged, and clients on an older engine refuse an engine-23 move with `RELAY_MOVE` before changing their board or cursor. Engine numbers 20 to 22 are allocated to other changes.
+ Engine 20 lets a decision name the items it changes. An `appendFact`, `answerDecision` or `verify` move may carry `implies`, a list of existing item ids, and an `answerDecision` move may carry `supersedes`, the shout id of an earlier answer. Either makes the move an engine-20 move: an older engine refuses it with `RELAY_MOVE` before changing its board or cursor, and a board replaying an older engine refuses `implies` with `ENGINE_VERSION`. Engine 20 also tells implied items when a decision is superseded: by a fact's `supersedes`, by an answer's `supersedes`, or by the next verdict on the same item. Moves recorded under engines 19 and earlier replay without these notices. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.
+
++Engine 23 lets a reject and a reopen carry a cause key (`cause`: `test:<file>::<title>`, `refusal:<CODE>`, `row:<id>` or `doctrine:<id>`) and lets the person record a never-again fact with `cause` and `neverAgain: true`, for `pullboard rigor`. Only a move that carries one of these needs engine 23; engine-22 and older moves replay unchanged, and clients on an older engine refuse an engine-23 move with `RELAY_MOVE` before changing their board or cursor. Engine 20 is the implied-items engine above; engine numbers 21 and 22 are allocated to other changes.
+
The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.
A linked board requires at least engine 3 after issuing any agent token, including
revoked or expired tokens. Issuing any machine credential raises that board’s minimum to engine 6, including after revocation or expiry. The minimum survives reopening the auth database;
diff --cc docs/lifecycle.md
index 2d21d946,d0672d72..0c2f046e
--- a/docs/lifecycle.md
+++ b/docs/lifecycle.md
@@@ -56,9 -56,9 +56,9 @@@ Each move checks its guards in this ord
| lapse | claimed | open | clock, when its lease runs out | none |
| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT), withinLane (OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), gateGreen (GATE_RED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |
| reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), roadmapReadable (MILESTONES_CORRUPT), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) |
- | accept | submitted | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED), result (LAND_HEADER) |
- | reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), result (LAND_HEADER) |
+ | accept | submitted | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED), result (LAND_HEADER), result (ENGINE_VERSION) |
-| reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), result (LAND_HEADER), result (ENGINE_VERSION) |
-| reopen | submitted, verified | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED) |
++| reject | submitted | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notBuilder (SELF_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), result (LAND_HEADER), result (ENGINE_VERSION) |
+| reopen | submitted, verified | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED) |
| escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED) |
| refreeze | open, claimed, submitted | open | coordinator, when there is no live claim awaiting a coordinator correction | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
| refreeze | claimed | claimed | agent, coordinator, when a live claim has a pending coordinator correction | joined (NOT_JOINED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
diff --cc src/api-moves.js
index 09f214c5,c107d3d2..bce8cf4d
--- a/src/api-moves.js
+++ b/src/api-moves.js
@@@ -13,7 -13,7 +13,7 @@@ const MOVES =
release: { item: true, flags: ['note'] },
submit: { item: true },
done: { item: true },
- verify: { item: true, positions: ['decision'], flags: ['reason', 'note', 'cause', 'as'] },
- verify: { item: true, positions: ['decision'], flags: ['reason', 'note', 'as', 'implies'] },
++ verify: { item: true, positions: ['decision'], flags: ['reason', 'note', 'cause', 'as', 'implies'] },
merged: { item: true, positions: ['commit'] },
withdraw: { item: true, positions: ['reason'] },
refreeze: { item: true },
diff --cc src/board.js
index 2214797e,004f398a..2a31a99b
--- a/src/board.js
+++ b/src/board.js
@@@ -15,9 -15,8 +15,10 @@@ import { briefFiles, briefSections } fr
import { COORDINATOR } from './config.js';
import { ENGINE_VERSION, GUARDS, IN_STATE, MOVES, STATES, UNKNOWN_MOVE, effectiveGuards, storeTriggers } from './machine.js';
import { Refused } from './refused.js';
+import { causeProblem, requireNeverAgain } from './rigor.js';
import { barCorrectionFields } from './bar-corrections.js';
+import { factReference } from './fact-reference.js';
+ import { factFromEvent, requestAnswerRefusal, tellAnswerImplications, tellFactImplications, tellVerdictImplications } from './implies.js';
import { parseSpec } from './spec.js';
export const ACCEPT_REASON = 'CRITERION_MET';
@@@ -1484,10 -1483,10 +1485,10 @@@ function reserveWithin(board, id, { age
*
* @param {any} board
* @param {number} id
- * @param {{ agentId: string, decision: string, reason?: string, note?: string, cause?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green' }} verdict
- * @param {{ agentId: string, decision: string, reason?: string, note?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green', implies?: number[], impliesId?: string }} verdict - implies: items this verdict changes (B29)
++ * @param {{ agentId: string, decision: string, reason?: string, note?: string, cause?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green', implies?: number[], impliesId?: string }} verdict - implies: items this verdict changes (B29)
* @returns {{ decision: string, reason: string, check?: 'none' | 'green' }}
*/
- export function verify(board, id, { agentId, decision, reason, note = '', cause, head, digest, policy, familyPolicy = 'off', check }) {
-export function verify(board, id, { agentId, decision, reason, note = '', head, digest, policy, familyPolicy = 'off', check, implies, impliesId }) {
++export function verify(board, id, { agentId, decision, reason, note = '', cause, head, digest, policy, familyPolicy = 'off', check, implies, impliesId }) {
const verb = { ACCEPT: 'accept', REJECT: 'reject' }[decision];
if (!verb) throw new Refused('BAD_DECISION', 'the decision is accept or reject');
const isAccept = verb === 'accept';
@@@ -1528,9 -1526,10 +1529,10 @@@
},
set: (found) => ({ item_verdict: decision, item_verified_by: isAccept ? agentId : null, item_owner: isAccept ? found.item_owner : null }),
});
- const detail = { reason: code, commit: item.item_commit };
+ const detail = { reason: code, commit: item.item_commit, ...(!isAccept && cause !== undefined && cause !== null ? { cause } : {}) };
if (isAccept && check !== undefined) detail.check = check;
- logEvent(board, agentId, verb, id, detail);
+ logEvent(board, agentId, verb, id, implies?.length ? { ...detail, implies } : detail);
+ tellVerdictImplications(board, (by, itemId, fact) => logEvent(board, by, 'fact', itemId, fact), id, { seed: impliesId, implies });
return { decision, reason: code, ...(isAccept && check !== undefined ? { check } : {}) };
});
}
@@@ -2068,15 -2066,20 +2070,8 @@@ export function events(board, { itemId
/** Fact labels distinguish observations from judgements reserved to an item's live holder [B29,B30]. */
export const FACT_KINDS = Object.freeze(['capture', 'measurement', 'note', 'diff', 'decision', 'rejection', 'supersession', 'root-cause']);
const FACT_JUDGEMENTS = new Set(['decision', 'rejection', 'supersession', 'root-cause']);
-
-/** Validate a portable code binding without reading source on replicas that hold only board data [B32,H7]. */
-export function factReference(ref) {
- if (ref === null || ref === undefined) return null;
- const parts = typeof ref === 'string' && /^([^\r\n\0]+):(\d+)(?:-(\d+))?@([0-9a-f]{40})$/iu.exec(ref);
- if (!parts) throw new Refused('BAD_FACT_REF', 'a fact reference needs path:line[-line]@full-sha with all 40 hexadecimal characters; use the full git commit id');
- const [, path, first, last, commit] = parts;
- const start = Number(first), end = Number(last ?? first);
- if (path.startsWith('/') || path.includes('\\') || /^[A-Za-z]:/u.test(path) || path.split('/').some((part) => !part || part === '.' || part === '..') || !Number.isSafeInteger(start) || !Number.isSafeInteger(end) || start < 1 || end < start) {
- throw new Refused('BAD_FACT_REF', 'a fact reference needs a relative repo path and a positive ascending line range; use path:line[-line]@full-sha');
- }
- return { path, start, end, commit: commit.toLowerCase() };
-}
+export { factReference };
- /** Give facts the same stamped identity on CLI, API, export and replica reads; a never-again keeps its cause [B29,B31,D1]. */
- function factFromEvent(event) {
- const detail = JSON.parse(event.event_detail);
- return { id: detail.id, eventId: event.event_id, kind: detail.kind, text: detail.text,
- by: event.event_by, at: event.event_at, ref: detail.ref ?? null, supersedes: detail.supersedes ?? null, ...(detail.neverAgain ? { cause: detail.cause, neverAgain: true } : {}) };
- }
-
/** Read every move and fact in append order, including superseded facts and full original text [B31,B32]. */
export function itemThread(board, id) {
itemById(board, id);
@@@ -2092,8 -2095,9 +2087,9 @@@ export function projectItemThreads(boar
}
/** Append a typed fact atomically; a correction never edits the original event [B29,B30,B31,B32].
- * The internal factId is set from a sealed move's identity during replay, rather than replica-local sequence ids; a never-again with its cause is the person's alone, and rigor lists it at once (#713) [D1]. */
- export function appendFact(board, id, { agentId, kind, text, ref = null, supersedes = null, factId = randomUUID(), cause = null, neverAgain = false, asPerson = false, channel = 'terminal' }) {
- * The internal factId is set from a sealed move's identity during replay, rather than replica-local sequence ids.
++ * The internal factId is set from a sealed move's identity during replay, rather than replica-local sequence ids; a never-again with its cause is the person's alone, and rigor lists it at once (#713) [D1].
+ */
-export function appendFact(board, id, { agentId, kind, text, ref = null, supersedes = null, factId = randomUUID(), implies }) {
++export function appendFact(board, id, { agentId, kind, text, ref = null, supersedes = null, factId = randomUUID(), implies, cause = null, neverAgain = false, asPerson = false, channel = 'terminal' }) {
return atomic(board, () => {
const item = current(board, itemById(board, id));
if (!board.db.prepare('SELECT 1 FROM agent WHERE agent_id = ?').get(agentId)) throw new Refused('NO_AGENT', `no registered agent ${agentId}; join a worktree before appending a fact`);
@@@ -2108,9 -2112,8 +2104,9 @@@
throw new Refused('NO_FACT', `no fact ${String(supersedes)} on item #${id}; use a fact id from pullboard show ${id} --json`);
}
const binding = factReference(ref);
- logEvent(board, agentId, 'fact', id, { id: factId, kind, text, ref: binding, supersedes, ...(implies?.length ? { implies } : {}) });
+ if (neverAgain || asPerson || cause !== null) requireNeverAgain(id, { agentId, cause, neverAgain, asPerson, channel });
- logEvent(board, neverAgain ? PERSON : agentId, 'fact', id, { id: factId, kind, text, ref: binding, supersedes, ...(neverAgain ? { cause, neverAgain: true, channel } : {}) });
- return factFromEvent(board.lastEvent);
++ 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 });
});
}
diff --cc src/cli.js
index b1660847,e0c0d4b0..4193c5ba
--- a/src/cli.js
+++ b/src/cli.js
@@@ -304,8 -308,7 +309,9 @@@ const OPTIONS =
commit: { type: 'string' },
ref: { type: 'string' },
supersedes: { type: 'string' },
+ cause: { type: 'string' },
+ 'never-again': { type: 'boolean' },
+ implies: { type: 'string' },
owns: { type: 'string' },
help: { type: 'boolean', short: 'h' },
version: { type: 'boolean', short: 'v' },
@@@ -2845,14 -2883,11 +2895,15 @@@ function workCommands(io, args)
return 0;
}),
fact: () => act(async (ctx, board, me) => {
- if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha] [--cause <key> --never-again --as person]');
- if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha] [--implies <ids>]');
++ if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha] [--implies <ids>] [--cause <key> --never-again --as person]');
const id = idArg(first);
+ const implies = parseImplies(values.implies);
+ const asPerson = values.as === 'person' && personMode(ctx, me, values);
+ if (asPerson) requirePersonChannel(ctx.io.personChannel);
+ const marked = asPerson || values['never-again'] || values.cause !== undefined
+ ? { cause: values.cause ?? null, neverAgain: Boolean(values['never-again']), asPerson, channel: ctx.io.personChannel ?? 'terminal' } : {};
const fact = await ordered(ctx, board, 'appendFact', [id, { agentId: me.id, kind: second,
- text: rest[0], supersedes: values.supersedes ?? null, ref: values.ref ?? null, ...marked }]);
- text: rest[0], supersedes: values.supersedes ?? null, ref: values.ref ?? null, ...(implies ? { implies } : {}) }]);
++ text: rest[0], supersedes: values.supersedes ?? null, ref: values.ref ?? null, ...(implies ? { implies } : {}), ...marked }]);
io.result?.({ item: id, fact });
io.say(`fact ${fact.id} appended to #${id} as ${fact.kind}`);
return 0;
diff --cc src/engine.js
index aebb61bb,8be6dc97..8520eeef
--- a/src/engine.js
+++ b/src/engine.js
@@@ -3,7 -3,8 +3,8 @@@ import { createHash, randomUUID } from
import * as store from './board.js';
import { recordedRefusal } from './recorded-refusal.js';
import { BAR_ENGINE, carriesBarReason } from './bar-corrections.js';
+ import { carriesImplies, IMPLIES_ENGINE } from './implies.js';
-import { ENGINE_VERSION } from './machine.js';
+import { CAUSE_ENGINE, ENGINE_VERSION } from './machine.js';
import { Refused } from './refused.js';
import { requestMoveProblem, recordRequestMove } from './relay-requests.js';
import { relayMoveActor, relaySenderProblem, validRelaySender } from './relay-sender.js';
@@@ -23,13 -24,10 +24,14 @@@ export const ENGINE_OPERATIONS = Object
/** Engine version at which each ordered operation first has stable replay semantics. */
const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8 });
- /** Dependency edits add engine-10 meaning, edit reasons engine-19 meaning, and a cause key on a
- * reject, reopen or person fact engine-23 meaning (#713), without changing ordinary historical envelopes.
-/** Dependency edits add engine-10 meaning, edit reasons engine-19 and implied items engine-20, without changing ordinary historical envelopes. */
++/** Dependency edits add engine-10 meaning, edit reasons engine-19, implied items engine-20, and a
++ * cause key on a reject, reopen or person fact engine-23 (#713), without changing ordinary historical envelopes.
+ */
function minimumOperationEngine(operation, args) {
const options = args[1];
+ const given = (name) => Boolean(options && typeof options === 'object' && Object.hasOwn(options, name) && options[name] !== undefined && options[name] !== null && options[name] !== false);
+ if (['verify', 'reopen', 'appendFact'].includes(operation) && (given('cause') || given('neverAgain') || given('asPerson'))) return CAUSE_ENGINE;
+ if (carriesImplies(operation, args)) return IMPLIES_ENGINE;
if (carriesBarReason(operation, args)) return BAR_ENGINE;
return operation === 'editItem' && options && Object.hasOwn(options, 'after') && options.after !== undefined
? 10 : OPERATION_ENGINE[operation] ?? 1;
diff --cc src/help.js
index ca83c557,dae546c3..831bbed1
--- a/src/help.js
+++ b/src/help.js
@@@ -81,9 -85,11 +85,12 @@@ Wor
pullboard skills --update refresh unchanged Claude Code skills from shipped versions
pullboard show <id> [--history] an item, the criterion frozen at claim, its verdicts: the latest in full,
earlier ones as one line; --history prints every note in full
- pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha]
+ pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha] [--implies <ids>]
append an observation or a holder/coordinator judgement to its thread
+ --implies 12,13: each named item gets a fact citing this decision,
+ and is told again when the decision is superseded
+ the person adds --cause <key> --never-again --as person: rigor lists it at once
+ pullboard why <id> the decisions that imply an item, newest first, and what superseded them
pullboard next [--wait <minutes>] offer an eligible review when reviews pile up, otherwise claim work
pullboard next --build claim a build explicitly, recording a skipped review offer
pullboard next --verify reserve the next submitted item you can check;
@@@ -95,8 -101,8 +102,9 @@@
pullboard release <id> [--note "why"] hand it back; a review release needs a one-line reason
pullboard submit <id> needs a clean tree, item check and affected tests green at HEAD (alias: done)
pullboard verify <id> accept --note "what you broke or which edge you tried, and what happened"
- pullboard verify <id> reject --reason TEST_FAILURE --note "what failed"
+ pullboard verify <id> reject --reason TEST_FAILURE --note "what failed" [--cause <key>]
+ a cause is test:<file>::<title>, refusal:<CODE>, row:<id> or doctrine:<id>
+ a verdict takes --implies <ids>; a later verdict on the item supersedes it
any --note can be --note-file <file>, which keeps quotes, $ and backticks intact
pullboard shout <lane|agent|person|all> <text> pullboard inbox
pullboard shout [<to>] <text> --decision ask for a decision; defaults to your coordinator or the person
@@@ -196,9 -203,9 +207,9 @@@ Reject reasons: TEST_FAILURE, BEHAVIOR_
const HELP_NAMES = [
'tour', 'init', 'worktree', 'join', 'takeover', 'whoami', 'lanes', 'lane', 'lane add', 'status', 'resources', 'settings', 'view', 'view export',
- 'serve', 'mcp', 'relay', 'relay recover', 'resume', 'hooks', 'add', 'edit', 'escalate', 'run', 'list', 'doctor', 'skills', 'show', 'next', 'land',
- 'check', 'claim', 'release', 'submit', 'done', 'verify', 'fact', 'shout', 'answer', 'pass', 'decisions', 'inbox', 'export', 'import',
+ 'serve', 'mcp', 'relay', 'relay recover', 'resume', 'hooks', 'add', 'edit', 'escalate', 'run', 'list', 'doctor', 'health', 'skills', 'show', 'next', 'land',
+ 'check', 'claim', 'release', 'submit', 'done', 'verify', 'fact', 'why', 'shout', 'answer', 'pass', 'decisions', 'inbox', 'export', 'import',
- 'sweep', 'merged', 'withdraw', 'refreeze', 'reopen', 'hold', 'stats', 'ledger', 'log', 'spec', 'spec check', 'spec view',
+ 'sweep', 'merged', 'withdraw', 'refreeze', 'reopen', 'hold', 'stats', 'ledger', 'log', 'rigor', 'spec', 'spec check', 'spec view',
'spec show', 'spec unmet', 'spec signoff', 'spec draft', 'spec signers', 'spec signers add', 'doctrine', 'doctrine check', 'forget', 'prompt', 'gate', 'hook',
'hook pre-commit', 'hook pre-merge-commit', 'hook commit-msg', 'hook pre-push', 'view export', 'version', 'lifecycle', 'help',
'roadmap', 'milestone', 'runner', 'runner add', 'blueprint', 'blueprint add', 'blueprint save',
diff --cc src/implies.js
index 00000000,760443b9..9f632f5b
mode 000000,100644..100644
--- a/src/implies.js
+++ b/src/implies.js
@@@ -1,0 -1,337 +1,338 @@@
+ /**
+ * A decision names the items it changes, and each named item carries it [B29,B30,B31,N29,P6].
+ *
+ * An answer, a verdict or a fact can carry `implies`: the ids of other items the decision changes.
+ * Each named item gets a fact citing the decision, and when the decision is superseded each gets a
+ * second fact naming the new one. Both are ordinary item facts in the event log; no other store.
+ *
+ * Who decided always comes from the board's own record of the decision (the answer's sender, the
+ * verdict's reviewer, the fact's author), never from the caller's arguments, so no relay or API
+ * caller can mint a person-origin citation (P6). The only route to `by: "person"` is a real
+ * person answer, which keeps its own person-channel rules.
+ */
+ import { createHash, randomUUID } from 'node:crypto';
+ import { mkdirSync, readFileSync, renameSync, writeFileSync } from 'node:fs';
+ import { dirname, join } from 'node:path';
+ import { COORDINATOR } from './config.js';
+ import { ENGINE_VERSION } from './machine.js';
+ import { Refused } from './refused.js';
+
+ /** The engine whose moves may carry `implies`, or supersede an answer; older replays never do. */
+ export const IMPLIES_ENGINE = 20;
+
+ /** The operations whose sealed options may carry `implies`. */
+ export const IMPLYING_OPERATIONS = Object.freeze(['appendFact', 'answerDecision', 'verify']);
+
+ /**
+ * Parse an `--implies` value into item ids, accepting `12,13` or `#12, #13`.
+ *
+ * @param {string | undefined} text
+ * @returns {number[] | undefined}
+ */
+ export function parseImplies(text) {
+ if (text === undefined) return undefined;
+ const parts = String(text).split(',').map((part) => part.trim()).filter(Boolean);
+ if (!parts.length || parts.some((part) => !/^#?[1-9]\d*$/u.test(part))) {
+ throw new Refused('USAGE', `--implies takes item ids separated by commas, as in --implies 12,13 (saw "${text}")`);
+ }
+ return [...new Set(parts.map((part) => Number(part.replace('#', ''))))];
+ }
+
+ /**
+ * True when a sealed move carries this engine's meaning: items it implies, or an answer it supersedes.
+ * The relay refuses such a move from an older engine before it changes any board.
+ *
+ * @param {string} operation
+ * @param {any[]} args
+ * @returns {boolean}
+ */
+ export function carriesImplies(operation, args) {
+ const options = args?.[1];
+ if (!IMPLYING_OPERATIONS.includes(operation) || !options || typeof options !== 'object') return false;
+ return (Array.isArray(options.implies) && options.implies.length > 0)
+ || (operation === 'answerDecision' && options.supersedes !== undefined && options.supersedes !== null);
+ }
+
+ /**
+ * Validate the implied ids before any part of the decision is written, naming the first unknown one.
+ * Refuses on a board replaying an older engine, so a forged older move cannot change state.
+ *
+ * @param {any} board
+ * @param {unknown} implies
+ * @returns {number[]}
+ */
+ export function checkImplies(board, implies) {
+ if (implies === undefined || implies === null) return [];
+ if (!Array.isArray(implies) || implies.some((id) => !Number.isSafeInteger(id) || id < 1)) {
+ throw new Refused('USAGE', '--implies takes item ids separated by commas, as in --implies 12,13');
+ }
+ const engine = board.executionEngineVersion ?? ENGINE_VERSION;
+ if (implies.length && engine < IMPLIES_ENGINE) {
+ throw new Refused('ENGINE_VERSION', `a decision that implies items requires engine ${IMPLIES_ENGINE}; this board uses engine ${engine}; upgrade Pullboard before using --implies`);
+ }
+ for (const id of implies) {
+ if (!board.db.prepare('SELECT 1 FROM item WHERE item_id = ?').get(id)) {
+ throw new Refused('NO_ITEM', `no item #${id} to imply; name items from pullboard list --all`);
+ }
+ }
+ return [...new Set(implies)];
+ }
+
+ /** The first nonempty line of a decision's text, trimmed, as its citation reads it. */
+ export function firstLine(text) {
+ return String(text ?? '').split('\n').map((line) => line.trim()).find(Boolean) ?? '';
+ }
+
+ /** A short name for a decision, as the facts and `pullboard why` print it. */
+ export function decisionLabel(decision) {
+ if (decision.source === 'answer') return `answer #${decision.id}`;
+ if (decision.source === 'verdict') return `verdict on #${decision.item}`;
+ return `fact ${decision.id} on #${decision.item}`;
+ }
+
+ /** The citation of an answer, read from its shout row. */
+ export function answerDecisionRef(shout) {
+ return { source: 'answer', id: shout.shout_id, item: null, by: shout.shout_from, line: firstLine(shout.shout_text) };
+ }
+
+ /** The citation of a verdict, read from its verdict row. */
+ export function verdictDecisionRef(verdict) {
+ const verb = verdict.verdict_decision === 'ACCEPT' ? 'accept' : 'reject';
+ const note = firstLine(verdict.verdict_note);
+ return { source: 'verdict', id: verdict.verdict_id, item: verdict.item_id, by: verdict.verdict_by,
+ line: `${verb} ${verdict.verdict_reason}${note ? `: ${note}` : ''}` };
+ }
+
+ /** The citation of a fact, read from its stamped event. */
+ export function factDecisionRef(fact, itemId) {
+ return { source: 'fact', id: fact.id, item: itemId, by: fact.by, line: firstLine(fact.text) };
+ }
+
+ /**
+ * The seed for implied-fact ids: the sealed move id on replay, or a fresh one when no move supplies it.
+ * A move id may be 80 characters, but an implied id adds a suffix and must still fit a fact id, so a
+ * move id longer than 72 is replaced by a digest of itself: every replica derives the same ids.
+ */
+ export function impliesSeed(seed) {
+ if (typeof seed === 'string' && /^[A-Za-z0-9_-]{1,72}$/u.test(seed)) return seed;
+ if (typeof seed === 'string' && /^[A-Za-z0-9_-]{73,80}$/u.test(seed)) return `h${createHash('sha256').update(seed).digest('base64url').slice(0, 43)}`;
+ return randomUUID();
+ }
+
+ /**
+ * Write one fact on each implied item citing the decision, stamped with the decider.
+ *
+ * @param {(by: string, itemId: number, detail: object) => void} log appends one fact event
+ * @param {{ seed: string, decision: object, implies: number[] }} options
+ */
+ export function writeImplied(log, { seed, decision, implies }) {
+ for (const itemId of implies) {
+ log(decision.by, itemId, { id: `${seed}-i${itemId}`, kind: 'note', text: `implied by ${decisionLabel(decision)} by ${decision.by}: ${decision.line}`,
+ ref: null, supersedes: null, decision });
+ }
+ }
+
+ /**
+ * Tell each item the old decision implied that a new decision supersedes it, stamped with the new decider.
+ *
+ * @param {(by: string, itemId: number, detail: object) => void} log appends one fact event
+ * @param {{ seed: string, old: object, next: object, implies: number[] }} options
+ */
+ export function writeSuperseded(log, { seed, old, next, implies }) {
+ for (const itemId of implies) {
+ log(next.by, itemId, { id: `${seed}-s${itemId}`, kind: 'note',
+ text: `${decisionLabel(old)} by ${old.by} is superseded by ${decisionLabel(next)} by ${next.by}: ${next.line}`,
+ ref: null, supersedes: null, decision: old, supersededBy: next });
+ }
+ }
+
+ /** True when two citations name the same decision. */
+ function sameDecision(left, right) {
+ return Boolean(left && right) && left.source === right.source && left.id === right.id && (left.item ?? null) === (right.item ?? null);
+ }
+
+ /**
+ * The items an earlier decision implied, read from the facts it wrote.
+ *
+ * @param {any} board
+ * @param {object} decision
+ * @returns {number[]}
+ */
+ export function impliedItems(board, decision) {
+ const rows = board.db.prepare("SELECT item_id, event_detail FROM event WHERE event_kind = 'fact' AND json_extract(event_detail, '$.decision') IS NOT NULL AND json_extract(event_detail, '$.supersededBy') IS NULL ORDER BY event_id").all();
+ return [...new Set(rows.filter((row) => sameDecision(JSON.parse(row.event_detail).decision, decision)).map((row) => row.item_id))];
+ }
+
+ /**
+ * The decisions that imply an item, newest first, each with the decision that superseded it (N29).
+ *
+ * @param {any[]} thread the item's facts and moves, oldest first
+ * @returns {{ source: string, id: any, item: number | null, by: string, line: string, at: string, fact: string, supersededBy: object | null }[]}
+ */
+ export function decisionsImplying(thread) {
+ const facts = thread.filter((entry) => entry.type === 'fact' && entry.decision);
+ return facts.filter((fact) => !fact.supersededBy)
+ .map((fact) => ({ ...fact.decision, at: fact.at, fact: fact.id,
+ supersededBy: facts.filter((notice) => notice.supersededBy && sameDecision(notice.decision, fact.decision)).at(-1)?.supersededBy ?? null }))
+ .reverse();
+ }
+
+ /** One line for a decision as `pullboard why` prints it. */
+ export function whyLine(entry) {
+ return `${entry.at} ${decisionLabel(entry)} by ${entry.by}: ${entry.line}${entry.supersededBy ? ` (superseded by ${decisionLabel(entry.supersededBy)} by ${entry.supersededBy.by})` : ''}`;
+ }
+
+ /** True when this replay's engine tells implied items about supersession; older replays never did. */
+ export function tellsSupersession(board) {
+ return (board.executionEngineVersion ?? ENGINE_VERSION) >= IMPLIES_ENGINE;
+ }
+
+ /** One shout row, or a refusal naming its id. */
+ function shoutRow(board, id) {
+ const found = board.db.prepare('SELECT * FROM shout WHERE shout_id = ?').get(id);
+ if (!found) throw new Refused('NO_SHOUT', `no shout #${id}`);
+ return found;
+ }
+
+ /**
+ * The earlier answer a new answer supersedes, or null; refuses anything that is not an answered
+ * decision, and an agent overruling the person (P6) or another agent's answer (B30).
+ *
+ * @param {any} board
+ * @param {number | null} supersedes
+ * @param {{ from: string, person: string }} answerer who answers now, and the person's id
+ * @returns {any | null}
+ */
+ export function supersededAnswer(board, supersedes, { from, person }) {
+ if (supersedes === null || supersedes === undefined) return null;
+ const engine = board.executionEngineVersion ?? ENGINE_VERSION;
+ if (engine < IMPLIES_ENGINE) throw new Refused('ENGINE_VERSION', `superseding an answer requires engine ${IMPLIES_ENGINE}; this board uses engine ${engine}; upgrade Pullboard before using --supersedes`);
+ if (!Number.isSafeInteger(supersedes) || supersedes < 1) throw new Refused('USAGE', 'name the answer this one supersedes by its shout id: --supersedes 12');
+ const old = shoutRow(board, supersedes);
+ const ask = old.shout_answers === null ? null : shoutRow(board, old.shout_answers);
+ if (old.shout_decision || !ask?.shout_decision || ask.shout_request) {
+ throw new Refused('NOT_A_DECISION', `shout #${supersedes} is not an answer to a decision; supersede an answer id from pullboard decisions`);
+ }
+ if (old.shout_from === person && from !== person) {
+ throw new Refused('B26_PERSON_ANSWER', `answer #${supersedes} is the person's; only the person supersedes it: ask your coordinator to pass a new decision to the person`);
+ }
+ if (from !== person && from !== COORDINATOR && old.shout_from !== from) {
+ throw new Refused('NOT_YOUR_DECISION', `answer #${supersedes} is ${old.shout_from}'s; only its author, the coordinator or the person supersedes it`);
+ }
+ return old;
+ }
+
+ /**
+ * Cite the newest verdict on each item it implies, and tell the items the verdict before it
+ * implied that this one supersedes it. Engines before IMPLIES_ENGINE replay unchanged.
+ * Runs inside the verdict's transaction, so a refused id leaves no verdict behind.
+ *
+ * @param {any} board
+ * @param {(by: string, itemId: number, detail: object) => void} log appends one fact event
+ * @param {number} id the verdict's item
+ * @param {{ seed?: string, implies?: number[] }} options
+ */
+ export function tellVerdictImplications(board, log, id, { seed, implies }) {
+ const named = checkImplies(board, implies);
+ const [latest, previous] = board.db.prepare('SELECT * FROM verdict WHERE item_id = ? ORDER BY verdict_id DESC LIMIT 2').all(id);
+ const decision = verdictDecisionRef(latest);
+ const ids = impliesSeed(seed);
+ writeImplied(log, { seed: ids, decision, implies: named });
+ if (!previous || !tellsSupersession(board)) return;
+ const old = verdictDecisionRef(previous);
+ writeSuperseded(log, { seed: ids, old, next: decision, implies: impliedItems(board, old) });
+ }
+
+ /**
+ * Cite a new answer on each item it implies, and tell the items an earlier answer implied that this
+ * one supersedes it. Runs inside the answer's transaction, so a refusal leaves no answer behind.
+ *
+ * @param {any} board
+ * @param {(by: string, itemId: number, detail: object) => void} log appends one fact event
+ * @param {number} answerId the new answer's shout id
+ * @param {{ seed?: string, implies?: number[], supersedes?: number | null, from: string, person: string }} options
+ * @returns {number} the answer's id, so the caller records and tells in one step
+ */
+ export function tellAnswerImplications(board, log, answerId, { seed, implies, supersedes, from, person }) {
+ const named = checkImplies(board, implies);
+ const replaced = supersededAnswer(board, supersedes, { from, person });
+ const decision = answerDecisionRef(shoutRow(board, answerId));
+ const ids = impliesSeed(seed);
+ writeImplied(log, { seed: ids, decision, implies: named });
+ if (replaced) writeSuperseded(log, { seed: ids, old: answerDecisionRef(replaced), next: decision, implies: impliedItems(board, answerDecisionRef(replaced)) });
+ return answerId;
+ }
+
+ /**
+ * Cite a new fact on each item it implies, and tell the items the fact it supersedes implied.
+ * Runs inside the fact's transaction, so a refused id leaves no fact behind.
+ *
+ * @param {any} board
+ * @param {(by: string, itemId: number, detail: object) => void} log appends one fact event
+ * @param {any} fact the new fact as the thread reads it
+ * @param {{ id: number, implies?: number[], supersedes: string | null }} options its item, implied ids and the fact it corrects
+ * @returns {any} the new fact
+ */
+ export function tellFactImplications(board, log, fact, { id, implies, supersedes }) {
+ const named = checkImplies(board, implies);
+ const decision = factDecisionRef(fact, id);
+ const seed = impliesSeed(fact.id);
+ writeImplied(log, { seed, decision, implies: named });
+ if (supersedes !== null && tellsSupersession(board)) {
+ const row = board.db.prepare("SELECT event_by, event_detail FROM event WHERE event_kind = 'fact' AND item_id = ? AND json_extract(event_detail, '$.id') = ?").get(id, supersedes);
+ const old = factDecisionRef({ id: supersedes, by: row.event_by, text: JSON.parse(row.event_detail).text }, id);
+ writeSuperseded(log, { seed, old, next: decision, implies: impliedItems(board, old) });
+ }
+ return fact;
+ }
+
+ /** The refusal for an answer to a request: a person answer, or one that names items or supersedes. */
+ export function requestAnswerRefusal(id, { asPerson }) {
+ return asPerson
+ ? new Refused('B26_PERSON_ANSWER', `requests are answered by the coordinator; run pullboard answer ${id} done or declined <reason>`)
+ : new Refused('NOT_A_DECISION', `request #${id} is not a decision, so it implies and supersedes nothing; answer it with pullboard answer ${id} done or declined <reason>`);
+ }
+
+ /** The optional engine-20 fields of a fact, present only when its event set them. */
+ export function decisionFields(detail) {
+ return { ...(detail.implies ? { implies: detail.implies } : {}), ...(detail.decision ? { decision: detail.decision } : {}),
+ ...(detail.supersededBy ? { supersededBy: detail.supersededBy } : {}) };
+ }
+
+ /** The most fact ids one checkout remembers as shown; older ones age out first. */
+ const SEEN_LIMIT = 2000;
+
+ /**
+ * The decision facts on the items this agent holds that its resume has not shown yet, marking them
+ * shown. The record is per checkout, like resume's release notes, so each shows once (B29).
+ *
+ * @param {string} gitDir this checkout's own git directory
+ * @param {{ item: number, facts: any[] }[]} held each held item and its thread
+ * @returns {{ item: number, fact: string, text: string }[]}
+ */
+ export function takeDecisionNotices(gitDir, held) {
+ const record = join(gitDir, 'pullboard-checkout', 'decisions-seen.json');
+ let seen = [];
+ try { seen = JSON.parse(readFileSync(record, 'utf8')).seen ?? []; }
+ catch (error) { if (error.code !== 'ENOENT' && !(error instanceof SyntaxError)) throw error; }
+ if (!Array.isArray(seen)) seen = [];
+ const known = new Set(seen);
+ const notices = held.flatMap(({ item, facts }) => facts
+ .filter((fact) => fact.type === 'fact' && fact.decision && !known.has(fact.id))
+ .map((fact) => ({ item, fact: fact.id, text: fact.text })));
+ if (!notices.length) return notices;
+ const next = [...seen, ...notices.map((notice) => notice.fact)].slice(-SEEN_LIMIT);
+ mkdirSync(dirname(record), { recursive: true });
+ const temporary = `${record}.${randomUUID()}.tmp`;
+ writeFileSync(temporary, `${JSON.stringify({ version: 1, seen: next })}\n`);
+ renameSync(temporary, record);
+ return notices;
+ }
+
-/** Give facts the same stamped identity on CLI, API, export and replica reads [B29,B31]. */
++/** Give facts the same stamped identity on CLI, API, export and replica reads; a never-again keeps its cause [B29,B31,D1]. */
+ export function factFromEvent(event) {
+ const detail = JSON.parse(event.event_detail);
+ return { id: detail.id, eventId: event.event_id, kind: detail.kind, text: detail.text,
- by: event.event_by, at: event.event_at, ref: detail.ref ?? null, supersedes: detail.supersedes ?? null, ...decisionFields(detail) };
++ by: event.event_by, at: event.event_at, ref: detail.ref ?? null, supersedes: detail.supersedes ?? null, ...decisionFields(detail),
++ ...(detail.neverAgain ? { cause: detail.cause, neverAgain: true } : {}) };
+ }
diff --cc src/machine.js
index c66dd9dd,227bc125..2081e1ad
--- a/src/machine.js
+++ b/src/machine.js
@@@ -177,8 -173,8 +177,8 @@@ export const MOVES =
},
{
verb: 'reject', from: ['submitted'], to: 'open', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',
- guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven'],
+ guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven', 'causeWellFormed'],
- alsoRefuses: [{ code: 'LAND_HEADER', rule: 'a displayed merge command fits the commit-header limit', next: 'shorten the item title or cited rows so the merge header fits' }],
+ alsoRefuses: [{ code: 'LAND_HEADER', rule: 'a displayed merge command fits the commit-header limit', next: 'shorten the item title or cited rows so the merge header fits' }, { code: 'ENGINE_VERSION', rule: 'a verdict that implies items replays only under engine 20 or later', next: 'upgrade Pullboard on every linked device before using --implies' }],
command: 'pullboard verify <id> reject --reason CODE --note "..."',
},
{