Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(relay): the board knows its people; approvers decide [E3,E4,E20]
Corey Olsona32b1ed7eb8e
diff --git a/docs/api.md b/docs/api.mdindex b9c2602e..d8bf5304 100644--- a/docs/api.md+++ b/docs/api.md@@ -522,6 +522,8 @@ upgrade guidance; it never returns an older or partial image.The authenticated relay page calls `cockpitPage` with `readOnly: true` and the separate `requests: true` capability. This enables only the person's literal intents through the sealing transport; generic API writes remain refused. Local read-only pages and exported snapshots omit this capability and refuse every action.+When `pullboard.json` names `approvers`, only those GitHub logins act as the person on the linked board: a phone request to `answer`, `hold`, `spec-approve` or `spec-decline` from another writer's session is received as refused with `NOT_APPROVER`, and so is a direct person move. `add` and `shout` requests stay open to every writer. Each event a relayed move writes names its `person`, the sender's GitHub login, in `event_detail`, beside `event_by`.+A paired relay browser translates `add`, `shout`, `answer`, `hold` (including `args.off: true`), `spec-approve` and `spec-decline` into literal CLI intent. Its transport accepts `{verb, item?, args}` at the paired board's moves address and seals a separate request document before posting `{sequence, sealed}` to `/api/v1/boards/:board/requests`. It never sends plaintext arguments, an engine operation or the board key. The relay stores and orders that opaque envelope; it neither executes a command nor writes a repository. Agent credentials cannot submit person intent or person-attributed holds and releases.The device-only request format is `{version: 1, type: "person-request", id, move: {verb, item?, args}}`. This request version is independent of the ordinary move engine version. The stable `id` survives interrupted sends and sequence collisions. Browser storage keeps each pending request's ciphertext separately, so another tab cannot replace or clear it. A later board read reconciles pending sends with the relay's acknowledged prefix before retrying.diff --git a/docs/formats.md b/docs/formats.mdindex 46a1693d..06965724 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -113,7 +113,7 @@ The board file is in the repository's Git common directory at `.git/pullboard/bo| `row grammar` | `1` | `SPEC_GRAMMAR_VERSION` in `src/spec.js`; optional `<!-- pullboard-grammar N -->` line in either file (absence means the current grammar) | Both files share the version. A declared version must match; an incompatible grammar change requires a coordinated version bump and compatible files. No automatic conversion occurs. || `board schema` | `2` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | Create missing tables and indexes, add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. || `event log` | `1` | `EVENT_LOG_VERSION` in `src/board.js`, persisted in `board_meta` as `event_log_version` | Older event-log versions upgrade in place; newer versions are refused with `EVENT_LOG_VERSION`. Preserve event rows when the board schema changes. |-| `move engine` | `69` | `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` | `71` | `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 -->Relay transport capability `apiVersion: 2` is independent of these versions and@@ -192,6 +192,8 @@ The relay outbox (#922, opt in with `relay.outbox`) lives beside `relay.json` asEngine 69 (`REVIEW_SKIP_ENGINE`) lets `reserveNextReview` carry `skipIds`: the submitted items the reviewer's own agent session built, which `pullboard next --verify` never offers it. A move with a non-empty `skipIds` needs engine 69, so an older reader refuses it instead of reserving a different item; moves without `skipIds`, and every move recorded before engine 69, replay as before.+Engine 71 (`PEOPLE_ENGINE`) names people and lets approvers alone act as the person. The relay stamps each stored record's sender with the GitHub login behind it, the engine the sender declared and, on a board that names approvers, `approver: true|false` for a person sender. Replaying a move made at engine 71 or later, every event it writes carries `person`, that login, beside `event_by`, the agent or seat. `pullboard.json` may list `approvers`, GitHub logins, at most fifty; leaving it out keeps today's behaviour. On a board that names them, every replica refuses with `NOT_APPROVER` a person move (a row or sentinel decision, an answer, hold or fact as the person, a person request shout) or a phone request to answer, hold or decide rows whose sender is not an approver, and the relay refuses an unlink or snapshot replacement from anyone else. A record whose seal no key opens, from an engine no newer than the replica's, is set aside as `relay_refused` with code `RELAY_SEAL`, and replay goes on; one from a newer engine still asks for an upgrade.+The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.A linked board requires at least engine 48 after issuing any agent token or machine credential, includingrevoked or expired ones; before engine 48 these minimums were 3 and 6. The minimum survives reopening the auth database;diff --git a/relay/README.md b/relay/README.mdindex 2151bc25..aea504f2 100644--- a/relay/README.md+++ b/relay/README.md@@ -103,6 +103,14 @@ see their boards. Board actions and minting or revoking board tokens requirewrite, maintain, or admin permission, checked again on every such operation. Repository ids are pinned so areplacement repository cannot inherit a board link.+A board may name approvers: the GitHub logins its `pullboard.json` lists. `pullboard relay on`, signed in as a person,+sends them with `PUT /api/v1/boards/:board/approvers` (`{approvers: [...]}`; an empty list removes them), and+`GET` on the same path returns them. The person who linked the board sets the first list; after that only a+current approver changes it (`NOT_APPROVER`). On such a board only an approver deletes the relay copy or replaces+its snapshot, from a session or that person's machine credential; each person record says whether its sender is+an approver, and every replica refuses person moves and phone requests from anyone else. A board that names none+works as before, and naming them raises its minimum engine to 71.+SQLite stores account/repository identities and SHA-256 hashes of relay-issuedcredentials, never their plaintext. Sessions expire in seven days by default;board tokens in one day (configurable up to thirty days). Revocation persists@@ -158,7 +166,7 @@ The client owns the encryption format and engine-version checks.All responses and refusals retain envelope `version: 1`. Moves use the shared100,000 byte JSON-body limit. Legacy API1 snapshots allow a bounded 90,000,000byte JSON body and 64,000,000 decoded bytes; API2 uses the bounded objects below. One private SQLite journal per board stores only its-identity, format, head cursor, receive times, public sender identities and sealed payloads. Compaction+identity, format, head cursor, receive times, public sender identities (account, GitHub login, declared engine and, on a board that names approvers, whether a person sender is one) and sealed payloads. Compactionkeeps the head cursor, so the next move never reuses an earlier sequence.### Paged snapshots and account storagediff --git a/relay/auth.js b/relay/auth.jsindex 653c98d6..dd0eb746 100644--- a/relay/auth.js+++ b/relay/auth.js@@ -7,6 +7,7 @@ import { Refused } from '../src/refused.js';import { repositoryName } from './github.js';import { approvalContext } from '../src/relay-approval.js';import { VERIFIER_STANDING_ENGINE } from '../src/machine.js';+import { PEOPLE_ENGINE } from '../src/people-engine.js';export const ACCESS_WINDOW_MS = 10 * 60_000;const MAX_TTL = 30 * 24 * 3600_000;@@ -81,6 +82,10 @@ export function createRelayAuth({ database, github, now = Date.now, sessionTTL =if (!db.prepare('PRAGMA table_info(relay_boards)').all().some((column) => column.name === 'storage_account')) {db.exec('ALTER TABLE relay_boards ADD COLUMN storage_account TEXT REFERENCES relay_users(id)');}+ // A board's approvers (#343): GitHub logins as a JSON array, or NULL for a board that names none.+ if (!db.prepare('PRAGMA table_info(relay_boards)').all().some((column) => column.name === 'approvers')) {+ db.exec('ALTER TABLE relay_boards ADD COLUMN approvers TEXT');+ }db.prepare('UPDATE relay_boards SET linked_at=? WHERE linked_at IS NULL').run(now());db.prepare('DELETE FROM relay_deleted_credentials WHERE expires<=?').run(now());db.exec('COMMIT');@@ -593,10 +598,55 @@ export function createRelayAuth({ database, github, now = Date.now, sessionTTL =minimumEngineVersion(board) {open();identifier(board, 'BAD_BOARD');+ // Only an engine that enforces approvers may read or write a board that names them [E4,E20].+ if (auth.boardApprovers(board)) return PEOPLE_ENGINE;// Machine and agent credentials now carry engine-48 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;},+ /**+ * The GitHub logins this board names as its approvers, or null when it names none and behaves as before [E4].+ *+ * @param {string} board+ * @returns {string[] | null}+ */+ boardApprovers(board) {+ open();+ const row = db.prepare('SELECT approvers FROM relay_boards WHERE id=?').get(board);+ return row?.approvers ? JSON.parse(row.approvers) : null;+ },+ /**+ * Whether this principal may act for a board that names approvers: true or false when it names them, null when+ * it names none. A machine or agent credential acts for the person who minted it [E4,E20].+ */+ isApprover(board, principal) {+ const approvers = auth.boardApprovers(board);+ return approvers ? approvers.includes(principal.user.login) : null;+ },+ /**+ * Set a board's approvers from its pullboard.json, signed in as a person. The first list is the linking person's+ * to set; after that only a current approver changes it, so a change takes effect only once an approver makes+ * it. An empty list removes them, and the board behaves as before [E4].+ *+ * @param {string} token - a person session+ * @param {string} board+ * @param {string[]} approvers - GitHub logins+ */+ async setBoardApprovers(token, board, approvers) {+ identifier(board, 'BAD_BOARD');+ if (!Array.isArray(approvers) || approvers.length > 50 || new Set(approvers).size !== approvers.length+ || approvers.some((login) => typeof login !== 'string' || !/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/u.test(login))) {+ throw new Refused('BAD_APPROVERS', 'name approvers as distinct GitHub logins, at most fifty');+ }+ const principal = await auth.authenticate(token, { board, write: true });+ if (principal.kind !== 'session') throw new Refused('HUMAN_REQUIRED', 'set approvers signed in as yourself');+ const current = auth.boardApprovers(board);+ const linker = db.prepare('SELECT storage_account FROM relay_boards WHERE id=?').get(board)?.storage_account;+ const allowed = current ? current.includes(principal.user.login) : linker === null || linker === undefined || linker === principal.user.id;+ if (!allowed) throw new Refused('NOT_APPROVER', `${principal.user.login} is not an approver of this board; an approver signs in and runs pullboard relay on to change the list`);+ db.prepare('UPDATE relay_boards SET approvers=? WHERE id=?').run(approvers.length ? JSON.stringify([...approvers].sort()) : null, board);+ return { board, approvers: approvers.length ? [...approvers].sort() : null };+ },/** Give a foreground person one board-bound machine delegate, never another person credential. */async issueMachine(token, { board, machine, host, expiresIn = MAX_TTL }) {identifier(board, 'BAD_BOARD');diff --git a/relay/journal.js b/relay/journal.jsindex 78136642..d17021e5 100644--- a/relay/journal.js+++ b/relay/journal.js@@ -84,7 +84,10 @@ export function createRelayJournal({ directory, boardId, maxBytes = DEFAULT_BYTEdb.prepare('UPDATE journal_meta SET value=? WHERE key=?').run(String(FORMAT), 'format');// Engine-27 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']]) {+ // Engine-71 people (#343): the GitHub login behind each record, and whether that person was one of the+ // board's approvers when it arrived. Older records keep them empty and replay as they did.+ for (const [column, type] of [['sender_policy', 'INTEGER'], ['sender_root', 'INTEGER'], ['sender_lineage', 'TEXT'], ['registration', 'TEXT'],+ ['sender_login', 'TEXT'], ['sender_approver', 'INTEGER'], ['sender_engine', 'INTEGER']]) {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@@ -131,7 +134,9 @@ export function createRelayJournal({ directory, boardId, maxBytes = DEFAULT_BYTEsender: { kind: row.sender_kind, userId: row.sender_user,...(row.sender_kind === 'agent' ? { agent: row.sender_agent } : row.sender_kind === 'machine' ? { machine: row.sender_agent } : {}),...(row.sender_policy ? { policy: row.sender_policy } : {}), ...(row.sender_root ? { root: true } : {}),- ...(row.sender_lineage ? { lineage: row.sender_lineage } : {}) },+ ...(row.sender_lineage ? { lineage: row.sender_lineage } : {}),+ ...(row.sender_login ? { login: row.sender_login } : {}), ...(row.sender_approver === null || row.sender_approver === undefined ? {} : { approver: row.sender_approver === 1 }),+ ...(row.sender_engine ? { engine: row.sender_engine } : {}) },...(row.registration ? { registration: JSON.parse(row.registration) } : {}),...(row.api_version === 2 ? { apiVersion: 2, pageBytes: row.page_bytes } : {}), bytes: Buffer.from(row.payload) };}@@ -146,11 +151,14 @@ export function createRelayJournal({ directory, boardId, maxBytes = DEFAULT_BYTE}if (personOnly && !['person', 'machine'].includes(value.kind)) throw new Refused('HUMAN_REQUIRED', 'use this board’s machine credential to replace its snapshot');if ((value.policy !== undefined && (!Number.isSafeInteger(value.policy) || value.policy < 1)) || (value.root !== undefined && value.root !== true) ||- (value.lineage !== undefined && (typeof value.lineage !== 'string' || !/^[0-9a-f-]{36}$/.test(value.lineage)))) {+ (value.lineage !== undefined && (typeof value.lineage !== 'string' || !/^[0-9a-f-]{36}$/.test(value.lineage))) ||+ (value.login !== undefined && (typeof value.login !== 'string' || !/^[A-Za-z0-9-]{1,39}$/u.test(value.login))) ||+ (value.approver !== undefined && typeof value.approver !== 'boolean') || (value.engine !== undefined && (!Number.isSafeInteger(value.engine) || value.engine < 1))) {throw new Refused('RELAY_PRINCIPAL', 'supply the relay policy stamp as a positive engine number');}return { kind: value.kind, userId: value.userId, agent: value.kind === 'agent' ? value.agent : value.kind === 'machine' ? value.machine : null,- policy: value.policy ?? null, root: value.root === true ? 1 : null, lineage: value.lineage ?? null };+ policy: value.policy ?? null, root: value.root === true ? 1 : null, lineage: value.lineage ?? null,+ login: value.login ?? null, approver: value.approver === undefined ? null : value.approver ? 1 : 0, engine: value.engine ?? null };}/** Keep a seat receipt to its four public fields: target, creator, sequence and ciphertext digest. */@@ -200,8 +208,8 @@ export function createRelayJournal({ directory, boardId, maxBytes = DEFAULT_BYTEif (sequence > next) throw new Refused('SEQUENCE_GAP', 'send the next sequence after the latest committed record before later uploads');const at = now();if (!(at instanceof Date) || !Number.isFinite(at.getTime())) throw new Refused('RELAY_CONFIG', 'the journal clock must return a valid Date');- db.prepare('INSERT INTO journal_record (sequence,received_at,kind,payload,sender_kind,sender_user,sender_agent,sender_policy,sender_root,sender_lineage,registration) VALUES (?,?,?,?,?,?,?,?,?,?,?)')- .run(sequence, at.toISOString(), kind, sealed, who.kind, who.userId, who.agent, who.policy, who.root, who.lineage, stored);+ db.prepare('INSERT INTO journal_record (sequence,received_at,kind,payload,sender_kind,sender_user,sender_agent,sender_policy,sender_root,sender_lineage,registration,sender_login,sender_approver,sender_engine) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)')+ .run(sequence, at.toISOString(), kind, sealed, who.kind, who.userId, who.agent, who.policy, who.root, who.lineage, stored, who.login, who.approver, who.engine);if (stored) {const claim = JSON.parse(stored);if (db.prepare('SELECT 1 FROM journal_registration WHERE target=?').get(claim.target)) {diff --git a/relay/service.js b/relay/service.jsindex 0df41319..c4143ba6 100644--- a/relay/service.js+++ b/relay/service.js@@ -101,10 +101,18 @@ function seatReceipt(body, who) {/** Give a snapshot its coverage cursor; clients unseal it and replay the following sealed events. */function state(row) { return { sequence: row.sequence, receivedAt: row.receivedAt, sender: row.sender, sealed: row.bytes.toString('base64url') }; }-/** Project a freshly authenticated credential to public sender metadata, never taking body fields. */+/**+ * Project a freshly authenticated credential to public sender metadata, never taking body fields. Every record names+ * the GitHub login behind it [E3]; on a board that names approvers, a person's record also says whether they are one,+ * and only an approver unlinks the board or replaces its snapshot [E4,E20].+ */function sender(who, personOnly = false) {if (personOnly && who.kind !== 'session' && !(personOnly === 'snapshot' && who.kind === 'machine')) throw new Refused('HUMAN_REQUIRED', 'approve this person action from the paired phone');+ if (personOnly && who.approver === false) throw new Refused('NOT_APPROVER', `${who.user.login} is not an approver of this board; only an approver unlinks it or replaces its snapshot`);return { kind: who.kind === 'session' ? 'person' : who.kind === 'machine' ? 'machine' : 'agent', userId: who.user.id,+ ...(typeof who.user.login === 'string' ? { login: who.user.login } : {}), ...(who.kind === 'session' && typeof who.approver === 'boolean' ? { approver: who.approver } : {}),+ // The engine the sender declared: a seal no replica opens, from an engine no newer than the replica's, is junk to set aside [E20].+ ...(Number.isSafeInteger(who.engineVersion) && who.engineVersion > 0 ? { engine: who.engineVersion } : {}),...(who.kind === 'board' ? { agent: who.agent } : who.kind === 'machine' ? { machine: who.machine } : {}),...(personOnly === 'snapshot' ? {} : { policy: VERIFIER_STANDING_ENGINE,...(who.root === true ? { root: true, ...(who.lineage ? { lineage: who.lineage } : {}) } : {}) }) };@@ -143,7 +151,9 @@ export function createRelayHandler({ directory, auth, pollMs = 200, publicOriginasync function authorized(token, id, write = false) {const who = deviceStore.authorizeSession(await auth.authenticate(token, { board: identity(id), write }));if (retention.expire(id)) throw new Refused('NO_BOARD', 'this inactive link expired; link and upload the local board again');- return who;+ // Whether this person is one of the board's approvers, or undefined for a board that names none [E4].+ const approver = auth.isApprover?.(identity(id), who);+ return typeof approver === 'boolean' ? { ...who, approver } : who;}const deviceStore = createDeviceStore({ directory: root, now });@@ -258,7 +268,7 @@ export function createRelayHandler({ directory, auth, pollMs = 200, publicOriginconst bytes = sealed(body, kind === 'move');if (!Number.isSafeInteger(body.sequence) || body.sequence < 1) throw new Refused('BAD_SEQUENCE', 'seal this move for the next positive sequence after the latest committed prefix');const authenticated = await authorized(who.credential, board.id, true);- const principal = sender(authenticated);+ const principal = sender({ ...authenticated, engineVersion: who.engineVersion });if (body.registration === undefined) {return withJournal(board.id, (journal) => {const row = body.sequence <= journal.latest() ? journal.append(body.sequence, bytes, kind, principal)@@ -340,6 +350,17 @@ export function createRelayHandler({ directory, auth, pollMs = 200, publicOriginlet url;try { url = new URL(req.url ?? '/', 'http://127.0.0.1'); }catch { throw new Refused('BAD_REQUEST', 'use a valid path under /api/v1/boards'); }+ const approvers = /^\/api\/v1\/boards\/([^/]+)\/approvers$/.exec(url.pathname);+ if (approvers && req.method === 'GET') {+ const id = identity(approvers[1]);+ await authorizedRequest(req, id);+ return apiJson(res, 200, { board: id, approvers: auth.boardApprovers(id) });+ }+ if (approvers && req.method === 'PUT') {+ const id = identity(approvers[1]);+ const body = await readApiBody(req, { maxBytes: 8_192 });+ return apiJson(res, 200, await auth.setBoardApprovers(credential(req, origin, true), id, body.approvers));+ }const snapshot = /^\/api\/v1\/boards\/([^/]+)\/state$/.exec(url.pathname);const deletion = /^\/api\/v1\/boards\/([^/]+)$/.exec(url.pathname);if (req.method === 'GET' && snapshot) {diff --git a/src/board.js b/src/board.jsindex bec4fc89..45f0610d 100644--- a/src/board.js+++ b/src/board.js@@ -529,8 +529,8 @@ export function atomic(board, work) {export function logEvent(board, by, kind, itemId, detail = {}, at) {const model = agentModel(board, by);const isAgent = Boolean(board.db.prepare('SELECT 1 FROM agent WHERE agent_id = ?').get(by));- const recorded = (board.executionEngineVersion ?? ENGINE_VERSION) >= 8 && isAgent- ? { ...detail, model: model ?? 'unknown' } : detail;+ const recorded = { ...detail, ...((board.executionEngineVersion ?? ENGINE_VERSION) >= 8 && isAgent ? { model: model ?? 'unknown' } : {}),+ ...(board.movePerson ? { person: board.movePerson } : {}) }; // The person behind a relayed move, from engine 71 (engine.js) [E3].const inserted = board.db.prepare('INSERT INTO event (event_at, event_by, event_kind, item_id, event_detail) VALUES (?, ?, ?, ?, ?)').run(at ? at.toISOString() : now(board), by, kind, itemId, JSON.stringify(recorded));diff --git a/src/config.js b/src/config.jsindex aed7819c..3251d974 100644--- a/src/config.js+++ b/src/config.js@@ -190,6 +190,8 @@ export function configProblems(config) {if (config.relay !== undefined && (!config.relay || typeof config.relay !== 'object' || Array.isArray(config.relay)|| config.relay.outbox !== undefined && typeof config.relay.outbox !== 'boolean'|| Object.keys(config.relay).some(key => key !== 'outbox'))) problems.push('"relay" has only the optional boolean "outbox", off by default');+ if (config.approvers !== undefined && (!Array.isArray(config.approvers) || config.approvers.length > 50 || new Set(config.approvers).size !== config.approvers.length+ || config.approvers.some((login) => typeof login !== 'string' || !/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$/u.test(login)))) problems.push('"approvers" lists the GitHub logins who act as the person on a linked board, at most fifty; leave it out for today\'s behaviour');if (!['inside', 'beside'].includes(config.worktrees)) problems.push('"worktrees" is "inside" or "beside"');if (config.submitGate !== undefined && config.submitGate !== 'landing') {problems.push('"submitGate" is "landing" when the full suite should be deferred until landing');diff --git a/src/engine.js b/src/engine.jsindex ab291cb6..8aa96ef5 100644--- a/src/engine.js+++ b/src/engine.js@@ -22,6 +22,7 @@ import { CHECK_ACCEPT_ENGINE } from './check-accept.js';import { HEALTH_SENTINEL_ENGINE } from './health-receipts.js';import { BOARD_SENTINEL_ENGINE } from './sentinels.js';import { RECURRING_JOB_ENGINE } from './job-engine.js';+import { PEOPLE_ENGINE } from './people-engine.js';import { SPEC_APPROVAL_ENGINE } from './spec-approval-engine.js';import { GATE_RUN_ENGINE } from './gate-run-engine.js';import { requireBound } from './quarantine.js';@@ -315,7 +316,8 @@ export function applyRelayMove(board, move, { sequence, at, sender, kind, digest// 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 });+ // The relay-authenticated GitHub login names the person behind the move, whoever sent it [E3].+ return applyEngineMove(board, move, { sequence, at, standing, enrollment: registration?.target ?? null, person: typeof sender?.login === 'string' ? sender.login : null });}return refuseRelayMove(board, move, { sequence, at, sender, kind, code: problem.code, digest, refusal: problem });}@@ -324,7 +326,7 @@ export function applyRelayMove(board, move, { sequence, at, sender, kind, digest* Apply one relay position with the same board functions as the CLI, preserving its refusal.* A receipt and prefix commit atomically; duplicate ids return that receipt without another move.*/-export function applyEngineMove(board, move, { sequence, at, standing = null, enrollment = null }) {+export function applyEngineMove(board, move, { sequence, at, standing = null, enrollment = null, person = null }) {validateMove(move);if (!Number.isSafeInteger(sequence) || sequence < 1 || !Number.isFinite(Date.parse(at))) throw new Refused('RELAY_MOVE', 'supply a valid relay sequence and receipt timestamp');return store.atomic(board, () => {@@ -348,6 +350,8 @@ export function applyEngineMove(board, move, { sequence, at, standing = null, enboard.executionEngineVersion = move.engine;const firstEvent = board.emittedEvents?.length ?? 0;if (enrollment !== null) board.relayEnrollment = enrollment;+ // From engine 71 every event of the move names its person; an older move replays without one.+ if (person !== null && move.engine >= PEOPLE_ENGINE) board.movePerson = person;try {const execute = () => store.atomic(board, () => {const problem = requestMoveProblem(board, move);@@ -367,6 +371,7 @@ export function applyEngineMove(board, move, { sequence, at, standing = null, en} finally {board.clock = clock;delete board.relayEnrollment;+ delete board.movePerson;if (engineVersion === undefined) delete board.executionEngineVersion;else board.executionEngineVersion = engineVersion;}diff --git a/src/next-steps.js b/src/next-steps.jsindex a358626c..1bafabd7 100644--- a/src/next-steps.js+++ b/src/next-steps.js@@ -367,6 +367,8 @@ export const NEXT_STEPS = Object.freeze({NOT_HOLDING: 'name an item: pullboard check <id>, or run the project gate: pullboard gate',NOT_JOINED: 'join a lane from this worktree: pullboard join <lane> --model "<model name>" (see: pullboard lanes)',NOT_MAIN: 'run this coordinator-owned operation from the main checkout, or ask the coordinator to do it',+ NOT_APPROVER: 'ask one of the approvers pullboard.json names to do it, signed in as themselves; to change the list, an approver commits it and runs pullboard relay on',+ BAD_APPROVERS: 'list approvers in pullboard.json as distinct GitHub logins, at most fifty, then run pullboard relay on',NOT_MERGED: 'merge the item\'s commit onto the trunk, then pullboard merged <id>',NOT_SSH_KEY: 'add a valid OpenSSH public key: pullboard spec signers add --key ~/.ssh/id_ed25519.pub',NOT_SSH_KEY_PATH: 'set user.signingkey to an SSH key file: git config user.signingkey ~/.ssh/id_ed25519.pub',diff --git a/src/people-engine.js b/src/people-engine.jsnew file mode 100644index 00000000..257aab0f--- /dev/null+++ b/src/people-engine.js@@ -0,0 +1,2 @@+/** First engine for moves that name their person and boards whose approvers alone act as the person (#343) [E3,E4,E20]. */+export const PEOPLE_ENGINE = 71;diff --git a/src/relay-approvers.js b/src/relay-approvers.jsnew file mode 100644index 00000000..fa6abca6--- /dev/null+++ b/src/relay-approvers.js@@ -0,0 +1,37 @@+/**+ * A board's approvers on the relay [E4,E20]. pullboard.json on accepted main names them; the relay keeps the same+ * GitHub logins as board metadata so it can stamp each person's records and refuse an unlink or snapshot from anyone+ * else. Only a person, signed in as themselves, sends the list, and the relay takes a change only from a current+ * approver, so a new list takes effect once an approver signs in with it.+ */+import { Refused } from './refused.js';+import { request } from './relay.js';+import { mainPolicy } from './trusted-policy.js';++/**+ * Send accepted main's approver list to the relay within a person's sign-in, when it differs from the relay's. A+ * refusal is reported and never stops the link: the old list stands until an approver brings the new one.+ *+ * @param {string} root - the board's checkout+ * @param {{ board: string, url: string }} state - the saved link+ * @param {string} session - the person's session token+ * @param {{ err?: (line: string) => void, say?: (line: string) => void }} io+ * @returns {Promise<string[] | null | undefined>} the relay's list after the call, or undefined when nothing was sent+ */+export async function syncApprovers(root, state, session, io) {+ let wanted;+ try { wanted = mainPolicy(root).config.approvers; } catch { return undefined; }+ const path = '/api/v1/boards/' + state.board + '/approvers';+ const current = (await request({ ...state, token: session }, path, {}, io)).approvers ?? null;+ const next = Array.isArray(wanted) && wanted.length ? [...wanted].sort() : null;+ if (JSON.stringify(current) === JSON.stringify(next)) return current;+ try {+ const saved = await request({ ...state, token: session }, path, { method: 'PUT', body: { approvers: next ?? [] } }, io);+ io.say?.(next ? `Approvers on the relay: ${next.join(', ')}.` : 'This board names no approvers on the relay.');+ return saved.approvers ?? null;+ } catch (error) {+ if (!(error instanceof Refused) || !['NOT_APPROVER', 'BAD_APPROVERS'].includes(error.code)) throw error;+ io.err?.(`pullboard: pullboard.json names different approvers, but ${error.message}`);+ return current;+ }+}diff --git a/src/relay-requests.js b/src/relay-requests.jsindex 9041fad1..6038a7f8 100644--- a/src/relay-requests.js+++ b/src/relay-requests.js@@ -43,6 +43,10 @@ export function receivePersonRequest(board, document, { sequence, at, sender })try {if (sender?.kind !== 'person' || typeof sender.userId !== 'string' || !sender.userId || sender.userId.length > 256) throw new Refused('RELAY_PERSON_ONLY', 'only the authenticated person can send a relay request; use the paired view with the person session');request = validatePersonRequest(document);+ // On a board that names approvers, a phone request that acts as the person must come from one [E4].+ if (sender.approver === false && ['answer', 'hold', 'spec-approve', 'spec-decline'].includes(request.move?.verb)) {+ throw new Refused('NOT_APPROVER', `${sender.login ?? 'this person'} is not an approver of this board; ask an approver to answer, hold or decide rows`);+ }} catch (cause) {if (!(cause instanceof Refused)) throw cause;error = recordedRefusal(cause);diff --git a/src/relay-sender.js b/src/relay-sender.jsindex aff6399f..f698d503 100644--- a/src/relay-sender.js+++ b/src/relay-sender.js@@ -26,7 +26,20 @@ export function validRelaySender(sender) {(sender.kind !== 'machine' || (typeof sender.machine === 'string' && sender.machine.length > 0 && sender.machine.length <= 256)) &&(sender.policy === undefined || Number.isSafeInteger(sender.policy) && sender.policy > 0) &&(sender.root === undefined || sender.root === true) &&- (sender.lineage === undefined || typeof sender.lineage === 'string' && sender.lineage.length > 0 && sender.lineage.length <= 64));+ (sender.lineage === undefined || typeof sender.lineage === 'string' && sender.lineage.length > 0 && sender.lineage.length <= 64) &&+ (sender.login === undefined || typeof sender.login === 'string' && /^[A-Za-z0-9-]{1,39}$/u.test(sender.login)) &&+ (sender.approver === undefined || typeof sender.approver === 'boolean') &&+ (sender.engine === undefined || Number.isSafeInteger(sender.engine) && sender.engine > 0));+}++/**+ * True for a move only the person may make: a row decision, a sentinel decision, an answer or hold as the person, a+ * person fact or request, or any move whose actor is the person. On a board that names approvers, only an approver's+ * session makes one [E4].+ */+function personAuthority(move) {+ return personFact(move) || ['recordRowDecisions', 'decideSentinel'].includes(move?.operation) || move?.operation === 'answerDecision' && Boolean(move.args?.[1]?.asPerson) ||+ move?.operation === 'shout' && Boolean(move.args?.[0]?.request) || relayMoveActor(move) === 'person';}/**@@ -51,7 +64,11 @@ export function relaySenderProblem(move, sender, kind, { phoneReceipt = false }if (move?.operation === 'shout' && move.args?.[0]?.answers != null) {return new Refused('RELAY_ANSWER', 'a sealed shout cannot answer or pass a decision; use pullboard answer <id> "<answer>" or pullboard pass <id> --note "<reason>" so the decision rules are checked');}- if (sender.kind === 'person') return null;+ if (sender.kind === 'person') {+ // The relay stamps whether the person is one of the board's approvers; a board that names none stamps nothing [E4,E20].+ return sender.approver === false && (kind === 'snapshot' || personAuthority(move))+ ? new Refused('NOT_APPROVER', `${sender.login ?? 'this person'} is not an approver of this board; only an approver it names answers person decisions, approves rows or replaces its snapshot`) : null;+ }if (personFact(move)) {return new Refused('RELAY_PERSON_ONLY', `${sender.kind === 'agent' ? `agent ${sender.agent}` : 'a machine'} cannot record the person's never-again; the person marks it from their own session`);}diff --git a/src/relay.js b/src/relay.jsindex cd2c3b6d..18816cab 100644--- a/src/relay.js+++ b/src/relay.js@@ -62,6 +62,7 @@ import {seatReceipt,withSeatName,} from './relay-seats.js';+import { syncApprovers } from './relay-approvers.js';import {ENGINE_VERSION,VERIFIER_STANDING_ENGINE,@@ -855,11 +856,11 @@ async function replayRelayRecord(board, key, state, record) {return applyRelayMove(board, move, { sequence: record.event_id, at: record.event_at, sender: record.sender, kind: record.kind,digest: createHash('sha256').update(record.sealed).digest('hex'), registration: record.registration });} catch (error) {- if (!(error instanceof Refused) || !['RELAY_MOVE', 'RELAY_RESPONSE', 'SEAL_FORMAT', 'SEAL_AUTH_FAILED'].includes(error.code)) throw error;- return refuseRelayMove(board, move, { sequence: record.event_id, at: record.event_at, sender: record.sender, kind: record.kind,- code: error.code === 'SEAL_AUTH_FAILED' ? 'RELAY_SEAL' : error.code,+ // A seal no key opens, sent by an engine no newer than this one, is junk: set aside, never a reason to stop [E20].+ if (!(error instanceof Refused) || !(['RELAY_MOVE', 'RELAY_RESPONSE', 'SEAL_FORMAT', 'SEAL_AUTH_FAILED'].includes(error.code) || error.code === 'SEAL_VERSION' && record.sender?.engine <= ENGINE_VERSION)) throw error;+ return refuseRelayMove(board, move, { sequence: record.event_id, at: record.event_at, sender: record.sender, kind: record.kind, code: ['SEAL_AUTH_FAILED', 'SEAL_VERSION'].includes(error.code) ? 'RELAY_SEAL' : error.code,digest: createHash('sha256').update(String(record.sealed)).digest('hex'),- refusal: error.code === 'SEAL_AUTH_FAILED'+ refusal: ['SEAL_AUTH_FAILED', 'SEAL_VERSION'].includes(error.code)? new Refused('RELAY_SEAL', 'this relay record failed authentication and was logged as refused; run pullboard relay to continue with the next ordered record'): error });}@@ -1648,7 +1649,7 @@ export async function relayOn(root, address, io, { session, credential, quiet =delete state.personReauth;saveLink(file, state);// The person's own sign-in sets up the coordinator's token, so no agent can mint it (#579).- if (/^ps_[A-Za-z0-9_-]{43}$/u.test(signed.token ?? '')) await ensurePersonCoordinator(file, state, signed.token, io);+ if (/^ps_[A-Za-z0-9_-]{43}$/u.test(signed.token ?? '')) { await ensurePersonCoordinator(file, state, signed.token, io); await syncApprovers(root, state, signed.token, io); }let result;try {let ready = true;diff --git a/test/relay-fixture.js b/test/relay-fixture.jsindex 8db22103..9c9f9f4c 100644--- a/test/relay-fixture.js+++ b/test/relay-fixture.js@@ -10,7 +10,9 @@ export async function githubFixture(t) {const state = { access: true, permission: 'write', public: false, installed: true, repositoryID: 100, repositories: ['repository'], accountID: 7, permissionAccountID: 7, deviceAuthorized: false, deviceDeclined: false, deviceExpired: false, slow: false, redirect: null, beforeDevicePoll: null, beforeUser: null };const calls = [];const codes = new Map();- const userTokens = new Set();+ // Each user credential remembers who signed in. state.signer picks the next person and state.people gives each+ // one an id and repository role; without them there is one person, fixture-user, as before.+ const userTokens = new Map();const installationTokens = new Set();const deviceCode = randomBytes(24).toString('base64url');const clientSecret = randomBytes(24).toString('base64url');@@ -34,7 +36,7 @@ export async function githubFixture(t) {/** Issue synthetic user credentials; only in-memory Sets ever retain their plaintext. */function userCredential() {const token = 'ghu_' + randomBytes(32).toString('base64url');- userTokens.add(token);+ userTokens.set(token, state.signer ?? 'fixture-user');return { access_token: token, token_type: 'bearer', scope: '', expires_in: 3600 };}@@ -92,7 +94,8 @@ export async function githubFixture(t) {if (url.pathname === '/user') {if (state.redirect) { res.writeHead(302, { location: state.redirect }); return res.end(); }if (state.beforeUser) await state.beforeUser();- return reply(res, isUser ? 200 : 401, { id: state.accountID, login: 'fixture-user' });+ const login = userTokens.get(bearer) ?? 'fixture-user';+ return reply(res, isUser ? 200 : 401, { id: state.people?.[login]?.id ?? state.accountID, login });}const repositoryPath = url.pathname.match(/^\/repos\/fixture\/([^/]+)(?:\/(.*))?$/u);const repositoryName = repositoryPath?.[1];@@ -109,9 +112,11 @@ export async function githubFixture(t) {return reply(res, 201, { token, expires_at: new Date(Date.now() + 3600_000).toISOString() });}if (allowedRepository && !repositoryPath[2]) return reply(res, isInstallation || state.public ? 200 : 404, { id: state.repositoryID + state.repositories.indexOf(repositoryName), full_name: 'fixture/' + repositoryName, private: !state.public });- if (allowedRepository && repositoryPath[2] === 'collaborators/fixture-user/permission') {+ const asked = /^collaborators\/([^/]+)\/permission$/u.exec(repositoryPath?.[2] ?? '')?.[1];+ if (allowedRepository && asked && (asked === 'fixture-user' || state.people?.[asked])) {if (state.beforePermission) await state.beforePermission();- const role = state.access ? state.permission : 'none';+ const person = state.people?.[asked];+ const role = person ? person.permission : state.access ? state.permission : 'none';const permission = { triage: 'read', maintain: 'write' }[role] || role;const permissions = state.permissions ?? {pull: ['read', 'triage', 'write', 'maintain', 'admin'].includes(role),@@ -119,7 +124,7 @@ export async function githubFixture(t) {push: ['write', 'maintain', 'admin'].includes(role),maintain: ['maintain', 'admin'].includes(role), admin: role === 'admin',};- const answer = { permission, user: { id: state.permissionAccountID } };+ const answer = { permission, user: { id: person ? person.id : state.permissionAccountID } };if (!state.legacyOnly) {answer.role_name = state.roleName ?? role;answer.user.permissions = permissions;diff --git a/test/team.test.js b/test/team.test.jsindex b917a268..31616c25 100644--- a/test/team.test.js+++ b/test/team.test.js@@ -4,6 +4,9 @@ import assert from 'node:assert/strict';import childProcess from 'node:child_process';import { syncBuiltinESMExports } from 'node:module';import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'node:fs';+import { cpSync } from 'node:fs';+import { randomBytes } from 'node:crypto';+import { randomUUID } from 'node:crypto';import { join } from 'node:path';import { pathToFileURL } from 'node:url';import { after, test } from 'node:test';@@ -17,6 +20,14 @@ import { fetchFresh } from './http-fixture.js';import { relaySnapshot, presentationDigest } from '../src/relay-presentation.js';import { snapshotState } from '../relay/browser-model.js';import { unpackRelease } from './release-archive.js';+import { relayClientFixture } from './relay-client-fixture.js';+import { relayFixtureChild } from './relay-client-fixture.js';+import { runFixtureGit } from './fixture-child.js';+import { decodeBoardKey } from '../src/seal.js';+import { seal } from '../src/seal.js';+import { ENGINE_VERSION as PEOPLE_VERSION } from '../src/machine.js';++const CLI = join(import.meta.dirname, '..', 'bin', 'pullboard.js');const helpers = createE2eHelpers();after(helpers.cleanup);@@ -467,3 +478,138 @@ test('an older pushed landing shows stale checked proof and a correction path ac'a later correction containing the checked composition clears the derived warning without rewriting the old landing');assert.equal(withBoard(box.repo, board => store.getItem(board, 1)).item_merged_commit, submitted);});++/** A person's own session, through the stand-in GitHub's real OAuth, signed in as `login`. */+async function personSession(box, login) {+ box.providerState.signer = login;+ try {+ const start = await fetch(box.origin + '/auth/github/start', { redirect: 'manual' });+ const binding = start.headers.getSetCookie().find((value) => value.startsWith('pb_oauth_binding=')).split(';')[0];+ const approved = await fetch(start.headers.get('location'), { redirect: 'manual' });+ const callback = await fetch(approved.headers.get('location'), { redirect: 'manual', headers: { cookie: binding } });+ assert.equal(callback.status, 303, `${login} signs in`);+ return callback.headers.getSetCookie().find((value) => value.startsWith('pb_session=')).split(';')[0].slice('pb_session='.length);+ } finally { box.providerState.signer = 'alice'; }+}++/** Call the relay as one credential, returning the status and document. */+async function relayCall(box, token, method, path, body) {+ const response = await fetch(box.origin + path, { method, headers: { authorization: 'Bearer ' + token, 'x-pullboard-engine': String(PEOPLE_VERSION),+ ...(body ? { 'content-type': 'application/json' } : {}) }, ...(body ? { body: JSON.stringify(body) } : {}) });+ let document = null;+ try { document = await response.json(); } catch { /* An empty answer stays null. */ }+ return { status: response.status, document };+}++/** Seal one phone request the way the paired view does and send it with this person's session. */+async function phoneRequest(box, session, move) {+ const link = JSON.parse(readFileSync(box.linkFile, 'utf8'));+ const head = await relayCall(box, session, 'GET', '/api/v2/boards/' + link.board + '/state');+ assert.equal(head.status, 200, `this person reads the board: ${JSON.stringify(head.document)}`);+ const events = await relayCall(box, session, 'GET', `/api/v1/boards/${link.board}/events?after=${head.document.state.sequence}`);+ const sequence = Math.max(head.document.state.sequence, ...(events.document.events ?? []).map((event) => event.event_id)) + 1;+ const document = { version: 1, type: 'person-request', id: randomUUID(), move };+ const key = decodeBoardKey(readFileSync(box.keyFile, 'utf8').trim());+ const sealed = Buffer.from(await seal(key, new TextEncoder().encode(JSON.stringify(document)), { boardId: link.board, kind: 'request', sequence })).toString('base64url');+ const sent = await relayCall(box, session, 'POST', `/api/v1/boards/${link.board}/requests`, { sequence, sealed });+ assert.equal(sent.status, 200, `the relay stores the sealed request: ${JSON.stringify(sent.document)}`);+ return document.id;+}++/** The phone requests this board has received, by id. */+async function receivedRequests(box) {+ assert.equal((await box.cli('status')).code, 0, 'the coordinator reads the relay');+ const meta = (await box.cli('export')).document.tables.board_meta.find((row) => row.meta_key === 'relay_person_requests');+ return Object.fromEntries((meta ? JSON.parse(meta.meta_value) : []).map((record) => [record.id, record]));+}++/** Two people with write access to the fixture repository, alice and bob, and alice's linked board. */+async function teamBoard(t, approvers) {+ const box = await relayClientFixture(t);+ Object.assign(box.providerState, { people: { alice: { id: 7, permission: 'write' }, bob: { id: 8, permission: 'write' } }, signer: 'alice' });+ if (approvers) {+ const file = join(box.root, 'pullboard.json');+ writeFileSync(file, JSON.stringify({ ...JSON.parse(readFileSync(file, 'utf8')), approvers }, null, 2) + '\n');+ runFixtureGit(['add', 'pullboard.json'], { cwd: box.root, env: box.env });+ runFixtureGit(['-c', 'core.hooksPath=/dev/null', 'commit', '-q', '-m', 'chore: name the approvers'], { cwd: box.root, env: box.env });+ }+ assert.equal((await box.link()).code, 0, 'alice links the board, signed in as herself');+ return box;+}++test('the board knows its people: events name them, approvers decide [E3,E4,E20]', { timeout: 180_000 }, async (t) => { // budget: hang ceiling for two people's real CLI runs and relay calls; not a speed target.+ const box = await teamBoard(t, ['alice']);+ const link = JSON.parse(readFileSync(box.linkFile, 'utf8'));+ const alice = await personSession(box, 'alice');+ const bob = await personSession(box, 'bob');+ assert.deepEqual((await relayCall(box, alice, 'GET', `/api/v1/boards/${link.board}/approvers`)).document.approvers, ['alice'], 'relay on gave the relay the approvers pullboard.json names');++ // S4c: every move records the person who made it, and the agent if one did.+ assert.equal((await box.cli('add', box.lane, 'An item alice adds')).code, 0);+ const bobRoot = join(box.root, '..', 'bob-clone');+ runFixtureGit(['clone', '-q', box.root, bobRoot], { cwd: box.root, env: box.env });+ runFixtureGit(['remote', 'set-url', 'origin', '[email protected]:fixture/repository.git'], { cwd: bobRoot, env: box.env });+ const bobHome = join(box.root, '..', 'bob-home');+ const bobEnv = { ...box.env, HOME: bobHome, PULLBOARD_HOME: join(bobHome, '.pullboard'), PULLBOARD_MACHINE_HOME: join(bobHome, 'machine') };+ cpSync(join(box.root, '.git', 'pullboard'), join(bobRoot, '.git', 'pullboard'), { recursive: true, filter: (path) => !path.endsWith('.lock') });+ mkdirSync(join(bobEnv.PULLBOARD_HOME, 'relay-keys'), { recursive: true, mode: 0o700 });+ cpSync(box.keyFile, join(bobEnv.PULLBOARD_HOME, 'relay-keys', link.board + '.key'));+ box.providerState.signer = 'bob';+ const bobOn = await relayFixtureChild(bobRoot, bobEnv, [CLI, 'relay', 'on', '--url', box.origin, '--json']);+ box.providerState.signer = 'alice';+ assert.equal(bobOn.code, 0, `bob signs in as himself on his own computer: ${bobOn.stderr}`);+ assert.equal((await relayFixtureChild(bobRoot, bobEnv, [CLI, 'add', box.lane, 'An item bob adds', '--json'])).code, 0, 'bob adds an item');+ const exported = (await box.cli('export')).document.tables;+ const events = exported.event;+ const madeBy = (title) => {+ const id = exported.item.find((item) => item.item_title === title)?.item_id;+ return events.filter((event) => event.event_kind === 'add' && event.item_id === id).map((event) => JSON.parse(event.event_detail).person);+ };+ assert.deepEqual(madeBy('An item alice adds'), ['alice'], 'alice’s move names alice');+ assert.deepEqual(madeBy('An item bob adds'), ['bob'], 'bob’s move names bob');+ assert.ok(events.filter((event) => event.event_kind === 'add').every((event) => event.event_by), 'each move still names the agent or seat that made it');++ // S4b: only an approver answers the person's decisions, and only an approver decides rows.+ const asked = await box.cli('shout', 'person', 'Ship the health endpoint as plain text or JSON?', '--decision');+ assert.equal(asked.code, 0);+ const decision = asked.document.id ?? asked.document.shout_id ?? asked.document.result?.id;+ const fromBob = await phoneRequest(box, bob, { verb: 'answer', item: Number(decision), args: { text: 'JSON' } });+ const fromAlice = await phoneRequest(box, alice, { verb: 'answer', item: Number(decision), args: { text: 'JSON' } });+ const requests = await receivedRequests(box);+ assert.equal(requests[fromBob].status, 'refused', 'bob, a writer but not an approver, cannot answer as the person');+ assert.equal(requests[fromBob].error.code, 'NOT_APPROVER');+ assert.notEqual(requests[fromAlice].status, 'refused', 'alice, an approver, answers as the person');+ const rowFromBob = await phoneRequest(box, bob, { verb: 'spec-approve', args: { ids: 'G1' } });+ assert.equal((await receivedRequests(box))[rowFromBob].error?.code, 'NOT_APPROVER', 'bob cannot approve a row');++ // E4: a change to the list takes effect only once an existing approver makes it.+ assert.equal((await relayCall(box, bob, 'PUT', `/api/v1/boards/${link.board}/approvers`, { approvers: ['bob'] })).document.error?.code, 'NOT_APPROVER', 'bob cannot make himself an approver');+ assert.deepEqual((await relayCall(box, bob, 'GET', `/api/v1/boards/${link.board}/approvers`)).document.approvers, ['alice']);++ // S9: a move no member can open is set aside, and only an approver unlinks the board or replaces its snapshot.+ const bobMachine = JSON.parse(readFileSync(join(bobRoot, '.git', 'pullboard', 'relay.json'), 'utf8')).token;+ const head = await relayCall(box, alice, 'GET', '/api/v2/boards/' + link.board + '/state');+ const after = await relayCall(box, alice, 'GET', `/api/v1/boards/${link.board}/events?after=${head.document.state.sequence}`);+ const next = Math.max(head.document.state.sequence, ...(after.document.events ?? []).map((event) => event.event_id)) + 1;+ const junk = await relayCall(box, bobMachine, 'POST', `/api/v1/boards/${link.board}/moves`, { sequence: next, sealed: randomBytes(64).toString('base64url') });+ assert.equal(junk.status, 200, 'a member’s credential can store bytes no key opens');+ const afterJunk = await box.cli('add', box.lane, 'After the junk');+ assert.equal(afterJunk.code, 0, `replay sets the unopenable move aside and the board moves on: ${afterJunk.stderr ?? ''}${JSON.stringify(afterJunk.document ?? {}).slice(0, 600)}`);+ assert.ok((await box.cli('export')).document.tables.event.some((event) => event.event_kind === 'relay_refused' && JSON.parse(event.event_detail).sequence === next), 'the set-aside move is on the record');+ const deleted = await relayCall(box, bob, 'DELETE', `/api/v1/boards/${link.board}`);+ assert.equal(deleted.document?.error?.code, 'NOT_APPROVER', 'bob cannot unlink the board');+ const replaced = await relayCall(box, bobMachine, 'PUT', `/api/v1/boards/${link.board}/state`, { sequence: next, sealed: randomBytes(64).toString('base64url') });+ assert.equal(replaced.document?.error?.code, 'NOT_APPROVER', 'bob’s computer cannot replace the snapshot');+ assert.equal((await box.cli('status')).code, 0, 'alice’s board still reads');+});++test('a board that names no approvers takes person moves as before [E4]', { timeout: 120_000 }, async (t) => { // budget: hang ceiling for real CLI runs and relay calls; not a speed target.+ const box = await teamBoard(t, null);+ const link = JSON.parse(readFileSync(box.linkFile, 'utf8'));+ const bob = await personSession(box, 'bob');+ assert.equal((await relayCall(box, bob, 'GET', `/api/v1/boards/${link.board}/approvers`)).document.approvers, null, 'the relay holds no approvers for this board');+ const asked = await box.cli('shout', 'person', 'Plain text or JSON?', '--decision');+ const decision = asked.document.id ?? asked.document.shout_id ?? asked.document.result?.id;+ const fromBob = await phoneRequest(box, bob, { verb: 'answer', item: Number(decision), args: { text: 'JSON' } });+ assert.notEqual((await receivedRequests(box))[fromBob].status, 'refused', 'any writer’s session answers as the person, as today');+});