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): record outside-parent row verdicts [S1,V4,H16]
Corey Olsondbd1ec09b427
diff --git a/src/board.js b/src/board.jsindex 38e71024..7ac3fe8d 100644--- a/src/board.js+++ b/src/board.js@@ -2341,3 +2341,5 @@ export function approveOutside(board, id, options) { return applyOutsideApproval/** Tailored inbox activity is the same canonical read projection as other board queries. */export { agentActivity } from './board-query.js';++export { recordRowVerification, rowVerifications } from './spec-verdicts.js';diff --git a/src/commands/spec.js b/src/commands/spec.jsindex 189f4a87..2095f779 100644--- a/src/commands/spec.js+++ b/src/commands/spec.js@@ -1,4 +1,5 @@/** The pullboard spec command, in its own module so an item adding another command never edits these lines. */+import { planRowVerificationApply, rowVerificationFindings } from '../spec-verdicts.js';import { planAutomaticRigorApply } from '../rigor-auto-apply.js';import {planSpecRevision,@@ -134,6 +135,7 @@ export async function specCommand(io, { first, second, rest, values }) {check: ['json'],view: ['out'],show: [],+ verify: ['reason'],unmet: ['must'],signoff: ['by', 'note', 'note-file'],signers: ['key', 'by'],@@ -159,6 +161,19 @@ export async function specCommand(io, { first, second, rest, values }) {if (!spec.exists) throw new Refused('NO_SPEC', `no ${ctx.config.spec}; run: pullboard init`);const practice = ctx.doctrine;const signoffs = readSignoffs(ctx.info.root);+ if (first === 'verify') {+ if (!second || rest.length !== 1 || !['accepted', 'rejected'].includes(rest[0])) throw new Refused('USAGE', 'use pullboard spec verify <id> accepted|rejected --reason "why"');+ const rows = spec.rows.filter(row => row.id === second);+ if (rows.length !== 1) throw new Refused('NO_ROW', `no unique row ${second}; read pullboard spec --json`);+ const source = readFileSync(spec.file, 'utf8').split(/\r?\n/u)[rows[0].line - 1];+ return withBoard(ctx, async board => {+ const me = whoAmI(ctx, board);+ const receipt = await ordered(ctx, board, 'recordRowVerification', [{ agentId: me.id, source, decision: rest[0], reason: values.reason }]);+ io.result?.({ verification: receipt });+ io.say(`${receipt.id}: ${receipt.decision} by ${receipt.by}; ask the coordinator to run pullboard spec apply`);+ return 0;+ });+ }if (first === 'draft') {if (second && /\|\s*gate\s*:/iu.test(second)) {throw new Refused('INLINE_GATE', 'move the gate after the requirement as --gate "<check>"');@@ -278,9 +293,12 @@ export async function specCommand(io, { first, second, rest, values }) {let applied;try { applied = await ordered(ctx, board, 'applyRowDecisions', [{ agentId: me.id, events: plan.records.map((record) => record.event) }]); }catch (error) { restoreRowApply(ctx.info.root, plan); throw error; }- io.result?.({ applied, files: plan.files.map((file) => file.file) });+ const verifications = planRowVerificationApply(ctx.info.root, ctx.config, store.rowVerifications(board), store.rowDecisions(board));+ writeRowApply(ctx.info.root, verifications);+ verifications.applied.forEach(id => io.say(`${ctx.config.spec}: ${id} verifier verdict applied`));+ io.result?.({ applied, verifications: verifications.applied, files: [...plan.files, ...verifications.files].map((file) => file.file) });applied.forEach((record) => io.say(`${record.file}: ${record.id} ${record.decision === 'approve' ? 'approved' : 'wont'}${record.reason ? `: ${record.reason}` : ''}`));- if (!applied.length && !drafted.length) io.say('no pending row decisions');+ if (!applied.length && !drafted.length && !verifications.applied.length) io.say('no pending row decisions');else io.say('stage and commit the changed row files and any .pullboard/signoffs.jsonl receipts');return 0;});@@ -334,6 +352,8 @@ export async function specCommand(io, { first, second, rest, values }) {for (const [name, parsed] of files) {const findings = [...lintSpec(parsed).filter((finding) => !finding.message.startsWith('duplicate id;')),+ ...(name === ctx.config.spec && parsed.rows.some(row => row.verify !== undefined)+ ? withBoard(ctx, board => rowVerificationFindings(board, parsed, readFileSync(parsed.file, 'utf8'))) : []),...missingGateFindings(parsed, ctx.info.root),...(collisionFindings.get(name) ?? []),];@@ -358,9 +378,9 @@ export async function specCommand(io, { first, second, rest, values }) {unnamed.forEach((problem) => messages.push(`${ctx.config.spec}: error: ${problem}`));errors += unnamed.length;if (values.json && !errors) {- const rows = files.flatMap(([file, parsed]) => parsed.rows.map(({ id, status, tier, text, gate, serves, signers = [], section, line, origin, version, reason, file: source, source: from }) => (+ const rows = files.flatMap(([file, parsed]) => parsed.rows.map(({ id, status, tier, text, gate, serves, signers = [], section, line, origin, version, reason, file: source, source: from, verify }) => ({ id, status, tier, text, gate, serves, signers, section, line, file: source ?? file,- ...(from === undefined ? {} : { source: from }), ...(origin ? { origin, version, reason } : {}) }+ ...(from === undefined ? {} : { source: from }), ...(verify === undefined ? {} : { verify }), ...(origin ? { origin, version, reason } : {}) })));const fit = readFitBatch(ctx.info.commonDir, { isMain: ctx.info.isMain, channel: io.personChannel });io.result({ rows, ...(fit.proposals.length ? { fit: fit.proposals, fitBatch: fit.batch } : {}) });@@ -410,6 +430,7 @@ export async function specCommand(io, { first, second, rest, values }) {if (row.gate) io.say(`gate: ${row.gate}`);if (row.serves.length) io.say(`serves: ${row.serves.join(', ')}`);if (row.source) io.say(`source: ${row.source}`);+ if (row.verify) io.say(`verify: ${row.verify.decision} by ${row.verify.by} | ${row.verify.reason}`);io.say(`signed: ${standing.met.map((entry) => `${entry.by} ${entry.on}`).join(', ') || 'no'}${standing.stale.length ? `; stale: ${standing.stale.length}` : ''}`);for (const entry of [...standing.met, ...standing.stale]) if (entry.note) io.say(`note (${entry.by}): ${entry.note}`);return 0;diff --git a/src/moves/recordRowVerification.js b/src/moves/recordRowVerification.jsnew file mode 100644index 00000000..57ec776b--- /dev/null+++ b/src/moves/recordRowVerification.js@@ -0,0 +1,15 @@+/** Exact-row verifier operation; its actor is the actual joined caller [V4,H16]. */+import { SPEC_VERDICT_ENGINE } from '../spec-verdict-engine.js';++/** Older replicas must refuse rather than lose independent verdict semantics. */+function minimumEngine() { return SPEC_VERDICT_ENGINE; }+/** Bind the canonical sender to the seat that recorded the verdict. */+function actor(move) { return move.args[0]?.agentId ?? null; }++export default Object.freeze({ operation: 'recordRowVerification', engine: SPEC_VERDICT_ENGINE,+ itemIdFirstArgument: false, minimumEngine, actor,+ nextSteps: Object.freeze({+ ROW_VERIFY: 'pullboard spec show <id>, then pullboard spec verify <id> accepted --reason "why"',+ ROW_VERIFY_PROVENANCE: 'draft the row through pullboard spec draft and join normally before verifying it',+ ROW_VERIFY_SELF: 'ask an outside-parent verifier to run pullboard spec verify',+ }) });diff --git a/src/spec-verdict-engine.js b/src/spec-verdict-engine.jsnew file mode 100644index 00000000..40147fcc--- /dev/null+++ b/src/spec-verdict-engine.js@@ -0,0 +1,4 @@+/** Exact-row independent verifier receipts require a reader that preserves their authority [V4,H16]. */+import { unassignedEngine } from './engine-next.js';++export const SPEC_VERDICT_ENGINE = unassignedEngine();diff --git a/src/spec-verdict-format.js b/src/spec-verdict-format.jsnew file mode 100644index 00000000..1c0c388b--- /dev/null+++ b/src/spec-verdict-format.js@@ -0,0 +1,26 @@+/** Optional verifier annotations are evidence, never a person's approval [S1,V4]. */++/** Parse the declared seat separately from its required following reason segment. */+export function parseRowVerification(value, reason) {+ const match = /^(accepted|rejected) by ([^\s|]+)$/u.exec(value);+ return match ? { decision: match[1], by: match[2], reason } : { invalid: value, reason };+}++/** Keep absent annotations byte-compatible and report malformed or empty verdicts explicitly. */+export function rowVerificationFormatProblems(verification) {+ if (verification === undefined) return [];+ return !verification || !['accepted', 'rejected'].includes(verification.decision)+ || typeof verification.by !== 'string' || !/^[^\s|]+$/u.test(verification.by)+ || typeof verification.reason !== 'string' || !verification.reason.trim() || /[\r\n|]/u.test(verification.reason)+ ? ['verify needs accepted or rejected by <seat>, followed by | <one-line reason>'] : [];+}++/** Remove only a terminal verifier annotation; all normative source bytes stay bound. */+export function rowVerificationSource(source) {+ return source.replace(/ \| verify: (?:accepted|rejected) by [^\s|]+ \| [^\r\n|]+$/u, '');+}++/** Materialize the exact recorded source with its actual verifier and reason. */+export function verifiedRowSource(record) {+ return `${record.source} | verify: ${record.decision} by ${record.by} | ${record.reason}`;+}diff --git a/src/spec-verdicts.js b/src/spec-verdicts.jsnew file mode 100644index 00000000..56836d17--- /dev/null+++ b/src/spec-verdicts.js@@ -0,0 +1,99 @@+/** Recorded outside-parent verdicts for known board-drafted spec rows [S1,V4,H16]. */+import { readFileSync } from 'node:fs';+import { join } from 'node:path';+import { atomic, logEvent } from './board.js';+import { rowDrafts } from './board-query.js';+import { parseSpec } from './spec.js';+import { Refused } from './refused.js';+import { rowVerificationSource, verifiedRowSource } from './spec-verdict-format.js';++/** Read immutable recorded parent/session identity without treating an unknown seat as independent. */+function recordedParent(board, id) {+ return board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(`agent_parent_session:${id}`)?.meta_value+ ?? board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(`agent_session:${id}`)?.meta_value;+}++/** Current receipts are native replay metadata, not a local projection cache. */+export function rowVerifications(board) {+ const raw = board.db.prepare("SELECT meta_value FROM board_meta WHERE meta_key='row_verifications'").get();+ return raw ? JSON.parse(raw.meta_value) : [];+}++/** Resolve the original exact draft, retaining its author after coordinator materialization. */+function rowAuthor(board, row) {+ const drafts = rowDrafts(board).filter(draft => draft.id === row.id && (draft.target ?? 'spec') === 'spec'+ && !draft.revises && ['text', 'gate', 'tier'].every(key => (draft[key] ?? '') === (row[key] ?? '')));+ const authors = new Set(drafts.map(draft => draft.by));+ if (authors.size !== 1) throw new Refused('ROW_VERIFY_PROVENANCE', `${row.id} lacks one exact board-drafted author; draft the row through pullboard spec draft before verifying it`);+ return [...authors][0];+}++/** Validate real recorded identity on both axes; separate seat names alone never establish independence. */+function outsideParent(board, author, verifier) {+ const authorParent = recordedParent(board, author);+ const verifierParent = recordedParent(board, verifier);+ if (!authorParent || !verifierParent) throw new Refused('ROW_VERIFY_PROVENANCE', 'the row author and verifier need recorded parent sessions; join normally before verifying the row');+ if (authorParent === verifierParent) throw new Refused('ROW_VERIFY_SELF', 'the row verifier shares its author parent session; ask an outside-parent verifier to run pullboard spec verify');+}++/** Record an exact-row receipt under the authenticated operation actor, without writing a file. */+export function recordRowVerification(board, { agentId, source, decision, reason }) {+ if (typeof source !== 'string' || /[\r\n]/u.test(source) || !['accepted', 'rejected'].includes(decision)+ || typeof reason !== 'string' || !reason.trim() || /[\r\n|]/u.test(reason)) {+ throw new Refused('ROW_VERIFY', 'name one row, accepted or rejected and a one-line reason: pullboard spec verify <id> accepted --reason "why"');+ }+ return atomic(board, () => {+ const base = rowVerificationSource(source);+ const parsed = parseSpec(`## Verification\n${base}\n`);+ if (parsed.problems.length || parsed.rows.length !== 1 || parsed.rows[0].unknown.length || parsed.rows[0].verify !== undefined) {+ throw new Refused('ROW_VERIFY', 'the verdict needs one exact spec row without malformed fields; run pullboard spec check first');+ }+ const row = parsed.rows[0];+ const author = rowAuthor(board, row);+ outsideParent(board, author, agentId);+ const record = { id: row.id, source: base, decision, reason: reason.trim(), by: agentId, author };+ logEvent(board, agentId, 'row_verification', null, { record });+ const entry = { ...record, event: board.lastEvent.event_id, at: board.lastEvent.event_at };+ const records = [...rowVerifications(board).filter(old => old.id !== row.id), entry];+ board.db.prepare("INSERT INTO board_meta(meta_key,meta_value) VALUES ('row_verifications',?) ON CONFLICT(meta_key) DO UPDATE SET meta_value=excluded.meta_value")+ .run(JSON.stringify(records));+ return entry;+ });+}++/** Reject fabricated, stale or same-parent file annotations against the current exact receipt. */+export function rowVerificationFindings(board, parsed, source) {+ const lines = source.split(/\r?\n/u);+ const records = rowVerifications(board);+ return parsed.rows.filter(row => row.verify !== undefined).flatMap(row => {+ const record = records.find(candidate => candidate.id === row.id);+ let message;+ if (!record || lines[row.line - 1] !== verifiedRowSource(record)) message = 'ROW_VERIFY_RECEIPT: no matching exact-row verifier receipt; run pullboard spec verify before applying its verdict';+ else {+ try { outsideParent(board, rowAuthor(board, row), record.by); }+ catch (error) { if (!(error instanceof Refused)) throw error; message = `${error.code}: ${error.message}`; }+ }+ return message ? [{ level: 'error', line: row.line, id: row.id, message }] : [];+ });+}++/** Plan only matching current rows; stale verdicts never overwrite changed requirements or signed decisions. */+export function planRowVerificationApply(root, config, records, decisions) {+ const file = config.spec;+ const before = readFileSync(join(root, file), 'utf8');+ const parsed = parseSpec(before);+ const lines = before.split('\n');+ const applied = [];+ for (const record of records) {+ const rows = parsed.rows.filter(row => row.id === record.id);+ if (rows.length !== 1 || decisions.some(decision => !decision.applied && decision.kind === 'spec' && decision.id === record.id)) continue;+ const row = rows[0];+ if (rowVerificationSource(lines[row.line - 1]) !== record.source) continue;+ const after = verifiedRowSource(record);+ if (lines[row.line - 1] === after) continue;+ lines[row.line - 1] = after;+ applied.push(record.id);+ }+ const after = lines.join('\n');+ return { applied, records: [], files: after === before ? [] : [{ file, before, after }], signoffs: { before: null, receipts: [] } };+}diff --git a/src/spec.js b/src/spec.jsindex bf458466..3bc05c23 100644--- a/src/spec.js+++ b/src/spec.js@@ -26,6 +26,7 @@ import {} from './config.js';import { cleanGitEnvironment } from './git.js';import { Refused } from './refused.js';+import { parseRowVerification, rowVerificationFormatProblems } from './spec-verdict-format.js';import {renamedGatePath,revisionGateCommand,@@ -52,7 +53,7 @@ const SECTION_RE = /^##\s+(.+)$/;const SIGNER_RE = /^(?!#)[^\s,]+$/u;const LEGACY_SIGNER_RE = /^[A-Z][A-Za-z]{1,11}$/;-const FIELD_NAMES = ['gate', 'serves', 'signers', 'count', 'runs', 'mode', 'files', 'source'];+const FIELD_NAMES = ['gate', 'serves', 'signers', 'count', 'runs', 'mode', 'files', 'source', 'verify'];const CHECK_FIELDS = ['count', 'runs', 'mode', 'files'];/** Replace the complete gate field, including check pipelines, while preserving other row fields. */@@ -78,7 +79,13 @@ function splitFields(rest) {const [text = '', ...parts] = rest.split(' | ');const fields = { text: text.trim(), gate: '', serves: [], signers: [], unknown: [] };let inCheck = false;+ let verdictReason = false;for (const part of parts) {+ if (verdictReason) {+ fields.verify = parseRowVerification(fields.verify, part.trim());+ verdictReason = false;+ continue;+ }const [key = '', ...value] = part.split(':');const joined = value.join(':').trim();if (inCheck && !FIELD_NAMES.includes(key.trim())) {@@ -86,7 +93,11 @@ function splitFields(rest) {continue;}inCheck = false;- if (key.trim() === 'gate') {+ if (key.trim() === 'verify') {+ if (Object.hasOwn(fields, 'verify')) fields.unknown.push('duplicate verify field');+ fields.verify = joined;+ verdictReason = true;+ } else if (key.trim() === 'gate') {fields.gate = joined;inCheck = /^check(\s|$)/u.test(joined);} else if (CHECK_FIELDS.includes(key.trim()) || key.trim() === 'source') fields[key.trim()] = joined;@@ -96,6 +107,7 @@ function splitFields(rest) {fields.signers = joined.split(',').map((signer) => signer.trim()).filter(Boolean);} else fields.unknown.push(part.trim());}+ if (verdictReason) fields.verify = parseRowVerification(fields.verify, '');return fields;}@@ -232,8 +244,9 @@ function rowFindings(row, maxWords) {// are not counted: the limit keeps the requirement itself short (blueprint rows carry both).const words = row.text.split(/ (?:Why|Choices): /u)[0].split(/\s+/).filter(Boolean).length;if (words > maxWords) add('warning', `${words} words; rows stay under ${maxWords}, the why goes elsewhere`);- for (const part of row.unknown) add('error', `unknown field "${part}"; fields are gate, serves, signers, count, runs, mode, files and source`);+ for (const part of row.unknown) add('error', `unknown field "${part}"; fields are gate, serves, signers, count, runs, mode, files, source and verify`);if (row.source !== undefined && !row.source.trim()) add('error', 'source names where the row came from; leave it out when the row has none');+ for (const message of rowVerificationFormatProblems(row.verify)) add('error', message);findings.push(...checkFieldFindings(row).map((message) => ({ level: 'error', line: row.line, id: row.id, message })));return findings;}