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
fix(next): a seat's claim stays with its own checkout [N2,B13]
Corey Olsonccc1eaa1dee0
diff --git a/src/cli.js b/src/cli.jsindex ecaf27ff..a7b9f0e1 100644--- a/src/cli.js+++ b/src/cli.js@@ -41,6 +41,7 @@ import {refuseNextIdle,} from './next-steps.js';import { reviewerStartup } from './next-steps.js';+import * as seatCheckout from './seat-checkout.js';import { submitPreflight } from './submit-preflight.js';import * as store from './board.js';import {@@ -1030,7 +1031,7 @@ async function bindCheckoutSession(io, positionals, values) {const ctx = context(io);agent = withBoard(ctx, (board) => store.agentAt(board, info.root)?.agent_id?? (command === 'hook' && store.landingBatches(board).some((batch) => batch.root === info.root && !['landed', 'blocked'].includes(batch.state)) ? COORDINATOR : null));- if (!agent && command !== 'join') throw new Refused('NOT_JOINED', 'this worktree has not joined a lane; run pullboard join <lane> --model "<model name>"');+ if (!agent && command !== 'join') throw withBoard(ctx, (board) => seatCheckout.unjoinedRefusal(info, store.listAgents(board)));}if (['shout', 'fact'].includes(command) && localSessionMatches(info, { agent: agent ?? 'unjoined agent', digest })) {CHECKOUT_BOARD_ONLY.set(io, command);@@ -2699,6 +2700,7 @@ async function submitHere(ctx, id) {const held = withBoard(ctx, (board) => {const me = whoAmI(ctx, board);const item = store.getItem(board, id);+ seatCheckout.refuseHeldElsewhere(ctx.info, store.listAgents(board), item, 'submit');if (item.item_status !== 'claimed' || item.item_owner !== me.id) throw new Refused('NOT_YOURS', 'claim this item before submitting it');const correction = store.pendingRefreezeProblem(board, id);if (correction) throw correction;@@ -3262,6 +3264,7 @@ async function nextHere(io, values) {throw new Refused('USAGE', '--wait is a number of minutes from 0 to 240');}const deadline = Date.now() + minutes * 60_000;+ const origin = ctx.info.root;for (;;) {const found = await nextOnce(ctx, values);if (found.context) ctx = found.context;@@ -3285,8 +3288,9 @@ async function nextHere(io, values) {io.say(`check out exactly that commit, here: ${here} git switch --detach ${item.item_commit}`);io.say(`then: ${here} pullboard verify ${item.item_id} accept${as} --note "how you proved it", or reject${as} --reason CODE --note "what failed"`);} else {+ if (found.seat && found.seat.path !== origin) io.say(seatCheckout.seatLeadLine(found.seat, item, found.held));if (found.reviewSkipped) io.say(`${reviewQueueLine(ctx, found.reviewSkipped, span)}; explicit build intent recorded with this claim`);- io.say(`${found.held ? 'you hold' : 'claimed'} #${item.item_id}: ${item.item_title}`);+ io.say(`${found.held ? (found.seat && found.seat.path !== origin ? `${found.seat.agent} holds` : 'you hold') : 'claimed'} #${item.item_id}: ${item.item_title}`);if (found.seat) io.say(`${found.seat.created ? 'opened' : 'work in'} ${found.seat.agent}, ${found.seat.lane} lane: ${here}`);if (found.shared?.length) io.say(`it touches ${found.shared.length === 1 ? 'a file' : `${found.shared.length} files`} you worked in recently: ${found.shared.slice(0, 4).join(', ')}`);if (item.item_criterion) io.say(`criterion: ${item.item_criterion}`);@@ -3565,6 +3569,7 @@ function workCommands(io, args) {const held = first ? store.getItem(board, idArg(first)): store.listItems(board).find((entry) => entry.item_status === 'claimed' && entry.item_owner === me.id && entry.item_parent_id === null);if (!held) throw new Refused('NOT_HOLDING', 'you hold no item; name one, pullboard check <id>, or run the project gate: pullboard gate');+ seatCheckout.refuseHeldElsewhere(ctx.info, store.listAgents(board), held, 'check');return { item: held, author: store.itemCheckAuthor(board, held.item_id), caller: me.id, agents: store.listAgents(board) };});const check = frozenCheck(item);@@ -3644,6 +3649,7 @@ function workCommands(io, args) {}),release: () => act(async (ctx, board, me) => {const args = [idArg(first), me.id, textArg(io, values, 'note') ?? ''];+ seatCheckout.refuseHeldElsewhere(ctx.info, store.listAgents(board), store.getItem(board, args[0]), 'release');const problem = store.reviewReleaseNoteProblem(board, ...args);if (problem) throw problem;const review = await ordered(ctx, board, 'release', args);diff --git a/src/seat-checkout.js b/src/seat-checkout.jsnew file mode 100644index 00000000..113be383--- /dev/null+++ b/src/seat-checkout.js@@ -0,0 +1,57 @@+/**+ * A seat works in its own checkout (#898). One agent session can hold seats in several checkouts (B13), and a helper+ * can start in a checkout that has no seat at all. These refusals and lines keep each claim with the checkout that+ * will do the work: an unjoined checkout is pointed at its session's seats instead of borrowing one, and an item held+ * by this session's seat elsewhere is named with that seat and its path.+ */+import { agentSessionDigest } from './person.js';+import { localSessionSeats } from './agent-session.js';+import { Refused } from './refused.js';++/** Quote a path the way the CLI's other cd lines do. */+function cdTo(path) {+ return `cd '${path.replaceAll("'", "'\\''")}' &&`;+}++/** This session's seats in other checkouts of the board, by local binding only. */+function sessionSeats(info, agents) {+ const digest = agentSessionDigest();+ return digest ? localSessionSeats(info, { agents, digest }).filter((seat) => seat.agent_path !== info.root) : [];+}++/**+ * The refusal for a write from a checkout with no seat. When this session has seats elsewhere it names them and the+ * command to continue there, so the checkout never claims under another checkout's seat.+ *+ * @param {{ root: string, commonDir: string }} info+ * @param {any[]} agents+ */+export function unjoinedRefusal(info, agents) {+ const seats = sessionSeats(info, agents);+ const join = 'pullboard join <lane> --model "<model name>"';+ if (!seats.length) return new Refused('NOT_JOINED', `this worktree has not joined a lane; run ${join}`);+ const named = seats.map((seat) => `${seat.agent_id} (${seat.agent_lane} lane) in ${seat.agent_path}`).join('; ');+ return new Refused('NOT_JOINED', `this checkout has no seat, and your session's seats work in their own checkouts: ${named}`,+ `continue in that seat: ${cdTo(seats[0].agent_path)} pullboard next; or give this checkout its own seat: ${join}`);+}++/**+ * Refuse a check, submit or release in this checkout for an item one of this session's seats holds in another one.+ *+ * @param {{ root: string, commonDir: string }} info+ * @param {any[]} agents+ * @param {{ item_id: number, item_status: string, item_owner: string|null }} item+ * @param {string} command - The command to repeat in the holder's checkout.+ */+export function refuseHeldElsewhere(info, agents, item, command) {+ if (item.item_status !== 'claimed') return;+ const holder = sessionSeats(info, agents).find((seat) => seat.agent_id === item.item_owner);+ if (!holder) return;+ throw new Refused('NOT_YOURS', `#${item.item_id} is held by ${holder.agent_id} in ${holder.agent_path}, not by this checkout`,+ `${command} it from that seat's checkout: ${cdTo(holder.agent_path)} pullboard ${command} ${item.item_id}`);+}++/** The line that leads next's output when the claim belongs to a seat in another checkout. */+export function seatLeadLine(seat, item, held) {+ return `${seat.agent} (${seat.lane} lane) ${held ? 'holds' : 'now holds'} #${item.item_id} in ${seat.path}; continue there: ${cdTo(seat.path)} pullboard next`;+}diff --git a/test/next-order.test.js b/test/next-order.test.jsindex 12de446a..1306fe99 100644--- a/test/next-order.test.js+++ b/test/next-order.test.js@@ -425,3 +425,43 @@ test('milestone order refuses invalid membership and unauthenticated ranking [N2assert.equal(refusal.error.code, 'RELAY_SENDER_MISMATCH');assert.equal(JSON.stringify(store.milestones(board)), original);});++test('next in a fresh unbound checkout of a seated session claims nothing and names the seat [N2,B13]', (t) => {+ const box = crossLaneFixture(t);+ const web = box.json(box.runAs(box.session, box.web, 'join', 'web', '--model', 'Cross-lane test', '--json'));+ const item = box.add('web', 'Web work for the seated checkout');+ const fresh = join(box.dir, 'fresh-helper');+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', fresh, 'main');+ const next = box.runAs(box.session, fresh, 'next', '--build', '--json');+ assert.notEqual(next.code, 0, 'an unbound checkout never claims for a seat bound elsewhere');+ const error = JSON.parse(next.out).error;+ assert.match(error.message, new RegExp(`${web.agent}.*${box.web.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')}`, 'u'), 'it names the seat and its checkout');+ assert.match(`${error.message} ${error.next ?? ''}`, /pullboard join <lane>|pullboard join web/u, 'and the join command for this checkout');+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));+ try { assert.equal(store.getItem(board, item).item_status, 'open', 'nothing was claimed'); }+ finally { store.closeBoard(board); }+});++test('a cross-checkout claim leads with its seat and other checkouts cannot act on it [N2,B13]', (t) => {+ const box = crossLaneFixture(t);+ const web = box.json(box.runAs(box.session, box.web, 'join', 'web', '--model', 'Cross-lane test', '--json'));+ const api = box.seat('owned-api', 'api', box.session);+ const later = box.add('web', 'Later web work');+ const first = box.add('api', 'Earlier API release');+ box.milestone('first', first);+ box.milestone('later', later);+ const next = box.runAs(box.session, box.web, 'next', '--build');+ assert.equal(next.code, 0, next.out + next.err);+ const lines = next.out.trim().split('\n');+ assert.match(lines[0], new RegExp(`^${api.agent} .*${api.root.replace(/[.*+?^${}()|[\]\\]/gu, '\\$&')}`, 'u'), `the output leads with the holding seat and its checkout: ${lines[0]}`);+ assert.ok(lines.slice(0, 3).some((line) => line.includes(`cd '${api.root}'`) || line.includes(`cd ${api.root}`)), 'and the command to continue there');+ for (const args of [['check', String(first), '--yes'], ['submit', String(first)], ['release', String(first)]]) {+ const refused = box.runAs(box.session, box.web, ...args, '--json');+ assert.notEqual(refused.code, 0, `${args[0]} from another checkout is refused`);+ const message = JSON.parse(refused.out).error.message;+ assert.ok(message.includes(api.agent) && message.includes(api.root), `${args[0]} names the holding seat and its path: ${message}`);+ }+ const again = box.runAs(box.session, box.web, 'next', '--build');+ assert.doesNotMatch(again.out, /you hold #/u, 'a checkout is never told it holds an item another seat holds');+ assert.notEqual(web.agent, api.agent);+});