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(init): a board with a product blueprint refuses another [S1,I1]
Corey Olsonaa1b772fe17c
diff --git a/docs/api.md b/docs/api.mdindex d76b0c46..1ef5b00d 100644--- a/docs/api.md+++ b/docs/api.md@@ -291,7 +291,7 @@ Decision moves keep the CLI's routing: `shout` with `args.decision: true` may omOnly the coordinator runs `spec apply`. It preflights every pending row against the exact source text, refusing stale decisions before writing any file. Approval changes the status to `approved`; decline changes it to `wont` with the person's reason as the row text, preserving trailing fields. SSH-enabled approvals carry one signed `row-decision` receipt binding the file, source, replacement, decision, reason and row text. Apply copies that same receipt into `.pullboard/signoffs.jsonl`; it remains a current exact-text sign-off. Commit the changed files and receipts together.-`init` and `blueprint add` take `--blueprint` more than once, and the blueprints land in the order given. A board takes at most one product blueprint and one architecture blueprint (kind `infrastructure` fills the architecture slot), and any number of practice and beyond-code ones; a second product or architecture blueprint is refused with `BLUEPRINT_KIND_TAKEN`, naming both, before anything is written. A rule or question whose row text an earlier blueprint in the same command drafted is drafted once: the later blueprint cites that row and lists it in `shared` as `{ key, id }`. Each starter item in `items` carries `blueprint`, the name of the blueprint that filed it, and its add appends a `note` fact `blueprint starter: {"blueprint":"<name>","version":<version>,"key":"<key>"}` to the item. With several blueprints, `blueprint add` returns the first blueprint's fields with every blueprint's `rows`, `items`, `proposedLanes` and `checksNotRun`, and each one's own result in `blueprints`; `init` returns the first in `blueprint` and all of them in `blueprints`.+`init` and `blueprint add` take `--blueprint` more than once, and the blueprints land in the order given. A board takes at most one product blueprint and one architecture blueprint (kind `infrastructure` fills the architecture slot), and any number of practice and beyond-code ones; a second product or architecture blueprint is refused with `BLUEPRINT_KIND_TAKEN`, naming both, before anything is written, whether the first is named in the same command or already on the board. A product or architecture blueprint leaves `<!-- pullboard-blueprint-kind <name> <kind> -->` beside its rows, which is how a later command finds it; a board added before that line existed is read from its bundled blueprint markers. Adding the blueprint the board already has again changes nothing and is no clash. A rule or question whose row text an earlier blueprint in the same command drafted is drafted once: the later blueprint cites that row and lists it in `shared` as `{ key, id }`. Each starter item in `items` carries `blueprint`, the name of the blueprint that filed it, and its add appends a `note` fact `blueprint starter: {"blueprint":"<name>","version":<version>,"key":"<key>"}` to the item. With several blueprints, `blueprint add` returns the first blueprint's fields with every blueprint's `rows`, `items`, `proposedLanes` and `checksNotRun`, and each one's own result in `blueprints`; `init` returns the first in `blueprint` and all of them in `blueprints`.To answer a pending question row (`<ask>: <default>. Choices: a, b.`, as `blueprint add` writes it), the person runs `spec answer <id> "<choice or text>"`, or the local view sends `spec-answer` with `args: {row: "B1", answer: "Postgres"}`. A listed choice matches in any case and keeps its listed spelling; other text joins the choices last. It refuses agent shells, agent worktrees and the API channel, records the same exact-row approval receipt, whose JSON `decisions` carry an `answer` read back from the signed text (never stored on its own), and the row leaves pending when the coordinator runs `spec apply`. `spec check` errors on a question that was pending at the trunk tip and now differs with no matching person decision.diff --git a/src/blueprint-set.js b/src/blueprint-set.jsindex c60ceb82..0f81d935 100644--- a/src/blueprint-set.js+++ b/src/blueprint-set.js@@ -5,7 +5,10 @@* A rule or question text two of them share is drafted once, by the first, and the later blueprint* cites that row. Every starter item keeps the name of the blueprint that filed it.*/-import { readBlueprint } from './blueprints.js';+import { existsSync, readFileSync } from 'node:fs';+import { join } from 'node:path';+import { bundledBlueprints, readBlueprint } from './blueprints.js';+import { CONFIG_FILE } from './config.js';import { Refused } from './refused.js';/**@@ -25,22 +28,62 @@ export function blueprintSlot(blueprint) {return ONE_PER_BOARD[blueprint.kind] ?? null;}+/**+ * The product and architecture blueprints a repo's board already has, read from its SPEC.md: the+ * kind line each one's add leaves, and for a board added before that line existed, the marker of a+ * bundled blueprint, whose kind its bundled file says. Nothing when the repo has no spec yet.+ *+ * @param {string} root - The repository root.+ * @returns {{ name: string, slot: string }[]}+ */+export function installedBlueprints(root) {+ let specFile = 'SPEC.md';+ try { specFile = JSON.parse(readFileSync(join(root, CONFIG_FILE), 'utf8')).spec ?? specFile; }+ catch (error) {+ // No pullboard.json yet, or one init will refuse on its own: the default spec file is read.+ if (!(error instanceof SyntaxError) && error?.code !== 'ENOENT') throw error;+ }+ const file = join(root, String(specFile));+ if (!existsSync(file)) return [];+ const found = new Map();+ const bundled = bundledBlueprints();+ for (const line of readFileSync(file, 'utf8').split(/\r?\n/u)) {+ const kind = /^<!-- pullboard-blueprint-kind (\S+) (\S+) -->$/u.exec(line.trim());+ const marker = /^<!-- pullboard-blueprint (\S+) \d+(?: adding .*)? -->$/u.exec(line.trim());+ if (kind && blueprintSlot({ kind: kind[2] })) found.set(kind[1], blueprintSlot({ kind: kind[2] }));+ else if (marker && !found.has(marker[1]) && bundled.includes(marker[1])) {+ const slot = blueprintSlot(readBlueprint(marker[1], root));+ if (slot) found.set(marker[1], slot);+ }+ }+ return [...found].map(([name, slot]) => ({ name, slot }));+}+/*** Read every named blueprint, in the order given, before anything is written, so an unknown name* or a clash leaves the repository as it was. The same blueprint version named twice is read once.- * A second product or architecture blueprint is refused with BLUEPRINT_KIND_TAKEN naming both.+ * A second product or architecture blueprint is refused with BLUEPRINT_KIND_TAKEN naming both,+ * whether the first is named in the same command or already on the board; adding again the+ * blueprint the board already has is no clash, since that add changes nothing.** @param {string[]} references - Bundled names or paths, as --blueprint gave them.* @param {string} cwd* @param {string} command - The command to name in the next step, such as "init".+ * @param {{ name: string, slot: string }[]} [installed] - The board's own, from installedBlueprints.* @returns {{ reference: string, blueprint: import('./blueprints.js').Blueprint }[]}*/-export function readBlueprints(references, cwd, command) {+export function readBlueprints(references, cwd, command, installed = []) {const read = [];for (const reference of references) {const blueprint = readBlueprint(reference, cwd);if (read.some((entry) => entry.blueprint.name === blueprint.name && entry.blueprint.version === blueprint.version)) continue;const slot = blueprintSlot(blueprint);+ const onBoard = slot && installed.find((entry) => entry.slot === slot && entry.name !== blueprint.name);+ if (onBoard) {+ throw new Refused('BLUEPRINT_KIND_TAKEN',+ `${onBoard.name} and ${blueprint.name} are both ${slot} blueprints, and this board already has ${onBoard.name}; a board takes one ${slot} blueprint, so add ${blueprint.name} on a board of its own`,+ `keep ${onBoard.name} and leave ${blueprint.name} out of pullboard ${command}`);+ }const holder = slot && read.find((entry) => blueprintSlot(entry.blueprint) === slot);if (holder) {const keep = read.map((entry) => `--blueprint ${entry.reference}`).join(' ');diff --git a/src/blueprints.js b/src/blueprints.jsindex 08358266..e28cf9f8 100644--- a/src/blueprints.js+++ b/src/blueprints.js@@ -227,6 +227,18 @@ export function blueprintMarker(blueprint) {return `<!-- pullboard-blueprint ${blueprint.name} ${blueprint.version} -->`;}+/**+ * The line a blueprint of a kind a board takes one of leaves beside its rows: its name and kind, so+ * a later add or init finds which product or architecture blueprint the board already has, even+ * one read from a local file (#720). Other kinds leave no such line.+ *+ * @param {{ name: string, kind?: string }} blueprint+ * @returns {string | null}+ */+export function blueprintKindMarker(blueprint) {+ return ['product', 'infrastructure', 'architecture'].includes(blueprint.kind) ? `<!-- pullboard-blueprint-kind ${blueprint.name} ${blueprint.kind} -->` : null;+}+/*** The marker line written with the rows while an add is under way: it records which row id each* rule and question key got, so a retry after a failure part way files no row twice and finds the@@ -425,7 +437,9 @@ export function planBlueprint(blueprint, { source, spec, doctrine, existingItemsids[question.key] = id;rows.push({ key: question.key, id, status: 'pending', text, line: `- ${id} [pending, must] ${text} | gate: review` });}- specRows = insertSection(source, spec, { existing: existingSection, name, lines: [...rows.map((row) => row.line), blueprintAddingMarker(blueprint, ids)] });+ const kindLine = blueprintKindMarker(blueprint);+ const kindLines = kindLine && !lines.some((text) => text.trim() === kindLine) ? [kindLine] : [];+ specRows = insertSection(source, spec, { existing: existingSection, name, lines: [...rows.map((row) => row.line), ...kindLines, blueprintAddingMarker(blueprint, ids)] });}const underWay = blueprintAddingMarker(blueprint, ids);const specAfter = specRows.split(/(\r?\n)/u).map((part) => (part.trim() === underWay || (resumed && part === addingLine) ? part.replace(part.trim(), marker) : part)).join('');diff --git a/src/cli.js b/src/cli.jsindex 41404723..195eaa3a 100644--- a/src/cli.js+++ b/src/cli.js@@ -62,7 +62,7 @@ import {unmetRows,} from './spec.js';import { answerQuestion, bundledBlueprints, landBlueprint, planBlueprint, readBlueprint, repoAnswers, saveBlueprint } from './blueprints.js';-import { blueprintStarterNote, combinedSummary, initBlueprintResult, readBlueprints, sharedRowLines } from './blueprint-set.js';+import { blueprintStarterNote, combinedSummary, initBlueprintResult, installedBlueprints, readBlueprints, sharedRowLines } from './blueprint-set.js';import { briefFiles } from './brief.js';import { commitFirst, commitOwnerLines, commitOwners, coordinatorInbox, coordinatorInboxLines, inboxFirst } from './resume.js';import { checkBaseline, prepareCheckBaseline, sayCheckBaseline, refuseCheckSyntax } from './check-baseline.js';@@ -1664,7 +1664,7 @@ function setupCommands(io, { first, second, rest = [], values }) {// Every named blueprint is read and checked before anything is written, so an unknown name,// a broken file, a URL or a second product blueprint leaves the repository untouched (#678,// #720). Past that, init adds each blueprint exactly as pullboard blueprint add does.- const blueprints = readBlueprints(values.blueprint ?? [], io.cwd, 'init');+ const blueprints = readBlueprints(values.blueprint ?? [], io.cwd, 'init', installedBlueprints(info.root));const model = optionalModel(values.model);const linked = relayLinked(info.root);const ctx = linked && model !== undefined ? context(io) : null;@@ -2877,7 +2877,7 @@ function workCommands(io, args) {throw new Refused('USAGE', `pullboard blueprint add <name or file> [--blueprint <name or file>]... | save [file]; bundled: ${bundledBlueprints().join(', ')}`);}// Several blueprints land in the order given, as one result; one lands exactly as before (#720).- const listed = readBlueprints(references, io.cwd, 'blueprint add');+ const listed = readBlueprints(references, io.cwd, 'blueprint add', installedBlueprints(ctx.info.root));const drafted = new Map();const landed = [];for (const { blueprint } of listed) landed.push(await addBlueprint(ctx, board, me, blueprint, { result: listed.length === 1, drafted }));diff --git a/test/blueprint.test.js b/test/blueprint.test.jsindex 9866dda6..707d12a8 100644--- a/test/blueprint.test.js+++ b/test/blueprint.test.js@@ -780,6 +780,38 @@ test('a second blueprint of the same kind is refused [S1,I1]', () => {assert.match(JSON.parse(refused.stdout).error.message, /web-app and website are both product blueprints/u);assert.equal(readFileSync(join(board.repo, 'SPEC.md'), 'utf8'), before, 'SPEC.md is unchanged');+ // A board that already has a product blueprint refuses another in a later command, before any+ // write, whichever was added first; the same blueprint again changes nothing and is no clash.+ const listed = (box) => (JSON.parse(box.run('list', '--all', '--json').stdout).items ?? []).length;+ for (const [first, second] of [['web-app', 'other-product.json'], ['other-product.json', 'web-app']]) {+ const sequential = freshBoard();+ writeFileSync(join(sequential.repo, 'other-product.json'), `${JSON.stringify({ ...PUBLISHED, name: 'other-product', title: 'Other product' })}\n`);+ json(sequential, 'blueprint', 'add', first);+ const spec = readFileSync(join(sequential.repo, 'SPEC.md'), 'utf8');+ const items = listed(sequential);+ const later = sequential.run('blueprint', 'add', second, '--json');+ assert.notEqual(later.status, 0, later.stdout);+ assert.equal(JSON.parse(later.stdout).error.code, 'BLUEPRINT_KIND_TAKEN');+ assert.match(JSON.parse(later.stdout).error.message, /(?=.*web-app)(?=.*other-product)/u, 'the refusal names both');+ assert.equal(readFileSync(join(sequential.repo, 'SPEC.md'), 'utf8'), spec, 'a later second product writes no row');+ assert.equal(listed(sequential), items, 'a later second product files no starter');+ assert.equal(json(sequential, 'blueprint', 'add', first).marked, true, 'the same blueprint again is a no-op');+ assert.equal(readFileSync(join(sequential.repo, 'SPEC.md'), 'utf8'), spec);+ assert.equal(json(sequential, 'blueprint', 'add', 'serverless').blueprint.name, 'serverless', 'an architecture blueprint still joins a product one later');+ }+ const reinit = emptyRepo();+ const once = reinit.run('init', '--blueprint', 'web-app');+ assert.equal(once.status, 0, once.stdout + once.stderr);+ const initSpec = readFileSync(join(reinit.repo, 'SPEC.md'), 'utf8');+ const second = reinit.run('init', '--blueprint', 'ios-app', '--json');+ assert.notEqual(second.status, 0, second.stdout);+ assert.equal(JSON.parse(second.stdout).error.code, 'BLUEPRINT_KIND_TAKEN');+ assert.match(JSON.parse(second.stdout).error.message, /web-app and ios-app are both product blueprints/u);+ assert.equal(readFileSync(join(reinit.repo, 'SPEC.md'), 'utf8'), initSpec, 'a later init with a second product writes no row');+ const again = reinit.run('init', '--blueprint', 'web-app');+ assert.equal(again.status, 0, again.stdout + again.stderr);+ assert.equal(readFileSync(join(reinit.repo, 'SPEC.md'), 'utf8'), initSpec, 'init with the same blueprint again changes no row');+// Any number of practice and beyond-code blueprints sit beside one product and one architecture.const many = emptyRepo();const names = ['web-app', 'serverless', 'test-reliability', 'research', 'writing'];