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(cli): coordinators declare their model [O8,O3]
Corey Olson24a42258f2b9
diff --git a/src/cli.js b/src/cli.jsindex a5037c6a..0efcc8ef 100644--- a/src/cli.js+++ b/src/cli.js@@ -542,6 +542,20 @@ function requiredModel(value, env = process.env) {return model;}+/** Resolve an optional coordinator declaration while preserving the legacy unknown identity. */+function optionalModel(value, env = process.env) {+ if (value === undefined && !env.PULLBOARD_MODEL) return undefined;+ return requiredModel(value, env);+}++/** Refuse to redeclare a coordinator whose linked board belongs to another checkout. */+function refuseRemoteCoordinatorModel(ctx, command) {+ const coordinator = withBoard(ctx, (board) => store.listAgents(board).find((agent) => agent.agent_id === COORDINATOR));+ if (!coordinator) throw new Refused('NO_AGENT', 'the linked snapshot has no coordinator; restore a consistent relay snapshot before initializing');+ const name = displayAgentName(coordinator, ctx.config.agents.names);+ throw new Refused('REMOTE_COORDINATOR_MODEL', `the coordinator's model is declared on the coordinator's own checkout (${name}); run pullboard ${command} there`);+}+/*** Who is asking: the coordinator in the main checkout, or the agent this worktree joined as.*@@ -1189,8 +1203,11 @@ function setupCommands(io, { first, values }) {return {init: async () => {const info = repoInfo(io.cwd);+ const model = optionalModel(values.model);+ if (model !== undefined && relayLinked(info.root)) refuseRemoteCoordinatorModel(context(io), 'init');const notes = initRepo({info,+ model,openBoardHere: () => store.openBoard(join(info.commonDir, 'pullboard', 'board.sqlite'), io.clock),/** Keep a linked coordinator's canonical identity without writing a clone-local path. */register: (board, options) => {@@ -1219,7 +1236,19 @@ function setupCommands(io, { first, values }) {},join: async () => {const ctx = context(io);- if (ctx.info.isMain) throw new Refused('MAIN_IS_COORDINATOR', 'the main checkout is the coordinator; join from a worktree: git worktree add ../<dir>');+ if (ctx.info.isMain) {+ if (first !== COORDINATOR) throw new Refused('MAIN_IS_COORDINATOR', 'the main checkout is the coordinator; join from a worktree: git worktree add ../<dir>');+ const route = values.route ?? 'strong';+ const model = requiredModel(values.model);+ if (relayLinked(ctx.info.root)) refuseRemoteCoordinatorModel(ctx, 'join coordinator');+ const id = await withBoard(ctx, async (board) => await ordered(ctx, board, 'register', [+ { lane: COORDINATOR, path: ctx.info.root, route, family: values.family, model },+ ]));+ const displayName = displayAgentName({ agent_id: id, agent_model: model }, ctx.config.agents.names);+ io.result?.({ agent: id, lane: COORDINATOR, route, path: ctx.info.root, model, displayName });+ io.say(`declared ${displayName} in the coordinator lane`);+ return 0;+ }if (!first || first === COORDINATOR || !isLane(ctx.config, first)) {throw new Refused('NO_LANE', `no lane "${first ?? ''}"; lanes: ${laneNames(ctx.config).slice(1).join(', ') || 'none yet, declare them in pullboard.json'}`);}@@ -2912,7 +2941,10 @@ async function runMain(argv, streams) {io.relayCommand = { cliOperation: command === 'done' ? 'submit' : command, cwd: resolve(io.cwd),positionals: parsed.positionals.slice(1),values: Object.fromEntries(Object.keys(parsed.values).filter(key => key !== 'json').sort().map(key => [key, parsed.values[key]])) };- sync = Boolean(command) && !parsed.values.help && !parsed.values.version && !['help', 'version', 'hook', 'init', 'relay', 'tour'].includes(command);+ sync = Boolean(command) && !parsed.values.help && !parsed.values.version+ && !['help', 'version', 'hook', 'init', 'relay', 'tour'].includes(command)+ // A coordinator declaration on a linked clone must refuse before auto-link or relay sync.+ && !(command === 'join' && parsed.positionals[1] === COORDINATOR);needsRepo = !(parsed.values.help || parsed.values.version || command === 'help' || command === 'version');} catch { sync = false; needsRepo = false; }if (parsed) {diff --git a/src/help.js b/src/help.jsindex c11809f8..f41d3702 100644--- a/src/help.js+++ b/src/help.js@@ -9,10 +9,11 @@ Nothing ships until a second agent verifies it.Set uppullboard tour see it work: a reject and its rework, scripted, in thirty seconds- pullboard init config, SPEC.md, agent instructions, git hooks, board+ pullboard init [--model <name>] config, SPEC.md, agent instructions, git hooks, board; optional coordinator modelpullboard worktree <lane> --model <name> [--route light] [--family <name>] make and join a worktree for a new agentpullboard join <lane> --model <name> [--route light] [--family <name>] register this worktree as an agentA model is required (or set PULLBOARD_MODEL); family is a separate declaration+ pullboard join coordinator --model <name> declare the main checkout's coordinator modelpullboard.json agents.names: suffix (default) or prefixpullboard whoami | lanes | status who you are, the lanes, the board at a glancepullboard takeover rebind this checkout when the same agent starts a new sessiondiff --git a/src/init.js b/src/init.jsindex 24889b0b..5ff6bead 100644--- a/src/init.js+++ b/src/init.js@@ -188,10 +188,10 @@ function writeSessionHook(root, onWrite) {/*** Set the repo up. Must run in the main checkout, which becomes the coordinator.*- * @param {{ info: { root: string, isMain: boolean }, openBoardHere: () => any, register: Function, closeBoard: Function }} context+ * @param {{ info: { root: string, isMain: boolean }, openBoardHere: () => any, register: Function, closeBoard: Function, model?: string }} context* @returns {string[]} What happened, one line each.*/-export function initRepo({ info, openBoardHere, register, closeBoard }) {+export function initRepo({ info, openBoardHere, register, closeBoard, model }) {if (!info.isMain) {throw new Refused('NOT_MAIN', 'run init in the main checkout; worktrees join a lane instead');}@@ -213,7 +213,7 @@ export function initRepo({ info, openBoardHere, register, closeBoard }) {];const board = openBoardHere();try {- register(board, { lane: COORDINATOR, path: root });+ register(board, { lane: COORDINATOR, path: root, model });} finally {closeBoard(board);}diff --git a/test/agent-session.test.js b/test/agent-session.test.jsindex 62d63f5a..01343424 100644--- a/test/agent-session.test.js+++ b/test/agent-session.test.js@@ -138,7 +138,7 @@ test('a second session cannot write in the main checkout until takeover [B3,B7]'assert.equal(takeover.status, 0, `${takeover.stdout}${takeover.stderr}`);const rows = boardSnapshot(box.boardFile);assert.ok(rows.event.slice(before.event.length).some(row => row.event_kind === 'shout' && row.event_by === 'coordinator'), 'takeover is recorded through an existing ordered shout event');- assert.match(rows.shout.at(-1).shout_text, /coordinator \(unknown\) took over/);+ assert.match(rows.shout.at(-1).shout_text, /coordinator \(Test Model\) took over/);assert.equal(rows.shout.at(-1).shout_to, 'person');assert.equal(rows.shout.length, before.shout.length + 1, 'main-checkout takeover records the person notice');const after = box.run(box.repo, ['shout', 'web', 'second session owns main', '--json'], { session: second });diff --git a/test/api.test.js b/test/api.test.jsindex b92a6c8a..7c62469f 100644--- a/test/api.test.js+++ b/test/api.test.js@@ -109,13 +109,16 @@ function sandbox() {return { dir, env, git, run };}-/** Initialize a real pullboard repo, replace its fixture config, and commit setup files. */+/** Initialize a real board with an undeclared legacy coordinator for the API protocol fixtures. */function project() {const box = sandbox();const repo = join(box.dir, 'repo');mkdirSync(repo);box.git(repo, 'init', '-q', '-b', 'main');+ const inheritedModel = box.env.PULLBOARD_MODEL;+ delete box.env.PULLBOARD_MODEL;const initialized = json(box, repo, 'init');+ if (inheritedModel !== undefined) box.env.PULLBOARD_MODEL = inheritedModel;const configFile = join(repo, 'pullboard.json');const config = JSON.parse(readFileSync(configFile, 'utf8'));writeFileSync(configFile, `${JSON.stringify({diff --git a/test/coordinator-resume.test.js b/test/coordinator-resume.test.jsindex 57fb9285..fc318a42 100644--- a/test/coordinator-resume.test.js+++ b/test/coordinator-resume.test.js@@ -247,7 +247,7 @@ test("the coordinator's handoff brief orders current work and leaves agent resumassert.equal((resumed.out.match(/^open decision /gmu) ?? []).length, 3, 'text caps each section while JSON keeps all records');assert.doesNotMatch(resumed.out, /Old answer stays in history/u);assert.match(resumed.out, new RegExp(`open decision #${openId} from web-1 \\(Test Model\\) \\(2h\\): Need a decision`));- assert.match(resumed.out, /recent decision .*person answered coordinator \(unknown\) \(1h ago\): Yes, after the review\./u);+ assert.match(resumed.out, /recent decision .*person answered coordinator \(Test Model\) \(1h ago\): Yes, after the review\./u);assert.match(resumed.out, new RegExp(`merges cleanly: #${cleanId} Clean item`));assert.match(resumed.out, new RegExp(`conflicts: #${conflictId} Conflict item \\(web/shared\\.txt\\)`));assert.match(resumed.out, new RegExp(`claimed for integration: #${activeId} by web-3 \\(Test Model\\) at .*\\(${descendant.slice(0, 12)}\\)`));diff --git a/test/e2e-helpers.js b/test/e2e-helpers.jsindex bc4435eb..cf9e5fc0 100644--- a/test/e2e-helpers.js+++ b/test/e2e-helpers.js@@ -74,13 +74,17 @@ const SPEC = `# Demo spec/*** A repo set up with pullboard, two lanes and a spec, committed through its own hooks, plus a- * worktree joined to the web lane.+ * worktree joined to the web lane. The coordinator stays deliberately undeclared; later agents+ * retain the runner's model, while initialization model coverage invokes init directly.*/function project(gate = CONFIG.gate, box = sandbox()) {const repo = join(box.dir, 'repo');mkdirSync(repo);box.git(repo, 'init', '-q', '-b', 'main');+ const inheritedModel = box.env.PULLBOARD_MODEL;+ delete box.env.PULLBOARD_MODEL;assert.equal(box.run(repo, 'init').code, 0);+ if (inheritedModel !== undefined) box.env.PULLBOARD_MODEL = inheritedModel;writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({ ...CONFIG, gate }, null, 2));writeFileSync(join(repo, 'SPEC.md'), SPEC);box.git(repo, 'add', '-A');diff --git a/test/e2e-model-names.test.js b/test/e2e-model-names.test.jsindex fda45bbb..413b2346 100644--- a/test/e2e-model-names.test.js+++ b/test/e2e-model-names.test.js@@ -1,17 +1,40 @@/** CLI model labels, stable agent identities, and model-free scripted tours [O8,O3,N10]. */import assert from 'node:assert/strict';import { spawnSync } from 'node:child_process';-import { existsSync, readFileSync, writeFileSync } from 'node:fs';+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';import { join } from 'node:path';import { after, test } from 'node:test';import * as store from '../src/board.js';import { createE2eHelpers } from './e2e-helpers.js';import { runFixtureChild } from './fixture-child.js';+import { relayClientFixture } from './relay-client-fixture.js';const e2e = createE2eHelpers();after(e2e.cleanup);const { BIN, sandbox, project } = e2e;+/** Create an empty real Git main checkout for coordinator initialization coverage. */+function coordinatorRepo(box, name) {+ const repo = join(box.dir, name);+ mkdirSync(repo);+ box.git(repo, 'init', '-q', '-b', 'main');+ return repo;+}++/** Read the ordered coordinator events from the fixture's real SQLite board. */+function coordinatorEvents(repo) {+ const board = store.openBoard(join(repo, '.git', 'pullboard', 'board.sqlite'));+ try { return store.events(board).filter(event => event.event_by === 'coordinator'); }+ finally { store.closeBoard(board); }+}++/** Read the coordinator model from the fixture's real SQLite board. */+function coordinatorModel(repo) {+ const board = store.openBoard(join(repo, '.git', 'pullboard', 'board.sqlite'));+ try { return store.agentAt(board, repo)?.agent_model ?? null; }+ finally { store.closeBoard(board); }+}+const TOUR_STEPS = ['1 The person approved one spec row. The coordinator files it as work.','2 A builder agent gets its own worktree in the app lane and claims the next item. Its criterion freezes.',@@ -23,6 +46,104 @@ const TOUR_STEPS = ['8 The coordinator merges it. The ledger is the receipt.',];+test('the coordinator declares its model [O8,O3]', async (t) => {+ const box = sandbox();+ delete box.env.PULLBOARD_MODEL;++ const flaggedRepo = coordinatorRepo(box, 'init-flag');+ const flaggedInit = box.run(flaggedRepo, 'init', '--model', 'CLI Coordinator', '--json');+ assert.equal(flaggedInit.code, 0, flaggedInit.err || flaggedInit.out);+ const flaggedWho = box.run(flaggedRepo, 'whoami', '--json');+ assert.equal(flaggedWho.code, 0, flaggedWho.err || flaggedWho.out);+ const flaggedIdentity = JSON.parse(flaggedWho.out);+ assert.equal(flaggedIdentity.model, 'CLI Coordinator');+ assert.equal(flaggedIdentity.displayName, 'coordinator (CLI Coordinator)');+ const flaggedJoin = coordinatorEvents(flaggedRepo).find(event => event.event_kind === 'join');+ assert.ok(flaggedJoin, 'init records the coordinator registration');+ assert.equal(JSON.parse(flaggedJoin.event_detail).model, 'CLI Coordinator');++ const envRepo = coordinatorRepo(box, 'init-environment');+ box.env.PULLBOARD_MODEL = 'Environment Coordinator';+ const environmentInit = box.run(envRepo, 'init', '--json');+ assert.equal(environmentInit.code, 0, environmentInit.err || environmentInit.out);+ const environmentWho = box.run(envRepo, 'whoami', '--json');+ assert.equal(environmentWho.code, 0, environmentWho.err || environmentWho.out);+ const environmentIdentity = JSON.parse(environmentWho.out);+ assert.equal(environmentIdentity.model, 'Environment Coordinator');+ assert.equal(environmentIdentity.displayName, 'coordinator (Environment Coordinator)');+ const environmentJoin = coordinatorEvents(envRepo).find(event => event.event_kind === 'join');+ assert.ok(environmentJoin, 'environment-backed init records the coordinator registration');+ assert.equal(JSON.parse(environmentJoin.event_detail).model, 'Environment Coordinator');++ delete box.env.PULLBOARD_MODEL;+ const unknownRepo = coordinatorRepo(box, 'init-unknown');+ const unknownInit = box.run(unknownRepo, 'init', '--json');+ assert.equal(unknownInit.code, 0, unknownInit.err || unknownInit.out);+ const unknownWho = box.run(unknownRepo, 'whoami', '--json');+ assert.equal(unknownWho.code, 0, unknownWho.err || unknownWho.out);+ const unknownIdentity = JSON.parse(unknownWho.out);+ assert.equal(unknownIdentity.model, 'unknown');+ assert.equal(unknownIdentity.displayName, 'coordinator (unknown)');+ assert.equal(coordinatorModel(unknownRepo), null);++ const declaredRepo = coordinatorRepo(box, 'later-declaration');+ const undeclaredInit = box.run(declaredRepo, 'init');+ assert.equal(undeclaredInit.code, 0, undeclaredInit.err || undeclaredInit.out);+ const declaration = box.run(declaredRepo, 'join', 'coordinator', '--model', 'Later Coordinator', '--json');+ assert.equal(declaration.code, 0, declaration.err || declaration.out);+ const declaredIdentity = JSON.parse(declaration.out);+ assert.equal(declaredIdentity.model, 'Later Coordinator');+ assert.equal(declaredIdentity.displayName, 'coordinator (Later Coordinator)');+ const move = box.run(declaredRepo, 'shout', 'all', 'the declared coordinator acts');+ assert.equal(move.code, 0, move.err || move.out);+ const declaredEvents = coordinatorEvents(declaredRepo);+ const modelEvent = declaredEvents.find(event => event.event_kind === 'model');+ const shoutEvent = declaredEvents.find(event => event.event_kind === 'shout');+ assert.ok(modelEvent, 'the later declaration is an ordered model event');+ assert.ok(shoutEvent, 'the coordinator records a later move');+ assert.equal(JSON.parse(modelEvent.event_detail).model, 'Later Coordinator');+ assert.equal(JSON.parse(shoutEvent.event_detail).model, 'Later Coordinator');++ const relay = await relayClientFixture(t);+ const remoteDeclaration = await relay.cli('join', 'coordinator', '--model', 'Remote Coordinator');+ assert.equal(remoteDeclaration.code, 0, remoteDeclaration.failure);+ await relay.link();+ const pairing = await relay.cli('relay', 'pair');+ assert.equal(pairing.code, 0, pairing.failure);+ delete relay.env.PULLBOARD_MODEL;+ const paired = await relay.otherDeviceJoin(pairing.document.code);+ const before = await paired.cli('export');+ assert.equal(before.code, 0, before.failure);+ const remoteCoordinator = before.document.tables.agent.find(agent => agent.agent_id === 'coordinator');+ assert.ok(remoteCoordinator, 'the linked snapshot retains the remote coordinator row');+ assert.equal(remoteCoordinator.agent_path, relay.root, 'the snapshot names the coordinator checkout on the source device');+ assert.equal(before.document.tables.board_meta.find(row => row.meta_key === 'agent_model:coordinator')?.meta_value, 'Remote Coordinator');+ const relayCalls = relay.calls.length;+ const linkedInit = await paired.cli('init');+ assert.equal(linkedInit.code, 0, linkedInit.failure);+ assert.equal(relay.calls.length, relayCalls, 'plain linked init does not publish a coordinator registration');+ const afterPlainInit = await paired.cli('export');+ assert.equal(afterPlainInit.code, 0, afterPlainInit.failure);+ assert.deepEqual(afterPlainInit.document, before.document, 'plain linked init preserves the remote coordinator identity and path');+ const callsBeforeRefusals = relay.calls.length;++ const refusal = await paired.cli('init', '--model', 'Clone Coordinator');+ assert.equal(refusal.code, 1);+ assert.equal(refusal.document.error.code, 'REMOTE_COORDINATOR_MODEL');+ assert.match(refusal.document.error.message, /the coordinator's model is declared on the coordinator's own checkout \(coordinator \(Remote Coordinator\)\)/u);+ assert.equal(refusal.document.error.message.includes('\n'), false, 'the refusal is one line');+ assert.equal(relay.calls.length, callsBeforeRefusals, 'the linked refusal does not attempt a remote registration');+ const joinRefusal = await paired.cli('join', 'coordinator', '--model', 'Clone Coordinator');+ assert.equal(joinRefusal.code, 1);+ assert.equal(joinRefusal.document.error.code, 'REMOTE_COORDINATOR_MODEL');+ assert.match(joinRefusal.document.error.message, /the coordinator's model is declared on the coordinator's own checkout \(coordinator \(Remote Coordinator\)\)/u);+ assert.equal(joinRefusal.document.error.message.includes('\n'), false, 'the linked coordinator-join refusal is one line');+ assert.equal(relay.calls.length, callsBeforeRefusals, 'the linked coordinator-join refusal does not dispatch a remote mutation');+ const after = await paired.cli('export');+ assert.equal(after.code, 0, after.failure);+ assert.deepEqual(after.document, before.document, 'linked init preserves the remote coordinator identity and path');+});+/** Return the numbered steps printed by the scripted tour. */function tourSteps(stdout) {return [...stdout.matchAll(/^(\d+) (.+)$/gmu)].map((match) => `${match[1]} ${match[2]}`);diff --git a/test/machine.test.js b/test/machine.test.jsindex d573f686..9f589a51 100644--- a/test/machine.test.js+++ b/test/machine.test.js@@ -29,6 +29,7 @@ const NOT_MOVES = {BAD_MACHINE_SETTINGS: 'machine-wide settings checked before a command runs',BAD_GATE_SLOTS: 'machine-wide gate capacity checked before a command runs',NO_AGENT: 'a linked coordinator must already be registered before an item move',+ REMOTE_COORDINATOR_MODEL: 'a linked replica cannot redeclare the coordinator model; use the coordinator checkout',EVENT_LOG_VERSION: 'the local board format is checked before opening it for an item move',NOT_YOUR_CHECKOUT: 'the caller owns the checkout session, checked before any item move',CHECKOUT_SESSION: 'the checkout-local session binding is readable before any item move',@@ -50,6 +51,9 @@ const ENTRY_POINTS = [{ verbs: ['reopen'], at: ['board.js#reopen'] },];+/** Setup refusals have no item move, but stay in the same reachability audit. */+const NON_MOVE_ENTRY_POINTS = ['cli.js#refuseRemoteCoordinatorModel'];+/** Board functions handed a function to call, and the one the CLI and the runner hand them. */const CALLBACKS = { 'board.js': { freeze: 'cli.js#freezer' } };@@ -420,7 +424,9 @@ test('every refusal a move raises today is declared on that move, and every declassert.ok(ENTRY_POINTS.some(({ at }) => at.some((entry) => walk.refusalsOf(entry).has(code))), `the walk finds ${code}`);}for (const code of Object.keys(NOT_MOVES)) {- assert.ok(ENTRY_POINTS.some(({ at }) => at.some((entry) => walk.refusalsOf(entry).has(code))), `${code} is listed as not a move because a move's code path raises it`);+ const moveRaises = ENTRY_POINTS.some(({ at }) => at.some((entry) => walk.refusalsOf(entry).has(code)));+ const setupRaises = NON_MOVE_ENTRY_POINTS.some((entry) => walk.refusalsOf(entry).has(code));+ assert.ok(moveRaises || setupRaises, `${code} is listed as not a move because a move or setup code path raises it`);}});diff --git a/test/relay-client.test.js b/test/relay-client.test.jsindex 0bbb12d7..45a5d409 100644--- a/test/relay-client.test.js+++ b/test/relay-client.test.js@@ -570,7 +570,9 @@ test('[H3,H16,V1,V17] three cloned linked replicas order competing claims and reawait cli(clones[0], envs[0], 'status');const beforeInit = localEvents(replicaFiles[0]);- const initializedClone = await cli(clones[0], envs[0], 'init');+ const modelFreeInitEnv = { ...envs[0] };+ delete modelFreeInitEnv.PULLBOARD_MODEL;+ const initializedClone = await cli(clones[0], modelFreeInitEnv, 'init');assert.equal(initializedClone.root, clones[0]);assert.deepEqual(localEvents(replicaFiles[0]), beforeInit, 'repeated init cannot bypass relay ordering to rewrite coordinator registration');