Skip to content

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.

feat(rigor): report recurring conflict files and draft splits [D1,C7]

Corey Olsona1fd69d8e8d4
diff --git a/src/cli.js b/src/cli.js
index 0ea25ccf..00bb13c9 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -352,6 +352,8 @@ import {
reportView,
} from './background-view.js';
import { rigorDraftCommand } from './rigor-draft.js';
+import { conflictLines, conflictReport } from './rigor-conflicts.js';
+import { draftConflictSplits } from './rigor-splits.js';
import { nextReview } from './next-review.js';
import { serveApi } from './api.js';
import { watchCommand } from './watch.js';
@@ -674,6 +676,7 @@ const OPTIONS = {
conflict: { type: 'string', multiple: true },
cause: { type: 'string' },
'never-again': { type: 'boolean' },
+ 'draft-splits': { type: 'boolean' },
implies: { type: 'string' },
owns: { type: 'string' },
red: { type: 'string' },
@@ -2653,13 +2656,16 @@ function readCommands(io, { first, second, rest, values }) {
}
return 0;
},
- rigor: () => {
+ rigor: async () => {
+ if (values['draft-splits'] && first) throw new Refused('USAGE', 'use pullboard rigor --draft-splits without a proof-bound draft subcommand');
if (first === 'draft') { const ctx = context(io); return rigorDraftCommand(io, { second, rest, values }, { root: ctx.info.root, config: ctx.config, read: () => withBoard(ctx, (board) => ({ events: store.events(board), actor: whoAmI(ctx, board).id })), reserve: (row) => reserveRow(ctx, row, true), propose: (row, evidence) => withBoard(ctx, async (board) => ordered(ctx, board, 'proposeSentinel', [{ agentId: whoAmI(ctx, board).id, row, evidence }])) }); }
if (first || second || rest.length) throw new Refused('USAGE', 'pullboard rigor takes no arguments; to draft a rule: pullboard rigor draft <key> "<rule>" --check "<command>" --red <commit> --green <commit>');
const ctx = context(io);
- const report = withBoard(ctx, (board) => rigorReport(store.events(board), { person: store.PERSON }));
+ const report = withBoard(ctx, (board) => { const history = store.events(board); return { ...rigorReport(history, { person: store.PERSON }), ...conflictReport(history) }; });
+ if (values['draft-splits']) report.splitDrafts = await draftConflictSplits(ctx, report, { read: () => withBoard(ctx, (board) => ({ coordinator: whoAmI(ctx, board).id === COORDINATOR, rows: store.rowDrafts(board) })), reserve: row => reserveRow(ctx, row, true) });
io.result?.(report);
- for (const line of rigorLines(report)) io.say(line);
+ for (const line of [...rigorLines(report), ...conflictLines(report)]) io.say(line);
+ for (const draft of report.splitDrafts ?? []) io.say(`${draft.id}: draft split proposal; person approval required`);
return 0;
},
log: () => {
diff --git a/src/help.js b/src/help.js
index 5d5e1491..2f9ea587 100644
--- a/src/help.js
+++ b/src/help.js
@@ -192,6 +192,7 @@ Receipts
commit pullboard.json to apply; a passing diagnostic never turns the original red green
pullboard rigor failure causes that repeated: on 2 items, or 1 item at 2 commits;
each with its items and whether it reads as work, product or both
+ pullboard rigor --draft-splits coordinator on main: draft review-gated split proposals for files colliding on 2 items in 14 days; only the person approves
pullboard rigor draft <key> "<rule>" --check "<command>" --red <commit> --green <commit> [--section <letter>]
--red is a noticed failure commit; prove its check red, then green at --green
draft Doctrine (work), spec (product) or both; only the person approves
diff --git a/src/rigor-conflicts.js b/src/rigor-conflicts.js
new file mode 100644
index 00000000..e5c96d05
--- /dev/null
+++ b/src/rigor-conflicts.js
@@ -0,0 +1,104 @@
+/** Recent merge collisions are architectural advice, separate from proof-bound Rigor causes [D1]. */
+import { conflictNote, shownPath } from './trunk-conflict.js';
+
+const WINDOW_DAYS = 14;
+const HOT_ITEMS = 2;
+
+/** Read only the complete canonical machine-note syntax; this is not authenticated Git evidence. */
+export function conflictNoteFiles(note) {
+ if (typeof note !== 'string') return null;
+ const match = /^conflicts with the trunk at ([a-f0-9]{12}) in ([\s\S]+); merge main and resubmit$/u.exec(note);
+ if (!match) return null;
+ const body = match[2];
+ const token = /"(?:[^"\\]|\\.)*"|[\w./@+-]+/uy;
+ const files = [];
+ let offset = 0;
+ while (offset < body.length) {
+ token.lastIndex = offset;
+ const found = token.exec(body);
+ if (!found) return null;
+ let file = found[0];
+ if (file.startsWith('"')) {
+ try { file = JSON.parse(file); }
+ catch { return null; /* A malformed quoted path is not a canonical conflict note. */ }
+ }
+ if (!file || file.includes('\0') || files.includes(file) || shownPath(file) !== found[0]) return null;
+ files.push(file);
+ offset = token.lastIndex;
+ if (offset === body.length) break;
+ if (body.slice(offset, offset + 2) !== ', ' || offset + 2 === body.length) return null;
+ offset += 2;
+ }
+ return files.length && conflictNote({ files, trunk: match[1] }) === note ? files : null;
+}
+
+/** Count each recent reopen or hold once per exact file, retaining inspectable event provenance. */
+export function conflictReport(events, { now = new Date() } = {}) {
+ const until = new Date(now).getTime();
+ const since = until - WINDOW_DAYS * 86_400_000;
+ const byFile = new Map();
+ const unattributed = new Map();
+ const seen = new Set();
+ for (const event of events) {
+ if (!['reopen', 'hold_item'].includes(event.event_kind) || !Number.isInteger(event.item_id) || event.item_id < 1) continue;
+ const at = Date.parse(event.event_at);
+ if (!Number.isFinite(at) || at < since || at > until || seen.has(event.event_id)) continue;
+ seen.add(event.event_id);
+ const detail = JSON.parse(event.event_detail);
+ const evidence = { id: event.event_id, item: event.item_id, kind: event.event_kind, at: event.event_at };
+ let files = null;
+ if (event.event_kind === 'reopen' && Array.isArray(detail.conflict?.files)
+ && detail.conflict.files.length && detail.conflict.files.every(file => typeof file === 'string' && file && !file.includes('\0'))
+ && /^[a-f0-9]{40}$/u.test(detail.conflict.trunk)) files = [...new Set(detail.conflict.files)];
+ if (event.event_kind === 'hold_item') {
+ files = conflictNoteFiles(detail.reason);
+ if (!files && /\bconflicts?\b/iu.test(detail.reason ?? '')) {
+ if (!unattributed.has(event.item_id)) unattributed.set(event.item_id, []);
+ unattributed.get(event.item_id).push(evidence);
+ }
+ }
+ for (const file of files ?? []) {
+ if (!byFile.has(file)) byFile.set(file, { file, reopens: 0, holds: 0, items: new Set(), events: [] });
+ const entry = byFile.get(file);
+ entry[event.event_kind === 'reopen' ? 'reopens' : 'holds'] += 1;
+ entry.items.add(event.item_id);
+ entry.events.push({ ...evidence, source: event.event_kind === 'reopen' ? 'typed-conflict' : 'machine-note-syntax' });
+ }
+ }
+ const conflictFiles = [...byFile.values()].map(entry => ({ ...entry, items: [...entry.items].sort((a, b) => a - b),
+ events: entry.events.sort((a, b) => a.id - b.id) })).sort((a, b) => b.items.length - a.items.length || a.file.localeCompare(b.file));
+ return { conflictWindow: { days: WINDOW_DAYS, since: new Date(since).toISOString(), until: new Date(until).toISOString(), thresholdItems: HOT_ITEMS },
+ conflictFiles, hotFiles: conflictFiles.filter(file => file.items.length >= HOT_ITEMS),
+ unattributedHolds: [...unattributed].sort(([a], [b]) => a - b).map(([item, events]) => ({ item, events })) };
+}
+
+/** Render exact paths safely on one terminal or Markdown line without changing their stored identity. */
+function displayFile(file) {
+ return JSON.stringify(file).replaceAll('|', '\\u007c').replaceAll('\u2028', '\\u2028').replaceAll('\u2029', '\\u2029');
+}
+
+/** Name the cost and missing attribution without presenting a split suggestion as a proved rule. */
+export function conflictLines(report) {
+ const lines = report.hotFiles.map(file => `hot file ${displayFile(file.file)}: ${file.reopens} conflict reopens, ${file.holds} conflict holds in 14 days; items ${file.items.map(id => '#' + id).join(', ')}; propose a split with pullboard rigor --draft-splits (coordinator, person approval required)`);
+ if (report.unattributedHolds.length) lines.push(`conflict holds without attributable files: ${report.unattributedHolds.map(entry => '#' + entry.item + ' (' + entry.events.length + ')').join(', ')}; no paths inferred from prose`);
+ return lines;
+}
+
+/** A durable ordinary proposal names the file and exact contributing events; it is never rigor: proof. */
+export function splitProposal(file) {
+ return { text: `Consider splitting ${displayFile(file.file)} into independently owned modules (for example, one module per command). It caused ${file.reopens} conflict reopens and ${file.holds} conflict holds across items ${file.items.map(id => '#' + id).join(', ')} in 14 days; review the architecture before deciding.`,
+ source: 'conflict-split:' + Buffer.from(JSON.stringify({ file: file.file, events: file.events.map(event => event.id) })).toString('base64url') };
+}
+
+/** Suppress a live same-file proposal or the same previously decided evidence, including board reservations. */
+export function splitAlreadyProposed(rows, file) {
+ const proposal = splitProposal(file);
+ return rows.some(row => {
+ const source = /(?:^|\s)Source: (conflict-split:([A-Za-z0-9_-]+))(?:\s|$)/u.exec(row.text ?? '');
+ if (!source) return false;
+ try {
+ const previous = JSON.parse(Buffer.from(source[2], 'base64url').toString('utf8'));
+ return previous.file === file.file && (row.status === 'draft' || source[1] === proposal.source);
+ } catch { return false; /* Unrelated or malformed source text cannot suppress a proposal. */ }
+ });
+}
diff --git a/src/rigor-splits.js b/src/rigor-splits.js
new file mode 100644
index 00000000..8c4087ca
--- /dev/null
+++ b/src/rigor-splits.js
@@ -0,0 +1,24 @@
+/** Ordinary architectural suggestions retain coordinator and person authority, without red/green proof [D1]. */
+import { loadDoctrine } from './doctrine.js';
+import { proposeDoctrine } from './doctrine-rulings.js';
+import { Refused } from './refused.js';
+import { splitAlreadyProposed, splitProposal } from './rigor-conflicts.js';
+
+/** Reserve and write pending review-gated rulings through the existing ordinary doctrine path. */
+export async function draftConflictSplits(ctx, report, { read, reserve }) {
+ const state = read();
+ if (!ctx.info.isMain || !state.coordinator) throw new Refused('COORDINATOR_ONLY', 'only the coordinator proposes standing split rulings; ask your coordinator to run pullboard rigor --draft-splits from the main checkout');
+ const splitDrafts = [];
+ for (const file of report.hotFiles) {
+ const doctrine = loadDoctrine(ctx.info.root, ctx.config);
+ if (splitAlreadyProposed([...doctrine.repo.rows, ...state.rows], file)) continue;
+ const suggestion = splitProposal(file);
+ const values = { source: suggestion.source, gate: 'review' };
+ const planned = proposeDoctrine({ ...ctx, doctrine }, values, suggestion.text, { reserved: state.rows.map(row => row.id), write: false });
+ const entry = await reserve({ ...planned.row, target: 'doctrine' });
+ const written = proposeDoctrine({ ...ctx, doctrine }, values, suggestion.text, { id: entry.id });
+ state.rows.push({ ...written.row, target: 'doctrine' });
+ splitDrafts.push(written);
+ }
+ return splitDrafts;
+}
diff --git a/test/rigor-checks.test.js b/test/rigor-checks.test.js
index a588c0c8..0ed5386b 100644
--- a/test/rigor-checks.test.js
+++ b/test/rigor-checks.test.js
@@ -21,6 +21,9 @@ import { testInputProblems } from '../bin/checks/test-inputs.js';
import * as store from '../src/board.js';
import { submitFixture } from './board-submit-fixture.js';
import { createE2eHelpers } from './e2e-helpers.js';
+import { loadDoctrine } from '../src/doctrine.js';
+import { conflictNote } from '../src/trunk-conflict.js';
+import { conflictNoteFiles, conflictReport } from '../src/rigor-conflicts.js';
const conflictE2e = createE2eHelpers();
after(conflictE2e.cleanup);
@@ -167,6 +170,72 @@ test('rigor reports a file that keeps causing merge conflicts [D1,C7]', () => {
assert.equal(readFileSync(join(box.repo, 'SPEC.md'), 'utf8'), before, 'reporting alone does not draft or approve a rule');
});
+
+test('a hot file becomes a draft split proposal [D1,C7]', () => {
+ const box = conflictHistory();
+ const original = loadDoctrine(box.repo).repo.rows;
+ const beforeSpec = readFileSync(join(box.repo, 'SPEC.md'), 'utf8');
+ const run = box.run(box.repo, 'rigor', '--draft-splits', '--json');
+ assert.equal(run.code, 0, run.out + run.err);
+ const report = JSON.parse(run.out);
+ assert.equal(report.splitDrafts.length, 1);
+ const draft = report.splitDrafts[0];
+ const doctrine = loadDoctrine(box.repo);
+ const row = doctrine.repo.rows.find(row => row.id === draft.row.id);
+ assert.equal(row.status, 'draft', 'the person has not approved this architectural advice');
+ assert.equal(row.gate, 'review', 'a suggestion has no fabricated executable proof');
+ assert.match(row.text, /splitting "src\/cli\.js"/u);
+ assert.match(row.text, /one module per command/u);
+ assert.match(row.text, /Source: conflict-split:/u);
+ assert.doesNotMatch(row.text, /Source: rigor:/u);
+ assert.deepEqual(doctrine.repo.rows.filter(row => row.id !== draft.row.id), original, 'existing judgments remain unchanged');
+ assert.equal(readFileSync(join(box.repo, 'SPEC.md'), 'utf8'), beforeSpec);
+ const written = readFileSync(doctrine.repo.file, 'utf8');
+ const again = box.run(box.repo, 'rigor', '--draft-splits', '--json');
+ assert.equal(again.code, 0, again.out + again.err);
+ assert.deepEqual(JSON.parse(again.out).splitDrafts, [], 'restarts do not duplicate pending advice');
+ assert.equal(readFileSync(doctrine.repo.file, 'utf8'), written);
+ const lane = box.run(box.web, 'rigor', '--draft-splits', '--json');
+ assert.equal(lane.code, 1, lane.out + lane.err);
+ assert.match(lane.out + lane.err, /COORDINATOR_ONLY/u);
+ const board = store.openBoard(join(box.repo, '.git/pullboard/board.sqlite'));
+ try {
+ const reservation = store.rowDrafts(board).find(row => row.id === draft.row.id);
+ assert.equal(reservation.target, 'doctrine', 'the ordinary draft is durably reserved on the project board');
+ assert.equal(reservation.gate, 'review');
+ } finally { store.closeBoard(board); }
+});
+
+test('conflict history counts exact notes and exposes unattributed holds [D1]', () => {
+ const now = new Date('2026-10-20T12:00:00Z');
+ /** An ordinary event-shaped fixture, with no synthetic database writes. */
+ const event = (id, item, kind, detail, at = now.toISOString()) => ({ event_id: id, item_id: item, event_kind: kind, event_at: at, event_detail: JSON.stringify(detail) });
+ const typed = event(1, 1, 'reopen', { conflict: { files: ['src/cli.js', 'src/one.js'], trunk: 'a'.repeat(40) } });
+ const held = event(2, 2, 'hold_item', { reason: conflictNote({ files: ['src/cli.js'], trunk: 'b'.repeat(40) }) });
+ const history = [typed, held, held, event(3, 2, 'unhold_item', {}),
+ event(4, 3, 'hold_item', { reason: 'a merge conflict somewhere in src/guess.js' }),
+ event(5, 4, 'hold_item', { reason: 'waiting for a person' }),
+ event(6, 5, 'reopen', { conflict: { files: ['src/old.js'], trunk: 'a'.repeat(40) } }, '2026-10-06T11:59:59Z'),
+ event(7, 6, 'hold_item', { reason: conflictNote({ files: ['src/future.js'], trunk: 'b'.repeat(40) }) }, '2026-10-20T12:00:01Z'),
+ event(8, 7, 'hold_item', { reason: conflictNote({ files: ['src/boundary.js'], trunk: 'b'.repeat(40) }) }, '2026-10-06T12:00:00Z')];
+ const report = conflictReport(history, { now });
+ assert.deepEqual(report.hotFiles.map(file => [file.file, file.reopens, file.holds, file.items]), [['src/cli.js', 1, 1, [1, 2]]]);
+ assert.deepEqual(report.hotFiles[0].events.map(event => event.source), ['typed-conflict', 'machine-note-syntax']);
+ assert.deepEqual(report.unattributedHolds.map(entry => entry.item), [3]);
+ assert.deepEqual(report.conflictFiles.map(file => file.file).sort(), ['src/boundary.js', 'src/cli.js', 'src/one.js']);
+ assert.equal(conflictReport([typed, event(9, 1, 'hold_item', { reason: conflictNote({ files: ['src/cli.js'], trunk: 'b'.repeat(40) }) })], { now }).hotFiles.length, 0, 'repeated events on one item cannot meet the distinct-item threshold');
+});
+
+test('canonical conflict notes preserve exact quoted paths [D1]', () => {
+ const files = ['src/plain.js', 'src/a, b.js', 'src/"quoted".js', 'src/a|b.js', 'src/line\nend.js', 'src/日本語.js'];
+ const note = conflictNote({ files, trunk: 'a'.repeat(40) });
+ assert.deepEqual(conflictNoteFiles(note), files);
+ for (const invalid of [note + ' extra', 'discussion: ' + note, note.replace(', ', ',')]) assert.equal(conflictNoteFiles(invalid), null);
+ assert.equal(conflictNoteFiles(conflictNote({ files: ['', 'src/a.js'], trunk: 'a'.repeat(40) })), null);
+ assert.equal(conflictNoteFiles(conflictNote({ files: ['src/a.js', 'src/a.js'], trunk: 'a'.repeat(40) })), null);
+ assert.equal(conflictNoteFiles(conflictNote({ files: ['src/\0bad.js'], trunk: 'a'.repeat(40) })), null);
+});
+
test('Pullboard\'s four checks count what main has [D1, C7]', async (t) => {
assert.equal(typeof fileSizeProblems, 'function', 'the size check imports without running');
assert.equal([testNameProblems, emptyCatchProblems, testInputProblems].every((find) => typeof find === 'function'), true);