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 spec rule; one gap closed [S2]

Corey Olson551b101e9fa3
diff --git a/docs/proof/spec-mutants.mjs b/docs/proof/spec-mutants.mjs
new file mode 100644
index 00000000..a869aa56
--- /dev/null
+++ b/docs/proof/spec-mutants.mjs
@@ -0,0 +1,46 @@
+/**
+ * The proof audit of the spec rows, S1 to S9 (item #57): 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/spec-mutants.mjs
+ */
+import { audit } from './harness.mjs';
+
+const PARSE = ['test/spec.test.js', 'rows parse with id, status, tier, text, gate, serves'];
+const NEVER_DROPPED = ['test/spec.test.js', 'a row-like line that does not parse is an error'];
+const UNIQUE = ['test/spec.test.js', 'ids are unique, retired ones included'];
+const SERVES = ['test/spec.test.js', 'serves links must name real ids and never cycle'];
+const GATES = ['test/spec.test.js', 'approved must-rows name their gate'];
+const SIGNOFF = ['test/spec.test.js', 'a sign-off holds the text it approved'];
+const BOTH_FILES = ['test/e2e.test.js', 'spec check lints both files'];
+const ONE_PAGE = ['test/view.test.js', 'one self-contained page with every tab and every row'];
+const PERMANENT = ['test/spec.test.js', 'an id once committed or cited never leaves the spec'];
+const DELETED = ['test/e2e.test.js', 'a deleted spec row is refused at commit'];
+const WONT = ['test/spec.test.js', 'a row marked wont stays with its id'];
+const ROW_PARSED = ' spec.rows.push({ id, status, tier: tier ?? \'\', ...fields, section: section.name, line: lineNo });';
+
+/** Row, the change, its edits as [file, from, to], the test that judges it, and the outcome expected. */
+const MUTANTS = [
+ ['S1', 'a row that does not parse is dropped silently', [['src/spec.js', " spec.problems.push({ line: lineNo, message: 'row does not parse: - ID [status, tier] text | gate: ... | serves: ...' });\n", '']], NEVER_DROPPED, 'red'],
+ ['S1', 'a row loses what it serves', [['src/spec.js', ROW_PARSED, " spec.rows.push({ id, status, tier: tier ?? '', ...fields, serves: [], section: section.name, line: lineNo });"]], PARSE, 'red'],
+ ['S1', 'a row loses its gate', [['src/spec.js', ROW_PARSED, " spec.rows.push({ id, status, tier: tier ?? '', ...fields, gate: '', section: section.name, line: lineNo });"]], PARSE, 'red'],
+ ['S2', 'a duplicate id passes', [['src/spec.js', ' if (seen.has(row.id)) {', ' if (false) {']], UNIQUE, 'red'],
+ ['S2', "a new row may reuse a retired row's id", [['src/spec.js', ' } else seen.set(row.id, row.line);', " } else if (row.status !== 'retired') seen.set(row.id, row.line);"]], UNIQUE, 'red'],
+ ['S2', 'a retired row may repeat a live id', [['src/spec.js', ' if (seen.has(row.id)) {', " if (seen.has(row.id) && row.status !== 'retired') {"]], UNIQUE, 'red'],
+ ['S3', 'serves may name an id the spec lacks', [['src/spec.js', ' if (!seen.has(target) && !spec.rows.some((other) => other.id === target)) {', ' if (false) {']], SERVES, 'red'],
+ ['S3', 'serves links may cycle', [['src/spec.js', ' if (cycle) {', ' if (false) {']], SERVES, 'red'],
+ ['S4', 'an approved must-row may leave out its gate', [['src/spec.js', " if (row.status === 'approved' && row.tier === 'must' && !row.gate) {", ' if (false) {']], GATES, 'red'],
+ ['S5', 'a sign-off counts whatever the row says now', [['src/spec.js', ' if (textOf.get(signoff.id) === signoff.text) standing.met.push(signoff);', ' if (true) standing.met.push(signoff);']], SIGNOFF, 'red'],
+ ['S5', 'a sign-off records no text', [['src/spec.js', 'JSON.stringify({ id, by, on, text: byId.get(id).text })', 'JSON.stringify({ id, by, on })']], SIGNOFF, 'red'],
+ ['S5', 'a row that is not approved can be signed', [['src/spec.js', " return row.status === 'approved' ? [] : [`${id} is ${row.status}; only approved rows are signed`];", ' return [];']], SIGNOFF, 'red'],
+ ['S6', 'spec check lints SPEC.md only', [['src/cli.js', 'const files = [[ctx.config.spec, spec], ...(practice.exists ? [[ctx.config.practice, practice]] : [])];', 'const files = [[ctx.config.spec, spec]];']], BOTH_FILES, 'red'],
+ ['S7', 'the page leaves out its practice tab', [['src/view.js', '<label for="t-practice">Practice</label>', '']], ONE_PAGE, 'red'],
+ ['S8', 'a committed id may leave the spec', [['src/spec.js', " .filter(([id]) => !present.has(id))\n .map(([id, commit]) => ({", " .filter(() => false)\n .map(([id, commit]) => ({"]], PERMANENT, 'red'],
+ ['S8', 'an id cited but never committed passes', [['src/spec.js', ' if (!present.has(id) && !committed.has(id)) {', ' if (false) {']], PERMANENT, 'red'],
+ ['S8', 'commit lets a row be deleted', [['src/spec.js', ' return parseSpec(before).rows.map((row) => row.id).filter((id) => !kept.has(id));', ' return [];']], DELETED, 'red'],
+ ['S9', 'a wont row can be cited', [['src/spec.js', " if (row.status === 'wont') return [`${id} is marked won't build; the person reopens it first`];", '']], WONT, 'red'],
+ ['S9', 'a wont row counts as unmet', [['src/spec.js', " row.status === 'approved' &&\n (!mustOnly || row.tier === 'must') &&", " row.status !== 'retired' &&\n (!mustOnly || row.tier === 'must') &&"]], WONT, 'red'],
+];
+
+audit(MUTANTS);
diff --git a/docs/proof/spec.md b/docs/proof/spec.md
new file mode 100644
index 00000000..e7714be2
--- /dev/null
+++ b/docs/proof/spec.md
@@ -0,0 +1,34 @@
+# Proof audit: the spec rows
+
+S1 to S9 govern SPEC.md and PRACTICE.md themselves:
+- the row format;
+- ids that are unique and permanent;
+- serves links;
+- gates on approved must-rows;
+- sign-offs that hold the text they approved;
+- the offline spec view;
+- rows marked wont.
+
+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 #57 holds it; see also [verification.md](verification.md), [board.md](board.md) and [lanes-and-commits.md](lanes-and-commits.md).
+
+Re-run it with `node docs/proof/spec-mutants.mjs`. It uses the shared harness, `docs/proof/harness.mjs`, which works on a temporary copy of the repo's tracked folders.
+
+| Row | Rule | Change that breaks it | Test that must go red | Result |
+|---|---|---|---|---|
+| S1 | One row per line: id, status, text, gate, what it serves. | a row that does not parse is dropped silently | a row-like line that does not parse is an error, never dropped | red |
+| S1 | | a row loses what it serves; a row loses its gate | rows parse with id, status, tier, text, gate, serves, section and line | red, both |
+| S2 | Ids are unique forever; retired rows stay, so no id is reused. | a duplicate id passes | ids are unique, retired ones included | red |
+| S2 | | a new row may reuse a retired row's id | ids are unique, retired ones included | red |
+| S2 | | a retired row may repeat a live id | ids are unique, retired ones included | red, **after this audit** |
+| S3 | Serves links name real ids and never cycle. | serves may name a missing id; serves links may cycle | serves links must name real ids and never cycle | red, both |
+| S4 | Approved must-rows name their gate. | an approved must-row may leave out its gate | approved must-rows name their gate | red |
+| S5 | A sign-off keeps the text it approved; changing the row makes it stale. | a sign-off counts whatever the row says now; it records no text; a row that is not approved can be signed | a sign-off holds the text it approved; changing the row makes it stale | red, all three |
+| S6 | PRACTICE.md uses the same format; spec check lints both. | spec check lints SPEC.md only | spec check lints both files | red |
+| S7 | `pullboard spec view` renders spec, questions, sign-offs and practice as one offline page. | the page leaves out its practice tab | one self-contained page with every tab and every row | red |
+| S8 | Ids are permanent: commit refuses a deleted row; spec check finds ids once committed or cited, now gone. | a committed id may leave; a cited, never-committed id passes | an id once committed or cited never leaves the spec | red, both |
+| S8 | | commit lets a row be deleted | a deleted spec row is refused at commit | red |
+| S9 | A wont row stays with its id, out of the counts; nothing new may cite it. | a wont row can be cited; a wont row counts as unmet | a row marked wont stays with its id, drops out of the counts | red, both |
+
+## What the audit changed
+
+The spec rows were the best tested of the four audits so far: 19 changes, and only one slipped at first. The S2 test covered a retired id reused by a new row. It never tried the other order, a retired row that repeats an id still live. Both break "ids are unique forever", so the test now covers both. The audit also targets reuse itself with a change that skips recording retired ids. The test catches that change, as it always would have.
diff --git a/test/spec.test.js b/test/spec.test.js
index 7f31be91..882a2f96 100644
--- a/test/spec.test.js
+++ b/test/spec.test.js
@@ -65,6 +65,8 @@ test('rows inside code fences are examples, not rows', () => {
test('ids are unique, retired ones included [S2]', () => {
const findings = lintSpec(parseSpec('## G\n- G1 [retired] Old.\n- G1 [draft] New.\n'));
assert.match(findings[0].message, /duplicate id; first on line 2/);
+ const later = lintSpec(parseSpec('## G\n- G1 [draft] New.\n- G1 [retired] Old.\n'));
+ assert.match(later[0].message, /duplicate id; first on line 2/, 'a retired row that repeats a live id is a duplicate too');
});
test('serves links must name real ids and never cycle [S3]', () => {