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(spec): a rule cannot lose its test silently [D1,S1]
Corey Olson3efc425a2178
diff --git a/docs/api.md b/docs/api.mdindex ee0ba4bb..b3db0a04 100644--- a/docs/api.md+++ b/docs/api.md@@ -465,6 +465,10 @@ The local server uses a shared HTTP router. Streams recheck access before each pHTTP refusals use the same versioned error envelope above: 400 for malformed calls, 401 for a missing or wrong session secret, 403 for an agent belonging to another board, 404 for an unknown board, path or shout, and 409 for the CLI engine's refusal. Shouts and answers append their events in the same transaction as their records. A move returns its own event, including when it also sends a coordinator shout.+## Spec gates++`pullboard spec check` fails when an approved must-row names a gate file the repo does not have, and it names the row and the file. A row of any other status that names a missing file only warns, so a draft can name a file it will create. The pre-commit hook refuses a commit that deletes or renames a file an approved must-row names, unless the same commit points that row at its new home.+## SSH spec sign-offs`pullboard spec signers add [--key <path>] [--by <principal>]` opts a repo into OpenSSH-signed spec sign-offs. The key defaults to Git `user.signingkey`, then `~/.ssh/id_ed25519.pub`. The principal defaults to the exact Git `user.email`; `--by` overrides it. `spec signoff` uses the same email default in a repo with SSH signers, and accepts `--by` when a listed principal differs. A row's `signers:` names those exact principals. Spec checking refuses a required principal without a corresponding signer entry.diff --git a/src/cli.js b/src/cli.jsindex 0ea25ccf..c6d4121b 100644--- a/src/cli.js+++ b/src/cli.js@@ -240,6 +240,7 @@ import {lintSpec,loadSpec,legacyDoctrineRenameBase,+ missingGateFindings,permanenceProblems,parseSpec,readSignoffs,@@ -4120,6 +4121,7 @@ async function specCommand(io, { first, second, rest, values }) {for (const [name, parsed] of files) {const findings = [...lintSpec(parsed).filter((finding) => !finding.message.startsWith('duplicate id;')),+ ...missingGateFindings(parsed, ctx.info.root),...(collisionFindings.get(name) ?? []),];findings.forEach((finding) => messages.push(`${name}:${finding.line} ${finding.id ?? ''} ${finding.level}: ${finding.message}`.replace(' ', ' ')));diff --git a/src/hooks.js b/src/hooks.jsindex 7f63d77a..982bbbff 100644--- a/src/hooks.js+++ b/src/hooks.js@@ -38,7 +38,9 @@ import { outOfLane } from './lanes.js';import {citedIds,deletedIds,+ gateFiles,idProblems,+ parseSpec,} from './spec.js';import { approvedRowProblems } from './approved-rows.js';@@ -280,6 +282,7 @@ export function preCommitProblems({ root, isMain, config, agent, boardFile, preMproblems.push(...secretsIn(addedLines(diff)).map((where) => `possible secret: ${where}`));}problems.push(...deletedRowProblems(root, [config.spec, config.practice]));+ problems.push(...deletedGateProblems(root, config));problems.push(...approvedRowProblems(root, config, boardFile));if (isMain) return problems;if (!agent) {@@ -311,6 +314,43 @@ export function preCommitProblems({ root, isMain, config, agent, boardFile, preMreturn problems;}+/**+ * A commit that deletes or renames a test file an approved must-row names must point that row at its new+ * home in the same commit, or the rule loses its test silently (#809). The row is read from HEAD's spec+ * and again from the staged one, so a repoint in this commit counts and a missing row does not.+ *+ * @param {string} root+ * @param {{ spec?: string }} config+ * @returns {string[]}+ */+export function deletedGateProblems(root, config) {+ if (!config?.spec) return [];+ const status = tryGit(root, ['diff', '--cached', '--name-status', '-M', '--no-color']);+ if (status.status !== 0) return [];+ const gone = new Map();+ for (const line of status.stdout.split('\n').filter(Boolean)) {+ const [code, from, to] = line.split('\t');+ if (code.startsWith('D')) gone.set(from, 'deletes');+ else if (code.startsWith('R')) gone.set(from, `renames to ${to}`);+ }+ if (!gone.size) return [];+ const head = tryGit(root, ['show', `HEAD:${config.spec}`]);+ if (head.status !== 0) return [];+ const staged = tryGit(root, ['show', `:${config.spec}`]);+ const before = parseSpec(head.stdout).rows.filter((row) => row.status === 'approved' && row.tier === 'must');+ const after = staged.status === 0 ? parseSpec(staged.stdout).rows : [];+ const problems = [];+ for (const [file, change] of gone) {+ for (const row of before) {+ if (!gateFiles(row.gate).includes(file)) continue;+ const now = after.find((candidate) => candidate.id === row.id);+ if (now && !gateFiles(now.gate).includes(file)) continue;+ problems.push(`${row.id} names ${file}, which this commit ${change}; point ${row.id} at its new home in this commit`);+ }+ }+ return problems;+}+/** Read lane ownership from the committed checkout, so unstaged settings cannot grant new folders [L1,L3]. */function committedLaneConfig(root) {const source = tryGit(root, ['show', 'HEAD:' + CONFIG_FILE]);diff --git a/src/spec.js b/src/spec.jsindex 16defe71..9d58657e 100644--- a/src/spec.js+++ b/src/spec.js@@ -249,6 +249,41 @@ export function checkFieldFindings(row) {return problems;}+/** A repo path with a known extension, as a whole word in a gate (#809). */+const GATE_FILE_RE = /(?:^|\s)((?:[\w.-]+\/)*[\w.-]+\.(?:js|mjs|cjs|sh|md|json|yml))(?=\s|$)/gu;++/**+ * The repo files a row's gate names, such as `test/board.test.js` or `bin/checks/file-size.js`. A gate+ * word without a path, such as `review` or `true`, names no file to check.+ *+ * @param {string | undefined} gate+ * @returns {string[]}+ */+export function gateFiles(gate) {+ return [...String(gate ?? '').matchAll(GATE_FILE_RE)].map((match) => match[1]);+}++/**+ * Findings for each row whose gate names a file the repo does not have (#809). An approved must-row is+ * an error, so spec check fails and names the row and the file; every other row only warns, so a draft+ * can name a file it will create.+ *+ * @param {any} spec - a parsed spec+ * @param {string} root - the repo root the gate paths resolve against+ * @returns {{ level: string, line: number, id: string, message: string }[]}+ */+export function missingGateFindings(spec, root) {+ const findings = [];+ for (const row of spec.rows) {+ for (const file of gateFiles(row.gate)) {+ if (existsSync(join(root, file))) continue;+ const level = row.status === 'approved' && row.tier === 'must' ? 'error' : 'warning';+ findings.push({ level, line: row.line, id: row.id, message: `gate file ${file} does not exist; name the file that proves the row` });+ }+ }+ return findings;+}+/*** The first cycle in the serves graph, as the ids around it, or null.*diff --git a/test/spec.test.js b/test/spec.test.jsindex 1121e41d..f84e9ddd 100644--- a/test/spec.test.js+++ b/test/spec.test.js@@ -9,6 +9,8 @@ import { join, resolve } from 'node:path';import { DatabaseSync } from 'node:sqlite';import { pathToFileURL } from 'node:url';import { test } from 'node:test';+import { configFromSource } from '../src/config.js';+import { preCommitProblems } from '../src/hooks.js';import { standardDoctrine } from '../src/doctrine.js';import { AGENT_SHELL_MARKERS, SSH_SHELL_MARKERS } from '../src/person.js';import { requireRelayOnChannel } from '../src/person.js';@@ -1044,3 +1046,43 @@ function answerCommandCase(t, separateGitDir) {assert.equal(person.status, 0, person.stdout + person.stderr);assert.equal(JSON.parse(person.stdout).decisions[0].answer, "Redis on the host's port");}++test('spec check fails when an approved row names a missing gate [S4]', (t) => {+ // An approved must-row whose gate file is gone fails spec check and names both the row and the file (#809).+ const source = `${SPEC}- G9 [approved, must] A rule keeps its proof. | gate: test/proof-gone.test.js\n`;+ const box = specBox(t, { specSource: source });+ const text = box.run('check');+ assert.equal(text.status, 1, text.stdout + text.stderr);+ assert.match(text.stdout + text.stderr, /G9 error: gate file test\/proof-gone\.test\.js does not exist/u);+ mkdirSync(join(box.root, 'test'));+ writeFileSync(join(box.root, 'test/proof-gone.test.js'), 'export {};\n');+ assert.equal(box.run('check').status, 0, 'the same row passes once its file exists');+});++test('a draft row with a missing gate file only warns [S4]', (t) => {+ const source = `${SPEC}- G9 [draft, must] A rule not yet proved. | gate: test/not-yet.test.js\n`;+ const box = specBox(t, { specSource: source });+ const text = box.run('check');+ assert.equal(text.status, 0, text.stdout + text.stderr);+ assert.match(text.stderr + text.stdout, /G9 warning: gate file test\/not-yet\.test\.js does not exist/u);+});++test('a commit that deletes an approved row test is refused [S4]', (t) => {+ // Staged deletion of the file an approved row names is refused until the same commit repoints the row (#809).+ const box = specBox(t, { specSource: `${SPEC}- G9 [approved, must] A rule keeps its proof. | gate: test/proof.test.js\n` });+ mkdirSync(join(box.root, 'test'));+ writeFileSync(join(box.root, 'test/proof.test.js'), 'export {};\n');+ box.git('add', '-A');+ box.git('commit', '-q', '-m', 'test: the proof');+ const config = configFromSource(readFileSync(join(box.root, 'pullboard.json'), 'utf8'));+ box.git('rm', '-q', 'test/proof.test.js');+ const refused = preCommitProblems({ root: box.root, isMain: true, config, agent: null });+ assert.ok(refused.some((problem) => problem.includes('G9 names test/proof.test.js, which this commit deletes')), refused.join('\n'));+ box.git('reset', '-q', '--hard', 'HEAD');+ writeFileSync(join(box.root, 'test/proof-new.test.js'), 'export {};\n');+ writeFileSync(join(box.root, config.spec), `${SPEC}- G9 [approved, must] A rule keeps its proof. | gate: test/proof-new.test.js\n`);+ box.git('rm', '-q', 'test/proof.test.js');+ box.git('add', '-A');+ const repointed = preCommitProblems({ root: box.root, isMain: true, config, agent: null });+ assert.ok(!repointed.some((problem) => problem.includes('G9 names')), `the same commit repoints the row: ${repointed.join('\n')}`);+});