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
chore(core): merge current main [B3,B7]
Corey Olson6e9839dd6975
diff --cc src/cli.jsindex 124c6472,cc215db5..b5a47922--- a/src/cli.js+++ b/src/cli.js@@@ -11,11 -11,10 +11,11 @@@ import { parseArgs } from 'node:util'import * as store from './board.js';import { CONFIG_FILE, COORDINATOR, loadConfig } from './config.js';import { doctrineHistory, loadDoctrine } from './doctrine.js';-import { requirePersonChannel } from './person.js';+import { agentSessionDigest, requirePersonChannel } from './person.js';+import { bindLocalSession } from './agent-session.js';import { decisionProjection, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';import { digestOf, gateReport, runGate, runShell } from './gate.js';- import { bareWorktreeFinding, contains, differFromHead, git, headCommit, headTree, isClean, repoInfo, resolveCommit, tryGit, untracked } from './git.js';+ import { bareWorktreeFinding, contains, differFromHead, git, headCommit, headTree, isClean, mainCheckout, repoInfo, resolveCommit, tryGit, untracked } from './git.js';import {FIX_NOTE,applyFixers,@@@ -644,60 -641,10 +644,61 @@@ function withBoard(ctx, work)/** Dispatch a board mutation locally, or seal it before any linked replica applies it. */async function ordered(ctx, board, operation, args) {+ /** Dispatch while this session holds the checkout, including long-running next/run loops. */+ const command = ['add', 'edit', 'merged'].includes(ctx.io.relayCommand?.cliOperation) ? ctx.io.relayCommand : undefined;- return relayLinked(ctx.info.root)- ? relayOperation(ctx.info.root, operation, args, ctx.io, command)- : store[operation](board, ...args);+ const execute = () => relayLinked(ctx.info.root)- ? relayOperation(ctx.info.root, operation, args, ctx.io) : store[operation](board, ...args);++ ? relayOperation(ctx.info.root, operation, args, ctx.io, command) : store[operation](board, ...args);+ const digest = agentSessionDigest();+ if (CHECKOUT_LEASES.has(ctx.io) || !digest || ctx.io.personChannel === 'view' || ctx.io.personRequest) return execute();+ const agent = ctx.info.isMain ? COORDINATOR : store.agentAt(board, ctx.info.root)?.agent_id ?? 'unjoined agent';+ const lease = await bindLocalSession(ctx.info, { agent, digest, keepLease: true });+ try { return await execute(); }+ finally { lease.release(); }+}++/** Check ownership before sync or command side effects; reads and authenticated person channels keep their identity. */+async function bindCheckoutSession(io, positionals, values) {+ if (values.help || values.version || io.personChannel === 'view' || io.personRequest) return;+ const [command, first] = positionals;+ if (command === 'takeover' && (positionals.length !== 1 || Object.keys(values).some((key) => key !== 'json'))) {+ throw new Refused('USAGE', 'pullboard takeover takes no arguments; run pullboard takeover [--json]');+ }+ const writes = ['init', 'join', 'worktree', 'hooks', 'hook', 'add', 'edit', 'fact', 'escalate', 'run', 'sweep',+ 'next', 'claim', 'hold', 'release', 'submit', 'done', 'verify', 'merged', 'withdraw', 'refreeze', 'shout', 'answer', 'pass', 'import', 'milestone', 'takeover', 'forget'];+ if (!writes.includes(command) && !(command === 'settings' && first) && !(command === 'spec' && first === 'apply') && !(command === 'relay' && ['on', 'off'].includes(first))) return;+ 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');+ return;+ }+ const info = repoInfo(io.cwd);+ let agent = info.isMain ? COORDINATOR : null;+ if (!info.isMain) {+ const ctx = context(io);+ agent = withBoard(ctx, (board) => store.agentAt(board, info.root)?.agent_id);+ if (!agent && command !== 'join') throw new Refused('NOT_JOINED', 'this worktree has not joined a lane; run pullboard join <lane>');+ }+ const lease = await bindLocalSession(info, { agent: agent ?? 'unjoined agent', digest, takeover: command === 'takeover', keepLease: !['run', 'next'].includes(command),+ /** Use an existing ordered shout so takeover has a receipt without changing the board format. */+ recordTakeover: async () => {+ const ctx = context(io);+ await withBoard(ctx, async (board) => {+ const me = whoAmI(ctx, board);+ const message = { from: me.id, to: info.isMain ? 'person' : COORDINATOR,+ text: `${me.id} took over this checkout in a new agent session.`, lanes: laneNames(ctx.config) };+ if (relayLinked(info.root)) await relayOperation(info.root, 'shout', [message], io);+ else store.shout(board, message);+ });+ },+ });+ if (agent) return { lease };+ /** Replace the temporary identity after a successful first join, retaining the winning session. */+ return { lease, finish: async () => {+ const ctx = context(io);+ const me = withBoard(ctx, (board) => whoAmI(ctx, board));+ lease.updateAgent(me.id);+ } };}/**@@@ -2399,52 -2407,35 +2468,56 @@@ function rememberTrunk(io)export async function main(argv, streams) {const io = commandOutput(argv, streams);let sync = true;+ let parsed;+ let checkoutSession;try {- const parsed = parseArgs({ args: argv, options: OPTIONS, allowPositionals: true });+ parsed = parseArgs({ args: argv, options: OPTIONS, allowPositionals: true });const command = parsed.positionals[0];+ 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);} catch { sync = false; }- /** A network refusal preserves offline reads; linked mutation dispatch requires an acknowledgement. */- const retry = async () => {- try { await syncRelay(io.cwd, io); }- catch (error) {- if (!(error instanceof Refused)) throw error;- if (!['NOT_A_REPO', 'NO_REPO', 'NO_CONFIG', 'CORE_BARE'].includes(error.code)) io.err(`pullboard: ${error.message}`);+ if (parsed) {+ try {+ checkoutSession = await bindCheckoutSession(io, parsed.positionals, parsed.values);+ if (checkoutSession?.lease) CHECKOUT_LEASES.set(io, checkoutSession.lease);}- };- rememberTrunk(io);- if (sync) {- await retry();- try { await executePersonRequests(io.cwd, io, main); }catch (error) {if (!(error instanceof Refused)) throw error;- if (!['NOT_A_REPO', 'NO_REPO', 'NO_CONFIG', 'CORE_BARE'].includes(error.code)) io.err('pullboard: ' + error.message);+ io.refusal(error);+ io.err(`pullboard: ${error.message}`);+ io.flush(1);+ return 1;+ }+ }+ try {+ /** A network refusal preserves offline reads; linked mutation dispatch requires an acknowledgement. */+ const retry = async () => {+ try { await syncRelay(io.cwd, io); }+ catch (error) {+ if (!(error instanceof Refused)) throw error;+ if (!['NOT_A_REPO', 'NO_REPO', 'NO_CONFIG', 'CORE_BARE'].includes(error.code)) io.err(`pullboard: ${error.message}`);+ }+ };++ rememberTrunk(io);+ if (sync) {+ await retry();+ try { await executePersonRequests(io.cwd, io, main); }+ catch (error) {+ if (!(error instanceof Refused)) throw error;+ if (!['NOT_A_REPO', 'NO_REPO', 'NO_CONFIG', 'CORE_BARE'].includes(error.code)) io.err('pullboard: ' + error.message);+ }}+ const code = await runCommand(argv, io);+ if (code === 0) await checkoutSession?.finish?.();+ if (sync && code === 0) await retry();+ io.flush(code);+ return code;+ } finally {+ CHECKOUT_LEASES.delete(io);+ checkoutSession?.lease?.release();}- const code = await runCommand(argv, io);- if (sync && code === 0) await retry();- io.flush(code);- return code;}/** Result-producing command names, including aliases, for API contract coverage (A1). */