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.

fix(core): retain local doctrine stale checks [D1,S19,V3]

Corey Olson897145286051
diff --cc src/cli.js
index 3d2df9c3,062d6c58..a91f589c
--- a/src/cli.js
+++ b/src/cli.js
@@@ -248,9 -250,8 +255,10 @@@ const OPTIONS =
text: { type: 'string' },
gate: { type: 'string' },
aim: { type: 'boolean' },
+ doctrine: { type: 'boolean' },
+ source: { type: 'string' },
section: { type: 'string' },
+ blueprint: { type: 'string' },
route: { type: 'string' },
family: { type: 'string' },
model: { type: 'string' },
@@@ -1103,48 -1128,6 +1136,69 @@@ function resumeReleaseNotes(info)
return releases.length ? { releases: releases.slice(0, 3), omitted: Math.max(0, releases.length - 3), notes: 'CHANGELOG.md' } : null;
}
+/** Read accepted-main doctrine plus applied person decisions, independent of this checkout's age. */
+function agentDoctrine(ctx, board) {
+ const root = ctx.info.root;
+ const primary = mainCheckout(root);
+ const retained = primary?.commit ? null : trunkRef(root);
+ const commit = primary?.commit ?? (retained ? resolveCommit(root, retained) : null);
+ let doctrine = ctx.doctrine;
+ let name = doctrine.name;
+ if (commit && tryGit(root, ['show', `${commit}:${CONFIG_FILE}`]).status === 0) {
+ const config = policyAt(root, commit).config;
+ name = config.practice;
+ let source = tryGit(root, ['show', `${commit}:${name}`]);
+ if (source.status !== 0 && [DOCTRINE_FILE, LEGACY_DOCTRINE_FILE].includes(name)) {
+ const alias = name === DOCTRINE_FILE ? LEGACY_DOCTRINE_FILE : DOCTRINE_FILE;
+ const other = tryGit(root, ['show', `${commit}:${alias}`]);
+ if (other.status === 0) { name = alias; source = other; }
+ }
+ doctrine = doctrineFromSource(source.status === 0 ? source.stdout : null, name);
+ }
+ const entry = git(root, ['worktree', 'list', '--porcelain', '-z']).split('\0')[0];
+ const primaryRoot = entry.startsWith('worktree ') ? entry.slice('worktree '.length) : null;
+ const file = primaryRoot && join(primaryRoot, name);
+ const current = file && existsSync(file) ? readFileSync(file, 'utf8') : null;
+ return appliedDoctrine(doctrine, store.rowDecisions(board), current);
+}
+
++/** Compare frozen rows with shared rules plus actual local edits, without shadowing newer main rules. */
++function staleDoctrineRows(ctx, doctrine) {
++ const root = ctx.info.root;
++ const working = loadDoctrine(root, ctx.config);
++ let source = tryGit(root, ['show', `HEAD:${working.name}`]);
++ if (source.status !== 0 && [DOCTRINE_FILE, LEGACY_DOCTRINE_FILE].includes(working.name)) {
++ const alias = working.name === DOCTRINE_FILE ? LEGACY_DOCTRINE_FILE : DOCTRINE_FILE;
++ source = tryGit(root, ['show', `HEAD:${alias}`]);
++ }
++ const committed = doctrineFromSource(source.status === 0 ? source.stdout : null, working.name);
++ const before = new Map(committed.rows.map(row => [row.id, row]));
++ const current = new Map(working.rows.map(row => [row.id, row]));
++ const rows = new Map(doctrine.rows.map(row => [row.id, row]));
++ for (const id of new Set([...before.keys(), ...current.keys()])) {
++ if (before.get(id)?.text === current.get(id)?.text) continue;
++ if (current.has(id)) rows.set(id, current.get(id));
++ else rows.delete(id);
++ }
++ return [...rows.values()];
++}
++
+/** Record each checkout's displayed approved rules so another checkout keeps its own notices. */
+function resumeDoctrineNotes(info, doctrine) {
+ const record = join(info.gitDir, 'pullboard-checkout', 'resume-doctrine.json');
+ let previous = {};
+ try { previous = JSON.parse(readFileSync(record, 'utf8')); } catch { /* First doctrine resume. */ }
+ if (!previous || typeof previous !== 'object' || Array.isArray(previous)) previous = {};
+ const approved = doctrine.rows.filter(row => row.origin === 'repo' && row.status === 'approved');
+ /** Identify the exact approved guidance this checkout has already displayed. */
+ const fingerprint = row => createHash('sha256').update(JSON.stringify([row.text, row.gate])).digest('hex');
+ const notes = approved.filter(row => previous[row.id] !== fingerprint(row))
+ .map(row => ({ id: 'doctrine:' + row.id, text: row.text, gate: row.gate }));
+ mkdirSync(dirname(record), { recursive: true });
+ writeFileSync(record, JSON.stringify({ ...previous, ...Object.fromEntries(approved.map(row => [row.id, fingerprint(row)])) }) + '\n', { mode: 0o600 });
+ return notes;
+}
+
/** Identify setup from this board's coordinator enrollment, independently of agent flags. */
function setupIdentity(board) {
return { boardId: store.boardId(board),
@@@ -1319,7 -1300,7 +1373,7 @@@ function resumeHere(io)
card.hookProblems = unwiredHookProblems(root);
const { me } = card;
const name = (id) => agentDisplayName(card.agents, ctx.config, id);
- card.stale = staleFrozenItems(card.all, loadSpec(root, ctx.config).rows, doctrine.rows).map((item) => ({ ...item, ...staleItemFinding(item) }));
- card.stale = staleFrozenItems(card.all, loadSpec(root, ctx.config).rows, ctx.doctrine.rows).map((item) => ({ ...item, ...staleItemFinding(item) }));
++ card.stale = staleFrozenItems(card.all, loadSpec(root, ctx.config).rows, staleDoctrineRows(ctx, doctrine)).map((item) => ({ ...item, ...staleItemFinding(item) }));
if (isMain) {
card.staleFollowUps = { count: card.stale.length + card.staleIntegrations.length,
list: 'pullboard resume --json', items: card.stale, integrations: card.staleIntegrations };
diff --cc src/help.js
index 22a2f1d4,4faff8fb..1e3f604e
--- a/src/help.js
+++ b/src/help.js
@@@ -148,9 -150,12 +150,13 @@@ Spe
pullboard spec show <id> | unmet [--must] | signoff <ids> [--by <principal>]
signoff: --note "what was checked" stays with the receipt
pullboard spec draft <text> [--section <letter>] [--aim] [--gate "<gate>"] any agent appends a draft row; never approves it
- --section chooses the section prefix; defaults to G
+ [--doctrine --source "<shout id or chat, date>"] the coordinator proposes a sourced doctrine ruling
+ --section chooses the section prefix; defaults to G, or DR with --doctrine
Defaults to must and gate review.
+ pullboard blueprint add <name or file> add a blueprint's rules and questions as drafts, and its starter items
+ bundled: web-app; nothing is approved, and a repeat adds nothing
+ pullboard blueprint save [file] [--name <name>] [--title "<title>"] write approved rules and answered questions as a blueprint
+ never items, notes, paths, emails or names; file defaults to <project>.blueprint.json
pullboard spec signers add [--key <path>] [--by <principal>] opt into SSH-signed sign-offs
principal defaults to Git user.email; --by overrides it
pullboard spec approve <ids> | decline <ids> --reason "why" the person's exact-row decision
diff --cc test/doctrine-rulings.test.js
index 4e3ad60a,00000000..95728643
mode 100644,000000..100644
--- a/test/doctrine-rulings.test.js
+++ b/test/doctrine-rulings.test.js
@@@ -1,108 -1,0 +1,151 @@@
+/** Person-approved rulings reach independent, unadvanced Git checkouts [D1,D3,B27]. */
+import assert from 'node:assert/strict';
+import {
+ readFileSync,
+ writeFileSync,
+} from 'node:fs';
+import { join } from 'node:path';
+import { test } from 'node:test';
+import { createE2eHelpers } from './e2e-helpers.js';
+import { parseSpec } from '../src/spec.js';
+
+test('a ruling the person approves reaches every agent once [D1,D3,B27]', (t) => {
+ const e2e = createE2eHelpers();
+ t.after(e2e.cleanup);
+ const box = e2e.project('true');
+ const other = join(box.dir, 'web-2');
+ box.git(box.repo, 'worktree', 'add', '-q', '-b', 'web/two', other);
+ const joined = box.run(other, 'join', 'web', '--model', 'Fixture');
+ assert.equal(joined.code, 0, joined.err || joined.out);
+ const checkouts = [box.repo, box.web, other];
+ const oldHeads = checkouts.map(path => box.git(path, 'rev-parse', 'HEAD'));
+ /** Run a real CLI command and require its public, versioned successful result. */
+ function json(path, ...args) {
+ const result = box.run(path, ...args, '--json');
+ assert.equal(result.code, 0, result.err || result.out);
+ return JSON.parse(result.out);
+ }
+ for (const path of checkouts) assert.deepEqual(json(path, 'resume').doctrineNotes ?? [], []);
+ const file = join(box.repo, 'DOCTRINE.md');
+ const before = readFileSync(file, 'utf8');
+ const missing = box.run(box.repo, 'spec', 'draft', 'Keep the approved ruling.', '--doctrine', '--json');
+ assert.notEqual(missing.code, 0, 'a proposal without its source is refused');
+ assert.equal(readFileSync(file, 'utf8'), before, 'a source-less proposal writes no row');
+
+ const rule = 'A builder escalates after two failed attempts.';
+ const drafted = json(box.repo, 'spec', 'draft', rule, '--doctrine', '--source', 'chat, 2026-10-16');
+ assert.match(JSON.parse(missing.out).error.message, /source/iu);
+ assert.equal(drafted.id, 'doctrine:' + drafted.row.id);
+ const row = parseSpec(readFileSync(file, 'utf8')).rows.find(row => row.id === drafted.row.id);
+ assert.equal(row.status, 'draft');
+ assert.ok(row.text.includes(rule) && row.text.includes('chat, 2026-10-16'), 'the proposed row keeps its source');
+ const foreign = box.run(box.web, 'spec', 'draft', 'A builder cannot propose standing rules.',
+ '--doctrine', '--source', 'shout 42', '--json');
+ assert.notEqual(foreign.code, 0);
+ assert.equal(JSON.parse(foreign.out).error.code, 'COORDINATOR_ONLY');
+ for (const path of checkouts) assert.deepEqual(json(path, 'resume').doctrineNotes, [], 'draft rulings are not announced');
+ box.git(box.repo, 'add', 'DOCTRINE.md');
+ box.git(box.repo, 'commit', '-q', '-m', 'docs(doctrine): propose ruling');
+ for (const path of checkouts) assert.deepEqual(json(path, 'resume').doctrineNotes, [], 'a committed draft is not in force either');
+ json(box.repo, 'spec', 'approve', drafted.id);
+ for (const path of checkouts) assert.deepEqual(json(path, 'resume').doctrineNotes, [], 'pending apply is not in force');
+ json(box.repo, 'spec', 'apply');
+ const mainNotes = json(box.repo, 'resume').doctrineNotes;
+ assert.equal(mainNotes.length, 1);
+ assert.equal(mainNotes[0].id, drafted.id);
+ assert.equal(mainNotes[0].text, row.text);
+ const text = box.run(box.web, 'resume');
+ assert.equal(text.code, 0, text.err || text.out);
+ assert.ok(text.out.includes(`new doctrine ${drafted.id} — ${row.text}`));
+ assert.deepEqual(json(other, 'resume').doctrineNotes, mainNotes, 'each checkout sees the same approved ruling');
+ for (const path of checkouts) assert.deepEqual(json(path, 'resume').doctrineNotes, [], 'the notice is consumed only in this checkout');
+ assert.equal(box.git(box.web, 'rev-parse', 'HEAD'), oldHeads[1]);
+ assert.equal(box.git(other, 'rev-parse', 'HEAD'), oldHeads[2]);
+ assert.ok(!readFileSync(join(box.web, 'DOCTRINE.md'), 'utf8').includes(rule), 'no fixture silently synchronizes the old worktree');
+
+ const item = json(box.repo, 'add', 'web', 'Follow the approved ruling', '--specs', drafted.id,
+ '--criterion', 'The builder follows the approved ruling.', '--check', 'true').item;
+ json(box.web, 'claim', String(item.item_id));
+ const frozen = JSON.parse(json(box.web, 'show', String(item.item_id)).item_frozen);
+ assert.deepEqual(frozen.rows.map(row => [row.id, row.text]), [[drafted.id, row.text]], 'claim freezes shared approved text');
+ assert.equal(box.git(box.web, 'rev-parse', 'HEAD'), oldHeads[1], 'a doctrine citation does not advance the checkout');
+ box.git(box.repo, 'add', 'DOCTRINE.md');
+ box.git(box.repo, 'commit', '-q', '-m', `docs(doctrine): approve ruling [${drafted.id}]`);
+
+ const replacement = 'A builder stops after two failed attempts. Source: chat, 2026-10-16';
+ json(box.repo, 'spec', 'approve', drafted.id, '--text', replacement);
+ assert.deepEqual(json(box.web, 'resume').stale, [], 'an unapplied change does not replace the in-force ruling');
+ json(box.repo, 'spec', 'apply');
+ const changed = json(box.web, 'resume');
+ assert.ok(changed.stale.some(entry => entry.id === item.item_id && entry.rows.includes(drafted.id)), 'the old checkout detects the changed frozen row');
+ assert.equal(changed.doctrineNotes[0].text, replacement);
+ const again = json(box.web, 'resume');
+ assert.deepEqual(again.doctrineNotes, []);
+ assert.ok(again.stale.some(entry => entry.id === item.item_id), 'staleness remains after its one-time notice');
+
+ const declined = json(box.repo, 'spec', 'draft', 'A ruling the person declines.', '--doctrine', '--source', 'shout 42');
+ json(box.repo, 'spec', 'decline', declined.id, '--reason', 'The person declines this proposal.');
+ json(box.repo, 'spec', 'apply');
+ assert.ok(json(other, 'resume').doctrineNotes.every(note => note.id !== declined.id), 'declined rulings are never announced');
+
+ box.git(box.repo, 'add', 'DOCTRINE.md');
+ box.git(box.repo, 'commit', '-q', '-m', `docs(doctrine): revise ruling [${drafted.id}]`);
+ const approvedSource = readFileSync(file, 'utf8');
+ const retiredSource = approvedSource.replace(`- ${drafted.row.id} [approved, must]`, `- ${drafted.row.id} [retired, must]`);
+ assert.notEqual(retiredSource, approvedSource);
+ writeFileSync(file, retiredSource);
+ box.git(box.repo, 'add', 'DOCTRINE.md');
+ box.git(box.repo, 'commit', '-q', '-m', 'docs(doctrine): retire ruling');
+ // An old applied receipt must not revive a retired committed rule via an unstaged restoration.
+ writeFileSync(file, approvedSource);
+ assert.ok(json(other, 'resume').doctrineNotes.every(note => note.id !== drafted.id), 'committed retirement wins over a stale receipt and working-copy restoration');
+ const retiredItem = json(box.repo, 'add', 'web', 'Do not revive the retired ruling', '--specs', drafted.id,
+ '--criterion', 'A stale applied receipt cannot revive committed retirement.', '--check', 'true').item;
+ const refused = box.run(other, 'claim', String(retiredItem.item_id), '--json');
+ assert.notEqual(refused.code, 0, 'the stale receipt cannot make a retired rule claimable');
+ assert.equal(JSON.parse(refused.out).error.code, 'UNKNOWN_SPEC');
+ assert.equal(json(other, 'show', String(retiredItem.item_id)).item_status, 'open', 'refusal leaves the item unclaimed');
+});
++
++test('local doctrine edits flag their frozen row without hiding shared approved rulings [D1,S19,V3]', (t) => {
++ const e2e = createE2eHelpers();
++ t.after(e2e.cleanup);
++ const box = e2e.project('true');
++ const oldHead = box.git(box.web, 'rev-parse', 'HEAD');
++ /** Exercise the real private CLI and retain its complete successful JSON result. */
++ function json(path, ...args) {
++ const result = box.run(path, ...args, '--json');
++ assert.equal(result.code, 0, result.err || result.out);
++ return JSON.parse(result.out);
++ }
++ const drafted = json(box.repo, 'spec', 'draft', 'Keep shared approved guidance visible.',
++ '--doctrine', '--source', 'chat, 2026-10-16');
++ box.git(box.repo, 'add', 'DOCTRINE.md');
++ box.git(box.repo, 'commit', '-q', '-m', 'docs(doctrine): propose shared guidance');
++ json(box.repo, 'spec', 'approve', drafted.id);
++ json(box.repo, 'spec', 'apply');
++ const shared = json(box.repo, 'add', 'web', 'Follow shared guidance', '--specs', drafted.id,
++ '--criterion', 'Shared approved guidance stays in force.', '--check', 'true').item;
++ const edited = json(box.repo, 'add', 'web', 'Follow inherited guidance', '--specs', 'doctrine:PB1',
++ '--criterion', 'A changed local row remains visible to diagnostics.', '--check', 'true').item;
++ for (const item of [shared, edited]) {
++ json(box.web, 'claim', String(item.item_id));
++ json(box.web, 'release', String(item.item_id));
++ }
++ const frozen = [shared, edited].map(item => json(box.web, 'show', String(item.item_id)).item_frozen);
++ const baseline = json(box.web, 'resume');
++ assert.deepEqual(baseline.stale, [], 'unchanged old-checkout files retain the shared approved rule');
++ assert.ok(baseline.doctrineNotes.some(note => note.id === drafted.id));
++ const file = join(box.web, 'DOCTRINE.md');
++ const original = readFileSync(file, 'utf8');
++ assert.ok(!original.includes('Keep shared approved guidance visible.'));
++ writeFileSync(file, original + '\n## Local diagnostic edit\n- PB1 [approved, must] A changed local inherited rule. | gate: true\n');
++ const changed = json(box.web, 'resume');
++ assert.deepEqual(changed.stale.map(item => [item.id, item.rows]), [[edited.item_id, ['doctrine:PB1']]],
++ 'only the locally edited rule is stale; shared approved guidance is still available');
++ assert.deepEqual(changed.doctrineNotes, [], 'an unapproved working-copy edit is not announced as new guidance');
++ assert.equal(box.git(box.web, 'rev-parse', 'HEAD'), oldHead, 'diagnostics never advance the old checkout');
++ assert.deepEqual([shared, edited].map(item => json(box.web, 'show', String(item.item_id)).item_frozen), frozen);
++ writeFileSync(file, original);
++ assert.deepEqual(json(box.web, 'resume').stale, [], 'restoring the working file clears only its diagnostic change');
++});