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
test(proof): break each verification rule; three gaps closed [V2,V4,V9]
Corey Olson722ab6bb245a
diff --git a/docs/proof/verification-mutants.mjs b/docs/proof/verification-mutants.mjsnew file mode 100644index 00000000..1daa75cb--- /dev/null+++ b/docs/proof/verification-mutants.mjs@@ -0,0 +1,77 @@+/**+ * The proof audit of the verification rows, V1 to V9 (item #48): for each row, one or more changes to+ * src/ that break the row's rule, and the tagged test that must go red under each. It copies the+ * repo to a fresh temporary folder and works only there, so it never changes a real checkout.+ *+ * Run it from the repo root: node docs/proof/verification-mutants.mjs+ */+import { spawnSync } from 'node:child_process';+import { cpSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';++const ROOT = resolve(import.meta.dirname, '..', '..');+const COPIED = ['src', 'bin', 'test', 'templates', 'skills', 'package.json', 'PRACTICE.md'];++const VERIFY_AT_COMMIT = ['test/e2e.test.js', 'verify runs at the submitted commit, against the criterion frozen at claim'];+const CLEAN_TREE = ['test/e2e.test.js', 'submit needs a clean tree, nothing untracked, and the gate green at HEAD'];+const VERDICT_RULES = ['test/board.test.js', 'ACCEPT needs CRITERION_MET'];+const BOARD_CRITERION = ['src/board.js', ' criterionUnchanged: (found) =>\n digest === found.item_frozen_digest', ' criterionUnchanged: (found) =>\n true || digest === found.item_frozen_digest'];+const CLI_CRITERION = ['src/cli.js', 'if (digest !== item.item_frozen_digest) {', 'if (false) {'];+const RED_GATE = ['src/cli.js', "if (!gate.isGreen) throw new Refused('GATE_RED'", "if (false) throw new Refused('GATE_RED'"];+const VERDICT_ROW = '.run(id, agentId, decision, code, note.trim(), found.item_commit, digest, head, now(board));';++/** Row, the change, its edits as [file, from, to], the test that judges it, and the outcome expected. */+const MUTANTS = [+ ['V1', 'the builder may verify its own work', [['src/board.js', "notBuilder: (found) => (found.item_built_by === agentId ? new Refused('SELF_VERIFY', 'the builder never verifies its own work; another agent must') : null),", 'notBuilder: () => null,']], ['test/board.test.js', 'the builder never verifies its own work'], 'red'],+ ['V2', 'every claim refreezes the criterion', [['src/board.js', ' if (found.item_frozen_digest !== null) return null;\n', '']], ['test/board.test.js', 'the first claim freezes the criterion'], 'red'],+ ['V2', 'the freeze leaves out the title', [['src/spec.js', 'JSON.stringify({ title: item.item_title, criterion:', 'JSON.stringify({ criterion:']], ['test/spec.test.js', 'the frozen criterion covers title'], 'red'],+ ['V2', 'the freeze leaves out the cited row text', [['src/spec.js', 'return { id, text: row.text, gate: row.gate };', 'return { id, gate: row.gate };']], ['test/spec.test.js', 'the frozen criterion covers title'], 'red'],+ ['V3', 'the board takes a verdict against a moved criterion', [BOARD_CRITERION], ['test/board.test.js', 'a verdict against a moved criterion is refused'], 'red'],+ ['V3', 'the CLI and the board both take a moved criterion', [BOARD_CRITERION, CLI_CRITERION], VERIFY_AT_COMMIT, 'red'],+ ['V3', "the CLI's own check alone is removed; the board still refuses with the same code", [CLI_CRITERION], VERIFY_AT_COMMIT, 'green'],+ ['V4', 'submit takes a dirty tree', [['src/cli.js', "if (!isClean(root)) throw new Refused('DIRTY'", "if (false) throw new Refused('DIRTY'"]], CLEAN_TREE, 'red'],+ ['V4', 'submit takes untracked files', [['src/cli.js', "if (stray.length) throw new Refused('UNTRACKED'", "if (false) throw new Refused('UNTRACKED'"]], CLEAN_TREE, 'red'],+ ['V4', 'submit takes a red gate', [RED_GATE], ['test/e2e.test.js', 'a red gate refuses submit'], 'red'],+ ['V5', 'an accept needs no proof note', [['src/board.js', ' proofNoted: () =>\n note.trim()', ' proofNoted: () =>\n true || note.trim()']], VERDICT_RULES, 'red'],+ ['V5', 'an accept may give another reason', [['src/board.js', 'reasonIsMet: () => (reason && reason !== ACCEPT_REASON ?', 'reasonIsMet: () => (false ?']], VERDICT_RULES, 'red'],+ ['V5', 'a reject needs no reason code', [['src/board.js', 'reasonCoded: () => (reason && REJECT_REASONS.includes(reason) ? null :', 'reasonCoded: () => (true ? null :']], VERDICT_RULES, 'red'],+ ['V5', 'a reject needs no note', [['src/board.js', `noteGiven: () => (note.trim() ? null : new Refused('NOTE_REQUIRED', 'a reject says what failed: --note "..."')),`, 'noteGiven: () => null,']], VERDICT_RULES, 'red'],+ ['V6', 'a rejected head may be submitted again', [['src/board.js', "return wasRejected ? new Refused('HEAD_NOT_NEW'", "return false ? new Refused('HEAD_NOT_NEW'"]], ['test/board.test.js', 'REJECT reopens the item'], 'red'],+ ['V6', 'a reject leaves the item submitted', [['src/machine.js', "verb: 'reject', from: ['submitted'], to: 'open',", "verb: 'reject', from: ['submitted'], to: 'submitted',"]], ['test/board.test.js', 'REJECT reopens the item'], 'red'],+ ['V7', 'verify runs from a checkout without the commit', [['src/cli.js', 'if (!commit || !contains(root, commit, head)) {', 'if (!commit) {']], VERIFY_AT_COMMIT, 'red'],+ ['V8', "a verdict binds the verifier's head as the commit", [['src/board.js', VERDICT_ROW, VERDICT_ROW.replace('found.item_commit', 'head')]], ['test/board.test.js', 'every verdict binds the submitted commit'], 'red'],+ ['V8', 'a verdict binds no digest', [['src/board.js', VERDICT_ROW, VERDICT_ROW.replace('digest, head', "'none', head")]], ['test/board.test.js', 'every verdict binds the submitted commit'], 'red'],+ ['V9', 'the main checkout verifies without --as coordinator', [['src/cli.js', ' if (values.as === COORDINATOR) return;\n const agents = store.listAgents(board)', ' return;\n const agents = store.listAgents(board)']], VERIFY_AT_COMMIT, 'red'],+];++const copy = mkdtempSync(join(tmpdir(), 'pullboard-proof-'));+try {+ for (const entry of COPIED) cpSync(join(ROOT, entry), join(copy, entry), { recursive: true });+ /** Run one test by name in the copy: whether it passed, and how many tests the name matched. */+ const judge = ([file, name]) => {+ const result = spawnSync(process.execPath, ['--disable-warning=ExperimentalWarning', '--test', `--test-name-pattern=${name}`, file], { cwd: copy, encoding: 'utf8', timeout: 300_000 });+ return { green: result.status === 0, matched: Number(/^# tests (\d+)/m.exec(result.stdout ?? '')?.[1] ?? 0) };+ };+ const baselines = [...new Set(MUTANTS.map(([, , , target]) => JSON.stringify(target)))].map((target) => judge(JSON.parse(target)));+ if (!baselines.every(({ green, matched }) => green && matched === 1)) throw new Error('the unchanged copy is not green on every target, so no red below would mean anything');+ let unexpected = 0;+ for (const [row, change, edits, target, expected] of MUTANTS) {+ const before = new Map(edits.map(([file]) => [file, readFileSync(join(copy, file), 'utf8')]));+ const after = new Map(before);+ for (const [file, from, to] of edits) {+ if (!after.get(file).includes(from)) throw new Error(`${row}: the code to change is gone from ${file}; update this audit`);+ after.set(file, after.get(file).replace(from, to));+ }+ for (const [file, text] of after) writeFileSync(join(copy, file), text);+ const { green } = judge(target);+ for (const [file, text] of before) writeFileSync(join(copy, file), text);+ const outcome = green ? 'green' : 'red';+ if (outcome !== expected) unexpected += 1;+ console.log(`${outcome === expected ? 'ok ' : 'UNEXPECTED'} ${row} ${outcome.padEnd(5)} ${change} (${target[1]})`);+ }+ console.log(`${MUTANTS.length} changes, ${unexpected} unexpected; the unchanged copy is green on all ${baselines.length} targets`);+ process.exitCode = unexpected ? 1 : 0;+} finally {+ rmSync(copy, { recursive: true, force: true });+}diff --git a/docs/proof/verification.md b/docs/proof/verification.mdnew file mode 100644index 00000000..795db4f4--- /dev/null+++ b/docs/proof/verification.md@@ -0,0 +1,41 @@+# Proof audit: the verification rows, V1 to V9++Each verification row was built before the board could verify anything, so no accepted item vouched for it. This audit breaks each row's rule in `src/`, one change at a time, and checks that a test carrying the row's id goes red. A row whose tests stay green under a broken rule is not proven, however long its tests have passed.++Re-run it with `node docs/proof/verification-mutants.mjs`. It copies the repo to a temporary folder and changes only that copy. First it checks that every target test is green on the unchanged copy, since a red that was already there proves nothing. It exits 1 if any change comes out other than expected.++| Row | Rule | Change that breaks it | Test that must go red | Result |+|---|---|---|---|---|+| V1 | The builder never verifies its own work. | `notBuilder` always passes | the builder never verifies its own work | red |+| V2 | The criterion freezes at first claim: title, criterion and cited rows. | every claim freezes again | the first claim freezes the criterion; later claims keep it | red |+| V2 | | the freeze leaves out the title | the frozen criterion covers title, criterion and cited row text | red, **after this audit** |+| V2 | | the freeze leaves out the cited row text | the frozen criterion covers title, criterion and cited row text | red |+| V3 | Verify refuses when the frozen criterion has changed. | the board's `criterionUnchanged` always passes | a verdict against a moved criterion is refused | red |+| V3 | | the board's check and the CLI's both pass | verify runs at the submitted commit, against the criterion frozen at claim | red |+| V3 | | the CLI's check alone is removed | verify runs at the submitted commit, against the criterion frozen at claim | green, as expected: the board refuses with the same code |+| V4 | Submit needs a clean tree and the gate green at HEAD. | submit takes a dirty tree | submit needs a clean tree, nothing untracked, and the gate green at HEAD | red |+| V4 | | submit takes untracked files | submit needs a clean tree, nothing untracked, and the gate green at HEAD | red |+| V4 | | submit takes a red gate | a red gate refuses submit | red, **once tagged V4 by this audit** |+| V5 | ACCEPT needs CRITERION_MET and a note; REJECT needs a reason code and a note. | no proof note; another reason; no reason code; no note (four changes) | ACCEPT needs CRITERION_MET; REJECT needs a reason code and a note | red, all four |+| V6 | REJECT reopens the item. Resubmitting needs a new head. | a rejected head may be submitted again; a reject leaves the item submitted | REJECT reopens the item; resubmitting a rejected head is refused | red, both |+| V7 | The verifier's checkout contains the submitted commit. | verify skips the containment check | verify runs at the submitted commit, against the criterion frozen at claim | red |+| V8 | Every verdict binds the submitted commit and the frozen digest. | the verdict records the verifier's head as the commit; the verdict records no digest | every verdict binds the submitted commit and the frozen digest | red, both |+| V9 | In the main checkout, verifying needs --as coordinator. | the main checkout verifies without --as | verify runs at the submitted commit, against the criterion frozen at claim | red, **once tagged V9 by this audit** |++## What the audit changed++- **V2:** the freeze test checked that a reworded row and a changed criterion move the digest, but never the title. A freeze without the title passed. It now asserts that a changed title moves the digest too.+- **V4:** the red-gate case was tested by "a red gate refuses submit", which carried no row id. So the row's own test went green with the red-gate refusal removed. That test now carries V4.+- **V9:** the main-checkout rule was checked inside the V3 and V7 test, but no test named V9. That test now carries V9.++## Open finding: a hand-written stamp passes a red gate (V4, drafted as V16)++`runGate` skips the gate when `pullboard-gate-green` in the git dir holds the committed tree's hash, and any agent can write that file. Reproduced on a fresh repo whose gate was red:++```+pullboard submit 1 -> [GATE_RED] the gate is red at 8c6b3057c8d7+git rev-parse 'HEAD^{tree}' > "$(git rev-parse --git-path pullboard-gate-green)"+pullboard submit 1 -> submitted #1 at 8c6b3057c8d7; gate green (this tree already passed)+```++So V4's "the gate green at HEAD" holds only for agents that don't forge the stamp. On one machine, any file pullboard writes an agent can write too. V16, drafted in SPEC.md, has submit run the gate itself on the tree it submits. Until then, a verifier's own gate run at the submitted commit is the only real check of a green gate.diff --git a/test/e2e.test.js b/test/e2e.test.jsindex c8cc69f7..14b2adc1 100644--- a/test/e2e.test.js+++ b/test/e2e.test.js@@ -215,7 +215,7 @@ test('pullboard worktree makes a joined worktree for a lane in one command [I4]'assert.match(box.run(box.repo, 'worktree', 'nope').err, /NO_LANE/);});-test('a red gate refuses submit', () => {+test('a red gate refuses submit [V4]', () => {const box = project();writeFileSync(join(box.repo, 'RED'), 'red');box.git(box.repo, 'add', 'RED');@@ -227,7 +227,7 @@ test('a red gate refuses submit', () => {assert.match(refused.err, /GATE_RED/);});-test('verify runs at the submitted commit, against the criterion frozen at claim [V3, V7]', () => {+test('verify runs at the submitted commit, against the criterion frozen at claim [V3, V7, V9]', () => {const box = project();box.run(box.repo, 'add', 'web', 'Page', '--specs', 'G1', '--criterion', 'renders a heading');box.run(box.web, 'claim', '1');diff --git a/test/spec.test.js b/test/spec.test.jsindex 4ba3eb5e..7f31be91 100644--- a/test/spec.test.js+++ b/test/spec.test.js@@ -105,6 +105,7 @@ test('the frozen criterion covers title, criterion and cited row text [V2]', ()const reworded = SPEC.replace('Same file twice is a no-op.', 'Same file twice changes nothing.');assert.notEqual(frozenCriterion(parseSpec(reworded), item).digest, first.digest);assert.notEqual(frozenCriterion(parseSpec(SPEC), { ...item, item_criterion: 'other' }).digest, first.digest);+ assert.notEqual(frozenCriterion(parseSpec(SPEC), { ...item, item_title: 'Load once' }).digest, first.digest, 'the title is frozen too');assert.throws(() => frozenCriterion(parseSpec(SPEC), { ...item, item_spec_ids: 'G9' }), /UNKNOWN_SPEC/);});