@sigloch/contracts 12.6.0 → 12.7.0

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.
@@ -0,0 +1,31 @@
1
+ import type { OntologyGraph } from './ontology.js';
2
+ import type { RuleViolation } from './rules.js';
3
+ import type { CodeFacts } from './conformance-rules.js';
4
+ /**
5
+ * Hoechstens so viele Aufrufkanten liegen zwischen zwei FUNCs, deren Fluss ein Aufruf belegt (RC-12) oder
6
+ * deren Aufruf einen Fluss verlangt (RC-13). Eine Invariante, keine Einstellung (Entscheid CR-SM-415):
7
+ * dasselbe Modell bekommt in jedem Repo dasselbe Urteil.
8
+ */
9
+ export declare const CALL_PATH_MAX_EDGES = 3;
10
+ /**
11
+ * Wie viel konnte RC-12 ansehen? Eine MESSUNG wie `importCoverage`, kein Befund. Gezaehlt werden die Paare
12
+ * (Erzeuger-FUNC, Abnehmer-FUNC) je FLOW; `anchored` sind die FUNCs, zwischen denen RC-13 Aufrufe sucht.
13
+ * „RC-12: 0 Befunde" heisst nur zusammen mit `checked` etwas.
14
+ */
15
+ export interface CallCoverage {
16
+ /** Synchrone Paare, die RC-12 beurteilt hat. */
17
+ checked: number;
18
+ /** Synchrone Paare mit einer Seite ohne `realRef`-Symbol. Ein Paar sind zwei FUNCs; ein Akteur zaehlt nicht. */
19
+ unbound: number;
20
+ /** Synchrone Paare mit einer Datei ausserhalb `callScope` (andere Sprache, Nachbarpaket, kein Lieferant). */
21
+ outOfScope: number;
22
+ /** Paare eines `async`-FLOW — nicht geprueft. */
23
+ async: number;
24
+ /** Paare eines FLOW ohne `sync` — die Kopplung ist unbekannt, nicht geprueft. */
25
+ syncUnknown: number;
26
+ /** FUNCs mit `realRef`-Symbol in einer Datei aus `callScope`. */
27
+ anchored: number;
28
+ }
29
+ export declare function callCoverage(graph: OntologyGraph, facts: CodeFacts): CallCoverage;
30
+ export declare function syncFlowNeedsCall(graph: OntologyGraph, facts: CodeFacts): RuleViolation[];
31
+ export declare function callNeedsFlow(graph: OntologyGraph, facts: CodeFacts): RuleViolation[];
@@ -0,0 +1,272 @@
1
+ /**
2
+ * RC-12 / RC-13 (CR-SM-415) — Fluss und Aufruf decken sich.
3
+ *
4
+ * Ein FLOW mit `sync: sync` sagt: der Erzeuger ruft den Abnehmer und wartet (oder der Abnehmer ruft den
5
+ * Erzeuger und bekommt den Inhalt als Antwort). RC-12 prueft das gegen die Aufrufe im Code, RC-13 die
6
+ * Gegenrichtung: ein Aufruf zwischen zwei verankerten FUNCs, fuer den kein FLOW steht.
7
+ *
8
+ * Gemessen vorher als Skript in graphcode (CR-GC-843, `scripts/fluss-aufruf.mjs`): 285 synchrone Paare,
9
+ * 158 pruefbar, 0 ohne Aufruf, nachdem falsche Abnehmer gerichtet waren. Die Gegenrichtung (Spike zu
10
+ * CR-GC-849): 71 verankerte FUNCs, 34 Aufrufpaare ohne FLOW, nach CR-GC-849 0.
11
+ *
12
+ * Rein ueber (graph, facts): die Aufrufkanten liefert der Lieferant je Sprache (`callEdges`, graphcode fuer
13
+ * TS, CR-GC-846). Die Regeln kennen keine Sprache. Ein Symbol in `callEdges` ist der PFAD seiner Deklaration,
14
+ * Glieder mit `.` getrennt, aeusseres zuerst (`GraphStore.open`). Daraus folgt, welche FUNC fuer einen
15
+ * Aufrufort steht: jede FUNC, deren `realRef.symbol` ein Glied dieses Pfads ist (in derselben Datei) — die
16
+ * Klasse steht fuer ihre Methoden, wie im Skript.
17
+ *
18
+ * @author andreas@siglochconsulting
19
+ */
20
+ import { readFlowSync, readRealRef } from './ontology.js';
21
+ /**
22
+ * Hoechstens so viele Aufrufkanten liegen zwischen zwei FUNCs, deren Fluss ein Aufruf belegt (RC-12) oder
23
+ * deren Aufruf einen Fluss verlangt (RC-13). Eine Invariante, keine Einstellung (Entscheid CR-SM-415):
24
+ * dasselbe Modell bekommt in jedem Repo dasselbe Urteil.
25
+ */
26
+ export const CALL_PATH_MAX_EDGES = 3;
27
+ const keyOf = (n) => `${n.file}#${n.symbol}`;
28
+ /** Die FUNC mit `realRef` samt Symbol — gebunden, unabhaengig von `callScope`. */
29
+ function boundFuncs(graph) {
30
+ const out = new Map();
31
+ for (const el of graph.elements) {
32
+ if (el.type !== 'FUNC')
33
+ continue;
34
+ const r = readRealRef(el.attributes);
35
+ if (r.state !== 'bound' || r.value.symbol === undefined)
36
+ continue;
37
+ out.set(el.id, { id: el.id, file: r.value.file, segments: r.value.symbol.split('.') });
38
+ }
39
+ return out;
40
+ }
41
+ /** Die Dateien, deren Aufrufe der Lieferant vollstaendig liefert. Ohne `callEdges` ist es keine. */
42
+ function scopeOf(facts) {
43
+ return facts.callEdges === undefined ? new Set() : new Set(facts.callScope ?? []);
44
+ }
45
+ /**
46
+ * Wo im Pfad `symbol` die FUNC `a` endet — der Index ihres letzten Glieds, oder -1, wenn `a` nicht fuer diesen
47
+ * Aufrufort steht. Der groessere Index ist der innere Anker.
48
+ */
49
+ function anchorDepth(a, node) {
50
+ if (node.file !== a.file)
51
+ return -1;
52
+ const path = node.symbol.split('.');
53
+ for (let end = path.length - 1; end >= a.segments.length - 1; end--) {
54
+ const start = end - a.segments.length + 1;
55
+ if (a.segments.every((s, i) => path[start + i] === s))
56
+ return end;
57
+ }
58
+ return -1;
59
+ }
60
+ /** Die Aufrufkanten als Nachbarschaft und alle Aufrufstellen, die darin vorkommen. */
61
+ function callGraph(facts) {
62
+ const next = new Map();
63
+ const nodes = new Map();
64
+ for (const e of facts.callEdges ?? []) {
65
+ nodes.set(keyOf(e.from), e.from);
66
+ nodes.set(keyOf(e.to), e.to);
67
+ const list = next.get(keyOf(e.from)) ?? [];
68
+ list.push(e.to);
69
+ next.set(keyOf(e.from), list);
70
+ }
71
+ // Sortiert: welcher von zwei gleich kurzen Wegen in der Meldung steht, haengt nicht an der Lieferreihenfolge.
72
+ for (const list of next.values())
73
+ list.sort((x, y) => keyOf(x).localeCompare(keyOf(y)));
74
+ return { next, nodes };
75
+ }
76
+ /** Die Aufrufstellen, fuer die `a` steht (jede Tiefe). */
77
+ function coveredBy(a, nodes) {
78
+ return new Set([...nodes].filter(([, n]) => anchorDepth(a, n) >= 0).map(([k]) => k));
79
+ }
80
+ /** Kuerzester Weg von `from` nach `to` ueber hoechstens CALL_PATH_MAX_EDGES Kanten — oder null. */
81
+ function shortestPath(next, from, to) {
82
+ let frontier = [...from].sort().map((k) => [k]);
83
+ const seen = new Set(from);
84
+ for (let d = 1; d <= CALL_PATH_MAX_EDGES; d++) {
85
+ const following = [];
86
+ for (const path of frontier) {
87
+ for (const n of next.get(path[path.length - 1]) ?? []) {
88
+ const k = keyOf(n);
89
+ if (to.has(k))
90
+ return [...path, k];
91
+ if (seen.has(k))
92
+ continue;
93
+ seen.add(k);
94
+ following.push([...path, k]);
95
+ }
96
+ }
97
+ frontier = following;
98
+ }
99
+ return null;
100
+ }
101
+ /** Je FLOW die Paare (Erzeuger-FUNC, Abnehmer-FUNC), getrennt nach `sync`, `async` und unbekannt. */
102
+ function flowPairs(graph) {
103
+ const typeOf = new Map(graph.elements.map((e) => [e.id, e.type]));
104
+ const io = graph.traces.filter((t) => t.type === 'io');
105
+ const out = { sync: [], async: 0, unknown: 0 };
106
+ for (const flow of [...graph.elements].filter((e) => e.type === 'FLOW').sort((a, b) => a.id.localeCompare(b.id))) {
107
+ const producers = io.filter((t) => t.target === flow.id && typeOf.get(t.source) === 'FUNC').map((t) => t.source).sort();
108
+ const consumers = io.filter((t) => t.source === flow.id && typeOf.get(t.target) === 'FUNC').map((t) => t.target).sort();
109
+ const n = producers.length * consumers.length;
110
+ if (n === 0)
111
+ continue;
112
+ const sync = readFlowSync(flow.attributes);
113
+ if (sync.state !== 'bound') {
114
+ out.unknown += n;
115
+ continue;
116
+ }
117
+ if (sync.value === 'async') {
118
+ out.async += n;
119
+ continue;
120
+ }
121
+ for (const from of producers)
122
+ for (const to of consumers)
123
+ out.sync.push({ flowId: flow.id, from, to });
124
+ }
125
+ return out;
126
+ }
127
+ function pairVerdict(p, bound, scope) {
128
+ const a = bound.get(p.from);
129
+ const b = bound.get(p.to);
130
+ if (!a || !b)
131
+ return 'unbound';
132
+ if (!scope.has(a.file) || !scope.has(b.file))
133
+ return 'outOfScope';
134
+ return 'checked';
135
+ }
136
+ export function callCoverage(graph, facts) {
137
+ const bound = boundFuncs(graph);
138
+ const scope = scopeOf(facts);
139
+ const pairs = flowPairs(graph);
140
+ const count = { checked: 0, unbound: 0, outOfScope: 0 };
141
+ for (const p of pairs.sync)
142
+ count[pairVerdict(p, bound, scope)]++;
143
+ const anchored = [...bound.values()].filter((a) => scope.has(a.file)).length;
144
+ return { ...count, async: pairs.async, syncUnknown: pairs.unknown, anchored };
145
+ }
146
+ /** Der FLOW belegt die Uebergabe selbst: `realRef` mit Symbol, das in seiner Datei deklariert ist. */
147
+ function handOverProven(attributes, facts) {
148
+ const r = readRealRef(attributes);
149
+ if (r.state === 'absent')
150
+ return { ok: false };
151
+ if (r.state === 'invalid')
152
+ return { ok: false, ref: 'invalid' };
153
+ const ref = `${r.value.file}#${r.value.symbol ?? ''}`;
154
+ const f = facts.files[r.value.file];
155
+ const ok = r.value.symbol !== undefined && f?.exists === true && f.declaredSymbols.includes(r.value.symbol);
156
+ return { ok, ref };
157
+ }
158
+ // RC-12: ein synchroner Fluss ohne Aufruf. Je Paar ein Befund am FLOW. Ohne `callEdges` still (wie RC-05
159
+ // ohne `importEdges`); ein Paar ohne Bindung oder ausserhalb `callScope` ist still und in `callCoverage`
160
+ // gezaehlt. Ein Weg in einer der beiden Richtungen zaehlt: die Antwort fliesst vom Gerufenen zum Aufrufer.
161
+ export function syncFlowNeedsCall(graph, facts) {
162
+ if (facts.callEdges === undefined)
163
+ return [];
164
+ const bound = boundFuncs(graph);
165
+ const scope = scopeOf(facts);
166
+ const { next, nodes } = callGraph(facts);
167
+ const byId = new Map(graph.elements.map((e) => [e.id, e]));
168
+ const violations = [];
169
+ for (const p of flowPairs(graph).sync) {
170
+ if (pairVerdict(p, bound, scope) !== 'checked')
171
+ continue;
172
+ const a = coveredBy(bound.get(p.from), nodes);
173
+ const b = coveredBy(bound.get(p.to), nodes);
174
+ if ([...a].some((k) => b.has(k)))
175
+ continue; // eine FUNC steht in der anderen: kein Aufruf noetig
176
+ if (shortestPath(next, a, b) ?? shortestPath(next, b, a))
177
+ continue;
178
+ const flow = byId.get(p.flowId);
179
+ const proof = handOverProven(flow.attributes, facts);
180
+ if (proof.ok)
181
+ continue;
182
+ const broken = proof.ref === undefined ? '' : ` — FLOW realRef '${proof.ref}' does not resolve`;
183
+ violations.push({
184
+ rule_id: 'RC-12',
185
+ severity: 'warning',
186
+ element_id: flow.id,
187
+ message: `${flow.id} is sync, but no call between ${p.from} and ${p.to} within ${CALL_PATH_MAX_EDGES} calls in either direction${broken}`,
188
+ fix_hint: proof.ref === undefined
189
+ ? `Re-point the flow at the FUNC pair that calls each other — or, if the hand-over is no call (callback, registry, socket), record the hand-over site via graph_mutate Format-E \`~ ${flow.id} @realRef {"file":…,"symbol":…}\``
190
+ : `Re-point the FLOW realRef at the current hand-over site via graph_mutate Format-E \`~ ${flow.id} @realRef {"file":…,"symbol":…}\` — or re-point the flow at the FUNC pair that calls each other`,
191
+ context: { element_type: 'FLOW', element_name: flow.name },
192
+ });
193
+ }
194
+ return violations;
195
+ }
196
+ // RC-13: ein Aufruf zwischen zwei verankerten FUNCs ohne FLOW (sync oder async, eine der beiden Richtungen).
197
+ // Ein Aufrufort gehoert dem INNERSTEN Anker — ohne das zaehlte `GraphStore.open` fuer die Klasse und fuer die
198
+ // Methode (Spike CR-GC-849: 36 statt 34 Paare). Ein Weg endet an der ersten anderen verankerten FUNC: ein Weg
199
+ // durch eine dritte sind zwei Fluesse, nicht einer. Je ungeordnetem Paar ein Befund, am Aufrufer; rufen beide
200
+ // einander, an dem mit der kleineren uid. Die Anker laufen sortiert, das Ergebnis haengt nicht an der
201
+ // Reihenfolge im Graphen.
202
+ export function callNeedsFlow(graph, facts) {
203
+ if (facts.callEdges === undefined)
204
+ return [];
205
+ const scope = scopeOf(facts);
206
+ const anchors = [...boundFuncs(graph).values()].filter((a) => scope.has(a.file)).sort((x, y) => x.id.localeCompare(y.id));
207
+ if (anchors.length < 2)
208
+ return [];
209
+ const { next, nodes } = callGraph(facts);
210
+ const owner = new Map();
211
+ for (const [k, n] of nodes) {
212
+ let best;
213
+ for (const a of anchors) {
214
+ const depth = anchorDepth(a, n);
215
+ if (depth >= 0 && (!best || depth > best.depth))
216
+ best = { id: a.id, depth };
217
+ }
218
+ if (best)
219
+ owner.set(k, best.id);
220
+ }
221
+ const flowPairKeys = new Set();
222
+ const typeOf = new Map(graph.elements.map((e) => [e.id, e.type]));
223
+ const io = graph.traces.filter((t) => t.type === 'io');
224
+ for (const flow of graph.elements.filter((e) => e.type === 'FLOW')) {
225
+ const ins = io.filter((t) => t.target === flow.id && typeOf.get(t.source) === 'FUNC').map((t) => t.source);
226
+ const outs = io.filter((t) => t.source === flow.id && typeOf.get(t.target) === 'FUNC').map((t) => t.target);
227
+ for (const x of ins)
228
+ for (const y of outs)
229
+ flowPairKeys.add([x, y].sort().join('|'));
230
+ }
231
+ const nameOf = new Map(graph.elements.map((e) => [e.id, e.name]));
232
+ const reported = new Set();
233
+ const violations = [];
234
+ for (const a of anchors) {
235
+ const seen = coveredBy(a, nodes);
236
+ let frontier = [...seen].filter((k) => owner.get(k) === a.id).sort().map((k) => [k]);
237
+ for (let d = 1; d <= CALL_PATH_MAX_EDGES; d++) {
238
+ const following = [];
239
+ for (const path of frontier) {
240
+ for (const n of next.get(path[path.length - 1]) ?? []) {
241
+ const k = keyOf(n);
242
+ if (seen.has(k))
243
+ continue;
244
+ seen.add(k);
245
+ const other = owner.get(k);
246
+ if (other === undefined) {
247
+ following.push([...path, k]);
248
+ continue;
249
+ }
250
+ const pair = [a.id, other].sort().join('|');
251
+ if (reported.has(pair) || flowPairKeys.has(pair))
252
+ continue;
253
+ reported.add(pair);
254
+ violations.push({
255
+ rule_id: 'RC-13',
256
+ severity: 'warning',
257
+ element_id: a.id,
258
+ message: `${a.id} calls ${other} without a flow — path: ${[...path, k].join(' → ')}`,
259
+ fix_hint: `Model the call as a FLOW between ${a.id} and ${other} (FUNC -io-> FLOW -io-> FUNC, with its SCHEMA and sync) — construction, start and stop count too`,
260
+ context: {
261
+ element_type: 'FUNC',
262
+ element_name: nameOf.get(a.id),
263
+ candidate_targets: [{ id: other, type: 'FUNC', name: nameOf.get(other) ?? other }],
264
+ },
265
+ });
266
+ }
267
+ }
268
+ frontier = following;
269
+ }
270
+ }
271
+ return violations;
272
+ }
@@ -34,6 +34,28 @@ export declare const ImportEdgeSchema: z.ZodObject<{
34
34
  to: z.ZodString;
35
35
  }, z.core.$strip>;
36
36
  export type ImportEdge = z.infer<typeof ImportEdgeSchema>;
37
+ /**
38
+ * Eine Aufrufstelle (CR-SM-415): Datei und der PFAD der Deklaration, Glieder mit `.` getrennt, aeusseres
39
+ * zuerst — `GraphStore.open`, nicht `open`. Erst der Pfad sagt, welche FUNC fuer die Stelle steht, wenn eine
40
+ * Klasse und ihre Methode je eine eigene FUNC tragen (RC-13, innerster Anker). Sprachneutral: ein Rust-
41
+ * Lieferant schreibt `Store.open` fuer `impl Store { fn open }`.
42
+ */
43
+ export declare const CallSiteSchema: z.ZodObject<{
44
+ file: z.ZodString;
45
+ symbol: z.ZodString;
46
+ }, z.core.$strip>;
47
+ /** Eine Aufrufkante: `from` ruft `to` (CR-SM-415, RC-12/RC-13). */
48
+ export declare const CallEdgeSchema: z.ZodObject<{
49
+ from: z.ZodObject<{
50
+ file: z.ZodString;
51
+ symbol: z.ZodString;
52
+ }, z.core.$strip>;
53
+ to: z.ZodObject<{
54
+ file: z.ZodString;
55
+ symbol: z.ZodString;
56
+ }, z.core.$strip>;
57
+ }, z.core.$strip>;
58
+ export type CallEdge = z.infer<typeof CallEdgeSchema>;
37
59
  /**
38
60
  * Deterministic, serializable code facts — the data contract between the
39
61
  * facts extractor (graphcode: TS parser today, ast-grep later — CR-GC-254)
@@ -61,6 +83,17 @@ export declare const CodeFactsSchema: z.ZodObject<{
61
83
  all: "all";
62
84
  referenced: "referenced";
63
85
  }>>;
86
+ callEdges: z.ZodOptional<z.ZodArray<z.ZodObject<{
87
+ from: z.ZodObject<{
88
+ file: z.ZodString;
89
+ symbol: z.ZodString;
90
+ }, z.core.$strip>;
91
+ to: z.ZodObject<{
92
+ file: z.ZodString;
93
+ symbol: z.ZodString;
94
+ }, z.core.$strip>;
95
+ }, z.core.$strip>>>;
96
+ callScope: z.ZodOptional<z.ZodArray<z.ZodString>>;
64
97
  }, z.core.$strip>;
65
98
  export type CodeFacts = z.infer<typeof CodeFactsSchema>;
66
99
  /** A conformance rule: pure over (graph, facts) — never touches I/O itself. */
@@ -18,6 +18,7 @@ import { z } from 'zod/v4';
18
18
  import { readTestRefs, readRealRef } from './ontology.js';
19
19
  import { CLOSED_STATUS } from './cr-quality-rules.js';
20
20
  import { whenDue } from './rule-due.js';
21
+ import { callNeedsFlow, syncFlowNeedsCall } from './call-rules.js';
21
22
  /** Parser facts about one source file (extracted by the executor). */
22
23
  export const FileFactsSchema = z.object({
23
24
  /** File exists on disk (repo-relative path). */
@@ -42,6 +43,15 @@ export const ImportEdgeSchema = z.object({
42
43
  from: z.string(),
43
44
  to: z.string(),
44
45
  });
46
+ /**
47
+ * Eine Aufrufstelle (CR-SM-415): Datei und der PFAD der Deklaration, Glieder mit `.` getrennt, aeusseres
48
+ * zuerst — `GraphStore.open`, nicht `open`. Erst der Pfad sagt, welche FUNC fuer die Stelle steht, wenn eine
49
+ * Klasse und ihre Methode je eine eigene FUNC tragen (RC-13, innerster Anker). Sprachneutral: ein Rust-
50
+ * Lieferant schreibt `Store.open` fuer `impl Store { fn open }`.
51
+ */
52
+ export const CallSiteSchema = z.object({ file: z.string(), symbol: z.string() });
53
+ /** Eine Aufrufkante: `from` ruft `to` (CR-SM-415, RC-12/RC-13). */
54
+ export const CallEdgeSchema = z.object({ from: CallSiteSchema, to: CallSiteSchema });
45
55
  /**
46
56
  * Deterministic, serializable code facts — the data contract between the
47
57
  * facts extractor (graphcode: TS parser today, ast-grep later — CR-GC-254)
@@ -81,6 +91,18 @@ export const CodeFactsSchema = z.object({
81
91
  * would report the absence of what it never looked at. ABSENT = `referenced`.
82
92
  */
83
93
  fileScope: z.enum(['referenced', 'all']).optional(),
94
+ /**
95
+ * Die Aufrufkanten des Codes, fuer RC-12 und RC-13 (CR-SM-415). Der Lieferant waehlt nach `realRef.lang`
96
+ * (graphcode liefert TS, CR-GC-846). ABSENT = Stille, wie `importEdges` fuer RC-05: der Lieferant hat nicht
97
+ * gesucht.
98
+ */
99
+ callEdges: z.array(CallEdgeSchema).optional(),
100
+ /**
101
+ * Die Dateien, deren Aufrufe `callEdges` VOLLSTAENDIG enthaelt — eine Liste repo-relativer Pfade wie die
102
+ * Schluessel von `files`, kein Muster. Nur zwischen diesen Dateien darf ein fehlender Weg ein Befund sein;
103
+ * alles andere zaehlt `callCoverage` als `outOfScope`. ABSENT = leer.
104
+ */
105
+ callScope: z.array(z.string()).optional(),
84
106
  });
85
107
  const missingFile = (facts, file) => facts.files[file]?.exists !== true;
86
108
  // RC-01: every valid FUNC realRef must resolve — file on disk, symbol declared in
@@ -685,6 +707,27 @@ function modMustBeResolvable(graph, facts) {
685
707
  context: { element_type: el.type, element_name: el.name },
686
708
  }));
687
709
  }
710
+ // ---------------------------------------------------------------------------
711
+ // RC-11: Code, der in keinem Modul liegt (CR-SM-405). `importCoverage` war eine Messung, kein Befund:
712
+ // RC-10 meldet das Modul ohne Dateien, RC-05 nur Importe zwischen zwei aufgeloesten Modulen — eine
713
+ // Datei in GAR KEINEM Modul sah keine Regel, und die Marke Bau fiel trotzdem (energymanager/lokal-1:
714
+ // 9 von 18 Endpunkten ohne Modul). Eine Datei ist kein Element; der Befund haengt am SYS, der Anker
715
+ // ist determiniert (kleinste uid). Ohne SYS schweigt die Regel, R-33 meldet den fehlenden SYS.
716
+ // Warning wie jede RC-Regel (CR-SM-353: RC laeuft nie am Gate); auf Stufe 12 haelt jeder Befund Bau.
717
+ // ---------------------------------------------------------------------------
718
+ function codeMustBelongToModule(graph, facts) {
719
+ const sys = graph.elements.filter(e => e.type === 'SYS').map(e => e.id).sort()[0];
720
+ if (sys === undefined)
721
+ return [];
722
+ return importCoverage(graph, facts).unassigned.map(file => ({
723
+ rule_id: 'RC-11',
724
+ severity: 'warning',
725
+ element_id: sys,
726
+ message: `${file} imports or is imported, but belongs to no module — no rule can judge its boundaries`,
727
+ fix_hint: `Set the source directory of the module that owns it (\`~ MOD-x @path <dir>\`), or bind a FUNC of that module to it (\`@realRef {"file":"${file}",…}\`)`,
728
+ context: { file },
729
+ }));
730
+ }
688
731
  // CR-SM-395: Stufe 12 — der Abgleich ist faellig, sobald der Bau eroeffnet ist (s. rule-due.ts).
689
732
  // Zwei Regeln warten nicht auf den Bau und liegen deshalb auf Stufe 10, der letzten Stufe, deren
690
733
  // Faelligkeit die `domain` ist; ihre Befunde halten weiter die Marke Bau:
@@ -705,6 +748,10 @@ export const CODE_CONFORMANCE_RULES = whenDue([
705
748
  { id: 'RC-08', name: 'SCHEMA realRef is a Zod schema', severity: 'warning', stage: 12, domain: ['SCHEMA'], evaluate: schemaRefMustBeZod },
706
749
  { id: 'RC-09', name: 'SCHEMA is parsed only at its modelled interface', severity: 'warning', stage: 12, domain: ['SCHEMA'], evaluate: schemaParsedOnlyAtInterface },
707
750
  { id: 'RC-10', name: 'MOD has resolvable files', severity: 'warning', stage: 12, domain: ['MOD'], evaluate: modMustBeResolvable },
751
+ { id: 'RC-11', name: 'Code file belongs to a module', severity: 'warning', stage: 12, domain: ['SYS'], evaluate: codeMustBelongToModule },
752
+ // CR-SM-415: Fluss und Aufruf decken sich, in beiden Richtungen (call-rules.ts).
753
+ { id: 'RC-12', name: 'Sync flow has a call', severity: 'warning', stage: 12, domain: ['FLOW'], evaluate: syncFlowNeedsCall },
754
+ { id: 'RC-13', name: 'Call between anchored functions has a flow', severity: 'warning', stage: 12, domain: ['FUNC'], evaluate: callNeedsFlow },
708
755
  ]);
709
756
  /** Run all RC rules against a graph + extracted code facts. */
710
757
  export function evaluateConformanceRules(graph, facts) {
@@ -1,10 +1,9 @@
1
1
  /**
2
- * FC-02..FC-05 — FCHAIN quality rules (CR-121 Phase 1; FC-05 CR-SM-363).
2
+ * FC-03..FC-05 — FCHAIN quality rules (CR-121 Phase 1; FC-05 CR-SM-363; FC-02 in UC-03 aufgegangen, CR-SM-412).
3
3
  */
4
4
  import type { OntologyGraph } from './ontology.js';
5
5
  import type { RuleDefinition, RuleViolation } from './rules.js';
6
6
  import type { MetricPolicy } from './policy.js';
7
- export declare function fc02LeafUcHasFchain(graph: OntologyGraph): RuleViolation[];
8
7
  export declare function fc03FchainFlat(graph: OntologyGraph): RuleViolation[];
9
8
  export declare function fc04ActorBounded(graph: OntologyGraph): RuleViolation[];
10
9
  export declare function fc05ChainConnected(graph: OntologyGraph): RuleViolation[];
@@ -1,29 +1,6 @@
1
1
  import { indexOf } from './graph-index.js';
2
2
  import { unwiredFuncs } from './rules.js';
3
3
  // ---------------------------------------------------------------------------
4
- // FC-02: Leaf UC (no UC→compose→UC) must have at least one FCHAIN
5
- // ---------------------------------------------------------------------------
6
- export function fc02LeafUcHasFchain(graph) {
7
- const idx = indexOf(graph);
8
- return idx.elementsOfType('UC')
9
- .filter(uc => {
10
- const composed = idx.out(uc.id, 'compose');
11
- // Leaf = no compose→UC children
12
- if (composed.some(t => idx.typeOf(t.target) === 'UC'))
13
- return false;
14
- // Must have compose→FCHAIN
15
- return !composed.some(t => idx.typeOf(t.target) === 'FCHAIN');
16
- })
17
- .map(uc => ({
18
- rule_id: 'FC-02',
19
- severity: 'warning',
20
- element_id: uc.id,
21
- message: `Leaf UC ${uc.id} has no FCHAIN scenario`,
22
- fix_hint: 'Add a FCHAIN via compose trace for behavioral specification',
23
- context: { element_type: uc.type, element_name: uc.name },
24
- }));
25
- }
26
- // ---------------------------------------------------------------------------
27
4
  // FC-03: ein Block (FUNC mit FUNC-Kindern) ist weder Glied einer Kette noch Erfueller einer Anforderung —
28
5
  // error seit CR-SM-410. Fall 1: FUNC within FCHAIN must not compose other FUNC (flat chain).
29
6
  // ---------------------------------------------------------------------------
@@ -250,7 +227,6 @@ export function fc05ChainConnected(graph) {
250
227
  // Aggregated
251
228
  // ---------------------------------------------------------------------------
252
229
  export const FC_RULES = [
253
- { id: 'FC-02', name: 'Leaf UC has FCHAIN', severity: 'warning', stage: 2, evaluate: fc02LeafUcHasFchain, domain: ['UC'] },
254
230
  // CR-SM-243: domain ist FUNC, nicht FCHAIN — die Regel meldet am FUNC mit der
255
231
  // verschachtelten Zerlegung. Die FCHAIN ist der Suchraum, nicht die Grundgesamtheit:
256
232
  // eine Kette mit n verschachtelten FUNCs erzeugt n Verstoesse gegen einen Beitrag von 1.
@@ -13,16 +13,17 @@ export declare const GRAMMAR_SNAPSHOT: {
13
13
  readonly versions: {
14
14
  readonly ontology: "11.0.0";
15
15
  readonly metaModel: "6.0.0";
16
- readonly rules: "47.0.0";
16
+ readonly rules: "49.1.0";
17
17
  };
18
18
  readonly elementTypes: readonly ["ACTOR", "CR", "FCHAIN", "FLOW", "FUNC", "MOD", "MS", "REQ", "SCHEMA", "SYS", "TEST", "UC"];
19
19
  readonly traceTypes: readonly ["allocate", "compose", "io", "relation", "satisfy", "verify"];
20
20
  readonly patterns: readonly ["ACTOR -io-> FLOW", "CR -relation-> FUNC", "CR -relation-> MOD", "CR -relation-> MS", "CR -relation-> REQ", "CR -relation-> SCHEMA", "CR -relation-> UC", "FCHAIN -compose-> FUNC [1..*]", "FCHAIN -satisfy-> REQ where target.kinds in {non-functional}", "FLOW -io-> ACTOR", "FLOW -io-> FUNC", "FLOW -relation-> SCHEMA [1]", "FUNC -allocate-> MOD [0..1]", "FUNC -compose-> FUNC [0..*]", "FUNC -io-> FLOW", "FUNC -satisfy-> REQ where target.kinds in {functional}", "MOD -compose-> MOD [0..*]", "MOD -satisfy-> REQ where target.kinds in {non-functional}", "MS -compose-> FUNC", "MS -compose-> REQ", "MS -compose-> UC", "MS -relation-> MS label=depends-on", "REQ -compose-> REQ [0..*]", "SYS -compose-> MOD [0..*]", "SYS -compose-> REQ [0..*]", "SYS -compose-> SYS [0..*]", "SYS -compose-> UC [1..*]", "SYS -satisfy-> REQ where target.kinds in {non-functional}", "TEST -verify-> REQ", "TEST -verify-> SCHEMA", "UC -compose-> FCHAIN [1..*]", "UC -compose-> REQ [1..*]"];
21
21
  readonly elementColumns: readonly ["OntologyElement.attributes", "OntologyElement.created_at", "OntologyElement.description", "OntologyElement.id", "OntologyElement.kinds", "OntologyElement.method", "OntologyElement.name", "OntologyElement.status", "OntologyElement.type", "OntologyElement.updated_at", "Trace.attributes", "Trace.created_at", "Trace.label", "Trace.source", "Trace.target", "Trace.type", "Trace.verified_at", "Trace.weight"];
22
22
  readonly attributes: readonly ["CR.architectureOnly: boolean", "CR.rationale: string", "CR.spike: boolean", "CR.status: enum", "FLOW.sync: enum", "FUNC.external: boolean", "FUNC.measuredMs: number", "FUNC.realRef: object", "FUNC.safety_relevant: boolean", "FUNC.sourceFile: string", "FUNC.timingBudgetMs: number", "MOD.external: boolean", "MOD.kind: string", "MOD.path: string", "MOD.realRef: object", "REQ.detection: number", "REQ.occurrence: number", "REQ.role: enum", "REQ.severity: number", "SCHEMA.contract: string", "SCHEMA.external: boolean", "SCHEMA.realRef: object", "TEST.sourceFile: string", "TEST.testRefs: array", "UC.operatingMode: string"];
23
- readonly rules: readonly ["AF-01 (warning) domain=[graph] stage=3 role=analysis", "AF-02 (warning) domain=[graph] stage=7 role=analysis", "AF-03 (warning) domain=[graph] stage=7 role=analysis", "AF-04 (warning) domain=[graph] stage=8 role=analysis", "AF-05 (warning) domain=[graph] stage=10 role=existence", "BQ-01 (warning) domain=[REQ] stage=3", "BQ-02 (warning) domain=[REQ] stage=3", "BQ-04 (warning) domain=[REQ] stage=3", "BQ-06 (warning) domain=[REQ] stage=3", "BQ-07 (warning) domain=[REQ] stage=3", "BW-02 (warning) domain=[FUNC] stage=5", "CL-01 (warning) domain=[ACTOR] stage=2", "CR-01 (warning) domain=[MOD] stage=7", "CR-R01 (warning) domain=[CR] stage=10", "CR-R02 (warning) domain=[CR] stage=10", "CR-R03 (warning) domain=[all] stage=immer", "FC-02 (warning) domain=[UC] stage=2", "FC-03 (error) domain=[FUNC] stage=5", "FC-04 (warning) domain=[FCHAIN] stage=6", "FC-05 (warning) domain=[FCHAIN] stage=6 role=existence", "FM-01 (warning) domain=[REQ] stage=3", "FM-02 (warning) domain=[REQ] stage=3", "FM-03 (warning) domain=[REQ] stage=9", "IO-01 (warning) domain=[FUNC] stage=5", "IO-02 (error) domain=[FLOW] stage=6", "MS-01 (warning) domain=[MS] stage=10", "MS-02 (warning) domain=[MS] stage=10", "MS-03 (info) domain=[CR] stage=10", "MT-01 (warning) domain=[MOD] stage=7", "MT-02 (warning) domain=[MOD] stage=7", "MT-04 (info) domain=[FUNC] stage=5", "ND-01 (warning) domain=[FUNC] stage=5", "ND-02 (warning) domain=[SCHEMA] stage=8", "NFR-01 (warning) domain=[FCHAIN,FUNC,MOD] stage=7", "R-01 (error) domain=[REQ] stage=9 role=existence", "R-02 (warning) domain=[FUNC] stage=5", "R-04 (warning) domain=[MOD] stage=7", "R-05 (warning) domain=[TEST] stage=9", "R-08 (error) domain=[all] stage=immer", "R-10 (warning) domain=[FLOW] stage=6", "R-12 (warning) domain=[FUNC] stage=5", "R-15 (warning) domain=[FCHAIN] stage=5 role=existence", "R-16 (warning) domain=[ACTOR] stage=2", "R-17 (warning) domain=[SYS] stage=2 role=existence", "R-18 (error) domain=[all] stage=immer", "R-19 (warning) domain=[TEST] stage=11", "R-20 (warning) domain=[FUNC] stage=11", "R-21 (warning) domain=[FCHAIN,FUNC] stage=9", "R-22 (warning) domain=[FUNC] stage=7 role=existence", "R-23 (warning) domain=[MOD] stage=7", "R-26 (warning) domain=[SCHEMA] stage=11", "R-29 (error) domain=[TEST] stage=11", "R-30 (warning) domain=[FUNC] stage=5", "R-31 (warning) domain=[FUNC] stage=6 role=existence", "R-32 (warning) domain=[SCHEMA] stage=9 role=existence", "R-33 (warning) domain=[graph] stage=1 role=existence", "RC-01 (warning) domain=[FUNC] stage=12", "RC-02 (warning) domain=[TEST] stage=12", "RC-03 (warning) domain=[SCHEMA] stage=12", "RC-04 (warning) domain=[SCHEMA] stage=12", "RC-05 (warning) domain=[MOD] stage=10", "RC-06 (warning) domain=[FUNC,MOD,SCHEMA] stage=12", "RC-07 (warning) domain=[CR,SYS] stage=10", "RC-08 (warning) domain=[SCHEMA] stage=12", "RC-09 (warning) domain=[SCHEMA] stage=12", "RC-10 (warning) domain=[MOD] stage=12", "RD-01 (warning) domain=[REQ] stage=3", "RD-02 (warning) domain=[REQ] stage=3", "RD-04 (warning) domain=[FUNC,MOD,SYS] stage=7", "RD-05 (warning) domain=[FUNC,MOD] stage=7", "SC-02 (warning) domain=[SCHEMA] stage=8", "UC-01 (warning) domain=[UC] stage=3 role=existence", "UC-02 (warning) domain=[UC] stage=2 role=existence", "UC-03 (warning) domain=[UC] stage=4 role=existence", "UC-04 (warning) domain=[UC] stage=2", "VR-01 (info) domain=[TEST] stage=11"];
24
- readonly conformanceRules: readonly ["RC-01 (warning)", "RC-02 (warning)", "RC-03 (warning)", "RC-04 (warning)", "RC-05 (warning)", "RC-06 (warning)", "RC-07 (warning)", "RC-08 (warning)", "RC-09 (warning)", "RC-10 (warning)"];
23
+ readonly enums: readonly ["CR.status=done", "CR.status=open", "FLOW.sync=async", "FLOW.sync=sync", "OntologyElement.kinds=functional", "OntologyElement.kinds=non-functional", "OntologyElement.method=analysis", "OntologyElement.method=demonstration", "OntologyElement.method=inspection", "OntologyElement.method=test", "OntologyElement.status=done", "OntologyElement.status=draft", "OntologyElement.status=open", "OntologyElement.status=reviewed", "REQ.role=mitigation", "REQ.role=risk"];
24
+ readonly rules: readonly ["AF-01 (warning) domain=[graph] stage=3 role=analysis", "AF-02 (warning) domain=[graph] stage=7 role=analysis", "AF-03 (warning) domain=[graph] stage=7 role=analysis", "AF-04 (warning) domain=[graph] stage=8 role=analysis", "AF-05 (warning) domain=[graph] stage=10 role=existence", "BQ-01 (warning) domain=[REQ] stage=3", "BQ-02 (warning) domain=[REQ] stage=3", "BQ-04 (warning) domain=[REQ] stage=3", "BQ-06 (warning) domain=[REQ] stage=3", "BQ-07 (warning) domain=[REQ] stage=3", "BW-02 (warning) domain=[FUNC] stage=5", "CL-01 (warning) domain=[ACTOR] stage=2", "CR-01 (warning) domain=[MOD] stage=7", "CR-R01 (warning) domain=[CR] stage=10", "CR-R02 (warning) domain=[CR] stage=10", "CR-R03 (warning) domain=[all] stage=immer", "FC-03 (error) domain=[FUNC] stage=5", "FC-04 (warning) domain=[FCHAIN] stage=6", "FC-05 (warning) domain=[FCHAIN] stage=6 role=existence", "FM-01 (warning) domain=[REQ] stage=3", "FM-02 (warning) domain=[REQ] stage=3", "FM-03 (warning) domain=[REQ] stage=9", "IO-01 (warning) domain=[FUNC] stage=5", "IO-02 (error) domain=[FLOW] stage=6", "MS-01 (warning) domain=[MS] stage=10", "MS-02 (warning) domain=[MS] stage=10", "MS-03 (info) domain=[CR] stage=10", "MT-01 (warning) domain=[MOD] stage=7", "MT-02 (warning) domain=[MOD] stage=7", "MT-04 (info) domain=[FUNC] stage=5", "ND-01 (warning) domain=[FUNC] stage=5", "ND-02 (warning) domain=[SCHEMA] stage=8", "NFR-01 (warning) domain=[FCHAIN,FUNC,MOD] stage=7", "R-01 (error) domain=[REQ] stage=9 role=existence", "R-02 (warning) domain=[FUNC] stage=5", "R-04 (warning) domain=[MOD] stage=7", "R-05 (warning) domain=[TEST] stage=9", "R-08 (error) domain=[all] stage=immer", "R-10 (warning) domain=[FLOW] stage=6", "R-12 (warning) domain=[FUNC] stage=5", "R-15 (warning) domain=[FCHAIN] stage=5 role=existence", "R-16 (warning) domain=[ACTOR] stage=2", "R-17 (warning) domain=[SYS] stage=2 role=existence", "R-18 (error) domain=[all] stage=immer", "R-19 (warning) domain=[TEST] stage=11", "R-20 (warning) domain=[FUNC] stage=11", "R-21 (warning) domain=[FCHAIN,FUNC] stage=9", "R-22 (warning) domain=[FUNC] stage=7 role=existence", "R-23 (warning) domain=[MOD] stage=7", "R-26 (warning) domain=[SCHEMA] stage=11", "R-29 (error) domain=[TEST] stage=11", "R-30 (warning) domain=[FUNC] stage=5", "R-31 (warning) domain=[FUNC] stage=6 role=existence", "R-32 (warning) domain=[SCHEMA] stage=9 role=existence", "R-33 (warning) domain=[graph] stage=1 role=existence", "R-35 (error) domain=[FUNC] stage=7", "RC-01 (warning) domain=[FUNC] stage=12", "RC-02 (warning) domain=[TEST] stage=12", "RC-03 (warning) domain=[SCHEMA] stage=12", "RC-04 (warning) domain=[SCHEMA] stage=12", "RC-05 (warning) domain=[MOD] stage=10", "RC-06 (warning) domain=[FUNC,MOD,SCHEMA] stage=12", "RC-07 (warning) domain=[CR,SYS] stage=10", "RC-08 (warning) domain=[SCHEMA] stage=12", "RC-09 (warning) domain=[SCHEMA] stage=12", "RC-10 (warning) domain=[MOD] stage=12", "RC-11 (warning) domain=[SYS] stage=12", "RC-12 (warning) domain=[FLOW] stage=12", "RC-13 (warning) domain=[FUNC] stage=12", "RD-01 (warning) domain=[REQ] stage=3", "RD-02 (warning) domain=[REQ] stage=3", "RD-04 (warning) domain=[FUNC,MOD,SYS] stage=7", "RD-05 (warning) domain=[FUNC,MOD] stage=7", "SC-02 (warning) domain=[SCHEMA] stage=8", "UC-01 (warning) domain=[UC] stage=3 role=existence", "UC-02 (warning) domain=[UC] stage=2 role=existence", "UC-03 (warning) domain=[UC] stage=4 role=existence", "UC-04 (warning) domain=[UC] stage=2", "VR-01 (info) domain=[TEST] stage=11"];
25
+ readonly conformanceRules: readonly ["RC-01 (warning)", "RC-02 (warning)", "RC-03 (warning)", "RC-04 (warning)", "RC-05 (warning)", "RC-06 (warning)", "RC-07 (warning)", "RC-08 (warning)", "RC-09 (warning)", "RC-10 (warning)", "RC-11 (warning)", "RC-12 (warning)", "RC-13 (warning)"];
25
26
  readonly policy: readonly ["apTable = null", "boundaryWidth = {warning:5}", "criticality = {infrastructure:3}", "crossingFlows = {warning:3}", "decompositionBreadth = {min:3,warning:9}", "instability = null", "lcom4 = {info:4,warning:6}", "riskRpn = 100"];
26
- readonly ruleHelp: readonly ["AF-01", "AF-02", "AF-03", "AF-04", "AF-05", "BQ-01", "BQ-02", "BQ-04", "BQ-06", "BQ-07", "BW-02", "CL-01", "CR-01", "CR-R01", "CR-R02", "CR-R03", "FC-02", "FC-03", "FC-04", "FC-05", "FM-01", "FM-02", "FM-03", "IO-01", "IO-02", "MS-01", "MS-02", "MS-03", "MT-01", "MT-02", "MT-04", "ND-01", "ND-02", "NFR-01", "R-01", "R-02", "R-04", "R-05", "R-08", "R-10", "R-12", "R-15", "R-16", "R-17", "R-18", "R-19", "R-20", "R-21", "R-22", "R-23", "R-26", "R-29", "R-30", "R-31", "R-32", "R-33", "RC-01", "RC-02", "RC-03", "RC-04", "RC-05", "RC-06", "RC-07", "RC-08", "RC-09", "RC-10", "RD-01", "RD-02", "RD-04", "RD-05", "SC-02", "UC-01", "UC-02", "UC-03", "UC-04", "VR-01"];
27
- readonly exports: readonly ["ACCEPTED_FINDINGS_ATTRIBUTE", "AF_RULES", "ALL_RULE_DEFS", "AO_RULES", "AcceptedFindingSchema", "ActionPriority", "AnalysisArtifactId", "AnalysisFreshnessStampSchema", "ApTableSchema", "BOUNDED_PATTERNS", "BQ_RULES", "CLOSED_STATUS", "CODE_CONFORMANCE_RULES", "CR_RULES", "ChainMetrics", "CodeFactsSchema", "DEFAULT_METRIC_POLICY", "ELEMENT_ATTRIBUTES", "ELEMENT_DESCRIPTIONS", "ElementType", "ElementUid", "FC_RULES", "FM_RULES", "FileFactsSchema", "FlowSync", "FunctionCriticality", "GRAPH_ANCHOR", "ImportEdgeSchema", "MARK_STAGE", "MAX_SLUG_LENGTH", "META_MODEL_VERSION", "MODELING_ELEMENT_TYPES", "MT_RULES", "Mark", "MetricPolicySchema", "ModuleMetrics", "ND_RULES", "ONTOLOGY_VERSION", "OntologyElement", "OntologyGraph", "PHASE_READINESS_NAME", "REQUIRED_PATTERNS", "RULES_VERSION", "RULE_HELP", "RULE_TASKS", "RealRefSchema", "RepoRelativePathSchema", "ReqKind", "ReqRole", "RequirementScope", "RiskCarriers", "RuleSeverity", "RuleViolation", "SC_RULES", "STAGE_SETS", "SteerSpace", "SteerTerm", "TASK_ENTRY", "TASK_OWNED_RULES", "TRACE_PATTERNS", "TestRefSchema", "TestRefsSchema", "TestResult", "Trace", "TraceType", "UC_RULES", "V3_RULES", "VIEW_RULES", "VerificationMethod", "ViolationCandidate", "ViolationContext", "acceptedRuleIds", "actionPriority", "admittingAlternatives", "allocationCohesion", "apMethod", "attributeTypeOf", "boxContracts", "bq01Unambiguous", "bq02Verifiable", "bq04Necessary", "bq06Conforming", "bq07Complete", "bw02WhiteboxWidth", "chainMetrics", "chainsByFunc", "cl01ConopsCompleteness", "contractsOfFlow", "cr01CrossingFlowCount", "crossingContractCount", "decomposedFuncs", "evaluateAFRules", "evaluateAORules", "evaluateAllRules", "evaluateBQRules", "evaluateCRRules", "evaluateConformanceRules", "evaluateFCRules", "evaluateFMRules", "evaluateMTRules", "evaluateNDRules", "evaluateRules", "evaluateSCRules", "evaluateUCRules", "evaluateViewRules", "extractFormatE", "fc02LeafUcHasFchain", "fc03FchainFlat", "fc04ActorBounded", "fc05ChainConnected", "flowProducers", "fm01MissingFmeaAttributes", "fm02MissingMitigation", "fm03HighRiskUnverified", "funcSimilarity", "funcSubtree", "functionCriticality", "getRuleDefsForProfile", "hydrateAttrValue", "importCoverage", "indexOf", "io01CrossModuleCompleteness", "isDue", "isElementUid", "isValidTrace", "jaccard", "markOfStage", "maxOccurs", "minOccurs", "moduleCrossings", "moduleMetrics", "mt01Instability", "mt02Lcom4", "mt04WhiteboxLcom4", "nd01FuncNearDuplicate", "nd02SchemaNearDuplicate", "nfr01BudgetOvershoot", "normalizeReqKinds", "pairsAbove", "parseElementUid", "readAnalysisStamp", "readFlowSync", "readRealRef", "readReqRole", "readTestRefs", "requirementScope", "riskCarriers", "sc02IsReferenced", "schemaSimilarity", "setBQ04SimilarityMatrix", "subtreeFuncs", "taskOf", "toElementUid", "toEvaluableGraph", "tokens", "traceRejection", "tryParseElementUid", "uc01HasRequirements", "uc02HasActor", "uc03HasScenario", "uc04GoalDefined", "unbuiltElementIds", "unwiredFuncs", "vr01TestNoResult", "whiteboxContractCount"];
27
+ readonly ruleHelp: readonly ["AF-01", "AF-02", "AF-03", "AF-04", "AF-05", "BQ-01", "BQ-02", "BQ-04", "BQ-06", "BQ-07", "BW-02", "CL-01", "CR-01", "CR-R01", "CR-R02", "CR-R03", "FC-03", "FC-04", "FC-05", "FM-01", "FM-02", "FM-03", "IO-01", "IO-02", "MS-01", "MS-02", "MS-03", "MT-01", "MT-02", "MT-04", "ND-01", "ND-02", "NFR-01", "R-01", "R-02", "R-04", "R-05", "R-08", "R-10", "R-12", "R-15", "R-16", "R-17", "R-18", "R-19", "R-20", "R-21", "R-22", "R-23", "R-26", "R-29", "R-30", "R-31", "R-32", "R-33", "R-35", "RC-01", "RC-02", "RC-03", "RC-04", "RC-05", "RC-06", "RC-07", "RC-08", "RC-09", "RC-10", "RC-11", "RC-12", "RC-13", "RD-01", "RD-02", "RD-04", "RD-05", "SC-02", "UC-01", "UC-02", "UC-03", "UC-04", "VR-01"];
28
+ readonly exports: readonly ["ACCEPTED_FINDINGS_ATTRIBUTE", "AF_RULES", "ALL_RULE_DEFS", "AO_RULES", "AcceptedFindingSchema", "ActionPriority", "AnalysisArtifactId", "AnalysisFreshnessStampSchema", "ApTableSchema", "BOUNDED_PATTERNS", "BQ_RULES", "CLOSED_STATUS", "CODE_CONFORMANCE_RULES", "CR_RULES", "CallEdgeSchema", "CallSiteSchema", "ChainMetrics", "CodeFactsSchema", "DEFAULT_METRIC_POLICY", "ELEMENT_ATTRIBUTES", "ELEMENT_DESCRIPTIONS", "ElementType", "ElementUid", "FC_RULES", "FM_RULES", "FileFactsSchema", "FlowSync", "FunctionCriticality", "GRAPH_ANCHOR", "ImportEdgeSchema", "MARK_STAGE", "MAX_SLUG_LENGTH", "META_MODEL_VERSION", "MODELING_ELEMENT_TYPES", "MT_RULES", "Mark", "MetricPolicySchema", "ModuleMetrics", "ND_RULES", "ONTOLOGY_VERSION", "OntologyElement", "OntologyGraph", "PHASE_READINESS_NAME", "REQUIRED_PATTERNS", "RULES_VERSION", "RULE_HELP", "RULE_TASKS", "RealRefSchema", "RepoRelativePathSchema", "ReqKind", "ReqRole", "RequirementScope", "RiskCarriers", "RuleSeverity", "RuleViolation", "SC_RULES", "STAGE_SETS", "SteerSpace", "SteerTerm", "TASK_ENTRY", "TASK_OWNED_RULES", "TRACE_PATTERNS", "TestRefSchema", "TestRefsSchema", "TestResult", "Trace", "TraceType", "UC_RULES", "V3_RULES", "VIEW_RULES", "VerificationMethod", "ViolationCandidate", "ViolationContext", "acceptedRuleIds", "actionPriority", "admittingAlternatives", "allocationCohesion", "apMethod", "attributeTypeOf", "boxContracts", "bq01Unambiguous", "bq02Verifiable", "bq04Necessary", "bq06Conforming", "bq07Complete", "bw02WhiteboxWidth", "callCoverage", "chainMetrics", "chainsByFunc", "cl01ConopsCompleteness", "contractsOfFlow", "cr01CrossingFlowCount", "crossingContractCount", "decomposedFuncs", "evaluateAFRules", "evaluateAORules", "evaluateAllRules", "evaluateBQRules", "evaluateCRRules", "evaluateConformanceRules", "evaluateFCRules", "evaluateFMRules", "evaluateMTRules", "evaluateNDRules", "evaluateRules", "evaluateSCRules", "evaluateUCRules", "evaluateViewRules", "extractFormatE", "fc03FchainFlat", "fc04ActorBounded", "fc05ChainConnected", "flowProducers", "fm01MissingFmeaAttributes", "fm02MissingMitigation", "fm03HighRiskUnverified", "funcSimilarity", "funcSubtree", "functionCriticality", "getRuleDefsForProfile", "hydrateAttrValue", "importCoverage", "indexOf", "io01CrossModuleCompleteness", "isDue", "isElementUid", "isValidTrace", "jaccard", "markOfStage", "maxOccurs", "minOccurs", "moduleCrossings", "moduleMetrics", "mt01Instability", "mt02Lcom4", "mt04WhiteboxLcom4", "nd01FuncNearDuplicate", "nd02SchemaNearDuplicate", "nfr01BudgetOvershoot", "normalizeReqKinds", "pairsAbove", "parseElementUid", "readAnalysisStamp", "readFlowSync", "readRealRef", "readReqRole", "readTestRefs", "requirementScope", "riskCarriers", "sc02IsReferenced", "schemaSimilarity", "setBQ04SimilarityMatrix", "subtreeFuncs", "taskOf", "toElementUid", "toEvaluableGraph", "tokens", "traceRejection", "tryParseElementUid", "uc01HasRequirements", "uc02HasActor", "uc03HasScenario", "uc04GoalDefined", "unbuiltElementIds", "unwiredFuncs", "vr01TestNoResult", "whiteboxContractCount"];
28
29
  };
@@ -13,7 +13,7 @@ export const GRAMMAR_SNAPSHOT = {
13
13
  versions: {
14
14
  ontology: "11.0.0",
15
15
  metaModel: "6.0.0",
16
- rules: "47.0.0",
16
+ rules: "49.1.0",
17
17
  },
18
18
  elementTypes: [
19
19
  "ACTOR",
@@ -118,6 +118,24 @@ export const GRAMMAR_SNAPSHOT = {
118
118
  "TEST.testRefs: array",
119
119
  "UC.operatingMode: string",
120
120
  ],
121
+ enums: [
122
+ "CR.status=done",
123
+ "CR.status=open",
124
+ "FLOW.sync=async",
125
+ "FLOW.sync=sync",
126
+ "OntologyElement.kinds=functional",
127
+ "OntologyElement.kinds=non-functional",
128
+ "OntologyElement.method=analysis",
129
+ "OntologyElement.method=demonstration",
130
+ "OntologyElement.method=inspection",
131
+ "OntologyElement.method=test",
132
+ "OntologyElement.status=done",
133
+ "OntologyElement.status=draft",
134
+ "OntologyElement.status=open",
135
+ "OntologyElement.status=reviewed",
136
+ "REQ.role=mitigation",
137
+ "REQ.role=risk",
138
+ ],
121
139
  rules: [
122
140
  "AF-01 (warning) domain=[graph] stage=3 role=analysis",
123
141
  "AF-02 (warning) domain=[graph] stage=7 role=analysis",
@@ -135,7 +153,6 @@ export const GRAMMAR_SNAPSHOT = {
135
153
  "CR-R01 (warning) domain=[CR] stage=10",
136
154
  "CR-R02 (warning) domain=[CR] stage=10",
137
155
  "CR-R03 (warning) domain=[all] stage=immer",
138
- "FC-02 (warning) domain=[UC] stage=2",
139
156
  "FC-03 (error) domain=[FUNC] stage=5",
140
157
  "FC-04 (warning) domain=[FCHAIN] stage=6",
141
158
  "FC-05 (warning) domain=[FCHAIN] stage=6 role=existence",
@@ -175,6 +192,7 @@ export const GRAMMAR_SNAPSHOT = {
175
192
  "R-31 (warning) domain=[FUNC] stage=6 role=existence",
176
193
  "R-32 (warning) domain=[SCHEMA] stage=9 role=existence",
177
194
  "R-33 (warning) domain=[graph] stage=1 role=existence",
195
+ "R-35 (error) domain=[FUNC] stage=7",
178
196
  "RC-01 (warning) domain=[FUNC] stage=12",
179
197
  "RC-02 (warning) domain=[TEST] stage=12",
180
198
  "RC-03 (warning) domain=[SCHEMA] stage=12",
@@ -185,6 +203,9 @@ export const GRAMMAR_SNAPSHOT = {
185
203
  "RC-08 (warning) domain=[SCHEMA] stage=12",
186
204
  "RC-09 (warning) domain=[SCHEMA] stage=12",
187
205
  "RC-10 (warning) domain=[MOD] stage=12",
206
+ "RC-11 (warning) domain=[SYS] stage=12",
207
+ "RC-12 (warning) domain=[FLOW] stage=12",
208
+ "RC-13 (warning) domain=[FUNC] stage=12",
188
209
  "RD-01 (warning) domain=[REQ] stage=3",
189
210
  "RD-02 (warning) domain=[REQ] stage=3",
190
211
  "RD-04 (warning) domain=[FUNC,MOD,SYS] stage=7",
@@ -207,6 +228,9 @@ export const GRAMMAR_SNAPSHOT = {
207
228
  "RC-08 (warning)",
208
229
  "RC-09 (warning)",
209
230
  "RC-10 (warning)",
231
+ "RC-11 (warning)",
232
+ "RC-12 (warning)",
233
+ "RC-13 (warning)",
210
234
  ],
211
235
  policy: [
212
236
  "apTable = null",
@@ -235,7 +259,6 @@ export const GRAMMAR_SNAPSHOT = {
235
259
  "CR-R01",
236
260
  "CR-R02",
237
261
  "CR-R03",
238
- "FC-02",
239
262
  "FC-03",
240
263
  "FC-04",
241
264
  "FC-05",
@@ -275,6 +298,7 @@ export const GRAMMAR_SNAPSHOT = {
275
298
  "R-31",
276
299
  "R-32",
277
300
  "R-33",
301
+ "R-35",
278
302
  "RC-01",
279
303
  "RC-02",
280
304
  "RC-03",
@@ -285,6 +309,9 @@ export const GRAMMAR_SNAPSHOT = {
285
309
  "RC-08",
286
310
  "RC-09",
287
311
  "RC-10",
312
+ "RC-11",
313
+ "RC-12",
314
+ "RC-13",
288
315
  "RD-01",
289
316
  "RD-02",
290
317
  "RD-04",
@@ -311,6 +338,8 @@ export const GRAMMAR_SNAPSHOT = {
311
338
  "CLOSED_STATUS",
312
339
  "CODE_CONFORMANCE_RULES",
313
340
  "CR_RULES",
341
+ "CallEdgeSchema",
342
+ "CallSiteSchema",
314
343
  "ChainMetrics",
315
344
  "CodeFactsSchema",
316
345
  "DEFAULT_METRIC_POLICY",
@@ -381,6 +410,7 @@ export const GRAMMAR_SNAPSHOT = {
381
410
  "bq06Conforming",
382
411
  "bq07Complete",
383
412
  "bw02WhiteboxWidth",
413
+ "callCoverage",
384
414
  "chainMetrics",
385
415
  "chainsByFunc",
386
416
  "cl01ConopsCompleteness",
@@ -403,7 +433,6 @@ export const GRAMMAR_SNAPSHOT = {
403
433
  "evaluateUCRules",
404
434
  "evaluateViewRules",
405
435
  "extractFormatE",
406
- "fc02LeafUcHasFchain",
407
436
  "fc03FchainFlat",
408
437
  "fc04ActorBounded",
409
438
  "fc05ChainConnected",
@@ -5,12 +5,13 @@
5
5
  /** Ontology schema version (element types + trace types). */
6
6
  export declare const ONTOLOGY_VERSION = "11.0.0";
7
7
  /** Rules engine version (validation rules incl. RC conformance). */
8
- export declare const RULES_VERSION = "47.0.0";
8
+ export declare const RULES_VERSION = "49.1.0";
9
9
  /** Meta-model version (trace pattern constraints + format-e parser). */
10
10
  export declare const META_MODEL_VERSION = "6.0.0";
11
11
  export * from './ontology.js';
12
12
  export * from './rules.js';
13
13
  export * from './conformance-rules.js';
14
+ export { callCoverage, type CallCoverage } from './call-rules.js';
14
15
  export * from './schema-quality-rules.js';
15
16
  export * from './uc-quality-rules.js';
16
17
  export * from './fchain-quality-rules.js';
package/dist/se/index.js CHANGED
@@ -5,12 +5,15 @@
5
5
  /** Ontology schema version (element types + trace types). */
6
6
  export const ONTOLOGY_VERSION = '11.0.0'; // MAJOR (CR-SM-393): das Attribut `concept` entfaellt an TEST, REQ, FUNC, MOD und SCHEMA (Entscheidung des Autors 2026-10-05: Konzept war nur als Zwischenstand gedacht, um mitten im Bau nicht mit Fehlermeldungen ueberhaeuft zu werden; gemessen setzt der lokale Agent es an JEDES Element). Ein Bestandsgraph, der es traegt, laedt weiter: `attributes` ist ein freier Sack, das Attribut ist wirkungslos; ueber Format-E kommt `@concept true` jetzt als String an (kein deklarierter Typ). Bestand: 444 Elemente in 23 von 35 Graphen tragen es (TEST 221, FUNC 113, SCHEMA 99, MOD 11, REQ 0). Prior: // MINOR (CR-SM-391): +`REQ.attributes.concept: boolean` — das fuenfte Element mit dem Schalter (TEST, FUNC, MOD, SCHEMA). Gelesen von R-01: nur eine Konzept-REQ darf ausschliesslich Konzept-TESTs tragen. Anders als an den vier anderen ist er KEINE Ausnahme von einer Bindungspflicht (eine REQ hat keinen realRef), sondern die Erklaerung, dass der Nachweis noch nicht faellig ist; ein `verify` braucht auch sie. Bestand: kein Graph der Familie traegt `concept` an einer REQ (35 Graphen, gemessen 2026-10-05), keine Migration. Prior: // MINOR (CR-SM-386): +`CR.attributes.architectureOnly: boolean`. CR-R02 las den Schalter identitaetsscharf (`=== true`), er stand aber nicht in ELEMENT_ATTRIBUTES — die typ-geleitete Hydrierung (CR-SM-251) liess `@architectureOnly true` als String "true" stehen, die Ausnahme war ueber Format-E unerreichbar. Bestand: bereits gespeicherte Strings "true" bleiben im Store Strings, bis der Knoten neu geschrieben oder per Export-Reimport hydriert wird; keine Migration. Prior: // BREAKING innerhalb des unveroeffentlichten 10.x (CR-SM-366): `ReqKind` 6 -> 2 Werte {functional, non-functional}, genau EIN Wert je REQ. Entfallen: precondition/postcondition (Vorbedingung = Eingangs-FLOW der Kette, Nachbedingung = UC-Ziel, geprueft ueber R-21; Leser UC-05/06 seit CR-SM-357 weg) und risk/mitigation (-> `REQ.attributes.role`, CR-SM-365). Die Zeichenkette bleibt 10.1.0: die Enum-WERTE stehen in keiner Oberflaeche von grammar-snapshot.ts (nur die Spalte `OntologyElement.kinds`), `check:grammar` verlangt also keine Bewegung; gegen die Registry (9.1.0) ist 10.x der eine Major dieses Zugs. Migration (graphcode CR-GC-669): pre/post-REQ je REQ auf functional|non-functional oder aufloesen, risk/mitigation -> role. Prior: // MINOR (CR-SM-365): +`REQ.attributes.role` (Enum `ReqRole` risk|mitigation, Leser `readReqRole`) — die FMEA-Rolle einer Anforderung, satisfy-neutral. Reine Ergaenzung an der Oberflaeche (ReqKind unveraendert; die Entfernung von risk/mitigation aus `kinds` ist CR-SM-366). Kein eigener Major: 10.0.0 ist unveroeffentlicht (Registry 9.1.0), 10.x ist EIN Major gegen die Registry; `check:grammar` vergleicht je Commit gegen HEAD und erzwingt daher eine Bewegung der Zeichenkette. Prior: // MAJOR (CR-SM-364): FLOW traegt genau ein Realisierungsattribut `sync` (Enum sync|async, fehlend = unbekannt, kein Default; Leser `readFlowSync`, Enum `FlowSync`). `protocol` und `qos` entfallen — formal breaking, am Bestand folgenlos: 0 von 186 Familien-FLOWs (bok, SM, GVE, GC, graphify) setzen eines davon, kein Leser ausser ontology.ts/grammar-snapshot.ts. Prior: // MINOR (CR-SM-355): `AnalysisFreshnessStampSchema.crRefs?: string[]` — die aus einem Task hervorgegangenen CRs, atomar mit dem Stempel; TR-01/IR-01 lesen es. Prior: // BREAKING (CR-SM-294): das Feld `asil` entfaellt ersatzlos, zusammen mit dem Enum `AsilLevel`. Sein einziger Leser war R-03 (ASIL isolation), und die Messung ueber 19 Familiengraphen (4540 Elemente) zeigt: 0 von 305 MOD tragen `asil` ueberhaupt. Ein Feld ohne Schreiber ist eine Regel, die nie feuert -- Gate 3 der Grammatik-Review. Mit R-03 fallen im selben Zug RT-01, PH-01, R-27 (alle drei lesen `attributes.kind === 'physical'`, 0 von 305 MOD tragen es) und CA-01 (`attributes.requires` / `attributes.capability`, 0/0). Die physische Ebene der Ontologie war nie in Gebrauch: kein Mitglied der Familie modelliert Hardware oder funktionale Sicherheit. `kind`, `requires` und `capability` brauchen KEINEN Schema-Eingriff -- sie lagen im freien `attributes`-Sack und sind nach der Streichung ihrer Leser schlicht unbenutzte Schluessel. Migration: ein Graph, der `asil` traegt, verliert das Feld beim naechsten Reseed; kein Element und keine Kante faellt (0 -> 0 Befunde ueber alle 19 Graphen). Prior: BREAKING (CR-SM-266a): drei Enums schrumpfen, und alle drei sind ENTFERNUNGEN. (1) ElementType 13 -> 12: `SESSION` entfaellt. (2) TraceType 7 -> 6: `produces` entfaellt. Beide trugen genau EIN Pattern (`SESSION -produces-> *`), und die Messung hat es widerlegt: 0 produces-Kanten und 0 SESSION-Knoten in ALLEN 9 aktiven Familie-Graphen, auch im graphcode-Selbstmodell nach 195 gegateten Versionen. Die reale Provenance lebt seit CR-GC-347 in `.graphcode/audit.jsonl` -- audit_trail/audit_stats lesen die DATEI, nie den Graphen; einziger Schreiber war ein toter Pfad (CR-195d in graph-api-core), Leser mit Wirkung keiner. Der urspruengliche CR-Entwurf hielt das Pattern fuer die Provenance-Kante und wollte es BEHALTEN ('Nicht-Befund'); die Zaehlung hat den Nicht-Befund kassiert -- Gate 1 verlangt fuer das Wiederaufmachen einer Entscheidung eine Messung, und hier war sie es. (3) Mit `produces` faellt `TraceCategory` und `Trace.category`. Das ist die wichtigste Haelfte: R-08 und R-18 haben `category === 'audit'` UEBERSPRUNGEN, also haette nach D5 jede Kante mit diesem selbstgesetzten Attribut die komplette Pattern-Matrix UND die Referenzintegritaet umgangen. Ein Attribut, das eine Strukturpruefung abschaltet, ist die Klasse aus CR-SM-263/-257; hier zusaetzlich der billige Zweitweg aus CR-GC-366, nur ohne Kante. Gemessen: 0 von 0 Traces aller 9 Graphen tragen `category` -- die Entfernung nimmt niemandem etwas weg. (4) ReqKind 7 -> 6: `negative` entfaellt. Ein Verbots-REQ ist auch eine Anforderung -- die Implementierung muss Regeln abfragen oder Sicherungen einbauen, das ist `functional`. Der Wert hatte NULL Leser (anders als risk/mitigation -> FM-01..03, pre/postcondition -> UC-05/06, non-functional -> NFR-01) und haette durch die neuen where-Praedikate per AUSLASSUNG erstmals Wirkung bekommen: er stand in keiner der vier Listen und waere nur noch per FCHAIN erfuellbar gewesen. Die sechs verbleibenden Werte partitionieren die where-Listen VOLLSTAENDIG. Migration `negative`: 3 REQs, alle graphcode, Ziel-kind je REQ statt pauschal -- REQ-dashboard-readonly und REQ-readonly-bridge nach `non-functional` (Architektur-Constraint an der Modulgrenze, konsistent mit D2), REQ-no-extraction nach `functional`. Rest-Reject dabei: genau 1 (`FUNC-serve-sse -satisfy-> REQ-readonly-bridge`), aufzuloesen durch Loeschen oder Heben auf die FCHAIN. Prior: BREAKING (CR-GC-366): das Trace-Pattern `FUNC -satisfy-> UC` entfaellt ersatzlos. Es war ein zweiter Weg vom Verhalten zum Use Case neben dem einzig tragenden `UC -compose-> FCHAIN -compose-> FUNC` — und der billigere: eine FUNC konnte einen UC bedienen, ohne in dessen Wirkkette zu stehen, womit IO-01 (FLOW-Pfade je Kettenpaar) und R-21 (Integrationstest je Kette) sie nie sahen. Die Abkuerzung umging genau die Pruefungen, die die Anbindung belastbar machen. Am graphcode-Selbstmodell waren 10 der 26 solchen Kanten reine Dopplung (die FUNC stand ohnehin in der FCHAIN), die restlichen 13 sind der Migrationsanlass. Jeder Graph mit solchen Kanten faellt jetzt R-18 (error) zur Last und muss migriert werden: FUNC in die FCHAIN des UC aufnehmen, satisfy-Kante loeschen. Prior: BREAKING (CR-SM-231b): das knotenweite `testResult` entfaellt — das Ergebnis haengt PRO `testRefs`-Eintrag (`result`, `ranAt`, `evidence`), aus demselben Grund wie `tool`. Ein einzelnes Ergebnis am Knoten konnte bei n Laeufen nicht sagen, welcher gemeint ist, und "einer rot, einer gruen" war gar nicht darstellbar — genau der Zustand, den ein Gate wissen muss. FM-03 liest jetzt "jeder Eintrag passed": "irgendeiner gruen" haette einen gruenen Unit-Lauf einen roten Visual-Lauf verdecken lassen. Ein Eintrag ohne Ergebnis ist nicht bestanden. VR-01 meldet die Dateien ohne Ergebnis statt nur den Knoten. Prior: BREAKING (CR-SM-231): `testRef` (Objekt) entfaellt ersatzlos zugunsten von `testRefs` (Array, min 1) — eine Abnahme, n Testdateien. Kein Union, kein Alias: ein Graph mit dem alten Attribut faellt R-19 zur Last und muss migriert werden. Anlass war ein Zaehl-Audit (537 laufende Tests in 67 Dateien, 14 TEST-Knoten mit je genau einer Datei, 53 Dateien an keine Abnahme gebunden) plus ein belegter Ausweichweg: dieselbe Spec-Datei stand im testRef ZWEIER TEST-Knoten, womit die Relation faktisch n:m war — ein roter Lauf keiner Abnahme mehr eindeutig zuordenbar, der TRR-Gate zaehlte dieselbe Evidenz doppelt. `tool` bleibt PRO EINTRAG: eine Abnahme mischt real die Runner (vitest + playwright). +AttributeSpec.type 'array' (testRefs ist das erste Listen-Attribut). Prior: BREAKING: `SemanticId` (`Name.TypeAbbr.Counter`) deleted, `ElementUid` (`<TYPE>-<slug>`) is the family canon — the old canon was used by no production graph of the family while 626 of 1145 elements already carried TYPE-slug (CR-SM-217); realRef unifies codeRef+schemaRef (+physical-MOD CAD ref), symbol optional; testRef stays separate (CR-228 C); +RepoRelativePathSchema on testRef/realRef .file — no absolute/`..` paths (CR-GC-255)
7
7
  /** Rules engine version (validation rules incl. RC conformance). */
8
- export const RULES_VERSION = '47.0.0'; // MAJOR (CR-SM-411): R-08 bekommt unter derselben Kennung und Schwere den zweiten Fall — ein Element traegt in einem Feld einen Wert, den der Element-Vertrag (`OntologyElement`) nicht kennt; dazu `role` an REQ (Entscheidung des Autors 2026-10-12: der Stand ist ein Fehler, den eine Regel als Befund meldet; das Modell wird nicht beim Laden abgelehnt). Bis hierher pruefte das nur das graphcode-Gate an dem, was ein Zug schreibt (lokal `SCHEMA-02`); Altbestand nannte keine Regel, und die Messung in graphcode brach daran ab (CR-GC-786). Das Urteil wird strenger: gezaehlt ueber 36 Modelldateien der Familie 100 neue Fehler in 6 Dateien (98 an `kinds` aus der Zeit vor CR-SM-366, 2 an `status`). Kein Export faellt; ein Modell mit Altbestand laedt weiter, das Gate weist nur neu eingefuehrte Fehler ab. An R-08 statt einer eigenen Kennung: Stufe `immer`, Menge `all` und Schwere sind dieselben, die Aussage auch (der Bestand widerspricht seinem Schema). Der Regelname lautet jetzt „Data integrity“. Davor 46.0.0: MAJOR (CR-SM-410): FC-03 (Block als Glied einer Kette) wird vom Hinweis zum FEHLER (Entscheidung des Autors 2026-10-11: „Block als Glied oder Erfuellen ist ein Fehler, dann muessen die bestehenden Repos eben gerichtet werden"). Als Fehler haelt der Befund die Marke PDR, und ein Gate, das neue Fehler abweist, nimmt eine Kette mit Block nicht mehr an. Nachgezaehlt ueber 30 Modelle der Familie nach dem Richten (graph-view-edit 30faf80, graphcode c20b2afd): 41 Bloecke, 0 Befunde. Unter derselben Kennung der zweite Fall: ein Block, der eine Anforderung erfuellt (`FUNC -satisfy-> REQ` an einer FUNC mit FUNC-Kindern), ist derselbe Fehler — bis hierher meldete das keine Regel. An FC-03 statt an R-02, weil eine Kennung keine zwei Schweren traegt (R-02 bleibt Warnung). Der Regelname lautet jetzt „Block is neither chain member nor satisfier". Davor 45.0.0: MAJOR (CR-SM-409): FC-05 (Kette haengt zusammen) bekommt die Rolle `existence` und haelt damit die Marke PDR (Entscheidung des Autors 2026-10-11). Kein Eintrag entfaellt, kein Befund aendert sich — aber das Urteil wird strenger: ein Modell mit zerfallener Kette, das PDR erreichte, erreicht sie nicht mehr. Gezaehlt ueber 30 Modelle der Familie: FC-05 meldet 2 Ketten in 1 Modell (graph-view-edit), dort haelt IO-02 die Marke schon; heute verliert kein Modell eine Marke. R-30 und FC-04 bleiben ohne Rolle. Davor 44.0.0: MAJOR (CR-SM-401): Stufe statt Dimension, Befunde zaehlen statt Prozent (Entscheidung des Autors 2026-10-07). ENTFERNT: `RULE_TO_DIMENSION`, `ReadinessDimension`, `ReadinessScore`, `ReadinessReport` (contracts; `SteerSpace`/`SteerTerm` bleiben), `DIMENSION_READINESS_NAME`, `DIMENSION_READINESS_DELTA_NAME`; in se-engine `computeReadiness` und `coreTypesOf`. Es gibt EINE Einteilung der Regeln, die Stufe; die Zahl der Befunde je Stufe liefert `countByStage` in @sigloch/graphcode-client. Keine Regel, keine Stufe, keine Marke aendert sich — Befunde und Marken ueber 38 Graphen identisch (gemessen). Davor 43.0.0 (CR-SM-400): eine Entscheidung ist ein erledigter Auftrag (Entscheidungen des Autors 2026-10-07). (a) `hasOpenOrder` filtert nicht mehr auf `relation [label: decides]`: ein offener CR ist ein Auftrag, ohne Ersatz. 3 offene CRs im Bestand tragen die Kante; in der Rig-Referenz `frontier` eroeffnen zwei davon jetzt den Bau, bis sie als erledigt gefuehrt sind. (b) Regel TR-01 („Trade decision recorded as CR“) ist ENTFERNT, mit ihr das Feld `crRefs` am Analyse-Vermerk und die Exporte `tradeDecisionRecorded`, `TASK_OUTCOME_RULES`, `evaluateTaskOutcomeRules` — 1 Befund an 38 Graphen. Der Vermerk ist `{ graphVersion }`; ein Alt-Vermerk mit `crRefs` laedt weiter (nicht-striktes Schema, das Feld wird abgestreift). Kein Kerntyp und kein Score je Dimension wandert (gemessen). (c) Der Hinweis von AF-02 nennt den erledigten CR mit relation-Kanten statt der `decides`-Kante. Katalog 77 → 76 Regeln. NICHT enthalten: CR-R02, `commitRef`, `architectureOnly` (warten auf den Autor, CR-SM-400 §4). Davor 42.0.0 (CR-SM-399): sechs Streichungen aus dem Sonderwissen der Steuerung (IR-01, `reqRefs`, `READINESS_SCORED_PROFILES`, `readFlowSync`, `codeRef`-Rueckfall, `fields`).
8
+ export const RULES_VERSION = '49.1.0'; // MINOR (CR-SM-415): zwei neue Regeln, beide warning, Stufe 12 — RC-12 („Sync flow has a call“, Domaene FLOW: ein FLOW mit `sync: sync` ohne Aufrufweg zwischen Erzeuger- und Abnehmer-FUNC, hoechstens 3 Kanten, eine der beiden Richtungen, oder ohne gueltigen Beleg `FLOW.realRef`) und RC-13 („Call between anchored functions has a flow“, Domaene FUNC: ein Aufrufweg zwischen zwei verankerten FUNCs ohne FLOW; innerster Anker, Weg endet an der ersten anderen verankerten FUNC). Beide lesen das neue optionale Feld `CodeFacts.callEdges`/`callScope` und schweigen ohne es; kein bestehendes Modell bekommt einen Befund, bis ein Lieferant die Kanten liefert (graphcode CR-GC-846). Dazu die Messung `callCoverage` neben `importCoverage`. Davor 49.0.0: MAJOR (CR-SM-405): neue Regel RC-11 („Code file belongs to a module“, warning, Stufe 12, Domaene SYS): je Import-Endpunkt, der zu keinem MOD aufloest, ein Befund am SYS — dieselbe Aufloesung wie RC-05 und `importCoverage` (Entscheidung des Autors 2026-10-15/19: Variante A, keine Ausnahmeliste; warning, weil RC nie am Gate laeuft, CR-SM-353, und auf Stufe 12 jeder Befund Bau haelt). Das Urteil wird strenger: ein Modell mit unzugeordnetem Code erreicht Bau nicht mehr. Vorbedingung graphcode 147518d7 (ITEM-2026-948): Tests und Nicht-Code sind keine Import-Endpunkte mehr. Davor 48.0.0: MAJOR (CR-SM-413): R-22 prueft nur noch Blattfunktionen, und die neue Regel R-35 („Block is not allocated to a module“, error, Stufe 7) meldet einen Block (FUNC mit FUNC-Kindern), der eine `allocate`-Kante auf ein MOD traegt (Entscheidung des Autors 2026-10-14/15: „mod ist mod, warum kommen da ueberhaupt func. und schon gar keine aggregierten“; eigene Kennung, weil die Regel MOD braucht, also Stufe 7, nicht Stufe 5 wie FC-03). Das Urteil wird strenger: ein Modell mit zugeordnetem Block bekommt einen Fehler, der PDR haelt. Vorher gerichtet: graphcode 15 Kanten, graph-view-edit 1. Bewusst nicht gerichtet (Entscheidung des Autors 2026-10-15, „fehler akzeptieren“): sirail, bok, sigllm, energymanager, agentdiary-frontier. Davor 47.1.0: MINOR (CR-SM-412): FC-02 („Leaf UC has FCHAIN“) entfaellt, UC-03 uebernimmt seine Blatt-Bedingung (ein UC mit `compose → UC`-Kindern braucht keine eigene Kette). Beide meldeten denselben Sachverhalt, weil `UC -compose-> UC` nicht in der Matrix steht: 36 von 36 Befunden doppelt ueber 36 Graphen. Kein Sachverhalt geht verloren, kein Urteil wird strenger, keine Marke aendert sich (FC-02 trug keine Rolle, UC-03 haelt wie bisher). Export `fc02LeafUcHasFchain` faellt, kein Leser in graphcode/graph-view-edit. Davor 47.0.0: MAJOR (CR-SM-411): R-08 bekommt unter derselben Kennung und Schwere den zweiten Fall — ein Element traegt in einem Feld einen Wert, den der Element-Vertrag (`OntologyElement`) nicht kennt; dazu `role` an REQ (Entscheidung des Autors 2026-10-12: der Stand ist ein Fehler, den eine Regel als Befund meldet; das Modell wird nicht beim Laden abgelehnt). Bis hierher pruefte das nur das graphcode-Gate an dem, was ein Zug schreibt (lokal `SCHEMA-02`); Altbestand nannte keine Regel, und die Messung in graphcode brach daran ab (CR-GC-786). Das Urteil wird strenger: gezaehlt ueber 36 Modelldateien der Familie 100 neue Fehler in 6 Dateien (98 an `kinds` aus der Zeit vor CR-SM-366, 2 an `status`). Kein Export faellt; ein Modell mit Altbestand laedt weiter, das Gate weist nur neu eingefuehrte Fehler ab. An R-08 statt einer eigenen Kennung: Stufe `immer`, Menge `all` und Schwere sind dieselben, die Aussage auch (der Bestand widerspricht seinem Schema). Der Regelname lautet jetzt „Data integrity“. Davor 46.0.0: MAJOR (CR-SM-410): FC-03 (Block als Glied einer Kette) wird vom Hinweis zum FEHLER (Entscheidung des Autors 2026-10-11: „Block als Glied oder Erfuellen ist ein Fehler, dann muessen die bestehenden Repos eben gerichtet werden"). Als Fehler haelt der Befund die Marke PDR, und ein Gate, das neue Fehler abweist, nimmt eine Kette mit Block nicht mehr an. Nachgezaehlt ueber 30 Modelle der Familie nach dem Richten (graph-view-edit 30faf80, graphcode c20b2afd): 41 Bloecke, 0 Befunde. Unter derselben Kennung der zweite Fall: ein Block, der eine Anforderung erfuellt (`FUNC -satisfy-> REQ` an einer FUNC mit FUNC-Kindern), ist derselbe Fehler — bis hierher meldete das keine Regel. An FC-03 statt an R-02, weil eine Kennung keine zwei Schweren traegt (R-02 bleibt Warnung). Der Regelname lautet jetzt „Block is neither chain member nor satisfier". Davor 45.0.0: MAJOR (CR-SM-409): FC-05 (Kette haengt zusammen) bekommt die Rolle `existence` und haelt damit die Marke PDR (Entscheidung des Autors 2026-10-11). Kein Eintrag entfaellt, kein Befund aendert sich — aber das Urteil wird strenger: ein Modell mit zerfallener Kette, das PDR erreichte, erreicht sie nicht mehr. Gezaehlt ueber 30 Modelle der Familie: FC-05 meldet 2 Ketten in 1 Modell (graph-view-edit), dort haelt IO-02 die Marke schon; heute verliert kein Modell eine Marke. R-30 und FC-04 bleiben ohne Rolle. Davor 44.0.0: MAJOR (CR-SM-401): Stufe statt Dimension, Befunde zaehlen statt Prozent (Entscheidung des Autors 2026-10-07). ENTFERNT: `RULE_TO_DIMENSION`, `ReadinessDimension`, `ReadinessScore`, `ReadinessReport` (contracts; `SteerSpace`/`SteerTerm` bleiben), `DIMENSION_READINESS_NAME`, `DIMENSION_READINESS_DELTA_NAME`; in se-engine `computeReadiness` und `coreTypesOf`. Es gibt EINE Einteilung der Regeln, die Stufe; die Zahl der Befunde je Stufe liefert `countByStage` in @sigloch/graphcode-client. Keine Regel, keine Stufe, keine Marke aendert sich — Befunde und Marken ueber 38 Graphen identisch (gemessen). Davor 43.0.0 (CR-SM-400): eine Entscheidung ist ein erledigter Auftrag (Entscheidungen des Autors 2026-10-07). (a) `hasOpenOrder` filtert nicht mehr auf `relation [label: decides]`: ein offener CR ist ein Auftrag, ohne Ersatz. 3 offene CRs im Bestand tragen die Kante; in der Rig-Referenz `frontier` eroeffnen zwei davon jetzt den Bau, bis sie als erledigt gefuehrt sind. (b) Regel TR-01 („Trade decision recorded as CR“) ist ENTFERNT, mit ihr das Feld `crRefs` am Analyse-Vermerk und die Exporte `tradeDecisionRecorded`, `TASK_OUTCOME_RULES`, `evaluateTaskOutcomeRules` — 1 Befund an 38 Graphen. Der Vermerk ist `{ graphVersion }`; ein Alt-Vermerk mit `crRefs` laedt weiter (nicht-striktes Schema, das Feld wird abgestreift). Kein Kerntyp und kein Score je Dimension wandert (gemessen). (c) Der Hinweis von AF-02 nennt den erledigten CR mit relation-Kanten statt der `decides`-Kante. Katalog 77 → 76 Regeln. NICHT enthalten: CR-R02, `commitRef`, `architectureOnly` (warten auf den Autor, CR-SM-400 §4). Davor 42.0.0 (CR-SM-399): sechs Streichungen aus dem Sonderwissen der Steuerung (IR-01, `reqRefs`, `READINESS_SCORED_PROFILES`, `readFlowSync`, `codeRef`-Rueckfall, `fields`).
9
9
  /** Meta-model version (trace pattern constraints + format-e parser). */
10
10
  export const META_MODEL_VERSION = '6.0.0'; // MAJOR (CR-SM-366): satisfy-where je Erfueller genau ein kind — FUNC {functional}, MOD/SYS {non-functional}, und NEU `FCHAIN -satisfy-> REQ where target.kinds in {non-functional}` (bisher ohne where). Eine functional-REQ an der Kette hatte keine FUNC und damit keinen realRef; jetzt R-18 `kinds-mismatch` mit candidate_sources [FUNC]. Bestand (5 Familien-Snapshots, 2026-09-27): 27 functional-REQ an FCHAIN, 53 satisfy-Kanten auf pre/postcondition-REQ, 4 auf risk/mitigation-REQ; ungueltige satisfy-Kanten 7 -> 91. Prior: // MINOR (CR-SM-341): `CR -relation-> SCHEMA` ergaenzt -- reine Erweiterung, keine Bestandskante wird ungueltig. Die Kante war der einzige Punkt, an dem zwei Regeln DESSELBEN Katalogs einander widersprachen: CR-R01 verlangt einen Umfang und nennt SCHEMA ausdruecklich (SCOPE_TYPES = FUNC/MOD/SCHEMA/REQ/UC, cr-quality-rules.ts), R-18 wies genau diese Kante ab, weil die Matrix fuer CR nur MS/UC/REQ/FUNC/MOD kannte. Gemessen an zwei Audit-Logs: 6 Ablehnungen in graphcode, 3 in sigllm -- jedes Mal ein CR, dessen Umfang ein Vertrag ist. Erweitert statt den fixHint zu kuerzen: ein CR, der eine Schnittstelle schneidet, hat genau dort seinen Umfang. Gleicher Zug, ohne Oberflaechenwirkung: R-18 haengt seinen Ablehnungsgrund als `context.trace_rejection` an den Befund (neuer Export `admittingAlternatives`). Prior: // MINOR (CR-SM-317, ITEM-2026-064): neues Muster `TEST -verify-> SCHEMA` — der Vertragstest haengt am Vertrag, nicht an einer Hilfs-REQ; additiv, kein bestehender Graph faellt. Prior: // BREAKING (CR-SM-271 Teil 2): `FLOW -relation-> SCHEMA` wird `1..1` — die erste DURCHGESETZTE Untergrenze (minOccurs/REQUIRED_PATTERNS; nur exakt-`1`, die `1..*`-compose-Untergrenzen bleiben Vollstaendigkeits-Warnungen ihrer Regeln). Migrationsbestand vorab abgetragen: graphcode 2, sigloch-modules 4, graph-view-edit 5 (je durchs Gate), urbanmobility-Fixture geloescht (39, Spike ohne Referenzen); sirail 4 offen (EXPORT_PENDING-Divergenz seit 2026-08-18).
11
11
  export * from './ontology.js';
12
12
  export * from './rules.js';
13
13
  export * from './conformance-rules.js';
14
+ // CR-SM-415: RC-12/RC-13 liegen in call-rules.ts; nach aussen geht nur die Messung, die Regeln laufen ueber
15
+ // CODE_CONFORMANCE_RULES.
16
+ export { callCoverage } from './call-rules.js';
14
17
  export * from './schema-quality-rules.js';
15
18
  export * from './uc-quality-rules.js';
16
19
  export * from './fchain-quality-rules.js';
@@ -124,12 +124,6 @@ export const RULE_HELP = {
124
124
  se: "One element tracked by more than one `CR` with `status` open/in-progress.",
125
125
  vorschlag: 'Kläre, welcher der offenen Änderungsaufträge an {n} zuerst ändert.',
126
126
  },
127
- 'FC-02': {
128
- plain: "A scenario that is not broken into sub-scenarios has no described sequence of steps → add one, even if the steps are done by hand.",
129
- se: "Leaf `UC` (no `UC -compose-> UC`) with no `FCHAIN`. A chain may consist of EXISTING FUNCs an actor strings together — it costs a node plus compose edges, not code.",
130
- prompt: "se:author-uc",
131
- vorschlag: 'Beschreibe die Abläufe {n} als Kette von Funktionen.',
132
- },
133
127
  'FC-03': {
134
128
  plain: "A step that contains further steps is used as if it were a single step: it sits in a sequence, or it is named as the one that fulfils a requirement. A container only collects steps → put its inner steps into the chain, and attach the requirement to the inner step that really carries it.",
135
129
  se: "`FUNC` that `compose`s other `FUNC`s (a block) and is a member of an `FCHAIN` or `satisfy`s a `REQ`. A block is neither chain member nor satisfier: chains are flat, and a requirement hangs on the leaf function that carries it (a requirement of the whole belongs to `MOD`, `FCHAIN` or `SYS`). Error (CR-SM-410).",
@@ -303,9 +297,14 @@ export const RULE_HELP = {
303
297
  },
304
298
  'R-22': {
305
299
  plain: "A function isn't assigned to any building block, so it has no home in the structure → put it on a module.",
306
- se: "`FUNC` with no `allocate` trace to a `MOD` (deployment assignment); every function lives on exactly one module.",
300
+ se: "Leaf `FUNC` (no `compose` child of type `FUNC`) with no `allocate` trace to a `MOD`; every leaf function lives on exactly one module. A block spans modules and has none (R-35, CR-SM-413).",
307
301
  vorschlag: 'Ordne die Funktionen {n} Modulen zu.',
308
302
  },
303
+ 'R-35': {
304
+ plain: "A function that only groups other functions is placed on a building block. Its inner functions often sit on different blocks, so no single one is right → remove the assignment; the inner functions keep theirs.",
305
+ se: "`FUNC` with `compose` children of type `FUNC` (a block) carrying an `allocate` trace to a `MOD`. The function tree and the module tree do not mirror each other; a block spans modules. Error (CR-SM-413).",
306
+ vorschlag: 'Löse die Modulzuordnung der Blöcke {n}; ihre inneren Funktionen behalten ihre Module.',
307
+ },
309
308
  'R-23': {
310
309
  plain: "A building block is empty — no function is assigned to it or to any block inside it → put a function on it, or remove the empty block.",
311
310
  se: "`MOD` with no `FUNC` ─allocate→ trace anywhere in its `compose` subtree (`subtreeFuncs`, the same count R-04 uses, CR-SM-321); the module-side complement of R-22 (empty-container signal like R-14/R-16/R-17). A container `MOD` whose sub-modules hold functions is not empty.",
@@ -382,6 +381,21 @@ export const RULE_HELP = {
382
381
  se: "`MOD` with neither a `path` attribute nor an allocated `FUNC` carrying a bound `realRef` — the only two ways a file resolves to a module. Without either, RC-05 and the boundary measurement are blind for this module by construction (sigllm: 0 RC-05 findings at 19 % import coverage, 8 at 81 %). The message names the cost from `importCoverage`. `external` modules are exempt, as for R-20 (CR-SM-344). Stage 11: due only once the build is open — an open CR or a first `realRef`/`testRefs` in the graph; before that it is not evaluated, not passed (CR-SM-395).",
383
382
  vorschlag: 'Gib den Modulen {n} ihren Quellordner.',
384
383
  },
384
+ 'RC-11': {
385
+ plain: "A code file belongs to no building block, so nobody checks which boundaries its imports cross → give the block that owns it its source folder, or point one of the block's functions at the file.",
386
+ se: "Import endpoint (a file that imports or is imported, tests and non-code excluded by the extractor) that resolves to no `MOD` — neither via the `realRef` of an allocated `FUNC` nor via a `MOD.path` prefix. Same resolution as RC-05 and `importCoverage`; one finding per file, anchored at the `SYS`. Stage 12: holds Bau (CR-SM-405).",
387
+ vorschlag: 'Ordne die Dateien {n} einem Modul zu.',
388
+ },
389
+ 'RC-12': {
390
+ plain: "The model says one function hands data to another and waits, but in the code neither calls the other → point the flow at the pair that really calls each other, or note in the flow where the hand-over happens.",
391
+ se: "`FLOW` with `sync: sync` whose producer and consumer `FUNC` both carry a `realRef` symbol in a file of `callScope`, yet `callEdges` holds no path of at most 3 calls between them in either direction (the answer flows from callee to caller). Silent when the `FLOW` carries a `realRef` whose symbol is declared (hand-over by callback, registry or socket, checked by the author). Pairs without binding, outside `callScope`, `async` or without `sync` are not judged; `callCoverage` counts them. Absent `callEdges` is SILENCE (CR-SM-415).",
392
+ vorschlag: 'Prüfe die Flüsse {n} gegen die Aufrufe im Code.',
393
+ },
394
+ 'RC-13': {
395
+ plain: "In the code one function calls another, but the model has no flow between them → add the flow, including the ones for setting up, starting and stopping.",
396
+ se: "Path of at most 3 calls in `callEdges` from one anchored `FUNC` (bound `realRef` symbol, file in `callScope`) to another, with no `FLOW` between the two in either direction, `sync` or `async`. A call site belongs to its innermost anchor (a method with its own `FUNC` does not count for its class); a path ends at the first other anchored `FUNC` — a path through a third one is two flows. One finding per pair, at the caller. The counterpart of RC-12; absent `callEdges` is SILENCE (CR-SM-415).",
397
+ vorschlag: 'Trage die Aufrufe von {n} als Fluss ins Modell ein.',
398
+ },
385
399
  'RD-01': {
386
400
  plain: "A smallest-piece feature has nothing built to fulfil it → add what implements it.",
387
401
  se: "Leaf `REQ` (no `compose`→`REQ` children) with no `satisfy` from a `FUNC`/`FCHAIN`/`MOD`/`SYS`.",
@@ -421,7 +435,7 @@ export const RULE_HELP = {
421
435
  },
422
436
  'UC-03': {
423
437
  plain: "A scenario says what should be possible but not how it runs → describe the steps as a chain of functions.",
424
- se: "`UC` with no `compose` trace to an `FCHAIN`. No behavioural scenario is declared.",
438
+ se: "Leaf `UC` (no `UC -compose-> UC`) with no `compose` trace to an `FCHAIN`. No behavioural scenario is declared. A chain may consist of EXISTING FUNCs an actor strings together — it costs a node plus compose edges, not code. A parent UC needs no chain of its own (CR-SM-412, formerly FC-02).",
425
439
  prompt: "se:author-uc",
426
440
  vorschlag: 'Beschreibe die Abläufe {n} als Kette von Funktionen.',
427
441
  },
@@ -161,6 +161,7 @@ export declare const ViolationContext: z.ZodObject<{
161
161
  }, z.core.$strip>>;
162
162
  value: z.ZodOptional<z.ZodNumber>;
163
163
  threshold: z.ZodOptional<z.ZodNumber>;
164
+ file: z.ZodOptional<z.ZodString>;
164
165
  }, z.core.$strip>;
165
166
  export type ViolationContext = z.infer<typeof ViolationContext>;
166
167
  export declare const RuleViolation: z.ZodObject<{
@@ -300,6 +301,7 @@ export declare const RuleViolation: z.ZodObject<{
300
301
  }, z.core.$strip>>;
301
302
  value: z.ZodOptional<z.ZodNumber>;
302
303
  threshold: z.ZodOptional<z.ZodNumber>;
304
+ file: z.ZodOptional<z.ZodString>;
303
305
  }, z.core.$strip>>;
304
306
  }, z.core.$strip>;
305
307
  export type RuleViolation = z.infer<typeof RuleViolation>;
package/dist/se/rules.js CHANGED
@@ -96,6 +96,12 @@ export const ViolationContext = z.object({
96
96
  */
97
97
  value: z.number().optional(),
98
98
  threshold: z.number().optional(),
99
+ /**
100
+ * CR-SM-405: die Datei, um die es geht, wenn der Befund an keinem Element haengen kann. RC-11 meldet je
101
+ * Datei ohne Modul einen Befund am SYS; ohne dieses Feld stuende die Datei nur im Meldungstext. RC-11
102
+ * setzte es seit a0c2f55, das Schema kannte es nicht — `tsc` brach ab, die Tests (ohne Typpruefung) nicht.
103
+ */
104
+ file: z.string().optional(),
99
105
  });
100
106
  export const RuleViolation = z.object({
101
107
  rule_id: z.string(),
@@ -1494,7 +1500,11 @@ function fchainMustHaveIntegrationTest(graph, policy) {
1494
1500
  // ---------------------------------------------------------------------------
1495
1501
  function funcMustBeAllocated(graph) {
1496
1502
  const idx = indexOf(graph);
1497
- const funcs = idx.elementsOfType('FUNC');
1503
+ // CR-SM-413: Grundgesamtheit sind die BLAETTER, wie bei R-31. Ein Block gliedert den Funktionsbaum,
1504
+ // ein MOD den Abhaengigkeitsbaum; seine Kinder liegen regelmaessig auf verschiedenen Modulen, also
1505
+ // gibt es fuer ihn kein richtiges Modul. Traegt er trotzdem eins, meldet das R-35.
1506
+ const decomposed = decomposedFuncs(graph);
1507
+ const funcs = idx.elementsOfType('FUNC').filter(fn => !decomposed.has(fn.id));
1498
1508
  const mods = idx.elementsOfType('MOD');
1499
1509
  const modIds = new Set(mods.map(m => m.id));
1500
1510
  return funcs
@@ -1513,6 +1523,27 @@ function funcMustBeAllocated(graph) {
1513
1523
  }));
1514
1524
  }
1515
1525
  // ---------------------------------------------------------------------------
1526
+ // R-35: ein Block (FUNC mit FUNC-Kindern) hat kein Modul (CR-SM-413) — Fehler. Er ueberspannt Module;
1527
+ // eine `allocate`-Kante stellt ihn in die Modulsicht und laesst Modulmetriken ihn neben seinen Blaettern
1528
+ // zaehlen. Eigene Kennung statt eines Beins an FC-03: die Regel braucht MOD, also Stufe 7.
1529
+ // ---------------------------------------------------------------------------
1530
+ function blockMustNotBeAllocated(graph) {
1531
+ const idx = indexOf(graph);
1532
+ const decomposed = decomposedFuncs(graph);
1533
+ return idx.elementsOfType('FUNC')
1534
+ .filter(fn => decomposed.has(fn.id))
1535
+ .map(fn => ({ fn, mods: idx.out(fn.id, 'allocate').map(t => t.target).filter(id => idx.typeOf(id) === 'MOD') }))
1536
+ .filter(({ mods }) => mods.length > 0)
1537
+ .map(({ fn, mods }) => ({
1538
+ rule_id: 'R-35',
1539
+ severity: 'error',
1540
+ element_id: fn.id,
1541
+ message: `${fn.id} composes other FUNCs but is allocated to ${mods.join(', ')} — a block spans modules and has none of its own`,
1542
+ fix_hint: `Delete the allocate trace${mods.length > 1 ? 's' : ''} (${mods.map(m => `- ${fn.id} -allocate-> ${m}`).join('; ')}); its leaf functions keep their modules`,
1543
+ context: { element_type: fn.type, element_name: fn.name },
1544
+ }));
1545
+ }
1546
+ // ---------------------------------------------------------------------------
1516
1547
  // R-23: MOD must have an allocated FUNC (CR-208) — the MOD-side complement of
1517
1548
  // R-22. R-04 only checks the upper bound (>8 FUNCs); nothing checks the lower.
1518
1549
  // An empty module is a legal intermediate state in the model (the view no longer
@@ -1802,6 +1833,7 @@ export const V3_RULES = whenDue([
1802
1833
  { id: 'R-20', name: 'FUNC realRef binding', severity: 'warning', stage: 11, evaluate: funcMustHaveCodeBinding, domain: ['FUNC'] },
1803
1834
  { id: 'R-21', name: 'FUNC↔FUNC handover needs a shared chain covered by member REQs or an integration test', severity: 'warning', stage: 9, evaluate: fchainMustHaveIntegrationTest, domain: ['FCHAIN', 'FUNC'] },
1804
1835
  { id: 'R-22', name: 'FUNC must be allocated to MOD', severity: 'warning', stage: 7, role: 'existence', evaluate: funcMustBeAllocated, domain: ['FUNC'] },
1836
+ { id: 'R-35', name: 'Block is not allocated to a module', severity: 'error', stage: 7, evaluate: blockMustNotBeAllocated, domain: ['FUNC'] },
1805
1837
  { id: 'R-23', name: 'MOD must have allocated FUNC', severity: 'warning', stage: 7, evaluate: modMustHaveAllocatedFunc, domain: ['MOD'] },
1806
1838
  { id: 'R-26', name: 'SCHEMA must have realRef', severity: 'warning', stage: 11, evaluate: schemaMustHaveSchemaRef, domain: ['SCHEMA'] },
1807
1839
  { id: 'R-32', name: 'SCHEMA must have contract TEST', severity: 'warning', stage: 9, role: 'existence', evaluate: schemaMustHaveContractTest, domain: ['SCHEMA'] },
@@ -76,12 +76,19 @@ export function uc02HasActor(graph) {
76
76
  }));
77
77
  }
78
78
  // ---------------------------------------------------------------------------
79
- // UC-03: UC must have compose→FCHAIN (scenario)
79
+ // UC-03: Leaf UC must have compose→FCHAIN (scenario). Die Blatt-Bedingung stammt aus FC-02, das
80
+ // dieselbe Aussage unter zweiter Kennung meldete (CR-SM-412): ein UC mit `compose → UC`-Kindern
81
+ // braucht keine eigene Kette. Heute Vorsorge — `UC -compose-> UC` steht nicht in der Matrix.
80
82
  // ---------------------------------------------------------------------------
81
83
  export function uc03HasScenario(graph) {
82
84
  const idx = indexOf(graph);
83
85
  return idx.elementsOfType('UC')
84
- .filter(uc => !idx.out(uc.id, 'compose').some(t => idx.typeOf(t.target) === 'FCHAIN'))
86
+ .filter(uc => {
87
+ const composed = idx.out(uc.id, 'compose');
88
+ if (composed.some(t => idx.typeOf(t.target) === 'UC'))
89
+ return false;
90
+ return !composed.some(t => idx.typeOf(t.target) === 'FCHAIN');
91
+ })
85
92
  .map(uc => ({
86
93
  rule_id: 'UC-03',
87
94
  severity: 'warning',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigloch/contracts",
3
- "version": "12.6.0",
3
+ "version": "12.7.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",