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
feat(doctrine): name the repo rules DOCTRINE.md [D1,D2,A5]
Corey Olsond4417d5e4884
diff --git a/docs/formats.md b/docs/formats.mdindex 1560db37..3144c3ff 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -2,7 +2,9 @@This page describes the text files people edit and the SQLite board kept inside `.git`. The row parser is in `src/spec.js`; board declarations and migrations are in `src/board.js`; lifecycle guards are generated from `src/machine.js`.-## SPEC.md and PRACTICE.md+## SPEC.md and DOCTRINE.md++Doctrine means the house rules for agentic development. New repos use `DOCTRINE.md`; existing `PRACTICE.md` files keep working. Rename a legacy file with `git mv -- PRACTICE.md DOCTRINE.md`. Keeping both names is refused because they define the same repo doctrine. The configuration and API retain their `practice` field names; an explicitly configured custom path still works.Both files use the shared row grammar in `src/spec.js`, whose version is `SPEC_GRAMMAR_VERSION`. Either file may declare the current version on its own line as `<!-- pullboard-grammar N -->`; without a marker, the file uses the current grammar. A marker inside a fenced code example is ignored. The parser accepts only the version it reads and refuses a mismatched or invalid marker with `A5_GRAMMAR_VERSION`; upgrade Pullboard or use a file written for its grammar. Pullboard does not rewrite these files during an upgrade.diff --git a/src/cli.js b/src/cli.jsindex 1ccc00a7..a16f17cf 100644--- a/src/cli.js+++ b/src/cli.js@@ -10,7 +10,7 @@ import { pathToFileURL } from 'node:url';import { parseArgs } from 'node:util';import * as store from './board.js';import { CONFIG_FILE, COORDINATOR, loadConfig } from './config.js';-import { loadDoctrine } from './doctrine.js';+import { doctrineHistory, loadDoctrine } from './doctrine.js';import { digestOf, gateReport, runGate, runShell } from './gate.js';import { bareWorktreeFinding, contains, differFromHead, git, headCommit, headTree, isClean, repoInfo, resolveCommit, tryGit, untracked } from './git.js';import {@@ -50,7 +50,7 @@ import { listResources } from './resources.js';import { citedTestFiles, rowEvidence, rowStage } from './evidence.js';import { exportView, serveView } from './serve.js';import { serveApi } from './api.js';-import { doctorProblems } from './doctor.js';+import { doctorProblems, doctrineProblems } from './doctor.js';import { mainPolicy, itemPolicy, submissionPaths, frozenCheck, checkAtCommit, dependencySnapshots } from './trusted-policy.js';import { exportBoard, importBoard } from './exchange.js';import { addSigner, assertRequiredSigners, defaultPrincipal, hasSignerFile } from './signature.js';@@ -136,10 +136,10 @@ Receiptspullboard log [id] every move, in orderSpec- pullboard spec --json parsed SPEC.md and PRACTICE.md rows as JSON+ pullboard spec --json parsed SPEC.md and doctrine rows as JSONpullboard forget <path> remove a repo from this machine's project list- pullboard spec check lint SPEC.md and PRACTICE.md- pullboard spec view [--out file] the spec, open questions, sign-offs and practice as one page+ pullboard spec check lint SPEC.md and the doctrine (house rules for agentic development)+ pullboard spec view [--out file] the spec, open questions, sign-offs and doctrine as one pagepullboard spec show <id> | unmet [--must] | signoff <ids> [--by <principal>]signoff: --note "what was checked" stays with the receiptpullboard spec signers add [--key <path>] [--by <principal>] opt into SSH-signed sign-offs@@ -1055,7 +1055,7 @@ function readCommands(io, { first, second, rest, values }) {return 1;}const ctx = context(io);- const problems = doctorProblems(ctx.file, ctx.info.root, tryGit);+ const problems = [...doctorProblems(ctx.file, ctx.info.root, tryGit), ...doctrineProblems(ctx.info.root, ctx.config)];io.result?.({ problems });if (!problems.length) {io.say('board is clean');@@ -1668,7 +1668,7 @@ function specCommand(io, { first, second, rest, values }) {for (const [name, parsed] of files) {const findings = lintSpec(parsed);findings.forEach((finding) => messages.push(`${name}:${finding.line} ${finding.id ?? ''} ${finding.level}: ${finding.message}`.replace(' ', ' ')));- const history = committedIds(ctx.info.root, name);+ const history = parsed === practice ? doctrineHistory(ctx.info.root, name) : committedIds(ctx.info.root, name);const cited = name === ctx.config.spec ? citations(ctx, history) : new Map();const lost = permanenceProblems(parsed === practice ? practice.repo : parsed, { committed: history.ids, cited });lost.forEach((problem) => messages.push(`${name}: ${problem.id} error: ${problem.message}`));diff --git a/src/config.js b/src/config.jsindex 6b00548c..abbd4831 100644--- a/src/config.js+++ b/src/config.js@@ -8,6 +8,8 @@ import { Refused } from './refused.js';export const CONFIG_FILE = 'pullboard.json';export const COORDINATOR = 'coordinator';+export const DOCTRINE_FILE = 'DOCTRINE.md';+export const LEGACY_DOCTRINE_FILE = 'PRACTICE.md';const LANE_NAME_RE = /^[a-z][a-z0-9-]{0,30}$/;const DURATION_RE = /^(\d+)(m|h|d)$/;@@ -34,7 +36,7 @@ const COMMIT_TYPES = [export function defaults() {return {spec: 'SPEC.md',- practice: 'PRACTICE.md',+ practice: DOCTRINE_FILE,gate: '',lease: '2h',reviewLease: '30m',@@ -141,7 +143,7 @@ export function configProblems(config) {}}if (typeof config.spec !== 'string' || !config.spec) problems.push('"spec" names a file');- if (typeof config.practice !== 'string' || !config.practice) problems.push('"practice" names a file');+ if (typeof config.practice !== 'string' || !config.practice) problems.push('"practice" names the doctrine file');if (typeof config.gate !== 'string') problems.push('"gate" is a shell command, like "npm test"');if (!['any', COORDINATOR].includes(config.verify?.policy)) {problems.push('"verify.policy" is "any" (any other agent) or "coordinator"');@@ -187,7 +189,19 @@ export function loadConfig(root) {if (!existsSync(file)) {throw new Refused('NO_CONFIG', `no ${CONFIG_FILE} in ${root}; run: pullboard init`);}- return configFromSource(readFileSync(file, 'utf8'));+ const config = configFromSource(readFileSync(file, 'utf8'));+ return { ...config, practice: doctrineFile(root, config.practice) };+}++/** Resolve the doctrine's current name while preserving legacy and explicitly configured paths. */+export function doctrineFile(root, name = DOCTRINE_FILE) {+ if (![DOCTRINE_FILE, LEGACY_DOCTRINE_FILE].includes(name)) return name;+ const current = existsSync(join(root, DOCTRINE_FILE));+ const legacy = existsSync(join(root, LEGACY_DOCTRINE_FILE));+ if (current && legacy) {+ throw new Refused('BAD_CONFIG', `${DOCTRINE_FILE} and ${LEGACY_DOCTRINE_FILE} both define the repo doctrine; restore one doctrine file: merge their rules into ${DOCTRINE_FILE} and remove ${LEGACY_DOCTRINE_FILE}`);+ }+ return current ? DOCTRINE_FILE : legacy ? LEGACY_DOCTRINE_FILE : name;}/** Parse committed coordinator settings with the same defaults and validation as local settings. */diff --git a/src/doctor.js b/src/doctor.jsindex a96efca7..06edb82d 100644--- a/src/doctor.js+++ b/src/doctor.js@@ -1,5 +1,7 @@/** Read-only integrity checks for a pullboard board file (A6). */import { existsSync } from 'node:fs';+import { join } from 'node:path';+import { DOCTRINE_FILE, LEGACY_DOCTRINE_FILE } from './config.js';import { DatabaseSync } from 'node:sqlite';import { checkAtCommit, submissionPaths, dependencySnapshots } from './trusted-policy.js';import { BLANKS, STATES, storeTriggers } from './machine.js';@@ -7,6 +9,12 @@ import { BLANKS, STATES, storeTriggers } from './machine.js';import { readEventLogVersion, SCHEMA_VERSION } from './board.js';const blankCharacters = new Set(BLANKS.map((point) => String.fromCodePoint(point)));+/** Offer the single rename that updates a legacy doctrine without rewriting the repo's rules. */+export function doctrineProblems(root, config) {+ if (config.practice !== LEGACY_DOCTRINE_FILE || !existsSync(join(root, LEGACY_DOCTRINE_FILE))) return [];+ return [finding('DOCTRINE_LEGACY', `${LEGACY_DOCTRINE_FILE} is the legacy name for the repo doctrine`, `git mv -- ${LEGACY_DOCTRINE_FILE} ${DOCTRINE_FILE}`)];+}+/*** Check a board and its git pins without opening it through the migrator, which repairs boards on* open. `doctor` must report the evidence it sees and leave that evidence untouched.diff --git a/src/doctrine.js b/src/doctrine.jsindex 1db0b275..50292141 100644--- a/src/doctrine.js+++ b/src/doctrine.js@@ -1,5 +1,7 @@/** The shared house rules (D1–D4): one packaged standard and a repo's explicit changes to it. */import { readFileSync } from 'node:fs';+import { DOCTRINE_FILE, LEGACY_DOCTRINE_FILE, doctrineFile } from './config.js';+import { committedIds } from './history.js';import { loadSpec, parseSpec } from './spec.js';export const STANDARD_VERSION = 1;@@ -27,7 +29,7 @@ function declineReason(row) {* duplicate repo rows remain visible to lint, and a decline must state its reason explicitly.*/export function loadDoctrine(root, config = {}) {- const name = config.practice ?? 'PRACTICE.md';+ const name = doctrineFile(root, config.practice);const repo = loadSpec(root, { ...config, spec: name });const standard = standardDoctrine();const inherited = new Set(standard.rows.map((row) => row.id));@@ -61,6 +63,15 @@ export function loadDoctrine(root, config = {}) {};}+/** Retain committed row ids across the conventional filename change, even before its rename commit. */+export function doctrineHistory(root, name) {+ const history = committedIds(root, name);+ if (![DOCTRINE_FILE, LEGACY_DOCTRINE_FILE].includes(name)) return history;+ const other = committedIds(root, name === DOCTRINE_FILE ? LEGACY_DOCTRINE_FILE : DOCTRINE_FILE);+ for (const [id, commit] of other.ids) if (!history.ids.has(id)) history.ids.set(id, commit);+ return { ...history, since: history.since ?? other.since };+}+/** A current, labelled rules list for AGENTS.md and cold-start run packs. */export function doctrineText(doctrine) {return doctrine.rows.map((row) => {diff --git a/src/hooks.js b/src/hooks.jsindex 9e73ebc8..c50c375f 100644--- a/src/hooks.js+++ b/src/hooks.js@@ -6,6 +6,7 @@import { spawnSync } from 'node:child_process';import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';import { join } from 'node:path';+import { DOCTRINE_FILE, LEGACY_DOCTRINE_FILE } from './config.js';import { git, gitChildEnv, tryGit } from './git.js';import { outOfLane } from './lanes.js';import { citedIds, deletedIds, idProblems } from './spec.js';@@ -290,12 +291,15 @@ export function applyFixers(root, fixers) {*/export function deletedRowProblems(root, paths) {return paths.flatMap((path) => {- const before = tryGit(root, ['show', `HEAD:${path}`]);- if (before.status !== 0) return [];- const staged = tryGit(root, ['show', `:${path}`]);- if (staged.status !== 0) return [`${path} is deleted; ids are permanent: restore it`];+ const names = [DOCTRINE_FILE, LEGACY_DOCTRINE_FILE].includes(path)+ ? [path, path === DOCTRINE_FILE ? LEGACY_DOCTRINE_FILE : DOCTRINE_FILE]+ : [path];+ const before = names.map((name) => ({ ...tryGit(root, ['show', `HEAD:${name}`]), name })).find((file) => file.status === 0);+ if (!before) return [];+ const staged = names.map((name) => ({ ...tryGit(root, ['show', `:${name}`]), name })).find((file) => file.status === 0);+ if (!staged) return [`${before.name} is deleted; ids are permanent: restore it`];return deletedIds(before.stdout, staged.stdout).map(- (id) => `${path}: ${id} is gone; ids are permanent: keep the row and mark it wont (won't build) or retired`,+ (id) => `${staged.name}: ${id} is gone; ids are permanent: keep the row and mark it wont (won't build) or retired`,);});}diff --git a/src/init.js b/src/init.jsindex 9f08fc56..01885b02 100644--- a/src/init.js+++ b/src/init.js@@ -6,7 +6,7 @@*/import { appendFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';import { basename, join } from 'node:path';-import { CONFIG_FILE, COORDINATOR, loadConfig } from './config.js';+import { CONFIG_FILE, COORDINATOR, doctrineFile, loadConfig } from './config.js';import { loadDoctrine } from './doctrine.js';import { installHooks } from './hooks.js';import { Refused } from './refused.js';@@ -168,11 +168,12 @@ export function initRepo({ info, openBoardHere, register, closeBoard }) {throw new Refused('NOT_MAIN', 'run init in the main checkout; worktrees join a lane instead');}const { root } = info;+ const doctrine = existsSync(join(root, CONFIG_FILE)) ? loadConfig(root).practice : doctrineFile(root);const gate = detectGate(root);const notes = [writeNew(join(root, CONFIG_FILE), configTemplate(gate, detectFixers(root)), CONFIG_FILE),writeNew(join(root, 'SPEC.md'), specTemplate(basename(root)), 'SPEC.md'),- writeNew(join(root, 'PRACTICE.md'), practiceTemplate(), 'PRACTICE.md'),+ writeNew(join(root, doctrine), practiceTemplate(), doctrine),...writeAgentDocs(root),...installHooks(root),...installSkills(root),diff --git a/src/templates.js b/src/templates.jsindex db4405a2..c61bf6c9 100644--- a/src/templates.js+++ b/src/templates.js@@ -3,6 +3,7 @@* every coding agent reads (AGENTS.md, which CLAUDE.md points at).*/import { doctrineText, standardDoctrine } from './doctrine.js';+import { DOCTRINE_FILE } from './config.js';export const AGENTS_START = '<!-- pullboard:start -->';export const AGENTS_END = '<!-- pullboard:end -->';@@ -19,7 +20,7 @@ export function configTemplate(gate, fix = []) {gate,...(fix.length ? { fix } : {}),spec: 'SPEC.md',- practice: 'PRACTICE.md',+ practice: DOCTRINE_FILE,verify: { policy: 'any', family: 'off' },lease: '2h',lanes: { review: { owns: [], starts: 'any time: verifiers check submitted work and own no folders' } },@@ -62,7 +63,9 @@ Write each requirement as one row under its section, in this format. The fence k* @returns {string}*/export function practiceTemplate() {- return `# Practice+ return `# Doctrine++Our house rules for agentic development.Inherits Pullboard standard doctrine version 1.@@ -93,7 +96,7 @@ This repo runs on pullboard: a work board, lanes and a spec that live in git. No**Source of truth.** \`SPEC.md\` holds every requirement as a row with an id, like \`G1.2\`. Code follows the spec. Commits cite the ids they serve: \`feat(scope): subject [G1.2]\`. Only a person approves or changes an approved row. Ids are permanent: a row the person cuts stays, marked \`wont\` (won't build), so every commit that cites it keeps its meaning.-**House rules.** This repo inherits Pullboard standard doctrine version 1. PRACTICE.md adds the repo's own rows, overrides a standard rule by its PB id, or declines it with a wont row and its reason as the row text: - PB7 [wont] <why>. Approved rows are in force; follow them as you would the spec. Run pullboard spec --json to read the current merged rules. Re-run pullboard init after changing PRACTICE.md to refresh this managed guidance.+**Doctrine.** Our house rules for agentic development. This repo inherits Pullboard standard doctrine version 1. ${doctrine.repo ? doctrine.name : DOCTRINE_FILE} adds the repo's own rows, overrides a standard rule by its PB id, or declines it with a wont row and its reason as the row text: - PB7 [wont] <why>. Approved rows are in force; follow them as you would the spec. Run pullboard spec --json to read the current merged rules. Re-run pullboard init after changing the doctrine to refresh this managed guidance.### Current doctrinediff --git a/src/view.js b/src/view.jsindex 0d4073be..0804397d 100644--- a/src/view.js+++ b/src/view.js@@ -173,7 +173,7 @@ export function renderSpecView({ title, spec, practice, signoffs, generatedAt, fconst search = '<input class="search" type="search" placeholder="Filter rows" aria-label="Filter rows">';const practicePanel = practice?.exists? sectionsHtml(practice, new Map(), false)- : `<p class="empty">No ${esc(files.practice)} yet. Run pullboard init to start from the standard practice.</p>`;+ : `<p class="empty">No ${esc(files.practice)} yet. Run pullboard init to start from the standard doctrine.</p>`;return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><title>${esc(title || 'Spec')}</title><style>${STYLE}</style></head>@@ -183,7 +183,7 @@ ${spec.intro.length ? `<p class="intro">${esc(spec.intro[0])}</p>` : ''}${summaryHtml(spec, by)}<div class="tabs"><input type="radio" name="tab" id="t-spec" checked><input type="radio" name="tab" id="t-questions"><input type="radio" name="tab" id="t-signoff"><input type="radio" name="tab" id="t-practice">-<nav><label for="t-spec">Spec</label><label for="t-questions">Open questions (${pending.length})</label><label for="t-signoff">Sign-off</label><label for="t-practice">Practice</label></nav>+<nav><label for="t-spec">Spec</label><label for="t-questions">Open questions (${pending.length})</label><label for="t-signoff">Sign-off</label><label for="t-practice">Doctrine</label></nav><section class="panel" id="p-spec">${search}${sectionsHtml(spec, by, true)}</section><section class="panel" id="p-questions">${pending.length ? tableHtml('Waiting on the person', pending, by, false) : '<p class="empty">No open questions.</p>'}</section><section class="panel" id="p-signoff">${search}${approved.length ? tableHtml('Approved rows, unsigned first', bySignoff, by, true) : '<p class="empty">No approved rows yet.</p>'}</section>diff --git a/test/api-http.test.js b/test/api-http.test.jsindex 574f28e3..b749df02 100644--- a/test/api-http.test.js+++ b/test/api-http.test.js@@ -52,7 +52,7 @@ function fixture(t) {const config = JSON.parse(readFileSync(join(root, 'pullboard.json'), 'utf8'));writeFileSync(join(root, 'pullboard.json'), JSON.stringify({ ...config, gate: 'true', lanes: { app: { owns: ['app/'] }, review: { owns: [] } } }));writeFileSync(join(root, 'SPEC.md'), '# HTTP fixture\n\n## Goals\n- G1 [approved, must] Keep the board. | gate: true\n');- writeFileSync(join(root, 'PRACTICE.md'), '');+ writeFileSync(join(root, 'DOCTRINE.md'), '');git('add', '-A');git('commit', '-q', '-m', 'chore: private HTTP fixture');return { root, dir, env, cli, run, commit: git('rev-parse', 'HEAD').trim() };diff --git a/test/api.test.js b/test/api.test.jsindex 03477483..39517506 100644--- a/test/api.test.js+++ b/test/api.test.js@@ -81,7 +81,7 @@ function project() {...config,gate: 'true',spec: 'SPEC.md',- practice: 'PRACTICE.md',+ practice: 'DOCTRINE.md',lanes: {app: { owns: ['app/'], specs: ['G1'] },review: { owns: [] },@@ -89,7 +89,7 @@ function project() {shared: [],}, null, 2)}\n`);writeFileSync(join(repo, 'SPEC.md'), SPEC);- writeFileSync(join(repo, 'PRACTICE.md'), '');+ writeFileSync(join(repo, 'DOCTRINE.md'), '');box.git(repo, 'add', '-A');box.git(repo, 'commit', '-q', '-m', 'chore: set up API fixture');return { ...box, repo, initialized };diff --git a/test/doctrine-name.test.js b/test/doctrine-name.test.jsnew file mode 100644index 00000000..0b7ac83f--- /dev/null+++ b/test/doctrine-name.test.js@@ -0,0 +1,192 @@+/** Canonical doctrine naming keeps legacy repos and the stable state API readable [D1,D2,A5]. */+import assert from 'node:assert/strict';+import { execFileSync, spawnSync } from 'node:child_process';+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';+import { after, test } from 'node:test';+import { projectState } from '../src/serve.js';++const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');+const DOCTRINE = 'DOCTRINE.md';+const PRACTICE = 'PRACTICE.md';+const TEMP_DIRS = [];+const LEGACY_RULES = '# Legacy doctrine\n\n## L · Local\n- L1 [fact] Keep the legacy rule.\n';+const LOCAL_RULE = '\n## L · Local\n- L1 [fact] Keep this repo rule.\n';++/** Remove all fixture repos and their private SQLite homes after the tests finish. */+function cleanup() {+ for (const dir of TEMP_DIRS) rmSync(dir, { recursive: true, force: true });+}++after(cleanup);++/** Quote a shell argument for the private hook shim. */+function shellWord(value) {+ return `'${String(value).replaceAll("'", "'\\''")}'`;+}++/** Make private Git and pullboard homes with a real CLI subprocess and PATH shim. */+function sandbox() {+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-doctrine-name-'));+ TEMP_DIRS.push(dir);+ const bin = join(dir, 'bin');+ mkdirSync(bin);+ writeFileSync(join(bin, 'pullboard'), `#!/bin/sh\nexec ${shellWord(process.execPath)} ${shellWord(BIN)} "$@"\n`);+ chmodSync(join(bin, 'pullboard'), 0o755);+ const env = { ...process.env };+ for (const key of Object.keys(env)) if (key.startsWith('GIT_')) delete env[key];+ Object.assign(env, {+ PATH: `${bin}:${process.env.PATH}`,+ HOME: join(dir, 'home'),+ PULLBOARD_HOME: join(dir, 'pullboard-home'),+ PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),+ GIT_CONFIG_GLOBAL: '/dev/null',+ GIT_CONFIG_NOSYSTEM: '1',+ GIT_AUTHOR_NAME: 'Doctrine name fixture',+ GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Doctrine name fixture',+ GIT_COMMITTER_EMAIL: '[email protected]',+ });+ /** Run Git with the fixture's isolated identity and configuration. */+ function git(cwd, ...args) {+ return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ }+ /** Run one real CLI command and keep stdout, stderr and status available to assertions. */+ function run(cwd, ...args) {+ return spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 20_000 });+ }+ return { dir, env, git, run };+}++/** Initialize a throwaway repo, optionally with the historical filename already present. */+function initializedRepo(box, name, { legacy = false } = {}) {+ const root = join(box.dir, name);+ mkdirSync(root);+ box.git(root, 'init', '-q', '-b', 'main');+ if (legacy) writeFileSync(join(root, PRACTICE), LEGACY_RULES);+ const result = box.run(root, 'init');+ assert.equal(result.status, 0, `${result.stdout}${result.stderr}`);+ return { ...box, root, init: result };+}++/** Append one valid local rule under its own doctrine section. */+function addLocalRule(root, file = DOCTRINE) {+ writeFileSync(join(root, file), `${readFileSync(join(root, file), 'utf8').trimEnd()}${LOCAL_RULE}`);+}++/** Run spec JSON and return its rows after checking the CLI result. */+function specRows(box, root) {+ const result = box.run(root, 'spec', '--json');+ assert.equal(result.status, 0, `${result.stdout}${result.stderr}`);+ return JSON.parse(result.stdout).rows;+}++/** Return doctor findings from the versioned JSON output. */+function doctorProblems(box, root) {+ const result = box.run(root, 'doctor', '--json');+ assert.ok([0, 1].includes(result.status), `${result.stdout}${result.stderr}`);+ return JSON.parse(result.stdout).problems;+}++test('[D1,D2,A5] init chooses DOCTRINE and preserves its rows through checks, JSON, view and rerun', function canonicalDoctrineFile() {+ const box = sandbox();+ const repo = initializedRepo(box, 'new-repo');+ const doctrinePath = join(repo.root, DOCTRINE);+ assert.equal(existsSync(doctrinePath), true, 'a fresh init writes the canonical doctrine file');+ assert.equal(existsSync(join(repo.root, PRACTICE)), false, 'a fresh init does not create the legacy filename');+ const config = JSON.parse(readFileSync(join(repo.root, 'pullboard.json'), 'utf8'));+ assert.equal(config.practice, DOCTRINE, 'the existing config field points at the canonical file');+ const help = box.run(repo.root, 'help', '--all');+ assert.equal(help.status, 0, help.stderr);+ assert.match(help.stdout, /doctrine \(house rules for agentic development\)/u);+ addLocalRule(repo.root);+ const saved = readFileSync(doctrinePath, 'utf8');++ const checked = box.run(repo.root, 'spec', 'check');+ assert.equal(checked.status, 0, `${checked.stdout}${checked.stderr}`);+ assert.match(checked.stdout, /DOCTRINE\.md: 13 rows/u, 'lint output names the actual source file and includes inherited rules');+ assert.ok(specRows(box, repo.root).some((row) => row.id === 'L1' && row.file === DOCTRINE));+ const view = box.run(repo.root, 'spec', 'view', '--out', 'doctrine-view.html');+ assert.equal(view.status, 0, `${view.stdout}${view.stderr}`);+ const html = readFileSync(join(repo.root, 'doctrine-view.html'), 'utf8');+ assert.match(html, /<label for="t-practice">Doctrine<\/label>/u);+ assert.match(html, /DOCTRINE\.md/u);++ const state = projectState(repo.root);+ assert.ok(state.practice.some((row) => row.id === 'L1'), 'API v1 retains the established practice field name');+ assert.equal(Object.hasOwn(state, 'doctrine'), false, 'the filename rename does not rename the API field');+ const repeated = box.run(repo.root, 'init');+ assert.equal(repeated.status, 0, `${repeated.stdout}${repeated.stderr}`);+ assert.equal(readFileSync(doctrinePath, 'utf8'), saved, 'rerunning init preserves repo doctrine rows');+ const guidance = readFileSync(join(repo.root, 'AGENTS.md'), 'utf8');+ assert.match(guidance, /L1 \(repo\)/u, 'generated guidance renders the same local row');+ assert.equal(guidance.split('house rules for agentic development').length - 1, 1, 'guidance glosses doctrine once');+});++test('[D1,D2,A5] legacy init keeps PRACTICE rules and doctor offers a working one-step rename', function legacyDoctrineFallback() {+ const box = sandbox();+ const repo = initializedRepo(box, 'legacy-repo', { legacy: true });+ assert.equal(existsSync(join(repo.root, DOCTRINE)), false, 'legacy initialization does not create a competing file');+ assert.equal(readFileSync(join(repo.root, PRACTICE), 'utf8'), LEGACY_RULES, 'legacy content is preserved byte for byte');+ assert.ok(specRows(box, repo.root).some((row) => row.id === 'L1' && row.file === PRACTICE));+ const view = box.run(repo.root, 'spec', 'view', '--out', 'legacy-view.html');+ assert.equal(view.status, 0, `${view.stdout}${view.stderr}`);+ assert.match(readFileSync(join(repo.root, 'legacy-view.html'), 'utf8'), /PRACTICE\.md/u);+ const state = projectState(repo.root);+ assert.ok(state.practice.some((row) => row.id === 'L1'), 'the API still exposes legacy rules as state.practice');++ box.git(repo.root, 'add', '-A');+ box.git(repo.root, 'commit', '-q', '-m', 'chore: initialize legacy doctrine fixture');+ const findings = doctorProblems(box, repo.root);+ const rename = findings.find((problem) => problem.code === 'DOCTRINE_LEGACY');+ assert.ok(rename, 'doctor identifies the legacy filename');+ assert.equal(rename.next, `git mv -- ${PRACTICE} ${DOCTRINE}`);+ box.git(repo.root, ...rename.next.split(' ').slice(1));+ const after = doctorProblems(box, repo.root);+ assert.equal(after.some((problem) => problem.code === 'DOCTRINE_LEGACY'), false, 'the suggested rename clears the finding');+ assert.ok(specRows(box, repo.root).some((row) => row.id === 'L1' && row.file === DOCTRINE), 'readers keep the same rule after rename');+ assert.ok(projectState(repo.root).practice.some((row) => row.id === 'L1'));+ const kept = readFileSync(join(repo.root, DOCTRINE), 'utf8');+ writeFileSync(join(repo.root, DOCTRINE), kept.replace('- L1 [fact] Keep the legacy rule.\n', ''));+ const erased = box.run(repo.root, 'spec', 'check');+ assert.equal(erased.status, 1, 'a pending filename rename does not erase the old ids');+ assert.match(erased.stdout, /L1 error:.*ids are permanent/u);+ box.git(repo.root, 'add', '--', DOCTRINE);+ assert.throws(() => box.git(repo.root, 'commit', '-q', '-m', 'docs: erase a legacy doctrine row'), /ids are permanent/u);+ writeFileSync(join(repo.root, DOCTRINE), kept);+ box.git(repo.root, 'add', '--', DOCTRINE);+ box.git(repo.root, 'commit', '-q', '-m', 'docs: rename the legacy doctrine');+ assert.ok(specRows(box, repo.root).some((row) => row.id === 'L1'), 'the intact rename commits through its installed hooks');+});++test('[D1,D2,A5] two conventional doctrine files refuse with a named BAD_CONFIG error', function refuseDuplicateDoctrineNames() {+ const box = sandbox();+ const repo = initializedRepo(box, 'duplicate-repo');+ writeFileSync(join(repo.root, PRACTICE), LEGACY_RULES);+ const result = box.run(repo.root, 'spec', 'check', '--json');+ assert.notEqual(result.status, 0);+ const document = JSON.parse(result.stdout);+ assert.equal(document.error.code, 'BAD_CONFIG');+ assert.match(document.error.message, /DOCTRINE\.md/u);+ assert.match(document.error.message, /PRACTICE\.md/u);+ assert.match(document.error.next, /merge their rules/u);+});++test('[D1,D2,A5] explicit custom practice paths remain authoritative beside DOCTRINE.md', function retainCustomDoctrinePath() {+ const box = sandbox();+ const repo = initializedRepo(box, 'custom-repo');+ const custom = '# Custom doctrine\n\n## C · Custom\n- C1 [fact] Use the configured custom doctrine file.\n';+ writeFileSync(join(repo.root, 'ways.md'), custom);+ const configPath = join(repo.root, 'pullboard.json');+ const config = JSON.parse(readFileSync(configPath, 'utf8'));+ writeFileSync(configPath, `${JSON.stringify({ ...config, practice: 'ways.md' }, null, 2)}\n`);++ const checked = box.run(repo.root, 'spec', 'check');+ assert.equal(checked.status, 0, `${checked.stdout}${checked.stderr}`);+ assert.match(checked.stdout, /ways\.md: 13 rows/u);+ const rows = specRows(box, repo.root);+ assert.ok(rows.some((row) => row.id === 'C1' && row.file === 'ways.md'));+ assert.equal(rows.some((row) => row.id === 'L1'), false, 'custom path remains the configured source');+ assert.ok(projectState(repo.root).practice.some((row) => row.id === 'C1'));+});diff --git a/test/e2e.test.js b/test/e2e.test.jsindex 8d040607..3cd73958 100644--- a/test/e2e.test.js+++ b/test/e2e.test.js@@ -176,14 +176,14 @@ test('init writes config, spec, agent docs and hooks once, and never clobbers [Iassert.equal(readFileSync(join(repo, 'CLAUDE.md'), 'utf8'), '@AGENTS.md\n');assert.equal(box.git(repo, 'config', '--get', 'core.hooksPath'), '.githooks');for (const hook of ['pre-commit', 'commit-msg', 'pre-push']) assert.ok(existsSync(join(repo, '.githooks', hook)));- const practice = readFileSync(join(repo, 'PRACTICE.md'), 'utf8');- assert.ok(practice.startsWith('# Practice'));+ const practice = readFileSync(join(repo, 'DOCTRINE.md'), 'utf8');+ assert.ok(practice.startsWith('# Doctrine'));assert.deepEqual(parseSpec(practice).rows, [], 'fresh init copies no standard rules [D4]');assert.equal(parseSpec(practice).sections.length, 6);assert.equal(practice.split('Inherits Pullboard standard doctrine version 1.').length, 2);assert.match(agents, /PB1 \(standard 1\)/, 'fresh guidance shows inherited rules [D3]');assert.ok(existsSync(join(repo, '.claude', 'skills', 'pullboard-decompose', 'SKILL.md')));- assert.match(second.out, /kept PRACTICE.md/);+ assert.match(second.out, /kept DOCTRINE.md/);assert.match(second.out, /kept the Claude Code skills/);});@@ -243,10 +243,10 @@ test("the coordinator's resume names its next step from the spec and the board,test('spec check lints both files; spec view writes one page into the git dir [S6, S7]', () => {const box = project();- writeFileSync(join(box.repo, 'PRACTICE.md'), '# Practice\n\n## C · Code\n- C1 [approved, must] Functions under 60 lines.\n');+ writeFileSync(join(box.repo, 'DOCTRINE.md'), '# Doctrine\n\n## C · Code\n- C1 [approved, must] Functions under 60 lines.\n');const check = box.run(box.repo, 'spec', 'check');assert.equal(check.code, 1);- assert.match(check.out, /PRACTICE.md:4 C1 error: an approved must-row names its gate/);+ assert.match(check.out, /DOCTRINE.md:4 C1 error: an approved must-row names its gate/);assert.match(check.out, /SPEC.md: 2 rows, 0 errors/);const view = box.run(box.repo, 'spec', 'view');assert.equal(view.code, 0, view.err);@@ -524,26 +524,26 @@ test("a worktree starts only from a commit that holds pullboard's files as the mconst first = refused(/\[NOT_COMMITTED\] this repo has no commit yet, and a new worktree starts from one; not committed: /, ['.githooks/pre-commit','AGENTS.md',- 'PRACTICE.md',+ 'DOCTRINE.md','SPEC.md','pullboard.json',]);sh(first);- for (const file of ['.githooks/pre-commit', 'AGENTS.md', 'PRACTICE.md', 'SPEC.md', 'pullboard.json']) {+ for (const file of ['.githooks/pre-commit', 'AGENTS.md', 'DOCTRINE.md', 'SPEC.md', 'pullboard.json']) {assert.equal(box.git(repo, 'ls-tree', '--name-only', 'HEAD', '--', file), file, `${file} is committed`);}assert.equal(box.git(repo, 'ls-tree', '--name-only', 'HEAD', '--', 'notes.txt'), '', 'the command commits only those files');writeFileSync(join(repo, 'SPEC.md'), `${SPEC}- G3 [draft, aim] A third goal. | gate: test\n`);writeFileSync(join(repo, '.githooks', 'post-checkout'), '#!/bin/sh\n');- rmSync(join(repo, 'PRACTICE.md'));+ rmSync(join(repo, 'DOCTRINE.md'));box.git(repo, 'add', 'notes.txt');refused(/\[NOT_COMMITTED\] a new worktree starts from the last commit, and these differ from it here: /, ['.githooks/post-checkout (not committed)',- 'PRACTICE.md (deleted)',+ 'DOCTRINE.md (deleted)','SPEC.md (changed)',]);- box.git(repo, 'checkout', '--', 'PRACTICE.md');+ box.git(repo, 'checkout', '--', 'DOCTRINE.md');sh(refused(/these differ from it here: \.githooks\/post-checkout \(not committed\), SPEC\.md \(changed\)\. /, []));assert.equal(box.git(repo, 'diff', '--cached', '--name-only'), 'notes.txt', "the person's staged file stays staged, and out of the commit");diff --git a/test/spec.test.js b/test/spec.test.jsindex ced7511a..23ab4abf 100644--- a/test/spec.test.js+++ b/test/spec.test.js@@ -295,6 +295,7 @@ function specBox(t, { specName = 'SPEC.md', practiceName = 'PRACTICE.md', practiwriteFileSync(join(root, 'pullboard.json'), JSON.stringify({ ...config, spec: specName, practice: practiceName, gate: 'true', lanes: { review: { owns: [] } } }));rmSync(join(root, 'SPEC.md'), { force: true });rmSync(join(root, 'PRACTICE.md'), { force: true });+ rmSync(join(root, 'DOCTRINE.md'), { force: true });writeFileSync(join(root, specName), SPEC);if (practice !== undefined) writeFileSync(join(root, practiceName), practice);git('add', '-A');diff --git a/test/view.test.js b/test/view.test.jsindex 1091dff2..baff7ace 100644--- a/test/view.test.js+++ b/test/view.test.js@@ -42,7 +42,7 @@ test('one self-contained page with every tab and inherited doctrine row [S7,D1,Dconst html = page();assert.ok(html.startsWith('<!doctype html>'));assert.ok(!/src="http|href="http/.test(html), 'nothing loads from the network');- for (const label of ['Spec', 'Open questions (1)', 'Sign-off', 'Practice']) assert.ok(html.includes(label));+ for (const label of ['Spec', 'Open questions (1)', 'Sign-off', 'Doctrine']) assert.ok(html.includes(label));for (const id of ['O1', 'O2', 'O3', 'O4', 'PB1', 'PB12']) assert.ok(html.includes(`>${id}<`), `${id} is on the page`);});