Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

chore(merge): integrate relay seat standing [H2,V1]

Corey Olsond683eef6a203
diff --cc docs/formats.md
index 6c0b222a,df5ecd04..4ef2640c
--- a/docs/formats.md
+++ b/docs/formats.md
@@@ -113,7 -113,7 +113,7 @@@ The board file is in the repository's G
| `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` | `27` | `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` | `30` | `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` | `35` | `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.
@@@ -128,11 -128,13 +128,15 @@@ Engine 19 makes a corrected bar record
Engine 20 lets a decision name the items it changes. An `appendFact`, `answerDecision` or `verify` move may carry `implies`, a list of existing item ids, and an `answerDecision` move may carry `supersedes`, the shout id of an earlier answer. Either makes the move an engine-20 move: an older engine refuses it with `RELAY_MOVE` before changing its board or cursor, and a board replaying an older engine refuses `implies` with `ENGINE_VERSION`. Engine 20 also tells implied items when a decision is superseded: by a fact's `supersedes`, by an answer's `supersedes`, or by the next verdict on the same item. Moves recorded under engines 19 and earlier replay without these notices. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.
- Engine 27 records on each new seat the seat that created it (`createdBy`: an agent id, or `machine` for a join no seat made), lets a creator name the new seat (`id`), and applies verifier standing to relay-replayed verdicts, review reservations and offers on a linked board: the verifier's line of creating seats must reach the coordinator through seats enrolled by the relay, without the builder or a machine join. Replicas apply a register move by another seat only with the relay's receipt for its target, creator, position and digest. The relay stamps every record it stores with `policy: 27`; a stamped move below engine 27 is refused. Engine-12 and older moves, and unstamped records, replay as they did. On an unlinked board who may verify is unchanged.
+ Engine 24 adds the person's `acceptCheck`: an item's current check, named by its SHA-256 digest, accepted so a check already green on main no longer holds the item on a board whose `checks.provesNothing` is `"hold"`. Only the person may send it, from the terminal or the view; the relay refuses it from an agent or a machine. A move from an older engine is refused before it changes the board or replay cursor, and older clients refuse engine-24 moves before interpreting them. Engines 21 through 23 are allocated to other changes.
+
+ Engine 30 lets a reject and a reopen carry a cause key (`cause`: `test:<file>::<title>`, `refusal:<CODE>`, `row:<id>` or `doctrine:<id>`) and lets the person record a never-again fact with `cause` and `neverAgain: true`, for `pullboard rigor`. Only a move that carries one of these needs engine 30; engine-29 and older moves replay unchanged, and clients on an older engine refuse an engine-30 move with `RELAY_MOVE` before changing their board or cursor. Engine 20 is the implied-items engine above; engine numbers 21 through 29 are allocated to other changes.
+
++Engine 35 records on each new seat the seat that created it (`createdBy`: an agent id, or `machine` for a join no seat made), lets a creator name the new seat (`id`), and applies verifier standing to relay-replayed verdicts, review reservations and offers on a linked board: the verifier's line of creating seats must reach the coordinator through seats enrolled by the relay, without the builder or a machine join. Replicas apply a register move by another seat only with the relay's receipt for its target, creator, position and digest. The relay stamps every record it stores with `policy: 35`; a stamped move below engine 35 is refused. Engine-12 and older moves, and unstamped records, replay as they did. On an unlinked board who may verify is unchanged.
+
The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.
- A linked board requires at least engine 27 after issuing any agent token or machine credential, including
- revoked or expired ones; before engine 27 these minimums were 3 and 6. The minimum survives reopening the auth database;
-A linked board requires at least engine 3 after issuing any agent token, including
-revoked or expired tokens. Issuing any machine credential raises that board’s minimum to engine 6, including after revocation or expiry. The minimum survives reopening the auth database;
++A linked board requires at least engine 35 after issuing any agent token or machine credential, including
++revoked or expired ones; before engine 35 these minimums were 3 and 6. The minimum survives reopening the auth database;
unlink removes the board and ends its lifetime. A missing declaration is legacy
engine 1. Board-content requests below their minimum, and malformed declarations,
receive `ENGINE_VERSION` with upgrade guidance before records are returned or
diff --cc docs/lifecycle.md
index 20076d51,12fe1ac1..e50540d1
--- a/docs/lifecycle.md
+++ b/docs/lifecycle.md
@@@ -51,14 -51,14 +51,14 @@@ Each move checks its guards in this ord
| Move | From | To | Who | Guards, in order; result refusals |
| --- | --- | --- | --- | --- |
- | claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), correctionRefrozen (PENDING_REFREEZE), laneOpen (LANE_HELD), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
+ | claim | open, claimed | claimed | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_CLAIMABLE), checkProvesSomething (CRITERION_PROVES_NOTHING), itemNotHeld (ITEM_HELD), inLane (WRONG_LANE), routeAllows (ROUTE), dependenciesVerified (BLOCKED), notHeldByAnother (HELD), correctionRefrozen (PENDING_REFREEZE), laneOpen (LANE_HELD), oneLiveClaim (ONE_CLAIM), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
| release | claimed | open | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), reviewReleaseExplained (NOTE_REQUIRED) |
| 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) |
+ | submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), checkProvesSomething (CRITERION_PROVES_NOTHING), 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), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), 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), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), 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), causeWellFormed (BAD_CAUSE), result (LAND_HEADER), result (ENGINE_VERSION) |
+| 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 or VERIFIER_STANDING), 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 or VERIFIER_STANDING), 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 or VERIFIER_STANDING), 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) |
++| 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 or VERIFIER_STANDING), 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 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 or VERIFIER_STANDING), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), result (LAND_HEADER), result (ENGINE_VERSION) |
+ | reopen | submitted, verified | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED) |
| escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED) |
| refreeze | open, claimed, submitted | open | coordinator, when there is no live claim awaiting a coordinator correction | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
| refreeze | claimed | claimed | agent, coordinator, when a live claim has a pending coordinator correction | joined (NOT_JOINED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
@@@ -134,8 -140,7 +140,8 @@@
| NO_POLICY | the caller's checkout contains the submitted commit | restore the frozen policy objects |
| BAD_CONFIG | the caller's checkout contains the submitted commit | repair the committed coordinator configuration |
| GIT_GRAFTS | the caller's checkout contains the submitted commit | ask the coordinator to remove the Git graft file before retrying |
- | SELF_VERIFY | the caller did not build it; on a linked board, at engine 27 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | another agent verifies it: pullboard next --verify |
- | VERIFIER_STANDING | the caller did not build it; on a linked board, at engine 27 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | the coordinator makes an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>" |
-| SELF_VERIFY | the caller did not build it | another agent verifies it: pullboard next --verify |
++| SELF_VERIFY | the caller did not build it; on a linked board, at engine 35 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | another agent verifies it: pullboard next --verify |
++| VERIFIER_STANDING | the caller did not build it; on a linked board, at engine 35 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | the coordinator makes an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>" |
| COORDINATOR_VERIFIES | the repo's verify policy lets the caller verify this lane's work | the coordinator verifies it |
| O2_FAMILY_MATCH | the builder and verifier have different declared families; an undeclared family counts as a match, only when verify.family is require | ask the coordinator for a verifier from another declared family |
| REVIEW_HELD | no other agent holds its review under a live lease | pullboard next --verify, which passes over reviews another agent holds |
diff --cc relay/auth.js
index eb3e8938,1172be7f..1fc5577b
--- a/relay/auth.js
+++ b/relay/auth.js
@@@ -82,10 -65,9 +82,11 @@@ export function createRelayAuth({ datab
const deviceConfirmations = new Map();
// A hashed ticket may revoke only its minted session, retained until that session expires.
const deviceSessionReceipts = new Map();
+ const sessionGuards = new Set();
let closed = false;
let locked = false;
+ // The relay journal's published seat receipts, read under the board lock (#579); none until wired.
+ let registrationClaim = () => null;
/** Refuse operation after closing instead of surfacing a raw SQLite error. */
function open() { if (closed) throw new Refused('RELAY_CLOSED', 'start the relay before signing in or using a credential'); }
@@@ -552,8 -520,7 +563,8 @@@
minimumEngineVersion(board) {
open();
identifier(board, 'BAD_BOARD');
- // Machine and agent credentials now carry engine-27 seat provenance; older clients would skip it.
- if (db.prepare("SELECT 1 FROM relay_credentials WHERE board=? AND kind='machine' LIMIT 1").get(board)) return 6;
++ // Machine and agent credentials now carry engine-35 seat provenance; older clients would skip it.
+ if (db.prepare("SELECT 1 FROM relay_credentials WHERE board=? AND kind IN ('machine','board') LIMIT 1").get(board)) return VERIFIER_STANDING_ENGINE;
return db.prepare("SELECT 1 FROM relay_credentials WHERE board=? AND kind='board' LIMIT 1").get(board) ? 3 : 1;
},
/** Give a foreground person one board-bound machine delegate, never another person credential. */
diff --cc src/board.js
index eabcc1d5,07046735..0a1181a5
--- a/src/board.js
+++ b/src/board.js
@@@ -13,16 -13,15 +13,19 @@@ import { DatabaseSync } from 'node:sqli
import { boardNotWritable } from './board-access.js';
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 { ENGINE_VERSION, GUARDS, IN_STATE, MOVES, STATES, UNKNOWN_MOVE, VERIFIER_STANDING_ENGINE, effectiveGuards, storeTriggers } from './machine.js';
import { Refused } from './refused.js';
+import { agentAt, agentModel, newSeatId, routeOf, saveAgentModel, seatLineage, standingProblem } from './seats.js';
+ import { causeProblem, requireNeverAgain } from './rigor.js';
import { barCorrectionFields } from './bar-corrections.js';
+ import { factReference } from './fact-reference.js';
import { factFromEvent, requestAnswerRefusal, tellAnswerImplications, tellFactImplications, tellVerdictImplications } from './implies.js';
import { parseSpec } from './spec.js';
+ export { acceptCheck } from './check-accept.js';
+/** The seat readers live in seats.js; the board re-exports them so `store.*` callers keep one import. */
+export { agentAt, agentCreator, listAgents, nextSeatId, seatEnrolled, seatLineage, withVerifierStanding } from './seats.js';
+
export const ACCEPT_REASON = 'CRITERION_MET';
export const PERSON = 'person';
@@@ -508,19 -537,12 +509,19 @@@ function current(board, item)
* by the agent; the board neither names nor infers it. Registering again preserves the agent id;
* explicitly supplied family and model values update their declarations, while omission preserves them.
*
- * From engine 27 a new seat records the seat that created it (`createdBy`: an agent id, or
++ * From engine 35 a new seat records the seat that created it (`createdBy`: an agent id, or
+ * `machine` for a join no seat made), so a linked board can tell a builder's own seats from
+ * independent verifiers (#579). A creator may name the new seat (`id`, the lane's next form) when
+ * the relay already issued a token for the next name; ids then skip taken names.
+ *
* @param {any} board
- * @param {{ lane: string, path: string, route?: string, family?: string | null, model?: string | null }} who
+ * @param {{ lane: string, path: string, route?: string, family?: string | null, model?: string | null, createdBy?: string, id?: string }} who
* @returns {string} The agent's id.
*/
-export function register(board, { lane, path, route = 'strong', family, model }) {
- if ((board.executionEngineVersion ?? ENGINE_VERSION) < 8) model = undefined;
+export function register(board, { lane, path, route = 'strong', family, model, createdBy, id: named }) {
+ const engine = board.executionEngineVersion ?? ENGINE_VERSION;
+ if (engine < 8) model = undefined;
+ if (engine < VERIFIER_STANDING_ENGINE) { createdBy = undefined; named = undefined; }
checkRoute(route);
if (lane === COORDINATOR && route !== 'strong') {
throw new Refused('BAD_ROUTE', 'the coordinator plans, merges and verifies; it is always strong');
diff --cc src/cli.js
index f2e4a898,0af98331..3f586ece
--- a/src/cli.js
+++ b/src/cli.js
@@@ -2701,13 -2729,19 +2735,21 @@@ async function nextOnce(ctx, values)
return await ordered(ctx, board, 'reserveNextReview', [{ agentId: me.id, lane: me.lane, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify.policy, familyPolicy: ctx.config.verify.family, runnable: values.runnable, routes: values.routes }]);
}
const warm = warmFiles(ctx, board, me);
- const { item, reasons, shared } = store.nextFor(board, { agentId: me.id, lane: me.lane, runnable: values.runnable, routes: values.routes, warm,
- priority: mainRedReworkItems(ctx.info.root, board) });
+ const seats = nextSessionSeats(ctx, board);
+ const owners = new Set(seats?.map((seat) => seat.agent_id));
+ const heldItems = seats ? store.listItems(board).filter((item) => item.item_status === 'claimed'
+ && item.item_parent_id === null && owners.has(item.item_owner)
+ && store.ROUTES.indexOf(item.item_route) <= store.ROUTES.indexOf(me.route)) : [];
+ const heldItem = heldItems.find((item) => item.item_owner === me.id) ?? heldItems[0];
+ const { item, reasons, shared } = heldItem ? { item: heldItem, reasons: [], shared: [] }
+ : store.nextFor(board, { agentId: me.id, lane: me.lane, runnable: values.runnable, routes: values.routes, warm,
+ ...(seats ? { lanes: laneNames(ctx.config).filter((lane) => lane !== COORDINATOR) } : {}),
+ priority: mainRedReworkItems(ctx.info.root, board) });
const held = item?.item_status === 'claimed';
- const offer = held ? null : store.reviewOffer(board, { agentId: me.id, lane: me.lane, policy: ctx.config.verify.policy,
+ /** Offer only reviews this seat may give; a linked board previews its engine-27 verifier standing (#579). */
+ const findOffer = () => store.reviewOffer(board, { agentId: me.id, lane: me.lane, policy: ctx.config.verify.policy,
familyPolicy: ctx.config.verify.family, ratio: ctx.config.verify.reviewRatio, runnable: values.runnable, routes: values.routes });
+ const offer = held ? null : relayLinked(ctx.info.root) ? store.withVerifierStanding(board, { root: true }, findOffer) : findOffer();
if (offer && !values.build) return { item: offer.item, offer, build: item ?? null };
if (!item) return { reasons };
const reviewSkipped = values.build && !held
diff --cc src/engine.js
index 0fb5ff69,bfdaaf96..ae046634
--- a/src/engine.js
+++ b/src/engine.js
@@@ -5,7 -4,8 +5,8 @@@ import { COORDINATOR } from './config.j
import { recordedRefusal } from './recorded-refusal.js';
import { BAR_ENGINE, carriesBarReason } from './bar-corrections.js';
import { carriesImplies, IMPLIES_ENGINE } from './implies.js';
- import { ENGINE_VERSION, VERIFIER_STANDING_ENGINE } from './machine.js';
+ import { CHECK_ACCEPT_ENGINE } from './check-accept.js';
-import { CAUSE_ENGINE, ENGINE_VERSION } from './machine.js';
++import { CAUSE_ENGINE, ENGINE_VERSION, VERIFIER_STANDING_ENGINE } from './machine.js';
import { Refused } from './refused.js';
import { requestMoveProblem, recordRequestMove } from './relay-requests.js';
import { relayMoveActor, relaySenderProblem, validRelaySender } from './relay-sender.js';
@@@ -186,50 -190,12 +191,50 @@@ export function refuseRelayMove(board,
});
}
+/**
- * Bind an engine-27 registration to the relay's receipt (#579). A seat made by another seat names
++ * Bind an engine-35 registration to the relay's receipt (#579). A seat made by another seat names
+ * itself in the move (`id`) and arrives with the receipt the relay issued its first token under:
+ * same target, the authenticated creator, this position and these exact sealed bytes. A join no
+ * seat made is machine-sent and carries no receipt; a receipt on any other move is refused.
+ *
+ * @param {any} board
+ * @param {any} move
+ * @param {{ sender: any, registration?: any, sequence: number, digest: string | null }} record
+ * @returns {Refused | null}
+ */
+function registrationProblem(board, move, { sender, registration, sequence, digest }) {
+ const refuse = (why) => new Refused('RELAY_REGISTRATION', `${why}; register the seat again from its creating seat's checkout`);
+ const options = move?.operation === 'register' && move.engine >= VERIFIER_STANDING_ENGINE ? move.args?.[0] : null;
+ if (!options || sender?.kind === 'person') return registration === undefined || registration === null ? null : refuse('the relay attached a seat receipt to a move that registers no seat');
+ const existing = typeof options.path === 'string' ? store.agentAt(board, options.path) : null;
+ if (sender.kind === 'machine' || existing) {
+ if (registration !== undefined && registration !== null) return refuse('a machine join or a returning seat carries no seat receipt');
+ if (existing && sender.kind === 'agent' && existing.agent_id !== sender.agent) return refuse(`agent ${sender.agent} cannot register another seat's worktree`);
+ return null;
+ }
+ if (options.createdBy === COORDINATOR && sender.root !== true) {
+ return refuse('only the coordinator credential the person set up creates seats; run pullboard relay on in the main checkout once');
+ }
+ const receipt = registration ?? {};
+ if (typeof options.id !== 'string' || receipt.target !== options.id || receipt.creator !== sender.agent || receipt.creator !== options.createdBy ||
+ receipt.sequence !== sequence || typeof digest !== 'string' || receipt.digest !== digest) {
+ return refuse('a new seat needs the relay receipt its creator received for exactly this sealed move');
+ }
+ return null;
+}
+
/** Authorize each public relay position before replay, retaining refusals atomically with its cursor. */
-export function applyRelayMove(board, move, { sequence, at, sender, kind, digest = null }) {
+export function applyRelayMove(board, move, { sequence, at, sender, kind, digest = null, registration }) {
requireSupportedEngine(move);
const phoneReceipt = sender?.kind === 'machine' && move?.engine >= 6 && Boolean(move.personRequest) && !requestMoveProblem(board, move, { checkExecutorLease: false });
- const problem = relaySenderProblem(move, sender, kind, { phoneReceipt });
- if (!problem) return applyEngineMove(board, move, { sequence, at });
+ const problem = relaySenderProblem(move, sender, kind, { phoneReceipt }) ?? (kind === 'move' ? registrationProblem(board, move, { sender, registration, sequence, digest }) : null);
+ if (!problem) {
+ // Engine-27 relay moves run under linked verifier standing; older recorded moves replay as they did.
+ // The person is above every seat; their own moves act with the coordinator's standing.
+ const standing = move?.engine >= VERIFIER_STANDING_ENGINE ? { root: sender?.root === true || sender?.kind === 'person',
+ person: sender?.kind === 'person', lineage: sender?.root === true && typeof sender.lineage === 'string' ? sender.lineage : null } : null;
+ return applyEngineMove(board, move, { sequence, at, standing, enrollment: registration?.target ?? null });
+ }
return refuseRelayMove(board, move, { sequence, at, sender, kind, code: problem.code, digest, refusal: problem });
}
diff --cc src/machine.js
index 0376e155,14be3e95..9c1c3af0
--- a/src/machine.js
+++ b/src/machine.js
@@@ -10,13 -10,10 +10,16 @@@
*/
/** Executable move semantics, carried by every sealed move and retained during replay [H16]. */
- export const ENGINE_VERSION = 27;
-export const ENGINE_VERSION = 30;
++export const ENGINE_VERSION = 35;
-/** The engine at which a reject, reopen or person fact can carry a cause key (#713); older moves replay unchanged [D1,H16]. */
+/**
+ * The engine whose relay moves carry seat provenance and verifier standing (#579). It is its own
+ * constant because engine slots are allotted per item: whoever lands second renumbers this line.
+ */
- export const VERIFIER_STANDING_ENGINE = 27;
++export const VERIFIER_STANDING_ENGINE = 35;
++
++/** The engine at which reject, reopen and person facts may carry cause keys [D1,H16]. */
+ export const CAUSE_ENGINE = 30;
/** @typedef {'agent' | 'coordinator' | 'clock'} Role */
@@@ -135,7 -134,7 +140,7 @@@ export const GUARDS =
{ id: 'childrenDone', refuse: 'CHILDREN_OPEN', rule: 'every child item is verified or withdrawn', next: 'finish the child items, or the coordinator withdraws them', source: 'board' },
{ id: 'headIsNew', refuse: 'HEAD_NOT_NEW', rule: 'a verifier has not rejected this commit at this bar; after a no-verdict reopen, the bar was refrozen', next: 'commit the rework, or refreeze the bar after a no-verdict reopen before resubmitting the same commit', source: 'board' },
{ id: 'atSubmittedCommit', refuse: 'NOT_AT_COMMIT', alsoRefuses: [{ code: 'OUTSIDE_LANE', next: 'restore foreign paths before accepting' }, { code: 'NO_POLICY', next: 'restore the frozen policy objects' }, { code: 'BAD_CONFIG', next: 'repair the committed coordinator configuration' }, { code: 'GIT_GRAFTS', next: 'ask the coordinator to remove the Git graft file before retrying' }], rule: "the caller's checkout contains the submitted commit", next: 'git switch --detach <commit>', source: 'cli' },
- { id: 'notBuilder', refuse: 'SELF_VERIFY', alsoRefuses: [{ code: 'VERIFIER_STANDING', next: 'the coordinator makes an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>"' }], rule: 'the caller did not build it; on a linked board, at engine 27 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join', next: 'another agent verifies it: pullboard next --verify', source: 'board' },
- { id: 'notBuilder', refuse: 'SELF_VERIFY', rule: 'the caller did not build it', next: 'another agent verifies it: pullboard next --verify', source: 'board' },
++ { id: 'notBuilder', refuse: 'SELF_VERIFY', alsoRefuses: [{ code: 'VERIFIER_STANDING', next: 'the coordinator makes an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>"' }], rule: 'the caller did not build it; on a linked board, at engine 35 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join', next: 'another agent verifies it: pullboard next --verify', source: 'board' },
{ id: 'policyAllows', refuse: 'COORDINATOR_VERIFIES', rule: "the repo's verify policy lets the caller verify this lane's work", next: 'the coordinator verifies it', source: 'board' },
{ id: 'familyAllows', refuse: 'O2_FAMILY_MATCH', rule: 'the builder and verifier have different declared families; an undeclared family counts as a match', next: 'ask the coordinator for a verifier from another declared family', source: 'board', when: 'only when verify.family is require' },
{ id: 'reviewFree', refuse: 'REVIEW_HELD', rule: 'no other agent holds its review under a live lease', next: 'pullboard next --verify, which passes over reviews another agent holds', source: 'board' },
diff --cc src/relay-pairing-client.js
index 138fc0ff,43dc086b..5fa32f6c
--- a/src/relay-pairing-client.js
+++ b/src/relay-pairing-client.js
@@@ -9,7 -9,7 +9,7 @@@ import { forgetBoardKey, readBoardKey,
import { encodeBoardKey } from './seal.js';
import { createPairingCode, openPairingBundle, parsePairingCode, sealPairingBundle } from './pairing.js';
import { terminalQr } from './qr.js';
- import { DEFAULT_RELAY, originRepository, relayPersonCoordinator, relayStatus, syncRelay } from './relay.js';
-import { DEFAULT_RELAY, originRepository, syncRelay } from './relay.js';
++import { DEFAULT_RELAY, originRepository, relayPersonCoordinator, syncRelay } from './relay.js';
import { ENGINE_VERSION } from './machine.js';
import { Refused } from './refused.js';
import { requirePersonChannel } from './person.js';
diff --cc src/relay-sender.js
index 71db5e15,e7d1924b..834ef27b
--- a/src/relay-sender.js
+++ b/src/relay-sender.js
@@@ -21,12 -19,19 +21,22 @@@ export function relayMoveActor(move)
export function validRelaySender(sender) {
return Boolean(sender && ['person', 'agent', 'machine'].includes(sender.kind) && typeof sender.userId === 'string' && sender.userId.length > 0 && sender.userId.length <= 256 &&
(sender.kind !== 'agent' || (typeof sender.agent === 'string' && sender.agent.length > 0 && sender.agent.length <= 256)) &&
- (sender.kind !== 'machine' || (typeof sender.machine === 'string' && sender.machine.length > 0 && sender.machine.length <= 256)));
+ (sender.kind !== 'machine' || (typeof sender.machine === 'string' && sender.machine.length > 0 && sender.machine.length <= 256)) &&
+ (sender.policy === undefined || Number.isSafeInteger(sender.policy) && sender.policy > 0) &&
+ (sender.root === undefined || sender.root === true) &&
+ (sender.lineage === undefined || typeof sender.lineage === 'string' && sender.lineage.length > 0 && sender.lineage.length <= 64));
}
+ /**
+ * True for a fact move that claims the person's authority: a never-again, a cause key, or person
+ * mode (#713). Only an authenticated person sender may make it, whatever channel it names, so no
+ * agent, coordinator seat or machine credential can make rigor list a cause as the person's.
+ */
+ function personFact(move) {
+ const options = move?.operation === 'appendFact' ? move.args?.[1] : null;
+ return Boolean(options && typeof options === 'object' && (options.asPerson || options.neverAgain || (options.cause !== undefined && options.cause !== null)));
+ }
+
/** Make the same authorization decision on every device, without inspecting its shell or checkout. */
export function relaySenderProblem(move, sender, kind, { phoneReceipt = false } = {}) {
if (!validRelaySender(sender)) {
diff --cc src/seats.js
index 2c112ae5,00000000..68a98e19
mode 100644,000000..100644
--- a/src/seats.js
+++ b/src/seats.js
@@@ -1,216 -1,0 +1,216 @@@
+/**
+ * Seats (B3, H2, V1): who each registered agent is on the board, read from the agent table and the
- * metadata kept beside it: its model, its route, and from engine 27 the seat that created it, whether
++ * metadata kept beside it: its model, its route, and from engine 35 the seat that created it, whether
+ * the relay enrolled it, and its machine lineage. Verifier standing on a linked board (#579) is
+ * decided here from that line of creators. board.js registers seats and re-exports the readers.
+ */
+import { COORDINATOR } from './config.js';
+import { ENGINE_VERSION, VERIFIER_STANDING_ENGINE } from './machine.js';
+import { Refused } from './refused.js';
+
+/**
+ * The agent registered for a worktree path, if any.
+ *
+ * @param {any} board
+ * @param {string} path
+ * @returns {any}
+ */
+export function agentAt(board, path) {
+ const agent = board.db.prepare('SELECT * FROM agent WHERE agent_path = ?').get(path);
+ return withModel(board, agent);
+}
+
+/** Read the model label kept beside other board metadata, avoiding any board-schema migration. */
+export function agentModel(board, id) {
+ return board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key = ?').get(`agent_model:${id}`)?.meta_value ?? null;
+}
+
+/** Attach an agent's model to a row from the legacy stable agent table. */
+export function withModel(board, agent) {
+ return agent ? { ...agent, agent_model: agentModel(board, agent.agent_id) } : agent;
+}
+
+/** Save or clear a model label without changing the shared SQLite schema. */
+export function saveAgentModel(board, id, model) {
+ if (model === null || model === undefined) {
+ board.db.prepare('DELETE FROM board_meta WHERE meta_key = ?').run(`agent_model:${id}`);
+ return;
+ }
+ board.db.prepare('INSERT INTO board_meta (meta_key, meta_value) VALUES (?, ?) ON CONFLICT(meta_key) DO UPDATE SET meta_value = excluded.meta_value')
+ .run(`agent_model:${id}`, model);
+}
+
+/**
+ * Every registered agent, oldest first.
+ *
+ * @param {any} board
+ * @returns {any[]}
+ */
+export function listAgents(board) {
+ return board.db.prepare('SELECT * FROM agent ORDER BY rowid').all().map((agent) => withModel(board, agent));
+}
+
+/**
+ * The route an agent joined on; strong for the coordinator and for ids the board does not know.
+ *
+ * @param {any} board
+ * @param {string} agentId
+ * @returns {string}
+ */
+export function routeOf(board, agentId) {
+ return board.db.prepare('SELECT agent_route FROM agent WHERE agent_id = ?').get(agentId)?.agent_route ?? 'strong';
+}
+
+/**
- * The id an engine-27 registration gives a new seat: the named one when it is the lane's form and
++ * The id an engine-35 registration gives a new seat: the named one when it is the lane's form and
+ * free, otherwise the lane's first free number from its count. Skipping taken numbers keeps a named
+ * seat from colliding with the next unnamed one.
+ *
+ * @param {any} board
+ * @param {string} lane
+ * @param {number} total
+ * @param {string | undefined} named
+ * @returns {string}
+ */
+export function newSeatId(board, lane, total, named) {
+ if (named === undefined) return firstFreeSeatId(board, lane, total);
+ const number = typeof named === 'string' && named.startsWith(`${lane}-`) ? named.slice(lane.length + 1) : '';
+ if (!/^[1-9][0-9]{0,8}$/.test(number) || Number(number) <= total || board.db.prepare('SELECT 1 FROM agent WHERE agent_id = ?').get(named)) {
+ throw new Refused('BAD_SEAT_ID', `a new ${lane} seat is named ${lane}-<n> above the lane's count and not yet taken; register again without a name`);
+ }
+ return named;
+}
+
+/**
+ * The lane's first seat number above its count that no seat holds yet.
+ *
+ * @param {any} board
+ * @param {string} lane
+ * @param {number} total
+ * @returns {string}
+ */
+function firstFreeSeatId(board, lane, total) {
+ let n = total + 1;
+ while (board.db.prepare('SELECT 1 FROM agent WHERE agent_id = ?').get(`${lane}-${n}`)) n += 1;
+ return `${lane}-${n}`;
+}
+
+/**
- * The seat that created this one, as its engine-27 registration recorded it: an agent id,
- * `machine` for a join no seat made, or null for a seat registered before engine 27.
++ * The seat that created this one, as its engine-35 registration recorded it: an agent id,
++ * `machine` for a join no seat made, or null for a seat registered before engine 35.
+ *
+ * @param {any} board
+ * @param {string} id
+ * @returns {string | null}
+ */
+export function agentCreator(board, id) {
+ return board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key = ?').get(`agent_creator:${id}`)?.meta_value ?? null;
+}
+
+/**
+ * Whether a relay replica enrolled this seat from its creator's receipt-bound registration (#579).
+ *
+ * @param {any} board
+ * @param {string} id
+ * @returns {boolean}
+ */
+export function seatEnrolled(board, id) {
+ return Boolean(board.db.prepare('SELECT 1 FROM board_meta WHERE meta_key = ?').get(`agent_enrolled:${id}`));
+}
+
+/**
+ * The machine registration lineage a relay-enrolled seat descends from: the person-set coordinator
+ * token of the machine that made its line (#579), or null when it was never recorded.
+ *
+ * @param {any} board
+ * @param {string} id
+ * @returns {string | null}
+ */
+export function seatLineage(board, id) {
+ return board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key = ?').get(`agent_lineage:${id}`)?.meta_value ?? null;
+}
+
+/**
+ * The id the next registration in a lane gets when it names none, for a creator that must
+ * predict it before sealing the move (the relay receipt names the target seat).
+ *
+ * @param {any} board
+ * @param {string} lane
+ * @returns {string}
+ */
+export function nextSeatId(board, lane) {
+ const { total } = board.db.prepare('SELECT COUNT(*) AS total FROM agent WHERE agent_lane = ?').get(lane);
+ return firstFreeSeatId(board, lane, total);
+}
+
+/**
+ * Run board work under linked-board verifier standing (#579): a relay replica replaying an
- * engine-27 move, or a linked CLI previewing one. `root` says whether the acting coordinator's
++ * engine-35 move, or a linked CLI previewing one. `root` says whether the acting coordinator's
+ * relay credential was set up by the person. Unlinked boards never enter this, so who may verify
+ * there is unchanged.
+ *
+ * @template T
+ * @param {any} board
+ * @param {{ root: boolean, person?: boolean, lineage?: string | null }} standing
+ * @param {() => T} work
+ * @returns {T}
+ */
+export function withVerifierStanding(board, standing, work) {
+ const previous = board.verifierStanding;
+ board.verifierStanding = { root: standing.root === true, person: standing.person === true,
+ lineage: typeof standing.lineage === 'string' ? standing.lineage : null };
+ try { return work(); }
+ finally {
+ if (previous === undefined) delete board.verifierStanding;
+ else board.verifierStanding = previous;
+ }
+}
+
+/**
+ * Why this seat may not verify the builder's item on a linked board, or null when it may. The
+ * seat's creators are walked up to the coordinator: the builder, a join no seat made (`machine`),
- * or a seat registered before engine 27 anywhere on the way means no standing. The coordinator
++ * or a seat registered before engine 35 anywhere on the way means no standing. The coordinator
+ * stands only on a credential the person set up.
+ *
+ * @param {any} board
+ * @param {string} verifier
+ * @param {string} builder
+ * @param {number} itemId
+ * @returns {Refused | null}
+ */
+export function standingProblem(board, verifier, builder, itemId) {
+ const standing = board.verifierStanding;
+ if (!standing || (board.executionEngineVersion ?? ENGINE_VERSION) < VERIFIER_STANDING_ENGINE) return null;
+ const refuse = (why) => new Refused('VERIFIER_STANDING',
+ `${verifier} cannot verify work built by ${builder} on this linked board: ${why}; ask the coordinator to make an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>"`);
+ if (builder === COORDINATOR) {
+ // The person stands above every seat; otherwise only a seat from another machine's line may.
+ if (standing.person) return null;
+ const refuseOwn = (why) => new Refused('VERIFIER_STANDING', `${verifier} cannot verify work the coordinator built on this linked board: ${why}; a seat from another machine's registration lineage, or the person, verifies it`);
+ const built = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key = ?').get(`item_lineage:${itemId}`)?.meta_value ?? null;
+ const lineage = seatLineage(board, verifier);
+ if (!built || !lineage) return refuseOwn('the machine lineage of the build or of this seat was not recorded');
+ if (built === lineage) return refuseOwn('this seat shares the building machine\'s registration lineage');
+ for (let seat = verifier, seen = new Set(); seat !== COORDINATOR; seat = agentCreator(board, seat)) {
+ if (seen.has(seat) || !seatEnrolled(board, seat)) return refuseOwn(`${seat} was not enrolled through the relay`);
+ seen.add(seat);
+ }
+ return null;
+ }
+ const seen = new Set();
+ for (let seat = verifier; ;) {
+ if (seat === COORDINATOR) {
+ return standing.root || seat !== verifier ? null
+ : refuse('the coordinator credential was not set up by the person; run pullboard relay on in the main checkout once');
+ }
+ if (seen.has(seat)) return refuse('its line of creating seats loops');
+ seen.add(seat);
+ const creator = agentCreator(board, seat);
+ if (creator === 'machine') return refuse(`${seat} joined without a creating seat`);
+ if (creator === builder) return refuse(`${seat} was created by the builder`);
+ if (creator === null || !seatEnrolled(board, seat)) {
+ return refuse(`${seat} was not enrolled by its creating seat through the relay`);
+ }
+ seat = creator;
+ }
+}
diff --cc test/agent-model-engine.test.js
index edc6b51a,f3b39a11..99f635f7
--- a/test/agent-model-engine.test.js
+++ b/test/agent-model-engine.test.js
@@@ -10,9 -10,9 +10,9 @@@ import { mkdtempSync, rmSync, writeFile
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, 30, 'engine 30 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]) {
+test('model declarations and event snapshots retain engines 1 through 12, 19 and 20 semantics [O8,O3,H16]', (t) => {
- assert.equal(ENGINE_VERSION, 27, 'engine 27 preserves the released engine-8 through engine-20 model behavior');
++ assert.equal(ENGINE_VERSION, 35, 'engine 35 preserves the released engine-8 through engine-20 model behavior');
+ for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 19, 20, ENGINE_VERSION]) {
const board = store.openBoard(':memory:');
t.after(() => store.closeBoard(board));
const registration = prepareEngineMove(board, 'register', [{ lane: 'web', path: '/web', model: 'First Model' }]);
diff --cc test/pending-refreeze.test.js
index 025078fc,710c1495..aab172f5
--- a/test/pending-refreeze.test.js
+++ b/test/pending-refreeze.test.js
@@@ -243,12 -243,12 +243,12 @@@ async function checkDependencyLegacyCli
const oldFeature = legacyEngine.applyRelayMove(old, engine10Move, engine10Receipt);
const currentFeature = applyRelayMove(current, engine10Move, engine10Receipt);
assert.equal(oldFeature.error, undefined, JSON.stringify(oldFeature));
- assert.deepEqual(currentFeature, oldFeature, 'engine 27 reproduces engine 10 dependency additions and clears');
- assert.deepEqual(currentFeature, oldFeature, 'engine 12 reproduces engine 10 dependency additions and clears');
++ assert.deepEqual(currentFeature, oldFeature, 'engine 35 reproduces engine 10 dependency additions and clears');
assert.deepEqual(store.getItem(current, target), legacyStore.getItem(old, target));
- assert.deepEqual(store.events(current), legacyStore.events(old), 'engine 10 and engine 27 replay identical events');
- assert.deepEqual(store.events(current), legacyStore.events(old), 'engine 10 and engine 12 replay identical events');
++ assert.deepEqual(store.events(current), legacyStore.events(old), 'engine 10 and engine 35 replay identical events');
assert.equal(appliedSequence(current), legacyEngine.appliedSequence(old));
assert.deepEqual(engineReceipt(current, engine10Move.id), legacyEngine.engineReceipt(old, engine10Move.id),
- 'engine 10 and engine 27 retain the same dependency-move receipts');
- 'engine 10 and engine 12 retain the same dependency-move receipts');
++ 'engine 10 and engine 35 retain the same dependency-move receipts');
const oldSnapshot = legacyExchange.exportBoard(old);
const currentSnapshot = exportBoard(current);
assert.equal(oldSnapshot.tables.board_meta.find((row) => row.meta_key === 'relay_engine_version').meta_value, '10');
@@@ -261,7 -261,7 +261,7 @@@
}
test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {
- assert.equal(ENGINE_VERSION, 27);
- assert.equal(ENGINE_VERSION, 30);
++ assert.equal(ENGINE_VERSION, 35);
const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));
const cleanup = [];
t.after(() => {
diff --cc test/relay-mint.test.js
index 79b84cbd,00000000..1a611655
mode 100644,000000..100644
--- a/test/relay-mint.test.js
+++ b/test/relay-mint.test.js
@@@ -1,367 -1,0 +1,367 @@@
+/** An agent in its worktree cannot mint a relay token or borrow another seat's verifier standing [H2,V1,E3,E5,P6] (#579). */
+import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import { DatabaseSync } from 'node:sqlite';
+import { chmodSync, copyFileSync, existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, statSync } from 'node:fs';
+import { dirname, join } from 'node:path';
+import { tmpdir } from 'node:os';
+import { test } from 'node:test';
+import * as store from '../src/board.js';
+import { appliedSequence, applyRelayMove } from '../src/engine.js';
+import { ENGINE_VERSION, VERIFIER_STANDING_ENGINE } from '../src/machine.js';
+import { createRelayJournal } from '../relay/journal.js';
+import { runFixtureChild } from './fixture-child.js';
+import { relayClientFixture } from './relay-client-fixture.js';
+
+const TOKEN = /^pa_[A-Za-z0-9_-]{43}$/u;
+const POLICY = { version: 1, commit: 'a'.repeat(40), verify: { policy: 'any', family: 'off' } };
+
+/** Run fixture Git with hooks off: this test is about relay credentials, not the installed hooks. */
+function git(root, env, args) {
+ const result = runFixtureChild('git', ['-c', 'core.hooksPath=/dev/null', ...args], { cwd: root, env, encoding: 'utf8' });
+ assert.equal(result.status, 0, result.failure ?? `fixture git ${args[0]} succeeds`);
+ return result.stdout.trim();
+}
+
+/** Send one credentialed request to the loopback relay; bearer values never enter a message. */
+async function call(origin, token, method, path, body) {
+ const response = await fetch(origin + path, {
+ method, headers: { authorization: `Bearer ${token}`, 'x-pullboard-engine': String(ENGINE_VERSION),
+ ...(body === undefined ? {} : { 'content-type': 'application/json' }) },
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
+ });
+ return { status: response.status, document: await response.json() };
+}
+
+/** Read the shared link file every worktree of this repository can read. */
+function link(box) { return JSON.parse(readFileSync(box.linkFile, 'utf8')); }
+
+/** Every file under a directory, for a scan that no person session sits on disk (#299). */
+function files(directory) {
+ if (!existsSync(directory)) return [];
+ return readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {
+ const path = join(directory, entry.name);
+ return entry.isDirectory() ? files(path) : entry.isFile() ? [path] : [];
+ });
+}
+
+/** Freeze a criterion with a valid verify policy, as the CLI does at claim. */
+function freezer() {
+ const text = JSON.stringify({ criterion: 'an independent seat accepts it', policy: POLICY });
+ return () => ({ text, digest: createHash('sha256').update(text).digest('hex') });
+}
+
+/** Put one item in submitted state on a board, built by `builder`. */
+function submitted(board, builder, lane) {
+ const added = store.addItem(board, { by: 'coordinator', lane, title: 'provenance review', criterion: 'an independent seat accepts it' });
+ const item = { item_id: typeof added === 'number' ? added : added.item_id };
+ store.claim(board, item.item_id, { agentId: builder, lane, leaseMs: 3_600_000, freeze: freezer(), head: 'a'.repeat(40) });
+ store.submit(board, item.item_id, { agentId: builder, commit: 'b'.repeat(40), tree: 'c'.repeat(40) });
+ return store.getItem(board, item.item_id);
+}
+
+test('an agent in its worktree cannot mint a relay token [H2,V1,E3,E5,P6]', async (t) => {
+ const box = await relayClientFixture(t);
+ const lane = box.lane;
+ git(box.root, box.env, ['add', '-A']);
+ git(box.root, box.env, ['commit', '-q', '-m', 'test: private relay mint fixture']);
+ const head = git(box.root, box.env, ['rev-parse', 'HEAD']);
+
+ // A seat the coordinator made before the board was linked: it builds, but it was never enrolled.
+ const prelinked = await box.cli('worktree', lane, '--model', 'Prelinked Seat');
+ assert.equal(prelinked.code, 0, prelinked.failure ?? 'the unlinked coordinator makes a worktree');
+ await box.link();
+ const start = link(box);
+ assert.match(start.agentTokens?.coordinator?.token ?? '', TOKEN, 'relay on sets up the coordinator token from the person sign-in');
+ const session = await call(box.origin, start.agentTokens.coordinator.token, 'GET', `/auth/session?board=${start.board}`);
+ assert.equal(session.document.session.root, true, 'the coordinator token is the person-made root');
+
+ // A manual join: no seat made it, so the machine credential gives it a build-only token, with no person action.
+ const manualRoot = join(dirname(box.root), 'manual-join');
+ git(box.root, box.env, ['worktree', 'add', '-q', '--detach', manualRoot, head]);
+ const before = box.transit.length;
+ const manualJoin = await box.cliAt(manualRoot, 'join', lane, '--model', 'Manual Seat');
+ assert.equal(manualJoin.code, 0, manualJoin.failure ?? 'a manual join enrolls with no person action');
+ const manual = manualJoin.document.agent;
+ const manualTraffic = box.transit.slice(before);
+ const manualMint = manualTraffic.find((entry) => entry.method === 'POST' && entry.path === '/auth/tokens');
+ assert.equal(JSON.parse(manualMint.request.toString('utf8')).agent, manual, 'the machine credential first-mints the manual seat');
+ assert.match(JSON.parse(manualMint.response.toString('utf8')).token ?? '', TOKEN);
+ assert.equal(manualTraffic.some((entry) => /approvals|authorize|\/auth\/device/u.test(entry.path)), false, 'no phone or person step');
+
+ // Fresh seats from their creators: the first token comes back in the creator's own registration request.
+ /** Make one seat from a creator's checkout and return its id, path and registration exchange. */
+ const created = async (cwd, model) => {
+ const from = box.transit.length;
+ const result = cwd === box.root ? await box.cli('worktree', lane, '--model', model) : await box.cliAt(cwd, 'worktree', lane, '--model', model);
+ assert.equal(result.code, 0, result.failure ?? `the creator makes ${model}`);
+ const traffic = box.transit.slice(from);
+ const registration = traffic.findLast((entry) => entry.method === 'POST' && entry.path.endsWith('/moves') && JSON.parse(entry.request.toString('utf8')).registration
+ && JSON.parse(entry.response.toString('utf8')).enrollment);
+ assert.ok(registration, 'the registration move carries its seat receipt');
+ const reply = JSON.parse(registration.response.toString('utf8'));
+ assert.equal(reply.enrollment.agent, result.document.agent, 'the registration reply enrolls the new seat');
+ assert.match(reply.enrollment.token ?? '', TOKEN, 'its creator receives the first token in that same request');
+ assert.equal(reply.event.registration.target, result.document.agent, 'the public event names the target');
+ assert.equal(JSON.stringify(reply.event).includes(reply.enrollment.token), false, 'the token never enters the public event');
+ assert.equal(traffic.some((entry) => entry.method === 'POST' && entry.path === '/auth/tokens'), false, 'no separate first mint');
+ assert.equal(traffic.some((entry) => /approvals|authorize|\/auth\/device/u.test(entry.path)), false, 'enrollment stays zero-tap');
+ return { id: result.document.agent, path: result.document.path, registration };
+ };
+ const builder = await created(box.root, 'Builder Seat');
+ const reviewer = await created(box.root, 'Reviewer Seat');
+ const child = await created(builder.path, 'Child Seat');
+ const grandchild = await created(child.path, 'Grandchild Seat');
+ const prelinkedActs = await box.cliAt(prelinked.document.path, 'shout', 'all', 'a seat from before the link keeps building');
+ assert.equal(prelinkedActs.code, 0, prelinkedActs.failure ?? 'an existing seat keeps working after the link');
+
+ const boardCopy = join(mkdtempSync(join(tmpdir(), 'pullboard-mint-board-')), 'board.sqlite');
+ t.after(() => rmSync(dirname(boardCopy), { recursive: true, force: true }));
+ copyFileSync(join(box.root, '.git', 'pullboard', 'board.sqlite'), boardCopy);
+ const board = store.openBoard(boardCopy);
+ t.after(() => store.closeBoard(board));
+ assert.equal(store.agentCreator(board, manual), 'machine', 'a manual join records that no seat made it');
+ assert.equal(store.agentCreator(board, builder.id), 'coordinator');
+ assert.equal(store.agentCreator(board, reviewer.id), 'coordinator');
+ assert.equal(store.agentCreator(board, child.id), builder.id, 'every registration records the seat that created it');
+ assert.equal(store.agentCreator(board, grandchild.id), child.id);
+ assert.equal(store.seatEnrolled(board, child.id), true);
+ assert.equal(store.seatEnrolled(board, manual), false);
+ assert.equal(store.seatEnrolled(board, prelinked.document.agent), false, 'a seat made before linking was never enrolled');
+
+ await t.test('every credential a worktree can reach is refused against every existing seat', async () => {
+ const state = link(box);
+ const shared = readFileSync(box.linkFile, 'utf8');
+ for (const path of [box.linkFile, ...files(join(box.root, '.git', 'pullboard')), ...files(box.env.PULLBOARD_HOME), ...files(box.env.PULLBOARD_MACHINE_HOME)]) {
+ if (statSync(path).size < 2_000_000) assert.equal(/ps_[A-Za-z0-9_-]{43}/u.test(readFileSync(path, 'latin1')), false, 'no person session is stored where a worktree can read it');
+ }
+ assert.match(state.token, /^pm_[A-Za-z0-9_-]{43}$/u, 'the shared link file holds the machine credential');
+ const seats = Object.keys(state.agentTokens);
+ for (const seat of ['coordinator', manual, prelinked.document.agent, builder.id, reviewer.id, child.id, grandchild.id]) assert.ok(seats.includes(seat), `${seat} has a cached token`);
+ assert.equal(seats.length, store.listAgents(board).length, 'every registered seat holds a token');
+ const credentials = [['machine', state.token], ...seats.map((seat) => [seat, state.agentTokens[seat].token])];
+ const copied = JSON.parse(builder.registration.request.toString('utf8')).registration;
+ let attempts = 0;
+ for (const [holder, credential] of credentials) {
+ for (const target of seats) {
+ if (holder === target) continue; // A seat's own token renewing itself is the one decided exception (7bbf20c0).
+ for (const body of [{ board: state.board, agent: target }, { board: state.board, agent: target, recover: true }, { board: state.board, agent: target, registration: copied }]) {
+ if (body.recover && holder === 'coordinator' && [builder.id, reviewer.id].includes(target)) continue; // Its creator's reissue.
+ if (body.recover && holder === builder.id && target === child.id) continue;
+ if (body.recover && holder === child.id && target === grandchild.id) continue;
+ const attempt = await call(box.origin, credential, 'POST', '/auth/tokens', body);
+ attempts += 1;
+ assert.ok(attempt.status >= 400, `${holder} cannot mint for ${target}`);
+ assert.ok(['TOKEN_EXISTS', 'TOKEN_AGENT', 'REGISTRATION_IN_MOVE'].includes(attempt.document.error?.code), `${holder} is refused by name for ${target}`);
+ }
+ }
+ const root = await call(box.origin, credential, 'POST', '/auth/coordinators', { board: state.board });
+ assert.equal(root.status, 403, `${holder} cannot set up the coordinator credential`);
+ assert.equal(root.document.error?.code, 'HUMAN_REQUIRED');
+ }
+ assert.ok(attempts > 90, 'the sweep covers every reachable credential against every existing seat');
+ assert.equal(readFileSync(box.linkFile, 'utf8'), shared, 'no refused attempt changed the shared link file');
+ });
+
+ await t.test('a seat renews only with its own token, and only its creator reissues a lost one', async () => {
+ const state = link(box);
+ const own = state.agentTokens[grandchild.id].token;
+ const renewed = await call(box.origin, own, 'POST', '/auth/tokens', { board: state.board, agent: grandchild.id });
+ assert.equal(renewed.status, 201, 'the current token renews its own seat');
+ assert.equal((await call(box.origin, own, 'GET', `/auth/session?board=${state.board}`)).status, 401, 'renewal revokes the old token');
+ assert.equal((await call(box.origin, renewed.document.token, 'GET', `/auth/session?board=${state.board}`)).document.session.agent, grandchild.id);
+ const reissued = await call(box.origin, state.agentTokens[child.id].token, 'POST', '/auth/tokens', { board: state.board, agent: grandchild.id, recover: true });
+ assert.equal(reissued.status, 201, 'the creator reissues a lost token');
+ assert.equal((await call(box.origin, renewed.document.token, 'GET', `/auth/session?board=${state.board}`)).status, 401, 'reissue revokes the old one');
+ // Once every token of a seat is revoked or expired, the machine credential still cannot renew it.
+ const person = await box.phoneSession();
+ await box.auth.revoke(person.token, reissued.document.id);
+ const machineRenewal = await call(box.origin, state.token, 'POST', '/auth/tokens', { board: state.board, agent: grandchild.id });
+ assert.equal(machineRenewal.document.error?.code, 'TOKEN_EXISTS', 'the machine credential never renews a registered seat that held a token');
+ // A machine-minted seat has no receipt to fall back on: its first-mint history alone refuses.
+ await box.auth.revoke(person.token, state.agentTokens[prelinked.document.agent].id);
+ const machineRemint = await call(box.origin, state.token, 'POST', '/auth/tokens', { board: state.board, agent: prelinked.document.agent });
+ assert.equal(machineRemint.document.error?.code, 'TOKEN_EXISTS', 'the machine credential never renews a seat that held a token');
+ const manualRecover = await call(box.origin, state.agentTokens[manual].token, 'POST', '/auth/tokens', { board: state.board, agent: manual, recover: true });
+ assert.equal(manualRecover.document.error?.code, 'TOKEN_AGENT', 'a machine-origin seat has no creator to reissue it');
+ // Retrying the exact registration returns the same issuance, and no token.
+ const first = JSON.parse(reviewer.registration.response.toString('utf8')).enrollment;
+ const retry = await call(box.origin, state.agentTokens.coordinator.token, 'POST', reviewer.registration.path, JSON.parse(reviewer.registration.request.toString('utf8')));
+ assert.equal(retry.status, 200, 'an exact registration retry is accepted');
+ assert.equal(retry.document.enrollment.id, first.id, 'it returns the same issuance');
+ assert.equal(retry.document.enrollment.expires, first.expires);
+ assert.equal(retry.document.enrollment.token, undefined, 'the relay holds no token to return');
+ });
+
+ await t.test('a machine-origin seat stays build-only and its name cannot be registered', async () => {
+ const state = link(box);
+ const sealed = Buffer.from('opaque fixture move').toString('base64url');
+ const registration = { target: manual, creator: builder.id, sequence: state.sequence + 1, digest: createHash('sha256').update(sealed).digest('hex') };
+ const later = await call(box.origin, state.agentTokens[builder.id].token, 'POST', `/api/v1/boards/${state.board}/moves`, { sequence: registration.sequence, sealed, registration });
+ assert.equal(later.document.error?.code, 'SEAT_TAKEN', 'registering a machine-minted name is refused, not upgraded');
+ // A pre-mint of the next name makes the creator take the one after it, still with no person action.
+ const target = store.nextSeatId(board, lane);
+ const premint = await call(box.origin, state.token, 'POST', '/auth/tokens', { board: state.board, agent: target });
+ assert.equal(premint.status, 201, 'the machine credential first-mints a never-issued name');
+ const skipped = await created(box.root, 'After Premint');
+ assert.notEqual(skipped.id, target, 'the pre-minted name is skipped, not upgraded');
+ const claimed = await box.cliAt(manualRoot, 'shout', 'all', 'manual seat still builds');
+ assert.equal(claimed.code, 0, claimed.failure ?? 'the build-only seat keeps acting under its own token');
+ });
+
+ await t.test('a registration interrupted before enrollment still claims its seat from the machine', async () => {
+ // Causal control for the 5e76ff75 reject: fail after the journal append, before enrollment.
+ const enroll = box.auth.enrollSeat;
+ let injected = 0;
+ box.auth.enrollSeat = (...args) => {
+ if (injected++ === 0) throw new Error('injected failure between the journal append and enrollment');
+ return enroll.apply(box.auth, args);
+ };
+ const from = box.transit.length;
+ let interrupted;
+ try { interrupted = await box.cli('worktree', lane, '--model', 'Interrupted Seat'); }
+ finally { box.auth.enrollSeat = enroll; }
+ assert.notEqual(interrupted.code, 0, 'the creator sees the failed registration');
+ const failed = box.transit.slice(from).find((entry) => entry.method === 'POST' && entry.path.endsWith('/moves') && JSON.parse(entry.request.toString('utf8')).registration);
+ assert.ok(failed, 'the registration reached the relay');
+ const body = JSON.parse(failed.request.toString('utf8'));
+ const state = link(box);
+ const snapshot = await call(box.origin, state.token, 'GET', `/api/v1/boards/${state.board}/state`);
+ const events = await call(box.origin, state.token, 'GET', `/api/v1/boards/${state.board}/events?after=${snapshot.document.state.sequence}`);
+ assert.equal(events.status, 200, JSON.stringify(events.document.error ?? {}));
+ assert.ok(events.document.events.some((event) => event.registration?.target === body.registration.target), 'the move and its receipt were published');
+ assert.equal(box.auth.seatRecord(state.board, body.registration.target), null, 'no first-issuance history was written');
+ const race = await call(box.origin, state.token, 'POST', '/auth/tokens', { board: state.board, agent: body.registration.target });
+ assert.equal(race.document.error?.code, 'TOKEN_EXISTS', 'the machine credential cannot first-mint a name its published receipt claims');
+ const retry = await call(box.origin, state.agentTokens.coordinator.token, 'POST', failed.path, body);
+ assert.equal(retry.status, 200, 'the creator\'s exact retry is accepted');
+ assert.equal(retry.document.enrollment.agent, body.registration.target);
+ assert.match(retry.document.enrollment.token ?? '', TOKEN, 'the exact retry finishes the enrollment with the first token');
+ assert.equal(box.auth.seatRecord(state.board, body.registration.target).origin, 'registered');
+ const after = await call(box.origin, state.token, 'POST', '/auth/tokens', { board: state.board, agent: body.registration.target });
+ assert.equal(after.document.error?.code, 'TOKEN_EXISTS');
+ });
+
+ await t.test('linked verify refuses the builder line and seats without standing, in one line', () => {
+ const item = submitted(board, builder.id, lane);
+ /** The accept arguments a seat sends for this item. */
+ const verdict = (agentId) => [item.item_id, { agentId, decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'checked the proof', head: 'd'.repeat(40), digest: item.item_frozen_digest }];
+ let id = 0;
- /** Replay one stamped engine-27 relay move from an agent on the linked board copy. */
++ /** Replay one stamped engine-35 relay move from an agent on the linked board copy. */
+ const move = (operation, args, sender, extra = {}) => applyRelayMove(board, { version: 1, engine: ENGINE_VERSION, id: `standing-${++id}`, operation, args }, {
+ sequence: appliedSequence(board) + 1, at: new Date().toISOString(), kind: 'move', sender: { kind: 'agent', userId: '1', policy: VERIFIER_STANDING_ENGINE, ...sender }, ...extra,
+ });
+ for (const seat of [child.id, grandchild.id, manual, prelinked.document.agent]) {
+ const refused = move('verify', verdict(seat), { agent: seat });
+ assert.equal(refused.error?.code, 'VERIFIER_STANDING', `${seat} has no verifier standing on the linked board`);
+ assert.equal(refused.error.message.includes('\n'), false, 'the refusal is one line');
+ assert.match(refused.error.message, /pullboard worktree <lane> --model "<model name>"/u, 'it names the coordinator command');
+ }
+ assert.equal(move('verify', verdict(builder.id), { agent: builder.id }).error?.code, 'SELF_VERIFY');
+ assert.equal(move('verify', verdict('coordinator'), { agent: 'coordinator' }).error?.code, 'VERIFIER_STANDING', 'a coordinator token the person did not set up has no standing');
+ const next = move('reserveNextReview', [{ agentId: child.id, lane, leaseMs: 60_000, policy: 'any' }], { agent: child.id });
+ assert.equal(next.result.item, null, 'next --verify offers the builder\'s child nothing');
+ assert.match(next.result.reasons.join('\n'), /pullboard worktree <lane> --model/u);
+ const forged = move('register', [{ lane, path: '/forged-seat', model: 'Forged', createdBy: builder.id, id: `${lane}-900` }], { agent: builder.id });
+ assert.equal(forged.error?.code, 'RELAY_REGISTRATION', 'a seat registered without its relay receipt is refused');
+ const accepted = move('verify', verdict(reviewer.id), { agent: reviewer.id });
+ assert.equal(accepted.result?.decision, 'ACCEPT', 'a seat the coordinator made outside the builder line verifies');
+ // The literal rule holds for the coordinator too (decision 11096): its seats share its lineage.
+ const own = submitted(board, 'coordinator', 'coordinator');
+ const ownVerdict = move('verify', [own.item_id, { ...verdict(reviewer.id)[1], digest: own.item_frozen_digest }], { agent: reviewer.id });
+ assert.equal(ownVerdict.error?.code, 'VERIFIER_STANDING', 'a coordinator-made seat cannot verify the coordinator\'s own work');
+ assert.match(ownVerdict.error.message, /another machine's registration lineage, or the person/u);
+
+ // The positive half of 11099: the coordinator on machine A builds; a seat from machine B's
+ // registration lineage, or the person, verifies it, while machine A's own seats still cannot.
+ const machineA = { agent: 'coordinator', root: true, lineage: '11111111-1111-4111-8111-111111111111' };
+ const machineB = { agent: 'coordinator', root: true, lineage: '22222222-2222-4222-8222-222222222222' };
+ /** Enroll one seat through a replayed, receipt-bound coordinator registration from one machine. */
+ const enrollFrom = (sender, n) => {
+ const target = `${lane}-${n}`;
+ const digest = String(n % 10).repeat(64);
+ const sequence = appliedSequence(board) + 1;
+ const made = move('register', [{ lane, path: `/lineage-seat-${n}`, model: 'Lineage Seat', createdBy: 'coordinator', id: target }], sender,
+ { registration: { target, creator: 'coordinator', sequence, digest }, digest });
+ assert.equal(made.result, target, `machine ${sender.lineage.slice(0, 1)} enrolls ${target}`);
+ return target;
+ };
+ const seatA = enrollFrom(machineA, 801);
+ const seatB = enrollFrom(machineB, 802);
+ /** Claim and submit one coordinator item through replayed moves from machine A. */
+ const builtOnA = () => {
+ const itemId = store.addItem(board, { by: 'coordinator', lane: 'coordinator', title: 'coordinator-built on machine A', criterion: 'another lineage accepts it' });
+ const frozen = freezer()();
+ assert.equal(move('claim', [itemId, { agentId: 'coordinator', lane: 'coordinator', leaseMs: 3_600_000, head: 'a'.repeat(40), frozen, freezeError: null }], machineA).error, undefined);
+ assert.equal(move('submit', [itemId, { agentId: 'coordinator', commit: 'b'.repeat(40), tree: 'c'.repeat(40) }], machineA).error, undefined);
+ return store.getItem(board, itemId);
+ };
+ const coordinatorItem = builtOnA();
+ const accept = (item) => [item.item_id, { agentId: seatB, decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'checked the proof', head: 'd'.repeat(40), digest: item.item_frozen_digest }];
+ const sameLine = move('verify', [coordinatorItem.item_id, { ...accept(coordinatorItem)[1], agentId: seatA }], { agent: seatA });
+ assert.equal(sameLine.error?.code, 'VERIFIER_STANDING', 'a seat from the building machine\'s own lineage is refused');
+ const otherMachine = move('verify', accept(coordinatorItem), { agent: seatB });
+ assert.equal(otherMachine.result?.decision, 'ACCEPT', 'a seat from another machine\'s registration lineage verifies coordinator-built work');
+ const forPerson = builtOnA();
+ const person = move('verify', [forPerson.item_id, { ...accept(forPerson)[1], agentId: seatA }], { kind: 'person', agent: undefined });
+ assert.equal(person.result?.decision, 'ACCEPT', 'the person verifies coordinator-built work');
+ });
+
+ // 19 (bar corrections, #470) and 20 (implies, #469) are main's engines before #579; their journals replay as they did too.
+ for (const engine of [11, 12, 19, 20]) await t.test(`an engine-${engine} journal replays as before`, (t) => {
+ const directory = mkdtempSync(join(tmpdir(), `pullboard-mint-engine${engine}-`));
+ t.after(() => rmSync(directory, { recursive: true, force: true }));
+ const historical = store.openBoard(':memory:');
+ t.after(() => store.closeBoard(historical));
+ historical.executionEngineVersion = engine;
+ store.register(historical, { lane: 'coordinator', path: '/repo' });
+ const legacyBuilder = store.register(historical, { lane: 'web', path: '/repo-web-1', createdBy: 'machine' });
+ const legacyReviewer = store.register(historical, { lane: 'web', path: '/repo-web-2' });
+ delete historical.executionEngineVersion;
+ assert.equal(store.agentCreator(historical, legacyBuilder), null, `engine ${engine} records no provenance`);
+ const item = submitted(historical, legacyBuilder, 'web');
+ const recorded = { version: 1, engine, id: `engine-${engine}-verify`, operation: 'verify',
+ args: [item.item_id, { agentId: legacyReviewer, decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'checked', head: 'd'.repeat(40), digest: item.item_frozen_digest }] };
+ const boardId = 'e'.repeat(32);
+ const path = join(directory, boardId + '.journal.sqlite');
+ const db = new DatabaseSync(path);
+ chmodSync(path, 0o600);
+ db.exec(`CREATE TABLE journal_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);
+ CREATE TABLE journal_record (sequence INTEGER PRIMARY KEY, received_at TEXT NOT NULL, kind TEXT NOT NULL CHECK(kind IN ('move','request')),
+ payload BLOB NOT NULL, sender_kind TEXT NOT NULL CHECK(sender_kind IN ('person','agent','machine')), sender_user TEXT NOT NULL, sender_agent TEXT);
+ CREATE TABLE journal_head (slot INTEGER PRIMARY KEY CHECK(slot=1), sequence INTEGER NOT NULL, last_activity_at TEXT);
+ CREATE TABLE journal_snapshot (slot INTEGER PRIMARY KEY CHECK(slot=1), sequence INTEGER NOT NULL, received_at TEXT NOT NULL, payload BLOB NOT NULL,
+ sender_kind TEXT NOT NULL, sender_user TEXT NOT NULL, sender_agent TEXT);`);
+ db.prepare('INSERT INTO journal_meta (key,value) VALUES (?,?),(?,?)').run('board', boardId, 'format', '3');
+ db.prepare("INSERT INTO journal_record VALUES (1,'2026-10-08T10:00:00.000Z','move',?,'agent','202',?)").run(Buffer.from(JSON.stringify(recorded)), legacyReviewer);
+ db.prepare("INSERT INTO journal_head VALUES (1,1,'2026-10-08T10:00:00.000Z')").run();
+ db.close();
+ const journal = createRelayJournal({ directory, boardId });
+ const [record] = journal.after();
+ journal.close();
+ assert.deepEqual(record.sender, { kind: 'agent', userId: '202', agent: legacyReviewer }, `the engine-${engine} record gains no stamp`);
+ assert.equal(record.registration, undefined);
+ assert.deepEqual(JSON.parse(record.bytes.toString('utf8')), recorded, 'its move bytes are unchanged');
+ const fresh = store.openBoard(':memory:');
+ t.after(() => store.closeBoard(fresh));
+ const stamped = applyRelayMove(fresh, recorded, { sequence: 1, at: record.receivedAt, kind: 'move',
+ sender: { ...record.sender, policy: VERIFIER_STANDING_ENGINE } });
+ assert.equal(stamped.error?.code, 'ENGINE_VERSION', 'a newly stored record cannot claim an old engine');
+ const replayed = applyRelayMove(historical, JSON.parse(record.bytes.toString('utf8')), { sequence: 1, at: record.receivedAt, kind: record.kind, sender: record.sender });
+ assert.equal(replayed.error, undefined, `the engine-${engine} verdict replays with its old rules`);
+ assert.equal(replayed.result.decision, 'ACCEPT');
+ });
+
+ await t.test('an unlinked board verifies exactly as before', (t) => {
+ const local = store.openBoard(':memory:');
+ t.after(() => store.closeBoard(local));
+ store.register(local, { lane: 'coordinator', path: '/repo' });
+ const localBuilder = store.register(local, { lane: 'web', path: '/repo-web-1', createdBy: 'machine' });
+ const localReviewer = store.register(local, { lane: 'web', path: '/repo-web-2', createdBy: 'machine' });
+ const item = submitted(local, localBuilder, 'web');
+ const result = store.verify(local, item.item_id, { agentId: localReviewer, decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'checked the proof',
+ head: 'd'.repeat(40), digest: item.item_frozen_digest, policy: 'any' });
+ assert.equal(result.decision, 'ACCEPT', 'an existing seat verifies another builder\'s item with no standing check');
+ assert.equal(store.reviewOffer(local, { agentId: localReviewer, lane: 'web', ratio: 0 }), null, 'nothing left to review');
+ });
+});