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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(board): shouts ask for decisions and carry evidence [B21,B22]
Corey Olson74aebe59893d
diff --git a/docs/proof/shouts-mutants.mjs b/docs/proof/shouts-mutants.mjsnew file mode 100644index 00000000..65c2948e--- /dev/null+++ b/docs/proof/shouts-mutants.mjs@@ -0,0 +1,31 @@+/**+ * The proof that decision asks (B21) and typed evidence (B22) hold (item #60): each change below+ * breaks one part of them, and the tagged test must go red under it. The harness works on a+ * temporary copy, never a real checkout.+ *+ * Run it from the repo root: node docs/proof/shouts-mutants.mjs+ */+import { audit } from './harness.mjs';++const DECIDE = ['test/board.test.js', 'a shout can ask for a decision'];+const EVIDENCE = ['test/board.test.js', 'a shout can carry typed evidence'];+const CLI = ['test/e2e.test.js', 'decisions are asked, listed and answered'];+const STORED = '.run(from, to, text.trim(), now(board), decision ? 1 : 0, answers, evidence?.kind ?? null,';++/** Row, the change, its edits as [file, from, to], the test that judges it, and the outcome expected. */+const MUTANTS = [+ ['B21', 'an answer may name a shout that asked for nothing', [['src/board.js', 'if (answers !== null && !getShout(board, answers).shout_decision) {', 'if (false) {']], DECIDE, 'red'],+ ['B21', 'an answer never closes its ask', [['src/board.js', ' AND NOT EXISTS (SELECT 1 FROM shout reply WHERE reply.shout_answers = ask.shout_id)', '']], DECIDE, 'red'],+ ['B21', 'a decision ask is stored as a plain shout', [['src/board.js', STORED, STORED.replace('decision ? 1 : 0', '0')]], DECIDE, 'red'],+ ['B21', 'an answer is stored without its ask', [['src/board.js', STORED, STORED.replace('decision ? 1 : 0, answers,', 'decision ? 1 : 0, null,')]], DECIDE, 'red'],+ ['B21', 'pullboard answer shouts to all, not the asker', [['src/cli.js', 'to: ask.shout_from, text:', "to: 'all', text:"]], CLI, 'red'],+ ['B21', 'pullboard decisions lists nothing', [['src/cli.js', 'const asks = withBoard(ctx, (board) => store.openDecisions(board));', 'const asks = [];']], CLI, 'red'],+ ['B22', 'any kind of evidence passes', [['src/board.js', 'if (!EVIDENCE_KINDS.includes(kind)) throw', 'if (false) throw']], EVIDENCE, 'red'],+ ['B22', 'evidence may leave out its outcome', [['src/board.js', "if (!String(outcome ?? '').trim()) throw", 'if (false) throw']], EVIDENCE, 'red'],+ ['B22', 'evidence may name an item the board lacks', [['src/board.js', "if (!Number.isInteger(item) || !board.db.prepare('SELECT 1 FROM item WHERE item_id = ?').get(item)) {", 'if (false) {']], EVIDENCE, 'red'],+ ['B22', 'evidence may name any text as its commit', [['src/board.js', "if (!/^[0-9a-f]{40}$/.test(commit ?? '')) throw", 'if (false) throw']], EVIDENCE, 'red'],+ ['B22', 'the CLI passes on a commit it could not resolve', [['src/cli.js', 'if (resolved.status !== 0) throw', 'if (false) throw']], CLI, 'red'],+ ['B22', 'inbox hides the evidence', [['src/cli.js', 'if (shout.shout_evidence_kind) io.say(', 'if (false) io.say(']], CLI, 'red'],+];++audit(MUTANTS);diff --git a/src/board.js b/src/board.jsindex 8922caed..c758413d 100644--- a/src/board.js+++ b/src/board.js@@ -213,6 +213,12 @@ function migrate(db) {['item', 'item_files', "TEXT NOT NULL DEFAULT ''"],['item', 'item_review_by', 'TEXT'],['item', 'item_review_until', 'TEXT'],+ ['shout', 'shout_decision', 'INTEGER NOT NULL DEFAULT 0'],+ ['shout', 'shout_answers', 'INTEGER'],+ ['shout', 'shout_evidence_kind', 'TEXT'],+ ['shout', 'shout_evidence_outcome', 'TEXT'],+ ['shout', 'shout_evidence_item', 'INTEGER'],+ ['shout', 'shout_evidence_commit', 'TEXT'],];for (const [table, column, type] of added) {const columns = db.prepare(`PRAGMA table_info(${table})`).all().map((entry) => entry.name);@@ -1113,15 +1119,69 @@ export function verdictsFor(board, id) {* @param {any} board* @param {{ from: string, to: string, text: string, lanes: string[] }} message*/-export function shout(board, { from, to, text, lanes }) {+export function shout(board, { from, to, text, lanes, decision = false, answers = null, evidence = null }) {if (!text.trim()) throw new Refused('EMPTY_SHOUT', 'a shout needs text');const isAgent = board.db.prepare('SELECT 1 FROM agent WHERE agent_id = ?').get(to);if (to !== 'all' && !lanes.includes(to) && !isAgent) {throw new Refused('NO_READER', `nobody reads "${to}": name a lane, an agent or all`);}- board.db- .prepare('INSERT INTO shout (shout_from, shout_to, shout_text, shout_at) VALUES (?, ?, ?, ?)')- .run(from, to, text.trim(), now(board));+ if (answers !== null && !getShout(board, answers).shout_decision) {+ throw new Refused('NOT_A_DECISION', `shout #${answers} asked for no decision; reply with pullboard shout`);+ }+ if (evidence) checkEvidence(board, evidence);+ const result = board.db+ .prepare(+ `INSERT INTO shout (shout_from, shout_to, shout_text, shout_at, shout_decision, shout_answers,+ shout_evidence_kind, shout_evidence_outcome, shout_evidence_item, shout_evidence_commit)+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,+ )+ .run(from, to, text.trim(), now(board), decision ? 1 : 0, answers, evidence?.kind ?? null, evidence ? evidence.outcome.trim() : null, evidence?.item ?? null, evidence?.commit ?? null);+ return Number(result.lastInsertRowid);+}++/** The kinds of evidence a shout can carry (B22): what was tried, or what was measured. */+export const EVIDENCE_KINDS = ['attempt', 'receipt'];++/**+ * Refuse evidence that is not fields a reader can trust (B22): its kind, its outcome, an item on+ * the board, and a full commit SHA, which the CLI resolves in the repo before it gets here.+ *+ * @param {any} board+ * @param {{ kind: string, outcome: string, item: number, commit: string }} evidence+ */+function checkEvidence(board, { kind, outcome, item, commit }) {+ if (!EVIDENCE_KINDS.includes(kind)) throw new Refused('BAD_EVIDENCE', `the evidence kind is attempt or receipt, not "${kind ?? ''}": --evidence receipt`);+ if (!String(outcome ?? '').trim()) throw new Refused('BAD_EVIDENCE', 'evidence names its outcome: --outcome measured');+ if (!Number.isInteger(item) || !board.db.prepare('SELECT 1 FROM item WHERE item_id = ?').get(item)) {+ throw new Refused('BAD_EVIDENCE', `evidence names an item on the board: --item <id> (saw ${item})`);+ }+ if (!/^[0-9a-f]{40}$/.test(commit ?? '')) throw new Refused('BAD_EVIDENCE', `evidence names a commit by its full SHA (saw "${commit ?? ''}")`);+}++/**+ * One shout by its id.+ *+ * @param {any} board+ * @param {number} id+ * @returns {any}+ */+export function getShout(board, id) {+ const found = board.db.prepare('SELECT * FROM shout WHERE shout_id = ?').get(id);+ if (!found) throw new Refused('NO_SHOUT', `no shout #${id}`);+ return found;+}++/**+ * Shouts that asked for a decision nobody has answered yet, oldest first (B21). They stay here, and+ * in the person's Needs-you, until an answer names them; nothing ever edits the ask.+ *+ * @param {any} board+ * @returns {any[]}+ */+export function openDecisions(board) {+ return board.db+ .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();}/**diff --git a/src/cli.js b/src/cli.jsindex 60161b2c..f6084b85 100644--- a/src/cli.js+++ b/src/cli.js@@ -91,6 +91,10 @@ Workpullboard verify <id> reject --reason TEST_FAILURE --note "what failed"any --note can be --note-file <file>, which keeps quotes, $ and backticks intactpullboard shout <lane|agent|all> <text> pullboard inbox+ pullboard shout <to> <text> --decision ask for a decision; it stays open until answered+ pullboard shout <to> <text> --evidence attempt|receipt --outcome <word> --item <id> --commit <rev>+ pullboard answer <shout-id> <text> answer a shout that asked for a decision+ pullboard decisions shouts still waiting for a decisionCoordinatorpullboard sweep --run "<checker>" --check "<checker on {file}>" [--route light] [--max 20] [--dry-run]@@ -156,6 +160,11 @@ const OPTIONS = {must: { type: 'boolean' },json: { type: 'boolean' },history: { type: 'boolean' },+ decision: { type: 'boolean' },+ evidence: { type: 'string' },+ outcome: { type: 'string' },+ item: { type: 'string' },+ commit: { type: 'string' },help: { type: 'boolean', short: 'h' },version: { type: 'boolean', short: 'v' },};@@ -336,6 +345,30 @@ function whoAmI(ctx, board) {*/const freezer = (ctx) => (item) => frozenCriterion(loadSpec(ctx.info.root, ctx.config), item);+/**+ * The evidence a shout carries, from its flags (B22). The commit is resolved here, in this repo,+ * so the board only ever stores a full SHA that names a real commit.+ *+ * @param {any} ctx+ * @param {any} values+ * @returns {{ kind: string, outcome: string, item: number, commit: string }}+ */+function evidenceFrom(ctx, values) {+ const rev = values.commit ?? '';+ const resolved = rev ? tryGit(ctx.info.root, ['rev-parse', '--verify', '--quiet', `${rev}^{commit}`]) : { status: 1, stdout: '' };+ if (resolved.status !== 0) throw new Refused('BAD_EVIDENCE', `evidence names a commit in this repo: --commit <rev> (saw "${rev}")`);+ const item = /^\d+$/.test(values.item ?? '') ? Number(values.item) : NaN;+ return { kind: values.evidence, outcome: values.outcome ?? '', item, commit: resolved.stdout };+}++/**+ * A shout's evidence as one line: its kind, outcome, item and commit (B22).+ *+ * @param {any} shout+ * @returns {string}+ */+const evidenceLine = (shout) => `${shout.shout_evidence_kind}: ${shout.shout_evidence_outcome}, #${shout.shout_evidence_item} at ${shout.shout_evidence_commit.slice(0, 12)}`;+/** How many characters of an earlier verdict's note show prints (N30). */const NOTE_LINE = 120;@@ -737,7 +770,19 @@ function readCommands(io, { first, values }) {const ctx = context(io);const shouts = withBoard(ctx, (board) => store.inbox(board, whoAmI(ctx, board).id));if (!shouts.length) io.say('no new shouts');- shouts.forEach((shout) => io.say(`${shout.shout_at.slice(0, 16)} ${shout.shout_from} -> ${shout.shout_to}: ${shout.shout_text}`));+ for (const shout of shouts) {+ const ask = shout.shout_decision ? `asks for a decision (#${shout.shout_id}; pullboard answer ${shout.shout_id} "..."): ` : '';+ const reply = shout.shout_answers ? `answers #${shout.shout_answers}: ` : '';+ io.say(`${shout.shout_at.slice(0, 16)} ${shout.shout_from} -> ${shout.shout_to}: ${ask}${reply}${shout.shout_text}`);+ if (shout.shout_evidence_kind) io.say(` ${evidenceLine(shout)}`);+ }+ return 0;+ },+ decisions: () => {+ const ctx = context(io);+ const asks = withBoard(ctx, (board) => store.openDecisions(board));+ if (!asks.length) io.say('no open decisions');+ for (const ask of asks) io.say(`#${ask.shout_id} ${ask.shout_from} -> ${ask.shout_to}, ${span(ctx, ask.shout_at)} ago: ${firstLine(ask.shout_text)}`);return 0;},ledger: () => {@@ -1127,8 +1172,16 @@ function workCommands(io, args) {return 0;}),shout: () => act((ctx, board, me) => {- store.shout(board, { from: me.id, to: first ?? '', text: [second, ...rest].filter(Boolean).join(' '), lanes: laneNames(ctx.config) });- io.say(`shouted to ${first}`);+ const evidence = values.evidence === undefined ? null : evidenceFrom(ctx, values);+ const text = [second, ...rest].filter(Boolean).join(' ');+ const id = store.shout(board, { from: me.id, to: first ?? '', text, lanes: laneNames(ctx.config), decision: Boolean(values.decision), evidence });+ io.say(values.decision ? `asked ${first} for a decision as #${id}; it stays open until someone runs: pullboard answer ${id} "<the decision>"` : `shouted to ${first}`);+ return 0;+ }),+ answer: () => act((ctx, board, me) => {+ const ask = store.getShout(board, idArg(first));+ const id = store.shout(board, { from: me.id, to: ask.shout_from, text: [second, ...rest].filter(Boolean).join(' '), lanes: laneNames(ctx.config), answers: ask.shout_id });+ io.say(`answered #${ask.shout_id} to ${ask.shout_from} as #${id}`);return 0;}),};diff --git a/test/board.test.js b/test/board.test.jsindex 6bb8d430..a76f9bee 100644--- a/test/board.test.js+++ b/test/board.test.js@@ -193,6 +193,35 @@ test('shouts reach a lane, an agent or all; inbox marks them read [B7]', () => {assert.deepEqual(store.inbox(board, 'web-1').map((shout) => shout.shout_text), ['web: rebase']);});+test('a shout can ask for a decision; it stays open until someone answers it [B21]', () => {+ const lanes = ['coordinator', 'web', 'api'];+ const ask = store.shout(board, { from: 'web-1', to: 'coordinator', text: 'ship the page today or tomorrow?', lanes, decision: true });+ const note = store.shout(board, { from: 'web-1', to: 'coordinator', text: 'fyi: the gate is slow', lanes });+ assert.deepEqual(store.openDecisions(board).map((shout) => shout.shout_id), [ask]);+ assert.throws(() => store.shout(board, { from: 'coordinator', to: 'web-1', text: 'ok', lanes, answers: note }), /NOT_A_DECISION/);+ assert.throws(() => store.shout(board, { from: 'coordinator', to: 'web-1', text: 'ok', lanes, answers: 999 }), /NO_SHOUT/);+ assert.deepEqual(store.openDecisions(board).map((shout) => shout.shout_id), [ask], 'a refused answer leaves it open');+ const answer = store.shout(board, { from: 'coordinator', to: 'web-1', text: 'today', lanes, answers: ask });+ assert.deepEqual(store.openDecisions(board), []);+ assert.equal(store.getShout(board, answer).shout_answers, ask);+ 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('a shout can carry typed evidence: attempt or receipt, outcome, item and commit [B22]', () => {+ const lanes = ['coordinator', 'web', 'api'];+ const id = submitted();+ const evidence = { kind: 'receipt', outcome: 'measured', item: id, commit: SHA_A };+ const stored = store.getShout(board, store.shout(board, { from: 'web-2', to: 'coordinator', text: 'FINISH the page holds', lanes, evidence }));+ assert.deepEqual([stored.shout_evidence_kind, stored.shout_evidence_outcome, stored.shout_evidence_item, stored.shout_evidence_commit], ['receipt', 'measured', id, SHA_A]);+ const refused = (fields, field) =>+ assert.throws(() => store.shout(board, { from: 'web-2', to: 'coordinator', text: 'x', lanes, evidence: { ...evidence, ...fields } }), new RegExp(`BAD_EVIDENCE.*${field}`));+ refused({ kind: 'hunch' }, 'attempt or receipt');+ refused({ outcome: ' ' }, 'outcome');+ refused({ item: 999 }, 'an item on the board');+ refused({ commit: 'abc' }, 'full SHA');+ assert.equal(store.getShout(board, store.shout(board, { from: 'web-2', to: 'coordinator', text: 'no evidence', lanes })).shout_evidence_kind, null);+});+test('every move lands in the event log; stats count items and verdicts [R1, R2]', () => {const id = submitted();verdict(id, { agentId: 'web-2', decision: 'REJECT', reason: 'TEST_FAILURE', note: 'red' });diff --git a/test/e2e.test.js b/test/e2e.test.jsindex c4a5169f..1c9b46bf 100644--- a/test/e2e.test.js+++ b/test/e2e.test.js@@ -217,6 +217,25 @@ test('submit needs a clean tree, nothing untracked, and the gate green at HEAD [assert.equal(box.git(box.repo, 'rev-parse', `refs/pullboard/items/1/${head.slice(0, 12)}`), head, 'submit pins the commit');});+test('decisions are asked, listed and answered, and evidence attached, from the command line [B21, B22]', () => {+ const box = project();+ box.run(box.repo, 'add', 'web', 'Page', '--specs', 'G1');+ const asked = box.run(box.web, 'shout', 'coordinator', 'ship', 'today?', '--decision');+ assert.equal(asked.code, 0, asked.err);+ const id = /as #(\d+)/.exec(asked.out)?.[1];+ assert.ok(id, asked.out);+ assert.match(box.run(box.repo, 'decisions').out, new RegExp(`#${id} {2}web-1 -> coordinator, \\d+m ago: ship today\\?`));+ assert.match(box.run(box.repo, 'inbox').out, new RegExp(`web-1 -> coordinator: asks for a decision \\(#${id}; pullboard answer ${id}`));+ assert.match(box.run(box.repo, 'answer', id, 'yes, today').out, new RegExp(`answered #${id} to web-1 as #\\d+`));+ assert.match(box.run(box.repo, 'decisions').out, /no open decisions/);+ assert.match(box.run(box.web, 'inbox').out, new RegExp(`coordinator -> web-1: answers #${id}: yes, today`));+ const head = box.git(box.web, 'rev-parse', 'HEAD');+ const proved = box.run(box.web, 'shout', 'coordinator', 'FINISH', 'the page', '--evidence', 'receipt', '--outcome', 'measured', '--item', '1', '--commit', 'HEAD');+ assert.equal(proved.code, 0, proved.err);+ assert.match(box.run(box.repo, 'inbox').out, new RegExp(`web-1 -> coordinator: FINISH the page\\n {2}receipt: measured, #1 at ${head.slice(0, 12)}`));+ assert.match(box.run(box.web, 'shout', 'coordinator', 'x', '--evidence', 'receipt', '--outcome', 'measured', '--item', '1', '--commit', 'nope').err, /BAD_EVIDENCE.*"nope"/);+});+test('pullboard worktree makes a joined worktree for a lane in one command [I4]', () => {const box = project();const made = box.run(box.repo, 'worktree', 'api');