docs(web): cross-walk editor modules to e2e coverage and open gaps

One row per EDITOR_TYPES entry with the e2e assertion or headed receipt it rests on, a stable MOD-<module>-NN gap register, and a compliance test that keeps the matrix aligned with the editor list and the register.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
mes123456
2026-12-02 13:57:15 +08:00
parent 45b0f9ec74
commit d9ce49d2d5
3 changed files with 159 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
import test from "node:test";
const root = path.resolve(import.meta.dirname, "../../..");
const doc = fs.readFileSync(path.join(root, "docs/web/MODULE-COVERAGE.md"), "utf8");
const workflowSource = fs.readFileSync(path.join(root, "web/protocol/editor-workflow.ts"), "utf8");
/* The editor list is a literal string array; reading the declaration keeps this
* test free of the protocol module graph it imports. A format change fails the
* match below instead of silently comparing against nothing. */
function editorTypes() {
const match = workflowSource.match(/export const EDITOR_TYPES = (\[[^\]]*\]) as const;/);
assert.ok(match, "EDITOR_TYPES declaration not found in editor-workflow.ts");
return JSON.parse(match[1]);
}
function section(title) {
const start = doc.indexOf(`## ${title}`);
assert.ok(start >= 0, `missing section: ${title}`);
const rest = doc.slice(start + title.length + 3);
const end = rest.indexOf("\n## ");
return end >= 0 ? rest.slice(0, end) : rest;
}
function cells(line) {
return line.split("|").slice(1, -1).map((cell) => cell.trim());
}
const editors = editorTypes();
const matrixRows = section("Editor matrix")
.split("\n")
.filter((line) => line.startsWith("| `"))
.map((line) => cells(line));
const registerRows = section("Gap register")
.split("\n")
.filter((line) => line.startsWith("| MOD-"))
.map((line) => cells(line));
test("the module matrix has exactly one row per editor type", () => {
const matrixEditors = matrixRows.map(([editor]) => editor.replaceAll("`", ""));
assert.equal(matrixEditors.length, editors.length);
assert.deepEqual([...matrixEditors].sort(), [...editors].sort());
for (const editor of editors) {
assert.equal(matrixEditors.filter((item) => item === editor).length, 1, `${editor} must appear once`);
}
});
test("every matrix row carries a known coverage level", () => {
const levels = new Set(["PROVEN", "READBACK_OR_PROBE", "GATE_ONLY", "INDIRECT", "UNCOVERED"]);
for (const [editor, , , , level] of matrixRows) {
const name = level.split(" ")[0].replaceAll("`", "");
assert.ok(levels.has(name), `${editor} has an unknown level: ${level}`);
}
});
test("gap ids are unique and every referenced id is registered", () => {
const ids = registerRows.map(([id]) => id);
assert.equal(new Set(ids).size, ids.length, "gap ids must be unique");
const registered = new Set(ids);
for (const [editor, , , , , gaps] of matrixRows) {
for (const match of gaps.matchAll(/MOD-[A-Z0-9_]+-\d{2}/g)) {
assert.ok(registered.has(match[0]), `${editor} references unregistered ${match[0]}`);
}
}
for (const id of ids) assert.match(id, /^MOD-[A-Z0-9_]+-\d{2}$/);
});
test("every registered gap carries a known state and priority", () => {
const states = new Set(["OPEN", "PARTIAL", "BLOCKED", "FROZEN"]);
for (const [id, , , , , priority, state] of registerRows) {
assert.ok(states.has(state.replaceAll("`", "")), `${id} has an unknown state: ${state}`);
assert.match(priority, /^P[1-3]$/);
}
});