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): validate verdict reads and preserve source lines [S1,V4]
Corey Olson9b7cbdcce94c
diff --git a/src/commands/spec.js b/src/commands/spec.jsindex 2095f779..1dabc388 100644--- a/src/commands/spec.js+++ b/src/commands/spec.js@@ -1,5 +1,8 @@/** 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 {+ planRowVerificationApply,+ rowVerificationFindings,+} from '../spec-verdicts.js';import { planAutomaticRigorApply } from '../rigor-auto-apply.js';import {planSpecRevision,@@ -97,6 +100,7 @@ import {} from '../view.js';import {mkdirSync,+ readFileSync,writeFileSync,} from 'node:fs';import {diff --git a/src/spec-verdicts.js b/src/spec-verdicts.jsindex 56836d17..d3380654 100644--- a/src/spec-verdicts.js+++ b/src/spec-verdicts.js@@ -1,11 +1,20 @@/** 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 {+ atomic,+ logEvent,+} from './board.js';import { rowDrafts } from './board-query.js';-import { parseSpec } from './spec.js';+import {+ lintSpec,+ parseSpec,+} from './spec.js';import { Refused } from './refused.js';-import { rowVerificationSource, verifiedRowSource } from './spec-verdict-format.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) {@@ -45,7 +54,7 @@ export function recordRowVerification(board, { agentId, source, decision, reasonreturn 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) {+ if (parsed.problems.length || parsed.rows.length !== 1 || parsed.rows[0].unknown.length || parsed.rows[0].verify !== undefined || lintSpec(parsed).some(finding => finding.level === 'error')) {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];@@ -71,7 +80,7 @@ export function rowVerificationFindings(board, parsed, source) {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}`; }+ catch (error) { if (!(error instanceof Refused) || !['ROW_VERIFY_PROVENANCE', 'ROW_VERIFY_SELF'].includes(error.code)) throw error; message = `${error.code}: ${error.message}`; }}return message ? [{ level: 'error', line: row.line, id: row.id, message }] : [];});@@ -88,10 +97,13 @@ export function planRowVerificationApply(root, config, records, decisions) {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 index = row.line - 1;+ const carriage = lines[index].endsWith('\r') ? '\r' : '';+ const current = carriage ? lines[index].slice(0, -1) : lines[index];+ if (rowVerificationSource(current) !== record.source) continue;const after = verifiedRowSource(record);- if (lines[row.line - 1] === after) continue;- lines[row.line - 1] = after;+ if (current === after) continue;+ lines[index] = after + carriage;applied.push(record.id);}const after = lines.join('\n');diff --git a/src/spec.js b/src/spec.jsindex 3bc05c23..0a3c7e39 100644--- a/src/spec.js+++ b/src/spec.js@@ -26,7 +26,10 @@ import {} from './config.js';import { cleanGitEnvironment } from './git.js';import { Refused } from './refused.js';-import { parseRowVerification, rowVerificationFormatProblems } from './spec-verdict-format.js';+import {+ parseRowVerification,+ rowVerificationFormatProblems,+} from './spec-verdict-format.js';import {renamedGatePath,revisionGateCommand,diff --git a/test/spec.test.js b/test/spec.test.jsindex a99e89e1..2dd5cf50 100644--- a/test/spec.test.js+++ b/test/spec.test.js@@ -1153,4 +1153,36 @@ test('a verdict on a spec row is recorded by an outside verifier [S1,V4,H16]', tstore.recordRowVerification(board, { agentId: verifier, source, decision: 'rejected', reason: 'A counterexample remains.' });assert.equal(box.run('apply').status, 0);assert.match(box.run('show', 'G1').stdout, /verify: rejected by/u);+ const valid = readFileSync(join(box.root, box.specName), 'utf8');+ writeFileSync(join(box.root, box.specName), valid.replace('A counterexample remains.', 'A forged reason.'));+ const forged = box.run('check');+ assert.equal(forged.status, 1);+ assert.match(forged.stdout, /ROW_VERIFY_RECEIPT/u);+ writeFileSync(join(box.root, box.specName), valid);+ for (const changed of [source.replace('G1', 'G99'), source.replace('original row', 'different row')]) {+ assert.throws(() => store.recordRowVerification(board, { agentId: verifier, source: changed, decision: 'accepted', reason }),+ { code: 'ROW_VERIFY_PROVENANCE' });+ }+ const unknown = store.register(board, { lane: 'review', path: join(box.root, 'unknown') });+ assert.throws(() => store.recordRowVerification(board, { agentId: unknown, source, decision: 'accepted', reason }),+ { code: 'ROW_VERIFY_PROVENANCE' });+ writeFileSync(join(box.root, box.specName), valid.replace(/\n/gu, '\r\n'));+ store.recordRowVerification(board, { agentId: verifier, source, decision: 'accepted', reason });+ assert.equal(box.run('apply').status, 0);+ const windowsSource = readFileSync(join(box.root, box.specName), 'utf8');+ assert.ok(!/(?<!\r)\n/u.test(windowsSource), 'applying a new verdict preserves CRLF source endings');+ assert.equal(box.run('check').status, 0);+});+++test('verifier fields reject duplicate and malformed annotations without swallowing check pipelines [S1,V4]', () => {+ const base = '- G1 [draft, must] A row. | gate: check printf yes | grep yes';+ assert.equal(parseSpec(`## G\n${base}\n`).rows[0].gate, 'check printf yes | grep yes');+ const valid = parseSpec(`## G\n${base} | verify: rejected by tests-2 | Missing evidence.\n`);+ assert.equal(valid.rows[0].gate, 'check printf yes | grep yes');+ assert.deepEqual(lintSpec(valid), []);+ for (const suffix of ['verify: maybe by tests-2 | Why.', 'verify: accepted by tests-2',+ 'verify: rejected by tests-2 | ', 'verify: accepted by tests-2 | Why. | verify: rejected by tests-3 | Why.']) {+ assert.ok(lintSpec(parseSpec(`## G\n${base} | ${suffix}\n`)).some(finding => finding.level === 'error'), suffix);+ }});