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.

fix(needs): share outstanding person calls across transports [N26,A9]

Corey Olsonbe9a2f27b086
diff --git a/src/cli.js b/src/cli.js
index 02971bbe..31600acf 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -39,6 +39,8 @@ export { HELP, VERSION };
import { productLine, productProblems, productSummaries } from './products.js';
import { isLane, laneNames, laneOf, outOfLane } from './lanes.js';
import { Refused } from './refused.js';
+import { personNeeds } from './needs.js';
+import { personNeedsState } from './needs-state.js';
import { commitCitations, committedIds } from './history.js';
import { promptFor, skillProblems, updateSkills } from './skills.js';
import {
@@ -1277,6 +1279,7 @@ function resumeHere(io) {
return {
me,
all,
+ needsYou: personNeeds(personNeedsState(root, { board })),
...(decisionSections ? { ...decisions, ...verifiedMergeGroups(root, toMerge, shouts, ctx.clock.now().getTime()),
flow: proofStats(board, { now: ctx.clock.now().getTime() }).flow } : {}),
requests: me.id === COORDINATOR ? store.openRequests(board) : [],
@@ -1374,7 +1377,9 @@ function resumeHere(io) {
say(`verified, not merged — conflicts: ${listed(groups.conflicts, ({ item, files }) => `#${item.item_id} ${firstLine(item.item_title)} (${files.join(', ') || 'files unavailable'})`)}`);
say(`verified, not merged — claimed for integration: ${listed(groups.integrating, ({ item, by, at, commit }) => `#${item.item_id} by ${name(by)} at ${at} (${commit.slice(0, 12)})`)}`);
}
- section(card.personQuestions, (ask) => `waiting on the person: #${ask.id} from ${name(ask.asker)} (${ask.age}): ${firstLine(ask.question)}`);
+ section(card.needsYou, (need) => need.kind === 'decision'
+ ? `waiting on the person: #${need.id} from ${need.ref} (${span(ctx, need.at)}): ${firstLine(need.text)}`
+ : `needs the person: ${need.ref}: ${firstLine(need.text)} (${need.what})`);
if (card.toVerify.length) say('review queue:');
section(card.toVerify, (item) => ` to verify: #${item.item_id} ${item.item_lane} (${span(ctx, item.item_updated_at)})`);
if (card.toMerge.length) say('merge verified work, run the gate, then record each with pullboard merged <id> <commit>');
diff --git a/src/mcp.js b/src/mcp.js
index 074c0ce7..cb8791ec 100644
--- a/src/mcp.js
+++ b/src/mcp.js
@@ -10,7 +10,8 @@ import { COORDINATOR } from './config.js';
import { VERSION } from './help.js';
import { refusalDocument } from './json.js';
import { Refused } from './refused.js';
-import { projectState } from './serve.js';
+import { personNeeds } from './needs.js';
+import { personNeedsState } from './needs-state.js';
/** MCP revisions this server speaks; the first is offered when a client asks for one it does not know. */
export const MCP_PROTOCOL_VERSIONS = Object.freeze(['2025-06-18', '2025-03-26', '2024-11-05']);
@@ -28,7 +29,7 @@ const PERSON_MOVE = /approv|declin|answer|sign_?off|decide|decision/u;
export const MCP_TOOLS = Object.freeze([
{
name: 'board_status',
- description: 'The board at a glance for this seat\'s agent: who you are, the open and active items, the review queue, unread shouts, and needsYou: the decisions and holds fields of the view\'s own board projection, as the view\'s Needs-you reads them; spec rows that need the person come with #702. Mirrors pullboard status and pullboard list. It builds the full board projection, so it is slower on large boards.',
+ description: 'The board at a glance for this seat\'s agent: who you are, the open and active items, the review queue, unread shouts, and needsYou: the shared list of open person decisions, undecided pending and draft spec rows, and lane holds. Mirrors pullboard status and pullboard list. It builds the full board projection, so it is slower on large boards.',
inputSchema: { type: 'object', properties: {}, additionalProperties: false },
},
{
@@ -150,14 +151,14 @@ async function callTool(runCommand, cwd, name, args) {
if (status.status) return toolResult(status.document, true);
const list = await runCli(runCommand, cwd, ['list', '--json']);
if (list.status) return toolResult(list.document, true);
- // Needs-you comes from the view's own projection, unshaped and read-only: one builder, no second query.
- const { decisions, holds } = projectState(cwd);
+ // Shared projection retains unapplied row decisions, so settled questions never return as needs.
+ const needsYou = personNeeds(personNeedsState(cwd));
const { version, ...summary } = status.document;
return toolResult({
version,
...summary,
items: list.document.items,
- needsYou: { decisions, holds },
+ needsYou,
}, false);
}
if (name === 'show_item') {
diff --git a/src/needs-state.js b/src/needs-state.js
new file mode 100644
index 00000000..3095adec
--- /dev/null
+++ b/src/needs-state.js
@@ -0,0 +1,17 @@
+/** Read the existing shared board projection with current unapplied person decisions [N26,A9]. */
+import { join } from 'node:path';
+import * as store from './board.js';
+import { repoInfo } from './git.js';
+import { projectRowDecisions } from './row-decisions.js';
+import { projectState } from './serve.js';
+
+/** Borrow an existing connection or open a read-only one; retain exact row-decision matching. */
+export function personNeedsState(root, { board: providedBoard = null } = {}) {
+ const info = repoInfo(root);
+ const board = providedBoard ?? { db: store.openBoardReadOnly(join(info.commonDir, 'pullboard', 'board.sqlite')) };
+ try {
+ return projectRowDecisions(store.rowDecisions(board), projectState(root, { board }));
+ } finally {
+ if (!providedBoard) store.closeBoard(board);
+ }
+}
diff --git a/src/needs.js b/src/needs.js
new file mode 100644
index 00000000..2ef2e38b
--- /dev/null
+++ b/src/needs.js
@@ -0,0 +1,20 @@
+/** The person's outstanding calls, shared with the browser as standalone source [N26,A9]. */
+export function personNeeds(state) {
+ /** Keep visible agent names identical to the page without depending on its runtime. */
+ const name = (id) => {
+ const agent = state.agents?.find(entry => entry.agent_id === id);
+ return agent?.displayName || (agent ? `${id} (${agent.model || agent.agent_model || 'unknown'})` : id);
+ };
+ const rows = (state.spec ?? []).filter(row => !row.decision);
+ const drafts = rows.filter(row => row.status === 'draft').length;
+ return [
+ ...(state.decisions ?? []).map(ask => ({ kind: 'decision', id: ask.shout_id,
+ ref: name(ask.shout_from), text: ask.shout_text, what: 'decision', at: ask.shout_at })),
+ ...rows.filter(row => row.status === 'pending').map(row => ({ kind: 'pending', id: row.id,
+ ref: row.id, text: row.text, what: 'answer in SPEC.md' })),
+ ...(state.holds ?? []).map(hold => ({ kind: 'hold', id: hold.hold_lane,
+ ref: hold.hold_lane, text: hold.hold_reason, what: 'lane held by ' + name(hold.hold_by) })),
+ ...(drafts ? [{ kind: 'draft', id: 'drafts', count: drafts, ref: String(drafts),
+ text: 'draft spec rows to approve or drop', what: 'review in SPEC.md', target: 'tab:spec' }] : []),
+ ];
+}
diff --git a/test/mcp.test.js b/test/mcp.test.js
index 56dc2499..2d111664 100644
--- a/test/mcp.test.js
+++ b/test/mcp.test.js
@@ -9,7 +9,8 @@ import { test } from 'node:test';
import { pathToFileURL } from 'node:url';
import { fixtureChildMessage, runFixtureChild, runFixtureGit, startFixtureChild } from './fixture-child.js';
import { AGENT_SHELL_MARKERS, SSH_SHELL_MARKERS } from '../src/person.js';
-import { projectState } from '../src/serve.js';
+import { personNeeds } from '../src/needs.js';
+import { personNeedsState } from '../src/needs-state.js';
const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
const SPEC = `# MCP fixture
@@ -234,13 +235,10 @@ test('[A9,P5] an MCP client reads the board and shouts as its agent', async (t)
assert.equal(status.structuredContent.version, 1);
assert.equal(status.structuredContent.me.id, box.agent, 'status reads as the seat\'s agent');
assert.ok(status.structuredContent.items.some((item) => item.item_id === itemId && item.item_status === 'open'), 'status lists the open item');
- assert.deepEqual(status.structuredContent.needsYou.decisions.map((ask) => ask.shout_id), [decisionId], 'Needs-you carries the person\'s open decision');
- // One builder: needsYou is the view's own projection, unshaped, never a query of the tool's own.
- // Spec rows that need the person come with #702, so needsYou carries decisions and holds only.
- assert.deepEqual(Object.keys(status.structuredContent.needsYou).sort(), ['decisions', 'holds'], 'needsYou carries no spec rows until #702');
- const projection = JSON.parse(JSON.stringify(projectState(box.web)));
- assert.deepEqual(status.structuredContent.needsYou, { decisions: projection.decisions, holds: projection.holds },
- 'needsYou is projectState\'s decisions and holds for the same board');
+ assert.deepEqual(status.structuredContent.needsYou.filter(need => need.kind === 'decision').map(need => need.id), [decisionId],
+ 'Needs-you carries the person\'s open decision');
+ assert.deepEqual(status.structuredContent.needsYou, personNeeds(personNeedsState(box.web)),
+ 'MCP uses the same person needs builder with current row decisions');
assert.deepEqual(JSON.parse(status.content[0].text), status.structuredContent, 'the text content is the same document');
const shown = await client.call('show_item', { id: itemId });
diff --git a/test/needs.test.js b/test/needs.test.js
new file mode 100644
index 00000000..a010fe89
--- /dev/null
+++ b/test/needs.test.js
@@ -0,0 +1,71 @@
+/** One person-facing obligation builder across sessions and transports [N26,A9]. */
+import assert from 'node:assert/strict';
+import { existsSync, readFileSync, writeFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { Readable } from 'node:stream';
+import { test } from 'node:test';
+import { runInNewContext } from 'node:vm';
+import { main } from '../src/cli.js';
+import { serveMcp } from '../src/mcp.js';
+import { createE2eHelpers } from './e2e-helpers.js';
+
+test('one builder lists what needs the person [N26,A9]', async (t) => {
+ const source = new URL('../src/needs.js', import.meta.url);
+ assert.ok(existsSync(source), 'the shared personNeeds builder exists');
+ const { personNeeds } = await import(source.href);
+ assert.equal(typeof personNeeds, 'function');
+ assert.doesNotMatch(readFileSync(source, 'utf8'), /^\s*import\b/mu, 'the browser builder has no imports');
+ const e2e = createE2eHelpers();
+ t.after(e2e.cleanup);
+ const box = e2e.project('true');
+ const spec = readFileSync(join(box.repo, 'SPEC.md'), 'utf8') + `
+- G3 [pending, aim] Which storage backend?
+- G4 [pending, aim] Keep the decided backend.
+- G5 [pending, aim] Do not resurrect the declined proposal.
+- G6 [draft, aim] Review the proposed retry policy.
+`;
+ writeFileSync(join(box.repo, 'SPEC.md'), spec);
+ box.git(box.repo, 'add', 'SPEC.md');
+ box.git(box.repo, 'commit', '-q', '-m', 'chore: describe person needs fixture');
+ // Copy only the fixture spec into its agent worktree; every decision stays on the shared real board.
+ writeFileSync(join(box.web, 'SPEC.md'), spec);
+ for (const args of [
+ ['spec', 'approve', 'G4'],
+ ['spec', 'decline', 'G5', '--reason', 'The person rejected this design.'],
+ ['shout', 'person', 'Which public interface should we keep?', '--decision'],
+ ['hold', 'web', '--reason', 'Await the interface decision.'],
+ ]) {
+ const result = box.run(box.repo, ...args);
+ assert.equal(result.code, 0, result.err || result.out);
+ }
+ // A real resume reads the same pending, unapplied decisions as the MCP tool.
+ const resumed = box.run(box.repo, 'resume', '--json');
+ assert.equal(resumed.code, 0, resumed.err || resumed.out);
+ const card = JSON.parse(resumed.out);
+ assert.ok(Array.isArray(card.needsYou), 'resume exposes the shared person needs list');
+ const expected = card.needsYou;
+ assert.deepEqual(expected.map(need => need.kind).sort(), ['decision', 'draft', 'hold', 'pending']);
+ assert.equal(expected.find(need => need.kind === 'pending').id, 'G3');
+ assert.equal(expected.find(need => need.kind === 'draft').count, 1);
+ assert.equal(expected.find(need => need.kind === 'hold').id, 'web');
+ assert.equal(expected.find(need => need.kind === 'decision').text, 'Which public interface should we keep?');
+ assert.ok(!expected.some(need => ['G4', 'G5'].includes(need.id)), 'approved and declined unapplied rows stay out');
+ const { personNeedsState } = await import('../src/needs-state.js');
+ const state = personNeedsState(box.repo);
+ assert.deepEqual(personNeeds(state), expected);
+ const before = JSON.stringify(state);
+ const browserBuilder = runInNewContext(`(${personNeeds.toString()})`);
+ assert.deepEqual(JSON.parse(JSON.stringify(browserBuilder(state))), expected,
+ 'the standalone source evaluates in an empty VM with no closure or imports');
+ assert.equal(JSON.stringify(state), before, 'the builder changes no input');
+ assert.deepEqual(personNeeds({}), [], 'an empty projection has no obligations');
+ const request = { jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'board_status', arguments: {} } };
+ let output = '';
+ let diagnostics = '';
+ const status = await serveMcp({ cwd: box.repo, input: Readable.from([JSON.stringify(request) + '\n']),
+ output: { write: text => { output += text; } }, log: { write: text => { diagnostics += text; } }, runCommand: main });
+ assert.equal(status, 0, diagnostics);
+ const reply = JSON.parse(output);
+ assert.equal(reply.result?.isError, false, JSON.stringify(reply));
+ assert.deepEqual(reply.result.structuredContent.needsYou, expected, 'MCP uses the same complete list');
+});