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
chore(merge): add doctrine collision rules [A5]
Corey Olsonebe873fc85c7
diff --cc src/cli.jsindex 793ace21,b5b46b88..27159653--- a/src/cli.js+++ b/src/cli.js@@@ -10,11 -9,9 +10,11 @@@ import { pathToFileURL } from 'node:urlimport { 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 { requirePersonChannel } from './person.js';+import { decisionProjection, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.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 { bareWorktreeFinding, contains, differFromHead, git, gitChildEnv, headCommit, headTree, isClean, repoInfo, resolveCommit, tryGit, untracked } from './git.js';import {FIX_NOTE,applyFixers,@@@ -66,7 -60,34 +68,34 @@@ import { relayJoin, relayPair } from '.const PACKAGE = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));export const VERSION = PACKAGE.version;+ /**+ * Read the grandfather baseline from the primary checkout's attached branch, never a builder's head.+ *+ * @param {string} root+ * @param {string} path+ * @returns {{ status: number, stdout: string }}+ */+ function coordinatorFile(root, path) {+ const commonDir = git(root, ['rev-parse', '--path-format=absolute', '--git-common-dir']);+ const coordinatorRoot = dirname(commonDir);+ const env = { ...gitChildEnv(root), GIT_NO_REPLACE_OBJECTS: '1' };+ const branch = spawnSync('git', ['symbolic-ref', '--quiet', 'HEAD'], {+ cwd: coordinatorRoot, env, encoding: 'utf8',+ });+ const ref = (branch.stdout ?? '').trim();+ if (branch.status !== 0 || !ref.startsWith('refs/heads/')) {+ throw new Refused(+ 'COORDINATOR_DETACHED',+ 'the primary checkout must be on its attached local branch to establish the collision baseline; the coordinator returns it to its branch',+ );+ }+ const result = spawnSync('git', ['--no-replace-objects', 'show', `${ref}:${path}`], {+ cwd: coordinatorRoot, env, encoding: 'utf8',+ });+ return { status: result.status ?? 1, stdout: result.stdout ?? '' };+ }+-export const HELP = `pullboard ${VERSION}: the local-first work board for teams of coding agents.+const ALL_HELP = `pullboard ${VERSION}: the local-first work board for teams of coding agents.Nothing ships until a second agent verifies it.Set up@@@ -676,15 -453,7 +705,15 @@@ function whoAmI(ctx, board)* @param {any} ctx* @returns {(item: any) => { text: string, digest: string }}*/-const freezer = (ctx) => (item) => frozenCriterion(loadSpec(ctx.info.root, ctx.config), item, ctx.doctrine);+const freezer = (ctx) => (item) => {+ const prior = item.item_frozen ? JSON.parse(item.item_frozen) : null;+ const policy = prior?.policy ?? (!prior && !(ctx.info.isMain && !headCommit(ctx.info.root)) ? { version: 1, commit: mainPolicy(ctx.info.root).commit } : null);+ const config = policy ? itemPolicy(ctx.info.root, { ...item, item_frozen: JSON.stringify({ policy }) }).config : ctx.config;- const frozen = frozenCriterion(loadSpec(ctx.info.root, config), item);++ const frozen = frozenCriterion(loadSpec(ctx.info.root, config), item, ctx.doctrine);+ if (!policy) return frozen; // Legacy criteria retain their original digest and committed claim base.+ const text = JSON.stringify({ ...JSON.parse(frozen.text), policy });+ return { text, digest: createHash('sha256').update(text).digest('hex') };+};/*** The evidence a shout carries, from its flags (B22). The commit is resolved here, in this repo,@@@ -1699,67 -1372,10 +1728,67 @@@ function workCommands(io, args)return withBoard(ctx, (board) => work(ctx, board, whoAmI(ctx, board)));};return {- add: () => act((ctx, board, me) => {+ fact: () => act(async (ctx, board, me) => {+ if (!first || !second || rest.length !== 1) throw new Refused('USAGE', 'pullboard fact <id> <kind> <text> [--supersedes <fact-id>] [--ref path:lines@full-sha]');+ const id = idArg(first);+ const fact = await ordered(ctx, board, 'appendFact', [id, { agentId: me.id, kind: second,+ text: rest[0], supersedes: values.supersedes ?? null, ref: values.ref ?? null }]);+ io.result?.({ item: id, fact });+ io.say(`fact ${fact.id} appended to #${id} as ${fact.kind}`);+ return 0;+ }),+ milestone: () => act(async (ctx, board, me) => {+ const ids = (text) => (text ?? '').split(',').map((value) => value.trim()).filter(Boolean);+ let name;+ let entry;+ if (first === 'add') {+ if (!second || rest.length || values.before !== undefined || values.add !== undefined || values.remove !== undefined || values.name !== undefined) {+ throw new Refused('USAGE', 'pullboard milestone add <name> [--note ...] [--items 1,2,3]');+ }+ name = await ordered(ctx, board, 'addMilestone', [{ agentId: me.id, name: second, note: values.note ?? null, items: ids(values.items) }]);+ } else if (first === 'items') {+ if (!second || rest.length || Boolean(values.add) === Boolean(values.remove) || values.items !== undefined || values.note !== undefined || values.before !== undefined || values.name !== undefined) {+ throw new Refused('USAGE', 'pullboard milestone items <name> --add ids or --remove ids');+ }+ name = second;+ const next = await ordered(ctx, board, 'editMilestoneItems', [name, {+ agentId: me.id,+ add: values.add === undefined ? [] : ids(values.add),+ remove: values.remove === undefined ? [] : ids(values.remove),+ }]);+ entry = { ...store.milestones(board).find((value) => value.name === name), items: next };+ } else if (first === 'move') {+ if (!second || rest.length || !values.before || values.items !== undefined || values.note !== undefined || values.name !== undefined || values.add !== undefined || values.remove !== undefined) {+ throw new Refused('USAGE', 'pullboard milestone move <name> --before <other>');+ }+ name = second;+ await ordered(ctx, board, 'moveMilestone', [name, { agentId: me.id, before: values.before }]);+ entry = store.milestones(board).find((value) => value.name === name);+ } else if (first === 'edit') {+ if (!second || rest.length || (values.name === undefined && values.note === undefined) || values.items !== undefined || values.before !== undefined || values.add !== undefined || values.remove !== undefined) {+ throw new Refused('USAGE', 'pullboard milestone edit <name> [--name <new name>] [--note <text>]');+ }+ name = second;+ entry = await ordered(ctx, board, 'editMilestone', [name, { agentId: me.id, newName: values.name, note: values.note }]);+ } else if (first === 'remove') {+ if (!second || rest.length || values.items !== undefined || values.note !== undefined || values.before !== undefined || values.name !== undefined || values.add !== undefined || values.remove !== undefined) {+ throw new Refused('USAGE', 'pullboard milestone remove <name>');+ }+ name = second;+ await ordered(ctx, board, 'removeMilestone', [name, { agentId: me.id }]);+ entry = { name };+ } else {+ throw new Refused('USAGE', 'use pullboard milestone add, items, move, edit or remove');+ }+ entry ??= store.milestones(board).find((value) => value.name === name);+ io.result?.({ milestone: entry });+ io.say(`milestone ${first === 'remove' ? 'removed' : first === 'add' ? 'added' : 'updated'}: ${name}`);+ return 0;+ }),+ add: () => act(async (ctx, board, me) => {if (!first || !isLane(ctx.config, first)) throw new Refused('NO_LANE', `no lane "${first ?? ''}"; see: pullboard lanes`);const specIds = idList(values.specs);- const problems = idProblems(loadSpec(ctx.info.root, ctx.config), specIds);+ const problems = idProblems(loadSpec(ctx.info.root, ctx.config), specIds, ctx.doctrine);if (problems.length) throw new Refused('UNKNOWN_SPEC', `${problems.join('; ')}`);const parentId = values.parent ? idArg(values.parent, 'a parent item id') : null;const after = idList(values.after).map((text) => idArg(text, 'an item id after --after'));@@@ -2061,9 -1651,12 +2121,12 @@@ async function specCommand(io, { firstlet errors = 0;const messages = [];for (const [name, parsed] of files) {- const findings = lintSpec(parsed);+ const findings = [+ ...lintSpec(parsed).filter((finding) => !finding.message.startsWith('duplicate id;')),+ ...(collisionFindings.get(name) ?? []),+ ];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}`));@@@ -2210,10 -1783,13 +2273,13 @@@ async function hookCommand(io, { firstif (first === 'pre-commit') {applyFixers(info.root, ctx.config.fix).forEach((note) => io.err(`pullboard pre-commit: ${note}`));const agent = info.isMain ? null : withBoard(ctx, (board) => store.agentAt(board, info.root));- problems = preCommitProblems({ root: info.root, isMain: info.isMain, config: ctx.config, agent });+ problems = preCommitProblems({ root: info.root, isMain: info.isMain, config: ctx.config, agent, boardFile: ctx.file });} else if (first === 'commit-msg') {const message = readFileSync(second ?? '', 'utf8');- problems = commitMsgProblems(message, { rules: ctx.config.commits, spec: loadSpec(info.root, ctx.config) });+ const spec = loadSpec(info.root, ctx.config);+ commitCitationWarnings(message, { spec, doctrine: ctx.doctrine })+ .forEach((warning) => io.say(`pullboard commit-msg: warning: ${warning}`));+ problems = commitMsgProblems(message, { rules: ctx.config.commits, spec, doctrine: ctx.doctrine });} else if (first === 'pre-push') {problems = prePushProblems(info.root, await readStdin(io.stdin));if (!problems.length) {diff --cc test/e2e.test.jsindex fad5b0c7,bdf4be97..49fb6628--- a/test/e2e.test.js+++ b/test/e2e.test.js@@@ -182,9 -180,25 +182,25 @@@ test('init writes config, spec, agent dassert.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.equal(box.run(repo, 'spec', 'check').code, 0, 'fresh init has no repeated ids [A5]');+ const specRows = parseSpec(readFileSync(join(repo, 'SPEC.md'), 'utf8'));+ const practiceRows = parseSpec(practice);+ const specPrefixes = specRows.sections.map(({ name }) => /^([A-Z])\s/u.exec(name)?.[1]).filter(Boolean);+ const practicePrefixes = parseSpec(practice).sections.map(({ name }) => /^([A-Z])\s/u.exec(name)?.[1]).filter(Boolean);+ assert.equal(specPrefixes.some((prefix) => practicePrefixes.includes(prefix)), false, 'init assigns distinct row prefixes to SPEC and PRACTICE');+ for (const [file, parsed] of [['SPEC.md', specRows], ['PRACTICE.md', practiceRows]]) {+ const source = readFileSync(join(repo, file), 'utf8');+ const additions = parsed.sections.map(({ name }) => {+ const prefix = /^([A-Z])\s/u.exec(name)?.[1];+ return prefix ? `\n- ${prefix}1 [draft] A starter row.\n` : '';+ }).join('');+ writeFileSync(join(repo, file), `${source}${additions}`);+ }+ const representativeRows = box.run(repo, 'spec', 'check');+ assert.equal(representativeRows.code, 0, representativeRows.err || representativeRows.out);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/);});diff --cc test/hooks.test.jsindex e5e44276,635e8009..c7bae752--- a/test/hooks.test.js+++ b/test/hooks.test.js@@@ -1,16 -1,11 +1,16 @@@/**- * The commit-message rules (C1, C2) and the pre-commit pattern checks, without git.+ * The commit-message rules (C1, C2) and the pre-commit pattern checks on real staged changes.*/import assert from 'node:assert/strict';+import { execFileSync } from 'node:child_process';+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join } from 'node:path';import { test } from 'node:test';import { defaults } from '../src/config.js';- import { addedLines, blockedPaths, commitMsgProblems, matchesPattern, preCommitProblems, secretsIn } from '../src/hooks.js';-import { addedLines, blockedPaths, commitCitationWarnings, commitMsgProblems, matchesPattern, secretsIn } from '../src/hooks.js';++import { addedLines, blockedPaths, commitCitationWarnings, commitMsgProblems, matchesPattern, preCommitProblems, secretsIn } from '../src/hooks.js';import { parseSpec } from '../src/spec.js';+import { Refused } from '../src/refused.js';const SPEC = { ...parseSpec('## G\n- G1 [approved, must] One. | gate: t\n- G2 [retired] Gone.\n'), name: 'SPEC.md' };const RULES = defaults().commits;