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(core): a decision names the items it implies, WIP [B29,B31,N29]
Corey Olson0f93fea9737c
diff --git a/docs/api.md b/docs/api.mdindex 7d0edfa6..c7d76cde 100644--- a/docs/api.md+++ b/docs/api.md@@ -80,6 +80,7 @@ For example: `flow: review wait average 61 min (1 measured; > 60 min); bottlenec| `add` | `version:number`, `item:object` || `edit` | `version:number`, `item:object` || `fact` | `version:number`, `item:number`, `fact:object` |+| `why` | `version:number`, `id:number`, `decisions:array` || `escalate` | `version:number`, `id:number`, `from:string`, `to:string` || `run` | `version:number`, `messages:array` || `sweep` | `version:number`, `messages:array` |@@ -154,6 +155,8 @@ A correction is a new fact with `--supersedes <fact-id>`. It requires the live h`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.## Refusalsdiff --git a/docs/formats.md b/docs/formats.mdindex c3797a6c..2499cf86 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -102,7 +102,7 @@ The board file is in the repository's Git common directory at `.git/pullboard/bo| `row grammar` | `1` | `SPEC_GRAMMAR_VERSION` in `src/spec.js`; optional `<!-- pullboard-grammar N -->` line in either file (absence means the current grammar) | Both files share the version. A declared version must match; an incompatible grammar change requires a coordinated version bump and compatible files. No automatic conversion occurs. || `board schema` | `2` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | Create missing tables and indexes, add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. || `event log` | `1` | `EVENT_LOG_VERSION` in `src/board.js`, persisted in `board_meta` as `event_log_version` | Older event-log versions upgrade in place; newer versions are refused with `EVENT_LOG_VERSION`. Preserve event rows when the board schema changes. |-| `move engine` | `12` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |+| `move engine` | `18` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |<!-- format-versions:end -->Pullboard 0.6.1 released engine 1. Engine 2 records a fresh explicit-build claim's skipped-review snapshot. Pullboard 0.8.1 released engine 3, including lane-sensitive graft refusals and authenticated relay senders. Engine 4 adds captured background-baseline completions through `completeCheckBaseline`; released engine-3 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Engine 5 requires a one-line reason when releasing a review and gives that reviewer a one-hour cooldown for the current submission. Each sealed move replays under its recorded engine version: engines 1 through 4 retain the original release event and review-reservation behavior. Engine 5 retains support for older moves, including engine-4 baseline completions. Pullboard 0.8.3 released engine 6, adding board-scoped machine credentials and permitting machine execution only for one exact, earlier authenticated phone request, including its payload digest. Engine 7 adds ordered item holds through `holdItem` and `releaseItemHold`; engine-6 clients stop with `ENGINE_VERSION` before interpreting either operation or advancing their replay cursor. Engine 8, shared by the 0.8.5 move changes, retains merged-item exception notes, selects the next review in roadmap order, and adds coordinator-only `reopen` for a submission returned without a verdict; engine-7 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Recorded engines 1 through 7 retain their original tier-first review selection. Engine 8 also adds durable refusal recovery for blocked relay positions; each explicit skip publishes the readable prefix even when another unsupported record follows. Engine 8 also permits coordinator criterion/check edits on a live claim as pending corrections; the holder cannot renew or submit until a refreeze adopts the correction while preserving the claim. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new moves. Each release shares one engine bump across its changed moves. Engine 8 also retains declared model labels on registration and records each registered agent move's model snapshot; engines 1 through 7 retain their original registration and event details without these model fields. Pullboard 0.8.8 released engine 9, which allows resubmitting the same rejected commit after a corrected criterion is refrozen, but only when the rejection names a different frozen digest. Engine 8 retains its HEAD_NOT_NEW refusal and prior submit-event detail. Engine-9 submit events add `criterionDigest`, and engine-8 boards replay with the original refusal and event history.@@ -113,6 +113,8 @@ Engine 11 permits resubmitting the same commit after a coordinator no-verdict reEngine 12 records declined person row decisions without replacing the exact source text: the row becomes `wont` and the reason stays in the decision record. Engine-11 decline receipts retain their original reason-as-row-text validation and replay outcome. Engine-11 clients refuse engine-12 moves before interpreting them; upgrade linked clients before recording new decline decisions.+Engine 18 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-18 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 18 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 13 to 17 replay without these notices. Engine numbers 13 to 17 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.+The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.A linked board requires at least engine 3 after issuing any agent token, includingrevoked or expired tokens. Issuing any machine credential raises that board’s minimum to engine 6, including after revocation or expiry. The minimum survives reopening the auth database;@@ -305,14 +307,14 @@ 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` || `escalate` | builder | `from`, `to`, `note`, `attempt` || `attempt` | reporting agent | `n`, `seconds`, `result` |-| `fact` | author | `id`, `kind`, `text`, `ref`, `supersedes` |+| `fact` | author | `id`, `kind`, `text`, `ref`, `supersedes`, engine-18 `implies`, `decision`, `supersededBy` || `claim` | builder | `leaseUntil`, `digest` || `renew` | builder | `leaseUntil`, `digest` || `release` | builder | — || `submit` | builder | `commit`, `tree`, `policyCommit`, engine-9 `criterionDigest` || `reserve` | reviewer | `until` |-| `accept` | reviewer | `reason`, `commit` |-| `reject` | reviewer | `reason`, `commit` |+| `accept` | reviewer | `reason`, `commit`, engine-18 `implies` |+| `reject` | reviewer | `reason`, `commit`, engine-18 `implies` || `reopen` | coordinator | `commit`, `note`, `judgment`, engine-10 `supersedes`, `landingFailure` || `merged` | coordinator | `commit` || `landing_batch` | coordinator | `batch` |@@ -328,7 +330,7 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `guards` | board | `missing`, `changed`, `stale` || `shout` | sender | `shout`, `to`, `decision`, `request`, `answers` || `pass` | coordinator | `shout`, `to`, `decision`, `request`, `answers` |-| `answer` | answerer | `shout`, `to`, `decision`, `request`, `answers`, `outcome`, `channel` |+| `answer` | answerer | `shout`, `to`, `decision`, `request`, `answers`, `outcome`, `channel`, engine-18 `implies`, `supersedes` || `row_decision` | person | `record`, `channel` || `row_apply` | coordinator | `events` |<!-- events:end -->@@ -341,7 +343,9 @@ Item facts use the existing append-only `event` table and event-log version 1. AA binding is `{path, start, end, commit}`: a relative repository path, a positive ascending inclusive line range and a full 40-character hexadecimal commit id. It identifies code without storing source or requiring Git on a replica. Fact ids are generated UUIDs locally. A sealed `appendFact` operation uses its executable move id as its fact id, so replicas keep corrections bound to the same fact even when local event sequence ids differ. Native export/import retains these event rows without a separate fact table or schema upgrade.-The derived `thread` in CLI `show` JSON and API v1 item state is an array in ascending event order. Move entries are `{type: "move", eventId, kind, by, at, detail}`. Fact entries are `{type: "fact", id, eventId, kind, text, by, at, ref, supersedes}`. `eventId` is the board's numeric event sequence; `id` is the stable fact identity used by corrections. `by` and `at` come from the immutable event author and UTC timestamp. `detail` retains a move's original structured payload. Nullable `ref` and `supersedes` preserve omitted fields as `null`. Superseded facts remain in the array beside their corrections.+The derived `thread` in CLI `show` JSON and API v1 item state is an array in ascending event order. Move entries are `{type: "move", eventId, kind, by, at, detail}`. Fact entries are `{type: "fact", id, eventId, kind, text, by, at, ref, supersedes}`. `eventId` is the board's numeric event sequence; `id` is the stable fact identity used by corrections. `by` and `at` come from the immutable event author and UTC timestamp. `detail` retains a move's original structured payload. Nullable `ref` and `supersedes` preserve omitted fields as `null`. Superseded facts remain in the array beside their corrections. Engine-18 facts add three optional fields, present only when set: `implies`, `decision` and `supersededBy`.++A decision that names the items it changes writes one `fact` event of kind `note` on each named item; the decision's own `fact`, `accept`, `reject` or `answer` event records the requested ids as `implies`, and an answer event records the answer it supersedes as `supersedes`. The implied fact's `decision` cites the decision as `{source, id, item, by, line}`. `source` is `answer`, `verdict` or `fact`. `id` is the answer's shout id, the verdict id, or the fact id. `item` is the item the verdict or fact belongs to, and `null` for an answer. `by` is who decided, and `line` is the decision's first nonempty line; a verdict's line is `accept CRITERION_MET: <note>` or `reject <REASON>: <note>`. The fact's text reads `implied by <decision> by <who>: <line>`. When the decision is superseded, each item it implied gets a second `note` fact with the same `decision` and a `supersededBy` citation of the new decision; its text reads `<old decision> by <who> is superseded by <new decision> by <who>: <line>`. Each fact's author is the decider who caused it: for an implied fact, the old decision's decider; for a supersession notice, the new one's. The citation is built from the board's own record of the decision (the answer's sender, the verdict's reviewer, the fact's author), never from the move's arguments, so only the person's own answer yields a `by: "person"` citation. Only the person supersedes the person's answer. Implied-fact ids are `<seed>-i<item>` and supersession-notice ids are `<seed>-s<item>`. The seed is the decision's fact id for a fact, and for an answer or verdict it is the sealed move id, or a fresh UUID for a local move. Every replica therefore writes the same ids. `pullboard why <id>` reads these facts and lists the decisions that imply an item, newest first. `pullboard resume` shows each implied fact on an item the agent holds once per checkout, recording the shown fact ids in `.git/pullboard-checkout/decisions-seen.json` (or the worktree's own git directory) as `{version: 1, seen: [<fact id>...]}`.Engine version 3 adds the sealed `appendFact` operation. It is the single engine increment reserved for the release after 0.7.0; other changes in that release reuse version 3. Older supported operations remain replayable; an older client refuses a version-3 move before applying it. The sealed envelope, CLI/API envelope, schema and event-log layout versions are unchanged.diff --git a/docs/formats.test.js b/docs/formats.test.jsindex b0a0d9bb..2f5a48cd 100644--- a/docs/formats.test.js+++ b/docs/formats.test.js@@ -278,6 +278,12 @@ function recordEventContract() {editItem(board, first, { agentId: coordinator, brief: 'Files: docs/formats.md\nTest: docs/formats.test.js', route: 'mid', criterion: 'Changed', check: 'node test' });const dependency = addItem(board, { by: coordinator, lane: 'docs', title: 'Dependency example' });editItem(board, first, { agentId: coordinator, after: [dependency] });+ const implying = appendFact(board, first, { agentId: coordinator, kind: 'decision', text: 'Dependency changes', implies: [dependency] });+ appendFact(board, first, { agentId: coordinator, kind: 'supersession', text: 'Dependency changes again', supersedes: implying.id });+ const asked = shout(board, { from: builder, to: coordinator, text: 'implying decision', lanes: ['docs', 'tests'], decision: true });+ const implyingAnswer = answerDecision(board, asked, { agentId: coordinator, text: 'yes', lanes: ['docs', 'tests'], implies: [dependency] });+ const askedAgain = shout(board, { from: builder, to: coordinator, text: 'superseding decision', lanes: ['docs', 'tests'], decision: true });+ answerDecision(board, askedAgain, { agentId: coordinator, text: 'no', lanes: ['docs', 'tests'], supersedes: implyingAnswer });editItem(board, first, { agentId: coordinator, after: [] });holdItem(board, first, { agentId: coordinator, reason: 'fixture item hold' });releaseItemHold(board, first, { agentId: coordinator });@@ -293,7 +299,7 @@ function recordEventContract() {const acceptedCommit = 'a'.repeat(40);submit(board, first, { agentId: builder, commit: acceptedCommit, tree: 'b'.repeat(40), files: ['docs/formats.md'], policyCommit: 'a'.repeat(40) });reserveReview(board, first, { agentId: reviewer, leaseMs: 60_000, policy: 'agents' });- verify(board, first, { agentId: reviewer, decision: 'ACCEPT', reason: ACCEPT_REASON, note: 'checked the example', head: acceptedCommit, digest: 'second', policy: 'agents' });+ verify(board, first, { agentId: reviewer, decision: 'ACCEPT', reason: ACCEPT_REASON, note: 'checked the example', head: acceptedCommit, digest: 'second', policy: 'agents', implies: [dependency] });merged(board, first, { agentId: coordinator, commit: 'c'.repeat(40) });const batch = recordLandingBatch(board, { agentId: coordinator, batch: { version: 1, id: 'format-example', base: 'a'.repeat(40), tip: 'c'.repeat(40),root: '/landing', branch: 'refs/heads/main', state: 'pushed', owner: 'format-example', logPath: '/landing.log', items: [{ id: first, commit: acceptedCommit, merge: 'c'.repeat(40) }] } });@@ -305,7 +311,7 @@ function recordEventContract() {claim(board, rejected, { agentId: builder, lane: 'docs', leaseMs: 60_000, freeze: freeze('rejected') });const rejectedCommit = 'd'.repeat(40);submit(board, rejected, { agentId: builder, commit: rejectedCommit, tree: 'e'.repeat(40) });- verify(board, rejected, { agentId: reviewer, decision: 'REJECT', reason: 'TEST_FAILURE', note: 'the fixture failed', head: rejectedCommit, digest: 'rejected', policy: 'agents' });+ verify(board, rejected, { agentId: reviewer, decision: 'REJECT', reason: 'TEST_FAILURE', note: 'the fixture failed', head: rejectedCommit, digest: 'rejected', policy: 'agents', implies: [dependency] });const corrected = addItem(board, { by: coordinator, lane: 'docs', title: 'Corrected live claim' });claim(board, corrected, { agentId: builder, lane: 'docs', leaseMs: 60_000, freeze: freeze('before-correction') });diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex 4d6325e6..29c04372 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -56,8 +56,8 @@ Each move checks its guards in this order and refuses with the first one that do| 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), 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) || 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) |@@ -147,7 +147,9 @@ Each move checks its guards in this order and refuses with the first one that do| ALREADY_MERGED | the item has no recorded merge receipt | a merged item cannot be reopened || LANDING_FAILURE_REQUIRED | a verified item note names the failing test and landing merge commit | cite the recorded batch, or name the test and merge commit in a manual note || LAND_HEADER | a displayed merge command fits the commit-header limit (accept result) | shorten the item title or cited rows so the merge header fits |+| ENGINE_VERSION | a verdict that implies items replays only under engine 18 or later (accept result) | upgrade Pullboard on every linked device before using --implies || LAND_HEADER | a displayed merge command fits the commit-header limit (reject result) | shorten the item title or cited rows so the merge header fits |+| ENGINE_VERSION | a verdict that implies items replays only under engine 18 or later (reject result) | upgrade Pullboard on every linked device before using --implies || BAD_DECISION | a verdict is accept or reject | pullboard verify <id> accept, or reject --reason CODE --note "..." |For check diagnostics, a refusal from a failed or unverifiable check includes an output digest, sanitized tail, and a private full-output path in the CLI message (also `error.message` in JSON). The artifact is owner-readable only. If it cannot be saved, the tail remains available and the message names the storage error instead of claiming a path.diff --git a/src/api-moves.js b/src/api-moves.jsindex 51dc394c..b3660767 100644--- a/src/api-moves.js+++ b/src/api-moves.js@@ -7,12 +7,12 @@ const MOVES = {'spec-decline': { prefix: ['spec', 'decline'], positions: ['ids'], flags: ['reason'] },add: { positions: ['lane', 'title'], flags: ['criterion', 'specs', 'parent', 'after', 'brief', 'route', 'check'], booleans: ['wait'], booleans: ['wait'] },edit: { item: true, flags: ['criterion', 'brief', 'route', 'check'], booleans: ['wait'], booleans: ['wait'] },- fact: { item: true, positions: ['kind', 'text'], flags: ['supersedes', 'ref'] },+ fact: { item: true, positions: ['kind', 'text'], flags: ['supersedes', 'ref', 'implies'] },claim: { item: true },release: { item: true, flags: ['note'] },submit: { item: true },done: { item: true },- verify: { item: true, positions: ['decision'], flags: ['reason', 'note', 'as'] },+ verify: { item: true, positions: ['decision'], flags: ['reason', 'note', 'as', 'implies'] },merged: { item: true, positions: ['commit'] },withdraw: { item: true, positions: ['reason'] },refreeze: { item: true },@@ -20,7 +20,7 @@ const MOVES = {escalate: { item: true, flags: ['note'] },hold: { positions: ['lane'], flags: ['reason'], booleans: ['off'] },shout: { positions: ['to', 'text'], optional: ['to'], booleans: ['decision'], flags: ['evidence', 'outcome', 'item', 'commit'] },- answer: { item: true, positions: ['text'], flags: ['as'] },+ answer: { item: true, positions: ['text'], flags: ['as', 'implies', 'supersedes'] },pass: { item: true, positions: ['note'] },next: { flags: ['as'], booleans: ['verify', 'build'] },};diff --git a/src/board.js b/src/board.jsindex 0bf0fbca..ae38405a 100644--- a/src/board.js+++ b/src/board.js@@ -14,6 +14,7 @@ import { briefFiles, briefSections } from './brief.js';import { COORDINATOR } from './config.js';import { ENGINE_VERSION, GUARDS, IN_STATE, MOVES, STATES, UNKNOWN_MOVE, effectiveGuards, storeTriggers } from './machine.js';import { Refused } from './refused.js';+import { decisionFields, requestAnswerRefusal, tellAnswerImplications, tellFactImplications, tellVerdictImplications } from './implies.js';import { parseSpec } from './spec.js';export const ACCEPT_REASON = 'CRITERION_MET';@@ -1479,10 +1480,10 @@ function reserveWithin(board, id, { agentId, leaseMs, policy, familyPolicy = 'of** @param {any} board* @param {number} id- * @param {{ agentId: string, decision: string, reason?: string, note?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green' }} verdict+ * @param {{ agentId: string, decision: string, reason?: string, note?: string, 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 = '', head, digest, policy, familyPolicy = 'off', check }) {+export function verify(board, id, { agentId, decision, reason, note = '', 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';@@ -1524,7 +1525,8 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,});const detail = { reason: code, commit: item.item_commit };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 } : {}) };});}@@ -1806,10 +1808,10 @@ export function verdictsFor(board, id) {* Insert a shout within the caller's transaction.** @param {any} board- * @param {{ from: string, to: string, text: string, lanes: string[], decision?: boolean, answers?: number | null, evidence?: any, request?: boolean, channel?: 'terminal' | 'view' }} message+ * @param {{ from: string, to: string, text: string, lanes: string[], decision?: boolean, answers?: number | null, evidence?: any, request?: boolean, channel?: 'terminal' | 'view', detail?: object }} message - detail: extra event fields* @returns {number}*/-function insertShout(board, { from, to, text, lanes, decision = false, answers = null, evidence = null, request = false, channel = 'terminal' }) {+function insertShout(board, { from, to, text, lanes, decision = false, answers = null, evidence = null, request = false, channel = 'terminal', detail = {} }) {if (!text.trim()) throw new Refused('EMPTY_SHOUT', 'a shout needs text');if (to === from) throw new Refused('SELF_SHOUT', `a shout cannot be addressed to its sender ${from}; name another agent, a lane or all`);if (request && (from !== 'person' || to !== COORDINATOR || decision || answers !== null)) {@@ -1852,7 +1854,7 @@ function insertShout(board, { from, to, text, lanes, decision = false, answers =).run(from, to, text.trim(), now(board), decision ? 1 : 0, answers, evidence?.kind ?? null, evidence ? evidence.outcome.trim() : null, evidence?.item ?? null, evidence?.commit ?? null, request ? 1 : 0, outcome);const id = Number(result.lastInsertRowid);- logEvent(board, from, answers === null ? 'shout' : decision ? 'pass' : 'answer', null, { shout: id, to, decision: Boolean(decision), request: Boolean(request), answers, ...(outcome ? { outcome } : {}), ...(personAnswer ? { channel } : {}) });+ logEvent(board, from, answers === null ? 'shout' : decision ? 'pass' : 'answer', null, { shout: id, to, decision: Boolean(decision), request: Boolean(request), answers, ...(outcome ? { outcome } : {}), ...(personAnswer ? { channel } : {}), ...detail });return id;}@@ -1892,14 +1894,14 @@ export function passDecision(board, id, { agentId, note, lanes }) {** @param {any} board* @param {number} id- * @param {{ agentId: string, text: string, lanes: string[], asPerson?: boolean, channel?: 'terminal' | 'view' }} options+ * @param {{ agentId: string, text: string, lanes: string[], asPerson?: boolean, channel?: 'terminal' | 'view', implies?: number[], supersedes?: number | null, impliesId?: string }} options - implies and supersedes tell items (B29,B31)* @returns {number}*/-export function answerDecision(board, id, { agentId, text, lanes, asPerson = false, channel = 'terminal' }) {+export function answerDecision(board, id, { agentId, text, lanes, asPerson = false, channel = 'terminal', implies, supersedes = null, impliesId }) {return atomic(board, () => {const ask = getShout(board, id);if (ask.shout_request) {- if (asPerson) throw new Refused('B26_PERSON_ANSWER', `requests are answered by the coordinator; run pullboard answer ${id} done or declined <reason>`);+ if (asPerson || implies?.length || supersedes !== null) throw requestAnswerRefusal(id, { asPerson });return insertShout(board, { from: agentId, to: ask.shout_from, text, lanes, answers: id });}if (!ask.shout_decision) throw new Refused('NOT_A_DECISION', `shout #${id} asked for no decision`);@@ -1915,7 +1917,8 @@ export function answerDecision(board, id, { agentId, text, lanes, asPerson = falthrow new Refused('NOT_YOUR_DECISION', `shout #${id} is addressed to ${ask.shout_to}, not ${lane} (agent ${agentId})`);}const from = personAnswer ? PERSON : agentId;- const answerId = insertShout(board, { from, to: ask.shout_from, text, lanes, answers: id, channel });+ const answerId = insertShout(board, { from, to: ask.shout_from, text, lanes, answers: id, channel, detail: { ...(implies?.length ? { implies } : {}), ...(supersedes !== null ? { supersedes } : {}) } });+ tellAnswerImplications(board, (by, itemId, fact) => logEvent(board, by, 'fact', itemId, fact), answerId, { seed: impliesId, implies, supersedes, from, person: PERSON });if (personAnswer && ask.shout_answers !== null) {const original = getShout(board, ask.shout_answers);insertShout(board, { from: PERSON, to: original.shout_from, text: `Person answered #${id}: ${String(text).trim()}`, lanes, answers: original.shout_id, channel });@@ -2079,7 +2082,7 @@ export function factReference(ref) {function factFromEvent(event) {const detail = JSON.parse(event.event_detail);return { id: detail.id, eventId: event.event_id, kind: detail.kind, text: detail.text,- by: event.event_by, at: event.event_at, ref: detail.ref ?? null, supersedes: detail.supersedes ?? null };+ by: event.event_by, at: event.event_at, ref: detail.ref ?? null, supersedes: detail.supersedes ?? null, ...decisionFields(detail) };}/** Read every move and fact in append order, including superseded facts and full original text [B31,B32]. */@@ -2099,7 +2102,7 @@ export function projectItemThreads(board, state) {/** Append a typed fact atomically; a correction never edits the original event [B29,B30,B31,B32].* The internal factId is set from a sealed move's identity during replay, rather than replica-local sequence ids.*/-export function appendFact(board, id, { agentId, kind, text, ref = null, supersedes = null, factId = randomUUID() }) {+export function appendFact(board, id, { agentId, kind, text, ref = null, supersedes = null, factId = randomUUID(), implies }) {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`);@@ -2114,8 +2117,8 @@ export function appendFact(board, id, { agentId, kind, text, ref = null, supersethrow new Refused('NO_FACT', `no fact ${String(supersedes)} on item #${id}; use a fact id from pullboard show ${id} --json`);}const binding = factReference(ref);- logEvent(board, agentId, 'fact', id, { id: factId, kind, text, ref: binding, supersedes });- return factFromEvent(board.lastEvent);+ logEvent(board, agentId, 'fact', id, { id: factId, kind, text, ref: binding, supersedes, ...(implies?.length ? { implies } : {}) });+ return tellFactImplications(board, (by, itemId, fact) => logEvent(board, by, 'fact', itemId, fact), factFromEvent(board.lastEvent), { id, implies, supersedes });});}diff --git a/src/cli.js b/src/cli.jsindex 7c289e1f..072629ee 100644--- a/src/cli.js+++ b/src/cli.js@@ -35,6 +35,7 @@ import {import { detectGate, initRepo, proposeLanes } from './init.js';import { lifecycleMarkdown } from './machine.js';import { HELP, VERSION } from './help.js';+import { checkImplies, decisionsImplying, parseImplies, takeDecisionNotices, whyLine } from './implies.js';import { defaultViewPort } from './view-port.js';export { HELP, VERSION };import { productLine, productProblems, productSummaries } from './products.js';@@ -299,6 +300,7 @@ const OPTIONS = {commit: { type: 'string' },ref: { type: 'string' },supersedes: { type: 'string' },+ implies: { type: 'string' },owns: { type: 'string' },help: { type: 'boolean', short: 'h' },version: { type: 'boolean', short: 'v' },@@ -1288,6 +1290,8 @@ function resumeHere(io) {flow: proofStats(board, { now: ctx.clock.now().getTime() }).flow } : {}),requests: me.id === COORDINATOR ? store.openRequests(board) : [],holding: all.filter((item) => item.item_status === 'claimed' && item.item_owner === me.id),+ held: all.filter((item) => item.item_status === 'claimed' && item.item_owner === me.id)+ .map((item) => ({ item: item.item_id, facts: store.itemThread(board, item.item_id) })),sentBack: all.filter((item) => item.item_status === 'open' && item.item_verdict === 'REJECT' && item.item_built_by === me.id).map((item) => ({ item, verdict: store.verdictsFor(board, item.item_id).at(-1) })),@@ -1352,6 +1356,9 @@ function resumeHere(io) {}}for (const request of card.requests) say(`request #${request.shout_id}: ${request.shout_text}; answer with pullboard answer ${request.shout_id} done, or declined <reason>`);+ card.decisions = takeDecisionNotices(ctx.info.gitDir, card.held);+ delete card.held;+ for (const notice of card.decisions) say(`decision for #${notice.item} ${notice.text}`);for (const item of card.holding) {say(`holding #${item.item_id} ${item.item_title}, lease ${span(ctx, item.item_lease_until)} left${item.item_check ? `; check: ${item.item_check}` : ''}`);const files = briefFiles(item.item_brief);@@ -1990,6 +1997,16 @@ function readCommands(io, { first, second, rest, values }) {}return 0;},+ why: () => {+ if (!first || second || rest.length) throw new Refused('USAGE', 'pullboard why <id>: the decisions that imply an item, newest first');+ const ctx = context(io);+ const id = idArg(first);+ const decisions = withBoard(ctx, (board) => decisionsImplying(store.itemThread(board, id)));+ io.result?.({ id, decisions });+ if (!decisions.length) io.say(`no decision implies #${id}`);+ for (const entry of decisions) io.say(whyLine(entry));+ return 0;+ },show: () => {const ctx = context(io);const id = idArg(first);@@ -2423,6 +2440,7 @@ async function addBlueprint(ctx, board, me, blueprint, { report = true } = {}) {async function verifyHere(ctx, id, { second, values }) {const decision = { accept: 'ACCEPT', reject: 'REJECT' }[String(second ?? '').toLowerCase()];if (!decision) throw new Refused('USAGE', 'pullboard verify <id> accept, or reject --reason CODE --note "..."');+ const implies = parseImplies(values.implies);const { root } = ctx.info;let verificationProfile = null;let accepted = null;@@ -2448,6 +2466,8 @@ async function verifyHere(ctx, id, { second, values }) {if (item.item_status !== 'submitted') {throw new Refused('NOT_SUBMITTED', `item #${id} is ${item.item_status}, not submitted`);}+ // Name an unknown implied item before the frozen check runs, not after it.+ if (implies) checkImplies(board, implies);const policy = itemPolicy(root, item);ctx = { ...ctx, config: policy.config };const head = headCommit(root) ?? '';@@ -2492,6 +2512,7 @@ async function verifyHere(ctx, id, { second, values }) {policy: ctx.config.verify.policy,familyPolicy: ctx.config.verify.family,...(decision === 'ACCEPT' ? { check: check.checked ? 'green' : 'none' } : {}),+ ...(implies ? { implies } : {}),}]);};const result = await withBoard(ctx, async (board) => {@@ -2783,10 +2804,11 @@ function workCommands(io, args) {return 0;}),fact: () => act(async (ctx, board, me) => {- if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha]');+ if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha] [--implies <ids>]');const id = idArg(first);+ const implies = parseImplies(values.implies);const fact = await ordered(ctx, board, 'appendFact', [id, { agentId: me.id, kind: second,- text: rest[0], supersedes: values.supersedes ?? null, ref: values.ref ?? null }]);+ text: rest[0], supersedes: values.supersedes ?? null, ref: values.ref ?? null, ...(implies ? { implies } : {}) }]);io.result?.({ item: id, fact });io.say(`fact ${fact.id} appended to #${id} as ${fact.kind}`);return 0;@@ -3108,7 +3130,10 @@ function workCommands(io, args) {answer: () => act(async (ctx, board, me) => {const asPerson = personMode(ctx, me, values);if (asPerson) requirePersonChannel(ctx.io.personChannel);- const id = await ordered(ctx, board, 'answerDecision', [idArg(first), { agentId: me.id, text: [second, ...rest].filter(Boolean).join(' '), lanes: laneNames(ctx.config), asPerson, channel: ctx.io.personChannel ?? 'terminal' }]);+ const implies = parseImplies(values.implies);+ const supersedes = values.supersedes === undefined ? undefined : idArg(String(values.supersedes).replace(/^#/u, ''));+ const id = await ordered(ctx, board, 'answerDecision', [idArg(first), { agentId: me.id, text: [second, ...rest].filter(Boolean).join(' '), lanes: laneNames(ctx.config), asPerson, channel: ctx.io.personChannel ?? 'terminal',+ ...(implies ? { implies } : {}), ...(supersedes ? { supersedes } : {}) }]);const ask = store.getShout(board, idArg(first));io.result?.({ id, answers: ask.shout_id });if (asPerson) {diff --git a/src/engine.js b/src/engine.jsindex 4948b094..a2b7165d 100644--- a/src/engine.js+++ b/src/engine.js@@ -2,6 +2,7 @@import { createHash, randomUUID } from 'node:crypto';import * as store from './board.js';import { recordedRefusal } from './recorded-refusal.js';+import { carriesImplies, IMPLIES_ENGINE } from './implies.js';import { ENGINE_VERSION } from './machine.js';import { Refused } from './refused.js';import { requestMoveProblem, recordRequestMove } from './relay-requests.js';@@ -22,9 +23,10 @@ export const ENGINE_OPERATIONS = Object.freeze([/** Engine version at which each ordered operation first has stable replay semantics. */const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8 });-/** Dependency edits add engine-10 meaning without changing ordinary historical edit envelopes. */+/** Dependency edits add engine-10 meaning, and implied items engine-18 meaning, without changing ordinary historical envelopes. */function minimumOperationEngine(operation, args) {const options = args[1];+ if (carriesImplies(operation, args)) return IMPLIES_ENGINE;return operation === 'editItem' && options && Object.hasOwn(options, 'after') && options.after !== undefined? 10 : OPERATION_ENGINE[operation] ?? 1;}@@ -114,6 +116,8 @@ function executableArgs(move, board) {if (!args[1] || typeof args[1] !== 'object' || Array.isArray(args[1])) throw new Refused('RELAY_MOVE', 'a fact needs its typed arguments; use the current Pullboard engine');args[1].factId = move.id;}+ // Implied facts take their ids from the sealed move, so every replica writes the same ones.+ if (['answerDecision', 'verify'].includes(move.operation) && args[1] && typeof args[1] === 'object' && !Array.isArray(args[1])) args[1].impliesId = move.id;if (['claim', 'refreeze'].includes(move.operation)) {const options = args[1];if (!options || !Object.hasOwn(options, 'frozen')) throw new Refused('RELAY_MOVE', 'the claim has no frozen criterion; send it with the current pullboard engine');@@ -136,7 +140,7 @@ function executableArgs(move, board) {!['any', 'coordinator'].includes(captured?.policy) || !['off', 'prefer', 'require'].includes(captured?.family)) {throw new Refused('NO_POLICY', 'the frozen verify policy is missing or invalid; ask the coordinator to refreeze this item before verifying it');}- args[1] = { ...options, policy: captured.policy, familyPolicy: captured.family };+ args[1] = { ...options, policy: captured.policy, familyPolicy: captured.family, impliesId: move.id };}return args;}diff --git a/src/help.js b/src/help.jsindex a1185b07..87976fb2 100644--- a/src/help.js+++ b/src/help.js@@ -76,8 +76,11 @@ Workpullboard skills --update refresh unchanged Claude Code skills from shipped versionspullboard 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+ pullboard why <id> the decisions that imply an item, newest first, and what superseded thempullboard next [--wait <minutes>] offer an eligible review when reviews pile up, otherwise claim workpullboard next --build claim a build explicitly, recording a skipped review offerpullboard next --verify reserve the next submitted item you can check;@@ -90,12 +93,15 @@ Workpullboard 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"+ a verdict takes --implies <ids>; a later verdict on the item supersedes itany --note can be --note-file <file>, which keeps quotes, $ and backticks intactpullboard shout <lane|agent|person|all> <text> pullboard inboxpullboard shout [<to>] <text> --decision ask for a decision; defaults to your coordinator or the personpullboard shout <to> <text> --evidence attempt|receipt --outcome <word> --item <id> --commit <rev>- pullboard answer <shout-id> <text> [--as person]+ pullboard answer <shout-id> <text> [--as person] [--implies <ids>] [--supersedes <answer-id>]answer your decision; person mode is main-checkout only+ --supersedes tells the items an earlier answer implied; only the person+ supersedes the person's answerpullboard pass <shout-id> <note> coordinator passes a decision to the personpullboard decisions [--as person] shouts waiting for you; main checkout defaults to coordinatorpullboard export print the whole board as versioned JSON@@ -186,7 +192,7 @@ Reject reasons: TEST_FAILURE, BEHAVIOR_MISMATCH, INSUFFICIENT_EVIDENCE, STALE_HEconst 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',+ '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','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',@@ -206,6 +212,7 @@ const HELP_EXAMPLES = {add: 'pullboard add web "Upload page" --specs G1', list: 'pullboard list web', show: 'pullboard show 12',claim: 'pullboard claim 12', submit: 'pullboard submit 12', 'next --verify': 'pullboard next --verify',fact: 'pullboard fact 12 measurement "The check passes in 8 seconds"',+ why: 'pullboard why 12',verify: 'pullboard verify 12 accept --note "removed the fix; the test failed"',answer: 'pullboard answer 12 "done"', pass: 'pullboard pass 12 "please decide"',status: 'pullboard status', view: 'pullboard view', mcp: 'pullboard mcp', stats: 'pullboard stats --since 2026-10-08', log: 'pullboard log 12', ledger: 'pullboard ledger',@@ -260,6 +267,7 @@ const HELP_FLAG_EXPLANATIONS = {'--check': 'the command that proves it','--family': 'records the family name','--model': 'identifies the agent model; required unless PULLBOARD_MODEL is set',+ '--implies': 'each named item gets a fact citing this decision','--landing': 'prioritizes a trunk landing in the machine gate queue','--json': 'prints one versioned document','--note': 'what was checked stays with the receipt',diff --git a/src/implies.js b/src/implies.jsnew file mode 100644index 00000000..f3928408--- /dev/null+++ b/src/implies.js@@ -0,0 +1,321 @@+/**+ * 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 { 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 = 18;++/** 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) };+}++/** A fresh seed for implied-fact ids when no sealed move supplies one; replay passes the move id. */+export function impliesSeed(seed) {+ return typeof seed === 'string' && /^[A-Za-z0-9_-]{1,72}$/u.test(seed) ? seed : 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+ */+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)) });+}++/**+ * 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);+ writeImplied(log, { seed: fact.id, 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: fact.id, 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-18 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;+}diff --git a/src/json.js b/src/json.jsindex eb237e3f..ca04fc53 100644--- a/src/json.js+++ b/src/json.js@@ -44,6 +44,7 @@ export const JSON_SHAPES = {add: shape({ item: 'object' }),edit: shape({ item: 'object' }),fact: shape({ item: 'number', fact: 'object' }),+ why: shape({ id: 'number', decisions: 'array' }),escalate: shape({ id: 'number', from: 'string', to: 'string' }),run: shape({ messages: 'array' }),sweep: shape({ messages: 'array' }),diff --git a/src/machine.js b/src/machine.jsindex 71b60afe..9e840df5 100644--- a/src/machine.js+++ b/src/machine.js@@ -10,7 +10,7 @@*//** Executable move semantics, carried by every sealed move and retained during replay [H16]. */-export const ENGINE_VERSION = 12;+export const ENGINE_VERSION = 18;/** @typedef {'agent' | 'coordinator' | 'clock'} Role */@@ -168,13 +168,13 @@ export const MOVES = [{verb: 'accept', from: ['submitted'], to: 'verified', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonIsMet', 'trunkMergeClean', 'noUnverifiedStack', 'itemCheckGreen', 'proofNoted'],- 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 18 or later', next: 'upgrade Pullboard on every linked device before using --implies' }],sets: ['item_verified_by'], command: 'pullboard verify <id> accept --note "..."',},{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'],- 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 18 or later', next: 'upgrade Pullboard on every linked device before using --implies' }],command: 'pullboard verify <id> reject --reason CODE --note "..."',},{diff --git a/src/templates.js b/src/templates.jsindex 5c9a529a..8271f4dd 100644--- a/src/templates.js+++ b/src/templates.js@@ -118,7 +118,7 @@ It prints the folder to work in and what to run there first. Every join needs th**The loop.**1. \`pullboard resume\` at the start of every session and after your context is compacted: your claim, what came back, unread shouts and the next step. Then \`pullboard inbox\`.-2. \`pullboard next\` claims the next item in your lane that is free to start. When everything is waiting on other work, \`pullboard next --wait 9\` keeps looking for up to 9 minutes, which fits one tool call with a ten-minute timeout; run it again to keep waiting. A claim is a 2-hour lease; claim again to renew. The criterion freezes now: \`pullboard show <id>\` is the bar your work is judged against, and its brief says how to start.+2. \`pullboard next\` claims the next item in your lane that is free to start. When everything is waiting on other work, \`pullboard next --wait 9\` keeps looking for up to 9 minutes, which fits one tool call with a ten-minute timeout; run it again to keep waiting. A claim is a 2-hour lease; claim again to renew. The criterion freezes now: \`pullboard show <id>\` is the bar your work is judged against, and its brief says how to start. \`pullboard why <id>\` lists the decisions that changed it, newest first. When your own answer, verdict or fact changes other items, name them with \`--implies <ids>\` so each one carries it.3. Build inside your lane's folders (\`pullboard lanes\`). Pre-commit refuses anything else; shout the owner instead.4. Commit, then \`pullboard submit <id>\`. It needs a clean tree and the gate green at HEAD.5. A different agent verifies: \`pullboard next --verify\` names the next item to check. It checks out the submitted commit and runs \`pullboard verify <id> accept --note "how it proved it"\`, or \`pullboard verify <id> reject --reason TEST_FAILURE --note "what failed"\`.diff --git a/test/agent-model-engine.test.js b/test/agent-model-engine.test.jsindex e85e2e8d..fcf27366 100644--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@ -11,7 +11,7 @@ import { tmpdir } from 'node:os';import { join } from 'node:path';test('model declarations and event snapshots retain engines 1 through 11 semantics [O8,O3,H16]', (t) => {- assert.equal(ENGINE_VERSION, 12, 'engine 12 preserves the released engine-8 through engine-11 model behavior');+ assert.equal(ENGINE_VERSION, 18, 'engine 18 preserves the released engine-8 through engine-11 model behavior');for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ENGINE_VERSION]) {const board = store.openBoard(':memory:');t.after(() => store.closeBoard(board));diff --git a/test/api.test.js b/test/api.test.jsindex 3f00ea84..90849a4d 100644--- a/test/api.test.js+++ b/test/api.test.js@@ -656,6 +656,8 @@ test('[A1] command results match the catalog across roots and subcommands', () =const added = json(box, repo, 'add', ['coordinator', 'API item', '--specs', 'G1', '--criterion', 'the API item is verified', '--check', 'true']);assert.equal(added.item.item_id, 1);json(box, repo, 'fact', ['1', 'note', 'API fact']);+ json(box, repo, 'fact', ['1', 'decision', 'API decision', '--implies', '1']);+ assert.equal(json(box, repo, 'why', ['1']).decisions[0].line, 'API decision', 'why lists the decision that implies the item [N29]');json(box, repo, 'edit', ['1', '--criterion', 'the edited API item is verified', '--check', 'true']);json(box, repo, 'show', ['1']);json(box, repo, 'list', ['--all']);diff --git a/test/implies.test.js b/test/implies.test.jsnew file mode 100644index 00000000..7fb1d930--- /dev/null+++ b/test/implies.test.js@@ -0,0 +1,220 @@+/** A decision names the items it changes, and each named item carries it [B29,B30,B31,N29,P6]. */+import assert from 'node:assert/strict';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';+import { chmodSync, mkdirSync, mkdtempSync, realpathSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';+import { after, test } from 'node:test';+import * as store from '../src/board.js';+import { applyEngineMove, applyRelayMove, prepareEngineMove } from '../src/engine.js';++const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');+const sandboxes = [];+const SPEC = '# Implies fixture\n\n## G · Goals\n- G1 [approved, must] The feature works. | gate: test\n';+const HOUR = 3_600_000;++after(() => {+ for (const dir of sandboxes) rmSync(dir, { recursive: true, force: true });+});++/** Make an isolated real-Git repo with a board, a coordinator, one joined web builder and three web items. */+function fixture() {+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-implies-')));+ sandboxes.push(dir);+ const shims = join(dir, 'bin');+ mkdirSync(shims);+ writeFileSync(join(shims, 'pullboard'), `#!/bin/sh\nexec "${process.execPath}" "${BIN}" "$@"\n`, { mode: 0o755 });+ chmodSync(join(shims, 'pullboard'), 0o755);+ const env = {+ ...process.env,+ PATH: `${shims}:${process.env.PATH}`,+ GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',+ GIT_AUTHOR_NAME: 'Test Agent', GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Test Agent', GIT_COMMITTER_EMAIL: '[email protected]',+ PULLBOARD_HOME: join(dir, 'home'), PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),+ };+ for (const name of Object.keys(env)) if (name.startsWith('GIT_') && !name.startsWith('GIT_CONFIG') && !name.startsWith('GIT_AUTHOR') && !name.startsWith('GIT_COMMITTER')) delete env[name];+ delete env.PULLBOARD_RELAY_TOKEN;+ const repo = join(dir, 'repo');+ mkdirSync(repo);+ /** Run Git in this private fixture with its isolated identity. */+ const git = (cwd, ...args) => runFixtureGit(args, { cwd, env });+ /** Run the actual CLI in a fixture checkout and keep both output streams. */+ const run = (cwd, ...args) => {+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout ?? '', err: result.failure ?? result.stderr ?? '' };+ };+ /** Run a command that must succeed with --json and return its one document. */+ const json = (cwd, ...args) => {+ const result = run(cwd, ...args, '--json');+ assert.equal(result.code, 0, `${args.join(' ')}: ${result.err}${result.out}`);+ return JSON.parse(result.out);+ };+ git(repo, 'init', '-q', '-b', 'main');+ assert.equal(run(repo, 'init').code, 0);+ writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({+ gate: 'true', spec: 'SPEC.md', verify: 'any', lease: '2h',+ lanes: { web: { owns: ['web/'], specs: ['G1'] } },+ }, null, 2));+ writeFileSync(join(repo, 'SPEC.md'), SPEC);+ mkdirSync(join(repo, 'web'));+ writeFileSync(join(repo, 'web', 'shared.txt'), 'base\n');+ git(repo, 'add', '-A');+ git(repo, 'commit', '-q', '-m', 'chore: create implies fixture');+ const web = json(repo, 'worktree', 'web', '--route', 'strong').path;+ for (const title of ['First implied item', 'Second implied item', 'Untouched item']) {+ json(repo, 'add', 'web', title, '--specs', 'G1', '--criterion', `${title} works`, '--check', 'true');+ }+ return { dir, env, repo, web, run, json };+}++/** The facts in one item's thread, read through the real show command. */+function facts(box, id) {+ return box.json(box.repo, 'show', String(id)).thread.filter((entry) => entry.type === 'fact');+}++/** Count how many times a literal string occurs in a text. */+function occurrences(text, needle) {+ return text.split(needle).length - 1;+}++test('[B29,B31,N29] a decision reaches the items it implies', () => {+ const box = fixture();+ assert.equal(box.json(box.web, 'claim', '1').id, 1);+ const ask = box.json(box.web, 'shout', 'coordinator', 'Which engine ships in 0.8.8?', '--decision').id;+ const answer = box.json(box.repo, 'answer', String(ask), 'Ship engine 9 in 0.8.8\nso #1 and #2 move to engine 10', '--implies', '1,#2');++ for (const id of [1, 2]) {+ const implied = facts(box, id).filter((fact) => fact.decision);+ assert.equal(implied.length, 1, `#${id} carries the decision as one fact`);+ assert.deepEqual(implied[0].decision, { source: 'answer', id: answer.id, item: null, by: 'coordinator', line: 'Ship engine 9 in 0.8.8' },+ `#${id}'s fact cites the decision's id, who decided and its first line`);+ assert.equal(implied[0].supersededBy, undefined, 'an implied fact is not a supersession notice');+ assert.match(implied[0].text, new RegExp(`answer #${answer.id} by coordinator: Ship engine 9 in 0\\.8\\.8$`), 'the fact text names the decision for any reader');+ const shown = box.run(box.repo, 'show', String(id));+ assert.equal(shown.code, 0, shown.err);+ assert.ok(shown.out.includes(`implied by answer #${answer.id} by coordinator: Ship engine 9 in 0.8.8`), `pullboard show #${id} prints the implied fact`);+ }+ assert.deepEqual(facts(box, 3), [], 'an item not named carries nothing');++ const notice = `implied by answer #${answer.id} by coordinator: Ship engine 9 in 0.8.8`;+ const first = box.run(box.web, 'resume');+ assert.equal(first.code, 0, first.err);+ assert.equal(occurrences(first.out, notice), 1, `the holder's next resume shows the decision once:\n${first.out}`);+ assert.ok(first.out.includes(`#1 ${notice}`), 'the resume line names the held item');+ const second = box.run(box.web, 'resume');+ assert.equal(second.code, 0, second.err);+ assert.equal(occurrences(second.out, notice), 0, `a later resume does not repeat it:\n${second.out}`);++ const ask2 = box.json(box.web, 'shout', 'coordinator', 'Engine 9 slipped; what now?', '--decision').id;+ const replacement = box.json(box.repo, 'answer', String(ask2), 'Ship engine 10 in 0.8.9 instead', '--supersedes', String(answer.id));+ for (const id of [1, 2]) {+ const told = facts(box, id).filter((fact) => fact.supersededBy);+ assert.equal(told.length, 1, `#${id} is told once that its decision was superseded`);+ assert.deepEqual(told[0].decision, { source: 'answer', id: answer.id, item: null, by: 'coordinator', line: 'Ship engine 9 in 0.8.8' }, 'the notice names the old decision');+ assert.deepEqual(told[0].supersededBy, { source: 'answer', id: replacement.id, item: null, by: 'coordinator', line: 'Ship engine 10 in 0.8.9 instead' }, 'the notice names the new decision');+ assert.match(told[0].text, new RegExp(`answer #${answer.id} by coordinator is superseded by answer #${replacement.id} by coordinator: Ship engine 10 in 0\\.8\\.9 instead$`));+ }+ assert.deepEqual(facts(box, 3), [], 'an item not named stays untouched by the supersession');+ const third = box.run(box.web, 'resume');+ assert.equal(occurrences(third.out, `is superseded by answer #${replacement.id}`), 1, `the holder's next resume shows the supersession once:\n${third.out}`);++ box.json(box.repo, 'fact', '3', 'decision', 'Keep #1 behind the engine flag', '--implies', '1');+ const why = box.json(box.repo, 'why', '1');+ assert.equal(why.id, 1);+ assert.deepEqual(why.decisions.map((entry) => [entry.source, entry.line, entry.supersededBy?.id ?? null]),+ [['fact', 'Keep #1 behind the engine flag', null], ['answer', 'Ship engine 9 in 0.8.8', replacement.id]],+ 'pullboard why lists the decisions that imply an item, newest first, with supersession');+ const whyText = box.run(box.repo, 'why', '1');+ assert.equal(whyText.code, 0, whyText.err);+ assert.ok(whyText.out.indexOf('Keep #1 behind the engine flag') < whyText.out.indexOf('Ship engine 9 in 0.8.8'), `newest first in text:\n${whyText.out}`);+ assert.match(whyText.out, new RegExp(`superseded by answer #${replacement.id}`));+ assert.deepEqual(box.json(box.repo, 'why', '3').decisions, [], 'an item nothing implies has no decisions');+});++test('[B29,B31] verdicts and facts carry --implies; a later verdict or a superseding fact tells the items; unknown ids are refused by name', () => {+ const box = fixture();+ box.json(box.web, 'claim', '1');+ box.json(box.web, 'submit', '1');+ const review = box.json(box.repo, 'worktree', 'web', '--route', 'strong').path;+ box.json(review, 'next', '--verify');+ const refused = box.run(review, 'verify', '1', 'reject', '--reason', 'TEST_FAILURE', '--note', 'x', '--implies', '2,99', '--json');+ assert.notEqual(refused.code, 0);+ assert.equal(JSON.parse(refused.out).error.code, 'NO_ITEM');+ assert.match(JSON.parse(refused.out).error.message, /#99/, 'the refusal names the unknown id');+ assert.equal(box.json(box.repo, 'show', '1').item_status, 'submitted', 'a refused --implies records no verdict');+ box.json(review, 'verify', '1', 'reject', '--reason', 'TEST_FAILURE', '--note', 'the fixture fails\nsecond line', '--implies', '2');+ const fromVerdict = facts(box, 2).filter((fact) => fact.decision);+ assert.equal(fromVerdict.length, 1);+ assert.equal(fromVerdict[0].decision.source, 'verdict');+ assert.equal(fromVerdict[0].decision.item, 1);+ assert.equal(fromVerdict[0].decision.line, 'reject TEST_FAILURE: the fixture fails');+ assert.equal(fromVerdict[0].by, fromVerdict[0].decision.by, 'the reviewer who decided authors the implied fact');+ box.json(box.web, 'claim', '1');+ writeFileSync(join(box.web, 'web', 'shared.txt'), 'fixed\n');+ runFixtureGit(['commit', '-q', '-am', 'fix: the fixture passes [G1]'], { cwd: box.web, env: box.env });+ box.json(box.web, 'submit', '1');+ box.json(review, 'next', '--verify');+ box.json(review, 'verify', '1', 'accept', '--note', 'ran the fixture check');+ const told = facts(box, 2).filter((fact) => fact.supersededBy);+ assert.equal(told.length, 1, 'a later verdict on the same item supersedes the earlier one for the items it implied');+ assert.equal(told[0].supersededBy.source, 'verdict');+ assert.equal(told[0].supersededBy.line, 'accept CRITERION_MET: ran the fixture check');++ const decision = box.json(box.repo, 'fact', '3', 'decision', 'Item 2 waits for engine 18', '--implies', '2').fact;+ box.json(box.repo, 'fact', '3', 'supersession', 'Item 2 waits for engine 19', '--supersedes', decision.id);+ const corrected = facts(box, 2).filter((fact) => fact.supersededBy?.source === 'fact');+ assert.equal(corrected.length, 1, 'superseding a fact that implied items tells each of them');+ assert.equal(corrected[0].decision.id, decision.id);+ assert.equal(corrected[0].supersededBy.line, 'Item 2 waits for engine 19');+ assert.equal(facts(box, 1).filter((fact) => fact.decision).length, 0, 'an item the fact never named is not told');+ const unknownFact = box.run(box.repo, 'fact', '3', 'note', 'stray', '--implies', '42', '--json');+ assert.equal(JSON.parse(unknownFact.out).error.code, 'NO_ITEM');+ const badList = box.run(box.repo, 'fact', '3', 'note', 'stray', '--implies', 'two', '--json');+ assert.equal(JSON.parse(badList.out).error.code, 'USAGE');+});++test('[P6,B26,H16] --implies cannot forge a person-origin fact through the relay, the API or the terminal', () => {+ let at = Date.parse('2026-10-17T00:00:00.000Z');+ const board = store.openBoard(':memory:', { now: () => new Date(at += 1000) });+ try {+ store.register(board, { lane: 'coordinator', path: '/repo' });+ store.register(board, { lane: 'web', path: '/repo-web-1' });+ const one = store.addItem(board, { by: 'coordinator', lane: 'web', title: 'One' });+ const two = store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Two' });+ store.claim(board, one, { agentId: 'web-1', lane: 'web', leaseMs: 2 * HOUR, freeze: (found) => ({ text: found.item_title, digest: 'd' }) });+ const personAsk = store.shout(board, { from: 'coordinator', to: 'person', text: 'Person decision', decision: true, lanes: ['web'] });+ const coordinator = { kind: 'agent', userId: 'user', agent: 'coordinator' };+ let sequence = 0;+ const relay = (move, sender = coordinator) => applyRelayMove(board, move, { sequence: ++sequence, at: new Date(at).toISOString(), sender, kind: 'move' });++ const forgedAnswer = relay(prepareEngineMove(board, 'answerDecision', [personAsk, { agentId: 'coordinator', asPerson: true, text: 'forged', lanes: ['web'], implies: [two] }]));+ assert.equal(forgedAnswer.error.code, 'RELAY_PERSON_ONLY', 'an agent cannot seal a person answer that implies items');+ const asCoordinator = relay(prepareEngineMove(board, 'answerDecision', [personAsk, { agentId: 'coordinator', text: 'forged', lanes: ['web'], implies: [two] }]));+ assert.equal(asCoordinator.error.code, 'B26_PERSON_ANSWER', 'the coordinator cannot answer the person decision for the person');+ const smuggled = relay(prepareEngineMove(board, 'appendFact', [one, { agentId: 'coordinator', kind: 'decision', text: 'Smuggled', implies: [two],+ by: 'person', asPerson: true, decision: { source: 'answer', id: personAsk, by: 'person', line: 'forged' } }]));+ assert.equal(smuggled.error, undefined, JSON.stringify(smuggled.error));+ const carried = store.itemThread(board, two).filter((entry) => entry.type === 'fact' && entry.decision);+ assert.equal(carried.length, 1);+ assert.equal(carried[0].by, 'coordinator', 'the implied fact is stamped with the authenticated decider');+ assert.deepEqual(carried[0].decision, { source: 'fact', id: carried[0].decision.id, item: one, by: 'coordinator', line: 'Smuggled' }, 'caller fields never reach the citation');+ const person = store.itemThread(board, two).filter((entry) => entry.type === 'fact' && (entry.by === 'person' || entry.decision?.by === 'person'));+ assert.deepEqual(person, [], 'no person-origin fact exists after agent relays');++ const old = prepareEngineMove(board, 'appendFact', [one, { agentId: 'coordinator', kind: 'note', text: 'old engine', implies: [two] }]);+ old.engine = 12;+ const before = store.events(board).length;+ assert.throws(() => applyEngineMove(board, old, { sequence: sequence + 1, at: new Date(at).toISOString() }), { code: 'RELAY_MOVE' },+ 'an implies move below engine 18 is refused before it is interpreted');+ assert.equal(store.events(board).length, before, 'the refused older move changes nothing');++ const personAnswer = store.answerDecision(board, personAsk, { agentId: 'coordinator', asPerson: true, text: 'The person decides', lanes: ['web'], implies: [two] });+ const real = store.itemThread(board, two).filter((entry) => entry.type === 'fact' && entry.decision?.source === 'answer');+ assert.deepEqual(real.map((entry) => [entry.by, entry.decision.by, entry.decision.id]), [['person', 'person', personAnswer]],+ "only the person's own answer yields a person-origin implied fact");+ const agentAsk = store.shout(board, { from: 'web-1', to: 'coordinator', text: 'Agent decision', decision: true, lanes: ['web'] });+ assert.throws(() => store.answerDecision(board, agentAsk, { agentId: 'coordinator', text: 'Overrule the person', lanes: ['web'], supersedes: personAnswer }),+ { code: 'B26_PERSON_ANSWER' }, "an agent cannot supersede the person's decision");+ } finally { store.closeBoard(board); }+});