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(spec): spec answer records the person's choice, in progress [S1,E3]
Corey Olsone1b7311e5c59
diff --git a/src/api-moves.js b/src/api-moves.jsindex 51dc394c..efc7f29c 100644--- a/src/api-moves.js+++ b/src/api-moves.js@@ -5,6 +5,7 @@ import { Refused } from './refused.js';const MOVES = {'spec-approve': { prefix: ['spec', 'approve'], positions: ['ids'], flags: ['by', 'text'] },'spec-decline': { prefix: ['spec', 'decline'], positions: ['ids'], flags: ['reason'] },+ 'spec-answer': { prefix: ['spec', 'answer'], positions: ['row', 'answer'] },add: { positions: ['lane', 'title'], flags: ['criterion', 'specs', 'parent', 'after', 'brief', 'route', 'check'], booleans: ['wait'], booleans: ['wait'] },edit: { item: true, flags: ['criterion', 'brief', 'route', 'check'], booleans: ['wait'], booleans: ['wait'] },fact: { item: true, positions: ['kind', 'text'], flags: ['supersedes', 'ref'] },diff --git a/src/blueprints.js b/src/blueprints.jsindex 184a0efd..233c426c 100644--- a/src/blueprints.js+++ b/src/blueprints.js@@ -407,6 +407,35 @@ function readQuestion(text) {return { reason: readings.size ? 'its question can be read more than one way' : 'its answer is not one of its choices, or its choices cannot be read back exactly' };}+/**+ * A question row's text once the person answers it: "<ask>: <answer>. Choices: <choices>.". A+ * listed choice matches in any case and keeps its listed spelling; any other answer joins the+ * choices last, so blueprint save still reads the answered row back as a question [S1].+ *+ * @param {string} text - The pending row's text, as questionText wrote it.+ * @param {string} given - The person's answer: one of the choices, or their own one-line text.+ * @param {string} id - The row id, for the refusal's next step.+ * @returns {{ text: string, answer: string, listed: boolean }}+ */+export function answerQuestion(text, given, id) {+ const read = readQuestion(text);+ if (!read?.question) {+ throw new Refused('SPEC_ANSWER', `${id} does not read as one question with its choices (${read?.reason ?? 'it has no ". Choices: " list'})`,+ `the person approves its exact new text instead: pullboard spec approve ${id} --text "<the answered row>"`);+ }+ const { ask, choices } = read.question;+ const answer = given.trim();+ const listed = choices.find((choice) => choice.toLowerCase() === answer.toLowerCase());+ const question = listed ? { ask, choices, default: listed } : { ask, choices: [...choices, answer], default: answer };+ const answered = questionText(question);+ const back = readQuestion(answered)?.question;+ if (!back || back.default !== question.default || back.choices.join('\n') !== question.choices.join('\n')) {+ throw new Refused('SPEC_ANSWER', `"${answer}" cannot be read back as ${id}'s one answer`,+ `give the answer without ", " or ": ": pullboard spec answer ${id} "<answer>"`);+ }+ return { text: answered, answer: question.default, listed: Boolean(listed) };+}+/*** 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 950ef125..d46889be 100644--- a/src/cli.js+++ b/src/cli.js@@ -16,7 +16,7 @@ import { displayAgentName } from './agent-names.js';import { doctrineHistory, loadDoctrine } from './doctrine.js';import { agentSessionDigest, requirePersonChannel } from './person.js';import { bindLocalSession, localSessionMatches } from './agent-session.js';-import { decisionProjection, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';+import { decisionProjection, handAnsweredQuestions, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';import { digestOf, gateReport, 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';@@ -58,7 +58,7 @@ import {standings,unmetRows,} from './spec.js';-import { bundledBlueprints, planBlueprint, readBlueprint, saveBlueprint } from './blueprints.js';+import { answerQuestion, bundledBlueprints, planBlueprint, readBlueprint, saveBlueprint } from './blueprints.js';import { briefFiles } from './brief.js';import { checkBaseline, prepareCheckBaseline, sayCheckBaseline } from './check-baseline.js';import { retryCheckBaselines, startCheckBaseline } from './check-baseline-worker.js';@@ -188,6 +188,7 @@ function commandHelp(name) {' pullboard spec signers add — person: register an SSH signing key',' pullboard spec approve <ids> — person: decide from their own terminal or Pullboard View',' pullboard spec decline <ids> — person: decide from their own terminal or Pullboard View',+ ' pullboard spec answer <id> "<choice or text>" — person: answer a pending question from their own terminal or Pullboard View',' pullboard spec apply — coordinator: apply recorded row decisions to the files',] : []),'Example:',@@ -3149,9 +3150,10 @@ async function specCommand(io, { first, second, rest, values }) {draft: ['aim', 'gate', 'section'],approve: ['by', 'text'],decline: ['reason'],+ answer: [],apply: [],}[first ?? '--json'];- if (!commandFlags) throw new Refused('USAGE', 'use pullboard spec --json | check | view | show <id> | unmet [--must] | draft "<text>" | signoff <ids> | approve <ids> | decline <ids> --reason "why" | apply');+ if (!commandFlags) throw new Refused('USAGE', 'use pullboard spec --json | check | view | show <id> | unmet [--must] | draft "<text>" | signoff <ids> | approve <ids> | decline <ids> --reason "why" | answer <id> "<choice or text>" | apply');const allowedFlags = [...new Set([...commandFlags, 'json'])];for (const flag of Object.keys(values)) {if (!allowedFlags.includes(flag)) {@@ -3208,6 +3210,24 @@ async function specCommand(io, { first, second, rest, values }) {return 0;});}+ if (first === 'answer') {+ requirePersonChannel(io.personChannel);+ return withBoard(ctx, async (board) => {+ const me = whoAmI(ctx, board);+ if (!ctx.info.isMain || me.id !== COORDINATOR) throw new Refused('B26_PERSON_APPROVAL', 'only the person answers a pending question, from the main checkout or the view', 'ask the person to answer it in pullboard view, or in their own terminal at the main checkout');+ const given = rest.join(' ').trim();+ if (!second || !given || /[\r\n|]/u.test(given)) throw new Refused('USAGE', 'give one row and a one-line answer without a field separator: pullboard spec answer <id> "<choice or text>"');+ 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 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`));+ return 0;+ });+ }if (first === 'apply') {if (second || rest.length) throw new Refused('USAGE', 'pullboard spec apply takes no ids; it applies current person decisions');return withBoard(ctx, async (board) => {@@ -3233,6 +3253,7 @@ async function specCommand(io, { first, second, rest, values }) {? legacyDoctrineRenameBase(ctx.info.root, DOCTRINE_FILE): null;const baselineNotes = new Set();+ const previousSources = new Map();const previousCounts = new Map(collisionFiles.map(([name]) => {const baselineName = renameBase && name === DOCTRINE_FILE ? LEGACY_DOCTRINE_FILE : name;const previous = name === DOCTRINE_FILE && !renameBase@@ -3240,6 +3261,7 @@ async function specCommand(io, { first, second, rest, values }) {: coordinatorFile(ctx.info.root, baselineName, renameBase ?? undefined);if (previous.baseline) baselineNotes.add(previous.baseline);const rows = previous.status === 0 ? parseSpec(previous.stdout, { strictGrammarVersion: false }).rows : [];+ previousSources.set(name, rows);const counts = new Map();for (const row of rows) counts.set(row.id, (counts.get(row.id) ?? 0) + 1);return [name, counts];@@ -3278,6 +3300,10 @@ async function specCommand(io, { first, second, rest, values }) {const history = parsed === practice ? doctrineHistory(ctx.info.root, name) : committedIds(ctx.info.root, name);const cited = name === ctx.config.spec ? citations(ctx, history) : new Map();const lost = permanenceProblems(parsed === practice ? practice.repo : parsed, { committed: history.ids, cited });+ if (name === ctx.config.spec) {+ const answered = handAnsweredQuestions(previousSources.get(name) ?? [], parsed.rows, () => hookRead(ctx, (board) => store.rowDecisions(board)) ?? []);+ lost.push(...answered.map((id) => ({ id, message: `pending question answered by hand; ask the person to run pullboard spec answer ${id} "<choice or text>" and restore the pending row` })));+ }lost.forEach((problem) => messages.push(`${name}: ${problem.id} error: ${problem.message}`));const fileErrors = findings.filter((finding) => finding.level === 'error').length + lost.length;errors += fileErrors;@@ -3375,7 +3401,7 @@ async function specCommand(io, { first, second, rest, values }) {io.say(`signed ${count} rows as ${by}; commit .pullboard/signoffs.jsonl`);return 0;}- throw new Refused('USAGE', 'pullboard spec --json | check | view | show <id> | unmet [--must] | draft "<text>" | signoff <ids> | signers add | approve <ids> | decline <ids> --reason "why" | apply');+ throw new Refused('USAGE', 'pullboard spec --json | check | view | show <id> | unmet [--must] | draft "<text>" | signoff <ids> | signers add | approve <ids> | decline <ids> --reason "why" | answer <id> "<choice or text>" | apply');}/** Read one consent line without waiting for EOF in an interactive terminal [V2]. */diff --git a/src/next-steps.js b/src/next-steps.jsindex d8afe8fe..8512d651 100644--- a/src/next-steps.js+++ b/src/next-steps.js@@ -342,6 +342,7 @@ export const NEXT_STEPS = Object.freeze({SHALLOW_BEFORE_OPT_IN: 'git fetch --unshallow, then pullboard spec signers add',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_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 c96b5e00..a3b4a147 100644--- a/src/row-decisions.js+++ b/src/row-decisions.js@@ -22,8 +22,12 @@ function decisionRows(root, config, ids) {});}-/** Capture all source text and signatures before recording any decision on the board. */-export function prepareRowDecisions(root, config, { ids, decision, reason = '', text: proposedText, by, on, commit = '' }) {+/**+ * 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.+ */+export function prepareRowDecisions(root, config, { ids, decision, reason = '', text: proposedText, answer, 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"');@@ -35,7 +39,8 @@ 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: '' };+ 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 } : {}) };return signed ? signRowDecision(root, record) : record;});}@@ -52,7 +57,7 @@ export function decisionProjection(records, row, kind) {if (decision) return {...row,decision,- stage: `${decision.decision === 'approve' ? 'approved' : 'declined'}, pending apply`,+ stage: `${decision.answer !== undefined ? `answered ${decision.answer}` : decision.decision === 'approve' ? 'approved' : 'declined'}, pending apply`,...(decision.decision === 'decline' ? { reason: decision.reason } : {}),};const appliedDecline = records.find((record) => record.kind === kind && record.id === row.id && record.applied@@ -68,6 +73,28 @@ export function projectRowDecisions(records, state) {};}+/**+ * The ids of blueprint questions answered by a hand edit to SPEC.md: a row that was pending with+ * its ". Choices: " list at the trunk tip and now differs in status or text, with no person row+ * decision for that exact status and text. The answer is the person's move alone (P6), so an+ * agent that edits the row instead is caught by spec check, the gate's first step.+ *+ * @param {any[]} before - The trunk tip's parsed SPEC.md rows.+ * @param {any[]} after - The working file's parsed rows.+ * @param {() => any[]} readDecisions - The board's row decisions, read only when a question changed.+ * @returns {string[]}+ */+export function handAnsweredQuestions(before, after, readDecisions) {+ const changed = before.filter((old) => old.status === 'pending' && old.text.includes('. Choices: ')).flatMap((old) => {+ const now = after.filter((row) => row.id === old.id);+ return now.length === 1 && (now[0].status !== old.status || now[0].text !== old.text) ? [now[0]] : [];+ });+ if (!changed.length) return [];+ const records = readDecisions();+ return changed.filter((row) => !records.some((record) => record.kind === 'spec' && record.id === row.id+ && record.text === row.text && row.status === (record.decision === 'approve' ? 'approved' : 'wont'))).map((row) => row.id);+}+/** Remove local index metadata while retaining the one canonical person receipt verbatim. */function decisionReceipt({ event, at, applied, appliedAt, ...record }) { return record; }diff --git a/test/spec.test.js b/test/spec.test.jsindex cf520e20..2b58145e 100644--- a/test/spec.test.js+++ b/test/spec.test.js@@ -6,9 +6,12 @@ import { runFixtureExecFile as execFileSync, runFixtureChild as spawnSync, runFiimport { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';+import { DatabaseSync } from 'node:sqlite';+import { pathToFileURL } from 'node:url';import { test } from 'node:test';import { standardDoctrine } from '../src/doctrine.js';import { AGENT_SHELL_MARKERS, SSH_SHELL_MARKERS } from '../src/person.js';+import { RECORDED_GENERIC_NEXT } from '../src/recorded-refusal.js';import {citedIds,deletedIds,@@ -500,6 +503,141 @@ 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. */+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+`;++/** Run one CLI command in a box with an environment of the test's choosing. */+function runIn(box, cwd, args, env = box.env) {+ return runFixtureChild(process.execPath, [resolve(import.meta.dirname, '../bin/pullboard.js'), ...args], { cwd, env, encoding: 'utf8' });+}++/** Send one move through the view's own API adapter, executeMove, on the channel named. */+function viewMove(box, move, channel, env) {+ const apiModule = pathToFileURL(resolve(import.meta.dirname, '../src/api.js')).href;+ const cliModule = pathToFileURL(resolve(import.meta.dirname, '../src/cli.js')).href;+ const source = `+ const { executeMove } = await import(${JSON.stringify(apiModule)});+ const { main } = await import(${JSON.stringify(cliModule)});+ const response = await executeMove(process.cwd(), ${JSON.stringify(move)}, main, undefined, ${JSON.stringify(channel)});+ process.stdout.write(JSON.stringify(response));+ `;+ const child = runFixtureChild(process.execPath, ['--input-type=module', '-e', source], { cwd: box.root, env, encoding: 'utf8' });+ assert.equal(child.status, 0, child.stdout + child.stderr);+ return JSON.parse(child.stdout);+}++/** The board's person row decisions, read without opening its migrator. */+function boardRowDecisions(box) {+ const db = new DatabaseSync(join(box.root, '.git', 'pullboard', 'board.sqlite'), { readOnly: true });+ try { return db.prepare("SELECT meta_value FROM board_meta WHERE meta_key='row_decisions'").get()?.meta_value ?? '[]'; }+ finally { db.close(); }+}++test("spec answer records the person's choice [S1,E3,P6]", (t) => {+ const box = specBox(t, { specSource: QUESTION_SPEC });+ const file = join(box.root, box.specName);+ const line = (id) => readFileSync(file, 'utf8').split('\n').find((text) => text.startsWith(`- ${id} `));+ const before = readFileSync(file, 'utf8');++ const listed = box.run('answer', 'B1', 'postgres', '--json');+ assert.equal(listed.status, 0, listed.stdout + listed.stderr);+ const [record] = JSON.parse(listed.stdout).decisions;+ assert.deepEqual([record.id, record.decision, record.answer, record.text],+ ['B1', 'approve', 'Postgres', 'Which store holds the data: Postgres. Choices: SQLite, Postgres.'],+ 'a listed choice matches in any case and keeps its listed spelling');+ 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 free = box.run('answer', 'B2', 'Redis on the host');+ assert.equal(free.status, 0, free.stdout + free.stderr);+ assert.match(free.stdout, /^B2: answered Redis on the host, pending apply$/mu);++ const applied = box.run('apply');+ assert.equal(applied.status, 0, applied.stdout + applied.stderr);+ assert.equal(line('B1'), '- B1 [approved, must] Which store holds the data: Postgres. Choices: SQLite, Postgres. | gate: review',+ 'the row leaves pending with the chosen answer');+ assert.equal(line('B2'), '- B2 [approved, must] Which store holds the cache: Redis on the host. Choices: SQLite, Postgres, Redis on the host. | gate: review',+ 'an answer outside the choices joins them, so blueprint save still reads the row back');++ const view = viewMove(box, { verb: 'spec-answer', args: { row: 'B3', answer: 'SQLite' } }, 'view', { ...box.env, CLAUDECODE: '1' });+ assert.equal(view.status, 200, JSON.stringify(view));+ assert.equal(view.body.event.event_by, 'person');+ assert.equal(JSON.parse(view.body.event.event_detail).channel, 'view');+ assert.equal(view.body.result.decisions[0].answer, 'SQLite');+ assert.equal(box.run('apply').status, 0);+ assert.equal(line('B3'), '- B3 [approved, must] Which store holds the logs: SQLite. Choices: SQLite, Postgres. | gate: review',+ 'the person answers from the view as well as the main checkout');++ const checked = box.run('check');+ assert.equal(checked.status, 0, `answers through the person path pass spec check: ${checked.stdout}${checked.stderr}`);++ const again = box.run('answer', 'B1', 'SQLite', '--json');+ assert.equal(again.status, 1);+ const error = JSON.parse(again.stdout).error;+ assert.equal(error.code, 'SPEC_ANSWER');+ assert.match(error.message, /B1 is approved, not a pending question/u);+ assert.match(error.next, /pullboard spec/u);+ assert.notEqual(error.next, RECORDED_GENERIC_NEXT);+});++test('an agent cannot answer a pending row [P6,B26,E3]', (t) => {+ const box = specBox(t, { specSource: QUESTION_SPEC });+ const file = join(box.root, box.specName);+ const before = readFileSync(file, 'utf8');+ const decisions = boardRowDecisions(box);+ const spoofs = { PULLBOARD_PERSON: '1', PULLBOARD_AS: 'person', PULLBOARD_AGENT: 'person', PULLBOARD_CHANNEL: 'view',+ PULLBOARD_PERSON_CHANNEL: 'view', PULLBOARD_VIEW_FOREGROUND: '1', USER: 'person', LOGNAME: 'person' };+ const shells = [...AGENT_SHELL_MARKERS.map((marker) => ({ [marker]: 'agent-fixture', ...spoofs })),+ { CLAUDECODE: '1' }, { SSH_CONNECTION: '10.0.0.1 22 10.0.0.2 22', ...spoofs }, { SSH_TTY: '/dev/ttys009' }];+ for (const shell of shells) {+ const name = Object.keys(shell).join('+');+ const refused = runIn(box, box.root, ['spec', 'answer', 'B1', 'Postgres', '--json'], { ...box.env, ...shell });+ assert.equal(refused.status, 1, `${name}: ${refused.stdout}${refused.stderr}`);+ const error = JSON.parse(refused.stdout).error;+ assert.equal(error.code, 'B26_PERSON_CHANNEL', name);+ assert.match(error.message, /the person/u, `${name}: the refusal names the person`);+ assert.match(error.next, /pullboard view/u, name);+ assert.notEqual(error.next, RECORDED_GENERIC_NEXT, name);+ }+ const flagged = runIn(box, box.root, ['spec', 'answer', 'B1', 'Postgres', '--as', 'person', '--json'], { ...box.env, CLAUDECODE: '1' });+ assert.equal(flagged.status, 1);+ assert.equal(JSON.parse(flagged.stdout).error.code, 'FLAG_NOT_ALLOWED', 'no flag makes an agent the person');++ const api = viewMove(box, { verb: 'spec-answer', args: { row: 'B1', answer: 'Postgres' } }, 'api', box.env);+ assert.equal(api.status, 409, JSON.stringify(api));+ assert.equal(api.body.error.code, 'B26_PERSON_CHANNEL', 'the agent API is not the person channel');++ const made = box.command('worktree', 'review');+ assert.equal(made.status, 0, made.stdout + made.stderr);+ const worktree = /^made (.+) on branch/mu.exec(made.stdout)[1];+ const agent = runIn(box, worktree, ['spec', 'answer', 'B1', 'Postgres', '--json']);+ assert.equal(agent.status, 1, agent.stdout + agent.stderr);+ const agentError = JSON.parse(agent.stdout).error;+ assert.equal(agentError.code, 'B26_PERSON_APPROVAL', 'an agent worktree is refused even from a clean terminal');+ assert.match(agentError.message, /only the person answers/u);+ assert.match(agentError.next, /pullboard view/u);+ assert.equal(readFileSync(file, 'utf8'), before, 'refused answers leave the spec bytes alone');+ assert.equal(boardRowDecisions(box), decisions, 'refused answers record no row decision');++ writeFileSync(file, before+ .replace('[pending, must] Which store holds the data: SQLite.', '[approved, must] Which store holds the data: Postgres.')+ .replace('holds the cache: SQLite.', 'holds the cache: Postgres.'));+ const handEdited = box.run('check');+ assert.equal(handEdited.status, 1, handEdited.stdout + handEdited.stderr);+ assert.match(handEdited.stdout, /B1 error: pending question answered by hand; ask the person to run pullboard spec answer B1/u,+ 'a hand edit that approves the question is flagged');+ assert.match(handEdited.stdout, /B2 error: pending question answered by hand; ask the person to run pullboard spec answer B2/u,+ 'a hand edit that changes the answer of a still-pending question is flagged');+ assert.doesNotMatch(handEdited.stdout, /B3 error|B4 error/u, 'untouched questions stay quiet');+});+test('spec --json emits one versioned document with every field, including empty fields [S13]', (t) => {const box = specBox(t);const shown = box.run('--json');