Skip to content

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

fix(relay): advance verifier standing to engine 48 [H2,V1,H16]

Corey Olson7cc1751d6a60
diff --cc docs/api.md
index e0378491,f857fb6a..70c9a10f
--- a/docs/api.md
+++ b/docs/api.md
@@@ -281,15 -281,7 +281,15 @@@ Only the coordinator sets or edits an i
Phone 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,host?}` requires a foreground person session and returns a `pm_` credential bound to that board and machine; `relay join` sends its host name as `host`. `GET /api/v1/devices/<deviceId>` with a board's `pm_` credential returns `{version, seen, revoked}` for a phone of the same account, with null fields for an unknown id. `GET /api/v1/devices` with that credential returns `{version, devices: [{deviceId, seen, revoked}]}` for the phones holding that board's key, by id only; names stay on the computer that paired them. 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,host?}` requires a foreground person session and returns a `pm_` credential bound to that board and machine; `relay join` sends its host name as `host`. `GET /api/v1/devices/<deviceId>` with a board's `pm_` credential returns `{version, seen, revoked}` for a phone of the same account, with null fields for an unknown id. `GET /api/v1/devices` with that credential returns `{version, devices: [{deviceId, seen, revoked}]}` for the phones holding that board's key, by id only; names stay on the computer that paired them. 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-35 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-48 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-35 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 35, 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 35 is refused, older unstamped records replay as they did, and a board with machine or agent credentials requires engine 35.
++On a linked board, an engine-48 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 48, 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 48 is refused, older unstamped records replay as they did, and a board with machine or agent credentials requires engine 48.
+
+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.
`GET /auth/machines?board=<id>` returns `{version, machines: [{machine, host, created, seen}]}` for the live computer credentials on that board, with duplicate computer ids listed once. `host` is the host name the computer sent when it joined, or null; `created` is its first join and `seen` its last relay contact, which moves at most once a minute. It requires that board's machine credential or a person session with current repository write access; agent tokens and credentials from another board are refused. `relay off` excludes its own computer from the list and warns which joined computers lose the shared copy if the phone approves deletion. The warning names each computer by its host name, or by the end of its id when the relay has no host for it. JSON also returns those ids in `affectedMachines` and the names in `joined`. Local unlink still succeeds when the relay cannot supply the list.
diff --cc docs/formats.md
index 6690d81c,383421b8..2ec011c3
--- a/docs/formats.md
+++ b/docs/formats.md
@@@ -113,7 -113,7 +113,7 @@@ The board file is in the repository's G
| `row grammar` | `1` | `SPEC_GRAMMAR_VERSION` in `src/spec.js`; optional `<!-- pullboard-grammar N -->` line in either file (absence means the current grammar) | Both files share the version. A declared version must match; an incompatible grammar change requires a coordinated version bump and compatible files. No automatic conversion occurs. |
| `board schema` | `2` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | Create missing tables and indexes, add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. |
| `event log` | `1` | `EVENT_LOG_VERSION` in `src/board.js`, persisted in `board_meta` as `event_log_version` | Older event-log versions upgrade in place; newer versions are refused with `EVENT_LOG_VERSION`. Preserve event rows when the board schema changes. |
- | `move engine` | `42` | `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` | `43` | `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` | `48` | `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.
@@@ -134,15 -134,13 +134,15 @@@ Engine 24 adds the person's `acceptChec
Engine 30 lets a reject and a reopen carry a cause key (`cause`: `test:<file>::<title>`, `refusal:<CODE>`, `row:<id>` or `doctrine:<id>`) and lets the person record a never-again fact with `cause` and `neverAgain: true`, for `pullboard rigor`. Only a move that carries one of these needs engine 30; engine-29 and older moves replay unchanged, and clients on an older engine refuse an engine-30 move with `RELAY_MOVE` before changing their board or cursor. Engine 20 is the implied-items engine above; engine numbers 21 through 29 are allocated to other changes.
- Engine 35 records on each new seat the seat that created it (`createdBy`: an agent id, or `machine` for a join no seat made), lets a creator name the new seat (`id`), and applies verifier standing to relay-replayed verdicts, review reservations and offers on a linked board: the verifier's line of creating seats must reach the coordinator through seats enrolled by the relay, without the builder or a machine join. Replicas apply a register move by another seat only with the relay's receipt for its target, creator, position and digest. The relay stamps every record it stores with `policy: 35`; a stamped move below engine 35 is refused. Engine-12 and older moves, and unstamped records, replay as they did. On an unlinked board who may verify is unchanged.
++Engine 48 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: 48`; a stamped move below engine 48 is refused. Engine-12 and older moves, and unstamped records, replay as they did. On an unlinked board who may verify is unchanged.
+
Engine 38 records submission test selections and normalized landing evidence. A `submit` carrying `submissionProof` or a `recordLandingBatch` carrying `invariantEvidence` requires engine 38; earlier engines refuse these envelopes before applying them, and a missing or malformed proof is refused with `SUBMISSION_PROOF` on a modern submit before its item or events change. Moves recorded under engines 37 and earlier replay without inferred coverage. Recorded invariant evidence is append-only when a landing batch is adopted; adopting or finishing a batch already carrying that evidence requires engine 38, even when the incoming move omits the evidence field. Engine slots 25 through 37 are allocated to earlier train changes; preserve their semantics when composing this item.
Engine 42 adds ordered `recordHealthFindings` observations. A scan retains its board event revision, emits new and resolved sentinel notices once, and records `health-failure` receipts under their refusal cause keys. Rigor counts repeated health episodes without inventing a changed code commit. Older engines refuse this operation before replay; earlier move meanings and feature minima stay unchanged.
The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.
- A linked board requires at least engine 35 after issuing any agent token or machine credential, including
- revoked or expired ones; before engine 35 these minimums were 3 and 6. The minimum survives reopening the auth database;
-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 48 after issuing any agent token or machine credential, including
++revoked or expired ones; before engine 48 these minimums were 3 and 6. The minimum survives reopening the auth database;
unlink removes the board and ends its lifetime. A missing declaration is legacy
engine 1. Board-content requests below their minimum, and malformed declarations,
receive `ENGINE_VERSION` with upgrade guidance before records are returned or
diff --cc docs/lifecycle.md
index bc2f086c,8f5550ff..536f110f
--- a/docs/lifecycle.md
+++ b/docs/lifecycle.md
@@@ -147,8 -147,7 +147,8 @@@ Each move checks its guards in this ord
| DIRTY | a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check | commit the reviewed composition before re-reviewing |
| UNTRACKED | a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check | commit or ignore untracked files before re-reviewing |
| VERDICT_TRUNK_MOVED | a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check | merge the latest main and re-review the clean composition |
- | SELF_VERIFY | the caller did not build it; on a linked board, at engine 35 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | another agent verifies it: pullboard next --verify |
- | VERIFIER_STANDING | the caller did not build it; on a linked board, at engine 35 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | the coordinator makes an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>" |
-| 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 48 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 48 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 src/board.js
index d1a2b03a,d0a0f518..4958a6ee
--- a/src/board.js
+++ b/src/board.js
@@@ -43,16 -42,11 +43,21 @@@ import
storeTriggers,
} from './machine.js';
import { Refused } from './refused.js';
+import {
+ agentAt,
+ agentModel,
+ listAgents,
+ newSeatId,
+ routeOf,
+ saveAgentModel,
+ seatLineage,
+ standingProblem,
+} from './seats.js';
+ import {
+ newRigorNotices,
+ rigorNoticeText,
+ } from './rigor-notices.js';
+ import { RIGOR_NOTICE_ENGINE } from './rigor-source.js';
import {
causeProblem,
requireNeverAgain,
diff --cc src/machine.js
index 6df15633,d033948f..a33f6dce
--- a/src/machine.js
+++ b/src/machine.js
@@@ -10,15 -10,10 +10,15 @@@
*/
/** Executable move semantics, carried by every sealed move and retained during replay [H16]. */
- export const ENGINE_VERSION = 42;
-import { RIGOR_NOTICE_ENGINE } from './rigor-source.js';
-export const ENGINE_VERSION = RIGOR_NOTICE_ENGINE;
++export const ENGINE_VERSION = 48;
-/** The engine at which a reject, reopen or person fact can carry a cause key (#713); older moves replay unchanged [D1,H16]. */
+/**
+ * The engine whose relay moves carry seat provenance and verifier standing (#579). It is its own
+ * constant because engine slots are allotted per item: whoever lands second renumbers this line.
+ */
- export const VERIFIER_STANDING_ENGINE = 35;
++export const VERIFIER_STANDING_ENGINE = 48;
+
+/** The engine at which reject, reopen and person facts may carry cause keys [D1,H16]. */
export const CAUSE_ENGINE = 30;
/** First released engine binding the checked composition, review trunk and paths [E8,H16]. */
@@@ -148,7 -143,7 +148,7 @@@ export const GUARDS =
{ 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: 'verdictReviewRecorded', refuse: 'BAD_VERDICT_REVIEW', rule: 'a new review binds the submitted commit, its exact checked commit, a valid trunk commit and canonical candidate paths', next: 'restore the submitted Git objects and retry the review with current Pullboard', source: 'board' },
{ id: 'reviewTreeCurrent', refuse: 'STALE_VERDICT', alsoRefuses: [{ code: 'DIRTY', next: 'commit the reviewed composition before re-reviewing' }, { code: 'UNTRACKED', next: 'commit or ignore untracked files before re-reviewing' }, { code: 'VERDICT_TRUNK_MOVED', next: 'merge the latest main and re-review the clean composition' }], rule: 'a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check', next: 'merge current main into the submitted commit and re-review it', 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 35 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join', next: 'another agent verifies it: pullboard next --verify', source: 'board' },
- { id: '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 48 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.js
index 52d46627,00000000..00370e9a
mode 100644,000000..100644
--- a/src/seats.js
+++ b/src/seats.js
@@@ -1,219 -1,0 +1,219 @@@
+/**
+ * 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 35 the seat that created it, whether
++ * metadata kept beside it: its model, its route, and from engine 48 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-35 registration gives a new seat: the named one when it is the lane's form and
++ * The id an engine-48 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-35 registration recorded it: an agent id,
- * `machine` for a join no seat made, or null for a seat registered before engine 35.
++ * The seat that created this one, as its engine-48 registration recorded it: an agent id,
++ * `machine` for a join no seat made, or null for a seat registered before engine 48.
+ *
+ * @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-35 move, or a linked CLI previewing one. `root` says whether the acting coordinator's
++ * engine-48 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 35 anywhere on the way means no standing. The coordinator
++ * or a seat registered before engine 48 anywhere on the way means no standing. The coordinator
+ * stands only on a credential the person set up.
+ *
+ * @param {any} board
+ * @param {string} verifier
+ * @param {string} builder
+ * @param {number} itemId
+ * @returns {Refused | null}
+ */
+export function standingProblem(board, verifier, builder, itemId) {
+ const standing = board.verifierStanding;
+ if (!standing || (board.executionEngineVersion ?? ENGINE_VERSION) < VERIFIER_STANDING_ENGINE) return null;
+ const refuse = (why) => new Refused('VERIFIER_STANDING',
+ `${verifier} cannot verify work built by ${builder} on this linked board: ${why}; ask the coordinator to make an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>"`);
+ if (builder === COORDINATOR) {
+ // The person stands above every seat; otherwise only a seat from another machine's line may.
+ if (standing.person) return null;
+ const refuseOwn = (why) => new Refused('VERIFIER_STANDING', `${verifier} cannot verify work the coordinator built on this linked board: ${why}; a seat from another machine's registration lineage, or the person, verifies it`);
+ const built = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key = ?').get(`item_lineage:${itemId}`)?.meta_value ?? null;
+ const lineage = seatLineage(board, verifier);
+ if (!built || !lineage) return refuseOwn('the machine lineage of the build or of this seat was not recorded');
+ if (built === lineage) return refuseOwn('this seat shares the building machine\'s registration lineage');
+ for (let seat = verifier, seen = new Set(); seat !== COORDINATOR; seat = agentCreator(board, seat)) {
+ if (seen.has(seat) || !seatEnrolled(board, seat)) return refuseOwn(`${seat} was not enrolled through the relay`);
+ seen.add(seat);
+ }
+ return null;
+ }
+ const seen = new Set();
+ for (let seat = verifier; ;) {
+ if (seat === COORDINATOR) {
+ return standing.root || seat !== verifier ? null
+ : refuse('the coordinator credential was not set up by the person; run pullboard relay on in the main checkout once');
+ }
+ if (seen.has(seat)) return refuse('its line of creating seats loops');
+ seen.add(seat);
+ const creator = agentCreator(board, seat);
+ if (creator === 'machine') return refuse(`${seat} joined without a creating seat`);
+ if (creator === builder) return refuse(`${seat} was created by the builder`);
+ if (creator === null || !seatEnrolled(board, seat)) {
+ return refuse(`${seat} was not enrolled by its creating seat through the relay`);
+ }
+ seat = creator;
+ }
+}
diff --cc test/agent-model-engine.test.js
index b28dad6b,e3e9e711..9d089a18
--- a/test/agent-model-engine.test.js
+++ b/test/agent-model-engine.test.js
@@@ -6,15 -6,15 +6,17 @@@ import * as store from '../src/board.js
import { applyEngineMove, prepareEngineMove } from '../src/engine.js';
import { exportBoard, importBoard } from '../src/exchange.js';
import { ENGINE_VERSION } from '../src/machine.js';
+import { VERIFIER_STANDING_ENGINE } from '../src/machine.js';
+ import { RIGOR_NOTICE_ENGINE } from '../src/rigor-source.js';
import { configProblems, defaults, loadConfig } from '../src/config.js';
import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
-test('model declarations and event snapshots retain engines 1 through 34 semantics [O8,O3,H16]', (t) => {
+test('model declarations and event snapshots retain all recorded engine semantics [O8,O3,H16]', (t) => {
+ assert.ok(ENGINE_VERSION >= RIGOR_NOTICE_ENGINE, 'the next writer preserves every historical model snapshot through main engine 33');
assert.ok(ENGINE_VERSION >= HEALTH_SENTINEL_ENGINE, 'the current writer retains the sentinel minimum and historical behavior');
+ assert.ok(ENGINE_VERSION >= VERIFIER_STANDING_ENGINE, 'the current writer retains verifier standing');
for (const version of Array.from({ length: ENGINE_VERSION }, (_, index) => index + 1)) {
const board = store.openBoard(':memory:');
t.after(() => store.closeBoard(board));
diff --cc test/pending-refreeze.test.js
index 374ca582,0caa8e72..07ae7a71
--- a/test/pending-refreeze.test.js
+++ b/test/pending-refreeze.test.js
@@@ -10,7 -10,7 +10,8 @@@ import * as store from '../src/board.js
import { appliedSequence, applyRelayMove, engineReceipt, prepareEngineMove } from '../src/engine.js';
import { exportBoard, importBoard } from '../src/exchange.js';
import { ENGINE_VERSION } from '../src/machine.js';
+import { VERIFIER_STANDING_ENGINE } from '../src/machine.js';
+ import { RIGOR_NOTICE_ENGINE } from '../src/rigor-source.js';
import { createE2eHelpers } from './e2e-helpers.js';
import { unpackRelease } from './release-archive.js';
@@@ -263,8 -263,8 +264,9 @@@ async function checkDependencyLegacyCli
}
test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {
+ assert.ok(ENGINE_VERSION >= RIGOR_NOTICE_ENGINE, 'the next writer retains all recorded dependency-edit behavior');
assert.ok(ENGINE_VERSION >= HEALTH_SENTINEL_ENGINE, 'the current writer retains the sentinel minimum and historical behavior');
+ assert.ok(ENGINE_VERSION >= VERIFIER_STANDING_ENGINE, 'the current writer retains verifier standing');
const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));
const cleanup = [];
t.after(() => {
diff --cc test/relay-mint.test.js
index 684a1fa4,00000000..76275acd
mode 100644,000000..100644
--- a/test/relay-mint.test.js
+++ b/test/relay-mint.test.js
@@@ -1,371 -1,0 +1,371 @@@
+/** 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 { submitFixture } from './board-submit-fixture.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') });
+}
+
+/** Create synthetic submitted history for the credential test; this fixture does not run a gate. */
+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) });
+ submitFixture(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 current-engine move with the engine-35 standing policy on the linked board copy. */
++ /** Replay one current-engine move with the engine-48 standing policy 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);
+ // Synthetic relay history names its deferred coverage; it does not claim a gate ran.
+ assert.equal(move('submit', [itemId, { agentId: 'coordinator', commit: 'b'.repeat(40), tree: 'c'.repeat(40),
+ submissionProof: { version: 1, files: [], full: false, deferred: true, reason: 'synthetic relay history; no gate execution' },
+ }], machineA).error, undefined);
+ return store.getItem(board, itemId);
+ };
+ const coordinatorItem = builtOnA();
+ const accept = (item) => [item.item_id, { agentId: seatB, decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'checked the proof', head: 'd'.repeat(40), digest: item.item_frozen_digest }];
+ const sameLine = move('verify', [coordinatorItem.item_id, { ...accept(coordinatorItem)[1], agentId: seatA }], { agent: seatA });
+ assert.equal(sameLine.error?.code, 'VERIFIER_STANDING', 'a seat from the building machine\'s own lineage is refused');
+ const otherMachine = move('verify', accept(coordinatorItem), { agent: seatB });
+ assert.equal(otherMachine.result?.decision, 'ACCEPT', 'a seat from another machine\'s registration lineage verifies coordinator-built work');
+ const forPerson = builtOnA();
+ const person = move('verify', [forPerson.item_id, { ...accept(forPerson)[1], agentId: seatA }], { kind: 'person', agent: undefined });
+ assert.equal(person.result?.decision, 'ACCEPT', 'the person verifies coordinator-built work');
+ });
+
+ // 19 (bar corrections, #470) and 20 (implies, #469) are main's engines before #579; their journals replay as they did too.
+ for (const engine of [11, 12, 19, 20]) await t.test(`an engine-${engine} journal replays as before`, (t) => {
+ const directory = mkdtempSync(join(tmpdir(), `pullboard-mint-engine${engine}-`));
+ t.after(() => rmSync(directory, { recursive: true, force: true }));
+ const historical = store.openBoard(':memory:');
+ t.after(() => store.closeBoard(historical));
+ historical.executionEngineVersion = engine;
+ store.register(historical, { lane: 'coordinator', path: '/repo' });
+ const legacyBuilder = store.register(historical, { lane: 'web', path: '/repo-web-1', createdBy: 'machine' });
+ const legacyReviewer = store.register(historical, { lane: 'web', path: '/repo-web-2' });
+ delete historical.executionEngineVersion;
+ assert.equal(store.agentCreator(historical, legacyBuilder), null, `engine ${engine} records no provenance`);
+ const item = submitted(historical, legacyBuilder, 'web');
+ const recorded = { version: 1, engine, id: `engine-${engine}-verify`, operation: 'verify',
+ args: [item.item_id, { agentId: legacyReviewer, decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'checked', head: 'd'.repeat(40), digest: item.item_frozen_digest }] };
+ const boardId = 'e'.repeat(32);
+ const path = join(directory, boardId + '.journal.sqlite');
+ const db = new DatabaseSync(path);
+ chmodSync(path, 0o600);
+ db.exec(`CREATE TABLE journal_meta (key TEXT PRIMARY KEY, value TEXT NOT NULL);
+ CREATE TABLE journal_record (sequence INTEGER PRIMARY KEY, received_at TEXT NOT NULL, kind TEXT NOT NULL CHECK(kind IN ('move','request')),
+ payload BLOB NOT NULL, sender_kind TEXT NOT NULL CHECK(sender_kind IN ('person','agent','machine')), sender_user TEXT NOT NULL, sender_agent TEXT);
+ CREATE TABLE journal_head (slot INTEGER PRIMARY KEY CHECK(slot=1), sequence INTEGER NOT NULL, last_activity_at TEXT);
+ CREATE TABLE journal_snapshot (slot INTEGER PRIMARY KEY CHECK(slot=1), sequence INTEGER NOT NULL, received_at TEXT NOT NULL, payload BLOB NOT NULL,
+ sender_kind TEXT NOT NULL, sender_user TEXT NOT NULL, sender_agent TEXT);`);
+ db.prepare('INSERT INTO journal_meta (key,value) VALUES (?,?),(?,?)').run('board', boardId, 'format', '3');
+ db.prepare("INSERT INTO journal_record VALUES (1,'2026-10-08T10:00:00.000Z','move',?,'agent','202',?)").run(Buffer.from(JSON.stringify(recorded)), legacyReviewer);
+ db.prepare("INSERT INTO journal_head VALUES (1,1,'2026-10-08T10:00:00.000Z')").run();
+ db.close();
+ const journal = createRelayJournal({ directory, boardId });
+ const [record] = journal.after();
+ journal.close();
+ assert.deepEqual(record.sender, { kind: 'agent', userId: '202', agent: legacyReviewer }, `the engine-${engine} record gains no stamp`);
+ assert.equal(record.registration, undefined);
+ assert.deepEqual(JSON.parse(record.bytes.toString('utf8')), recorded, 'its move bytes are unchanged');
+ const fresh = store.openBoard(':memory:');
+ t.after(() => store.closeBoard(fresh));
+ const stamped = applyRelayMove(fresh, recorded, { sequence: 1, at: record.receivedAt, kind: 'move',
+ sender: { ...record.sender, policy: VERIFIER_STANDING_ENGINE } });
+ assert.equal(stamped.error?.code, 'ENGINE_VERSION', 'a newly stored record cannot claim an old engine');
+ const replayed = applyRelayMove(historical, JSON.parse(record.bytes.toString('utf8')), { sequence: 1, at: record.receivedAt, kind: record.kind, sender: record.sender });
+ assert.equal(replayed.error, undefined, `the engine-${engine} verdict replays with its old rules`);
+ assert.equal(replayed.result.decision, 'ACCEPT');
+ });
+
+ await t.test('an unlinked board verifies exactly as before', (t) => {
+ const local = store.openBoard(':memory:');
+ t.after(() => store.closeBoard(local));
+ store.register(local, { lane: 'coordinator', path: '/repo' });
+ const localBuilder = store.register(local, { lane: 'web', path: '/repo-web-1', createdBy: 'machine' });
+ const localReviewer = store.register(local, { lane: 'web', path: '/repo-web-2', createdBy: 'machine' });
+ const item = submitted(local, localBuilder, 'web');
+ const result = store.verify(local, item.item_id, { agentId: localReviewer, decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'checked the proof',
+ head: 'd'.repeat(40), digest: item.item_frozen_digest, policy: 'any' });
+ assert.equal(result.decision, 'ACCEPT', 'an existing seat verifies another builder\'s item with no standing check');
+ assert.equal(store.reviewOffer(local, { agentId: localReviewer, lane: 'web', ratio: 0 }), null, 'nothing left to review');
+ });
+});