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
fix(spec): show the answer from signed text; bound choice parts [S1]
Corey Olson7b04db187a30
diff --git a/docs/api.md b/docs/api.mdindex b8114431..1c31d67f 100644--- a/docs/api.md+++ b/docs/api.md@@ -278,7 +278,7 @@ Decision moves keep the CLI's routing: `shout` with `args.decision: true` may omOnly the coordinator runs `spec apply`. It preflights every pending row against the exact source text, refusing stale decisions before writing any file. Approval changes the status to `approved`; decline changes it to `wont` with the person's reason as the row text, preserving trailing fields. SSH-enabled approvals carry one signed `row-decision` receipt binding the file, source, replacement, decision, reason and row text. Apply copies that same receipt into `.pullboard/signoffs.jsonl`; it remains a current exact-text sign-off. Commit the changed files and receipts together.-To answer a pending question row (`<ask>: <default>. Choices: a, b.`, as `blueprint add` writes it), the person runs `spec answer <id> "<choice or text>"`, or the local view sends `spec-answer` with `args: {row: "B1", answer: "Postgres"}`. A listed choice matches in any case and keeps its listed spelling; other text joins the choices last. It refuses agent shells, agent worktrees and the API channel, records the same exact-row approval receipt with an `answer` field, and the row leaves pending when the coordinator runs `spec apply`. `spec check` errors on a question that was pending at the trunk tip and now differs with no matching person decision.+To answer a pending question row (`<ask>: <default>. Choices: a, b.`, as `blueprint add` writes it), the person runs `spec answer <id> "<choice or text>"`, or the local view sends `spec-answer` with `args: {row: "B1", answer: "Postgres"}`. A listed choice matches in any case and keeps its listed spelling; other text joins the choices last. It refuses agent shells, agent worktrees and the API channel, records the same exact-row approval receipt, whose JSON `decisions` carry an `answer` read back from the signed text (never stored on its own), and the row leaves pending when the coordinator runs `spec apply`. `spec check` errors on a question that was pending at the trunk tip and now differs with no matching person decision.To approve new wording, the person uses `spec approve <one-id> --text "exact proposed text"`, or `spec-approve` with `args: {ids: "G1", text: "exact proposed text"}`. This records the same exact-row receipt; files wait for coordinator apply. Text must be one nonempty line without a field separator. Pre-commit checks the staged row against that person decision or a verified staged SSH sign-off; unstaged receipts cannot authorize a commit.diff --git a/src/blueprints.js b/src/blueprints.jsindex d4f75646..96452ad6 100644--- a/src/blueprints.js+++ b/src/blueprints.js@@ -427,6 +427,11 @@ export function answerQuestion(text, given, id) {const head = text.slice(0, at);const choicesText = text.slice(at + CHOICES.length, -1);const parts = choicesText.split(', ');+ // The same bound readQuestion keeps, so the runs of parts below stay a small, fixed amount of work.+ if (parts.length > MOST_CHOICE_PARTS) {+ throw new Refused('SPEC_ANSWER_CHOICES', `${id} lists ${parts.length} choice parts, more than the ${MOST_CHOICE_PARTS} an answer can read`,+ `the person approves its exact answered text instead: pullboard spec approve ${id} --text "<ask>: <answer>. Choices: <choices>."`);+ }const runs = parts.flatMap((_, from) => parts.slice(from).map((__, length) => parts.slice(from, from + length + 1).join(', ')));const colons = positions(head, ': ');const listedSplits = colons.filter((colon) => runs.includes(head.slice(colon + 2)));@@ -439,6 +444,32 @@ export function answerQuestion(text, given, id) {return { text: `${ask}: ${chosen}${CHOICES}${listed ? choicesText : `${choicesText}, ${answer}`}.`, answer: chosen, listed: Boolean(listed) };}+/**+ * The answer an answered row's text carries, read back from the text alone: the one answer that+ * answerQuestion turns the pending row's text into exactly this answered text, or null when there+ * is none. Spec show and the view display this, because the source and the answered text are what+ * a row decision signs; nothing else a record carries is trusted for display [S1,S19].+ *+ * @param {string} pending - The pending row's text before the answer.+ * @param {string} answered - The decision's signed text.+ * @returns {string | null}+ */+export function answerFromText(pending, answered) {+ const at = answered.lastIndexOf(CHOICES);+ if (at < 0) return null;+ const head = answered.slice(0, at);+ for (const colon of positions(head, ': ')) {+ try {+ const read = answerQuestion(pending, head.slice(colon + 2), 'row');+ if (read.text === answered) return read.answer;+ } catch (error) {+ if (!(error instanceof Refused)) throw error;+ // This split of the answered text is no answer to the pending row; try the next one.+ }+ }+ return null;+}+/*** Name why a piece of text may not leave this board, or return null when it may. Text that holds* a path, an email or any private name (a person, an agent, a model label or a machine) stays.diff --git a/src/cli.js b/src/cli.jsindex ce2a14c8..77c3ff22 100644--- a/src/cli.js+++ b/src/cli.js@@ -17,7 +17,7 @@ import { doctrineHistory, loadDoctrine } from './doctrine.js';import { checkRulesAt, doctrineReport, hasSubmitRules, holdDoctrine, ruleLine } from './doctrine-checks.js';import { agentSessionDigest, requirePersonChannel } from './person.js';import { bindLocalSession, localSessionMatches } from './agent-session.js';-import { decisionProjection, handAnsweredQuestions, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';+import { decisionAnswer, decisionProjection, handAnsweredQuestions, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';import { digestOf, gateReport, refuseSandboxBlocked, runGate, runProfiledShell, runSubmitGate, submitGateReport, timingDigest, withGateSlot } from './gate.js';import { checkNeedsBrowser } from './browser-admission.js';import { bareWorktreeFinding, codeIsFromMain, contains, differFromHead, git, gitChildEnv, headCommit, headTree, invalidateGitFacts, isClean, mainCheckout, patchId, repoInfo, resolveCommit, tryGit, untracked, withGitFacts } from './git.js';@@ -3332,11 +3332,13 @@ async function specCommand(io, { first, second, rest, values }) {const row = spec.rows.find((entry) => entry.id === second);if (!row) throw new Refused('NO_ROW', `${second} is not a row in ${ctx.config.spec}`, 'list the pending questions with pullboard spec --json, then answer one of them');if (row.status !== 'pending') throw new Refused('SPEC_ANSWER', `${second} is ${row.status}, not a pending question`, `read it with pullboard spec show ${second}; only a pending row takes an answer`);- const { text, answer } = answerQuestion(row.text, given, second);- const records = prepareRowDecisions(ctx.info.root, ctx.config, { ids: [second], decision: 'approve', text, answer, on: new Date().toISOString(), commit: headCommit(ctx.info.root) ?? '' });+ const { text } = answerQuestion(row.text, given, second);+ const records = prepareRowDecisions(ctx.info.root, ctx.config, { ids: [second], decision: 'approve', text, on: new Date().toISOString(), commit: headCommit(ctx.info.root) ?? '' });const decisions = await ordered(ctx, board, 'recordRowDecisions', [{ agentId: store.PERSON, channel: io.personChannel ?? 'terminal', decisions: records }]);- io.result?.({ decisions });- decisions.forEach((record) => io.say(`${record.id}: answered ${record.answer}, pending apply`));+ // The answer reported is read back from the signed text, never carried as a field of its own.+ const answered = decisions.map((record) => ({ ...record, answer: decisionAnswer(record) }));+ io.result?.({ decisions: answered });+ answered.forEach((record) => io.say(`${record.id}: answered ${record.answer}, pending apply`));return 0;});}diff --git a/src/next-steps.js b/src/next-steps.jsindex 8512d651..2ca1476d 100644--- a/src/next-steps.js+++ b/src/next-steps.js@@ -343,6 +343,7 @@ export const NEXT_STEPS = Object.freeze({SHOUT_NOT_AVAILABLE: 'read shouts with pullboard inbox, or refresh the snapshot with a current CLI',SNAPSHOT_FORMAT: 'refresh the snapshot from a linked machine: pullboard relay',SPEC_ANSWER: 'read the row with pullboard spec show <id>; the person answers a pending question with pullboard spec answer <id> "<choice or text>"',+ SPEC_ANSWER_CHOICES: 'the person approves the exact answered text instead: pullboard spec approve <id> --text "<ask>: <answer>. Choices: <choices>."',SPEC_BEHIND_MAIN: 'git merge main',SPEC_INVALID: 'fix the unparsed row the message names, then pullboard spec check',SPEC_SECTION: 'name a section the spec has; see pullboard spec',diff --git a/src/row-decisions.js b/src/row-decisions.jsindex a3b4a147..3357325c 100644--- a/src/row-decisions.js+++ b/src/row-decisions.js@@ -2,7 +2,8 @@import { appendFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { dirname, join } from 'node:path';import { loadDoctrine } from './doctrine.js';-import { loadSpec, SIGNOFFS_FILE } from './spec.js';+import { answerFromText } from './blueprints.js';+import { loadSpec, parseSpec, SIGNOFFS_FILE } from './spec.js';import { defaultPrincipal, hasSignerFile, signRowDecision, verifyRowDecision } from './signature.js';import { Refused } from './refused.js';@@ -24,10 +25,10 @@ function decisionRows(root, config, ids) {/*** Capture all source text and signatures before recording any decision on the board. An answer to- * a pending question is an approval of its answered text that also carries the answer, signed with- * the rest of the record, so spec show and the view can say what the person chose.+ * a pending question is an approval of its answered text and carries no separate answer field: the+ * answer shown is read back from the signed source and text by decisionAnswer.*/-export function prepareRowDecisions(root, config, { ids, decision, reason = '', text: proposedText, answer, by, on, commit = '' }) {+export function prepareRowDecisions(root, config, { ids, decision, reason = '', text: proposedText, by, on, commit = '' }) {if (!ids.length) throw new Refused('USAGE', 'name rows: pullboard spec approve <ids> or spec decline <ids> --reason "why"');if (!['approve', 'decline'].includes(decision)) throw new Refused('ROW_DECISION', 'use pullboard spec approve or decline');if (decision === 'decline' && (!reason.trim() || /[\r\n|]/u.test(reason))) throw new Refused('ROW_DECISION', 'a decline needs a one-line reason without a field separator; use --reason "why"');@@ -39,8 +40,7 @@ export function prepareRowDecisions(root, config, { ids, decision, reason = '',const text = decision === 'approve' ? proposedText?.trim() ?? row.text : row.text;const replacement = source.replace(/\[([a-z]+)(,\s*[a-z]+)?\]/u, (_, old, tier = '') => `[${status}${tier}]`).replace(/(\]\s+)([^|]*)(?=\s*\||$)/u, (_, prefix, old) => `${prefix}${text}${old.match(/\s+$/u)?.[0] ?? ''}`);- const record = { version: 1, type: 'row-decision', kind, file, id: row.id, source, replacement, text, decision, reason: decision === 'decline' ? reason.trim() : '', by: principal, on, commit, note: '',- ...(answer !== undefined ? { answer } : {}) };+ const record = { version: 1, type: 'row-decision', kind, file, id: row.id, source, replacement, text, decision, reason: decision === 'decline' ? reason.trim() : '', by: principal, on, commit, note: '' };return signed ? signRowDecision(root, record) : record;});}@@ -51,13 +51,33 @@ export function pendingRowDecision(records, row, kind) {&& (row.text === record.text || row.text === record.source.match(/\]\s+([^|]*)(?:\||$)/u)?.[1]?.trim()));}+/**+ * The answer a decision gives a pending question, read back from the signed source row and the+ * signed text, or null for any other decision. A record's other fields, such as an unsigned+ * "answer" written into the board by hand, are never read [S19,P6].+ *+ * @param {any} record+ * @returns {string | null}+ */+export function decisionAnswer(record) {+ if (record.decision !== 'approve' || record.kind !== 'spec') return null;+ const [pending] = parseSpec(`## Decision\n${record.source}\n`).rows;+ return pending?.status === 'pending' ? answerFromText(pending.text, record.text) : null;+}++/** Name a pending decision: the answer it gives, or approved or declined. */+function decisionStage(record) {+ const answer = decisionAnswer(record);+ return answer !== null ? `answered ${answer}` : record.decision === 'approve' ? 'approved' : 'declined';+}+/** Add pending status to existing rows without replacing their current file-backed status. */export function decisionProjection(records, row, kind) {const decision = pendingRowDecision(records, row, kind);if (decision) return {...row,decision,- stage: `${decision.answer !== undefined ? `answered ${decision.answer}` : decision.decision === 'approve' ? 'approved' : 'declined'}, pending apply`,+ stage: `${decisionStage(decision)}, pending apply`,...(decision.decision === 'decline' ? { reason: decision.reason } : {}),};const appliedDecline = records.find((record) => record.kind === kind && record.id === row.id && record.applieddiff --git a/test/spec.test.js b/test/spec.test.jsindex 757e0a23..e3dc5785 100644--- a/test/spec.test.js+++ b/test/spec.test.js@@ -503,13 +503,14 @@ test('a drafted row reads as draft [S1,C7]', (t) => {], 'both an existing pending question and a newly drafted row remain approvable');});-/** Four blueprint questions as blueprint add writes them: the default answer, then every choice. */+/** Blueprint questions as blueprint add writes them: the default answer, then every choice; B5 lists 13 parts. */const QUESTION_SPEC = `${SPEC}## B · Blueprint- B1 [pending, must] Which store holds the data: SQLite. Choices: SQLite, Postgres. | gate: review- B2 [pending, must] Which store holds the cache: SQLite. Choices: SQLite, Postgres. | gate: review- B3 [pending, must] Which store holds the logs: SQLite. Choices: SQLite, Postgres. | gate: review- B4 [pending, must] Which store holds the files: SQLite. Choices: SQLite, Postgres. | gate: review+- B5 [pending, must] Which region hosts it: r1. Choices: r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13. | gate: review`;/** Run one CLI command in a box with an environment of the test's choosing. */@@ -554,6 +555,22 @@ test("spec answer records the person's choice [S1,E3,P6]", (t) => {assert.equal(record.by, 'person');assert.equal(readFileSync(file, 'utf8'), before, 'the answer waits for the coordinator apply, as an approval does');assert.match(box.run('show', 'B1').stdout, /answered Postgres, pending apply/u);+ const board = new DatabaseSync(join(box.root, '.git', 'pullboard', 'board.sqlite'));+ try {+ const stored = JSON.parse(board.prepare("SELECT meta_value FROM board_meta WHERE meta_key='row_decisions'").get().meta_value);+ board.prepare("UPDATE board_meta SET meta_value=? WHERE meta_key='row_decisions'")+ .run(JSON.stringify(stored.map((entry) => (entry.id === 'B1' ? { ...entry, answer: 'Tampered' } : entry))));+ } finally { board.close(); }+ const tampered = box.run('show', 'B1');+ assert.match(tampered.stdout, /answered Postgres, pending apply/u, 'the answer shown is read back from the signed text');+ assert.doesNotMatch(tampered.stdout, /Tampered/u, 'an unsigned answer field never changes what is shown');++ const oversized = box.run('answer', 'B5', 'r2', '--json');+ assert.equal(oversized.status, 1, oversized.stdout + oversized.stderr);+ const bound = JSON.parse(oversized.stdout).error;+ assert.equal(bound.code, 'SPEC_ANSWER_CHOICES', 'more than 12 choice parts is refused by name');+ assert.match(bound.message, /B5 lists 13 choice parts, more than the 12/u);+ assert.match(bound.next, /pullboard spec approve B5 --text/u);const free = box.run('answer', 'B2', 'Redis on the host');assert.equal(free.status, 0, free.stdout + free.stderr);