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(health): printed next steps run as pasted [N2,B13]

Corey Olson04ff4233081b
diff --git a/src/health.js b/src/health.js
index 70dcc10d..121e038c 100644
--- a/src/health.js
+++ b/src/health.js
@@ -291,8 +291,8 @@ function queueFaults(board, { items, at }) {
subject: `${route} route`, key: `ROUTE_UNSERVED:route:${route}`, since: since(first.id), now,
title: 'route has no active agent',
why: `${open.length} open ${route} ${open.length === 1 ? 'item waits' : 'items wait'}, starting with #${first.id}, and no active agent can take ${route} work`,
- next: `start an agent on the ${route} route: pullboard join ${first.lane} --route ${route}`,
- command: `pullboard join ${first.lane} --route ${route}`,
+ next: `start an agent on the ${route} route: in a shell with PULLBOARD_MODEL set, run pullboard worktree ${first.lane} --route ${route}`,
+ command: `pullboard worktree ${first.lane} --route ${route}`,
owner: { role: 'coordinator', who: COORDINATOR }, detail: { route, items: open.map((entry) => entry.id) },
}));
}
@@ -303,8 +303,8 @@ function queueFaults(board, { items, at }) {
subject: `#${entry.id}`, key: `ITEM_UNTAKEABLE:item:${entry.id}`, since: since(entry.id), now,
title: 'nobody can take it',
why: `no active agent in the ${entry.lane} lane can take a ${entry.route} item, so #${entry.id} waits: ${entry.title}`,
- next: `start an agent in the ${entry.lane} lane on the ${entry.route} route: pullboard join ${entry.lane} --route ${entry.route}`,
- command: `pullboard join ${entry.lane} --route ${entry.route}`,
+ next: `start an agent in the ${entry.lane} lane on the ${entry.route} route: in a shell with PULLBOARD_MODEL set, run pullboard worktree ${entry.lane} --route ${entry.route}`,
+ command: `pullboard worktree ${entry.lane} --route ${entry.route}`,
owner: { role: 'coordinator', who: COORDINATOR }, detail: { lane: entry.lane, route: entry.route },
}));
}
diff --git a/test/health.test.js b/test/health.test.js
index b657ba01..101aebe0 100644
--- a/test/health.test.js
+++ b/test/health.test.js
@@ -316,7 +316,9 @@ test('health names a route with open work and no agent [N2,B13]', async (t) => {
assert.ok(route, `health names the route nobody serves: ${result.stdout}`);
assert.deepEqual(route.owner, { role: 'coordinator', who: 'coordinator' }, 'the coordinator starts an agent on the route');
assert.ok(route.why.includes(`#${waiting}`), `the finding names the waiting item: ${route.why}`);
- assert.ok(route.next.includes('--route mid'), `the next step joins the route: ${route.next}`);
+ assert.equal(route.command, 'pullboard worktree core --route mid', `the command starts an agent on the route: ${route.command}`);
+ assert.ok(route.next.includes('pullboard worktree core --route mid') && route.next.includes('PULLBOARD_MODEL'), `the next step names the worktree command and the model: ${route.next}`);
+ assert.ok(!route.command.includes('pullboard join'), 'join from the main checkout would enroll the coordinator, not start an agent');
assert.ok(!report.stuck.some((entry) => entry.owner?.who === light && entry.key.startsWith('ROUTE_UNSERVED')), 'the light agent is not named for a mid route');
});
@@ -338,3 +340,48 @@ test('health names a rank inversion [N2,B13]', async (t) => {
assert.ok(inversion.why.includes(`#${earlier}`), `the finding names the free item ahead: ${inversion.why}`);
assert.ok(inversion.next.includes(`claim #${earlier}`), `the next step claims it: ${inversion.next}`);
});
+
+test('every printed next step runs as pasted through main() [N2,B13]', async (t) => {
+ // Each next step health prints runs from the directory a person would use: the worktree commands from
+ // the main checkout, and the agent steps from that agent's own worktree (#798).
+ const box = repo(t);
+ const brief = { criterion: 'The item is done when its test passes.', check: 'true', brief: 'Files:\n- src/mid.js\nTest:\n- the mid work runs' };
+ const { board, at } = boardAt(box);
+ at(40 * HOUR);
+ store.register(board, { lane: 'coordinator', path: box.root });
+ const idlePath = join(box.dir, 'core-idle');
+ box.git(['worktree', 'add', '-q', idlePath, '-b', 'core-idle']);
+ const idle = store.register(board, { lane: 'core', route: 'strong', path: idlePath });
+ at(HOUR / 12);
+ const holderPath = join(box.dir, 'core-holder');
+ box.git(['worktree', 'add', '-q', holderPath, '-b', 'core-holder']);
+ const holder = store.register(board, { lane: 'core', route: 'mid', path: holderPath });
+ store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Earlier mid', route: 'mid', ...brief });
+ const later = store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Later mid', route: 'mid', ...brief });
+ const strong = store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Strong work' });
+ store.claim(board, later, { agentId: holder, lane: 'core', leaseMs: 2 * HOUR, freeze });
+ store.closeBoard(board);
+
+ const before = await cli(box.root, ['health', '--json']);
+ const printed = JSON.parse(before.stdout).stuck.filter((entry) => entry.command);
+ const keys = printed.map((entry) => entry.key);
+ for (const key of [`ROUTE_UNSERVED:route:strong`, `ITEM_UNTAKEABLE:item:${strong}`, `IDLE_AGENT:agent:${idle}`, `RANK_INVERSION:item:${later}`]) {
+ assert.ok(keys.includes(key), `health prints a next step for ${key}: ${keys.join(', ')}`);
+ }
+ const folders = { [idle]: idlePath, [holder]: holderPath };
+ const saved = process.env.PULLBOARD_MODEL;
+ process.env.PULLBOARD_MODEL = 'claude-haiku-5-5';
+ try {
+ for (const entry of printed) {
+ assert.ok(!entry.command.startsWith('pullboard join'), `${entry.key} never runs join: ${entry.command}`);
+ const argv = entry.command.match(/"[^"]*"|\S+/gu).slice(1).map((token) => token.replace(/^"|"$/gu, ''));
+ const ran = await cli(folders[entry.owner.who] ?? box.root, argv);
+ assert.equal(ran.code, 0, `${entry.key} runs as printed: pullboard ${argv.join(' ')}: ${ran.stderr}${ran.stdout}`);
+ }
+ } finally {
+ if (saved === undefined) delete process.env.PULLBOARD_MODEL; else process.env.PULLBOARD_MODEL = saved;
+ }
+ const after = JSON.parse((await cli(box.root, ['health', '--json'])).stdout);
+ assert.ok(!after.stuck.some((entry) => entry.key === 'ROUTE_UNSERVED:route:strong'), 'the worktree the next step starts serves the strong route');
+ assert.ok(!after.stuck.some((entry) => entry.key === `RANK_INVERSION:item:${later}`), 'the release the next step names clears the rank inversion');
+});