Skip to content

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.

fix(next): send main-checkout newcomers to open lane work [N2,B26]

Corey Olsonfc391b2ae767
diff --git a/src/cli.js b/src/cli.js
index acfdd3b7..2ea99c37 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -35,6 +35,10 @@ import {
import { performance } from 'node:perf_hooks';
import { pathToFileURL } from 'node:url';
import { parseArgs } from 'node:util';
+import {
+ mainLaneWork,
+ refuseNextIdle,
+} from './next-steps.js';
import * as store from './board.js';
import {
CONFIG_FILE,
@@ -3185,7 +3189,7 @@ async function nextOnce(ctx, values) {
familyPolicy: ctx.config.verify.family, ratio: ctx.config.verify.reviewRatio, runnable: values.runnable, routes: values.routes });
const offer = held ? null : relayLinked(ctx.info.root) ? store.withVerifierStanding(board, { root: true }, findOffer) : findOffer();
if (offer && !values.build) return { item: offer.item, offer, build: item ?? null };
- if (!item) return { reasons };
+ if (!item) return { reasons, laneWork: ctx.info.isMain ? mainLaneWork(store.listItems(board)) : null };
const reviewSkipped = values.build && !held
? { offeredItem: offer?.item.item_id ?? null, ratio: ctx.config.verify.reviewRatio, ...store.reviewQueue(board) } : null;
const routed = seats ? await nextSeatContext(ctx, board, me, item, seats) : { context: ctx };
@@ -3308,14 +3312,10 @@ async function nextHere(io, values) {
}
return 0;
}
- if (!found.retry && Date.now() >= deadline) {
+ if (!found.retry && (found.laneWork || Date.now() >= deadline)) {
if (values.verify) refuseWhileBuilding(ctx);
- const waited = minutes ? ` after ${minutes} minutes` : '';
const agents = withBoard(ctx, (board) => store.listAgents(board));
- const repair = `${waited}. To keep looking: pullboard next --wait 9${values.verify ? ' --verify' : ''} (minutes; give the command a ten-minute timeout)`;
- io.refusal?.(new Refused('NOTHING_FREE', found.reasons.join('; ') + repair));
- io.err(`pullboard: [NOTHING_FREE] ${found.reasons.map((reason) => displayedWait(reason, agents, ctx.config)).join('; ')}${repair}`);
- return 1;
+ return refuseNextIdle(io, found.reasons, found.reasons.map((reason) => displayedWait(reason, agents, ctx.config)), { minutes, verify: values.verify, laneWork: found.laneWork });
}
if (!found.retry) await new Promise((done) => setTimeout(done, 5000));
}
diff --git a/src/next-steps.js b/src/next-steps.js
index ccc1f36d..787aa870 100644
--- a/src/next-steps.js
+++ b/src/next-steps.js
@@ -8,6 +8,32 @@
* every code raised in src/ has a row here.
*/
import { RECORDED_GENERIC_NEXT } from './recorded-refusal.js';
+import { Refused } from './refused.js';
+
+/** Name open build lanes without claiming their work as the coordinator [N2,B26]. */
+export function mainLaneWork(items) {
+ const counts = new Map();
+ for (const item of items) {
+ if (item.item_status !== 'open' || item.item_lane === 'coordinator') continue;
+ counts.set(item.item_lane, (counts.get(item.item_lane) ?? 0) + 1);
+ }
+ const lanes = [...counts].sort(([a], [b]) => a.localeCompare(b));
+ if (!lanes.length) return null;
+ return {
+ summary: lanes.map(([lane, count]) => `${count} ${count === 1 ? 'item' : 'items'} open in lane ${lane}`).join('; '),
+ next: `pullboard worktree ${lanes[0][0]} --model "<model name>"`,
+ };
+}
+
+/** Preserve empty-queue refusals while sending a main-checkout newcomer to existing lane work. */
+export function refuseNextIdle(io, reasons, displayed, { minutes, verify, laneWork }) {
+ const waited = minutes ? ` after ${minutes} minutes` : '';
+ const repair = laneWork ? `. ${laneWork.summary}. Start there: ${laneWork.next}`
+ : `${waited}. To keep looking: pullboard next --wait 9${verify ? ' --verify' : ''} (minutes; give the command a ten-minute timeout)`;
+ io.refusal?.(new Refused('NOTHING_FREE', reasons.join('; ') + repair, laneWork?.next));
+ io.err(`pullboard: [NOTHING_FREE] ${displayed.join('; ')}${repair}`);
+ return 1;
+}
/** The coordinator carries every seat's request for a person decision [B26]. */
export const COORDINATOR_PERSON_REQUEST = 'ask the coordinator to bring it to the person: pullboard shout coordinator "<what is needed>" --decision';
diff --git a/test/next-order.test.js b/test/next-order.test.js
index a33204c5..ed4c287f 100644
--- a/test/next-order.test.js
+++ b/test/next-order.test.js
@@ -7,7 +7,7 @@ import { applyEngineMove, applyRelayMove, prepareEngineMove } from '../src/engin
import { ENGINE_VERSION, MILESTONE_RANK_ENGINE } from '../src/machine.js';
import { exportBoard, importBoard } from '../src/exchange.js';
import { createE2eHelpers } from './e2e-helpers.js';
-import { existsSync, readFileSync } from 'node:fs';
+import { existsSync, mkdirSync, readFileSync } from 'node:fs';
import { join, resolve } from 'node:path';
import { createHash } from 'node:crypto';
@@ -164,6 +164,50 @@ function crossLaneFixture(t) {
return { ...box, session, runAs, json, seat, add, milestone, binding };
}
+test('next in the main checkout names the lane worktree to join [N2,B26]', t => {
+ const helpers = createE2eHelpers();
+ t.after(helpers.cleanup);
+ const box = helpers.sandbox(), repo = join(box.dir, 'fresh-board');
+ mkdirSync(repo);
+ box.git(repo, 'init', '-q', '-b', 'main');
+ const model = box.env.PULLBOARD_MODEL;
+ delete box.env.PULLBOARD_MODEL;
+ assert.equal(box.run(repo, 'init').code, 0);
+ if (model !== undefined) box.env.PULLBOARD_MODEL = model;
+ assert.equal(box.run(repo, 'lane', 'add', 'app', '--owns', 'app/').code, 0);
+ box.git(repo, 'add', '-A');
+ box.git(repo, 'commit', '-q', '-m', 'chore: set up the fresh board');
+ for (const title of ['First app item', 'Second app item']) {
+ const added = box.run(repo, 'add', 'app', title, '--route', 'strong',
+ '--criterion', 'The app item creates its readiness marker.', '--check', 'test -f app/ready', '--json');
+ assert.equal(added.code, 0, `${added.out}\n${added.err}`);
+ }
+ const json = box.run(repo, 'next', '--json');
+ assert.equal(json.code, 1, json.out);
+ const refusal = JSON.parse(json.out).error;
+ assert.equal(refusal.code, 'NOTHING_FREE', 'the empty coordinator queue keeps its refusal code');
+ assert.match(refusal.message, /2 items open in lane app/u);
+ assert.equal(refusal.next, 'pullboard worktree app --model "<model name>"');
+ assert.doesNotMatch(refusal.message + refusal.next, /wait|keep looking/iu);
+ for (const args of [[], ['--wait', '0.01']]) {
+ const text = box.run(repo, 'next', ...args);
+ assert.equal(text.code, 1);
+ assert.match(text.err, /2 items open in lane app/u);
+ assert.match(text.err, /pullboard worktree app --model "<model name>"/u);
+ assert.doesNotMatch(text.err, /pullboard next --wait|keep looking/iu);
+ }
+ const opened = box.run(repo, 'worktree', 'app', '--model', 'Newcomer test', '--json');
+ assert.equal(opened.code, 0, `${opened.out}\n${opened.err}`);
+ const seat = JSON.parse(opened.out);
+ const next = box.run(seat.path, 'next', '--build', '--json');
+ assert.equal(next.code, 0, `${next.out}\n${next.err}`);
+ assert.equal(JSON.parse(next.out).item.item_lane, 'app', 'the suggested command reaches work through the normal claim');
+ const idle = helpers.project('true');
+ const empty = JSON.parse(idle.run(idle.repo, 'next', '--json').out).error;
+ assert.equal(empty.code, 'NOTHING_FREE');
+ assert.match(empty.next, /pullboard next --wait 9/u, 'a genuinely idle board retains its ordinary wait');
+});
+
test('an agent pulls the top item in any of its lanes [N2,B13]', (t) => {
const box = crossLaneFixture(t);
const web = box.json(box.runAs(box.session, box.web, 'join', 'web', '--model', 'Cross-lane test', '--json'));