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(blueprint): run starter checks in their lane [I1,V2]
Corey Olsoncac4fe73386d
diff --git a/src/blueprints.js b/src/blueprints.jsindex cd054094..10ae1948 100644--- a/src/blueprints.js+++ b/src/blueprints.js@@ -27,7 +27,7 @@* accepted. Every rule of an architecture blueprint names its source, or the blueprint is refused* with BLUEPRINT_NO_SOURCE when it is read or saved: an architecture rule paraphrases a known-good* reference, so the row it drafts must say which one. An item's route is light, mid or strong (strong when left out), as pullboard add takes- * it. Its brief, criterion and check pass through to add unchanged, so a light or mid item is filed when it+ * it. Its brief and criterion pass through unchanged; bundled checks use the chosen lane folder. A light or mid item is filed when it* carries what add requires for that route and refused with add's own refusal when it does not.* A check is stored on the item and never run during add: no check baseline starts, so nothing a* blueprint supplies executes. A blueprint is read from the bundled set or a local path, never a URL.@@ -62,6 +62,7 @@ export const BLUEPRINT_KINDS = ['product', 'architecture', 'practice', 'beyond-cconst LEGACY_KINDS = { infrastructure: 'architecture' };const BUNDLED_DIR = fileURLToPath(new URL('./blueprints/', import.meta.url));+const BUNDLED = new WeakSet();const NAME_RE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/u;const KEY_RE = /^[A-Za-z0-9]+$/u;const PREFIX_RE = /^[A-Z][A-Z0-9]*$/u;@@ -77,6 +78,16 @@ export function bundledBlueprints() {return readdirSync(BUNDLED_DIR).filter((file) => file.endsWith('.json')).map((file) => file.slice(0, -5)).sort();}+/** Scope only trusted bundled starters to a unique owned folder; arbitrary local checks keep their meaning. */+export function starterCheck(blueprint, command, placement, config) {+ const owns = placement.proposal?.owns ?? config.lanes[placement.lane]?.owns ?? [];+ if (!BUNDLED.has(blueprint) || owns.length !== 1 || !owns[0].endsWith('/')) return command;+ const folder = owns[0].replace(/\/+$/u, '');+ if (!folder || /[*?{}\[\]]/u.test(folder)) return command;+ const quoted = `'${folder.replaceAll("'", "'\\''")}'`;+ return `cd ${quoted} && (${command})`;+}+/*** Read and check a blueprint: a bundled name such as web-app, or a path to a JSON file.* A bare name is looked up among the bundled ones first, so a stray file cannot shadow it.@@ -104,6 +115,7 @@ export function readBlueprint(reference, cwd) {}const blueprint = validateBlueprint(value, bundled ? text : basename(file));if (bundled && blueprint.name !== text) throw new Refused('BAD_BLUEPRINT', `${text}.json names itself "${blueprint.name}"; its name and file name must match`);+ if (bundled) BUNDLED.add(blueprint);return blueprint;}@@ -437,10 +449,12 @@ export function repoAnswers(root) {* @returns {Blueprint}*/export function landBlueprint(blueprint, answers) {- return { ...blueprint, questions: blueprint.questions.map((question) => {+ const landed = { ...blueprint, questions: blueprint.questions.map((question) => {const answer = question.detect ? answers[question.detect] : undefined;return answer && question.choices.includes(answer) ? { ...question, default: answer } : question;}) };+ if (BUNDLED.has(blueprint)) BUNDLED.add(landed);+ return landed;}/**diff --git a/src/check-baseline.js b/src/check-baseline.jsindex 519abec5..6436afd4 100644--- a/src/check-baseline.js+++ b/src/check-baseline.js@@ -13,7 +13,6 @@ import {tryGit,} from './git.js';import { runShell } from './gate.js';-import { CONFIG_FILE } from './config.js';import { Refused } from './refused.js';/**@@ -29,7 +28,6 @@ export function checkBaseline(root, command, { main = undefined } = {}) {const captured = main === undefined ? prepareCheckBaseline(root, command) : { command, main, result: 'pending' };if (captured.result !== 'pending') return captured;const base = { command, main: captured.main };- if (command === gateOnMain(root, base.main)) return { ...base, result: 'green', reason: 'repo gate' };const directory = mkdtempSync(join(tmpdir(), 'pullboard-check-base-'));const checkout = join(directory, 'checkout');const env = gitChildEnv(root);@@ -65,20 +63,9 @@ export function prepareCheckBaseline(root, command) {if (!primary) return { command, main: null, result: 'unavailable', reason: 'coordinator checkout is detached' };if (!primary.commit) return { command, main: null, result: 'unavailable', reason: 'no main' };const base = { command, main: primary.commit };- if (command === gateOnMain(root, base.main)) return { ...base, result: 'green', reason: 'repo gate' };return { ...base, result: 'pending', request: randomUUID() };}-/** Use main's committed gate for the shortcut; a dirty local config cannot manufacture a green base. */-function gateOnMain(root, main) {- const config = tryGit(root, ['show', `${main}:${CONFIG_FILE}`]);- if (config.status !== 0) return '';- try {- const gate = JSON.parse(config.stdout)?.gate;- return typeof gate === 'string' ? gate.trim() : '';- } catch { return ''; }-}-/*** A check that would prove the work (#917): one that runs the item's new test file. The file is the one the* criterion or brief names, or one named after the item; the runner is the item's own Node test runner when it usesdiff --git a/src/cli.js b/src/cli.jsindex 74a18a5c..f361cc8a 100644--- a/src/cli.js+++ b/src/cli.js@@ -216,6 +216,7 @@ import {answerQuestion,landBlueprint,planBlueprint,+ starterCheck,readBlueprint,repoAnswers,} from './blueprints.js';@@ -1761,9 +1762,8 @@ export async function addBlueprint(ctx, board, me, blueprint, { report = true, rconst proposedLanes = proposals.filter((lane) => lanes.some((placed) => placed.proposal === lane));const starters = plan.items.map((entry, index) => ({ key: entry.key, afterKeys: entry.after, asked: lanes[index].asked, item: { by: me.id, lane: lanes[index].lane,title: entry.title, criterion: entry.criterion, specIds: entry.specIds, parentId: null, after: [], brief: entry.brief, route: entry.route,- ...(entry.check === undefined ? {} : { check: entry.check }) } }));- // The same checks pullboard add uses, before anything is written. A blueprint's item check is- // stored, never run: no check baseline starts during add, so nothing a blueprint supplies executes.+ ...(entry.check === undefined ? {} : { check: starterCheck(blueprint, entry.check, lanes[index], ctx.config) }) } }));+ // Bundled checks are scoped at placement; add stores checks without executing them or starting a baseline.// Every bundled starter carries a check (#724), and only the coordinator sets one, so an agent's// add is refused with the step that works: add it from the coordinator's checkout.if (me.id !== COORDINATOR && starters.some(({ item }) => item.check !== undefined)) {diff --git a/test/blueprint-starter-fixture.js b/test/blueprint-starter-fixture.jsnew file mode 100644index 00000000..f3eccb89--- /dev/null+++ b/test/blueprint-starter-fixture.js@@ -0,0 +1,73 @@+/** Real bundled starter command execution and baseline controls [I1,V2]. */+import assert from 'node:assert/strict';+import {+ mkdirSync,+ realpathSync,+ writeFileSync,+} from 'node:fs';+import { join } from 'node:path';+import {+ bundledBlueprints,+ readBlueprint,+} from '../src/blueprints.js';+import {+ checkBaseline,+ prepareCheckBaseline,+} from '../src/check-baseline.js';+import { runFixtureChild } from './fixture-child.js';++/** Exercise each real bundled shell command, retaining all failures so both defects reproduce. */+export function assertStarterChecks({ emptyRepo, freshBoard, json }) {+ const failures = [];+ for (const name of bundledBlueprints()) {+ const box = emptyRepo();+ const started = box.run('init', '--blueprint', name);+ assert.equal(started.status, 0, started.stdout + started.stderr);+ const lane = join(box.repo, 'app');+ mkdirSync(lane, { recursive: true });+ const items = json(box, 'list', '--all').items;+ for (const item of items) {+ assert.equal(item.item_check_baseline ?? null, null, 'blueprint add never executes a check');+ const command = `trap 'printf "\\n__starter_cwd__%s\\n" "$(pwd -P)"' EXIT; ${item.item_check}`;+ const ran = runFixtureChild('/bin/sh', ['-c', command], { cwd: box.repo, env: box.env, encoding: 'utf8' });+ const observed = /__starter_cwd__([^\n]+)/u.exec(ran.stdout)?.[1];+ try { assert.equal(observed, realpathSync(lane), `${name}: ${item.item_check} executes in its lane, even before its test runner exists`); }+ catch (error) { failures.push(error); }+ }+ assert.equal(items.length, readBlueprint(name).items.length, `${name} files every starter`);+ }+ const chosen = freshBoard({ lanes: { service: { owns: ['services/my api/'], specs: [] } } });+ const folder = join(chosen.repo, 'services', 'my api');+ mkdirSync(folder, { recursive: true });+ const placed = json(chosen, 'blueprint', 'add', 'web-app');+ const first = json(chosen, 'show', String(placed.items[0].id));+ assert.equal(first.item_lane, 'service');+ const ran = runFixtureChild('/bin/sh', ['-c', `trap 'printf "\\n__starter_cwd__%s\\n" "$(pwd -P)"' EXIT; ${first.item_check}`],+ { cwd: chosen.repo, env: chosen.env, encoding: 'utf8' });+ try { assert.equal(/__starter_cwd__([^\n]+)/u.exec(ran.stdout)?.[1], realpathSync(folder), 'the actual chosen lane folder, including spaces, is used'); }+ catch (error) { failures.push(error); }+ const ambiguous = freshBoard({ lanes: { app: { owns: ['src/', 'test/'], specs: [] } } });+ const rootItems = json(ambiguous, 'blueprint', 'add', 'web-app').items;+ assert.equal(json(ambiguous, 'show', String(rootItems[0].id)).item_check, 'npm test',+ 'multiple owned folders keep repo-root semantics rather than choosing one arbitrarily');++ const custom = freshBoard();+ const supplied = readBlueprint('web-app');+ const check = 'node -e "process.stdout.write(process.cwd())"';+ writeFileSync(join(custom.repo, 'local.json'), JSON.stringify({ ...supplied, items: [{ ...supplied.items[0], check }] }));+ const filed = json(custom, 'blueprint', 'add', 'local.json');+ assert.equal(json(custom, 'show', String(filed.items[0].id)).item_check, check,+ 'a local blueprint with a bundled-looking name retains its exact supplied command');++ const command = `${JSON.stringify(process.execPath)} -e 'process.exit(23)'`;+ const baseline = freshBoard({ gate: command });+ const actual = runFixtureChild('/bin/sh', ['-c', command], { cwd: baseline.repo, env: baseline.env, encoding: 'utf8' });+ assert.equal(actual.status, 23, 'the command equal to the committed gate really fails');+ const prepared = prepareCheckBaseline(baseline.repo, command);+ const measured = checkBaseline(baseline.repo, command, { main: baseline.git('rev-parse', 'HEAD') });+ try { assert.equal(prepared.result, 'pending', 'preparation cannot certify a repo gate green without executing it'); }+ catch (error) { failures.push(error); }+ try { assert.equal(measured.result, 'red', 'executing a failing repo-gate command reports red'); }+ catch (error) { failures.push(error); }+ if (failures.length) throw new AggregateError(failures, failures.map(error => error.message).join('\n'));+}diff --git a/test/blueprint.test.js b/test/blueprint.test.jsindex 6bd0594b..c8bf3b06 100644--- a/test/blueprint.test.js+++ b/test/blueprint.test.js@@ -10,6 +10,7 @@ import { bundledBlueprints, readBlueprint, validateBlueprint } from '../src/blueimport { blueprintRowIds, starterStates } from '../src/blueprint-report.js';import { parseSpec } from '../src/spec.js';import { createE2eHelpers } from './e2e-helpers.js';+import { assertStarterChecks } from './blueprint-starter-fixture.js';const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');const PUBLISHED = JSON.parse(readFileSync(resolve(import.meta.dirname, '../src/blueprints/web-app.json'), 'utf8'));@@ -246,7 +247,7 @@ test('every bundled starter item carries a criterion and a check [S1,I1]', () =>const items = readBlueprint(name, process.cwd()).items;assert.equal(added.items.length, items.length, `${name} files every starter`);assert.deepEqual(added.checksNotRun, added.items.map((item) => item.id), `${name}: every check is stored, none run`);- board.expected.push(...items.map((item) => [item.title, item.criterion, item.check]));+ board.expected.push(...items.map((item) => [item.title, item.criterion, `cd 'app' && (${item.check})`]));}for (const { box, expected } of boards) {const filed = json(box, 'list', '--all').items.sort((a, b) => a.item_id - b.item_id);@@ -260,7 +261,7 @@ test('every bundled starter item carries a criterion and a check [S1,I1]', () =>const started = fresh.run('init', '--blueprint', 'web-app');assert.equal(started.status, 0, started.stdout + started.stderr);const startedItems = (JSON.parse(fresh.run('list', '--json').stdout).items ?? []).sort((a, b) => a.item_id - b.item_id);- assert.deepEqual(startedItems.map((item) => [item.item_title, item.item_criterion, item.item_check]), web.items.map((item) => [item.title, item.criterion, item.check]));+ assert.deepEqual(startedItems.map((item) => [item.item_title, item.item_criterion, item.item_check]), web.items.map((item) => [item.title, item.criterion, `cd 'app' && (${item.check})`]));assert.match(started.stdout, new RegExp(`checks stored, not run: ${startedItems.map((item) => `#${item.item_id}`).join(', ')}; no check baseline ran`, 'u'));});@@ -1486,3 +1487,5 @@ test('a Something else answer that names the stack fits a plain Node project [A8assert.equal(proposal.decision, 'answer');assert.equal(proposal.text, `The app is built with: ${stack}. Choices: Next.js, SvelteKit, Rails, Something else.`);});++test("every bundled blueprint's starter check runs from its lane's folder and a baseline never reads green for a command that fails on main [I1,V2]", () => assertStarterChecks({ emptyRepo, freshBoard, json }));diff --git a/test/check-baseline.test.js b/test/check-baseline.test.jsindex d5ef1714..c76c1718 100644--- a/test/check-baseline.test.js+++ b/test/check-baseline.test.js@@ -292,7 +292,7 @@ test('[V2,H3,H16] green baseline warns through add edit show and private next veassert.match(review.stdout, /CRITERION_PROVES_NOTHING/u);});-test('[V2,H3,H16] repo gates skip command execution and baselines preserve clear and missing-main states', async function baselineTransitions() {+test('[V2,H3,H16] repo gates execute before baselines report green and preserve clear and missing-main states', async function baselineTransitions() {const box = project({ content: 'green' });const gateMarker = join(box.dir, 'repo-gate-marker.txt');const gate = fileCheck('green', gateMarker);@@ -301,14 +301,12 @@ test('[V2,H3,H16] repo gates skip command execution and baselines preserve clearbox.git(box.repo, 'add', 'pullboard.json');box.git(box.repo, 'commit', '-q', '-m', 'chore: set the fixture gate');const { item: gated } = addChecked(box, 'Gate check', gate);- assert.deepEqual(gated.item_check_baseline, {- command: gate,- main: box.git(box.repo, 'rev-parse', 'refs/heads/main'),- result: 'green',- reason: 'repo gate',- warning: 'CRITERION_PROVES_NOTHING',- });- assert.equal(existsSync(gateMarker), false, 'an exact gate match never runs its command, even in the temporary clone');+ assert.equal(gated.item_check_baseline.command, gate);+ assert.equal(gated.item_check_baseline.main, box.git(box.repo, 'rev-parse', 'refs/heads/main'));+ assert.equal(gated.item_check_baseline.result, 'green');+ assert.equal(gated.item_check_baseline.reason, undefined, 'a matching gate receives an actual measurement');+ assert.equal(gated.item_check_baseline.warning, 'CRITERION_PROVES_NOTHING');+ assert.equal(existsSync(gateMarker), true, 'an exact gate match runs its command in the temporary clone');const metadataEdit = box.run(box.repo, ['edit', String(gated.item_id), '--brief', 'updated brief', '--json']);assert.equal(metadataEdit.status, 0, `${metadataEdit.stdout}${metadataEdit.stderr}`);