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
Merge origin/main into core/579-claude; engine 13 moves to 20 [H2,V1]
Corey Olsona38a19fa9e75
diff --cc docs/api.mdindex 17fe40b9,822eacaf..b48adce8--- a/docs/api.md+++ b/docs/api.md@@@ -191,15 -199,7 +199,15 @@@ Only the coordinator sets or edits an iPhone enrollment uses a one-use `#device=<locator>.<secret>` fragment, removed before sign-in. The secret remains on the phone and Mac. Person-authenticated `/api/v1/devices/session` returns the current account id. `/api/v1/devices/enrollments/:locator` supports POST `{}` to start a ten-minute locator, PUT of the exact public enrollment and MAC, GET of `{version, enrollment}` and DELETE to consume it. A native Mac checks the MAC locally before retaining any recipient. `/api/v1/devices/:deviceId` supports POST `{}` to record an authenticated recipient and DELETE to revoke it. PUT `/api/v1/devices/:deviceId/boards/:boardId` stores `{engine, wrapped}`; GET `/api/v1/devices/:deviceId/boards` returns `{version, wraps: [{board, engine, wrapped}]}` filtered by current board access. `wrapped` is opaque base64url client ciphertext. Enrollment, device listing and direct revocation require a person session. A board-scoped machine credential can PUT only its own board wrap to an already enrolled device. Cookie writes require the exact configured Origin, and all responses are no-store. Device ids and grants belong to the authenticated GitHub account. Revoked ids cannot be registered or uploaded again.-`POST /auth/machines {board,machine}` requires a foreground person session and returns a `pm_` credential bound to that board and machine. This delegate can mint board-scoped `pa_` tokens through `/auth/tokens` and list only its board’s token ids and metadata. It cannot link a board, issue a machine credential, post a phone request, revoke another credential directly, or use person-only cookie endpoints. Agent tokens cannot mint any credential.+`POST /auth/machines {board,machine}` requires a foreground person session and returns a `pm_` credential bound to that board and machine. This delegate can list only its board’s token ids and metadata, and through `POST /auth/tokens {board,agent}` it first-mints a `pa_` token only for a seat the relay never issued a token to, including after that token expired or was revoked (`TOKEN_EXISTS` otherwise). Such a seat (a manual `pullboard join`, or any name minted ahead) is machine-origin for good: it builds, never verifies on a linked board, and its name cannot later be registered (`SEAT_TAKEN`). The native client also checks that the seat is registered, which the relay cannot see. It cannot link a board, issue a machine credential, post a phone request, revoke another credential directly, or use person-only cookie endpoints.+- A `pa_` token renews only its own seat: `POST /auth/tokens {board,agent}` naming itself returns a new token and revokes the one that asked (`TOKEN_AGENT` for any other seat). A seat's first token from another seat comes only with the move that registers it: `POST /api/v1/boards/:board/moves {sequence, sealed, registration}`, sent with the creating seat's token, where `registration` is `{target, creator, sequence, digest}` (the creator is the sender, the sequence is this upload's, and the digest is the SHA-256 of the `sealed` text). The relay appends the move and issues the target's first token in one board lock and returns it only in that reply as `enrollment`; the public event carries the receipt and never the token. An exact retry returns the same issuance id and expiry without a token. The receipt commits in the same journal transaction as the move and is kept through compaction, and it claims the target from that moment: the machine credential and a person are refused a first mint for any name a receipt claims, under the same board lock that appends receipts, so no failure between the append and the enrollment leaves a window. If enrollment fails after the append, the creator's exact retry, or its `recover:true` reissue, rolls the first mint forward from the journalled receipt. A lost token is reissued by its creator, `POST /auth/tokens {board,agent,recover:true}` with the creator's token, which revokes the old ones. `/auth/tokens` refuses a `registration` field (`REGISTRATION_IN_MOVE`), so a copied receipt never mints. Replicas apply an engine-13 registration by another seat only with the receipt that names its target, creator, position and digest, so the board's record of who created a seat matches the relay's.++A `pa_` token renews only its own seat: `POST /auth/tokens {board,agent}` naming itself returns a new token and revokes the one that asked (`TOKEN_AGENT` for any other seat). A seat's first token from another seat comes only with the move that registers it: `POST /api/v1/boards/:board/moves {sequence, sealed, registration}`, sent with the creating seat's token, where `registration` is `{target, creator, sequence, digest}` (the creator is the sender, the sequence is this upload's, and the digest is the SHA-256 of the `sealed` text). The relay appends the move and issues the target's first token in one board lock and returns it only in that reply as `enrollment`; the public event carries the receipt and never the token. An exact retry returns the same issuance id and expiry without a token. The receipt commits in the same journal transaction as the move and is kept through compaction, and it claims the target from that moment: the machine credential and a person are refused a first mint for any name a receipt claims, under the same board lock that appends receipts, so no failure between the append and the enrollment leaves a window. If enrollment fails after the append, the creator's exact retry, or its `recover:true` reissue, rolls the first mint forward from the journalled receipt. A lost token is reissued by its creator, `POST /auth/tokens {board,agent,recover:true}` with the creator's token, which revokes the old ones. `/auth/tokens` refuses a `registration` field (`REGISTRATION_IN_MOVE`), so a copied receipt never mints. Replicas apply an engine-20 registration by another seat only with the receipt that names its target, creator, position and digest, so the board's record of who created a seat matches the relay's.++`POST /auth/coordinators {board}` takes a person session only and issues the coordinator's token: the first one (`bootstrap`), a fresh one after loss, expiry or revocation (`reissue`), or the person's reset of a coordinator first minted by the machine (`reset`). It revokes every older coordinator token. `pullboard relay on` calls it inside its own sign-in, so a board needs no extra tap. `GET /auth/tokens` also returns `coordinatorEvents`, each with its reason, the person session id, the revoked token ids, the issued id and the time; `pullboard relay tokens` prints them.+- On a linked board, an engine-13 verdict, review reservation or review offer needs verifier standing: the verifier was enrolled through the relay by its creator, each creator up the line was too, the line ends at the coordinator, and neither the builder nor a machine join is on it. The coordinator stands on the token the person set up. A seat without standing is refused with `VERIFIER_STANDING` in one line that names the fix, `pullboard worktree <lane> --model "<model name>"` run by the coordinator from the main checkout. Seats from before engine 13, or from before the board was linked, keep building; reviews need a fresh seat made that way. Each person-made coordinator token carries a machine lineage (a reissue that replaces a token keeps it; another machine's token starts its own), and a seat enrolled from it, or from a seat in its line, records that lineage. A coordinator claim records the lineage of the machine that builds it. When the coordinator built an item, a seat from another machine's registration lineage, or the person, verifies it; a seat from the building machine's own lineage is refused and told so. On an unlinked board who may verify is unchanged. The relay stamps each record it stores with `policy` (and `root` for the person-made coordinator token); a stamped record below engine 13 is refused, older unstamped records replay as they did, and a board with machine or agent credentials requires engine 13.++On a linked board, an engine-20 verdict, review reservation or review offer needs verifier standing: the verifier was enrolled through the relay by its creator, each creator up the line was too, the line ends at the coordinator, and neither the builder nor a machine join is on it. The coordinator stands on the token the person set up. A seat without standing is refused with `VERIFIER_STANDING` in one line that names the fix, `pullboard worktree <lane> --model "<model name>"` run by the coordinator from the main checkout. Seats from before engine 20, or from before the board was linked, keep building; reviews need a fresh seat made that way. Each person-made coordinator token carries a machine lineage (a reissue that replaces a token keeps it; another machine's token starts its own), and a seat enrolled from it, or from a seat in its line, records that lineage. A coordinator claim records the lineage of the machine that builds it. When the coordinator built an item, a seat from another machine's registration lineage, or the person, verifies it; a seat from the building machine's own lineage is refused and told so. On an unlinked board who may verify is unchanged. The relay stamps each record it stores with `policy` (and `root` for the person-made coordinator token); a stamped record below engine 20 is refused, older unstamped records replay as they did, and a board with machine or agent credentials requires engine 20.++Residual: tokens on disk, in the repository's shared `relay.json`, are readable by every process of the same operating-system user, so a process that reads another seat's current `pa_` can act as that seat and renew it; signed moves (#408) close that. An agent holding the machine credential can still make a seat of its own, by a manual join or by minting a never-issued name, which also makes a creator skip that name. That seat cannot verify that agent's work, nor any work on a linked board, and cannot act as any existing seat. A sealed snapshot uploaded with the machine credential remains a trusted checkpoint for replicas that restore from it.A machine publishes an opaque approval with `POST /api/v1/devices/approvals {context,sealed}`. The publishing machine may GET only its own requests. The paired phone reads `/api/v1/devices/:deviceId/approvals`, explicitly POSTs `/:requestId/authorize {}` and completes the encrypted reply through `/:requestId/complete {response}`. The publishing machine executes a native revocation through `/:requestId/execute {grant}`; the two-minute grant binds the entire context and is atomically consumed once. Native reply keys and grants never persist. A refused foreground approval fails immediately with the original refusal code and reason plus its request id. A refused remote approval makes local unlinking or registration exit nonzero while retaining the completed local work: one line names that completion, the refusal code and reason, the request id and the next action. The JSON result preserves the local outcome and includes `remote: {code, reason, requestId}`. New-board linking uses a durable non-person reply key and returns only a board-scoped machine credential. `relay off` immediately unlinks locally even offline or in an agent shell, reports that the relay copy remains, and queues a separate one-tap phone deletion request when possible.diff --cc docs/formats.mdindex 004c70af,56cc62a3..0469c8d8--- a/docs/formats.md+++ b/docs/formats.md@@@ -102,7 -102,7 +102,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` | `13` | `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` | `19` | `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` | `20` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |<!-- format-versions:end -->Pullboard 0.6.1 released engine 1. Engine 2 records a fresh explicit-build claim's skipped-review snapshot. Pullboard 0.8.1 released engine 3, including lane-sensitive graft refusals and authenticated relay senders. Engine 4 adds captured background-baseline completions through `completeCheckBaseline`; released engine-3 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Engine 5 requires a one-line reason when releasing a review and gives that reviewer a one-hour cooldown for the current submission. Each sealed move replays under its recorded engine version: engines 1 through 4 retain the original release event and review-reservation behavior. Engine 5 retains support for older moves, including engine-4 baseline completions. Pullboard 0.8.3 released engine 6, adding board-scoped machine credentials and permitting machine execution only for one exact, earlier authenticated phone request, including its payload digest. Engine 7 adds ordered item holds through `holdItem` and `releaseItemHold`; engine-6 clients stop with `ENGINE_VERSION` before interpreting either operation or advancing their replay cursor. Engine 8, shared by the 0.8.5 move changes, retains merged-item exception notes, selects the next review in roadmap order, and adds coordinator-only `reopen` for a submission returned without a verdict; engine-7 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Recorded engines 1 through 7 retain their original tier-first review selection. Engine 8 also adds durable refusal recovery for blocked relay positions; each explicit skip publishes the readable prefix even when another unsupported record follows. Engine 8 also permits coordinator criterion/check edits on a live claim as pending corrections; the holder cannot renew or submit until a refreeze adopts the correction while preserving the claim. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new moves. Each release shares one engine bump across its changed moves. Engine 8 also retains declared model labels on registration and records each registered agent move's model snapshot; engines 1 through 7 retain their original registration and event details without these model fields. Pullboard 0.8.8 released engine 9, which allows resubmitting the same rejected commit after a corrected criterion is refrozen, but only when the rejection names a different frozen digest. Engine 8 retains its HEAD_NOT_NEW refusal and prior submit-event detail. Engine-9 submit events add `criterionDigest`, and engine-8 boards replay with the original refusal and event history.@@@ -113,11 -113,11 +113,13 @@@ Engine 11 permits resubmitting the samEngine 12 records declined person row decisions without replacing the exact source text: the row becomes `wont` and the reason stays in the decision record. Engine-11 decline receipts retain their original reason-as-row-text validation and replay outcome. Engine-11 clients refuse engine-12 moves before interpreting them; upgrade linked clients before recording new decline decisions.- Engine 13 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: 13`; a stamped move below engine 13 is refused. Engine-12 and older moves, and unstamped records, replay as they did. On an unlinked board who may verify is unchanged.+ Engine 19 makes a corrected bar record why the old one was wrong. Once an item has ever been claimed, an `editItem` that changes its criterion or check must carry `reason`, the text of what the old bar got wrong; without one it is refused with `BAR_REASON`, naming `--reason`. The edit event then records `reason` and `barCorrection: {fields, reject}`: `fields` lists `criterion` and/or `check`, and `reject` is `{verdict, by, reason, at}` when the item's newest verdict is a reject no earlier correction already explained, or `null`. That reject is counted as caused by the bar. The board derives `barCorrection` from its own rows; a move supplies only `reason`. An edit before any claim needs no reason and records one only if given. `pullboard stats` JSON adds `bars`, keyed by agent: `{corrections, barRejects, buildRejects}`. Corrections and the rejects they explain count to the agent who corrected the bar; any other reject counts as the build's, to the agent who added the item. An `editItem` move carrying `reason` requires engine 19, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor. Moves recorded under engines 18 and earlier replay without the reason rule. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.+++Engine 20 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: 20`; a stamped move below engine 20 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 13 after issuing any agent token or machine credential, including- revoked or expired ones; before engine 13 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 20 after issuing any agent token or machine credential, including++revoked or expired ones; before engine 20 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 legacyengine 1. Board-content requests below their minimum, and malformed declarations,receive `ENGINE_VERSION` with upgrade guidance before records are returned ordiff --cc docs/lifecycle.mdindex 54d1105a,4d6325e6..2bfdfca9--- a/docs/lifecycle.md+++ b/docs/lifecycle.md@@@ -134,8 -134,7 +134,8 @@@ Each move checks its guards in this ord| 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 13 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 13 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 20 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 20 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.jsindex 5299b728,1a1ba65d..b14b2e26--- a/relay/auth.js+++ b/relay/auth.js@@@ -544,8 -501,7 +544,8 @@@ export function createRelayAuth({ databminimumEngineVersion(board) {open();identifier(board, 'BAD_BOARD');- // Machine and agent credentials now carry engine-13 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-20 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 relay/journal.jsindex 83ebb056,57e1dd51..cd85ab0c--- a/relay/journal.js+++ b/relay/journal.js@@@ -71,15 -71,6 +71,15 @@@ export function createRelayJournal({ diDROP TABLE journal_snapshot_v2;UPDATE journal_meta SET value='3' WHERE key='format';`);}- // Engine-13 attribution (#579): the relay's policy stamp, the person-set coordinator flag and a++ // Engine-20 attribution (#579): the relay's policy stamp, the person-set coordinator flag and a+ // seat receipt. Older records keep these empty, so they replay exactly as they did.+ for (const [column, type] of [['sender_policy', 'INTEGER'], ['sender_root', 'INTEGER'], ['sender_lineage', 'TEXT'], ['registration', 'TEXT']]) {+ if (!db.prepare('PRAGMA table_info(journal_record)').all().some((saved) => saved.name === column)) db.exec(`ALTER TABLE journal_record ADD COLUMN ${column} ${type}`);+ }+ // A published seat receipt claims its target for good: compaction keeps it, so no later machine+ // first mint can take a name a creator registered, even if enrollment never finished (#579).+ db.exec(`CREATE TABLE IF NOT EXISTS journal_registration (target TEXT PRIMARY KEY, creator TEXT NOT NULL,+ sequence INTEGER NOT NULL UNIQUE, digest TEXT NOT NULL)`);db.exec('INSERT OR IGNORE INTO journal_head (slot,sequence) SELECT 1, COALESCE(MAX(sequence),0) FROM journal_record');if (!db.prepare('PRAGMA table_info(journal_head)').all().some((column) => column.name === 'last_activity_at')) {db.exec('ALTER TABLE journal_head ADD COLUMN last_activity_at TEXT');diff --cc src/board.jsindex 8426c9de,090581bb..359ef9b1--- a/src/board.js+++ b/src/board.js@@@ -13,14 -13,11 +13,15 @@@ import { DatabaseSync } from 'node:sqliimport { 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 { barCorrectionFields } from './bar-corrections.js';import { parseSpec } from './spec.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';@@@ -506,19 -535,12 +507,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 13 a new seat records the seat that created it (`createdBy`: an agent id, or++ * From engine 20 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.jsindex b0f18f3b,c82f9c03..ea93e997--- a/src/cli.js+++ b/src/cli.js@@@ -574,12 -576,6 +576,12 @@@ function withBoard(ctx, work)/** Dispatch a board mutation locally, or seal it before any linked replica applies it. */async function ordered(ctx, board, operation, args) {- // Every engine-13 registration records the seat that made it: the coordinator from the main++ // Every engine-20 registration records the seat that made it: the coordinator from the main+ // checkout, the joined agent from its worktree, or `machine` for a join no seat made (#579).+ if (operation === 'register' && args[0] && args[0].createdBy === undefined) {+ const joined = store.agentAt(board, ctx.info.root)?.agent_id;+ args = [{ ...args[0], createdBy: ctx.info.isMain ? COORDINATOR : joined ?? 'machine' }, ...args.slice(1)];+ }const command = ['add', 'edit', 'merged'].includes(ctx.io.relayCommand?.cliOperation) ? ctx.io.relayCommand : undefined;/** Dispatch while this session holds the checkout, including long-running next/run loops. */const execute = () => relayLinked(ctx.info.root)@@@ -2638,10 -2644,8 +2650,10 @@@ async function nextOnce(ctx, values)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 held = item?.item_status === 'claimed';- /** Offer only reviews this seat may give; a linked board previews its engine-13 verifier standing (#579). */- 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-20 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 && !helddiff --cc src/engine.jsindex adeeae49,8f1c9ca0..f497174a--- a/src/engine.js+++ b/src/engine.js@@@ -1,9 -1,9 +1,10 @@@/** Versioned, deterministic replay through the CLI's existing board engine [H3,H16]. */import { createHash, randomUUID } from 'node:crypto';import * as store from './board.js';+import { COORDINATOR } from './config.js';import { recordedRefusal } from './recorded-refusal.js';+ import { BAR_ENGINE, carriesBarReason } from './bar-corrections.js';-import { ENGINE_VERSION } from './machine.js';+import { 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';@@@ -180,50 -181,12 +182,50 @@@ export function refuseRelayMove(board,});}+/**- * Bind an engine-13 registration to the relay's receipt (#579). A seat made by another seat names++ * Bind an engine-20 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-13 relay moves run under linked verifier standing; older recorded moves replay as they did.++ // Engine-20 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.jsindex 8b7bd1b9,bbd1cfb9..f31104e5--- a/src/machine.js+++ b/src/machine.js@@@ -10,13 -10,7 +10,13 @@@*//** Executable move semantics, carried by every sealed move and retained during replay [H16]. */- export const ENGINE_VERSION = 13;-export const ENGINE_VERSION = 19;++export const ENGINE_VERSION = 20;++/**+ * 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 = 13;++export const VERIFIER_STANDING_ENGINE = 20;/** @typedef {'agent' | 'coordinator' | 'clock'} Role */@@@ -135,7 -129,7 +135,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 13 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 20 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/seats.jsindex 0767f392,00000000..65ea3ac7mode 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 13 the seat that created it, whether++ * metadata kept beside it: its model, its route, and from engine 20 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-13 registration gives a new seat: the named one when it is the lane's form and++ * The id an engine-20 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-13 registration recorded it: an agent id,- * `machine` for a join no seat made, or null for a seat registered before engine 13.++ * The seat that created this one, as its engine-20 registration recorded it: an agent id,++ * `machine` for a join no seat made, or null for a seat registered before engine 20.+ *+ * @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-13 move, or a linked CLI previewing one. `root` says whether the acting coordinator's++ * engine-20 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 13 anywhere on the way means no standing. The coordinator++ * or a seat registered before engine 20 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.jsindex 3c1e9e62,ba92a56d..2c84af92--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@@ -10,9 -10,9 +10,9 @@@ import { mkdtempSync, rmSync, writeFileimport { tmpdir } from 'node:os';import { join } from 'node:path';- test('model declarations and event snapshots retain engines 1 through 12 semantics [O8,O3,H16]', (t) => {- assert.equal(ENGINE_VERSION, 13, 'engine 13 preserves the released engine-8 through engine-12 model behavior');- for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ENGINE_VERSION]) {-test('model declarations and event snapshots retain engines 1 through 11 semantics [O8,O3,H16]', (t) => {- assert.equal(ENGINE_VERSION, 19, 'engine 19 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 and 19 semantics [O8,O3,H16]', (t) => {++ assert.equal(ENGINE_VERSION, 20, 'engine 20 preserves the released engine-8 through engine-19 model behavior');++ for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 19, 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.jsindex fc90d13d,7191bfc2..603c8539--- a/test/pending-refreeze.test.js+++ b/test/pending-refreeze.test.js@@@ -243,12 -243,12 +243,12 @@@ async function checkDependencyLegacyCliconst 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 13 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 20 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 13 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 20 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 13 retain the same dependency-move receipts');- 'engine 10 and engine 12 retain the same dependency-move receipts');++ 'engine 10 and engine 20 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, 13);- assert.equal(ENGINE_VERSION, 19);++ assert.equal(ENGINE_VERSION, 20);const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));const cleanup = [];t.after(() => {diff --cc test/relay-deploy.test.jsindex a7537604,39cd8655..5ad81332--- a/test/relay-deploy.test.js+++ b/test/relay-deploy.test.js@@@ -291,7 -291,7 +291,7 @@@ test('[H5,H18] the Railway checklist matest('[H5,H18] the Railway smoke links, reads one unsealed move and unlinks locally', async (t) => {const box = await relayClientFixture(t);await box.link();- assert.equal(await box.requireEngineThree(), 13, 'a machine-linked board requires the engine-13 seat-provenance replay engine');- assert.equal(await box.requireEngineThree(), 6, 'a machine-linked board requires the machine-aware replay engine');++ assert.equal(await box.requireEngineThree(), 20, 'a machine-linked board requires the engine-20 seat-provenance replay engine');const previous = JSON.parse(readFileSync(box.linkFile, 'utf8'));const legacy = await fetch(`${previous.url}/api/v1/boards/${previous.board}/state`, {headers: { authorization: `Bearer ${previous.token}`, 'x-pullboard-engine': '2' },diff --cc test/relay-machine-auth.test.jsindex b7715248,96b6aaa0..6f495238--- a/test/relay-machine-auth.test.js+++ b/test/relay-machine-auth.test.js@@@ -57,7 -57,7 +57,7 @@@ test('machine credentials mint and lisassert.equal(tokens.some(value => Object.hasOwn(value, 'token') || Object.hasOwn(value, 'hash')), false);await assert.rejects(auth.listTokens(machine.token, beta), { code: 'TOKEN_BOARD' });await assert.rejects(auth.issueToken(machine.token, { board: beta, agent: 'cross-board' }), { code: 'TOKEN_BOARD' });- assert.equal(auth.minimumEngineVersion(alpha), 13, 'machine and agent credentials require engine 13 (#579)');- assert.equal(auth.minimumEngineVersion(alpha), 6);++ assert.equal(auth.minimumEngineVersion(alpha), 20, 'machine and agent credentials require engine 20 (#579)');await assert.rejects(auth.listTokens(agent.token, alpha), { code: 'HUMAN_REQUIRED' });await assert.rejects(auth.revoke(machine.token, agent.id), { code: 'TOKEN_NOT_OWNED' });diff --cc test/relay-mint.test.jsindex 9f60d46f,00000000..b24718a7mode 100644,000000..100644--- a/test/relay-mint.test.js+++ b/test/relay-mint.test.js@@@ -1,366 -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-13 relay move from an agent on the linked board copy. */++ /** Replay one stamped engine-20 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');+ });+- for (const engine of [11, 12]) await t.test(`an engine-${engine} journal replays as before`, (t) => {++ // 19 is main's engine before #579 (bar corrections, #470); its journals replay as they did too.++ for (const engine of [11, 12, 19]) 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');+ });+});diff --cc test/relay-retention.test.jsindex c8641e07,b2601ed0..c0d2dbb8--- a/test/relay-retention.test.js+++ b/test/relay-retention.test.js@@@ -60,7 -60,7 +60,7 @@@ async function fixture(t)/** Return status/body without ever placing credentials in diagnostic text or URLs. */async function call(id, { path = '/state', method = 'GET', token = signed.token, body } = {}) {const response = await fetch('http://127.0.0.1:' + relay.port + '/api/v1/boards' + (id ? '/' + id + path : ''), {- method, headers: { 'x-pullboard-engine': '13', authorization: 'Bearer ' + token, ...(body ? { 'content-type': 'application/json' } : {}) },- method, headers: { 'x-pullboard-engine': '3', authorization: 'Bearer ' + token, ...(body ? { 'content-type': 'application/json' } : {}) },++ method, headers: { 'x-pullboard-engine': '20', authorization: 'Bearer ' + token, ...(body ? { 'content-type': 'application/json' } : {}) },...(body ? { body: JSON.stringify(body) } : {}),});return { status: response.status, body: await response.json() };@@@ -88,7 -88,7 +88,7 @@@ test('[H18] warnings begin at sixty daywarningTimeout.unref();t.after(() => { clearTimeout(warningTimeout); controller.abort(); });const stream = await fetch('http://127.0.0.1:' + box.relay.port + '/api/v1/boards/' + A + '/events?after=0', {- headers: { 'x-pullboard-engine': '13', authorization: 'Bearer ' + box.signed.token, accept: 'text/event-stream' }, signal: controller.signal,- headers: { 'x-pullboard-engine': '3', authorization: 'Bearer ' + box.signed.token, accept: 'text/event-stream' }, signal: controller.signal,++ headers: { 'x-pullboard-engine': '20', authorization: 'Bearer ' + box.signed.token, accept: 'text/event-stream' }, signal: controller.signal,});const reader = stream.body.getReader();let delivered = '';diff --cc test/relay-sealed.test.jsindex 02ffe84c,2dbaa441..cfbbf8b2--- a/test/relay-sealed.test.js+++ b/test/relay-sealed.test.js@@@ -1196,10 -1194,9 +1196,10 @@@ test('checkpoint restore checks native}});-test('relay accepts engine 4 clients carrying sealed background completions [V2,H16]', async t => {+test('relay stores engine-4 sealed background completions opaquely [V2,H16]', async t => {const box = await fixture(t, { machineCredentials: false });- // A board with agent tokens requires an engine-13 client (#579); the sealed move keeps engine 4.- const headers = { 'x-pullboard-engine': '4' };++ // A board with agent tokens requires an engine-20 client (#579); the sealed move keeps engine 4.+ const headers = { 'x-pullboard-engine': String(ENGINE_VERSION) };assert.ok(ENGINE_VERSION >= 4, 'engine-4 background completions remain supported');const snapshot = await box.call(box.path + '/state', {method: 'PUT', token: box.person.token, headers,diff --cc test/relay-version.test.jsindex 5f31771a,efac9635..2a2b663b--- a/test/relay-version.test.js+++ b/test/relay-version.test.js@@@ -28,10 -28,10 +28,10 @@@ test('relay enforces the minimum enginawait auth.revoke(person.token, historical.id);time += 10;assert.equal(auth.minimumEngineVersion(A), 1);- assert.equal(auth.minimumEngineVersion(B), 13, 'agent tokens now require engine 13 (#579)');- assert.equal(auth.minimumEngineVersion(B), 3);++ assert.equal(auth.minimumEngineVersion(B), 20, 'agent tokens now require engine 20 (#579)');auth.close();auth = createRelayAuth(authConfig);- assert.equal(auth.minimumEngineVersion(B), 13, 'the minimum survives revocation, expiry and reopening the real auth database');- assert.equal(auth.minimumEngineVersion(B), 3, 'the minimum survives revocation, expiry and reopening the real auth database');++ assert.equal(auth.minimumEngineVersion(B), 20, 'the minimum survives revocation, expiry and reopening the real auth database');const relay = await serveRelay({ directory: join(directory, 'data'), auth, maintenanceMs: 0, pollMs: 10 });t.after(async () => { await relay.close(); auth.close(); rmSync(directory, { recursive: true, force: true }); });const base = `http://127.0.0.1:${relay.port}/api/v1/boards/`;@@@ -48,19 -48,19 +48,19 @@@}// Seed opaque snapshots so eligible reads reach actual state and event handlers.for (const board of [A, B]) {- const seeded = await call(board, '/state', { engine: 13, method: 'PUT', body: JSON.stringify({ sequence: 0, sealed: opaque }) });- const seeded = await call(board, '/state', { engine: 3, method: 'PUT', body: JSON.stringify({ sequence: 0, sealed: opaque }) });++ const seeded = await call(board, '/state', { engine: 20, method: 'PUT', body: JSON.stringify({ sequence: 0, sealed: opaque }) });assert.equal(seeded.status, 200, seeded.text);}for (const board of [A, B]) {- const currentState = await call(board, '/state', { engine: 13 });- const currentState = await call(board, '/state', { engine: 3 });++ const currentState = await call(board, '/state', { engine: 20 });assert.equal(currentState.status, 200, currentState.text);- assert.equal((await call(board, '/events?after=0', { engine: 13 })).status, 200);- assert.equal((await call(board, '/events?after=0', { engine: 3 })).status, 200);++ assert.equal((await call(board, '/events?after=0', { engine: 20 })).status, 200);}for (const board of [A, B]) {const controller = new AbortController();const streamed = await fetch(base + board + '/events?after=0', {- headers: { authorization: `Bearer ${person.token}`, 'x-pullboard-engine': '13', accept: 'text/event-stream' }, signal: controller.signal,- headers: { authorization: `Bearer ${person.token}`, 'x-pullboard-engine': '3', accept: 'text/event-stream' }, signal: controller.signal,++ headers: { authorization: `Bearer ${person.token}`, 'x-pullboard-engine': '20', accept: 'text/event-stream' }, signal: controller.signal,});assert.equal(streamed.status, 200);await streamed.body.cancel(); controller.abort();diff --cc test/relay.test.jsindex 7a1db5cf,97c8b885..bd81c380--- a/test/relay.test.js+++ b/test/relay.test.js@@@ -823,7 -823,7 +823,7 @@@ test('revoking a board credential whilconst origin = `http://127.0.0.1:${service.port}`;const snapshot = await fetch(`${origin}/api/v1/boards/${board}/state`, {method: 'PUT',- headers: { 'x-pullboard-engine': '13', authorization: `Bearer ${person.token}`, 'content-type': 'application/json' },- headers: { 'x-pullboard-engine': '3', authorization: `Bearer ${person.token}`, 'content-type': 'application/json' },++ headers: { 'x-pullboard-engine': '20', authorization: `Bearer ${person.token}`, 'content-type': 'application/json' },body: JSON.stringify({ sequence: 0, sealed: 'AQ' }),});assert.equal(snapshot.status, 200);@@@ -843,7 -843,7 +843,7 @@@let stream;const upload = fetch(`${origin}/api/v1/boards/${board}/moves`, {method: 'POST',- headers: { 'x-pullboard-engine': '13', authorization: `Bearer ${agent.token}`, 'content-type': 'application/json' },- headers: { 'x-pullboard-engine': '3', authorization: `Bearer ${agent.token}`, 'content-type': 'application/json' },++ headers: { 'x-pullboard-engine': '20', authorization: `Bearer ${agent.token}`, 'content-type': 'application/json' },body: new ReadableStream({ start(controller) { stream = controller; controller.enqueue(Buffer.from('{"sequence":1,"sealed":"')); } }),duplex: 'half',});@@@ -859,7 -859,7 +859,7 @@@assert.equal(response.status, 401, JSON.stringify(refusal));assert.equal(refusal.error.code, 'AUTH_REQUIRED');const events = await fetch(`${origin}/api/v1/boards/${board}/events?after=0`, {- headers: { 'x-pullboard-engine': '13', authorization: `Bearer ${person.token}` },- headers: { 'x-pullboard-engine': '3', authorization: `Bearer ${person.token}` },++ headers: { 'x-pullboard-engine': '20', authorization: `Bearer ${person.token}` },});assert.equal(events.status, 200);assert.deepEqual((await events.json()).events, [], 'the revoked upload never appends a move');@@@ -880,7 -880,7 +880,7 @@@ test('revoking a person token during snconst origin = `http://127.0.0.1:${service.port}`;const firstSnapshot = await fetch(`${origin}/api/v1/boards/${board}/state`, {method: 'PUT',- headers: { 'x-pullboard-engine': '13', authorization: `Bearer ${person.token}`, 'content-type': 'application/json' },- headers: { 'x-pullboard-engine': '3', authorization: `Bearer ${person.token}`, 'content-type': 'application/json' },++ headers: { 'x-pullboard-engine': '20', authorization: `Bearer ${person.token}`, 'content-type': 'application/json' },body: JSON.stringify({ sequence: 0, sealed: 'AQ' }),});assert.equal(firstSnapshot.status, 200);@@@ -900,7 -900,7 +900,7 @@@let stream;const upload = fetch(`${origin}/api/v1/boards/${board}/state`, {method: 'PUT',- headers: { 'x-pullboard-engine': '13', authorization: `Bearer ${person.token}`, 'content-type': 'application/json' },- headers: { 'x-pullboard-engine': '3', authorization: `Bearer ${person.token}`, 'content-type': 'application/json' },++ headers: { 'x-pullboard-engine': '20', authorization: `Bearer ${person.token}`, 'content-type': 'application/json' },body: new ReadableStream({ start(controller) { stream = controller; controller.enqueue(Buffer.from('{"sequence":0,"sealed":"')); } }),duplex: 'half',});@@@ -916,7 -916,7 +916,7 @@@assert.equal(response.status, 401, JSON.stringify(refusal));assert.equal(refusal.error.code, 'AUTH_REQUIRED');const current = await fetch(`${origin}/api/v1/boards/${board}/state`, {- headers: { 'x-pullboard-engine': '13', authorization: `Bearer ${observer.token}` },- headers: { 'x-pullboard-engine': '3', authorization: `Bearer ${observer.token}` },++ headers: { 'x-pullboard-engine': '20', authorization: `Bearer ${observer.token}` },});assert.equal(current.status, 200);const saved = await current.json();