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): read draft reservations after the proof [S1,D1,B26]
Corey Olson8a5491a1ce1f
diff --git a/src/cli.js b/src/cli.jsindex b097e913..99fd9818 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, 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 },+ 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, reserved: () => (hookRead(ctx, (board) => store.rowDrafts(board)) ?? []).map((draft) => draft.id) },{ 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})`);diff --git a/src/rigor-draft.js b/src/rigor-draft.jsindex ff53fb4c..fa647ae3 100644--- a/src/rigor-draft.js+++ b/src/rigor-draft.js@@ -19,12 +19,13 @@ 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, reserved?: string[] }} board reserved: ids the board's- * drafts hold, which a new row skips like any written row (#878)+ * @param {{ root: string, config: any, events: any[], person: string, reserved?: () => string[] }} board reserved: reads the ids+ * the board's drafts hold, which a new row skips like any written row (#878). It is read after the proof, right+ * before each write, so a lane draft made while a slow proof runs still counts.* @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, reserved = [] }, { 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);@@ -37,8 +38,8 @@ export async function rigorDraft({ root, config, events, person, agent, reservedconst 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, taken: reserved }));- if (cause.reads !== 'work') drafts.push(draftRow(root, config, { target: 'spec', text: rowText, gate: proof.check, fields: [`source: ${source}`], section, taken: reserved }));+ 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 2a61aeb3..a3035c26 100644--- a/test/rigor.test.js+++ b/test/rigor.test.js@@ -246,6 +246,42 @@ test('independent Rigor writer respects a lane draft reservation [D1,S1,B26]', (assert.notEqual(inLane('spec', 'approve', laneFirst).status, 0, 'a lane cannot approve its own draft; the person does');});+test('a lane draft made while a Rigor proof runs still keeps its id [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');+ const joined = runFixtureChild(process.execPath, [BIN, 'join', 'app', '--model', 'Lane model'], { cwd: lane, env: box.env, encoding: 'utf8' });+ assert.equal(joined.status, 0, joined.stdout + joined.stderr);+ // The proof's own check drafts from the lane the first time it runs, so the draft lands mid-proof.+ const result = join(box.dir, 'mid-proof-draft.json');+ const drafter = join(box.dir, 'mid-proof-draft.mjs');+ writeFileSync(drafter, [+ "import { existsSync, writeFileSync } from 'node:fs';",+ "import { spawnSync } from 'node:child_process';",+ `if (!existsSync(${JSON.stringify(result)})) {`,+ ` const drafted = spawnSync(${JSON.stringify(process.execPath)}, [${JSON.stringify(BIN)}, 'spec', 'draft', 'A lane row drafted mid-proof', '--json'], { cwd: ${JSON.stringify(lane)}, env: ${JSON.stringify(box.env)}, encoding: 'utf8' });`,+ ` writeFileSync(${JSON.stringify(result)}, JSON.stringify({ status: drafted.status, out: drafted.stdout + drafted.stderr }));`,+ '}',+ ].join('\n'));+ const check = `node ${drafter} && test -f fixed.txt`;+ const rigor = json(box, 'rigor', 'draft', 'row:G1', 'The fixed file exists', '--check', check, '--red', proof.red, '--green', proof.green);+ const midProof = JSON.parse(readFileSync(result, 'utf8'));+ assert.equal(midProof.status, 0, midProof.out);+ const laneId = JSON.parse(midProof.out).id;+ assert.notEqual(rigor.drafts[0].id, laneId, `Rigor's ${rigor.drafts[0].id} skips the lane draft made during its proof`);+ const applied = box.run('spec', 'apply');+ assert.equal(applied.status, 0, applied.stdout + applied.stderr);+ assert.doesNotMatch(applied.stdout, /holds other text/u);+ assert.equal(json(box, 'spec').rows.find((row) => row.id === laneId)?.text, 'A lane row drafted mid-proof');+});+test('automatic Rigor notices retain old replay and include reopen and never-again [D1,H16]', () => {const box = freshBoard();const historyBox = history(box.file);