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.

feat(core): reserve a named review from next [V15]

Corey Olson0e6529ee890b
diff --git a/src/cli.js b/src/cli.js
index 1b7fc430..e49485e7 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -87,6 +87,7 @@ Work
earlier ones as one line; --history prints every note in full
pullboard next [--wait <minutes>] claim the next item in your lane that is free to start
pullboard next --verify reserve the next submitted item you can check;
+ pullboard next --verify <id> reserve that submitted item instead
in the main checkout, verifying needs --as coordinator
pullboard check [id] run your item's check, the command that proves it (the project gate is pullboard gate)
pullboard claim <id> take or renew a lease; the first claim freezes the criterion
@@ -1117,6 +1118,10 @@ function nextOnce(ctx, values) {
if (values.verify) checkMainVerifier(ctx, board, values);
const me = whoAmI(ctx, board);
if (values.verify) {
+ const reservation = { agentId: me.id, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify };
+ if (values.verifyId !== undefined) {
+ return { item: store.reserveReview(board, idArg(values.verifyId, 'an item id after --verify'), reservation), reasons: [] };
+ }
return store.reserveNextReview(board, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify, runnable: values.runnable, routes: values.routes });
}
const warm = warmFiles(ctx, board, me);
@@ -1143,6 +1148,10 @@ function nextOnce(ctx, values) {
*/
async function nextHere(io, values) {
const ctx = context(io);
+ if (values.verifyId !== undefined && !values.verify) {
+ throw new Refused('USAGE', 'give an item id only with --verify: pullboard next --verify <id>');
+ }
+ if (values.verifyId !== undefined) idArg(values.verifyId, 'an item id after --verify');
const minutes = values.wait === undefined ? 0 : Number(values.wait);
if (!Number.isFinite(minutes) || minutes < 0 || minutes > 240) {
throw new Refused('USAGE', '--wait is a number of minutes from 0 to 240');
@@ -1302,7 +1311,7 @@ function workCommands(io, args) {
}),
run: () => runItems(io, values, { context, withBoard, whoAmI, nextOnce, submitHere, freezer }),
sweep: () => act((ctx, board, me) => sweepHere(ctx, board, me, values)),
- next: () => nextHere(io, values),
+ next: () => nextHere(io, { ...values, verifyId: first }),
check: () => {
const ctx = context(io);
const item = withBoard(ctx, (board) => {
diff --git a/test/e2e.test.js b/test/e2e.test.js
index f38b3ce4..fdbd10c4 100644
--- a/test/e2e.test.js
+++ b/test/e2e.test.js
@@ -20,6 +20,7 @@ import { connect } from 'node:net';
import { join, resolve } from 'node:path';
import { after, test } from 'node:test';
import { parseSpec } from '../src/spec.js';
+import * as store from '../src/board.js';
const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
const cockpitSource = () => readFileSync(resolve(import.meta.dirname, '../src/cockpit.js'), 'utf8');
@@ -679,6 +680,68 @@ test('next claims the next free item; --verify names the next to check [N2]', ()
assert.match(box.run(box.web, 'next', '--verify').err, /NOTHING_FREE/);
});
+test('next --verify can reserve a named submitted review and default to the lowest free one [V15]', () => {
+ const box = project();
+ const reviewers = ['api-1', 'api-2'].map((name) => {
+ const path = join(box.dir, name);
+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', path);
+ const joined = box.run(path, 'join', 'api');
+ assert.equal(joined.code, 0, joined.err);
+ return path;
+ });
+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));
+ let first;
+ let second;
+ try {
+ const commit = box.git(box.repo, 'rev-parse', 'HEAD');
+ const tree = box.git(box.repo, 'rev-parse', 'HEAD^{tree}');
+ /** Create and submit an item through the real SQLite board state. */
+ const submit = (title) => {
+ const id = store.addItem(board, { by: 'coordinator', lane: 'web', title });
+ store.claim(board, id, {
+ agentId: 'web-1', lane: 'web', leaseMs: 60 * 60_000,
+ freeze: (item) => ({ text: item.item_title, digest: `digest:${item.item_title}` }),
+ });
+ store.submit(board, id, { agentId: 'web-1', commit, tree });
+ return id;
+ };
+ first = submit('First review');
+ second = submit('Second review');
+ } finally {
+ store.closeBoard(board);
+ }
+
+ const named = box.run(reviewers[0], 'next', '--verify', String(second));
+ assert.equal(named.code, 0, named.err);
+ assert.match(named.out, new RegExp(`next to verify: #${second} Second review, built by web-1`));
+ assert.match(named.out, new RegExp(`check out exactly that commit, here: cd ${reviewers[0]} && git switch --detach [0-9a-f]{40}`));
+ const namedJson = box.run(reviewers[0], 'next', '--verify', String(second), '--json');
+ assert.equal(namedJson.code, 0, namedJson.err);
+ const result = JSON.parse(namedJson.out);
+ assert.equal(result.version, 1);
+ assert.equal(result.item.item_id, second);
+ assert.equal(result.review, true);
+ assert.equal(result.held, false);
+ assert.deepEqual(result.shared, []);
+ const reserved = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));
+ try {
+ assert.equal(store.getItem(reserved, second).item_review_by, 'api-1', 'the named item is reserved for the caller');
+ } finally {
+ store.closeBoard(reserved);
+ }
+
+ const held = box.run(reviewers[1], 'next', '--verify', String(second));
+ assert.equal(held.code, 1, held.out);
+ assert.match(held.err, /REVIEW_HELD/);
+ const builder = box.run(box.web, 'next', '--verify', String(first));
+ assert.equal(builder.code, 1, builder.out);
+ assert.match(builder.err, /SELF_VERIFY/);
+
+ const lowest = box.run(reviewers[1], 'next', '--verify');
+ assert.equal(lowest.code, 0, lowest.err);
+ assert.match(lowest.out, new RegExp(`next to verify: #${first} First review, built by web-1`));
+});
+
test('a deleted spec row is refused at commit; spec check finds any id gone from history or cited [S8, S9]', () => {
const box = project();
const spec = join(box.repo, 'SPEC.md');