@afokapu/atdd-bun 0.5.0 → 0.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +30 -0
  2. package/conventions/atdd-bun.planner/atdd-bun.planner.acceptance-identity.convention.yaml +27 -0
  3. package/conventions/atdd-bun.planner/atdd-bun.planner.identity-required.convention.yaml +28 -0
  4. package/conventions/atdd-bun.planner/atdd-bun.planner.identity-unique.convention.yaml +27 -0
  5. package/conventions/atdd-bun.planner/atdd-bun.planner.interlocking-participant-resolves.convention.yaml +28 -0
  6. package/conventions/atdd-bun.planner/atdd-bun.planner.parse.convention.yaml +27 -0
  7. package/conventions/atdd-bun.planner/atdd-bun.planner.reference-resolves.convention.yaml +28 -0
  8. package/conventions/atdd-bun.planner/atdd-bun.planner.schema.convention.yaml +30 -0
  9. package/conventions/atdd-bun.planner/atdd-bun.planner.train-wagon-resolves.convention.yaml +26 -0
  10. package/conventions/atdd-bun.topology/atdd-bun.topology.e2e-location.convention.yaml +38 -0
  11. package/conventions/atdd-bun.topology/atdd-bun.topology.feature-source-coverage.convention.yaml +30 -0
  12. package/conventions/atdd-bun.topology/atdd-bun.topology.feature-test-coverage.convention.yaml +29 -0
  13. package/conventions/atdd-bun.topology/atdd-bun.topology.plan-location.convention.yaml +31 -0
  14. package/conventions/atdd-bun.topology/atdd-bun.topology.source-location.convention.yaml +33 -0
  15. package/conventions/atdd-bun.topology/atdd-bun.topology.test-location.convention.yaml +34 -0
  16. package/detectors/atdd_topology/atdd.implementation.yaml +16 -0
  17. package/detectors/atdd_topology/detect.mjs +182 -0
  18. package/detectors/atdd_topology/fixtures/clean/atdd-bun.yaml +2 -0
  19. package/detectors/atdd_topology/fixtures/clean/e2e/interlockings/checkout/nominal.routes.test.ts +4 -0
  20. package/detectors/atdd_topology/fixtures/clean/e2e/journeys/checkout.journey.test.ts +5 -0
  21. package/detectors/atdd_topology/fixtures/clean/implementation/orders/features/place-order/domain/order.ts +4 -0
  22. package/detectors/atdd_topology/fixtures/clean/plan/_journeys/checkout.yaml +4 -0
  23. package/detectors/atdd_topology/fixtures/clean/plan/_trains/_interlockings/checkout.yaml +4 -0
  24. package/detectors/atdd_topology/fixtures/clean/plan/_trains/checkout.yaml +1 -0
  25. package/detectors/atdd_topology/fixtures/clean/plan/orders/E001.yaml +8 -0
  26. package/detectors/atdd_topology/fixtures/clean/plan/orders/_orders.yaml +5 -0
  27. package/detectors/atdd_topology/fixtures/clean/plan/orders/place-order.yaml +3 -0
  28. package/detectors/atdd_topology/fixtures/clean/tests/wagons/orders/features/place-order/unit/order.test.ts +4 -0
  29. package/detectors/atdd_topology/fixtures/dirty/plan/_journeys/checkout.yaml +3 -0
  30. package/detectors/atdd_topology/fixtures/dirty/plan/orders/E001.yaml +4 -0
  31. package/detectors/atdd_topology/fixtures/dirty/plan/orders/_orders.yaml +4 -0
  32. package/detectors/atdd_topology/fixtures/dirty/plan/orders/features/place-order.yaml +3 -0
  33. package/detectors/atdd_topology/fixtures/dirty/src/wagons/orders/features/place-order/domain/forged.ts +2 -0
  34. package/detectors/atdd_topology/fixtures/dirty/src/wagons/orders/features/place-order/domain/order.ts +2 -0
  35. package/detectors/atdd_topology/fixtures/dirty/tests/wagons/orders/features/place-order/unit/order.test.ts +4 -0
  36. package/detectors/atdd_traceability_closure/detect.mjs +5 -2
  37. package/detectors/bun_interlocking_binding/checks/interlocking_runtime_executes.mjs +3 -2
  38. package/detectors/bun_interlocking_binding/detect.mjs +6 -5
  39. package/detectors/bun_interlocking_coverage/_shared/interlocking.mjs +4 -3
  40. package/detectors/bun_interlocking_coverage/checks/interlocking_train_sequence.mjs +2 -2
  41. package/detectors/bun_interlocking_infrastructure/_shared/interlocking.mjs +2 -1
  42. package/detectors/bun_interlocking_infrastructure/checks/journey_runner_boundary.mjs +3 -2
  43. package/detectors/bun_interlocking_infrastructure/checks/journey_station_routing.mjs +2 -1
  44. package/detectors/bun_interlocking_infrastructure/checks/wagon_contract_honoured.mjs +3 -2
  45. package/detectors/bun_tester_discipline_detector/checks/t_acceptance_resolves.mjs +7 -6
  46. package/detectors/planner_docs_capability/atdd.implementation.yaml +7 -0
  47. package/detectors/planner_plan_integrity/atdd.implementation.yaml +1 -0
  48. package/detectors/planner_plan_integrity/detect.mjs +4 -1
  49. package/detectors/planner_plan_integrity/fixtures/dirty/plan/_trains/_interlockings/checkout.yaml +6 -0
  50. package/detectors/planner_plan_integrity/fixtures/dirty/plan/_trains/_interlockings/unnamed.yaml +2 -0
  51. package/detectors/planner_plan_integrity/fixtures/dirty/plan/_trains/dup-a.yaml +7 -0
  52. package/detectors/planner_plan_integrity/fixtures/dirty/plan/_trains/dup-b.yaml +6 -0
  53. package/detectors/planner_plan_integrity/fixtures/dirty/plan/orders/E001.yaml +5 -0
  54. package/detectors/planner_schema_validation/fixtures/dirty/plan/_trains/missing-description.yaml +5 -0
  55. package/integrity.json +65 -24
  56. package/package.json +1 -1
  57. package/planner-nodes/ENFORCEMENT_SCOPE.yaml +11 -1
  58. package/relationships.yaml +224 -0
  59. package/src/docs-capability.ts +3 -0
  60. package/src/enforce.ts +30 -5
  61. package/src/hooks.ts +2 -1
  62. package/src/index.ts +2 -0
  63. package/src/planner-kernel.ts +4 -2
  64. package/src/planner-schema-validator.ts +12 -10
  65. package/src/planner-validators.ts +16 -15
  66. package/src/topology.ts +40 -0
@@ -0,0 +1,182 @@
1
+ #!/usr/bin/env bun
2
+ // Configurable plan/source/test/E2E topology and feature-decomposition gate.
3
+ import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
4
+ import { join, relative, sep } from "node:path";
5
+ import { topologyFor } from "../../src/topology.ts";
6
+
7
+ const roots = JSON.parse(process.env.ATDD_SCAN_ROOTS || "[]"), report = process.env.ATDD_VIOLATIONS_REPORT;
8
+ if (!report) process.exit(2);
9
+ const sourceExt = new Set([".ts", ".tsx", ".js", ".jsx", ".mjs", ".mts", ".cts", ".cjs", ".html", ".htm"]);
10
+ const testName = /(?:^test_.*|.*(?:\.test|\.spec|_test))\.(?:[cm]?[jt]sx?)$/;
11
+ const slug = "[a-z][a-z0-9-]*";
12
+ const componentUrn = new RegExp(`^component:(${slug}):(${slug}):[A-Za-z0-9.]+:(frontend|backend):(domain|application|integration|presentation)$`);
13
+ const testUrn = new RegExp(`^test:(${slug}):(${slug}):([A-Za-z0-9][A-Za-z0-9._-]*)$`);
14
+ const violations = [];
15
+ const rel = (root, path) => relative(root, path).split(sep).join("/");
16
+ const read = path => { try { return readFileSync(path, "utf8"); } catch { return ""; } };
17
+ const text = (data, key) => data && typeof data === "object" && !Array.isArray(data) && typeof data[key] === "string" ? data[key] : "";
18
+ const list = (data, key) => data && typeof data === "object" && Array.isArray(data[key]) ? data[key] : [];
19
+ const urns = values => values.map(value => typeof value === "string" ? value : text(value, "urn")).filter(Boolean);
20
+ function add(rule_id, root, path, evidence, line = 1, source_line = "") { violations.push({ rule_id, file: rel(root, path), line, col: 1, evidence, source_line }); }
21
+ function walk(dir, predicate, found = []) {
22
+ let entries; try { entries = readdirSync(dir, { withFileTypes: true }); } catch { return found; }
23
+ for (const entry of entries) {
24
+ if (["node_modules", ".git", ".atdd", "dist", "build", ".next", "_generated"].includes(entry.name)) continue;
25
+ const path = join(dir, entry.name);
26
+ if (entry.isDirectory()) walk(path, predicate, found); else if (predicate(path)) found.push(path);
27
+ }
28
+ return found;
29
+ }
30
+ async function topology(root) { const value = await topologyFor(root); return { plan_root: value.planRoot, source_root: value.sourceRoot, test_root: value.testRoot, e2e_root: value.e2eRoot }; }
31
+ function header(path) {
32
+ const lines = read(path).split(/\r?\n/).slice(0, 60);
33
+ const field = name => {
34
+ const index = lines.findIndex(line => new RegExp(`^\\s*//\\s*${name}:\\s*(\\S.*?)\\s*$`).test(line));
35
+ return index < 0 ? { value: "", line: 1, raw: "" } : { value: lines[index].replace(new RegExp(`^\\s*//\\s*${name}:\\s*`), "").trim(), line: index + 1, raw: lines[index].trim() };
36
+ };
37
+ return { urn: field("URN"), acceptance: field("Acceptance"), train: field("Train"), journey: field("Journey") };
38
+ }
39
+
40
+ for (const root of roots) {
41
+ const cfg = await topology(root), planRoot = join(root, cfg.plan_root), docs = [];
42
+ for (const path of walk(planRoot, path => /\.ya?ml$/.test(path))) {
43
+ try { const data = Bun.YAML.parse(read(path)); if (data && typeof data === "object" && !Array.isArray(data)) docs.push({ path, data }); } catch { /* schema validation owns parse errors */ }
44
+ }
45
+ const wagons = docs.filter(doc => text(doc.data, "urn").startsWith("wagon:")).map(doc => ({ ...doc, slug: text(doc.data, "urn").slice(6) }));
46
+ const features = docs.filter(doc => text(doc.data, "urn").startsWith("feature:")).map(doc => { const [,, wagon, slug] = ["", ...text(doc.data, "urn").split(":")]; return { ...doc, wagon, slug, urn: text(doc.data, "urn") }; });
47
+ const wmbts = docs.filter(doc => text(doc.data, "urn").startsWith("wmbt:")).map(doc => { const [, wagon, code] = text(doc.data, "urn").split(":"); return { ...doc, wagon, code, urn: text(doc.data, "urn") }; });
48
+ const featureByUrn = new Map(features.map(feature => [feature.urn, feature])), memberships = new Map(), wmbtOwners = new Map(), sourceByFeature = new Map(), testByFeature = new Map();
49
+ const acceptances = new Set(wmbts.flatMap(wmbt => list(wmbt.data, "acceptances").map(acceptance => text(acceptance?.identity, "urn")).filter(Boolean)));
50
+ // The feature(s) that own each acceptance, through the WMBTs they list: a test is credited only to its owner.
51
+ const acceptanceOwners = new Map();
52
+ for (const feature of features) for (const wmbtUrn of list(feature.data, "wmbts").map(String)) for (const wmbt of wmbts.filter(w => w.urn === wmbtUrn))
53
+ for (const acceptance of list(wmbt.data, "acceptances").map(a => text(a?.identity, "urn")).filter(Boolean)) acceptanceOwners.set(acceptance, [...(acceptanceOwners.get(acceptance) || []), `${feature.wagon}:${feature.slug}`]);
54
+ const trains = new Set(docs.map(doc => text(doc.data, "train_id")).filter(Boolean));
55
+
56
+ for (const wagon of wagons) {
57
+ const expected = `${cfg.plan_root}/${wagon.slug}/_${wagon.slug}.yaml`;
58
+ if (rel(root, wagon.path) !== expected) add("atdd-bun.topology.plan-location", root, wagon.path, `wagon:${wagon.slug} must be declared at ${expected}`);
59
+ const declared = urns(list(wagon.data, "features"));
60
+ if ((Number(wagon.data.wmbt?.total) > 0 || wmbts.some(wmbt => wmbt.wagon === wagon.slug)) && !declared.length) add("planner.wagon.features", root, wagon.path, `wagon:${wagon.slug} has WMBTs but no feature decomposition`);
61
+ for (const urn of declared) {
62
+ const feature = featureByUrn.get(urn);
63
+ if (!feature) { add("planner.wagon.features", root, wagon.path, `wagon:${wagon.slug} lists ${urn}, but no feature document declares it`); continue; }
64
+ memberships.set(urn, [...(memberships.get(urn) || []), wagon.slug]);
65
+ if (feature.wagon !== wagon.slug || text(feature.data, "wagon") !== `wagon:${wagon.slug}`) add("planner.feature.wagon-link", root, feature.path, `${urn} must belong to wagon:${wagon.slug}`);
66
+ }
67
+ }
68
+ for (const feature of features) {
69
+ const expected = `${cfg.plan_root}/${feature.wagon}/${feature.slug}.yaml`, owners = memberships.get(feature.urn) || [];
70
+ if (rel(root, feature.path) !== expected) add("atdd-bun.topology.plan-location", root, feature.path, `${feature.urn} must be declared at ${expected}`);
71
+ if (owners.length !== 1) add("planner.feature.wagon-link", root, feature.path, `${feature.urn} must be listed by exactly one wagon; found ${owners.length}`);
72
+ for (const urn of urns(list(feature.data, "wmbts"))) wmbtOwners.set(urn, [...(wmbtOwners.get(urn) || []), feature.urn]);
73
+ }
74
+ for (const wmbt of wmbts) {
75
+ const expected = `${cfg.plan_root}/${wmbt.wagon}/${wmbt.code}.yaml`, owners = wmbtOwners.get(wmbt.urn) || [];
76
+ if (rel(root, wmbt.path) !== expected) add("atdd-bun.topology.plan-location", root, wmbt.path, `${wmbt.urn} must be declared at ${expected}`);
77
+ if (owners.length !== 1) add("planner.wagon.features", root, wmbt.path, `${wmbt.urn} must belong to exactly one feature; found ${owners.length}`);
78
+ }
79
+
80
+ const declaredFeatures = new Set(features.map(feature => `${feature.wagon}:${feature.slug}`));
81
+ // A repository can ship an independent frontend or infrastructure fixture with journeys but
82
+ // no wagon/feature plan. Feature layout begins only when the plan models a feature; this
83
+ // preserves that boundary while making every modeled feature strict.
84
+ const modelsFeatures = wagons.length > 0 || features.length > 0 || wmbts.length > 0;
85
+ if (modelsFeatures) for (const path of walk(join(root, cfg.source_root), path => sourceExt.has(path.slice(path.lastIndexOf("."))) && !testName.test(path))) {
86
+ const h = header(path), match = componentUrn.exec(h.urn.value);
87
+ if (!match) { add("atdd-bun.topology.source-location", root, path, "source requires URN: component:{wagon}:{feature}:{name}:{frontend|backend}:{domain|application|integration|presentation}", h.urn.line, h.urn.raw); continue; }
88
+ const wagon = match[1], feature = match[2], layer = match[4], expected = `${cfg.source_root}/${wagon}/features/${feature}/${layer === "integration" ? "infrastructure" : layer}/`;
89
+ if (!rel(root, path).startsWith(expected)) add("atdd-bun.topology.source-location", root, path, `${h.urn.value} must live beneath ${expected}`, h.urn.line, h.urn.raw);
90
+ else sourceByFeature.set(`${wagon}:${feature}`, [...(sourceByFeature.get(`${wagon}:${feature}`) || []), path]);
91
+ if (wagon && feature && !declaredFeatures.has(`${wagon}:${feature}`)) add("planner.feature.wagon-link", root, path, `${h.urn.value} names undeclared feature:${wagon}:${feature}`, h.urn.line, h.urn.raw);
92
+ }
93
+ if (modelsFeatures) for (const path of walk(join(root, cfg.test_root), path => testName.test(path))) {
94
+ const h = header(path), match = testUrn.exec(h.urn.value);
95
+ if (!match) { add("atdd-bun.topology.test-location", root, path, "test requires URN: test:{wagon}:{feature}:{acceptance}", h.urn.line, h.urn.raw); continue; }
96
+ const [, wagon, feature, acceptance] = match, expected = `${cfg.test_root}/${wagon}/features/${feature}/`;
97
+ if (!rel(root, path).startsWith(expected) || !/(unit|contract|integration)\//.test(rel(root, path).slice(expected.length))) add("atdd-bun.topology.test-location", root, path, `${h.urn.value} must live beneath ${expected}{unit,contract,integration}/`, h.urn.line, h.urn.raw);
98
+ if (wagon && feature && !declaredFeatures.has(`${wagon}:${feature}`)) add("planner.feature.wagon-link", root, path, `${h.urn.value} names undeclared feature:${wagon}:${feature}`, h.urn.line, h.urn.raw);
99
+ const binding = `acc:${wagon}:${acceptance}`;
100
+ if (h.acceptance.value !== binding) add("atdd-bun.topology.test-location", root, path, `${h.urn.value} must bind Acceptance: ${binding}`, h.acceptance.line, h.acceptance.raw);
101
+ else if (!acceptances.has(binding)) add("atdd-bun.topology.test-location", root, path, `${binding} is not declared by a WMBT in ${cfg.plan_root}/`, h.acceptance.line, h.acceptance.raw);
102
+ else if (acceptanceOwners.has(binding) && !acceptanceOwners.get(binding).includes(`${wagon}:${feature}`)) add("atdd-bun.topology.test-location", root, path, `${binding} belongs to feature:${acceptanceOwners.get(binding).join(", feature:")}, not feature:${wagon}:${feature}; a test lives beneath the feature whose acceptance it proves`, h.acceptance.line, h.acceptance.raw);
103
+ else testByFeature.set(`${wagon}:${feature}`, [...(testByFeature.get(`${wagon}:${feature}`) || []), path]);
104
+ }
105
+ for (const feature of features) if (list(feature.data, "wmbts").length) {
106
+ const key = `${feature.wagon}:${feature.slug}`;
107
+ if (!sourceByFeature.get(key)?.length) add("atdd-bun.topology.feature-source-coverage", root, feature.path, `${feature.urn} owns WMBTs but has no source component beneath ${cfg.source_root}/${feature.wagon}/features/${feature.slug}/`);
108
+ if (!testByFeature.get(key)?.length) add("atdd-bun.topology.feature-test-coverage", root, feature.path, `${feature.urn} owns WMBTs but has no test bound to one of its acceptances`);
109
+ }
110
+ const e2eRoot = join(root, cfg.e2e_root);
111
+ // A browser test is the E2E proof for a frontend behavior. It deliberately
112
+ // substitutes for the Bun E2E path below, never supplements it: one behavior,
113
+ // one runner. htmx_e2e_detector (included in the tester profile) owns the
114
+ // stricter Playwright naming, header, subject, and harness validation.
115
+ const browserTrains = new Set(), browserJourneys = new Set();
116
+ for (const path of walk(e2eRoot, path => /\.e2e\.[cm]?[jt]sx?$/.test(path))) {
117
+ const content = read(path), h = header(path);
118
+ if (!/from\s+["']@playwright\/test["']/.test(content) || !/(^|[^.\w])test(\.(describe|only|skip|fixme|fail|slow|step))?\s*\(/m.test(content)) continue;
119
+ // A browser spec carries its journey identity as a test URN, not an Acceptance (tester.htmx forbids
120
+ // Acceptance on journey specs). It substitutes only when that URN is a valid E2E or SMOKE proof for the
121
+ // very train or journey it is bound to.
122
+ // The proof is the `// URN:` header, whole: a URN-shaped string elsewhere in the file (a decoy constant) proves nothing.
123
+ const proves = (subject) => h.urn.value.startsWith(`test:${subject}:`) && /^(E2E|SMOKE)-\d{3}-[a-z0-9][a-z0-9-]*$/.test(h.urn.value.slice(`test:${subject}:`.length));
124
+ if (h.train.value && proves(h.train.value)) browserTrains.add(h.train.value);
125
+ if (h.journey.value && proves(h.journey.value)) browserJourneys.add(h.journey.value);
126
+ }
127
+ const interlockingRoutes = new Set();
128
+ const interlockings = new Map(docs.filter(doc => text(doc.data, "interlocking_id").startsWith("interlocking:")).map(doc => [text(doc.data, "interlocking_id"), doc]));
129
+ const journeys = docs.filter(doc => text(doc.data, "journey_id").startsWith("journey:"));
130
+ const journeyReachability = journey => {
131
+ const continuations = list(journey.data, "continuations"), reachable = new Set(), queue = [text(journey.data.entrypoint, "interlocking_id")].filter(Boolean);
132
+ while (queue.length) {
133
+ const interlockingId = queue.shift(); if (!interlockingId || reachable.has(interlockingId)) continue;
134
+ reachable.add(interlockingId);
135
+ for (const continuation of continuations) if (text(continuation?.from, "interlocking_id") === interlockingId && text(continuation?.to, "interlocking_id")) queue.push(text(continuation.to, "interlocking_id"));
136
+ }
137
+ return reachable;
138
+ };
139
+ const hasFrontendSurface = entry => !Array.isArray(entry?.surfaces) || entry.surfaces.map(String).includes("frontend");
140
+ const frontendInterlockings = new Set(journeys.filter(journey => {
141
+ const entry = journey.data.entrypoint;
142
+ return entry && typeof entry === "object" && entry.exposed === true && hasFrontendSurface(entry);
143
+ }).flatMap(journey => [...journeyReachability(journey)]));
144
+ for (const interlocking of interlockings.values()) {
145
+ const id = text(interlocking.data, "interlocking_id").slice(13);
146
+ for (const route of list(interlocking.data, "routes")) {
147
+ const routeId = text(route, "route_id"); if (!routeId) continue;
148
+ const expected = join(e2eRoot, "interlockings", id, `${routeId}.routes.test.ts`);
149
+ interlockingRoutes.add(rel(root, expected));
150
+ const browserEligible = frontendInterlockings.has(text(interlocking.data, "interlocking_id"));
151
+ if (!existsSync(expected) && !(browserEligible && browserTrains.has(text(route, "train_id")))) add("atdd-bun.topology.e2e-location", root, interlocking.path, browserEligible
152
+ ? `${text(interlocking.data, "interlocking_id")} route ${routeId} requires ${rel(root, expected)} or a Playwright E2E spec bound to Train: ${text(route, "train_id")}`
153
+ : `${text(interlocking.data, "interlocking_id")} route ${routeId} is not on an exposed frontend journey and requires ${rel(root, expected)}`);
154
+ }
155
+ }
156
+ for (const journey of journeys) {
157
+ const entry = journey.data.entrypoint, id = text(journey.data, "journey_id").slice(8), path = join(e2eRoot, "journeys", `${id}.journey.test.ts`);
158
+ const reachable = journeyReachability(journey), journeyTrains = new Set([...reachable].flatMap(interlockingId => list(interlockings.get(interlockingId)?.data, "routes").map(route => text(route, "train_id")).filter(Boolean)));
159
+ const browserEligible = entry && typeof entry === "object" && hasFrontendSurface(entry);
160
+ if (entry && typeof entry === "object" && entry.exposed === true && !existsSync(path) && !(browserEligible && browserJourneys.has(`journey:${id}`))) add("atdd-bun.topology.e2e-location", root, journey.path, browserEligible
161
+ ? `exposed journey:${id} requires ${cfg.e2e_root}/journeys/${id}.journey.test.ts or a Playwright E2E spec bound to Journey: journey:${id}`
162
+ : `exposed backend journey:${id} requires ${cfg.e2e_root}/journeys/${id}.journey.test.ts`);
163
+ else if (entry && typeof entry === "object" && entry.exposed === true && existsSync(path)) {
164
+ const h = header(path), match = testUrn.exec(h.urn.value);
165
+ if (!match || !declaredFeatures.has(`${match[1]}:${match[2]}`)) add("atdd-bun.topology.e2e-location", root, path, "journey E2E test requires a test:{wagon}:{feature}:{acceptance} URN naming a declared feature", h.urn.line, h.urn.raw);
166
+ else if (h.acceptance.value !== `acc:${match[1]}:${match[3]}` || !acceptances.has(h.acceptance.value)) add("atdd-bun.topology.e2e-location", root, path, `journey E2E test requires Acceptance: acc:${match[1]}:${match[3]}, declared by a WMBT in ${cfg.plan_root}/`, h.acceptance.line, h.acceptance.raw);
167
+ if (!trains.has(h.train.value) || !journeyTrains.has(h.train.value)) add("atdd-bun.topology.e2e-location", root, path, `journey E2E Train: must resolve to a reachable selected train; found ${h.train.value || "<missing>"}`, h.train.line, h.train.raw);
168
+ }
169
+ }
170
+ for (const path of walk(e2eRoot, path => testName.test(path))) {
171
+ const location = rel(root, path), h = header(path);
172
+ if (location.startsWith(`${cfg.e2e_root}/journeys/`) && !/\.journey\.test\.[cm]?[jt]sx?$/.test(path)) add("atdd-bun.topology.e2e-location", root, path, "journey E2E tests must end in .journey.test.ts", h.urn.line, h.urn.raw);
173
+ if (location.startsWith(`${cfg.e2e_root}/interlockings/`) && !/\.routes\.test\.[cm]?[jt]sx?$/.test(path)) add("atdd-bun.topology.e2e-location", root, path, "interlocking E2E tests must end in .routes.test.ts", h.urn.line, h.urn.raw);
174
+ if (location.startsWith(`${cfg.e2e_root}/interlockings/`) && /\.routes\.test\.[cm]?[jt]sx?$/.test(path) && interlockingRoutes.size && !interlockingRoutes.has(location)) add("atdd-bun.topology.e2e-location", root, path, "interlocking E2E test does not name a declared route", h.urn.line, h.urn.raw);
175
+ if (location.startsWith(`${cfg.e2e_root}/interlockings/`) && /\.routes\.test\.[cm]?[jt]sx?$/.test(path)) {
176
+ const match = testUrn.exec(h.urn.value);
177
+ if (!match || !declaredFeatures.has(`${match[1]}:${match[2]}`)) add("atdd-bun.topology.e2e-location", root, path, "interlocking E2E test requires a test:{wagon}:{feature}:{acceptance} URN naming a declared feature", h.urn.line, h.urn.raw);
178
+ else if (h.acceptance.value !== `acc:${match[1]}:${match[3]}` || !acceptances.has(h.acceptance.value)) add("atdd-bun.topology.e2e-location", root, path, "interlocking E2E test requires an Acceptance: binding declared by a WMBT", h.acceptance.line, h.acceptance.raw);
179
+ }
180
+ }
181
+ }
182
+ writeFileSync(report, JSON.stringify({ violations }, null, 2));
@@ -0,0 +1,2 @@
1
+ topology:
2
+ source_root: implementation
@@ -0,0 +1,4 @@
1
+ // URN: test:orders:place-order:E001-E2E-002
2
+ // Acceptance: acc:orders:E001-E2E-002
3
+ import { test } from "bun:test";
4
+ test("nominal", () => {});
@@ -0,0 +1,5 @@
1
+ // URN: test:orders:place-order:E001-E2E-001
2
+ // Acceptance: acc:orders:E001-E2E-001
3
+ // Train: train:orders:checkout
4
+ import { test } from "bun:test";
5
+ test("checkout", () => {});
@@ -0,0 +1,4 @@
1
+ // URN: component:orders:place-order:Order:backend:domain
2
+ // Tested-By:
3
+ // - test:orders:place-order:E001-UNIT-001
4
+ export class Order {}
@@ -0,0 +1,4 @@
1
+ journey_id: journey:checkout
2
+ entrypoint:
3
+ exposed: true
4
+ interlocking_id: interlocking:checkout
@@ -0,0 +1,4 @@
1
+ interlocking_id: interlocking:checkout
2
+ routes:
3
+ - route_id: nominal
4
+ train_id: train:orders:checkout
@@ -0,0 +1 @@
1
+ train_id: train:orders:checkout
@@ -0,0 +1,8 @@
1
+ urn: wmbt:orders:E001
2
+ acceptances:
3
+ - identity:
4
+ urn: acc:orders:E001-UNIT-001
5
+ - identity:
6
+ urn: acc:orders:E001-E2E-001
7
+ - identity:
8
+ urn: acc:orders:E001-E2E-002
@@ -0,0 +1,5 @@
1
+ urn: wagon:orders
2
+ wmbt:
3
+ total: 1
4
+ features:
5
+ - urn: feature:orders:place-order
@@ -0,0 +1,3 @@
1
+ urn: feature:orders:place-order
2
+ wagon: wagon:orders
3
+ wmbts: [wmbt:orders:E001]
@@ -0,0 +1,4 @@
1
+ // URN: test:orders:place-order:E001-UNIT-001
2
+ // Acceptance: acc:orders:E001-UNIT-001
3
+ import { test } from "bun:test";
4
+ test("order", () => {});
@@ -0,0 +1,3 @@
1
+ journey_id: journey:checkout
2
+ entrypoint:
3
+ exposed: true
@@ -0,0 +1,4 @@
1
+ urn: wmbt:orders:E001
2
+ acceptances:
3
+ - identity:
4
+ urn: acc:orders:E001-UNIT-001
@@ -0,0 +1,4 @@
1
+ urn: wagon:orders
2
+ wmbt:
3
+ total: 1
4
+ features: []
@@ -0,0 +1,3 @@
1
+ urn: feature:orders:place-order
2
+ wagon: wagon:orders
3
+ wmbts: [wmbt:orders:E001]
@@ -0,0 +1,2 @@
1
+ // URN: forged:orders:place-order:Forged:backend:domain
2
+ export class Forged {}
@@ -0,0 +1,2 @@
1
+ // URN: component:orders:missing:Order:backend:domain
2
+ export class Order {}
@@ -0,0 +1,4 @@
1
+ // URN: test:orders:place-order:E001-UNIT-001
2
+ // Acceptance: acc:orders:WRONG
3
+ import { test } from "bun:test";
4
+ test("order", () => {});
@@ -2,6 +2,7 @@
2
2
  // Bun-native closure gate for plan -> test -> implementation traceability.
3
3
  import { readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
4
4
  import { join, relative } from "node:path";
5
+ import { topologyFor } from "../../src/topology.ts";
5
6
 
6
7
  const roots = JSON.parse(process.env.ATDD_SCAN_ROOTS || "[]");
7
8
  const excludes = new Set(JSON.parse(process.env.ATDD_SCAN_EXCLUDES || "[]"));
@@ -14,6 +15,7 @@ const violations = [];
14
15
  const plans = { acc: new Set(), wmbt: new Set(), train: new Set() };
15
16
  const tests = new Map();
16
17
  const sources = [];
18
+ let planDisplay = "plan/";
17
19
 
18
20
  function ignored(path) {
19
21
  return [...excludes].some((needle) => path.includes(needle));
@@ -33,10 +35,11 @@ function add(rule_id, file, line, evidence, source_line = "") {
33
35
  function lineOf(content, token) { return content.slice(0, content.indexOf(token)).split("\n").length; }
34
36
 
35
37
  for (const root of roots) {
38
+ const topology = await topologyFor(root), planPrefix = topology.planRoot.replace(/\/$/, "") + "/"; planDisplay = planPrefix;
36
39
  walk(root, (path) => {
37
40
  const name = path.split("/").pop() || "";
38
41
  const content = text(path);
39
- if (/\.ya?ml$/i.test(name) && /(?:^|\/)plan(?:\/|$)/.test(path)) {
42
+ if (/\.ya?ml$/i.test(name) && relative(root, path).replaceAll("\\", "/").startsWith(planPrefix)) {
40
43
  for (const [kind, re] of Object.entries({
41
44
  acc: /\bacc:[A-Za-z0-9_.:-]+/g,
42
45
  wmbt: /\bwmbt:[A-Za-z0-9_.:-]+/g,
@@ -70,7 +73,7 @@ for (const test of tests.values()) {
70
73
  }
71
74
  const boundAcceptances = new Set([...tests.values()].map((test) => test.binding).filter((id) => id?.startsWith("acc:")));
72
75
  for (const acceptance of plans.acc) {
73
- if (!boundAcceptances.has(acceptance)) add("traceability.plan.executable-acceptance-has-test", "plan/", 1, `${acceptance} has no Bun test binding`, acceptance);
76
+ if (!boundAcceptances.has(acceptance)) add("traceability.plan.executable-acceptance-has-test", planDisplay, 1, `${acceptance} has no Bun test binding`, acceptance);
74
77
  }
75
78
  for (const source of sources) {
76
79
  if (!source.testedBy.length) {
@@ -30,6 +30,7 @@ const LOADS_DECLARATION =
30
30
  /\breadFileSync\s*\(|\breadFile\s*\(|\bBun\s*\.\s*file\s*\(|\bcreateReadStream\s*\(|\bfs\s*\.\s*promises\s*\.\s*readFile\b/;
31
31
  const RESOLVES = /\bInterlockingResolution\b|\bresolveTrain\s*\(/;
32
32
  const EXCLUDES = ["node_modules", "dist", "build", ".next", "_generated"];
33
+ const PLAN_ROOT = process.env.ATDD_PLAN_ROOT || "plan";
33
34
 
34
35
  const readText = (p) => { try { return readFileSync(p, "utf8"); } catch { return ""; } };
35
36
 
@@ -53,7 +54,7 @@ export function findConsumerRoots(scanRoot) {
53
54
  (function rec(d) {
54
55
  let st; try { st = statSync(d); } catch { return; }
55
56
  if (!st.isDirectory()) return;
56
- for (const marker of ["src", "plan", "e2e"]) {
57
+ for (const marker of ["src", PLAN_ROOT, "e2e"]) {
57
58
  try { if (statSync(join(d, marker)).isDirectory()) { roots.add(d); break; } } catch {}
58
59
  }
59
60
  let entries; try { entries = readdirSync(d).sort(); } catch { return; }
@@ -111,7 +112,7 @@ export function maskComments(text) {
111
112
  export function scanExecution(scanRoot) {
112
113
  const violations = [];
113
114
  for (const croot of findConsumerRoots(scanRoot)) {
114
- const ilFiles = walk(join(croot, "plan"), (f) => /_interlockings[/\\].*\.ya?ml$/.test(f));
115
+ const ilFiles = walk(join(croot, PLAN_ROOT), (f) => /_interlockings[/\\].*\.ya?ml$/.test(f));
115
116
  const declared = [...new Set(ilFiles.flatMap((f) => declaredValues(readText(f))))];
116
117
  if (!declared.length) continue;
117
118
  const rtFiles = walk(join(croot, "src/trains"), (f) => /\.(ts|tsx|mjs|js)$/.test(f))
@@ -28,6 +28,7 @@ import { join, sep, resolve } from "node:path";
28
28
  const RULE = "coder.bun.interlocking-bilateral-binding";
29
29
  const DEFAULT_EXCLUDES = ["_generated", "node_modules", "dist", "build", ".next"];
30
30
  const PARALLEL_FIELDS = ["entrypoints", "runtime_exposure", "station_actions", "exposed_actions", "reachability"];
31
+ const PLAN_ROOT = process.env.ATDD_PLAN_ROOT || "plan";
31
32
 
32
33
  // ── generic IO / masking ─────────────────────────────────────────────────────
33
34
 
@@ -147,7 +148,7 @@ function* walkDirs(root) {
147
148
  function findConsumerRoots(scanRoot) {
148
149
  const roots = new Set();
149
150
  for (const d of walkDirs(scanRoot)) {
150
- if (hasChildDir(d, "src") || hasChildDir(d, "plan") || hasChildDir(d, "e2e")) roots.add(d);
151
+ if (hasChildDir(d, "src") || hasChildDir(d, PLAN_ROOT) || hasChildDir(d, "e2e")) roots.add(d);
151
152
  }
152
153
  return [...roots];
153
154
  }
@@ -181,9 +182,9 @@ const isYaml = (f) => f.endsWith(".yaml") || f.endsWith(".yml");
181
182
  const isTs = (f) => f.endsWith(".ts") || f.endsWith(".tsx");
182
183
 
183
184
  function interlockingFiles(croot) {
184
- const base = join(croot, "plan", "_trains", "_interlockings");
185
+ const base = join(croot, PLAN_ROOT, "_trains", "_interlockings");
185
186
  const out = [...walkFiles(base, isYaml)];
186
- const idx = join(croot, "plan", "_trains", "_interlockings.yaml");
187
+ const idx = join(croot, PLAN_ROOT, "_trains", "_interlockings.yaml");
187
188
  try {
188
189
  if (statSync(idx).isFile()) out.push(idx);
189
190
  } catch {
@@ -377,7 +378,7 @@ function trainArtifactExists(croot, route) {
377
378
  }
378
379
  if (route.trainId) {
379
380
  try {
380
- return statSync(join(croot, "plan", "_trains", `${route.trainId}.yaml`)).isFile();
381
+ return statSync(join(croot, PLAN_ROOT, "_trains", `${route.trainId}.yaml`)).isFile();
381
382
  } catch {
382
383
  return false;
383
384
  }
@@ -413,7 +414,7 @@ function scanConsumerRoot(croot) {
413
414
  for (const rec of records) {
414
415
  for (const route of rec.routes) {
415
416
  if (trainArtifactExists(croot, route)) continue;
416
- const target = route.trainPath || (route.trainId ? `plan/_trains/${route.trainId}.yaml` : "<no train_id>");
417
+ const target = route.trainPath || (route.trainId ? `${PLAN_ROOT}/_trains/${route.trainId}.yaml` : "<no train_id>");
417
418
  violations.push(
418
419
  mk(
419
420
  rel(rec.file, croot),
@@ -10,6 +10,7 @@ import { readFileSync, statSync, readdirSync, writeFileSync } from "node:fs";
10
10
  import { join, sep } from "node:path";
11
11
 
12
12
  export const DEFAULT_EXCLUDES = ["_generated", "node_modules", "dist", "build", ".next"];
13
+ export const PLAN_ROOT = process.env.ATDD_PLAN_ROOT || "plan";
13
14
 
14
15
  // Production runner symbols (core #1251 call model).
15
16
  export const PROD_INTERLOCKING = "InterlockingRunner";
@@ -220,7 +221,7 @@ function* walkDirs(root) {
220
221
  export function findConsumerRoots(scanRoot) {
221
222
  const roots = new Set();
222
223
  for (const d of walkDirs(scanRoot)) {
223
- if (hasChildDir(d, "plan") || hasChildDir(d, "e2e") || hasChildDir(d, "src")) roots.add(d);
224
+ if (hasChildDir(d, PLAN_ROOT) || hasChildDir(d, "e2e") || hasChildDir(d, "src")) roots.add(d);
224
225
  }
225
226
  return [...roots];
226
227
  }
@@ -254,9 +255,9 @@ const isYaml = (f) => f.endsWith(".yaml") || f.endsWith(".yml");
254
255
  const isTs = (f) => f.endsWith(".ts") || f.endsWith(".tsx");
255
256
 
256
257
  export function interlockingFiles(croot) {
257
- const base = join(croot, "plan", "_trains", "_interlockings");
258
+ const base = join(croot, PLAN_ROOT, "_trains", "_interlockings");
258
259
  const out = [...walkFiles(base, isYaml)];
259
- const idx = join(croot, "plan", "_trains", "_interlockings.yaml");
260
+ const idx = join(croot, PLAN_ROOT, "_trains", "_interlockings.yaml");
260
261
  try {
261
262
  if (statSync(idx).isFile()) out.push(idx);
262
263
  } catch {
@@ -16,7 +16,7 @@
16
16
  // suite green. The runtime obeyed the new plan; no test looked.
17
17
  import {
18
18
  parseJsonEnv, readText, findConsumerRoots, interlockingFiles, e2eFiles,
19
- parseInterlocking, tokenCovered, rel, mk,
19
+ parseInterlocking, tokenCovered, rel, mk, PLAN_ROOT,
20
20
  } from "../_shared/interlocking.mjs";
21
21
  import { writeFileSync, readdirSync, statSync } from "node:fs";
22
22
  import { join } from "node:path";
@@ -69,7 +69,7 @@ export function declaresASequence(croot, trainId) {
69
69
  if (st.isDirectory()) { if (name !== "_interlockings") rec(full); continue; }
70
70
  if (/\.ya?ml$/.test(name)) found.push(full);
71
71
  }
72
- })(join(croot, "plan"));
72
+ })(join(croot, PLAN_ROOT));
73
73
  for (const f of found) {
74
74
  const text = readText(f);
75
75
  if (!text.includes(trainId)) continue;
@@ -25,6 +25,7 @@ import { readFileSync, statSync, readdirSync, writeFileSync } from "node:fs";
25
25
  import { join, sep, basename } from "node:path";
26
26
 
27
27
  export const DEFAULT_EXCLUDES = ["_generated", "node_modules", "dist", "build", ".next"];
28
+ export const PLAN_ROOT = process.env.ATDD_PLAN_ROOT || "plan";
28
29
 
29
30
  // Structured-resolution model contract, TS camelCase, transcribed from core's own
30
31
  // InterlockingResolution (src/atdd/runtime/interlocking/runner.py).
@@ -127,7 +128,7 @@ function* walkDirs(root) {
127
128
  export function findConsumerRoots(scanRoot) {
128
129
  const roots = new Set();
129
130
  for (const d of walkDirs(scanRoot)) {
130
- if (hasChildDir(d, "src") || hasChildDir(d, "plan") || hasChildDir(d, "e2e")) roots.add(d);
131
+ if (hasChildDir(d, "src") || hasChildDir(d, PLAN_ROOT) || hasChildDir(d, "e2e")) roots.add(d);
131
132
  }
132
133
  return [...roots];
133
134
  }
@@ -18,6 +18,7 @@ import {
18
18
  mk,
19
19
  writeReport,
20
20
  maskComments,
21
+ PLAN_ROOT,
21
22
  } from "../_shared/interlocking.mjs";
22
23
 
23
24
  const RULE = "coder.bun.journey-runner-boundary";
@@ -25,7 +26,7 @@ const roots = parseJsonEnv("ATDD_SCAN_ROOTS", []);
25
26
  const violations = [];
26
27
 
27
28
  function hasJourneyTopology(root) {
28
- const base = join(root, "plan", "_journeys");
29
+ const base = join(root, PLAN_ROOT, "_journeys");
29
30
  if (!existsSync(base)) return false;
30
31
  const stack = [base];
31
32
  while (stack.length) {
@@ -88,7 +89,7 @@ for (const scanRoot of roots) {
88
89
  if (modules.length === 0) {
89
90
  violations.push(mk(
90
91
  RULE,
91
- "plan/_journeys",
92
+ `${PLAN_ROOT}/_journeys`,
92
93
  1,
93
94
  0,
94
95
  "missing-journey-runner: journey topology is declared but no JourneyRunner class exists under src/trains/",
@@ -13,6 +13,7 @@ import {
13
13
  mk,
14
14
  writeReport,
15
15
  maskComments,
16
+ PLAN_ROOT,
16
17
  } from "../_shared/interlocking.mjs";
17
18
 
18
19
  const RULE = "coder.bun.station-master-journey-routing";
@@ -24,7 +25,7 @@ function escapeRegExp(value) {
24
25
  }
25
26
 
26
27
  function journeyDocuments(croot) {
27
- const base = join(croot, "plan", "_journeys");
28
+ const base = join(croot, PLAN_ROOT, "_journeys");
28
29
  if (!existsSync(base)) return [];
29
30
  const out = [], stack = [base];
30
31
  while (stack.length) {
@@ -30,6 +30,7 @@ const RULE = "coder.bun.wagon-honours-its-contract";
30
30
  const EXCLUDES = ["node_modules", "dist", "build", ".next", ".git", "_generated"];
31
31
  const TS = /\.(ts|tsx|mjs|js)$/;
32
32
  const TEST = /\.(test|spec)\.[cm]?[jt]sx?$/;
33
+ const PLAN_ROOT = process.env.ATDD_PLAN_ROOT || "plan";
33
34
 
34
35
  const read = (p) => { try { return readFileSync(p, "utf8"); } catch { return ""; } };
35
36
 
@@ -61,7 +62,7 @@ function consumerRoots(root, excludes) {
61
62
  let st;
62
63
  try { st = statSync(d); } catch { return; }
63
64
  if (!st.isDirectory()) return;
64
- try { if (statSync(join(d, "plan")).isDirectory()) { roots.push(d); return; } } catch {}
65
+ try { if (statSync(join(d, PLAN_ROOT)).isDirectory()) { roots.push(d); return; } } catch {}
65
66
  let entries;
66
67
  try { entries = readdirSync(d).sort(); } catch { return; }
67
68
  for (const n of entries) if (!excludes.includes(n)) rec(join(d, n));
@@ -111,7 +112,7 @@ const violations = [];
111
112
  for (const root of parseJsonEnv("ATDD_SCAN_ROOTS", [])) {
112
113
  for (const croot of consumerRoots(root, excludes)) {
113
114
  const contracts = [];
114
- for (const f of walk(join(croot, "plan"), (p) => /\.ya?ml$/.test(p), excludes)) {
115
+ for (const f of walk(join(croot, PLAN_ROOT), (p) => /\.ya?ml$/.test(p), excludes)) {
115
116
  const c = wagonContract(read(f));
116
117
  if (c) contracts.push({ file: f, ...c });
117
118
  }
@@ -48,9 +48,9 @@ function planFiles(dir, excludes) {
48
48
  // and WMBT documents, and a reference is resolvable if the plan states that URN
49
49
  // anywhere. Over-accepting here is safe — the failure this rule exists to catch is a
50
50
  // reference to something the plan never mentions at all.
51
- function declaredUrns(croot, excludes) {
51
+ function declaredUrns(croot, excludes, planRoot) {
52
52
  const urns = new Set();
53
- for (const f of planFiles(join(croot, "plan"), excludes)) {
53
+ for (const f of planFiles(join(croot, planRoot), excludes)) {
54
54
  for (const m of read(f).matchAll(/\b((?:acc|wmbt):[a-z0-9][\w.-]*(?::[\w.-]+)?)/gi)) {
55
55
  urns.add(m[1]);
56
56
  }
@@ -58,13 +58,13 @@ function declaredUrns(croot, excludes) {
58
58
  return urns;
59
59
  }
60
60
 
61
- function consumerRoots(root, excludes) {
61
+ function consumerRoots(root, excludes, planRoot) {
62
62
  const roots = [];
63
63
  (function rec(d) {
64
64
  let st;
65
65
  try { st = statSync(d); } catch { return; }
66
66
  if (!st.isDirectory()) return;
67
- try { if (statSync(join(d, "plan")).isDirectory()) { roots.push(d); return; } } catch {}
67
+ try { if (statSync(join(d, planRoot)).isDirectory()) { roots.push(d); return; } } catch {}
68
68
  let entries;
69
69
  try { entries = readdirSync(d).sort(); } catch { return; }
70
70
  for (const n of entries) if (!excludes.includes(n)) rec(join(d, n));
@@ -79,10 +79,11 @@ if (!reportPath) {
79
79
  }
80
80
  const excludes = [...DEFAULT_EXCLUDES, ...parseJsonEnv("ATDD_SCAN_EXCLUDES", [])];
81
81
  const violations = [];
82
+ const planRoot = process.env.ATDD_PLAN_ROOT || "plan";
82
83
 
83
84
  for (const root of parseJsonEnv("ATDD_SCAN_ROOTS", [])) {
84
- for (const croot of consumerRoots(root, excludes)) {
85
- const declared = declaredUrns(croot, excludes);
85
+ for (const croot of consumerRoots(root, excludes, planRoot)) {
86
+ const declared = declaredUrns(croot, excludes, planRoot);
86
87
  if (!declared.size) continue; // nothing declared: nothing to resolve against
87
88
  for (const file of walkTests(croot, excludes)) {
88
89
  const H = parseHeader(read(file));
@@ -34,6 +34,13 @@ emits_rule_ids:
34
34
  - planner.docs.adr-registry-derived # disposition: advisory (registry drifted from :decides:)
35
35
  - planner.docs.journey-view-current # disposition: strict (generated journey view differs from plan/)
36
36
 
37
+ # Rules the capability API (checkDocumentation) emits and the filesystem report cannot: they need a
38
+ # declaration, a change set, or a render. tests/docs-capability.test.ts triggers each one.
39
+ api_emits_rule_ids:
40
+ - planner.docs.artifact-path-shape
41
+ - planner.docs.undeclared-change
42
+ - planner.docs.reference-integrity
43
+
37
44
  # TWO SURFACES, ONE DETECTOR.
38
45
  #
39
46
  # entrypoint the CAPABILITY seam. Core calls
@@ -9,6 +9,7 @@ contract_version: "1.0.0"
9
9
  # fail closed before convention validators can answer.
10
10
  emits_rule_ids:
11
11
  - atdd-bun.planner.parse
12
+ - atdd-bun.planner.identity-required
12
13
  - atdd-bun.planner.identity-unique
13
14
  - atdd-bun.planner.reference-resolves
14
15
  - atdd-bun.planner.train-wagon-resolves
@@ -6,6 +6,7 @@ const roots = JSON.parse(process.env.ATDD_SCAN_ROOTS ?? "[]"), report = process.
6
6
  if (!report) throw new Error("ATDD_VIOLATIONS_REPORT is required");
7
7
  const ids = {
8
8
  "planner.kernel.parse": "atdd-bun.planner.parse",
9
+ "planner.kernel.identity-required": "atdd-bun.planner.identity-required",
9
10
  "planner.kernel.identity-unique": "atdd-bun.planner.identity-unique",
10
11
  "planner.kernel.reference-resolves": "atdd-bun.planner.reference-resolves",
11
12
  "planner.kernel.train-wagon-resolves": "atdd-bun.planner.train-wagon-resolves",
@@ -14,7 +15,9 @@ const ids = {
14
15
  };
15
16
  const violations = (await Promise.all(roots.map(validatePlan))).flatMap(graph => graph.findings).map(item => ({
16
17
  ...item,
17
- rule_id: ids[item.rule_id] ?? item.rule_id,
18
+ // Every kernel finding reports under a declared package rule. An unmapped one is a new emission path:
19
+ // fail loudly rather than publish a rule id nothing declares (tests/rule-coverage.test.ts maps them all).
20
+ rule_id: ids[item.rule_id] ?? (() => { throw new Error(`planner_plan_integrity: kernel rule ${item.rule_id} has no declared package rule; map it in detect.mjs`); })(),
18
21
  line: 1,
19
22
  col: 1,
20
23
  source_line: "",