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(cli): pullboard check runs an item's check [N23]

Corey Olson03b123513f44
diff --git a/src/cli.js b/src/cli.js
index fb17a70f..319bb8a7 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -9,7 +9,7 @@ import { pathToFileURL } from 'node:url';
import { parseArgs } from 'node:util';
import * as store from './board.js';
import { COORDINATOR, loadConfig } from './config.js';
-import { gateReport, runGate } from './gate.js';
+import { digestOf, gateReport, runGate, runShell } from './gate.js';
import { contains, git, headCommit, headTree, isClean, repoInfo, resolveCommit, tryGit, untracked } from './git.js';
import {
FIX_NOTE,
@@ -75,6 +75,7 @@ Work
pullboard show <id> an item, the criterion frozen at claim, its verdicts
pullboard next [--wait <minutes>] claim the next item in your lane that is free to start
pullboard next --verify name the next submitted item you can check
+ pullboard check [id] run your item's check, the command that proves it (the project gate is pullboard gate)
in the main checkout, verifying needs --as coordinator
pullboard claim <id> take or renew a lease; the first claim freezes the criterion
pullboard release <id> hand it back
@@ -936,6 +937,21 @@ 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),
+ check: () => {
+ const ctx = context(io);
+ const item = withBoard(ctx, (board) => {
+ if (first) return store.getItem(board, idArg(first));
+ const me = whoAmI(ctx, board);
+ const held = 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');
+ return held;
+ });
+ if (!item.item_check) throw new Refused('NO_CHECK', `#${item.item_id} has no check command; its proof is the project gate: pullboard gate`);
+ const run = runShell(ctx.info.root, item.item_check);
+ io.say(`check ${run.isGreen ? 'green' : 'red'} in ${run.seconds}s: ${item.item_check}`);
+ if (!run.isGreen) io.say(digestOf(run.output).replace(/^/gm, ' '));
+ return run.isGreen ? 0 : 1;
+ },
claim: () => act((ctx, board, me) => {
const result = store.claim(board, idArg(first), { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: freezer(ctx), head: headCommit(ctx.info.root) });
io.say(`${result.renewed ? 'renewed' : 'claimed'} #${first} until ${result.leaseUntil}; criterion frozen as ${result.digest.slice(0, 12)}`);
diff --git a/src/gate.js b/src/gate.js
index a2239890..b17dd8b5 100644
--- a/src/gate.js
+++ b/src/gate.js
@@ -53,6 +53,21 @@ export function isStampedGreen(root) {
return tree !== null && existsSync(file) && readFileSync(file, 'utf8').trim() === tree;
}
+/**
+ * Run a shell command in a checkout for a digest: both streams in one pipe, in order, read whole
+ * however long, stdin closed so nothing waits on a person.
+ *
+ * @param {string} root
+ * @param {string} command
+ * @returns {{ isGreen: boolean, output: string, seconds: number }}
+ */
+export function runShell(root, command) {
+ const started = Date.now();
+ // Newlines, not spaces, around the command, so a trailing comment in it cannot swallow the `)`.
+ const result = spawnSync(`(\n${command}\n) 2>&1`, { cwd: root, shell: true, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', maxBuffer: 2 ** 30 });
+ return { isGreen: result.status === 0, output: `${result.stdout ?? ''}${result.stderr ?? ''}`, seconds: Math.round((Date.now() - started) / 1000) };
+}
+
/**
* Run the configured gate in the repo, unless this exact tree already passed. Its output, both
* streams in order, is kept whole in the git dir and returned for a digest.
@@ -67,17 +82,13 @@ export function runGate(root, config) {
}
if (isStampedGreen(root)) return { isGreen: true, isCached: true, output: '', seconds: 0, log: '' };
const before = committedTree(root);
- const started = Date.now();
- // Newlines, not spaces, around the command, so a trailing comment in it cannot swallow the `)`.
- const result = spawnSync(`(\n${config.gate}\n) 2>&1`, { cwd: root, shell: true, stdio: ['ignore', 'pipe', 'pipe'], encoding: 'utf8', maxBuffer: 2 ** 30 });
- const isGreen = result.status === 0;
- const output = `${result.stdout ?? ''}${result.stderr ?? ''}`;
+ const { isGreen, output, seconds } = runShell(root, config.gate);
const log = gitPath(root, LOG);
writeFileSync(log, output);
if (isGreen && before !== null && committedTree(root) === before) {
writeFileSync(gitPath(root, STAMP), `${before}\n`);
}
- return { isGreen, isCached: false, output, seconds: Math.round((Date.now() - started) / 1000), log };
+ return { isGreen, isCached: false, output, seconds, log };
}
/**
diff --git a/test/e2e.test.js b/test/e2e.test.js
index ff3ea687..63e5791a 100644
--- a/test/e2e.test.js
+++ b/test/e2e.test.js
@@ -747,3 +747,24 @@ test('spec check at an older commit skips ids that items cite from a later commi
assert.match(ghost.out, /SPEC.md: G4 error: item #2 cites it, but it was never committed/);
assert.doesNotMatch(ghost.out, /G3 error/);
});
+
+test('check runs the item\'s own check command, yours by default, and prints a digest [N23]', () => {
+ const box = project();
+ box.run(box.repo, 'add', 'web', 'Page', '--specs', 'G1', '--check', 'test -f web/a.html || { echo "not ok 1 - web/a.html is missing"; exit 1; }');
+ box.run(box.repo, 'add', 'web', 'Loose', '--specs', 'G1');
+ assert.match(box.run(box.web, 'check').err, /NOT_HOLDING.*pullboard gate/);
+ box.run(box.web, 'claim', '1');
+ const red = box.run(box.web, 'check');
+ assert.equal(red.code, 1);
+ assert.match(red.out, /^check red in \d+s: test -f web\/a.html/);
+ assert.match(red.out, /\n {2}not ok 1 - web\/a.html is missing\n/);
+ mkdirSync(join(box.web, 'web'));
+ writeFileSync(join(box.web, 'web', 'a.html'), '<h1>Hi</h1>');
+ const green = box.run(box.web, 'check');
+ assert.equal(green.code, 0, green.out);
+ assert.match(green.out, /^check green in \d+s: test -f web\/a.html/);
+ assert.equal(green.out.split('\n').filter(Boolean).length, 1);
+ assert.equal(box.run(box.repo, 'check', '1').code, 1, 'named, from another checkout: there the file is missing');
+ assert.match(box.run(box.web, 'check', '2').err, /NO_CHECK.*#2 has no check command/);
+ assert.match(box.run(box.repo, 'help').out, /pullboard check \[id\]/);
+});