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(board): list lane decisions for agents [B21,B27]

Corey Olson8209cb3704c1
diff --git a/src/board.js b/src/board.js
index 3ab72b3e..8a212448 100644
--- a/src/board.js
+++ b/src/board.js
@@ -1313,10 +1313,11 @@ export function getShout(board, id) {
/**
* Shouts that asked for a decision nobody has answered yet, oldest first (B21). An optional
- * recipient limits the queue; without one this returns every open decision for internal readers.
+ * recipient limits the queue; an array matches any listed recipient. Without one this returns
+ * every open decision for internal readers.
*
* @param {any} board
- * @param {string} [recipient]
+ * @param {string | string[]} [recipient]
* @returns {any[]}
*/
export function openDecisions(board, recipient = null) {
@@ -1325,9 +1326,12 @@ export function openDecisions(board, recipient = null) {
.prepare('SELECT * FROM shout ask WHERE ask.shout_decision = 1 AND NOT EXISTS (SELECT 1 FROM shout reply WHERE reply.shout_answers = ask.shout_id) ORDER BY ask.shout_id')
.all();
}
+ const recipients = [...new Set(Array.isArray(recipient) ? recipient : [recipient])];
+ if (!recipients.length) return [];
+ const marks = recipients.map(() => '?').join(', ');
return board.db
- .prepare('SELECT * FROM shout ask WHERE ask.shout_decision = 1 AND ask.shout_to = ? AND NOT EXISTS (SELECT 1 FROM shout reply WHERE reply.shout_answers = ask.shout_id) ORDER BY ask.shout_id')
- .all(recipient);
+ .prepare(`SELECT * FROM shout ask WHERE ask.shout_decision = 1 AND ask.shout_to IN (${marks}) AND NOT EXISTS (SELECT 1 FROM shout reply WHERE reply.shout_answers = ask.shout_id) ORDER BY ask.shout_id`)
+ .all(...recipients);
}
/** Requests remain visible to the coordinator until a done or declined answer closes them (A2). */
diff --git a/src/cli.js b/src/cli.js
index e18e7813..b74a62e1 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -995,7 +995,7 @@ function readCommands(io, { first, second, rest, values }) {
const asks = withBoard(ctx, (board) => {
const me = whoAmI(ctx, board);
const asPerson = personMode(ctx, me, values);
- return store.openDecisions(board, asPerson ? 'person' : me.id);
+ return store.openDecisions(board, asPerson ? 'person' : [me.id, me.lane]);
});
io.result?.({ decisions: asks });
if (!asks.length) io.say('no open decisions');
diff --git a/test/api.test.js b/test/api.test.js
index fb7ed938..a35766d4 100644
--- a/test/api.test.js
+++ b/test/api.test.js
@@ -281,6 +281,71 @@ test('[A1,B21,B27] a lane decision is answered by its agent through CLI JSON', (
assert.equal(delivered.shout_text, 'Retry once.');
});
+test('[A1,B21,B27] decisions shows an agent its direct and lane asks only', () => {
+ const box = project();
+ /** Create a real worktree registered to the requested lane. */
+ const worktree = (name, lane) => {
+ const path = join(box.dir, name);
+ box.git(box.repo, 'worktree', 'add', '-q', path, '-b', `${lane}/${name}`);
+ const joined = box.run(path, 'join', lane);
+ assert.equal(joined.status, 0, joined.stderr);
+ return path;
+ };
+ const app1 = worktree('app-1', 'app');
+ const app2 = worktree('app-2', 'app');
+ const review = worktree('review-1', 'review');
+ const laneAsk = json(box, box.repo, 'shout', ['app', 'Lane decision?', '--decision']).id;
+ const app1Ask = json(box, box.repo, 'shout', ['app-1', 'App one decision?', '--decision']).id;
+ const app2Ask = json(box, box.repo, 'shout', ['app-2', 'App two decision?', '--decision']).id;
+ const reviewAsk = json(box, box.repo, 'shout', ['review', 'Review decision?', '--decision']).id;
+ const coordinatorAsk = json(box, box.repo, 'shout', ['coordinator', 'Coordinator decision?', '--decision']).id;
+
+ const app1Queue = json(box, app1, 'decisions').decisions.map(({ shout_id }) => shout_id);
+ assert.deepEqual(app1Queue, [laneAsk, app1Ask]);
+ const app1Text = box.run(app1, 'decisions');
+ assert.equal(app1Text.status, 0, app1Text.stderr);
+ assert.match(app1Text.stdout, new RegExp(`#${laneAsk}\\b`));
+ assert.match(app1Text.stdout, new RegExp(`#${app1Ask}\\b`));
+ assert.doesNotMatch(app1Text.stdout, new RegExp(`#(?:${app2Ask}|${reviewAsk}|${coordinatorAsk})\\b`));
+ assert.deepEqual(json(box, app2, 'decisions').decisions.map(({ shout_id }) => shout_id), [laneAsk, app2Ask]);
+ assert.deepEqual(json(box, review, 'decisions').decisions.map(({ shout_id }) => shout_id), [reviewAsk]);
+ const app2Text = box.run(app2, 'decisions');
+ assert.equal(app2Text.status, 0, app2Text.stderr);
+ assert.match(app2Text.stdout, new RegExp(`#${laneAsk}\\b`));
+ assert.match(app2Text.stdout, new RegExp(`#${app2Ask}\\b`));
+ const reviewText = box.run(review, 'decisions');
+ assert.equal(reviewText.status, 0, reviewText.stderr);
+ assert.match(reviewText.stdout, new RegExp(`#${reviewAsk}\\b`));
+ assert.doesNotMatch(reviewText.stdout, new RegExp(`#(?:${laneAsk}|${app1Ask}|${app2Ask}|${coordinatorAsk})\\b`));
+
+ json(box, app2, 'answer', [String(laneAsk), 'Lane answered.']);
+ assert.deepEqual(json(box, app1, 'decisions').decisions.map(({ shout_id }) => shout_id), [app1Ask]);
+ const answeredText = box.run(app2, 'decisions');
+ assert.equal(answeredText.status, 0, answeredText.stderr);
+ assert.match(answeredText.stdout, new RegExp(`#${app2Ask}\\b`));
+ assert.doesNotMatch(answeredText.stdout, new RegExp(`#${laneAsk}\\b`));
+ assert.deepEqual(json(box, box.repo, 'decisions').decisions.map(({ shout_id }) => shout_id), [coordinatorAsk]);
+ const passedAsk = json(box, app1, 'shout', ['coordinator', 'Please decide this.', '--decision']).id;
+ const pass = json(box, box.repo, 'pass', [String(passedAsk), 'the person should decide']);
+ assert.deepEqual(json(box, box.repo, 'decisions', ['--as', 'person']).decisions.map(({ shout_id }) => shout_id), [pass.id]);
+ jsonError(box, app1, 'decisions', ['--as', 'person'], {
+ status: 1,
+ code: 'B26_PERSON_ANSWER',
+ message: '[B26_PERSON_ANSWER] only the main checkout can act as the person; ask your coordinator to answer or pass this decision',
+ next: 'ask your coordinator to answer or pass this decision',
+ });
+ jsonError(box, app1, 'answer', [String(app2Ask), 'No'], {
+ status: 1,
+ code: 'NOT_YOUR_DECISION',
+ message: `shout #${app2Ask} is addressed to app-2, not your app lane (agent app-1)`,
+ next: 'Run pullboard help, correct the reported problem, and retry the command.',
+ });
+ const coordinatorText = box.run(box.repo, 'decisions');
+ assert.equal(coordinatorText.status, 0, coordinatorText.stderr);
+ assert.match(coordinatorText.stdout, new RegExp(`#${coordinatorAsk}\\b`));
+ assert.doesNotMatch(coordinatorText.stdout, new RegExp(`#(?:${app1Ask}|${app2Ask}|${reviewAsk})\\b`));
+});
+
test('[A1] refusals are one JSON document with exact public error fields', () => {
const box = sandbox();
const repo = join(box.dir, 'repo');
diff --git a/test/board.test.js b/test/board.test.js
index 7d9db4bb..508b1622 100644
--- a/test/board.test.js
+++ b/test/board.test.js
@@ -342,6 +342,18 @@ test('an agent cannot answer another lane decision [B21,B27]', () => {
assert.deepEqual(store.openDecisions(board, 'api').map(({ shout_id }) => shout_id), [ask]);
});
+test('the decisions store query accepts multiple recipients once in shout order [B21,B27]', () => {
+ const lanes = ['coordinator', 'web', 'api'];
+ const laneAsk = store.shout(board, { from: 'web-1', to: 'api', text: 'lane?', lanes, decision: true });
+ const directAsk = store.shout(board, { from: 'web-1', to: 'api-1', text: 'direct?', lanes, decision: true });
+ const otherLaneAsk = store.shout(board, { from: 'web-1', to: 'web', text: 'other?', lanes, decision: true });
+ assert.deepEqual(store.openDecisions(board, ['api-1', 'api', 'api']).map(({ shout_id }) => shout_id), [laneAsk, directAsk]);
+ store.answerDecision(board, laneAsk, { agentId: 'api-1', text: 'yes', lanes });
+ assert.deepEqual(store.openDecisions(board, ['api-1', 'api']).map(({ shout_id }) => shout_id), [directAsk]);
+ assert.deepEqual(store.openDecisions(board, []), []);
+ assert.deepEqual(store.openDecisions(board, 'web').map(({ shout_id }) => shout_id), [otherLaneAsk]);
+});
+
test('decisions climb to the person and answers return to the first asker [B25, B26, B27]', () => {
const lanes = ['coordinator', 'web', 'api'];
const original = store.shout(board, { from: 'web-1', to: 'coordinator', text: 'Ship today?', lanes, decision: true });