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(history): prefer complete row trailers to previews [C7]
Corey Olson0a0dc2b93c0a
diff --git a/src/history.js b/src/history.jsindex 828a0c94..b5801cd0 100644--- a/src/history.js+++ b/src/history.js@@ -4,9 +4,9 @@* row keeps its meaning however the spec changes.*/import { spawnSync } from 'node:child_process';+import { parseCommitMessage } from './commit-message.js';import {ID_RE,- citedIds,parseSpec,} from './spec.js';@@ -68,8 +68,9 @@ export function committedIds(root, path, revs = ['HEAD']) {}/**- * The spec ids cited in commit headers from `since` (the spec's first commit) to HEAD, each with- * the newest commit that cites it. Commits older than the spec cite nothing it could hold.+ * The complete spec citations from `since` (the spec's first commit) to HEAD, each with the newest+ * commit that cites it. Final row trailers take priority over header previews; legacy commits fall+ * back to their named header rows. Commits older than the spec cite nothing it could hold.** @param {string} root* @param {string} since@@ -77,13 +78,17 @@ export function committedIds(root, path, revs = ['HEAD']) {*/export function commitCitations(root, since) {const out = [- gitOut(root, ['log', '--format=%h%x09%s', `${since}..HEAD`]),- gitOut(root, ['log', '-1', '--format=%h%x09%s', since]),+ gitOut(root, ['log', '--format=%h%x00%B%x00', `${since}..HEAD`]),+ gitOut(root, ['log', '-1', '--format=%h%x00%B%x00', since]),].join('\n');const cited = new Map();- for (const line of out.split('\n')) {- const [short, ...subject] = line.split('\t');- for (const id of citedIds(subject.join('\t')).filter((entry) => ID_RE.test(entry))) {+ // Git commit messages cannot contain NUL, so body lines and tabs cannot forge record boundaries.+ const records = out.split('\0');+ for (let index = 0; index + 1 < records.length; index += 2) {+ const short = records[index].trim();+ if (!short) continue;+ const parsed = parseCommitMessage(records[index + 1]);+ for (const id of (parsed.rows ?? parsed.shown).filter((entry) => ID_RE.test(entry))) {if (!cited.has(id)) cited.set(id, `commit ${short}`);}}diff --git a/test/history.test.js b/test/history.test.jsindex 2822a7eb..851a4593 100644--- a/test/history.test.js+++ b/test/history.test.js@@ -4,6 +4,10 @@ import { mkdirSync, writeFileSync } from 'node:fs';import { join } from 'node:path';import { after, test } from 'node:test';import { commitCitations } from '../src/history.js';+import * as store from '../src/board.js';+import { frozenCriterion, parseSpec } from '../src/spec.js';+import { rowEvidence } from '../src/evidence.js';+import { submitFixture } from './board-submit-fixture.js';import { createE2eHelpers } from './e2e-helpers.js';const e2e = createE2eHelpers();@@ -62,3 +66,45 @@ test('a legacy preview without full trailers preserves only the rows actually naconst found = commitCitations(root, first);assert.deepEqual([...found.keys()].sort(), ['G1', 'G2']);});+++test('mixed Git history cannot replace show, ledger or coverage board authority [C7,S8,B3]', () => {+ const { box, root, first, commit } = historyFixture();+ const spec = '# Spec\n\n## G · Goals\n- G1 [approved, must] Board requirement. | gate: test\n- G2 [approved, must] Historical requirement. | gate: test\n';+ writeFileSync(join(root, 'SPEC.md'), spec);+ writeFileSync(join(root, 'pullboard.json'), JSON.stringify({ gate: 'true', spec: 'SPEC.md',+ lanes: { web: { owns: ['web/'], specs: ['G'] } } }));+ box.git(root, 'add', 'SPEC.md', 'pullboard.json');+ box.git(root, 'commit', '-q', '-m', 'chore: configure historical fixture');+ commit('test: legacy citation [G1]');+ commit('test(merge): historic item [G2]\n\nPullboard-Item: #1\nPullboard-Rows: G2');+ const source = box.git(root, 'rev-parse', 'HEAD').trim();+ const initialized = box.run(root, 'init');+ assert.equal(initialized.code, 0, initialized.err);+ const board = store.openBoard(join(root, '.git', 'pullboard', 'board.sqlite'));+ let id;+ let item;+ try {+ id = store.addItem(board, { by: 'coordinator', lane: 'coordinator', title: 'Board rows remain authoritative',+ criterion: 'Keep the live and frozen requirement.', specIds: ['G1'] });+ assert.equal(id, 1);+ store.claim(board, id, { agentId: 'coordinator', lane: 'coordinator', leaseMs: 60_000,+ freeze: () => frozenCriterion(parseSpec(spec), store.getItem(board, id)), head: source });+ // Synthetic historical submission proves a reader contract, not successful gate execution.+ submitFixture(board, id, { agentId: 'coordinator', commit: source,+ tree: box.git(root, 'rev-parse', source + '^{tree}').trim() });+ item = store.getItem(board, id);+ const coverage = rowEvidence(root, 'G1', { items: [item], testFiles: [] });+ assert.equal(coverage.awaiting, true);+ assert.equal(rowEvidence(root, 'G2', { items: [item], testFiles: [] }).awaiting, false);+ } finally { store.closeBoard(board); }+ const shown = box.run(root, 'show', String(id), '--json');+ assert.equal(shown.code, 0, shown.err);+ const detail = JSON.parse(shown.out);+ assert.equal(detail.item_spec_ids, 'G1');+ assert.deepEqual(JSON.parse(detail.item_frozen).rows.map(row => row.id), ['G1']);+ const ledger = box.run(root, 'ledger', '--json');+ assert.equal(ledger.code, 0, ledger.err);+ assert.equal(JSON.parse(ledger.out).items.find(entry => entry.item_id === id).item_spec_ids, 'G1');+ assert.deepEqual([...commitCitations(root, first).keys()].sort(), ['G1', 'G2']);+});