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
fix(team): preserve grant replay and refusal contracts [E21,H16,M1]
Corey Olsonaf34d7062402
diff --git a/docs/formats.md b/docs/formats.mdindex 30e0ae3f..e008267e 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -406,10 +406,12 @@ Each connection also has a temporary `moving(token INTEGER)` table and `status_tThe `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its append-only record format has the independent `EVENT_LOG_VERSION`. Each event has an increasing integer id, an ISO timestamp, the actor, the event kind, an optional item id, and a JSON object in `event_detail`. Board moves append their event inside the same immediate transaction as the move. Events are append-only; board triggers reject updates and deletes. The actor column is the acting agent id, except guard-repair events, which use `board`. Under engine 8 and later, each event by a registered agent also carries a `model` string snapshot in `event_detail`; legacy agents without a declaration use `unknown`. Declared models live under `agent_model:<agent id>` in `board_meta`, without changing the agent table or stable ids. Rejoining with another model appends a `model` event whose common snapshot holds the new declaration. This common snapshot is separate from the per-kind payload fields listed below. The following rows name the emitted kinds and the union of their operation-specific detail keys; CLI accept events additionally carry the frozen-check result described below:+The computed-grant engine adds `grantEngine` to new join, claim and renewal events as a version marker only. It stores no grant or scope: permission is computed from the seat lane, current claim and lease, or the current review reservation. Older event bytes remain unchanged. A new marker prevents an older engine from reinterpreting a narrowed claim; communication and review administration keep their existing engine floors.+<!-- events:start -->| Kind | Actor | Detail fields || --- | --- | --- |-| `join` | joining agent | `lane`, `route` |+| `join` | joining agent | `lane`, `route`, optional `grantEngine` || `family` | agent | `family` || `model` | agent | — || `moved` | coordinator | `path` |@@ -418,8 +420,8 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `escalate` | builder | `from`, `to`, `note`, `attempt` || `attempt` | reporting agent | `n`, `seconds`, `result` || `fact` | author | `id`, `kind`, `text`, `ref`, `supersedes`, engine-20 `implies`, `decision`, `supersededBy`, engine-30 `cause`, `neverAgain`, `channel` |-| `claim` | builder | `leaseUntil`, `digest` |-| `renew` | builder | `leaseUntil`, `digest` |+| `claim` | builder | `leaseUntil`, `digest`, optional `grantEngine` |+| `renew` | builder | `leaseUntil`, `digest`, optional `grantEngine` || `release` | builder | — || `submit` | builder | `commit`, `tree`, `policyCommit`, engine-9 `criterionDigest`, engine-38 `submissionProof` || `reserve` | reviewer | `until` |diff --git a/docs/lifecycle.md b/docs/lifecycle.mdindex e1207fab..d66e0f45 100644--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@ -59,10 +59,10 @@ Each move checks its guards in this order and refuses with the first one that do| claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), checkProvesSomething (CRITERION_PROVES_NOTHING), barReady (BAR_NOT_READY), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE or OUTSIDE_NATIVE_BUILD), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), builderFirstRefusal (REOPEN_HELD_FOR_BUILDER), correctionRefrozen (PENDING_REFREEZE), laneOpen (LANE_HELD), lineCapacity (LINE_WIP_LIMIT or LINE_SETTING_RANGE), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN or AGENT_APPROVAL_REQUIRED or BAR_NOT_READY) || release | open, claimed | open | agent, coordinator | joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_YOURS), releaseOwnsWork (NOT_YOURS), reviewReleaseExplained (NOTE_REQUIRED) || lapse | claimed | open | clock, when its lease runs out | none |-| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS or OUTSIDE_NATIVE_BUILD), correctionRefrozen (PENDING_REFREEZE), checkProvesSomething (CRITERION_PROVES_NOTHING), barReady (BAR_NOT_READY), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT or HOST_NAME), 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), trunkInCandidate (MAIN_NOT_COMPOSED), noUnverifiedStack (STACKED_ON_UNVERIFIED), infraExplained (INFRA_NOTE_REQUIRED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), gateGreen (GATE_RED or RUNNER_GUI_SESSION_REQUIRED or LAND_TIMEOUT_CUSTODY or LAND_GATE_OUTPUT or SLOT_DB_LOCKED or TIMING_SLOT_REQUIRED or RUNNER_BROWSER_SLOT_REQUIRED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), submissionProofValid (SUBMISSION_PROOF), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |+| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS or OUTSIDE_NATIVE_BUILD), correctionRefrozen (PENDING_REFREEZE), checkProvesSomething (CRITERION_PROVES_NOTHING), barReady (BAR_NOT_READY), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT or HOST_NAME), 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), trunkInCandidate (MAIN_NOT_COMPOSED), noUnverifiedStack (STACKED_ON_UNVERIFIED), infraExplained (INFRA_NOTE_REQUIRED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), gateGreen (GATE_RED or RUNNER_GUI_SESSION_REQUIRED or LAND_TIMEOUT_CUSTODY or LAND_GATE_OUTPUT or SLOT_DB_LOCKED or TIMING_SLOT_REQUIRED or RUNNER_BROWSER_SLOT_REQUIRED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), submissionProofValid (SUBMISSION_PROOF), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW), result (AGENT_GRANT_EXPIRED), result (AGENT_GRANT_ITEM), result (AGENT_GRANT_LANE) || reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), roadmapReadable (MILESTONES_CORRUPT or LINE_SETTING_RANGE), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) |-| accept | submitted, verified | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_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), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), itemCheckGreen (CHECK_RED or RUNNER_GUI_SESSION_REQUIRED or SANDBOX_PROVIDER_REQUIRED or SANDBOX_IMAGE_REQUIRED or SANDBOX_RUNTIME or SANDBOX_EXPORT or SANDBOX_EXECUTION or SANDBOX_CLEANUP_REQUIRED or SANDBOX_CHECK_REQUIRED or CHECK_NO_PROOF or OUTSIDE_SANDBOX_REQUIRED or SLOT_DB_LOCKED or TIMING_SLOT_REQUIRED or CHECK_UNVERIFIED or GUARD_CANNOT_FAIL or GUARD_NOT_FOUND), proofNoted (PROOF_REQUIRED), result (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION) |-| reject | submitted, verified | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_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 (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION), result (NOT_YOURS), result (CLOSED) |+| accept | submitted, verified | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_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), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), itemCheckGreen (CHECK_RED or RUNNER_GUI_SESSION_REQUIRED or SANDBOX_PROVIDER_REQUIRED or SANDBOX_IMAGE_REQUIRED or SANDBOX_RUNTIME or SANDBOX_EXPORT or SANDBOX_EXECUTION or SANDBOX_CLEANUP_REQUIRED or SANDBOX_CHECK_REQUIRED or CHECK_NO_PROOF or OUTSIDE_SANDBOX_REQUIRED or SLOT_DB_LOCKED or TIMING_SLOT_REQUIRED or CHECK_UNVERIFIED or GUARD_CANNOT_FAIL or GUARD_NOT_FOUND), proofNoted (PROOF_REQUIRED), result (AGENT_GRANT_EXPIRED), result (AGENT_GRANT_ITEM), result (AGENT_GRANT_LANE), result (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION) |+| reject | submitted, verified | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_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 (AGENT_GRANT_EXPIRED), result (AGENT_GRANT_ITEM), result (AGENT_GRANT_LANE), result (VERDICT_ENVIRONMENT), result (LAND_HEADER), result (ENGINE_VERSION), result (NOT_YOURS), result (CLOSED) || reopen | submitted, verified | open | agent, coordinator | joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reopenAuthority (COORDINATOR_ONLY or VERDICT_WITHDRAW_FORBIDDEN or VERDICT_WITHDRAW_STATE), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED), trunkConflicts (NOT_CONFLICTING or CONFLICT_FILES or NO_TRUNK or MERGE_CHECK_FAILED), conflictAccepted (NOT_ACCEPTED or BAD_CONFLICT or ENGINE_VERSION), result (BAD_VERDICT_WITHDRAW), result (ENGINE_VERSION), result (BAD_CONFIG) || escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED or AGENT_REPLACED or SESSION_LEDGER), 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 or AGENT_REPLACED or SESSION_LEDGER), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), barReady (BAR_NOT_READY), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN or AGENT_APPROVAL_REQUIRED or BAR_NOT_READY) |@@ -213,9 +213,18 @@ Each move checks its guards in this order and refuses with the first one that do| NOT_ACCEPTED | a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 52 or later, only for reopen --conflict | reopen a submission with --note "why" || BAD_CONFLICT | a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 52 or later, only for reopen --conflict | run pullboard reopen <id> --conflict <file> from the main checkout || ENGINE_VERSION | a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 52 or later, only for reopen --conflict | upgrade Pullboard on every linked device before using --conflict |+| AGENT_GRANT_EXPIRED | an item mutation has a live claim or review grant (submit result) | claim the intended item, or shout the coordinator if its claim is unavailable |+| AGENT_GRANT_ITEM | an item mutation belongs to the current claim or review grant (submit result) | finish or release the claim, then claim the intended item; use shout for coordination |+| AGENT_GRANT_LANE | an item mutation stays inside the unclaimed seat lane (submit result) | join a seat in the intended lane or ask its owner to make the item change |+| AGENT_GRANT_EXPIRED | an item mutation has a live claim or review grant (accept result) | claim the intended item, or shout the coordinator if its claim is unavailable |+| AGENT_GRANT_ITEM | an item mutation belongs to the current claim or review grant (accept result) | finish or release the claim, then claim the intended item; use shout for coordination |+| AGENT_GRANT_LANE | an item mutation stays inside the unclaimed seat lane (accept result) | join a seat in the intended lane or ask its owner to make the item change || VERDICT_ENVIRONMENT | optional recorded verdict environment contains exact platform, architecture and Node version (accept result) | run the frozen check with current Pullboard, then have an independent reviewer record a fresh verdict with its actual executor environment || 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 20 or later (accept result) | upgrade Pullboard on every linked device before using --implies |+| AGENT_GRANT_EXPIRED | an item mutation has a live claim or review grant (reject result) | claim the intended item, or shout the coordinator if its claim is unavailable |+| AGENT_GRANT_ITEM | an item mutation belongs to the current claim or review grant (reject result) | finish or release the claim, then claim the intended item; use shout for coordination |+| AGENT_GRANT_LANE | an item mutation stays inside the unclaimed seat lane (reject result) | join a seat in the intended lane or ask its owner to make the item change || VERDICT_ENVIRONMENT | optional recorded verdict environment contains exact platform, architecture and Node version (reject result) | run the frozen check with current Pullboard, then have an independent reviewer record a fresh verdict with its actual executor environment || 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 20 or later (reject result) | upgrade Pullboard on every linked device before using --implies |diff --git a/src/agent-grant.js b/src/agent-grant.jsindex 37ceb360..dac91ff6 100644--- a/src/agent-grant.js+++ b/src/agent-grant.js@@ -14,12 +14,17 @@ function target(move) {/** A version marker is not a grant: it only prevents an older engine bypassing a new seat or claim. */export function agentGrantMinimum(board, move) {+ // Communication and review administration neither widen nor replace a claim. An old claim could erase its version marker.+ if (move.operation !== 'claim' && (ADMINISTRATIVE.has(move.operation) || !target(move))) return 1;const actor = MOVE_REGISTRY[move.operation]?.actor(move);if (typeof actor !== 'string' || ['person', 'coordinator', 'machine'].includes(actor)) return 1;const event = board.db.prepare("SELECT event_detail FROM event WHERE event_by=? AND event_kind IN ('join','claim','renew') ORDER BY event_id DESC LIMIT 1").get(actor);- if (!event) return 1;- const version = JSON.parse(event.event_detail).grantEngine;- return Number.isSafeInteger(version) && version >= AGENT_GRANT_ENGINE ? AGENT_GRANT_ENGINE : 1;+ const item = target(move)?.item ?? (move.operation === 'claim' ? move.args?.[0] : null);+ const claimed = Number.isSafeInteger(item) ? board.db.prepare("SELECT event_detail FROM event WHERE item_id=? AND event_kind IN ('claim','renew') ORDER BY event_id DESC LIMIT 1").get(item) : null;+ return [event, claimed].some(row => {+ const version = row && JSON.parse(row.event_detail).grantEngine;+ return Number.isSafeInteger(version) && version >= AGENT_GRANT_ENGINE;+ }) ? AGENT_GRANT_ENGINE : 1;}/** Refuse out-of-grant item changes at the same ordered instant on every replica. */diff --git a/src/machine.js b/src/machine.jsindex eda2c875..7bcd6771 100644--- a/src/machine.js+++ b/src/machine.js@@ -158,6 +158,13 @@ export const GUARDS = [{ id: 'conflictAccepted', refuse: 'NOT_ACCEPTED', alsoRefuses: [{ code: 'BAD_CONFLICT', next: 'run pullboard reopen <id> --conflict <file> from the main checkout' }, { code: 'ENGINE_VERSION', next: 'upgrade Pullboard on every linked device before using --conflict' }], rule: 'a trunk conflict reopens an accepted item, names its files and the full trunk commit, and replays only under engine 52 or later', next: 'reopen a submission with --note "why"', source: 'board', when: 'only for reopen --conflict' },];+/** Shared named item-grant refusals reachable through native dispatch. */+const AGENT_GRANT_REFUSALS = [+ { code: 'AGENT_GRANT_EXPIRED', rule: 'an item mutation has a live claim or review grant', next: 'claim the intended item, or shout the coordinator if its claim is unavailable' },+ { code: 'AGENT_GRANT_ITEM', rule: 'an item mutation belongs to the current claim or review grant', next: 'finish or release the claim, then claim the intended item; use shout for coordination' },+ { code: 'AGENT_GRANT_LANE', rule: 'an item mutation stays inside the unclaimed seat lane', next: 'join a seat in the intended lane or ask its owner to make the item change' },+];+/** @type {Move[]} */export const MOVES = [{ verb: 'intake', from: ['open'], to: 'submitted', by: ['agent', 'coordinator'], refuse: 'NOT_CLAIMABLE',@@ -175,6 +182,7 @@ export const MOVES = [{verb: 'submit', from: ['claimed'], to: 'submitted', by: ['agent', 'coordinator'], refuse: 'NOT_YOURS',guards: ['joined', 'itemExists', IN_STATE, 'isHolder', 'correctionRefrozen', 'checkProvesSomething', 'barReady', 'criterionUnchanged', 'treeClean', 'nothingUntracked', 'hasCommit', 'withinLane', 'trunkMergeClean', 'trunkInCandidate', 'noUnverifiedStack', 'infraExplained', 'doctrineHolds', 'gateConfigured', 'queuedItemLease', 'gateGreen', 'treeStillDuringGate', 'submissionProofValid', 'childrenDone', 'headIsNew'],+ alsoRefuses: AGENT_GRANT_REFUSALS,sets: ['item_built_by', 'item_commit'], command: 'pullboard submit <id>',},{@@ -185,13 +193,13 @@ export const MOVES = [{verb: 'accept', from: ['submitted', 'verified'], to: 'verified', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notMerged', 'verdictReviewRecorded', 'reviewTreeCurrent', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonIsMet', 'trunkMergeClean', 'noUnverifiedStack', 'queuedItemLease', 'itemCheckGreen', 'proofNoted'],- alsoRefuses: [{ code: 'VERDICT_ENVIRONMENT', rule: 'optional recorded verdict environment contains exact platform, architecture and Node version', next: 'run the frozen check with current Pullboard, then have an independent reviewer record a fresh verdict with its actual executor environment' }, { 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' }],+ alsoRefuses: [...AGENT_GRANT_REFUSALS, { code: 'VERDICT_ENVIRONMENT', rule: 'optional recorded verdict environment contains exact platform, architecture and Node version', next: 'run the frozen check with current Pullboard, then have an independent reviewer record a fresh verdict with its actual executor environment' }, { 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' }],sets: ['item_verified_by'], command: 'pullboard verify <id> accept --note "..."',},{verb: 'reject', from: ['submitted', 'verified'], to: 'open', by: ['agent', 'coordinator'], refuse: 'NOT_SUBMITTED',guards: ['coordinatorSaysAs', 'joined', 'itemExists', IN_STATE, 'atSubmittedCommit', 'notMerged', 'verdictReviewRecorded', 'reviewTreeCurrent', 'notBuilder', 'routeAllows', 'policyAllows', 'familyAllows', 'reviewFree', 'criterionUnchanged', 'reasonCoded', 'noteGiven', 'causeWellFormed'],- alsoRefuses: [{ code: 'VERDICT_ENVIRONMENT', rule: 'optional recorded verdict environment contains exact platform, architecture and Node version', next: 'run the frozen check with current Pullboard, then have an independent reviewer record a fresh verdict with its actual executor environment' }, { 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' }, { code: 'NOT_YOURS', rule: 'the automatic escalation is authorized as the coordinator or item holder', next: 'ask the coordinator to inspect the item and its route' }, { code: 'CLOSED', rule: 'the rejected item remains open or claimed when automatic escalation starts', next: 'pullboard show <id>, then ask the coordinator to inspect its current state' }],+ alsoRefuses: [...AGENT_GRANT_REFUSALS, { code: 'VERDICT_ENVIRONMENT', rule: 'optional recorded verdict environment contains exact platform, architecture and Node version', next: 'run the frozen check with current Pullboard, then have an independent reviewer record a fresh verdict with its actual executor environment' }, { 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' }, { code: 'NOT_YOURS', rule: 'the automatic escalation is authorized as the coordinator or item holder', next: 'ask the coordinator to inspect the item and its route' }, { code: 'CLOSED', rule: 'the rejected item remains open or claimed when automatic escalation starts', next: 'pullboard show <id>, then ask the coordinator to inspect its current state' }],command: 'pullboard verify <id> reject --reason CODE --note "..."',},{diff --git a/test/agent-model-engine.test.js b/test/agent-model-engine.test.jsindex c4476112..d06ed772 100644--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@ -1,3 +1,4 @@+import { AGENT_GRANT_ENGINE } from '../src/agent-grant-engine.js';/** Declared models replay with their recorded engine and survive board exchange [O8,O3,H16]. */import assert from 'node:assert/strict';import { test } from 'node:test';@@ -47,8 +48,9 @@ test('model declarations and event snapshots retain all supported engine semantiassert.equal(first.error, undefined);assert.equal(first.result, 'web-1');assert.equal(store.agentAt(board, '/web').agent_model, version < 8 ? null : 'First Model');- assert.deepEqual(JSON.parse(first.events[0].event_detail), version < 8- ? { lane: 'web' } : { lane: 'web', model: 'First Model' });+ const joinedDetail = version < 8 ? { lane: 'web' } : { lane: 'web', model: 'First Model',+ ...(version >= AGENT_GRANT_ENGINE ? { grantEngine: AGENT_GRANT_ENGINE } : {}) };+ assert.deepEqual(JSON.parse(first.events[0].event_detail), joinedDetail);const update = prepareEngineMove(board, 'register', [{ lane: 'web', path: '/web', model: 'Second Model' }]);const changed = applyEngineMove(board, { ...update, engine: version }, { sequence: 2, at: '2026-10-10T07:01:00Z' });@@ -59,7 +61,7 @@ test('model declarations and event snapshots retain all supported engine semantiif (version >= 8) {assert.equal(changed.events[0].event_kind, 'model');assert.deepEqual(JSON.parse(changed.events[0].event_detail), { model: 'Second Model' });- assert.deepEqual(JSON.parse(store.events(board)[0].event_detail), { lane: 'web', model: 'First Model' },+ assert.deepEqual(JSON.parse(store.events(board)[0].event_detail), joinedDetail,'later model changes never rewrite an earlier move snapshot');}}diff --git a/test/engine.test.js b/test/engine.test.jsindex 3f0674a1..909bd480 100644--- a/test/engine.test.js+++ b/test/engine.test.js@@ -20,14 +20,17 @@ const HOUR = 3_600_000;const CLAIM_AT = '2026-10-07T18:00:00.000Z';/** Open two independent SQLite copies of the same registered board and one available item. */-function engineCopies(t, initialize = () => {}) {+function engineCopies(t, initialize = () => {}, seedEngine = ENGINE_VERSION) {const directory = mkdtempSync(join(tmpdir(), 'pullboard-engine-'));const source = store.openBoard(join(directory, 'source.sqlite'));+ // A historical move needs the actual historical join prefix, not a current writer's activated grant.+ source.executionEngineVersion = seedEngine;store.register(source, { lane: 'coordinator', path: '/source' });store.register(source, { lane: 'web', path: '/source/web-1' });store.register(source, { lane: 'web', path: '/source/web-2' });const item = store.addItem(source, { by: 'coordinator', lane: 'web', title: 'Engine fixture' });initialize(source);+ delete source.executionEngineVersion;const document = exportBoard(source);const copies = ['one', 'two'].map((name, index) => {const clock = { now: () => new Date(`2026-10-07T${index + 16}:00:00.000Z`) };@@ -628,7 +631,7 @@ test('a failed durable receipt rolls back an otherwise successful move and its c});test('engine 65 keeps an ordinary claim available without a return window [B13,H16]', t => {- const { copies: [board], item } = engineCopies(t);+ const { copies: [board], item } = engineCopies(t, undefined, 65);const move = { ...claimMove(board, item, 'web-2'), engine: 65 };const result = applyEngineMove(board, move, { sequence: 1, at: CLAIM_AT });assert.equal(result.error, undefined);@@ -644,7 +647,7 @@ test('return-window engine admission uses the receipt time rather than replica csubmitFixture(board, id, { agentId: 'web-1', commit: 'a'.repeat(40), tree: 'a'.repeat(40) });store.verify(board, id, { agentId: 'web-2', decision: 'REJECT', reason: 'OTHER', note: 'proof',head: 'a'.repeat(40), digest: 'f'.repeat(64), policy: 'any', reopenFirstRefusalMinutes: 30 });- });+ }, 66);const before = boardRows(expiredClock, item);const old = { ...claimMove(expiredClock, item, 'web-2'), engine: 65 };assert.throws(() => applyEngineMove(expiredClock, old, { sequence: 1, at: '2026-10-07T16:05:00.000Z' }), /engine/);diff --git a/test/move-registry.test.js b/test/move-registry.test.jsindex ac717615..0e1e0169 100644--- a/test/move-registry.test.js+++ b/test/move-registry.test.js@@ -1,3 +1,4 @@+import { ENGINE_VERSION } from '../src/machine.js';/** @pullboard-test-input source-tree *//** @pullboard-test-input test-tree *//** @pullboard-test-loads src/move-registry.js src/moves/*.js */@@ -59,7 +60,11 @@ test('today\'s move order, actors, recovery text and recorded SQLite prefix areassert.deepEqual(applyEngineMove(board, move, options), outcome, move.operation);assert.deepEqual(applyEngineMove(board, move, options), outcome, 'same-position retry returns its immutable receipt');}- assert.equal(JSON.stringify(exportBoard(board)), JSON.stringify(SNAPSHOT.replay.acceptedExpected), 'items, events, receipts and replay cursor retain accepted-main bytes for the exact historical moves');+ const expected = structuredClone(SNAPSHOT.replay.acceptedExpected);+ // This tag describes the current reader/writer capability, not the engine of an immutable old receipt.+ const capability = expected.tables.board_meta.find(row => row.meta_key === 'relay_engine_version');+ capability.meta_value = String(ENGINE_VERSION);+ assert.equal(JSON.stringify(exportBoard(board)), JSON.stringify(expected), 'items, events, receipts and cursor retain accepted-main bytes; only the explicit current-engine capability tag advances');});test('two new board moves declared in two files need no edit to engine.js, relay-sender.js or next-step-words.js [C7,V4,H3,H16]', t => {diff --git a/test/relay-client-fixture.js b/test/relay-client-fixture.jsindex 3ad91818..8583540d 100644--- a/test/relay-client-fixture.js+++ b/test/relay-client-fixture.js@@ -723,7 +723,10 @@ globalThis.fetch = function tracedFetch(input, init) {assert.equal((await childResult(otherRoot, initEnv, [CLI, 'init', '--json'])).code, 0, 'the cloned project initializes its private local board');const joined = await run('relay', 'join', code, '--url', origin);const document = joined.document;- if (joined.code !== 0) throw new Error('real clone did not join the one-use pairing code');+ if (joined.code !== 0) {+ const refusal = document?.error?.code;+ throw new Error(`real clone did not join the one-use pairing code (${typeof refusal === 'string' && /^[A-Z0-9_]+$/u.test(refusal) ? refusal : 'NO_TYPED_REFUSAL'})`);+ }const exported = await run('export');if (exported.code !== 0) throw new Error('paired clone could not read its restored board');const link = JSON.parse(readFileSync(join(otherRoot, '.git', 'pullboard', 'relay.json'), 'utf8'));diff --git a/test/team.test.js b/test/team.test.jsindex 90caafff..1a18a539 100644--- a/test/team.test.js+++ b/test/team.test.js@@ -915,7 +915,7 @@ test('an agent grant narrows at claim and expires identically on independent repassert.equal(fact(1, 'The expired lease no longer authorizes a move', expired).error?.code,'AGENT_GRANT_EXPIRED', 'ordered receipt time, not the receiving machine clock, ends the grant');// Administrative communication and release cannot be trapped behind the grant being reported.- assert.equal(replay('shout', [{ from: actor, to: 'coordinator', text: 'My claim expired; arranging the next work.' }], expired).error,+ assert.equal(replay('shout', [{ from: actor, to: 'coordinator', text: 'My claim expired; arranging the next work.', lanes: ['web', 'api'] }], expired).error,undefined, 'ordinary coordination remains available after expiry');assert.equal(replay('release', [1, actor, 'Done with this claim.'], expired).error, undefined);assert.equal(fact(1, 'Release does not revive an expired grant', expired).error?.code, 'AGENT_GRANT_EXPIRED',@@ -944,6 +944,7 @@ test('an agent grant narrows at claim without changing old receipts or permittin};apply('register', [{ lane: 'coordinator', path: box.repo, model: 'fixture-model' }]);const actor = apply('register', [{ lane: 'web', path: box.web, model: 'fixture-model' }]).outcome.result;+ const other = apply('register', [{ lane: 'web', path: join(box.dir, 'legacy-other-seat'), model: 'fixture-model' }]).outcome.result;for (const title of ['First', 'Second']) apply('addItem', [{ by: 'coordinator', lane: 'web', title,criterion: 'A real file must exist', specIds: [], check: 'test -f grant-proof' }]);/** Freeze an actual private Git revision; replicas receive only the canonical frozen value. */@@ -957,6 +958,8 @@ test('an agent grant narrows at claim without changing old receipts or permittinconst prior = apply('appendFact', [2, { agentId: actor, kind: 'note', text: 'Legacy behavior stays recorded.' }]);const forged = prepareEngineMove(boards[0], 'appendFact', [2, { agentId: actor, kind: 'note', text: 'Old engine cannot bypass the new claim.' }]);forged.engine = legacy;+ const oldPeer = prepareEngineMove(boards[0], 'appendFact', [1, { agentId: other, kind: 'note', text: 'Another old seat must understand the new item grant.' }]);+ oldPeer.engine = legacy;apply('claim', [1, options], AGENT_GRANT_ENGINE);for (const board of boards) {const before = store.itemThread(board, 2);@@ -965,6 +968,9 @@ test('an agent grant narrows at claim without changing old receipts or permittinassert.throws(() => applyEngineMove(board, forged, { sequence: appliedSequence(board) + 1, at: clock.now().toISOString() }),error => error.code === 'RELAY_MOVE' && error.message.includes(String(AGENT_GRANT_ENGINE)),'a freshly sealed old-engine move cannot bypass new-claim authority');+ assert.throws(() => applyEngineMove(board, oldPeer, { sequence: appliedSequence(board) + 1, at: clock.now().toISOString() }),+ error => error.code === 'RELAY_MOVE' && error.message.includes(String(AGENT_GRANT_ENGINE)),+ 'another legacy seat cannot interpret a newly claimed item under old grant semantics');assert.deepEqual(store.itemThread(board, 2), before, 'neither old receipt replay nor a forged old move adds a fact');}});