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): preserve omitted fields and sync revision fixtures [P6,B23]
Corey Olson58defd859aa8
diff --git a/src/row-drafts.js b/src/row-drafts.jsindex a62ecd99..3ed53fc8 100644--- a/src/row-drafts.js+++ b/src/row-drafts.js@@ -34,7 +34,7 @@ export { rowDrafts } from './board-query.js';*/export function draftSpecRow(board, { agentId, row, written = false }) {if (!agentId || agentId === PERSON) throw new Refused('ROW_DRAFT', 'an agent drafts a row and the person approves it; run pullboard spec draft "<text>" from an agent seat');- const needed = written ? ['text'] : row?.revises !== undefined ? ['text', 'tier', 'section'] : ['text', 'gate', 'tier', 'section'];+ const needed = written ? ['text'] : row?.revises !== undefined ? ['text', 'section'] : ['text', 'gate', 'tier', 'section'];if (!row || !/^[A-Z][A-Z0-9]*\d+$/u.test(String(row.id)) || !['spec', 'doctrine', undefined].includes(row.target)|| needed.some((key) => typeof row[key] !== 'string' || !row[key].trim() || /[\r\n|]/u.test(row[key]))) {throw new Refused('ROW_DRAFT', 'a drafted row needs its id and a one-line text, gate, tier and section; run pullboard spec draft "<text>"');diff --git a/src/spec-revisions.js b/src/spec-revisions.jsindex 93a7736f..8f007f7e 100644--- a/src/spec-revisions.js+++ b/src/spec-revisions.js@@ -21,6 +21,7 @@ import { draftRow } from './spec-draft.js';import {loadSpec,parseSpec,+ replaceRowGate,STATUSES,} from './spec.js';@@ -40,13 +41,12 @@ export function planSpecRevision(root, config, { revises, text, gate, status, reif (!STATUSES.includes(wanted)) throw new Refused('SPEC_REVISION', `unknown status ${wanted}; use one of ${STATUSES.join(', ')}`);const nextGate = gate ?? row.gate;const nextText = text ?? row.text;- let replacement = source.replace(/\[[a-z]+(?=,|\])/u, () => `[${wanted}`)- .replace(/(\]\s+)[^|]*/u, (_, start) => `${start}${nextText} `);- replacement = /\|\s*gate\s*:/u.test(replacement)- ? replacement.replace(/(\|\s*gate\s*:\s*)[^|]*/u, (_, start) => `${start}${nextGate} `)- : `${replacement.trimEnd()} | gate: ${nextGate}`;- replacement = replacement.trimEnd();- if (replacement === source) throw new Refused('SPEC_REVISION', 'the proposed row is unchanged; give new text, gate or status');+ if (nextText === row.text && nextGate === row.gate && wanted === row.status) throw new Refused('SPEC_REVISION', 'the proposed row is unchanged; give new text, gate or status');+ let replacement = source;+ if (wanted !== row.status) replacement = replacement.replace(/\[[a-z]+(?=,|\])/u, () => `[${wanted}`);+ if (nextText !== row.text) replacement = replacement.replace(/(\]\s+)([^|]*)/u,+ (_, start, old) => `${start}${nextText}${old.match(/\s*$/u)?.[0] ?? ''}`);+ if (nextGate !== row.gate) replacement = replaceRowGate(replacement, nextGate);const prefix = /^([A-Z][A-Z0-9]*?)\d+(?:\.\d+)*$/u.exec(revises)?.[1];const plan = draftRow(root, config, { target: 'spec', text: nextText, gate: nextGate, tier: row.tier, section: prefix, taken, write: false });return { ...plan.row, target: 'spec', revises, file: config.spec, source, replacement, status: wanted, reason: reason.trim() };@@ -68,7 +68,9 @@ export function validSpecRevision(row) {&& typeof row.reason === 'string' && row.reason.trim() && !/[\r\n|]/u.test(row.reason)&& before.length === 1 && before[0].status === 'approved' && before[0].id === row.revises&& after.length === 1 && after[0].id === row.revises && after[0].text === row.text- && after[0].gate === row.gate && after[0].status === row.status && row.source !== row.replacement;+ && after[0].gate === row.gate && after[0].status === row.status && row.source !== row.replacement+ && [...new Set([...Object.keys(before[0]), ...Object.keys(after[0])])].filter(key => !['text', 'gate', 'status', 'line', 'section'].includes(key))+ .every(key => JSON.stringify(before[0][key]) === JSON.stringify(after[0][key]));}/** Accept only the exact approved effect of a still-pending board proposal. */diff --git a/src/spec.js b/src/spec.jsindex a3915046..bf458466 100644--- a/src/spec.js+++ b/src/spec.js@@ -55,6 +55,13 @@ const LEGACY_SIGNER_RE = /^[A-Z][A-Za-z]{1,11}$/;const FIELD_NAMES = ['gate', 'serves', 'signers', 'count', 'runs', 'mode', 'files', 'source'];const CHECK_FIELDS = ['count', 'runs', 'mode', 'files'];+/** Replace the complete gate field, including check pipelines, while preserving other row fields. */+export function replaceRowGate(source, gate) {+ const field = new RegExp(`(\\|\\s*gate\\s*:\\s*)(.*?)(?=\\|\\s*(?:${FIELD_NAMES.join('|')})\\s*:|$)`, 'u');+ return field.test(source) ? source.replace(field, (_, start, old) => `${start}${gate}${old.match(/\s*$/u)?.[0] ?? ''}`)+ : `${source.trimEnd()} | gate: ${gate}`;+}+/*** One row's trailing fields, after the text: `| gate: ...`, `| serves: a, b` and `| signers: CO,AB`.* A doctrine rule may add `| count: N`, `| runs: nightly`, `| mode: watch` and `| files: <paths>`diff --git a/test/spec-revise.test.js b/test/spec-revise.test.jsindex b9feb243..097b7011 100644--- a/test/spec-revise.test.js+++ b/test/spec-revise.test.js@@ -13,6 +13,11 @@ import {import { createE2eHelpers } from './e2e-helpers.js';import { personNeedsState } from '../src/needs-state.js';import { parseSpec } from '../src/spec.js';+import { loadConfig } from '../src/config.js';+import {+ planSpecRevision,+ validSpecRevision,+} from '../src/spec-revisions.js';const fixtures = createE2eHelpers();after(fixtures.cleanup);@@ -57,6 +62,9 @@ test('a proposed change to an approved row waits in Needs you and applies only wconst decision = history.find(event => event.event_kind === 'row_decision' && JSON.stringify(event).includes(proposal.id));assert.ok(decision, 'durable row history identifies the proposal and person decision');assert.equal(decision.event_by, 'person', 'the approval history attributes the actual person');+ box.git(box.repo, 'add', 'SPEC.md');+ box.git(box.repo, 'commit', '-q', '-m', 'feat: apply the person-approved revision [G1]');+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');const approved = readFileSync(file, 'utf8');const declined = JSON.parse(succeeds(box.run(box.web, 'spec', 'draft', 'An unwanted replacement.',@@ -80,6 +88,9 @@ test('a proposed change to an approved row waits in Needs you and applies only wsucceeds(box.run(box.repo, 'spec', 'apply'));assert.equal(row(box, 'G1').status, 'retired', 'the person can approve an explicit status revision');assert.ok(!personNeedsState(box.repo).needs.some(entry => [proposal.id, retired.id].includes(entry.id)), 'older applied revisions stay closed after the target gets a newer decision');+ box.git(box.repo, 'add', 'SPEC.md');+ box.git(box.repo, 'commit', '-q', '-m', 'feat: apply the person-approved retirement [G1]');+ box.git(box.web, 'merge', '-q', '--ff-only', 'main');assert.notEqual(box.run(box.web, 'spec', 'draft', 'Change a retired row.', '--revises', 'G1', '--reason', 'Not approved.').code, 0);});@@ -129,3 +140,26 @@ test('[B23,N39] a real gate rename gives the new path and an exact revision commassert.match(output, /renamed to test\/new\.test\.js/u);assert.ok(output.includes("pullboard spec draft 'The page renders.' --revises 'G1' --gate 'node --test test/new.test.js' --reason 'Gate renamed from test/old.test.js to test/new.test.js.'"));});++test('[P6,B23] revision plans preserve omitted fields and refuse formatting-only changes', { timeout: 120_000 }, () => {+ const box = fixtures.project('true');+ const file = join(box.repo, 'SPEC.md');+ const source = readFileSync(file, 'utf8').replace('- G1 [approved, must] The page renders. | gate: web test',+ '- G1 [approved] The page renders. | gate: check node old | grep ok | count: 0 | serves: G2 ');+ writeFileSync(file, source);+ const config = loadConfig(box.repo);+ const unchanged = { revises: 'G1', reason: 'Explain a change.', taken: [] };+ assert.throws(() => planSpecRevision(box.repo, config, unchanged), error => error.code === 'SPEC_REVISION' && /unchanged/u.test(error.message));+ const text = planSpecRevision(box.repo, config, { ...unchanged, text: 'The page renders accessibly.' });+ assert.equal(text.replacement, text.source.replace('The page renders.', 'The page renders accessibly.'));+ assert.ok(validSpecRevision(text));+ const gate = planSpecRevision(box.repo, config, { ...unchanged, gate: 'true' });+ assert.equal(gate.replacement, gate.source.replace('check node old | grep ok', 'true'));+ assert.ok(validSpecRevision(gate));+ const status = planSpecRevision(box.repo, config, { ...unchanged, status: 'retired' });+ assert.equal(status.replacement, status.source.replace('[approved]', '[retired]'));+ assert.ok(validSpecRevision(status));+ assert.equal(validSpecRevision({ ...text, replacement: `${text.replacement} | signers: someone-else` }), false,+ 'a revision payload cannot silently introduce fields outside text, gate and status');+ assert.equal(readFileSync(file, 'utf8'), source, 'planning never writes the private row file');+});