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(rigor): every row writer skips the board's draft ids [S1,D1,B26]
Corey Olson2222f950b82c
diff --git a/src/blueprints.js b/src/blueprints.jsindex 9ab4655c..cd054094 100644--- a/src/blueprints.js+++ b/src/blueprints.js@@ -454,15 +454,16 @@ export function landBlueprint(blueprint, answers) {* shared, so a text two blueprints share is drafted once (#720).** @param {Blueprint} blueprint- * @param {{ source: string, spec: any, doctrine: any, existingItems: { id: number, title: string, specIds: string[] }[], gate: string, drafted?: Map<string, string> }} board+ * @param {{ source: string, spec: any, doctrine: any, existingItems: { id: number, title: string, specIds: string[] }[], gate: string, drafted?: Map<string, string>, reserved?: string[] }} board* source is SPEC.md's text and spec its parse; doctrine is loadDoctrine's result; existingItems- * are the items on the board; gate is pullboard.json's gate now; drafted maps row text to row id.+ * are the items on the board; gate is pullboard.json's gate now; drafted maps row text to row id;+ * reserved are the ids the board's row drafts hold.* @returns {{ marked: boolean, resumed: boolean, section: { prefix: string, name: string, isNew: boolean }, rows: { key: string, id: string, status: string, text: string, source?: string, line: string }[], shared: { key: string, id: string }[], specRows: string, specAfter: string, ids: Record<string, string>, items: { key: string, title: string, specIds: string[], after: string[], lane?: string, route: string, criterion: string, brief: string }[], existing: Record<string, number>, gate: string | null }}* specRows is the text to write before the items (rows and the under-way marker), specAfter the* text once they are all added (the finished marker); existing maps starter keys already on the* board to their item ids.*/-export function planBlueprint(blueprint, { source, spec, doctrine, existingItems = [], gate, drafted = new Map() }) {+export function planBlueprint(blueprint, { source, spec, doctrine, existingItems = [], gate, drafted = new Map(), reserved = [] }) {const marker = blueprintMarker(blueprint);const lines = source.split(/\r?\n/u);const marked = lines.some((text) => text.trim() === marker);@@ -490,8 +491,8 @@ export function planBlueprint(blueprint, { source, spec, doctrine, existingItemslet specRows = source;if (resumed) ids = addingIds(addingLine, blueprint);else {- // The same rows spec draft numbers against: SPEC.md and the repo's own doctrine.- const numberedRows = [...spec.rows, ...(doctrine?.repo?.rows ?? [])];+ // The same rows spec draft numbers against: SPEC.md, the repo's own doctrine and the board's row drafts (#878).+ const numberedRows = [...spec.rows, ...(doctrine?.repo?.rows ?? []), ...reserved.map((id) => ({ id }))];const allocate = () => {const id = nextRowId(prefix, numberedRows);numberedRows.push({ id });diff --git a/src/cli.js b/src/cli.jsindex 49799ca1..b097e913 100644--- a/src/cli.js+++ b/src/cli.js@@ -2661,8 +2661,8 @@ function readCommands(io, { first, second, rest, values }) {async function rigorDraftHere(io, { second, rest, values }) {if (rest.length > 1) throw new Refused('USAGE', 'pullboard rigor draft <key> "<rule>" --check "<command>" --red <commit> --green <commit> [--section <letter>]');const ctx = context(io);- const { events, actor } = withBoard(ctx, (board) => ({ events: store.events(board), actor: whoAmI(ctx, board).id }));- const result = await rigorDraft({ root: ctx.info.root, config: ctx.config, events, person: store.PERSON, agent: actor },+ const { events, actor, reserved } = withBoard(ctx, (board) => ({ events: store.events(board), actor: whoAmI(ctx, board).id, reserved: store.rowDrafts(board).map((draft) => draft.id) }));+ const result = await rigorDraft({ root: ctx.info.root, config: ctx.config, events, person: store.PERSON, agent: actor, reserved },{ key: second, text: rest[0], check: values.check, red: values.red, green: values.green, section: values.section });io.result?.(result);io.say(`proved ${result.key}: red at ${result.proof.red.commit.slice(0, 12)} (${result.proof.red.problems} problem lines, exit ${result.proof.red.exit}), green at ${result.proof.green.commit.slice(0, 12)} (exit ${result.proof.green.exit})`);@@ -2864,7 +2864,7 @@ async function addBlueprint(ctx, board, me, blueprint, { report = true, result =// only: nothing runs and nothing is fetched (#725).const plan = planBlueprint(landBlueprint(blueprint, repoAnswers(ctx.info.root)), { source, spec, doctrine: ctx.doctrine,existingItems: store.listItems(board, { all: true }).map((item) => ({ id: item.item_id, title: item.item_title, specIds: item.item_spec_ids ? item.item_spec_ids.split(',') : [] })),- gate: String(JSON.parse(configSource).gate ?? ''), drafted });+ gate: String(JSON.parse(configSource).gate ?? ''), drafted, reserved: store.rowDrafts(board).map((draft) => draft.id) });for (const row of plan.rows) drafted.set(row.text, row.id);// Every starter is checked before anything is written, so a refusal leaves the board as it was.// Starters go to a build lane, never the coordinator's; a proposed lane is named, not written (#732).@@ -3984,7 +3984,7 @@ async function specCommand(io, { first, second, rest, values }) {withBoard(ctx, (board) => {if (!ctx.info.isMain || whoAmI(ctx, board).id !== COORDINATOR) throw new Refused('COORDINATOR_ONLY', 'only the coordinator proposes standing rulings; ask your coordinator to run spec draft --doctrine --source');});- const result = proposeDoctrine(ctx, values, second);+ const result = proposeDoctrine(ctx, values, second, (hookRead(ctx, (board) => store.rowDrafts(board)) ?? []).map((draft) => draft.id));io.result?.(result);io.say(result.id);return 0;diff --git a/src/doctrine-rulings.js b/src/doctrine-rulings.jsindex b4801e5a..983e2c67 100644--- a/src/doctrine-rulings.js+++ b/src/doctrine-rulings.js@@ -144,9 +144,10 @@ export function resumeDoctrineNotes(info, doctrine) {* @param {any} ctx the CLI context* @param {{ source?: string, section?: string, aim?: boolean, gate?: string }} values* @param {string} text the ruling+ * @param {string[]} [reserved] ids the board's row drafts hold, which a new ruling skips (#878)* @returns {{ id: string, row: { id: string, status: string, tier: string, text: string, gate: string, section: string } }}*/-export function proposeDoctrine(ctx, values, text) {+export function proposeDoctrine(ctx, values, text, reserved = []) {const doctrine = ctx.doctrine;if (!doctrine.repoExists) throw new Refused('NO_SPEC', `no ${doctrine.name}; run pullboard init before proposing doctrine`);if (doctrine.repo.problems.length) throw new Refused('SPEC_INVALID', `fix the unparsed row in ${doctrine.name} before proposing a ruling`);@@ -155,7 +156,7 @@ export function proposeDoctrine(ctx, values, text) {const prefix = values.section ?? 'DR';const section = sections.find(section => section.prefix === prefix);if (!section && values.section) throw new Refused('SPEC_SECTION', `unknown section "${prefix}" in ${doctrine.name}; use a declared section or omit --section for rulings`);- const used = [...loadSpec(ctx.info.root, ctx.config).rows, ...doctrine.rows];+ const used = [...loadSpec(ctx.info.root, ctx.config).rows, ...doctrine.rows, ...reserved.map((id) => ({ id }))];const numbers = used.map(row => new RegExp(`^${prefix}(\\d+)$`, 'u').exec(row.id)?.[1]).filter(Boolean).map(Number);const id = `${prefix}${Math.max(0, ...numbers) + 1}`;const tier = values.aim ? 'aim' : 'must';diff --git a/src/rigor-draft.js b/src/rigor-draft.jsindex 70085a26..ff53fb4c 100644--- a/src/rigor-draft.js+++ b/src/rigor-draft.js@@ -19,11 +19,12 @@ import { rigorSource } from './rigor-source.js';* has not repeated (pullboard rigor does not list it), the rule text is not one line, or the proof* does not hold. Returns the drafts with their evidence and proof.*- * @param {{ root: string, config: any, events: any[], person: string }} board+ * @param {{ root: string, config: any, events: any[], person: string, reserved?: string[] }} board reserved: ids the board's+ * drafts hold, which a new row skips like any written row (#878)* @param {{ key: string, text: string, check?: string, red?: string, green?: string, section?: string }} request* @returns {Promise<{ key: string, reads: string, evidence: { items: { id: number, commits: string[] }[], occurrences: number, neverAgain: boolean }, proof: object, drafts: object[] }>}*/-export async function rigorDraft({ root, config, events, person, agent }, { key, text, check, red, green, section }) {+export async function rigorDraft({ root, config, events, person, agent, reserved = [] }, { key, text, check, red, green, section }) {const malformed = causeProblem(key ?? '');if (malformed) throw malformed;const cause = rigorReport(events, { person }).causes.find((entry) => entry.key === key);@@ -36,8 +37,8 @@ export async function rigorDraft({ root, config, events, person, agent }, { key,const rowText = `${text.trim()} ${why}`;const source = rigorSource(cause, proof);const drafts = [];- if (cause.reads !== 'product') drafts.push(draftRow(root, config, { target: 'doctrine', text: rowText, gate: `check ${proof.countCheck}`, fields: ['count: 0', `source: ${source}`], section }));- if (cause.reads !== 'work') drafts.push(draftRow(root, config, { target: 'spec', text: rowText, gate: proof.check, fields: [`source: ${source}`], section }));+ if (cause.reads !== 'product') drafts.push(draftRow(root, config, { target: 'doctrine', text: rowText, gate: `check ${proof.countCheck}`, fields: ['count: 0', `source: ${source}`], section, taken: reserved }));+ if (cause.reads !== 'work') drafts.push(draftRow(root, config, { target: 'spec', text: rowText, gate: proof.check, fields: [`source: ${source}`], section, taken: reserved }));return { key, reads: cause.reads, evidence: { items: cause.items, occurrences: cause.occurrences, neverAgain: cause.neverAgain },proof: { check: proof.check, red: proof.red, green: proof.green }, drafts };}diff --git a/test/rigor.test.js b/test/rigor.test.jsindex 06723a37..2a61aeb3 100644--- a/test/rigor.test.js+++ b/test/rigor.test.js@@ -205,6 +205,47 @@ test('a Rigor draft reaches Needs-you with its proof [D1,D3,S1,P6]', () => {assert.equal(json(box, 'resume').rigor.undrafted.length, 0);});+test('independent Rigor writer respects a lane draft reservation [D1,S1,B26]', () => {+ const box = freshBoard();+ const config = join(box.repo, 'pullboard.json');+ writeFileSync(config, `${JSON.stringify({ ...JSON.parse(readFileSync(config, 'utf8')), lanes: { app: { owns: ['app/'] } } }, null, 2)}\n`);+ box.git('add', 'pullboard.json'); box.git('commit', '-q', '-m', 'chore: add the app lane');+ const proof = noticeProof(box);+ const historyBox = noticeHistory(box);+ for (const id of ['Product first', 'Product second'].map(historyBox.add)) { historyBox.submit(id, proof.red); historyBox.reject(id, 'row:G1'); }+ historyBox.close();+ const lane = join(box.dir, 'lane');+ box.git('worktree', 'add', '-q', lane, '-b', 'app/rows');+ /** Run the real CLI in the lane worktree. */+ const inLane = (...args) => runFixtureChild(process.execPath, [BIN, ...args], { cwd: lane, env: box.env, encoding: 'utf8' });+ const joined = inLane('join', 'app', '--model', 'Lane model');+ assert.equal(joined.status, 0, joined.stdout + joined.stderr);+ /** Draft a spec row from the lane and return its id. */+ const laneDraft = (text) => {+ const drafted = inLane('spec', 'draft', text, '--json');+ assert.equal(drafted.status, 0, drafted.stdout + drafted.stderr);+ return JSON.parse(drafted.stdout).id;+ };+ // Lane first, then Rigor in the main checkout; then the lane again, while Rigor's row is still uncommitted there.+ const laneFirst = laneDraft('A lane row drafted before Rigor');+ const rigor = json(box, 'rigor', 'draft', 'row:G1', 'The fixed file exists', '--check', 'test -f fixed.txt', '--red', proof.red, '--green', proof.green);+ const rigorId = rigor.drafts[0].id;+ const laneAfter = laneDraft('A lane row drafted after Rigor');+ assert.equal(new Set([laneFirst, rigorId, laneAfter]).size, 3, `every writer keeps its own id: ${laneFirst}, ${rigorId}, ${laneAfter}`);+ assert.equal(runFixtureGit(['status', '--porcelain'], { cwd: lane, env: box.env, encoding: 'utf8' }).trim(), '', 'the lane edits no file outside its lane');++ const applied = box.run('spec', 'apply');+ assert.equal(applied.status, 0, applied.stdout + applied.stderr);+ assert.doesNotMatch(applied.stdout, /holds other text/u);+ const rows = json(box, 'spec').rows;+ const text = (id) => rows.find((row) => row.id === id)?.text ?? '';+ assert.equal(text(laneFirst), 'A lane row drafted before Rigor');+ assert.equal(text(laneAfter), 'A lane row drafted after Rigor');+ assert.match(text(rigorId), /^The fixed file exists Why: rigor row:G1/u);+ assert.ok([laneFirst, rigorId, laneAfter].every((id) => rows.find((row) => row.id === id)?.status === 'draft'), 'all three stay drafts for the person');+ assert.notEqual(inLane('spec', 'approve', laneFirst).status, 0, 'a lane cannot approve its own draft; the person does');+});+test('automatic Rigor notices retain old replay and include reopen and never-again [D1,H16]', () => {const box = freshBoard();const historyBox = history(box.file);