Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
Merge commit '47dfd8c6db8093ab50a7a22cc6c2c00166fd6137' into HEAD
Corey Olsona13f8444c90f
diff --cc docs/formats.mdindex dcac6952,931e0fe9..1c72968d--- a/docs/formats.md+++ b/docs/formats.md@@@ -115,11 -115,9 +115,11 @@@ The version table is generated from th| `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` | `3` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | On a write open of a board whose version is behind: create missing tables and indexes (version 3 adds the hot-path indexes), add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. Read opens never migrate; a board at the current version whose shape differs is reported once on stderr and left as it is. || `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` | `120` | `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` | `123` | `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 -->+A signed board uses event-log format 2; older tools refuse it.+A builder never picks an engine number (#1101). An item that adds a board move adds its own `src/<name>-engine.js` leaf as `export const NAME_ENGINE = unassignedEngine();` (importing `unassignedEngine` from `./engine-next.js`); on its branch the leaf reads as one above the highest landed engine. The landing merge writes the next number into the leaf, in landing order, inside that item's merge commit, and sets the `move engine` row above to the highest landed number. A landed number never changes, so recorded moves replay as they were written. Moves are recorded under landed numbers only: code with an unnumbered engine is for its branch's own tests, and a move it records on a real board before landing may later read under another item's number, so the item lands before its moves are used.Relay transport capability `apiVersion: 2` is independent of these versions anddiff --cc relay/service.jsindex 9ffb102d,4e0e8cef..52e1700c--- a/relay/service.js+++ b/relay/service.js@@@ -23,18 -11,13 +23,20 @@@ import { createDeviceStore } from './deimport { createDeviceHandler } from './device-http.js';import { createPairingStore } from './pairing-store.js';import { createPairingHandler } from './pairing-http.js';+ import { createKeyRequestStore } from './key-request-store.js';+ import { createKeyRequestHandler } from './key-request-http.js';import { createRelayBrowserHandler } from './browser-page.js';import { VERIFIER_STANDING_ENGINE } from '../src/machine.js';-import { SEALED_SNAPSHOT_BYTES, SNAPSHOT_BODY_BYTES } from '../src/relay-limits.js';-import { createRelayPagesHandler, snapshotPageRoot } from './pages-http.js';+import {+ SEALED_SNAPSHOT_BYTES,+ SNAPSHOT_BODY_BYTES,+} from '../src/relay-limits.js';+import {+ createRelayPagesHandler,+ snapshotPageRoot,+} from './pages-http.js';import { createStorageQuota } from './storage-quota.js';+import { createPasskeyHandler } from './passkey-http.js';import { createUploadStatusHandler } from './upload-status.js';import { createRelayBoardLinks } from './board-links.js';diff --cc src/board.jsindex 456ebfee,6b2b52af..27583cd0--- a/src/board.js+++ b/src/board.js@@@ -310,7 -314,9 +314,10 @@@ export { declareJob, recordJobRun } froexport { proposeSentinel, decideSentinel, beginSentinelRun, finishSentinelRun } from './sentinels.js';export { flakeLedger, recordFlakeObservation } from './flakes.js';export { flakeQuarantines, gateRuns, recordGateRun } from './quarantine.js';+export { personProposals, personSigning, proposePersonMove, setPersonSigning } from './person-signing.js'; // Signed person moves [E22].+ export { proofReceipts, recordProofRun } from './proof-receipts.js';+ import { refuseLongShout } from './proof-receipts.js';+ import { PROOF_RUN_ENGINE } from './proof-run-engine.js';export { recordPublishFinding } from './pr-findings.js';/** The seat readers live in seats.js; the board re-exports them so `store.*` callers keep one import. */export { agentAt, agentById, agentCreator, coordinatorHolder, listAgents, nextSeatId, seatEnrolled, seatLineage, takeCoordinator, withVerifierStanding } from './seats.js';diff --cc src/cli-main.jsindex 36dd55bd,cd78334b..d9e68d8f--- a/src/cli-main.js+++ b/src/cli-main.js@@@ -309,7 -310,7 +310,7 @@@ async function runMain(argv, streams)const [command, verb] = parsed.positionals;const remoteRelayOn = command === 'relay' && verb === 'on' && !parsed.values.all;if (!parsed.values.help && !parsed.values.version &&- (parsed.values.as === 'person' && command !== 'decisions' && !await (await import('./person-signing-cli.js')).personMovesSigned(io.cwd, io) || command === 'relay' && ['on', 'join', 'revoke'].includes(verb) && !remoteRelayOn)) {- (parsed.values.as === 'person' && command !== 'decisions' || command === 'relay' && ['on', 'join', 'revoke', 'members'].includes(verb) && !remoteRelayOn)) {++ (parsed.values.as === 'person' && command !== 'decisions' && !await (await import('./person-signing-cli.js')).personMovesSigned(io.cwd, io) || command === 'relay' && ['on', 'join', 'revoke', 'members'].includes(verb) && !remoteRelayOn)) {(await import('./person.js')).requirePersonChannel(io.personChannel);io.caller('person');}diff --cc src/commands/answer.jsindex c7e8524a,6e4a31b1..ebee1d8a--- a/src/commands/answer.js+++ b/src/commands/answer.js@@@ -9,11 -14,9 +14,12 @@@ importimport {requirePersonChannel,} from '../person.js';+import {+ requireSignedPerson,+} from '../person-signing-cli.js';import {actOn,+ context,agentDisplayName,idArg,ordered,diff --cc src/help.jsindex 90090454,492a03f7..f02cba70--- a/src/help.js+++ b/src/help.js@@@ -40,8 -40,8 +40,9 @@@ Set urelease priority is opt-in: gate.queue.currentReleaseFirst (default false), within each board's otherwise-tied positionsmemory hold is opt-in: gate.memoryFloorMB in ~/.pullboard/settings.json holds the queue under that many MB free or critical pressure (default off)short slots for runs that name their test files are opt-in: pullboard settings gate.shortSlots <n> (default 0)+ signed person moves are opt-in: pullboard settings person.signed on makes each wait for your passkey; only the passkey turns it offrunner-first dispatch is opt-in: pullboard settings gate.runnersFirst on|off (default off)+ runner admission deadline: pullboard settings gate.runnerWaitMs <n> (default 300000ms)pullboard runner add <ssh-host> --slots <n> --browser <n> [--node <remote-path>] [--root <remote-path>]register SSH test capacity; no runner sign-in; root defaults to ~/.pullboard-runnerpullboard runner list each runner's registered slots and browsers, which it runs atdiff --cc src/next-step-defaults.jsindex c0532923,fde1f0be..9745b126--- a/src/next-step-defaults.js+++ b/src/next-step-defaults.js@@@ -1,17 -1,13 +1,25 @@@/** General CLI recovery text; operation-owned codes live in src/moves/ [P4,C7]. */export const DEFAULT_NEXT_STEPS = Object.freeze({+ PASSKEY_ASSERTION: 'confirm the move again on your passkey from the relay view',+ PASSKEY_PRESENCE: 'confirm the move again with Face ID, Touch ID or a key touch',+ PASSKEY_REGISTRATION: 'add the passkey again from the relay view on this phone or browser',+ PASSKEY_REQUIRED: 'add a passkey in the relay view on your phone or browser, then confirm the move',+ PERSON_AUTHORITY: 'upgrade the relay so it publishes its passkey stamp key, then retry',+ PERSON_AUTHORITY_CHANGED: 'check which relay this board belongs to; link it to the relay it pinned',+ PERSON_PROPOSAL: 'start the person move from a terminal seat, then confirm it with your passkey',+ PERSON_SIGNED: 'confirm it with your passkey in the relay view; pair a phone or browser first with pullboard relay on --all',+ PERSON_SIGNER_REQUIRED: 'decide the other rows with your passkey; a row that names SSH signers waits until signing is off',+ PERSON_SIGNING_CORRUPT: 'restore the board from a known-good export',+ PERSON_SIGNING_ERASED: 'restore a known-good board that keeps its signing history',+ PERSON_SIGNING_RELAY: 'link this board to the relay with pullboard relay on --all, then turn signing on',+ "DECISIONS_NOT_AVAILABLE": "read each board's state from the local API, which carries its own person decisions",+ "PROJECT_REPO_AMBIGUOUS": "run pullboard decisions --as person and answer with the repo name it prints before the #",+ "PROJECT_REPO_UNKNOWN": "run pullboard decisions --as person to see the repos of this project, then answer repo#id",+ "COMPANION_PARENT": "name the parent item: pullboard companion <parent> <lane> \"<title>\" --key <key>",+ "COMPANION_KEY": "supply a stable --key and reuse it for this same parent and target lane",+ "COMPANION_LANE": "choose a different target lane; ordinary same-lane children use pullboard add --parent",+ "COMPANION_CONTENT": "supply title, criterion and brief text and existing spec ids for the companion",+ "COMPANION_RECORD": "restore a consistent board export so the companion request index matches its child","BOARD_REFERENCE": "use an immutable board ID or one exact qualified name from the authorized project inventory","BOARD_LINK_FORMAT": "use the exact bounded version 1 board-link, approval, announcement or sealed envelope contract","BOARD_LINK_AUTH": "configure each board’s established signer authority and the per-link sealing capability; never use an unsigned or full-board-key fallback",diff --cc src/relay-outbox.jsindex e9aa2022,f01ac266..9c5252e4--- a/src/relay-outbox.js+++ b/src/relay-outbox.js@@@ -175,7 -176,7 +176,7 @@@ export const ITEM_SLOTS = Object.freezerecordRowDecisions: [], decideSpecRevisions: [], applyRowDecisions: [], draftSpecRow: [], recordSpecApprovalBaseline: [],recordLandingBatch: [], recordLandingWaiver: [], recordLandingFlake: [], recordLandingTestDefect: [], finishLandingBatch: [],recordHealthFindings: [], decideSentinel: [], beginSentinelRun: [], finishSentinelRun: [],- recordFlakeObservation: [], recordGateRun: [], declareJob: [], recordJobRun: [], takeCoordinator: [], openHandoff: [], landingLeaseMove: [], setPersonSigning: [], proposePersonMove: [],- recordFlakeObservation: [], recordGateRun: [], recordProofRun: [[0, 'itemId'], [0, 'receipt', 'proof', 'item']], declareJob: [], recordJobRun: [], takeCoordinator: [], openHandoff: [], landingLeaseMove: [],++ recordFlakeObservation: [], recordGateRun: [], recordProofRun: [[0, 'itemId'], [0, 'receipt', 'proof', 'item']], declareJob: [], recordJobRun: [], takeCoordinator: [], openHandoff: [], landingLeaseMove: [], setPersonSigning: [], proposePersonMove: [],...Object.fromEntries(FIRST_ITEM.map((operation) => [operation, [[0]]])),intakeOutside: [[0, 'item', 'parentId'], [0, 'item', 'after', '*']],addItem: [[0, 'parentId'], [0, 'after', '*']],diff --cc test/boundary.test.jsindex d26057e2,49c6b6dc..d2d9f097--- a/test/boundary.test.js+++ b/test/boundary.test.js@@@ -39,8 -39,8 +39,10 @@@ test('the core names no model, engine otest('only explicit relay commands open outbound connections; the view defaults to loopback and API stays loopback [P5, H15, H17, H19, N26, A2]', () => {const allowed = (file, line) => file === 'src/relay.js' ||(file === 'src/relay-pairing-client.js' && line.trim() === 'response = await fetch(new URL(path, url), {') ||+ // A board that signs person moves reads its linked relay's person authority, the relay link it already holds (#408).+ (file === 'src/person-signing-cli.js' && line.trim() === "const response = await fetch(new URL(AUTHORITY_PATH, origin), { redirect: 'error', signal: AbortSignal.timeout(timeoutMs) });") ||+ // relay on's key hand-over reads a person's public SSH keys from GitHub itself, so the relay cannot add one [E17].+ (file === 'src/relay-handover.js' && line.trim() === "const response = await fetch(new URL('users/' + encodeURIComponent(login) + '/keys', base.href.endsWith('/') ? base : base.href + '/'),") ||(['src/serve.js', 'src/api.js'].includes(file) && line.trim() === "import { createServer } from 'node:http';") ||(file === 'src/local-fetch.js' && line.trim() === "import { request as httpRequest } from 'node:http';") ||(file === 'src/serve.js' && line.trim() === "const reply = await fetch(address.origin + path, { headers: { 'x-pullboard-key': address.searchParams.get('k') } });") ||diff --cc test/move-registry-baseline.jsonindex 2fbd0489,449f4784..7c953437--- a/test/move-registry-baseline.json+++ b/test/move-registry-baseline.json@@@ -66,9 -67,9 +67,11 @@@"actOnActivity","recordActivityDelivery","decideSpecRevisions",+ "proposePersonMove","recordRowVerification",+ "requestCompanion",- "setBoardMembers"++ "setBoardMembers",+ "setPersonSigning"],"itemIdFirstArgument": ["signBar",@@@ -670,21 -679,21 +681,37 @@@null,null],+ "setBoardMembers": [+ null,+ "first",+ null,+ null,+ null,+ null+ ],+ "requestCompanion": [+ null,+ "first",+ null,+ null,+ null,+ null++ ],+ "proposePersonMove": [+ null,+ "first",+ null,+ null,+ null,+ null+ ],+ "setPersonSigning": [+ null,+ "first",+ null,+ null,+ null,+ null]},"floorCases": [@@@ -7051,18 -7069,24 +7087,36 @@@"ROW_VERIFY_PROVENANCE": "draft the row through pullboard spec draft and join normally before verifying it","ROW_VERIFY_PENDING": "ask the coordinator to run pullboard spec apply before recording a verifier verdict","ROW_VERIFY_SELF": "ask an outside-parent verifier to run pullboard spec verify",+ "PASSKEY_ASSERTION": "confirm the move again on your passkey from the relay view",+ "PASSKEY_PRESENCE": "confirm the move again with Face ID, Touch ID or a key touch",+ "PASSKEY_REGISTRATION": "add the passkey again from the relay view on this phone or browser",+ "PASSKEY_REQUIRED": "add a passkey in the relay view on your phone or browser, then confirm the move",+ "PERSON_AUTHORITY": "upgrade the relay so it publishes its passkey stamp key, then retry",+ "PERSON_AUTHORITY_CHANGED": "check which relay this board belongs to; link it to the relay it pinned",+ "PERSON_PROPOSAL": "start the person move from a terminal seat, then confirm it with your passkey",+ "PERSON_SIGNED": "confirm it with your passkey in the relay view; pair a phone or browser first with pullboard relay on --all",+ "PERSON_SIGNER_REQUIRED": "decide the other rows with your passkey; a row that names SSH signers waits until signing is off",+ "PERSON_SIGNING_CORRUPT": "restore the board from a known-good export",+ "PERSON_SIGNING_ERASED": "restore a known-good board that keeps its signing history",- "PERSON_SIGNING_RELAY": "link this board to the relay with pullboard relay on --all, then turn signing on"++ "PERSON_SIGNING_RELAY": "link this board to the relay with pullboard relay on --all, then turn signing on",+ "BOARD_MEMBERS_INVALID": "ask a committed approver to publish a complete signed board member list",+ "BOARD_MEMBERS_REVISION": "read the current member revision, then sign a new list",+ "RELAY_NOT_MEMBER": "ask a committed approver to publish the board member list with pullboard relay members set <login>, then retry relay on",+ "BOARD_REPLACE": "run pullboard relay on again; a relink replaces only the repository's active board",+ "BOARD_REPO_LINKED": "pull pullboard.json from main, which names the repository's board, then run pullboard relay on again to join it",+ "GITHUB_UNAVAILABLE": "run any pullboard command again once GitHub answers; the new device keeps waiting",+ "RELAY_JOIN_NOT_EMPTY": "keep this board, then run pullboard init and pullboard relay on in a fresh clone to join the team board",+ "RELAY_KEY_VOUCH": "add the SSH key that signed this device to your GitHub account with gh ssh-key add, then run pullboard relay on again",+ "RELAY_KEY_WAIT_EXPIRED": "run pullboard relay on again while a linked computer of this repository is online",+ "RELAY_SSH_KEY": "make an SSH key with ssh-keygen -t ed25519, add it to GitHub with gh ssh-key add, then run pullboard relay on again",+ "RELAY_SSH_KEYGEN": "install OpenSSH, then run pullboard relay on again",+ "RELAY_SSH_SIGN": "load the key with ssh-add, or set PULLBOARD_SSH_KEY to a key on your GitHub account, then run pullboard relay on again",+ "COMPANION_PARENT": "name the parent item: pullboard companion <parent> <lane> \"<title>\" --key <key>",+ "COMPANION_KEY": "supply a stable --key and reuse it for this same parent and target lane",+ "COMPANION_LANE": "choose a different target lane; ordinary same-lane children use pullboard add --parent",+ "COMPANION_CONTENT": "supply title, criterion and brief text and existing spec ids for the companion",+ "COMPANION_RECORD": "restore a consistent board export so the companion request index matches its child",+ "RUNNER_WAIT_DEADLINE": "check the runners the message names, or restore local gate capacity with pullboard settings, then retry"},"replay": {"initial": {diff --cc test/team.test.jsindex 4c607fab,a9fe9198..7db3d9fa--- a/test/team.test.js+++ b/test/team.test.js@@@ -3,102 -3,34 +3,99 @@@import assert from 'node:assert/strict';import childProcess from 'node:child_process';import { syncBuiltinESMExports } from 'node:module';-import { existsSync, mkdtempSync, mkdirSync, readFileSync, writeFileSync, rmSync, cpSync, readdirSync, lstatSync, renameSync, symlinkSync } from 'node:fs';-import { randomBytes, randomUUID } from 'node:crypto';-import { join, resolve } from 'node:path';+import {+ existsSync,+ mkdtempSync,+ mkdirSync,+ readFileSync,+ writeFileSync,+ rmSync,+ cpSync,+ readdirSync,+ lstatSync,+ renameSync,+ symlinkSync,+} from 'node:fs';+import {+ createHash,+ randomBytes,+ randomUUID,+} from 'node:crypto';+import {+ join,+ resolve,+} from 'node:path';import { pathToFileURL } from 'node:url';-import { after, test } from 'node:test';+import {+ after,+ test,+} from 'node:test';import * as store from '../src/board.js';-import { exportBoard, importBoard } from '../src/exchange.js';-import { applyEngineMove, prepareEngineMove } from '../src/engine.js';-import { relayClientFixture as sessionRelay, relayFixtureChild as sessionChild, relayClientFixture, relayFixtureChild } from './relay-client-fixture.js';-import { runFixtureGit as sessionGit, runFixtureGit, runFixtureChild } from './fixture-child.js';+import {+ exportBoard,+ importBoard,+} from '../src/exchange.js';+import {+ applyEngineMove,+ prepareEngineMove,+} from '../src/engine.js';+import {+ relayClientFixture as sessionRelay,+ relayFixtureChild as sessionChild,+ relayClientFixture,+ relayFixtureChild,+} from './relay-client-fixture.js';+import {+ runFixtureChild,+ runFixtureGit as sessionGit,+ runFixtureGit,+} from './fixture-child.js';+import {+ grantChallenge,+ softwarePasskey,+} from './person-passkey-fixture.js';+import {+ optionalPasskeyApply,+ optionalPasskeyApplyThroughCli,+ rejectFabricatedPasskeyMetadata,+ rejectSyntheticPasskeyEvent,+} from './person-optional-apply-fixture.js';+import { rejectConsumedOffReplay } from './person-off-replay-fixture.js';+import {+ firstPinNeedsBuiltInRelay,+ firstUnpairedAuthorityInsertion,+} from './person-first-pin-fixture.js';+import { refuseNamedSigners } from '../src/person-signing-cli.js';import { createE2eHelpers } from './e2e-helpers.js';-import { serveApi } from '../src/api.js';+import {+ executeMove,+ serveApi,+} from '../src/api.js';import { main } from '../src/cli.js';import { fetchFresh } from './http-fixture.js';-import { relaySnapshot, presentationDigest } from '../src/relay-presentation.js';+import {+ relaySnapshot,+ presentationDigest,+} from '../src/relay-presentation.js';import { snapshotState } from '../relay/browser-model.js';import { unpackRelease } from './release-archive.js';-import { decodeBoardKey, seal } from '../src/seal.js';+import {+ decodeBoardKey,+ seal,+} from '../src/seal.js';import { ENGINE_VERSION as PEOPLE_VERSION } from '../src/machine.js';import { relayWorkBudgetMs } from './relay-budget.js';- import {- hostname,- tmpdir,- } from 'node:os';- import {- assertMatchingLandingHost,- assertNoCulpritTrunkHold,- } from './landing-environment-fixture.js';+ import { hostname, tmpdir } from 'node:os';+ import { createDeviceKeys, unwrapDeviceBoardKey } from '../src/relay-device-keys.js';+ import { handOverBoardKeys, statementBytes } from '../src/relay-handover.js';+ import { signSshVouch } from '../src/relay-ssh-proof.js';+ import { assertMatchingLandingHost, assertNoCulpritTrunkHold } from './landing-environment-fixture.js';import { landingQueueCase } from './landing-queue-fixture.js';+import { DatabaseSync } from 'node:sqlite';const CLI = join(import.meta.dirname, '..', 'bin', 'pullboard.js');+/** The shipped command run with an explicit trusted fixture relay; test-only, never published (#408). */+const TRUSTED_CLI = join(import.meta.dirname, 'person-trusted-cli.js');const helpers = createE2eHelpers();after(helpers.cleanup);@@@ -947,312 -1020,142 +1088,451 @@@ test('a landing lease renewal or waiteassert.equal(state.line.length, 1, 'suppressing polling events does not discard the waiting command');});+/** Send one sealed person request with its passkey presence, returning the relay's answer. */+async function passkeyRequest(box, session, document, presence) {+ const link = JSON.parse(readFileSync(box.linkFile, 'utf8'));+ const head = await relayCall(box, session, 'GET', '/api/v2/boards/' + link.board + '/state');+ 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 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');+ return relayCall(box, session, 'POST', `/api/v1/boards/${link.board}/requests`, { sequence, sealed, ...(presence ? { presence } : {}) });+}++/** True when no regular file under a directory holds a person session or a person grant. */+function holdsNoPersonCredential(directory) {+ return filesUnder(directory).every((file) => !/(?:ps_|pg_)[A-Za-z0-9_-]{43}/u.test(readFileSync(file).toString('latin1')));+}++test('person-only moves are signed [E22,B26,H16]', { timeout: relayWorkBudgetMs(60) }, async (t) => { // budget: hang ceiling for real CLI runs and relay calls; not a speed target.+ const box = await relayClientFixture(t);+ // The shipped command, handed the loopback fixture relay as an explicit trusted parameter in this test's own call path:+ // no environment variable or global can make the real CLI trust it (#408 rulings 38756cb3 and 28611).+ const trusted = [TRUSTED_CLI, box.origin];+ /** Run the command in the main checkout with a chosen environment, trusting only this fixture relay. */+ const cli = (env, ...args) => relayFixtureChild(box.root, env, [...trusted, ...args, '--json']);+ // S10a: an agent that cleared AI_AGENT and CLAUDECODE has exactly the person's shell markers.+ const cleared = { ...box.env };+ const marked = { ...box.env, AI_AGENT: '1', CLAUDECODE: '1' };++ // Off, the default: person moves work as today, and status says once that they are not signed.+ const text = runFixtureChild(process.execPath, [CLI, 'status'], { cwd: box.root, env: box.env, encoding: 'utf8' });+ assert.equal(text.status, 0);+ assert.equal(text.stdout.split('\n').filter((line) => /person moves are not signed/u.test(line)).length, 1, 'status says it in one line');+ assert.equal((await box.cli('status')).document.person.signed, false);+ const early = (await box.cli('shout', 'person', 'A decision before signing', '--decision')).document.id;+ assert.equal((await cli(box.env, 'answer', String(early), 'Off answers as today', '--as', 'person')).code, 0, 'off: the terminal answers as the person');++ // A board with no relay cannot turn signing on: only the relay can vouch for a passkey (#408 trust-anchor ruling).+ const offline = await cli(marked, 'settings', 'person.signed', 'on');+ assert.equal(offline.document.error?.code, 'PERSON_SIGNING_RELAY', `no relay, no signing: ${JSON.stringify(offline.document)}`);+ // Linked, turning signing on is allowed from the terminal, even an agent's; unlinking then still works with no tap.+ assert.equal((await box.link()).code, 0);+ const on = await cli(marked, 'settings', 'person.signed', 'on');+ assert.equal(on.code, 0, `an agent may turn signing on: ${JSON.stringify(on.document)}`);+ assert.equal(on.document.person.signed, true);+ const ask = (await box.cli('shout', 'person', 'A decision only the person answers', '--decision')).document.id;+ // The same board on a device that is not paired: its link set aside, restored below without linking again, and no+ // move succeeds meanwhile, so the relay and the board still agree when it returns.+ renameSync(box.linkFile, `${box.linkFile}.unpaired`);++ // S10a and the on-and-unpaired case: every person move fails closed at once, naming how to pair a passkey.+ const calls = box.calls.length;+ for (const words of [['answer', String(ask), 'S10a cleared markers', '--as', 'person'], ['spec', 'approve', 'E1'], ['spec', 'approve', 'doctrine:D1'],+ ['spec', 'decline', 'E1', '--reason', 'no'], ['land', '--waive', 'test/x.test.js', '--until', '2099-01-01', '--reason', 'flaky'], ['settings', 'person.signed', 'off']]) {+ const refused = await cli(cleared, ...words);+ assert.equal(refused.code, 1, words.join(' '));+ assert.equal(refused.document.error.code, 'PERSON_SIGNED', `${words.join(' ')}: ${JSON.stringify(refused.document)}`);+ assert.match(refused.document.error.next, /relay on --all/u, 'unpaired: the next step pairs a phone or browser');+ assert.match(refused.document.error.next, /passkey/u);+ }+ assert.equal(box.calls.length, calls, 'refused locally, before any network call or wait');+ assert.equal((await cli(marked, 'answer', String(ask), 'marked agent', '--as', 'person')).document.error.code, 'PERSON_SIGNED', 'an agent shell is refused too');+ const remote = await cli({ ...cleared, SSH_CONNECTION: '10.0.0.2 50000 10.0.0.1 22' }, 'answer', String(ask), 'from SSH', '--as', 'person');+ assert.equal(remote.document.error.code, 'PERSON_SIGNED', 'over SSH the same passkey step applies');++ // No local file edit turns it off: not the project config, not machine settings.+ const config = join(box.root, 'pullboard.json');+ writeFileSync(config, JSON.stringify({ ...JSON.parse(readFileSync(config, 'utf8')), person: { signed: false } }, null, 2) + '\n');+ mkdirSync(box.env.PULLBOARD_MACHINE_HOME, { recursive: true });+ writeFileSync(join(box.env.PULLBOARD_MACHINE_HOME, 'settings.json'), JSON.stringify({ person: { signed: false } }) + '\n');+ assert.equal((await cli(cleared, 'answer', String(ask), 'after edits', '--as', 'person')).document.error.code, 'PERSON_SIGNED', 'edits leave it on');+ assert.equal((await box.cli('status')).document.person.signed, true);++ // S10b: whatever the OS user can read, an agent can read, so the local view's channel is refused too.+ const viewed = await executeMove(box.root, { verb: 'answer', item: ask, args: { as: 'person', text: 'through the view secret' } }, main);+ assert.equal(viewed.body.error?.code, 'PERSON_SIGNED', 'the view channel is not the person once signing is on');++ // Linked, a terminal person move goes to the passkey as an action-bound request and says where to confirm.+ renameSync(`${box.linkFile}.unpaired`, box.linkFile);+ assert.ok(holdsNoPersonCredential(box.root) && holdsNoPersonCredential(box.env.HOME), 'no file holds a person session or grant');+ const terminal = helpers.launch({ ...box, env: { ...cleared, SSH_CONNECTION: '127.0.0.1 40000 127.0.0.1 22' } },+ box.root, process.execPath, [...trusted, 'answer', String(ask), 'Signed on the passkey', '--as', 'person', '--json']);+ t.after(async () => { if (terminal.exitCode === null && terminal.signalCode === null) terminal.kill('SIGTERM'); await terminal.closed; });+ /** Observe fixture SQLite directly; no second command may execute the waiting action. */+ const nativeRows = (sql, ...args) => {+ const db = new DatabaseSync(join(box.root, '.git', 'pullboard', 'board.sqlite'), { readOnly: true });+ try { return db.prepare(sql).all(...args); } finally { db.close(); }+ };+ /** Read durable request receipts without running status, export or another command. */+ const nativeRequests = () => Object.fromEntries(JSON.parse(nativeRows('SELECT meta_value FROM board_meta WHERE meta_key=?',+ 'relay_person_requests')[0]?.meta_value ?? '[]').filter(record => !record.duplicateOf).map(record => [record.id, record]));+ await helpers.waitFor(() => {+ assert.equal(terminal.exitCode, null, terminal.stderrText);+ return terminal.stderrText.includes(box.origin) && terminal.stderrText.includes('this terminal is waiting');+ }, 'the original SSH terminal asks for one passkey confirmation', relayWorkBudgetMs(5));+ const proposals = JSON.parse(nativeRows('SELECT meta_value FROM board_meta WHERE meta_key=?', 'person_proposals')[0].meta_value);+ const proposal = proposals.at(-1);+ assert.deepEqual(proposal.move, { verb: 'answer', item: ask, args: { as: 'person', text: 'Signed on the passkey' } }, 'the exact move waits for the passkey');++ // The person registers a passkey with user presence; agents and machines cannot ask for a grant.+ const link = JSON.parse(readFileSync(box.linkFile, 'utf8'));+ const phone = (await box.phoneSession()).token;+ const passkey = softwarePasskey(box.origin);+ const challenge = await relayCall(box, phone, 'POST', '/api/v1/passkeys/challenge', {});+ assert.equal(challenge.status, 200, JSON.stringify(challenge.document));+ const registered = await relayCall(box, phone, 'POST', '/api/v1/passkeys', { challenge: challenge.document.challenge, ...passkey.create(challenge.document.challenge) });+ assert.equal(registered.status, 200, JSON.stringify(registered.document));+ const document = { version: 1, type: 'person-request', id: proposal.id, move: proposal.move };+ const machineGrant = await relayCall(box, link.token, 'POST', `/api/v1/boards/${link.board}/person-grants`, { request: proposal.id, digest: 'a'.repeat(64) });+ assert.equal(machineGrant.document.error?.code, 'HUMAN_REQUIRED', 'the machine credential, which agents share, gets no grant');+ /** Ask the relay for a fresh single-use grant for this request and the digest of its exact intent. */+ const grantFor = async (document) => {+ const digest = createHash('sha256').update(JSON.stringify(document)).digest('hex');+ const issued = await relayCall(box, phone, 'POST', `/api/v1/boards/${link.board}/person-grants`, { request: document.id, digest });+ assert.equal(issued.status, 200, JSON.stringify(issued.document));+ assert.deepEqual(issued.document.credentials, [passkey.id]);+ return issued.document.grant;+ };++ // Without user presence, or with no assertion at all, nothing acts as the person.+ const absent = await passkeyRequest(box, phone, document, { grant: await grantFor(document), ...passkey.get(grantChallenge('not-this-grant')) });+ assert.equal(absent.document.error?.code, 'PASSKEY_ASSERTION', 'an assertion over another challenge is refused');+ const grant = await grantFor(document);+ const noPresence = await passkeyRequest(box, phone, document, { grant, ...passkey.get(grantChallenge(grant), { presence: false }) });+ assert.equal(noPresence.document.error?.code, 'PASSKEY_PRESENCE', 'an authenticator answer with no user present is refused');+ const elsewhere = await passkeyRequest(box, phone, document, { grant, ...passkey.get(grantChallenge(grant), { origin: 'http://elsewhere.localhost' }) });+ assert.equal(elsewhere.document.error?.code, 'PASSKEY_ASSERTION', 'an answer made for another site is refused');+ const forgedSignature = { grant, ...passkey.get(grantChallenge(grant)), signature: passkey.get(grantChallenge('other bytes')).signature };+ assert.equal((await passkeyRequest(box, phone, document, forgedSignature)).document.error?.code, 'PASSKEY_ASSERTION', 'a signature over other bytes is refused');+ const unsigned = { version: 1, type: 'person-request', id: randomUUID(), move: proposal.move };+ assert.equal((await passkeyRequest(box, phone, unsigned)).status, 200, 'the relay stores a session request without a passkey');+ await helpers.waitFor(() => nativeRequests()[unsigned.id]?.status === 'refused', 'the waiting terminal refuses unsigned intent', relayWorkBudgetMs(5));+ let received = nativeRequests();+ assert.equal(received[unsigned.id].status, 'refused');+ assert.equal(received[unsigned.id].error.code, 'PERSON_SIGNED', 'without a passkey the native board refuses it');++ // One confirmation on the passkey carries out the exact move, once.+ const presence = { grant, ...passkey.get(grantChallenge(grant)) };+ const signed = await passkeyRequest(box, phone, document, presence);+ assert.equal(signed.status, 200, JSON.stringify(signed.document));+ const terminalResult = await terminal.closed;+ assert.equal(terminalResult.code, 0, terminal.stderrText);+ assert.equal(JSON.parse(terminal.stdoutText).request, proposal.id, 'the original terminal reports its exact request');+ received = nativeRequests();+ assert.equal(received[proposal.id].status, 'done', JSON.stringify(received[proposal.id]));+ const answers = nativeRows('SELECT * FROM shout WHERE shout_answers=?', ask);+ assert.deepEqual(answers.map((row) => [row.shout_from, row.shout_text]), [['person', 'Signed on the passkey']]);+ const replay = await passkeyRequest(box, phone, { ...document, id: randomUUID() }, presence);+ assert.equal(replay.document.error?.code, 'PHONE_APPROVAL_USED', 'the grant is single-use');+ assert.ok(holdsNoPersonCredential(box.root) && holdsNoPersonCredential(box.env.HOME), 'the grant was never stored');++ // A hand edit to the board file cannot forge a passkey request, turn signing off or swap the relay key.+ const raw = new DatabaseSync(join(box.root, '.git', 'pullboard', 'board.sqlite'));+ try {+ /** One board metadata value, read straight from the file. */+ const meta = (key) => raw.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(key)?.meta_value;+ assert.equal(meta('event_log_version'), '2', 'a Pullboard from before signed moves refuses this board');+ assert.throws(() => raw.prepare("UPDATE board_meta SET meta_value='{}' WHERE meta_key='person_authority_local'").run(), /PERSON_AUTHORITY/u, 'the pinned relay key stays');+ assert.throws(() => raw.prepare("INSERT OR REPLACE INTO board_meta(meta_key,meta_value) VALUES ('person_authority_local','{}')").run(), /PERSON_AUTHORITY/u);+ assert.throws(() => raw.prepare("DELETE FROM event WHERE event_kind='person_signing'").run(), /APPEND_ONLY/u, 'the signing history stays');+ const records = JSON.parse(meta('relay_person_requests'));+ const genuine = records.find((record) => record.id === proposal.id);+ const sender = JSON.parse(genuine.received).sender;+ // A genuine stamp copied into a hand-written off names the digest of another request.+ raw.prepare('INSERT INTO event (event_at, event_by, event_kind, item_id, event_detail) VALUES (?,?,?,?,?)').run(new Date().toISOString(), 'person', 'person_signing', null,+ JSON.stringify({ signed: false, request: proposal.id, presence: sender.presence, intent: { version: 1, type: 'person-request', id: proposal.id, move: { verb: 'signing', args: { signed: 'off' } } } }));+ // The same stamp on a rewritten request: the same id, another answer, waiting to run again.+ const forged = structuredClone(document);+ forged.move.args.text = 'A forged second answer';+ const { result, resultSequence, executor, executorUntil, ...rest } = genuine;+ const rewritten = { ...rest, move: forged.move, encoded: JSON.stringify(forged), received: JSON.stringify({ document: forged, sender }), status: 'waiting' };+ raw.prepare('UPDATE board_meta SET meta_value=? WHERE meta_key=?').run(JSON.stringify(records.map((record) => record.id === genuine.id ? rewritten : record)), 'relay_person_requests');+ } finally { raw.close(); }+ assert.equal((await box.cli('status')).document.person.signed, true, 'the hand-written off turns nothing off');+ const waitingAgain = helpers.launch({ ...box, env: cleared }, box.root, process.execPath,+ [...trusted, 'answer', String(ask), 'still signed', '--as', 'person', '--json']);+ try {+ await helpers.waitFor(() => { assert.equal(waitingAgain.exitCode, null, waitingAgain.stderrText); return waitingAgain.stderrText.includes('this terminal is waiting'); },+ 'a cleared-marker terminal still waits for a new confirmation', relayWorkBudgetMs(5));+ assert.equal(nativeRows('SELECT * FROM shout WHERE shout_answers=?', ask).length, 1, 'waiting creates no second person answer');+ } finally { if (waitingAgain.exitCode === null && waitingAgain.signalCode === null) waitingAgain.kill('SIGTERM'); await waitingAgain.closed; }+ assert.equal((await box.cli('export')).document.tables.shout.filter((row) => row.shout_answers === ask).length, 1, 'the rewritten request never runs as the person');++ // A signed row decision binds the exact rows the person saw; a row naming SSH signers is refused by name.+ const shown = { id: 'G1', text: 'A row the person decides on the passkey.' };+ writeFileSync(join(box.root, 'SPEC.md'), readFileSync(join(box.root, 'SPEC.md'), 'utf8').replace('## G · Goals: what the client asked for\n',+ `## G · Goals: what the client asked for\n\n- G1 [draft, must] ${shown.text} | gate: review\n`));+ // The template's own placeholder G1 may sit beside it; the person sees the row this test wrote.+ shown.source = readFileSync(join(box.root, 'SPEC.md'), 'utf8').split(/\r?\n/u).find(line => line.startsWith('- G1 ') && line.includes(shown.text));+ const blind = { version: 1, type: 'person-request', id: randomUUID(), move: { verb: 'spec-approve', args: { ids: 'G1' } } };+ const seen = { ...blind, id: randomUUID(), rows: [shown] };+ for (const request of [blind, seen]) {+ const rowGrant = await grantFor(request);+ assert.equal((await passkeyRequest(box, phone, request, { grant: rowGrant, ...passkey.get(grantChallenge(rowGrant)) })).status, 200);+ }+ received = await receivedRequests(box, (...args) => cli(box.env, ...args));+ assert.equal(received[blind.id].error?.code, 'STALE_ROW_DECISION', 'a decision that does not name the rows shown is refused');+ assert.notEqual(received[seen.id].status, 'refused', JSON.stringify(received[seen.id]));+ const decided = (await box.cli('export')).document.tables.event.filter((row) => row.event_kind === 'row_decision');+ assert.deepEqual(decided.map((row) => [row.event_by, JSON.parse(row.event_detail).record.id]), [['person', 'G1']], 'the passkey decided exactly the row it showed');+ // The real CLI applies that decision, checked against the authority its relay vouches for, never a stored key (#408).+ const applied = await cli(box.env, 'spec', 'apply');+ assert.equal(applied.code, 0, JSON.stringify(applied.document));+ assert.match(readFileSync(join(box.root, 'SPEC.md'), 'utf8'), /- G1 \[approved, must\] A row the person decides on the passkey\./u, 'the native CLI applies the passkey approval');+ assert.throws(() => refuseNamedSigners([{ id: 'G2', signers: ['[email protected]'] }], ['G2']), { code: 'PERSON_SIGNER_REQUIRED', message: /G2 names its SSH signers alice@example\.com/u });++ /** One live SSH command, one confirmation, no status/export/other CLI before its original exit. */+ async function confirmTerminal(argv, expectedVerb) {+ const beforeIds = new Set(JSON.parse(nativeRows('SELECT meta_value FROM board_meta WHERE meta_key=?', 'person_proposals')[0]?.meta_value ?? '[]').map(entry => entry.id));+ const child = helpers.launch({ ...box, env: { ...cleared, SSH_CONNECTION: '127.0.0.1 40000 127.0.0.1 22' } },+ box.root, process.execPath, [...trusted, ...argv, '--json']);+ try {+ const proposal = await helpers.waitFor(() => {+ assert.equal(child.exitCode, null, child.stderrText);+ if (!child.stderrText.includes('this terminal is waiting')) return null;+ return JSON.parse(nativeRows('SELECT meta_value FROM board_meta WHERE meta_key=?', 'person_proposals')[0]?.meta_value ?? '[]').find(entry => !beforeIds.has(entry.id));+ }, 'the exact new terminal proposal', relayWorkBudgetMs(5));+ assert.equal(proposal.move.verb, expectedVerb);+ const request = { version: 1, type: 'person-request', id: proposal.id, move: proposal.move,+ ...(proposal.rows ? { rows: proposal.rows } : {}) };+ const actionGrant = await grantFor(request);+ assert.equal((await passkeyRequest(box, phone, request, { grant: actionGrant, ...passkey.get(grantChallenge(actionGrant)) })).status, 200);+ const outcome = await child.closed;+ assert.equal(outcome.code, 0, child.stderrText);+ const result = JSON.parse(child.stdoutText);+ assert.equal(result.request, proposal.id);+ assert.ok(['done', 'waiting'].includes(nativeRequests()[proposal.id].status));+ return result;+ } finally {+ if (child.exitCode === null && child.signalCode === null) child.kill('SIGTERM');+ await child.closed;+ }+ }+ // Each newly mapped action must complete on its original terminal, with exact target/meaning.+ const factItem = (await box.cli('add', box.lane, 'SIGNED_FACT_TARGET')).document.item.item_id;+ const fact = await confirmTerminal(['fact', String(factItem), 'decision', 'Keep this exact rule', '--as', 'person', '--cause', 'row:G1', '--never-again'], 'fact');+ assert.equal(fact.item, factItem);+ assert.equal(fact.fact.text, 'Keep this exact rule');+ const held = await confirmTerminal(['hold', box.lane, '--as', 'person', '--reason', 'Wait for the exact reviewed rule'], 'hold');+ assert.equal(held.held, true);+ assert.equal(nativeRows('SELECT hold_reason,hold_by FROM hold WHERE hold_lane=?', box.lane)[0].hold_by, 'person');+ const unheld = await confirmTerminal(['hold', box.lane, '--as', 'person', '--off'], 'hold');+ assert.equal(unheld.held, false);+ assert.equal(nativeRows('SELECT * FROM hold WHERE hold_lane=?', box.lane).length, 0);+ for (const name of ['signed-watch-approved', 'signed-watch-declined']) {+ assert.equal((await box.cli('sentinel', 'propose', name, '--check', 'true', '--every', 'hourly', '--owner', 'coordinator')).code, 0);+ }+ const watch = await confirmTerminal(['sentinel', 'approve', 'signed-watch-approved'], 'sentinel-approve');+ assert.equal(watch.sentinel.status, 'approved');+ const declinedWatch = await confirmTerminal(['sentinel', 'decline', 'signed-watch-declined', '--reason', 'Do not run this exact watch'], 'sentinel-decline');+ assert.equal(declinedWatch.sentinel.status, 'declined');+ const question = 'Which store holds the data: SQLite. Choices: SQLite, Postgres.';+ writeFileSync(join(box.root, 'SPEC.md'), readFileSync(join(box.root, 'SPEC.md'), 'utf8')+ + `\n- G2 [pending, must] ${question} | gate: review\n- G3 [draft, must] A terminal-approved row. | gate: review\n- G4 [draft, must] A terminal-declined row. | gate: review\n`);+ const answeredRow = await confirmTerminal(['spec', 'answer', 'G2', 'Postgres'], 'spec-answer');+ assert.equal(answeredRow.decisions[0].id, 'G2');+ assert.match(answeredRow.decisions[0].text, /data: Postgres/u);+ const approvedRow = await confirmTerminal(['spec', 'approve', 'G3'], 'spec-approve');+ assert.equal(approvedRow.decisions[0].decision, 'approve');+ const declinedRow = await confirmTerminal(['spec', 'decline', 'G4', '--reason', 'Do not approve this row'], 'spec-decline');+ assert.equal(declinedRow.decisions[0].decision, 'decline');+ writeFileSync(join(box.root, 'SPEC.md'), readFileSync(join(box.root, 'SPEC.md'), 'utf8')+ + '\n- G5 [approved, must] An optional sign-off row. | gate: review\n- G6 [approved, must] A named-signature row. | gate: review | signers: [email protected]\n');+ mkdirSync(join(box.root, 'test'), { recursive: true });+ writeFileSync(join(box.root, 'test', 'signed-evidence.test.js'), '/** [G5] Cited evidence fixture; no test run is implied by optional sign-off. */\n');+ runFixtureGit(['add', 'test/signed-evidence.test.js'], { cwd: box.root, env: box.env });+ const sshFile = join(box.root, '.pullboard', 'signoffs.jsonl');+ const beforeSsh = existsSync(sshFile) ? readFileSync(sshFile, 'utf8') : null;+ const optionalSignoff = await confirmTerminal(['spec', 'signoff', 'G5'], 'spec-approve');+ assert.equal(optionalSignoff.count, 1);+ assert.equal(optionalSignoff.by, 'person');+ assert.equal(existsSync(sshFile) ? readFileSync(sshFile, 'utf8') : null, beforeSsh, 'passkey approval never writes an SSH signature');+ const namedSignoff = await cli(cleared, 'spec', 'signoff', 'G6');+ assert.equal(namedSignoff.document.error?.code, 'PERSON_SIGNER_REQUIRED');+ assert.match(namedSignoff.document.error.message, /G6 names its SSH signers alice@example\.com/u);+ const signerChange = await cli(cleared, 'spec', 'signers', 'add', '--by', '[email protected]', '--key', 'unread-key');+ assert.equal(signerChange.document.error?.code, 'PERSON_SIGNER_REQUIRED');+ assert.match(signerChange.document.error.message, /alice@example\.com/u);++ const waiver = await confirmTerminal(['land', '--waive', 'gate:lint', '--until', '2099-01-01', '--reason', 'An explicit bounded fixture exception'], 'land-waive');+ assert.equal(waiver.waiver.test, 'gate:lint');++ // Only the passkey turns signing off; unlinking offline keeps it on.+ const switchedOff = await confirmTerminal(['settings', 'person.signed', 'off'], 'signing');+ assert.equal(switchedOff.person.signed, false);+ assert.equal((await cli(box.env, 'status')).document.person.signed, false, 'the passkey turned signing off');+ assert.equal((await cli(marked, 'settings', 'person.signed', 'on')).code, 0);+ await box.stopRelay();+ await cli(cleared, 'relay', 'off');+ assert.equal(existsSync(box.linkFile), false, 'unlinking works offline with no tap');+ assert.equal((await box.cli('status')).document.person.signed, true, 'unlinking never turns signing off');+});++/** Keep the initial-unpaired local-edit clause distinct from the post-pin trigger controls. */+test('person-only moves are signed before the first authority pin [E22,B26,H16]', firstUnpairedAuthorityInsertion);++test('person-only moves are signed only from the built-in relay over TLS [E22,B26,H16]', { timeout: relayWorkBudgetMs(8) }, firstPinNeedsBuiltInRelay); // budget: hang ceiling for one link and two refused CLI runs; not a speed target.++/** Optional SSH policy must accept a genuinely bound passkey row decision without using an SSH key. */+test('person-only moves are signed through optional SSH apply [E22,H16]', optionalPasskeyApply);++/** The actual CLI applies and projects the recorded passkey approval even with optional SSH enabled. */+test('person-only moves are signed: an unlinked CLI applies no passkey decision it cannot verify [E22,H16]', optionalPasskeyApplyThroughCli);++/** Initial trust and committed execution provenance are separate signing boundaries. */+test('person-only moves are signed against fabricated receipt metadata [E22,H16]', rejectFabricatedPasskeyMetadata);++/** A local event insertion is not an authenticated execution of a different row source. */+test('person-only moves are signed against synthetic execution events [E22,H16]', rejectSyntheticPasskeyEvent);++test('person-only moves are signed against consumed OFF replay [E22,H16]', rejectConsumedOffReplay);+ /** Initialise a second repo in the first one's sandbox, so both register in the same machine home. */+ function siblingRepo(box, name, project) {+ const repo = join(box.dir, name);+ mkdirSync(repo);+ box.git(repo, 'init', '-q', '-b', 'main');+ assert.equal(box.run(repo, 'init').code, 0);+ return { repo, project };+ }++ /** Put a repo into a named project under its own name, committed so the board reads it. */+ function nameRepo(box, repo, name, project) {+ const file = join(repo, 'pullboard.json');+ const config = JSON.parse(readFileSync(file, 'utf8'));+ writeFileSync(file, JSON.stringify({ ...config, name, project }, null, 2));+ box.git(repo, 'add', '-A');+ box.git(repo, 'commit', '-q', '-m', 'chore: name the repo');+ }++ test("one decision list across a project's repos [N34]", { timeout: 180_000 }, async t => { // budget: hang ceiling for three real repos' CLI runs and one view process; not a speed target.+ const box = helpers.project();+ const other = siblingRepo(box, 'repo-b').repo;+ const lone = siblingRepo(box, 'repo-c').repo;+ nameRepo(box, box.repo, 'alpha', 'shop');+ nameRepo(box, other, 'beta', 'shop');+ nameRepo(box, lone, 'gamma', 'elsewhere');+ const ask = (root, text) => {+ const asked = box.run(root, 'shout', 'person', text, '--decision');+ assert.equal(asked.code, 0, asked.err);+ return Number(/as #(\d+)/.exec(asked.out)?.[1]);+ };+ const alphaId = ask(box.repo, 'Ship alpha?');+ const betaId = ask(other, 'Ship beta?');+ ask(lone, 'Ship gamma?');+ const listed = () => JSON.parse(box.run(box.repo, 'decisions', '--as', 'person', '--json').out);++ // The person sees both repos of the project, each with its repo, and not another project's.+ const text = box.run(box.repo, 'decisions', '--as', 'person');+ assert.equal(text.code, 0, text.err);+ assert.match(text.out, new RegExp(`alpha#${alphaId} .*Ship alpha\\?`));+ assert.match(text.out, new RegExp(`beta#${betaId} .*Ship beta\\?`));+ assert.doesNotMatch(text.out, /gamma|Ship gamma/);+ const both = listed();+ assert.deepEqual(both.decisions.map(({ repo, shout_id: id }) => `${repo}#${id}`).sort(), [`alpha#${alphaId}`, `beta#${betaId}`].sort());++ // The local API lists the same decisions, each with its board and repo.+ const view = await helpers.startView(box, box.repo);+ t.after(view.stop);+ const headers = { 'x-pullboard-key': view.key };+ const boards = (await (await fetchFresh(`${view.base}/api/v1/boards`, { headers })).json()).boards;+ const alphaBoard = boards.find(entry => entry.root === box.repo);+ const betaBoard = boards.find(entry => entry.root === other);+ const api = await (await fetchFresh(`${view.base}/api/v1/decisions?board=${alphaBoard.id}`, { headers })).json();+ assert.equal(api.project, 'shop');+ assert.deepEqual(api.decisions.map(({ board, repo }) => `${repo}:${board}`).sort(), [`alpha:${alphaBoard.id}`, `beta:${betaBoard.id}`].sort());++ // Answering from the first repo closes the decision on the second repo's own board, and nowhere else.+ const answered = box.run(box.repo, 'answer', `beta#${betaId}`, 'Yes, ship it.', '--as', 'person');+ assert.equal(answered.code, 0, answered.err);+ assert.deepEqual(withBoard(other, board => store.openDecisions(board, store.PERSON)), []);+ assert.equal(withBoard(box.repo, board => store.openDecisions(board, store.PERSON)).length, 1);+ assert.deepEqual(listed().decisions.map(({ repo }) => repo), ['alpha']);+ const unknown = box.run(box.repo, 'answer', 'nowhere#1', 'x', '--as', 'person');+ assert.notEqual(unknown.code, 0);+ assert.match(unknown.err, /PROJECT_REPO_UNKNOWN/);+ });++ test('two repos of a project that share a name are addressed by folder, never guessed [N34]', { timeout: 120_000 }, () => { // budget: hang ceiling for two real repos' CLI runs; not a speed target.+ const box = helpers.project();+ const other = siblingRepo(box, 'repo-twin').repo;+ nameRepo(box, box.repo, 'twin', 'shop');+ nameRepo(box, other, 'twin', 'shop');+ const ask = (root, text) => Number(/as #(\d+)/.exec(box.run(root, 'shout', 'person', text, '--decision').out)?.[1]);+ ask(box.repo, 'Ship first?');+ const secondId = ask(other, 'Ship second?');+ const listed = JSON.parse(box.run(box.repo, 'decisions', '--as', 'person', '--json').out).decisions.map(({ repo }) => repo).sort();+ assert.deepEqual(listed, ['repo', 'repo-twin']);+ const guessed = box.run(box.repo, 'answer', `twin#${secondId}`, 'yes', '--as', 'person');+ assert.notEqual(guessed.code, 0);+ assert.match(guessed.err, /PROJECT_REPO_AMBIGUOUS/);+ assert.equal(withBoard(other, board => store.openDecisions(board, store.PERSON)).length, 1, 'nothing closed on either board');+ assert.equal(box.run(box.repo, 'answer', `repo-twin#${secondId}`, 'yes', '--as', 'person').code, 0);+ assert.deepEqual(withBoard(other, board => store.openDecisions(board, store.PERSON)), []);+ assert.equal(withBoard(box.repo, board => store.openDecisions(board, store.PERSON)).length, 1, 'the same-numbered question here stays open');+ });+++ test('a non-approver device without a signed member list receives no board key [H15,E17]', async t => {+ const folder = mkdtempSync(join(tmpdir(), 'pullboard-handover-membership-'));+ t.after(() => rmSync(folder, { recursive: true, force: true }));+ const box = helpers.project();+ const state = { board: withBoard(box.repo, store.boardId), repository: 'fixture/repository', login: 'alice' };+ const boardKey = randomBytes(32);+ /** Make an actual SSH signature and device key, independent of what the malicious relay asserts. */+ async function request(login) {+ const file = join(folder, login);+ const made = runFixtureChild('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', file], { encoding: 'utf8' });+ assert.equal(made.status, 0, 'OpenSSH creates the private fixture signing key');+ const device = await createDeviceKeys();+ const statement = { v: 1, board: state.board, repository: state.repository, login, device: device.deviceId,+ publicKey: device.publicKey, engine: PEOPLE_VERSION, expires: Date.now() + 60_000 };+ const input = file + '.statement';+ writeFileSync(input, statementBytes(statement), { mode: 0o600 });+ const signed = runFixtureChild('ssh-keygen', ['-Y', 'sign', '-q', '-n', 'pullboard-device-key', '-f', file, input], { encoding: 'utf8' });+ assert.equal(signed.status, 0, "the request is genuinely signed by that login's SSH key");+ return { device, signingKey: file, publicKey: readFileSync(file + '.pub', 'utf8').trim().split(' ').slice(0, 2).join(' '),+ entry: { id: login, login, statement, signature: readFileSync(input + '.sig', 'utf8') } };+ }+ const outsider = await request('bob');+ const member = await request('alice');+ const body = { v: 1, board: state.board, repository: state.repository, login: 'alice' };+ const identity = { body, signature: signSshVouch(JSON.stringify(['pullboard-person-identity', body]), 'pullboard-person-identity', member.signingKey) };+ /** Present attacker-controlled relay entries while resolving SSH ownership directly for each account. */+ async function answer(person) {+ const deliveries = [];+ await handOverBoardKeys(state, boardKey, {+ root: box.repo, identity,+ async send(_state, _path, options) {+ if (options.method === 'PUT') { deliveries.push(options.body); return {}; }+ return { requests: [person.entry] };+ },+ async githubKeys(login) { return login === person.entry.login ? [person.publicKey] : []; },+ }, { err() {} });+ assert.equal(deliveries.length, 1, 'each request gets one explicit refusal or delivery');+ return deliveries[0];+ }+ const refused = await answer(outsider);+ const leaked = refused.wrapped ? await unwrapDeviceBoardKey(outsider.device.privateKey,+ JSON.parse(Buffer.from(refused.wrapped, 'base64url').toString('utf8')),+ { board: state.board, device: outsider.device.deviceId, engine: PEOPLE_VERSION }) : null;+ assert.equal(leaked !== null && Buffer.from(leaked).equals(boardKey), false, 'the outsider cannot decrypt the actual board key');+ assert.equal(refused.refused?.code, 'RELAY_NOT_MEMBER', 'a valid outsider signature cannot establish trusted board membership');+ assert.equal(Object.hasOwn(refused, 'wrapped'), false, 'the relay receives no key ciphertext it could unwrap as the outsider');+ const allowed = await answer(member);+ assert.ok(allowed.wrapped, 'the linked person can still bootstrap their own independently vouched device');+ const unwrapped = await unwrapDeviceBoardKey(member.device.privateKey,+ JSON.parse(Buffer.from(allowed.wrapped, 'base64url').toString('utf8')),+ { board: state.board, device: member.device.deviceId, engine: PEOPLE_VERSION });+ assert.deepEqual(Buffer.from(unwrapped), boardKey, 'the legitimate new device receives the actual board key');+ });