Skip to content

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.

test(proof): break each lane and commit rule [L1,L3,C1,C3,C4]

Corey Olson8f7bd74f2a6e
diff --git a/docs/proof/lanes-and-commits-mutants.mjs b/docs/proof/lanes-and-commits-mutants.mjs
new file mode 100644
index 00000000..e4eb30a2
--- /dev/null
+++ b/docs/proof/lanes-and-commits-mutants.mjs
@@ -0,0 +1,50 @@
+/**
+ * The proof audit of the lane and commit rows, L1 to L4 and C1 to C5 (item #55): 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.
+ * The harness works on a temporary copy, never a real checkout.
+ *
+ * Run it from the repo root: node docs/proof/lanes-and-commits-mutants.mjs
+ */
+import { audit } from './harness.mjs';
+
+const BAD_LANE = ['test/lanes.test.js', 'a config with a bad lane refuses and names the field'];
+const LANE_NAMES = ['test/lanes.test.js', 'lane names list the coordinator first'];
+const LONGEST = ['test/lanes.test.js', "the longest owned prefix decides a path's lane"];
+const IN_LANE = ['test/e2e.test.js', 'a lane commits only inside its folders'];
+const HEADER = ['test/hooks.test.js', 'header format, length, case and period'];
+const CITES = ['test/hooks.test.js', 'feat and fix cite ids; cited ids exist'];
+const PRE_PUSH = ['test/e2e.test.js', 'pre-push runs the gate once per tree'];
+const MERGE_HINT = ['test/hooks.test.js', 'a refused merge message points to the message git writes'];
+const FIXERS = ['test/e2e.test.js', 'pre-commit runs the fixers on fully staged files'];
+const PRE_PUSH_RUN = " const gate = runGate(info.root, ctx.config);\n if (gate.isCached)";
+
+/** Row, the change, its edits as [file, from, to], the test that judges it, and the outcome expected. */
+const MUTANTS = [
+ ['L1', 'a lane may own something other than a list of paths', [['src/config.js', 'if (!isStringList(lane?.owns)) problems.push(', 'if (false) problems.push(']], BAD_LANE, 'red'],
+ ['L1', "a lane's specs may be anything", [['src/config.js', 'if (lane?.specs !== undefined && !isStringList(lane.specs)) {', 'if (false) {']], BAD_LANE, 'red'],
+ ['L1', "a lane's start may be anything", [['src/config.js', "if (lane?.starts !== undefined && typeof lane.starts !== 'string') {", 'if (false) {']], BAD_LANE, 'red'],
+ ['L1', 'a lane may be named all or coordinator', [['src/config.js', "if (!LANE_NAME_RE.test(name) || name === 'all' || name === COORDINATOR) {", 'if (!LANE_NAME_RE.test(name)) {']], BAD_LANE, 'red'],
+ ['L1', 'the coordinator is listed last', [['src/lanes.js', 'return [COORDINATOR, ...Object.keys(config.lanes)];', 'return [...Object.keys(config.lanes), COORDINATOR];']], LANE_NAMES, 'red'],
+ ['L2', 'the first matching prefix decides, not the longest', [['src/lanes.js', 'if (path.startsWith(prefix) && prefix.length > longest) {', 'if (path.startsWith(prefix) && longest === 0) {']], LONGEST, 'red'],
+ ['L2', 'an unowned path belongs to no lane', [['src/lanes.js', ' let owner = COORDINATOR;', " let owner = '';"]], LONGEST, 'red'],
+ ['L3', 'a lane may commit outside its folders', [['src/hooks.js', 'const foreign = outOfLane(config, agent.agent_lane, touched);', 'const foreign = [];']], IN_LANE, 'red'],
+ ['L3', "a move counts only where it lands, not where it left", [['src/hooks.js', 'const paths = fields.slice(index + 1, index + (isMove ? 3 : 2));', 'const paths = fields.slice(index + (isMove ? 2 : 1), index + (isMove ? 3 : 2));']], IN_LANE, 'red'],
+ ['L4', 'a worktree that joined no lane may commit', [['src/hooks.js', " problems.push('this worktree has not joined a lane: pullboard join <lane>');\n return problems;", ' return problems;']], IN_LANE, 'red'],
+ ['C1', 'a header of any length passes', [['src/hooks.js', 'if (header.length > rules.maxHeader) {', 'if (false) {']], HEADER, 'red'],
+ ['C1', 'a header of any type passes', [['src/hooks.js', "const typeRe = new RegExp(`^(${rules.types.join('|')})", 'const typeRe = new RegExp(`^([a-z]+)']], HEADER, 'red'],
+ ['C1', 'a subject may start uppercase', [['src/hooks.js', 'if (/^[A-Z]/.test(subject)) {', 'if (false) {']], HEADER, 'red'],
+ ['C1', 'a subject may end with a period', [['src/hooks.js', "if (subject.endsWith('.')) problems.push(", 'if (false) problems.push(']], HEADER, 'red'],
+ ['C2', 'cited ids need not exist', [['src/hooks.js', '...idProblems(spec, ids).map(', '...[].map(']], CITES, 'red'],
+ ['C2', 'feat and fix may cite nothing', [['src/hooks.js', 'if (type && rules.requireIds.includes(type) && !ids.length) {', 'if (false) {']], CITES, 'red'],
+ ['C3', 'pre-push never runs the gate', [['src/cli.js', PRE_PUSH_RUN, " const gate = { isGreen: true, isCached: false, output: '', seconds: 0, log: '' };\n if (gate.isCached)"]], PRE_PUSH, 'red'],
+ ['C3', 'pre-push runs the gate again on a tree that passed', [['src/cli.js', PRE_PUSH_RUN, " const gate = runGate(info.root, ctx.config, { trustStamp: false });\n if (gate.isCached)"]], PRE_PUSH, 'red'],
+ ['C3', 'pre-push lets through a commit that is not checked out', [['src/hooks.js', 'if (commit !== head) problems.push(', 'if (false) problems.push(']], PRE_PUSH, 'red'],
+ ['C4', 'a refused merge header does not point to the exempt message', [['src/hooks.js', ". For a merge, keep the message git writes, which is exempt: git merge --no-edit'", "'"]], MERGE_HINT, 'red'],
+ ['C4', 'a refused header does not show what it saw', [['src/hooks.js', ' (saw "${header.slice(0, 60)}")', '']], HEADER, 'red'],
+ ['C4', 'a blocked hook drops the note that says what to do', [['src/cli.js', ".join('\\n')}\\n${FIX_NOTE}`);", ".join('\\n')}`);"]], IN_LANE, 'red'],
+ ['C5', 'no fixer ever runs', [['src/hooks.js', ' if (!fixers.length) return [];', ' return [];']], FIXERS, 'red'],
+ ['C5', 'a partly staged file is fixed anyway', [['src/hooks.js', 'covers(fixer, path) && !unstaged.has(path) && existsSync(join(root, path))', 'covers(fixer, path) && existsSync(join(root, path))']], FIXERS, 'red'],
+ ['C5', 'what a fixer fixed is not staged again', [['src/hooks.js', "if (result.status === 0) git(root, ['add', '--', ...files]);", "if (false) git(root, ['add', '--', ...files]);"]], FIXERS, 'red'],
+];
+
+audit(MUTANTS);
diff --git a/docs/proof/lanes-and-commits.md b/docs/proof/lanes-and-commits.md
new file mode 100644
index 00000000..6e8b200c
--- /dev/null
+++ b/docs/proof/lanes-and-commits.md
@@ -0,0 +1,35 @@
+# Proof audit: the lane and commit rows
+
+The lane rows (L1 to L4) and the commit rows (C1 to C5) are enforced by git hooks. No accepted item vouched for them. 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. Item #55 holds it; see also [verification.md](verification.md) and [board.md](board.md).
+
+Re-run it with `node docs/proof/lanes-and-commits-mutants.mjs`. It uses the shared harness, `docs/proof/harness.mjs`, which works on a temporary copy of the repo's tracked folders. The harness checks each target test exists, matches exactly one test and is green before any change.
+
+| Row | Rule | Change that breaks it | Test that must go red | Result |
+|---|---|---|---|---|
+| L1 | Lanes live in pullboard.json: folders owned, spec prefixes, when it starts. | a lane may own something other than a list; its specs or its start may be anything (three changes) | a config with a bad lane refuses and names the field | red, all three, **after this audit** |
+| L1 | | a lane may be named all or coordinator | a config with a bad lane refuses and names the field | red |
+| L1 | | the coordinator is listed last | lane names list the coordinator first | red |
+| L2 | The longest owned prefix decides a path's lane; unowned paths are the coordinator's. | the first matching prefix decides; an unowned path belongs to no lane | the longest owned prefix decides a path's lane | red, both |
+| L3 | In a lane's worktree, pre-commit refuses changes outside the lane, moves included. | a lane may commit outside its folders | a lane commits only inside its folders | red |
+| L3 | | a move counts only where it lands, not where it left | a lane commits only inside its folders | red, **after this audit** |
+| L4 | A worktree that has not joined a lane cannot commit. | a worktree that joined no lane may commit | a lane commits only inside its folders | red |
+| C1 | Header: type(scope): subject [ids], 72 characters at most. | any length; an uppercase subject; a trailing period (three changes) | header format, length, case and period | red, all three |
+| C1 | | a header of any type passes | header format, length, case and period | red, **after this audit** |
+| C2 | Cited ids exist; feat and fix cite at least one. | cited ids need not exist; feat and fix may cite nothing | feat and fix cite ids; cited ids exist and are not retired | red, both |
+| C3 | Pre-push runs the gate, unless this exact tree already passed it. | pre-push never runs the gate | pre-push runs the gate once per tree | red |
+| C3 | | pre-push runs the gate again on a tree that passed | pre-push runs the gate once per tree | red, **after this audit** |
+| C3 | | pre-push lets through a commit that is not checked out | pre-push runs the gate once per tree | red |
+| C4 | Every refusal says what to do and shows what it saw. | a refused merge header does not point to the exempt message | a refused merge message points to the message git writes | red |
+| C4 | | a refused header does not show what it saw | header format, length, case and period | red, **after this audit** |
+| C4 | | a blocked hook drops its note on what to do | a lane commits only inside its folders | red, **after this audit** |
+| C5 | Pre-commit runs the fixers on fully staged files and restages what they fix. | no fixer runs; a partly staged file is fixed anyway; what a fixer fixed is not restaged | pre-commit runs the fixers on fully staged files | red, all three |
+
+## What the audit changed
+
+- **L1:** the bad-lane test used names that fail the name rule first, which returns before the fields are read. So a lane could own a string, cite a string or start at a number, and the test still passed. It now gives a well-named lane three bad fields, checks each is named, and carries L1.
+- **L3:** the move test moved a file out of the lane, which its destination catches. A file moved in from another lane, which only its source catches, was never tried. It is now.
+- **C1:** the unknown-type case, `Added the page`, also fails on its capital and its missing colon. A type outside the list, `feature: …`, is now tried on its own.
+- **C3:** a second push of a tree that passed was never shown to skip the gate. The test now checks the skip message.
+- **C4:** "shows what it saw" and "says what to do" were printed but never asserted. Both are now: the header refusal quotes the header, and a blocked hook ends with its note.
+
+C4 says every refusal does this. The audit tests the hook refusals it changed, not every refusal in the CLI.
diff --git a/test/e2e.test.js b/test/e2e.test.js
index 7698d915..c4a5169f 100644
--- a/test/e2e.test.js
+++ b/test/e2e.test.js
@@ -180,6 +180,7 @@ test('a lane commits only inside its folders; an unjoined worktree cannot commit
assert.match(unjoined.stderr, /has not joined a lane/);
const foreign = commitFile(box, box.web, 'api/a.js', 'a', 'feat(web): page [G1]');
assert.match(foreign.stderr, /outside the web lane: api\/a.js \(api's\)/);
+ assert.match(foreign.stderr, /Fix what each line names/, 'a blocked hook says what to do (C4)');
box.git(box.web, 'reset', '-q', '--hard');
box.git(box.web, 'clean', '-fdq');
assert.equal(commitFile(box, box.web, 'docs/web.md', 'shared', 'docs: web notes').status, 0);
@@ -188,6 +189,14 @@ test('a lane commits only inside its folders; an unjoined worktree cannot commit
box.git(box.web, 'mv', 'web/a.html', 'api/a.html');
const moved = box.tryGit(box.web, 'commit', '-q', '-m', 'refactor(web): move the page');
assert.match(moved.stderr, /outside the web lane: api\/a.html/);
+ assert.equal(commitFile(box, box.repo, 'api/b.js', 'b', 'feat(api): an api file [G2]').status, 0);
+ const second = join(box.dir, 'web-2');
+ box.git(box.repo, 'worktree', 'add', '-q', second, '-b', 'web/two');
+ assert.match(box.run(second, 'join', 'web').out, /joined as web-2/);
+ mkdirSync(join(second, 'web'), { recursive: true });
+ box.git(second, 'mv', 'api/b.js', 'web/b.js');
+ const taken = box.tryGit(second, 'commit', '-q', '-m', 'refactor(web): take the api file');
+ assert.match(taken.stderr, /outside the web lane: api\/b.js/, 'a move counts where it left, not only where it lands');
});
test('submit needs a clean tree, nothing untracked, and the gate green at HEAD [V4, B9]', () => {
@@ -273,6 +282,7 @@ test('pre-push runs the gate once per tree and pushes only the checked-out commi
assert.match(box.run(box.repo, 'gate').out, /this tree already passed/);
const elsewhere = box.tryGit(box.repo, 'push', '-q', 'origin', 'web/one:web/one');
assert.equal(elsewhere.status, 0, 'web/one is at the same commit as main, so it is what is checked out');
+ assert.match(`${elsewhere.stdout}${elsewhere.stderr}`, /the gate passed on this exact tree; not running it twice/, 'the second push of a passed tree skips the gate');
commitFile(box, box.web, 'web/b.html', 'b', 'feat(web): second page [G1]');
const notHere = box.tryGit(box.repo, 'push', '-q', 'origin', 'web/one');
assert.notEqual(notHere.status, 0);
diff --git a/test/hooks.test.js b/test/hooks.test.js
index 9753b0a1..f238d6ab 100644
--- a/test/hooks.test.js
+++ b/test/hooks.test.js
@@ -29,6 +29,8 @@ test('feat and fix cite ids; cited ids exist and are not retired [C2]', () => {
test('header format, length, case and period [C1]', () => {
assert.match(check('Added the page')[0], /type\(scope\): subject/);
+ assert.match(check('Added the page')[0], /saw "Added the page"/, 'the refusal shows the header it saw (C4)');
+ assert.match(check('feature: add the page [G1]')[0], /type\(scope\): subject/, 'a type outside the configured list is refused');
assert.match(check(`docs: ${'x'.repeat(80)}`)[0], /shorten the header to 72 characters or fewer \(it has 86\)/);
assert.deepEqual(check('docs: Explain lanes.'), [
'start the subject with a lowercase letter (saw "Explain lanes.")',
diff --git a/test/lanes.test.js b/test/lanes.test.js
index cd5089c8..80311c39 100644
--- a/test/lanes.test.js
+++ b/test/lanes.test.js
@@ -40,10 +40,14 @@ test('lane names list the coordinator first [L1]', () => {
assert.ok(!isLane(CONFIG, 'all'));
});
-test('a config with a bad lane refuses and names the field', () => {
+test('a config with a bad lane refuses and names the field [L1]', () => {
const problems = configProblems({ ...CONFIG, lanes: { Web: { owns: 'apps/' }, all: { owns: [] } } });
assert.ok(problems.some((problem) => problem.includes('lane "Web"')));
assert.ok(problems.some((problem) => problem.includes('lane "all"')));
+ const fields = configProblems({ ...CONFIG, lanes: { web: { owns: 'apps/', specs: 'B', starts: 5 } } });
+ for (const field of ['"owns" is a list', '"specs" is a list', '"starts" is text']) {
+ assert.ok(fields.some((problem) => problem.includes(`lane "web": ${field}`)), `a well-named lane with a bad field is refused: ${field}`);
+ }
assert.ok(configProblems({ ...CONFIG, verify: 'anyone' }).some((problem) => problem.includes('"verify"')));
});