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): one coordinator per board, passed by takeover [E19]
Corey Olsonf394ff487ec3
diff --git a/docs/api.md b/docs/api.mdindex b9c2602e..7ff4492e 100644--- a/docs/api.md+++ b/docs/api.md@@ -188,7 +188,7 @@ For example: `flow: review wait average 61 min (1 measured; > 60 min); bottlenec`join` and `worktree` require a free-text `--model` label or `PULLBOARD_MODEL` environment value; labels are not inferred from a provider or family. Rejoining the same worktree preserves its agent id; the model label is required on every join, and omitting the optional `--family` preserves its prior declaration. `pullboard.json` may set `agents.names` to `suffix` (the default, `web-1 (Claude)`) or `prefix` (`claude-web-1`). CLI `agent` fields remain stable ids; `displayName` shows the chosen style. `resume.me` and API state `agents[]` carry `model` and `displayName`; older agents with no model display `unknown`. Each event records the actor model in `event_detail.model` for a registered agent, with `unknown` for legacy agents without a declaration. `show` includes `item_builder_family` and each verdict's `verdict_verifier_family`. These family fields are `null` when the agent did not declare a family, and later declarations do not rewrite prior submissions or verdicts.-Each checkout is bound to the first agent session that writes there. The local Git directory holds only its session digest, agent id and timestamp; bindings are absent from board exports and relay snapshots. Another agent session gets `NOT_YOUR_CHECKOUT` and the command to make its own worktree. The same agent starting a new session runs `pullboard takeover`; the existing ordered shout records the takeover, addressed to the person for the main checkout or the coordinator for a lane checkout. Markerless terminals, reads, the view and person requests keep their existing behavior. A shout or decision addressed to its sender is refused with `SELF_SHOUT`.+Each checkout is bound to the first agent session that writes there. The local Git directory holds only its session digest, agent id and timestamp; bindings are absent from board exports and relay snapshots. Another agent session gets `NOT_YOUR_CHECKOUT` and the command to make its own worktree. The same agent starting a new session runs `pullboard takeover`; the existing ordered shout records the takeover, addressed to the person for the main checkout or the coordinator for a lane checkout. On a linked board one main checkout holds the coordinator at a time: another linked main checkout acting as coordinator gets `COORDINATOR_HELD`, naming the holder as `computer` and the end of its relay machine id, and `pullboard takeover` there, from an agent session or a person's terminal, takes the coordinator; its result adds `coordinator` (the new holder) and `previous`. Markerless terminals, reads, the view and person requests keep their existing behavior. A shout or decision addressed to its sender is refused with `SELF_SHOUT`.`status.reviewQueue` contains `pending`, `reviewing` (distinct agents with live review leases), `reserved`, `oldestSubmittedAt` and `ageMs`. Age starts at each outstanding item's latest submit event; reserving or renewing its review does not reset it. An empty queue has `oldestSubmittedAt: null` and `ageMs: 0`. Among unreserved submissions, `awaitingFirstReview` counts items with no release since their latest submission; `releasedWithoutVerdict` counts those released without a verdict. `releasedItems` lists `{item, releases, reason}` with the cumulative release count and latest reason for that submission. Historical releases without a reason show `reason not recorded`.diff --git a/docs/formats.md b/docs/formats.mdindex 46a1693d..51ff039d 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` | `72` | `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 72 (`COORDINATOR_HOLD_ENGINE`) holds a linked board's coordinator at one main checkout at a time. Each linked main checkout sends its coordinator moves under its own root coordinator credential, whose lineage the relay authenticates. The board keeps the holding lineage in `board_meta` as `coordinator_holder`, with the holder's name, `computer` and the end of its relay machine id. The first coordinator move at engine 72 takes the hold; a later one from another lineage is refused with `COORDINATOR_HELD`, naming the holder. Registering seats and recording the coordinator's path stay open to every linked main checkout. `takeCoordinator`, sent by `pullboard takeover` in a linked main checkout, moves the hold to the sender and logs a `coordinator-takeover` event naming both holders. Moves recorded before engine 72, and every move on an unlinked board, replay as before.+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/src/board.js b/src/board.jsindex bec4fc89..d1706593 100644--- a/src/board.js+++ b/src/board.js@@ -2575,6 +2575,7 @@ export function milestones(board) {// A lane agent's drafted rows live in row-drafts.js (#878); exported here so the engine dispatches them.export { draftSpecRow, rowDrafts } from './row-drafts.js';+export { coordinatorHolder, takeCoordinator } from './coordinator-hold.js';export { recordSpecApprovalBaseline, specApprovalBaseline, specApprovalBaselineExists } from './spec-approval-baseline.js';// The roadmap's moves live in milestones.js; the board keeps exporting them so the engine replays them.export { addMilestone, canonicalMilestoneTarget, editMilestone, editMilestoneItems, orderMilestoneItems, moveMilestone, removeMilestone, roadmap, shipMilestone } from './milestones.js';diff --git a/src/cli.js b/src/cli.jsindex 81d83547..f9cad9a1 100644--- a/src/cli.js+++ b/src/cli.js@@ -943,7 +943,10 @@ async function bindCheckoutSession(io, positionals, values) {if (command === 'answer' && values.as === 'person') return;const digest = agentSessionDigest();if (!digest) {- if (command === 'takeover') throw new Refused('AGENT_SESSION', 'takeover belongs to an agent session; run pullboard takeover from the agent’s shell');+ // A person's shell in a linked main checkout takes the board's coordinator; it binds no agent session (#347).+ if (command === 'takeover' && !(repoInfo(io.cwd).isMain && relayLinked(repoInfo(io.cwd).root))) {+ throw new Refused('AGENT_SESSION', 'takeover belongs to an agent session; run pullboard takeover from the agent’s shell');+ }return;}if (command === 'check') {diff --git a/src/commands/takeover.js b/src/commands/takeover.jsindex 56e7fb16..338a3405 100644--- a/src/commands/takeover.js+++ b/src/commands/takeover.js@@ -1,14 +1,30 @@/** The pullboard takeover command, in its own module so an item adding another command never edits these lines. */import {context,+ ordered,whoAmI,withBoard,} from '../cli.js';+import { COORDINATOR } from '../config.js';+import { computerLabel } from '../coordinator-hold.js';+import { relayLinked } from '../relay.js';+import { relayMachineContext } from '../relay.js';-/** Run `pullboard takeover` and return its exit code. */-export function run(io) {+/**+ * Run `pullboard takeover` and return its exit code. In an agent worktree it rebinds the checkout to this agent+ * session. In the main checkout of a linked board it also takes the board's coordinator for this checkout, as an+ * ordered move, so another machine's or person's main checkout stops acting as coordinator (#347).+ */+export async function run(io) {const ctx = context(io);const me = withBoard(ctx, (board) => whoAmI(ctx, board));+ if (ctx.info.isMain && relayLinked(ctx.info.root)) {+ const label = computerLabel(relayMachineContext(ctx.info.root)?.machine);+ const taken = await withBoard(ctx, (board) => ordered(ctx, board, 'takeCoordinator', [{ agentId: COORDINATOR, label }]));+ io.result?.({ agent: me.id, path: ctx.info.root, coordinator: taken.holder, previous: taken.previous });+ io.say(`${me.displayName} now coordinates this board from ${taken.holder}${taken.previous && taken.previous !== taken.holder ? `, taking over from ${taken.previous}` : ''}`);+ return 0;+ }io.result?.({ agent: me.id, path: ctx.info.root });io.say(`${me.displayName} took over this checkout for the current agent session`);return 0;diff --git a/src/coordinator-hold-engine.js b/src/coordinator-hold-engine.jsnew file mode 100644index 00000000..27cd0bfc--- /dev/null+++ b/src/coordinator-hold-engine.js@@ -0,0 +1,2 @@+/** A linked board's coordinator is held by one main checkout at a time; takeover passes it (#347). */+export const COORDINATOR_HOLD_ENGINE = 72;diff --git a/src/coordinator-hold.js b/src/coordinator-hold.jsnew file mode 100644index 00000000..58751610--- /dev/null+++ b/src/coordinator-hold.js@@ -0,0 +1,122 @@+/**+ * One coordinator per board, held by one main checkout at a time and passed by takeover [E19].+ *+ * On a linked board every main checkout's coordinator moves reach the relay under that checkout's own root+ * coordinator credential, whose lineage the relay authenticates. The board records the lineage that holds the+ * coordinator: the first coordinator move at this engine takes it, so a board coordinated from one checkout works+ * as before. A coordinator move from any other lineage is refused, naming the holder, until that checkout runs+ * pullboard takeover. An unlinked board's main checkout is already held by one session through its checkout+ * binding, so nothing here applies to it (#347).+ */+import {+ atomic,+ logEvent,+} from './board.js';+import { COORDINATOR } from './config.js';+import { COORDINATOR_HOLD_ENGINE } from './coordinator-hold-engine.js';+import { Refused } from './refused.js';+import { credentialActor } from './relay-sender.js';++export { COORDINATOR_HOLD_ENGINE };+const HOLDER_KEY = 'coordinator_holder';+/** Operations a non-holding main checkout may still send: seat creation and path upkeep stay per machine. */+const UNHELD_OPERATIONS = new Set(['register', 'ensureCoordinator', 'takeCoordinator']);++/**+ * A stored or received holder name, bounded and free of control characters.+ *+ * @param {unknown} label+ * @returns {string}+ */+export function holderLabel(label) {+ const text = typeof label === 'string' ? label.replace(/[\u0000-\u001f\u007f-\u009f]/gu, ' ').trim().slice(0, 80) : '';+ return text || 'another main checkout';+}++/**+ * The name a linked main checkout goes by in a hold: its computer, by the end of the machine id the relay gave it+ * when it was linked, as the device roster shows a computer. It carries no host name or path, since a hold is read+ * by every member of a team board.+ *+ * @param {unknown} machine the link's relay machine id+ * @returns {string}+ */+export function computerLabel(machine) {+ return typeof machine === 'string' && /^[A-Za-z0-9_.-]{1,128}$/u.test(machine) ? `computer ${machine.slice(-8)}` : 'another main checkout';+}++/**+ * Name the sending main checkout on a coordinator move, so a hold and its refusals say which checkout holds it.+ * The name travels sealed inside the move, so only the board's members read it.+ *+ * @param {any} move a prepared engine move+ * @param {unknown} machine the sending link's relay machine id+ * @returns {any} the same move+ */+export function stampCoordinatorHolder(move, machine) {+ if (credentialActor(move) === COORDINATOR) move.holder = computerLabel(machine);+ return move;+}++/**+ * The checkout that holds this board's coordinator, or null before any linked coordinator move at this engine.+ *+ * @param {any} board+ * @returns {{ lineage: string, label: string, at: string } | null}+ */+export function coordinatorHolder(board) {+ const row = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key = ?').get(HOLDER_KEY);+ if (!row) return null;+ try {+ const value = JSON.parse(row.meta_value);+ return typeof value?.lineage === 'string' ? { lineage: value.lineage, label: holderLabel(value.label), at: String(value.at ?? '') } : null;+ } catch { return null; }+}++/** Record a holder in the caller's transaction. */+function saveHolder(board, lineage, label, at) {+ board.db.prepare('INSERT INTO board_meta (meta_key, meta_value) VALUES (?, ?) ON CONFLICT(meta_key) DO UPDATE SET meta_value = excluded.meta_value')+ .run(HOLDER_KEY, JSON.stringify({ lineage, label: holderLabel(label), at }));+}++/**+ * Admit one relay-ordered coordinator move from the main checkout with this lineage, or refuse it by name.+ * The first such move takes the hold, so a single coordinating checkout never sees a refusal.+ *+ * @param {any} board+ * @param {{ operation: string, engine: number, holder?: unknown }} move+ * @param {string | null | undefined} lineage the relay-authenticated root coordinator lineage of the sender+ * @param {string} at the relay receipt time+ */+export function requireCoordinatorHold(board, move, lineage, at) {+ if (!lineage || !(move.engine >= COORDINATOR_HOLD_ENGINE) || UNHELD_OPERATIONS.has(move.operation)) return;+ const holder = coordinatorHolder(board);+ if (!holder) { saveHolder(board, lineage, move.holder, at); return; }+ if (holder.lineage === lineage) return;+ throw new Refused('COORDINATOR_HELD',+ `this board's coordinator is held by ${holder.label}, so this main checkout cannot act as coordinator; to coordinate from here, run pullboard takeover in this main checkout`);+}++/**+ * Take this board's coordinator for the main checkout that sent the move, recording who held it before.+ * Only a relay-ordered move from a linked main checkout's own coordinator credential can take it.+ *+ * @param {any} board+ * @param {{ agentId: string, label: string }} options+ * @returns {{ holder: string, previous: string | null }}+ */+export function takeCoordinator(board, { agentId, label }) {+ if (agentId !== COORDINATOR) throw new Refused('COORDINATOR_ONLY', 'only the coordinator takes over the coordinator; run pullboard takeover in the main checkout');+ const lineage = board.verifierStanding?.lineage;+ if (!lineage) {+ throw new Refused('COORDINATOR_TAKEOVER', 'a linked board passes its coordinator between main checkouts; run pullboard takeover in the main checkout of a board linked with pullboard relay on');+ }+ return atomic(board, () => {+ const previous = coordinatorHolder(board);+ const at = board.clock?.now?.().toISOString?.() ?? new Date().toISOString();+ saveHolder(board, lineage, label, at);+ const holder = holderLabel(label);+ logEvent(board, COORDINATOR, 'coordinator-takeover', null, { holder, previous: previous?.label ?? null, engine: COORDINATOR_HOLD_ENGINE });+ return { holder, previous: previous?.label ?? null };+ });+}diff --git a/src/engine.js b/src/engine.jsindex ab291cb6..208badde 100644--- a/src/engine.js+++ b/src/engine.js@@ -61,6 +61,8 @@ import {} from './flake-engine.js';import { LOCAL_LANDING_ENGINE } from './land-engine.js';import { REVIEW_SKIP_ENGINE } from './review-skip-engine.js';+import { COORDINATOR_HOLD_ENGINE } from './coordinator-hold-engine.js';+import { requireCoordinatorHold } from './coordinator-hold.js';const ITEM_ID_FIRST_ARGUMENT = new Set(['acceptCheck', 'editItem', 'escalate', 'recordAttempt', 'claim', 'release', 'submit', 'reserveReview', 'verify', 'merged', 'withdraw', 'refreeze', 'reopen', 'appendFact']);@@ -73,12 +75,12 @@ export const ENGINE_OPERATIONS = Object.freeze(['recordRowDecisions', 'applyRowDecisions', 'draftSpecRow', 'appendFact', 'recordSpecApprovalBaseline','recordLandingBatch', 'recordLandingWaiver', 'recordLandingFlake', 'finishLandingBatch', 'acceptCheck','recordHealthFindings', 'proposeSentinel', 'decideSentinel', 'beginSentinelRun', 'finishSentinelRun',- 'recordFlakeObservation', 'recordGateRun', 'declareJob', 'recordJobRun',+ 'recordFlakeObservation', 'recordGateRun', 'declareJob', 'recordJobRun', 'takeCoordinator',]);/** Engine version at which each ordered operation first has stable replay semantics. */const OPERATION_ENGINE = Object.freeze({ draftSpecRow: ROW_DRAFT_ENGINE, orderMilestoneItems: MILESTONE_RANK_ENGINE, reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8, acceptCheck: CHECK_ACCEPT_ENGINE,- shipMilestone: MILESTONE_SHIP_ENGINE, recordSpecApprovalBaseline: SPEC_APPROVAL_ENGINE });+ shipMilestone: MILESTONE_SHIP_ENGINE, recordSpecApprovalBaseline: SPEC_APPROVAL_ENGINE, takeCoordinator: COORDINATOR_HOLD_ENGINE });/** Dependency edits, causes, sealed reviews, submission proofs, trunk conflicts, health observations and milestone targets retain distinct recorded engine meanings. */function minimumOperationEngine(operation, args, board, at) {@@ -352,6 +354,8 @@ export function applyEngineMove(board, move, { sequence, at, standing = null, enconst execute = () => store.atomic(board, () => {const problem = requestMoveProblem(board, move);if (problem) throw problem;+ // One main checkout coordinates a linked board at a time; another is refused by name (#347).+ requireCoordinatorHold(board, move, standing?.lineage, at);return store[move.operation](board, ...executableArgs(move, board));});const result = standing ? store.withVerifierStanding(board, standing, execute) : execute();diff --git a/src/help.js b/src/help.jsindex caf790d7..6fa2244d 100644--- a/src/help.js+++ b/src/help.js@@ -21,6 +21,7 @@ Set uppullboard lane add <name> --owns <path>[,<path>] add a lane that owns those folders to pullboard.jsonrefuses a lane name or a path that is already owned, naming the ownerpullboard takeover rebind this checkout when the same agent starts a new session+ in a linked main checkout it also takes the board's coordinator herepullboard resources local resource holders and their FIFO queuespullboard settings [gateSlots <n> | browserSlots <n>] view or set machine capacity (gate default 2; browser default 1)browser-free check slots are opt-in: gate.browserFreeChecks in ~/.pullboard/settings.json (default false)diff --git a/src/next-steps.js b/src/next-steps.jsindex a358626c..d60771e1 100644--- a/src/next-steps.js+++ b/src/next-steps.js@@ -234,6 +234,8 @@ export const NEXT_STEPS = Object.freeze({CORE_BARE: 'turn off core.bare: git config core.bare false',COORDINATOR_CHECK: 'ask your coordinator to set the check: pullboard shout coordinator "please set a check on #<id>"',COORDINATOR_ONLY: 'ask the coordinator to do it: pullboard shout coordinator "<what you need>"',+ COORDINATOR_HELD: 'coordinate from the main checkout the refusal names, or run pullboard takeover in this main checkout to take the coordinator here',+ COORDINATOR_TAKEOVER: 'link the board with pullboard relay on in the main checkout, then run pullboard takeover there',COORDINATOR_VERIFIES: 'leave the review to the coordinator; shout it when the item is ready: pullboard shout coordinator "#<id> is ready to verify"',CRITERIA_CHANGED: 'ask the coordinator to refreeze it: pullboard shout coordinator "please refreeze #<id>"',CRITERION_PROVES_NOTHING: 'set a check that fails before the work: pullboard edit <id> --check "<command>", or ask the person to accept this one: pullboard check accept <id>',diff --git a/src/relay-outbox.js b/src/relay-outbox.jsindex 886b7893..bf8d3e2f 100644--- a/src/relay-outbox.js+++ b/src/relay-outbox.js@@ -45,6 +45,7 @@ import {seal,unseal,} from './seal.js';+import { stampCoordinatorHolder } from './coordinator-hold.js';import { Refused } from './refused.js';/** How many replay refusals the link keeps for pullboard status; older ones stay in the relay's own receipts. */@@ -321,7 +322,7 @@ export async function queueMove(link, { operation, args, command, move, error, a})();if (!move) {const sent = withSeatName(root, operation, args);- move = localRecords(root, (board) => prepareEngineMove(board, operation, sent));+ move = stampCoordinatorHolder(localRecords(root, (board) => prepareEngineMove(board, operation, sent)), state.machine);move.actor = relayMoveActor(move) ?? credentialActor(move);}const stray = strayItemRefs(outbox, move);diff --git a/src/relay-sender.js b/src/relay-sender.jsindex aff6399f..c3cb382a 100644--- a/src/relay-sender.js+++ b/src/relay-sender.js@@ -10,7 +10,7 @@ export function relayMoveActor(move) {if (move.operation === 'addItem') return args[0]?.by ?? null;if (move.operation === 'shout') return args[0]?.from ?? null;if (['proposeSentinel', 'decideSentinel', 'beginSentinelRun', 'finishSentinelRun'].includes(move.operation)) return args[0]?.agentId ?? null;- if (['recordHealthFindings', 'recordFlakeObservation', 'recordGateRun', 'declareJob', 'recordJobRun'].includes(move.operation)) return args[0]?.agentId ?? null;+ if (['recordHealthFindings', 'recordFlakeObservation', 'recordGateRun', 'declareJob', 'recordJobRun', 'takeCoordinator'].includes(move.operation)) return args[0]?.agentId ?? null;if (['holdLane', 'releaseLane'].includes(move.operation) && args[1]?.asPerson) return 'person';if (move.operation === 'release') return args[1] ?? null;if (['reserveNextReview', 'addMilestone', 'recordRowDecisions', 'applyRowDecisions', 'draftSpecRow', 'recordSpecApprovalBaseline', 'recordLandingBatch', 'recordLandingWaiver', 'recordLandingFlake', 'finishLandingBatch'].includes(move.operation)) return args[0]?.agentId ?? null;diff --git a/src/relay.js b/src/relay.jsindex cd2c3b6d..8b6ab5b2 100644--- a/src/relay.js+++ b/src/relay.js@@ -106,6 +106,7 @@ import {outboxQueueable,queueMove,} from './relay-outbox.js';+import { stampCoordinatorHolder } from './coordinator-hold.js';import { Refused } from './refused.js';import { refusalFromReceipt } from './recorded-refusal.js';import { relayNotices } from './relay-notices.js';@@ -1203,7 +1204,7 @@ export async function relayOperation(root, operation, args, io, command, applyLotry {if (!move) {const sent = withSeatName(root, operation, args);- move = localRecords(root, (board) => prepareEngineMove(board, operation, sent, io.personRequestMoveId ? { id: io.personRequestMoveId } : {}));+ move = stampCoordinatorHolder(localRecords(root, (board) => prepareEngineMove(board, operation, sent, io.personRequestMoveId ? { id: io.personRequestMoveId } : {})), state.machine);if (io.personRequest) move.personRequest = structuredClone(io.personRequest);const problem = move.personRequest && localRecords(root, board => requestMoveProblem(board, move, { checkExecutorLease: false }));if (problem) throw problem;diff --git a/test/relay-credential.test.js b/test/relay-credential.test.jsindex 8e29b554..d1d0ac70 100644--- a/test/relay-credential.test.js+++ b/test/relay-credential.test.js@@ -31,6 +31,7 @@ test('every current operation selects its native actor credential without a secomain: 'a'.repeat(40), command: 'c'.repeat(64), green: true, failures: [], load: { average: [0, 0, 0], cpus: 1, freeMB: 100 }, at: '2026-10-20T00:00:00.000Z' } }];if (operation === 'declareJob') args = [{ agentId: actor, name: 'credential-job', every: '10m', owner: actor }];if (operation === 'recordJobRun') args = [{ agentId: actor, name: 'credential-job' }];+ if (operation === 'takeCoordinator') args = [{ agentId: actor, label: 'computer credential' }];if (operation === 'proposeSentinel') args = [{ agentId: actor,row: { name: 'credential-watch', check: 'true', every: 'hourly', owner: actor } }];if (['beginSentinelRun', 'finishSentinelRun'].includes(operation)) {diff --git a/test/team.test.js b/test/team.test.jsindex b917a268..3bae105a 100644--- a/test/team.test.js+++ b/test/team.test.js@@ -17,6 +17,11 @@ 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 { resolve } from 'node:path';+import { relayWorkBudgetMs } from './relay-budget.js';+import { hostname } from 'node:os';const helpers = createE2eHelpers();after(helpers.cleanup);@@ -467,3 +472,57 @@ 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);});++test('one coordinator per board across machines [E19]', { timeout: relayWorkBudgetMs(12) }, async t => { // budget: hang ceiling for two linked devices' real CLI and relay round trips; not a speed target.+ const box = await relayClientFixture(t);+ await box.link();+ const pairing = await box.cli('relay', 'pair');+ const other = await box.otherDeviceJoin(pairing.document.code);+ /** A refusal's code and message as the CLI reports them. */+ const refusal = result => ({ code: result.document?.error?.code, message: String(result.document?.error?.message ?? '') });++ // The first device to act as coordinator holds it; the board keeps working there as it does today.+ assert.equal((await box.cli('add', box.lane, 'Planned on the first machine')).code, 0, 'the first machine coordinates');+ assert.equal((await box.cli('add', box.lane, 'Still planned on the first machine')).code, 0, 'the holder keeps coordinating');++ // On one machine, the main checkout is held by one agent session at a time; takeover passes it between sessions.+ /** Run the first machine's real CLI from a named agent session. */+ const inSession = (session, ...args) => relayFixtureChild(box.root, { ...box.env, CLAUDECODE: '1', CLAUDE_CODE_SESSION_ID: session },+ [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args, '--json']);+ assert.equal((await inSession('first-session', 'add', box.lane, 'Planned in the first session')).code, 0, 'one agent session coordinates');+ assert.equal(refusal(await inSession('second-session', 'add', box.lane, 'Planned in a second session')).code, 'NOT_YOUR_CHECKOUT',+ 'a second session acting as coordinator in the same main checkout is refused');+ assert.equal((await inSession('second-session', 'takeover')).code, 0, 'takeover passes the main checkout to the second session');+ assert.equal((await inSession('second-session', 'add', box.lane, 'Planned in the second session after takeover')).code, 0, 'the new session coordinates');+ assert.equal(refusal(await inSession('first-session', 'add', box.lane, 'Planned again in the first session')).code, 'NOT_YOUR_CHECKOUT',+ 'the earlier session is refused after the takeover');++ // A second machine's main checkout acting as coordinator is refused, by name.+ const second = await other.cli('add', box.lane, 'Planned on the second machine');+ assert.notEqual(second.code, 0, 'a second coordinator is refused');+ assert.equal(refusal(second).code, 'COORDINATOR_HELD');+ const firstName = `computer ${JSON.parse(readFileSync(box.linkFile, 'utf8')).machine.slice(-8)}`;+ const secondName = `computer ${other.machine.slice(-8)}`;+ assert.notEqual(firstName, secondName, 'the two linked computers have different names');+ assert.ok(refusal(second).message.includes(firstName), `the refusal names the holding computer: ${refusal(second).message}`);+ assert.doesNotMatch(refusal(second).message, new RegExp(hostname(), 'u'), 'the name carries no host name');+ assert.match(refusal(second).message, /pullboard takeover/u, 'the refusal names the takeover');++ // Takeover passes the coordinator to the second machine, and the first is then refused by name.+ const taken = await other.cli('takeover');+ assert.equal(taken.code, 0, `takeover passes the coordinator: ${JSON.stringify(taken.document)}`);+ assert.equal(taken.document.coordinator, secondName, 'takeover reports the new holder');+ assert.equal(taken.document.previous, firstName, 'takeover reports the holder it replaced');+ assert.equal((await other.cli('add', box.lane, 'Planned on the second machine after takeover')).code, 0, 'the new holder coordinates');+ const first = await box.cli('add', box.lane, 'Planned again on the first machine');+ assert.equal(refusal(first).code, 'COORDINATOR_HELD', 'the earlier holder is now the second coordinator');+ assert.ok(refusal(first).message.includes(secondName), `the refusal names the new holder: ${refusal(first).message}`);++ // Both replicas agree on the items each holder made, and on no others.+ for (const device of [box, other]) {+ const titles = (await device.cli('list')).document.items.map(item => item.item_title);+ assert.deepEqual(titles.filter(title => title.startsWith('Planned') || title.startsWith('Still')).sort(),+ ['Planned in the first session', 'Planned in the second session after takeover', 'Planned on the first machine',+ 'Planned on the second machine after takeover', 'Still planned on the first machine']);+ }+});