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.

chore(cli): integrate ordered engine before checks [V2,H16]

Corey Olson546f25e38d0e
diff --cc docs/api.md
index edfaaa0b,edfaaa0b..8db67928
--- a/docs/api.md
+++ b/docs/api.md
@@@ -1,6 -1,6 +1,6 @@@
# CLI JSON API
--Add `--json` to a Pullboard command to receive one JSON document on stdout. The document has `version: 1`; diagnostics stay out of stderr. The flag may appear with command options before `--`. A flag after `--` is an argument to the command, not an output-mode switch.
++Add `--json` to a Pullboard command to receive one JSON document on stdout. The document has `version: 1`; diagnostics stay out of stderr except for sign-in instructions and check consent notices that must appear before execution. The flag may appear with command options before `--`. A flag after `--` is an argument to the command, not an output-mode switch.
The API version is independent of the package version. Its contract is stable within each major API version: existing command names, required fields, field types, and refusal fields do not change within that version. An incompatible change requires a new `version`. New fields may be added, so clients should ignore fields they do not use.
@@@ -78,7 -78,7 +78,9 @@@ A successful command returns the field
## Refusals
--A refusal keeps the command's existing exit status and prints exactly one versioned document to stdout. In JSON mode stderr stays empty. The command-specific `code` identifies the rule; `message` explains what happened; `next` gives the next step.
++A refusal keeps the command's existing exit status and prints exactly one versioned document to stdout. In JSON mode stderr stays empty except for sign-in instructions and check consent notices. The command-specific `code` identifies the rule; `message` explains what happened; `next` gives the next step.
++
++Only the coordinator sets or edits an item's `--check`. `pullboard check [id]` prints the command and its setter before execution, and asks for consent when the caller did not set it. Use `--yes` to confirm that command without a prompt. An EOF or declined answer refuses with `CHECK_CONFIRM` before running the command. With `--json`, the notice and prompt appear immediately on stderr and stdout remains one JSON document; a successful check result also includes the optional `by` setter field.
```json
{
diff --cc src/cli.js
index 9def42ba,7e37c1cf..bc3199a4
--- a/src/cli.js
+++ b/src/cli.js
@@@ -1363,8 -1390,8 +1392,8 @@@ function workCommands(io, args)
after,
brief: briefInLane(ctx, first, briefArg(io, values) ?? ''),
route: values.route ?? 'strong',
- check: values.check ?? '',
+ check: values.check,
- });
+ }]);
io.result?.({ item: store.getItem(board, id) });
io.say(`#${id}`);
return 0;
@@@ -1394,33 -1421,21 +1423,33 @@@
io.say(`#${id} escalated ${moved.from} -> ${moved.to}; it is open for a ${moved.to} agent`);
return 0;
}),
- run: () => runItems(io, values, { context, withBoard, whoAmI, nextOnce, submitHere, freezer }),
+ run: () => runItems(io, values, { context, withBoard, whoAmI, nextOnce, submitHere, freezer, ordered }),
sweep: () => act((ctx, board, me) => sweepHere(ctx, board, me, values)),
next: () => nextHere(io, { ...values, verifyId: first }),
- check: () => {
+ check: async () => {
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);
+ const { item, author, caller } = withBoard(ctx, (board) => {
+ const me = first ? (ctx.info.isMain ? { id: COORDINATOR } : { id: store.agentAt(board, ctx.info.root)?.agent_id }) : whoAmI(ctx, board);
+ 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');
- return held;
+ return { item: held, author: store.itemCheckAuthor(board, held.item_id), caller: me.id };
});
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 by = author || 'unknown (legacy)';
+ const notice = `check #${item.item_id} set by ${by}: ${item.item_check}`;
+ if (values.json) io.stderr.write(`${notice}\n`);
+ else io.say(notice);
+ if (!values.yes && (!author || author !== caller)) {
+ if (values.json) io.stderr.write('Run this check? [y/N]\n');
+ else io.err('Run this check? [y/N]');
+ const answer = await firstInputLine(io.stdin);
+ if (!/^y(?:es)?$/iu.test(answer.trim())) {
+ throw new Refused('CHECK_CONFIRM', `the check set by ${by} was not run: ${item.item_check}; run pullboard check ${item.item_id} --yes after reading the command, or answer yes at the prompt`);
+ }
+ }
const run = runShell(ctx.info.root, item.item_check);
- io.result?.({ id: item.item_id, green: run.isGreen, seconds: run.seconds, check: item.item_check, report: run.isGreen ? '' : digestOf(run.output) });
+ io.result?.({ id: item.item_id, green: run.isGreen, seconds: run.seconds, check: item.item_check, by, report: run.isGreen ? '' : digestOf(run.output) });
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;
diff --cc test/api.test.js
index 2024de3f,2024de3f..03477483
--- a/test/api.test.js
+++ b/test/api.test.js
@@@ -178,8 -178,8 +178,10 @@@ function assertRequiredShape(value, req
function json(box, cwd, command, args = [], subcommand) {
const result = box.run(cwd, command, ...args, '--json');
assert.equal(result.status, 0, `${command} ${args.join(' ')}: ${result.stderr}${result.stdout}`);
-- assert.equal(result.stderr, '', `${command} --json must keep stderr empty`);
const document = JSON.parse(result.stdout);
++ if (command === 'check') {
++ assert.equal(result.stderr, `check #${document.id} set by ${document.by}: ${document.check}\n`, 'check attribution is visible before execution while stdout remains one JSON document');
++ } else assert.equal(result.stderr, '', `${command} --json must keep stderr empty`);
assert.equal(document.version, 1, `${command} --json has a version 1 envelope`);
assertRequiredShape(document, shapeFor(command, subcommand).required, command);
return document;