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): allow lane decision answers [B21,B27]

Corey Olson9a53b627fda8
diff --git a/docs/api.md b/docs/api.md
index 40a88392..8087130b 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -4,7 +4,7 @@ Add `--json` to a Pullboard command to receive one JSON document on stdout. The
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.
-Decision shouts without a recipient go to the agent's coordinator, or to `person` when sent by the coordinator. `pullboard pass <shout-id> <note>` is for coordinators: it forwards an open coordinator decision to the person with the original question and note. From the main checkout, `pullboard decisions` and `pullboard answer <shout-id> <text>` default to the coordinator; use `--as person` to select the person's queue or answer a person-addressed decision. Person mode is accepted only in the main checkout. An answer in person mode cannot answer a coordinator-addressed decision, and a coordinator-default answer cannot impersonate the person; the refusal prints the command to retry. A person answer is delivered to the original asker. An agent worktree cannot select person mode.
+Decision shouts without a recipient go to the agent's coordinator, or to `person` when sent by the coordinator. An agent may answer a decision sent to its own lane; the reply names that agent and goes to the original asker. An agent in another lane gets `NOT_YOUR_DECISION`. `pullboard pass <shout-id> <note>` is for coordinators: it forwards an open coordinator decision to the person with the original question and note. From the main checkout, `pullboard decisions` and `pullboard answer <shout-id> <text>` default to the coordinator; use `--as person` to select the person's queue or answer a person-addressed decision. Person mode is accepted only in the main checkout. An answer in person mode cannot answer a coordinator-addressed decision, and a coordinator-default answer cannot impersonate the person; the refusal prints the command to retry. A person answer is delivered to the original asker. An agent worktree cannot select person mode.
A successful command returns the fields listed below. `version` is always the number `1`. The catalog lists required top-level fields; nested objects and arrays are command data, and optional top-level fields may be added.
diff --git a/docs/api.test.js b/docs/api.test.js
index 3aeb31d9..dcb5922d 100644
--- a/docs/api.test.js
+++ b/docs/api.test.js
@@ -28,6 +28,7 @@ function readShapeTable(start, end) {
test('[A1] API guide documents every CLI result and refusal shape from the source catalog', () => {
assert.match(guide, /stable within each major API version/);
assert.match(guide, /incompatible change requires a new \x60version\x60/);
+ assert.match(guide, /agent may answer a decision sent to its own lane/);
const documentedCommands = readShapeTable('<!-- api-command-shapes:start -->', '<!-- api-command-shapes:end -->');
const sourceCommands = Object.fromEntries(Object.entries(JSON_SHAPES.commands).map(([name, shape]) => [name, shape.required]));
@@ -38,7 +39,6 @@ test('[A1] API guide documents every CLI result and refusal shape from the sourc
assert.deepEqual(documentedRefusals.error, JSON_SHAPES.errorFields);
assert.deepEqual(Object.keys(documentedRefusals).sort(), ['envelope', 'error']);
});
-
test('[A2] API guide documents the local HTTP response catalog', () => {
const documented = readShapeTable('<!-- api-http-shapes:start -->', '<!-- api-http-shapes:end -->');
const source = Object.fromEntries(Object.entries(JSON_SHAPES.http).map(([name, shape]) => [name, shape.required]));
diff --git a/src/board.js b/src/board.js
index 46538522..3ab72b3e 100644
--- a/src/board.js
+++ b/src/board.js
@@ -1263,7 +1263,12 @@ export function answerDecision(board, id, { agentId, text, lanes, asPerson = fal
if (asPerson && ask.shout_to !== PERSON) throw new Refused('B26_PERSON_ANSWER', `person mode answers only decisions addressed to the person; the coordinator answers this one: pullboard answer ${id} "<answer>"`);
if (!asPerson && ask.shout_to === PERSON && agentId === COORDINATOR) throw new Refused('B26_PERSON_ANSWER', `this decision is addressed to the person; answer from the main checkout: pullboard answer ${id} "<answer>" --as person`);
const personAnswer = asPerson;
- if (ask.shout_to !== agentId && !personAnswer) throw new Refused('NOT_YOUR_DECISION', `shout #${id} is addressed to ${ask.shout_to}, not ${agentId}`);
+ const caller = personAnswer ? null : board.db.prepare('SELECT agent_lane FROM agent WHERE agent_id = ?').get(agentId);
+ const ownsDecision = ask.shout_to === agentId || ask.shout_to === caller?.agent_lane;
+ if (!ownsDecision && !personAnswer) {
+ const lane = caller?.agent_lane ? `your ${caller.agent_lane} lane` : 'a lane you do not belong to';
+ throw new Refused('NOT_YOUR_DECISION', `shout #${id} is addressed to ${ask.shout_to}, not ${lane} (agent ${agentId})`);
+ }
const from = personAnswer ? PERSON : agentId;
const answerId = insertShout(board, { from, to: ask.shout_from, text, lanes, answers: id });
if (personAnswer && ask.shout_answers !== null) {
diff --git a/test/api.test.js b/test/api.test.js
index 2e1085e7..fb7ed938 100644
--- a/test/api.test.js
+++ b/test/api.test.js
@@ -262,6 +262,25 @@ test('[A1] command results match the catalog across roots and subcommands', () =
TEMP_DIRS.push(dirname(tourRepo));
});
+test('[A1,B21,B27] a lane decision is answered by its agent through CLI JSON', () => {
+ const box = project();
+ const agent = join(box.dir, 'app-1');
+ box.git(box.repo, 'worktree', 'add', '-q', agent, '-b', 'app/one');
+ const joined = box.run(agent, 'join', 'app');
+ assert.equal(joined.status, 0, joined.stderr);
+
+ const ask = json(box, box.repo, 'shout', ['app', 'Should this endpoint retry?', '--decision']);
+ const answer = json(box, agent, 'answer', [String(ask.id), 'Retry once.']);
+ assert.equal(answer.answers, ask.id);
+ assert.ok(Number.isInteger(answer.id));
+
+ const delivered = json(box, box.repo, 'inbox').shouts.find(({ shout_id }) => shout_id === answer.id);
+ assert.ok(delivered, 'the original coordinator receives the lane answer');
+ assert.equal(delivered.shout_from, 'app-1');
+ assert.equal(delivered.shout_answers, ask.id);
+ assert.equal(delivered.shout_text, 'Retry once.');
+});
+
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 1b1030dd..7d9db4bb 100644
--- a/test/board.test.js
+++ b/test/board.test.js
@@ -320,6 +320,28 @@ test('a shout can ask for a decision; it stays open until someone answers it [B2
assert.equal(store.getShout(board, ask).shout_text, 'ship the page today or tomorrow?', 'an answer is a new shout; the ask is never edited');
});
+test('an agent answers its lane decision and the reply reaches the asker [B21,B27]', () => {
+ const lanes = ['coordinator', 'web', 'api'];
+ const ask = store.shout(board, { from: 'web-1', to: 'api', text: 'Should the endpoint retry?', lanes, decision: true });
+ const answer = store.answerDecision(board, ask, { agentId: 'api-1', text: 'Retry once.', lanes });
+ const reply = store.getShout(board, answer);
+ assert.equal(reply.shout_from, 'api-1', 'the responding agent is identified');
+ assert.equal(reply.shout_to, 'web-1', 'the answer goes to the original asker');
+ assert.equal(reply.shout_answers, ask, 'the reply closes the lane decision');
+ assert.equal(store.inbox(board, 'web-1').find(({ shout_id }) => shout_id === answer).shout_text, 'Retry once.');
+ assert.deepEqual(store.openDecisions(board, 'api'), []);
+});
+
+test('an agent cannot answer another lane decision [B21,B27]', () => {
+ const lanes = ['coordinator', 'web', 'api'];
+ const ask = store.shout(board, { from: 'web-1', to: 'api', text: 'Should the endpoint retry?', lanes, decision: true });
+ assert.throws(
+ () => store.answerDecision(board, ask, { agentId: 'web-2', text: 'Retry once.', lanes }),
+ /NOT_YOUR_DECISION.*api.*web/u,
+ );
+ assert.deepEqual(store.openDecisions(board, 'api').map(({ shout_id }) => shout_id), [ask]);
+});
+
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 });