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(doctrine): give working rename and staging advice [D1,D2]
Corey Olsonf95a8ec5bfa3
diff --git a/src/doctor.js b/src/doctor.jsindex 06edb82d..d51f4939 100644--- a/src/doctor.js+++ b/src/doctor.js@@ -2,6 +2,7 @@import { existsSync } from 'node:fs';import { join } from 'node:path';import { DOCTRINE_FILE, LEGACY_DOCTRINE_FILE } from './config.js';+import { tryGit } from './git.js';import { DatabaseSync } from 'node:sqlite';import { checkAtCommit, submissionPaths, dependencySnapshots } from './trusted-policy.js';import { BLANKS, STATES, storeTriggers } from './machine.js';@@ -9,10 +10,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. */+/** Offer a working tracked or untracked rename without rewriting the repo's doctrine [D1,D2]. */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}`)];+ const tracked = tryGit(root, ['ls-files', '--error-unmatch', '--', LEGACY_DOCTRINE_FILE]).status === 0;+ const command = tracked ? 'git mv' : 'mv';+ return [finding('DOCTRINE_LEGACY', `${LEGACY_DOCTRINE_FILE} is the legacy name for the repo doctrine`, `${command} -- ${LEGACY_DOCTRINE_FILE} ${DOCTRINE_FILE}`)];}/**diff --git a/test/doctrine-name.test.js b/test/doctrine-name.test.jsindex 0b7ac83f..a187b782 100644--- a/test/doctrine-name.test.js+++ b/test/doctrine-name.test.js@@ -1,7 +1,7 @@/** 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 { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { after, test } from 'node:test';@@ -136,6 +136,14 @@ test('[D1,D2,A5] legacy init keeps PRACTICE rules and doctor offers a working onconst state = projectState(repo.root);assert.ok(state.practice.some((row) => row.id === 'L1'), 'the API still exposes legacy rules as state.practice');+ const untrackedRename = doctorProblems(box, repo.root).find((problem) => problem.code === 'DOCTRINE_LEGACY');+ assert.ok(untrackedRename);+ assert.equal(untrackedRename.next, `mv -- ${PRACTICE} ${DOCTRINE}`, 'an untracked legacy file needs a filesystem rename');+ const moved = spawnSync('sh', ['-c', untrackedRename.next], { cwd: repo.root, env: box.env, encoding: 'utf8' });+ assert.equal(moved.status, 0, moved.stderr);+ assert.ok(specRows(box, repo.root).some((row) => row.id === 'L1' && row.file === DOCTRINE));+ renameSync(join(repo.root, DOCTRINE), join(repo.root, 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);diff --git a/test/newcomer.test.js b/test/newcomer.test.jsindex 2e3e0522..383f6bf6 100644--- a/test/newcomer.test.js+++ b/test/newcomer.test.js@@ -21,7 +21,7 @@ function project(t) {return { root, env, git, run };}-test('init ends with a working staging line for exactly its own writes [I1,I2]', (t) => {+test('init ends with a working staging line for exactly its own writes [I1,I2,D1,D2]', (t) => {const box = project(t);writeFileSync(join(box.root, '.env.local'), 'LOCAL=1\n');writeFileSync(join(box.root, 'notes.txt'), 'keep this out of the initial commit\n');@@ -46,7 +46,7 @@ test('init ends with a working staging line for exactly its own writes [I1,I2]','.claude/skills/pullboard-spec-review/SKILL.md','.claude/skills/pullboard-verify/SKILL.md','.githooks/commit-msg', '.githooks/pre-push',- 'AGENTS.md', 'PRACTICE.md', 'SPEC.md', 'pullboard.json',+ 'AGENTS.md', 'DOCTRINE.md', 'SPEC.md', 'pullboard.json',]);assert.equal(readFileSync(join(box.root, '.env.local'), 'utf8'), 'LOCAL=1\n');assert.equal(readFileSync(join(box.root, '.githooks', 'pre-commit'), 'utf8'), '#!/bin/sh\n# My hook\n');