@sigloch/contracts 11.0.0 → 12.6.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.
- package/dist/se/analysis-freshness-rules.d.ts +0 -27
- package/dist/se/analysis-freshness-rules.js +1 -77
- package/dist/se/chain-metrics.d.ts +142 -0
- package/dist/se/chain-metrics.js +381 -0
- package/dist/se/evaluate-all.d.ts +2 -3
- package/dist/se/evaluate-all.js +1 -3
- package/dist/se/fchain-quality-rules.js +36 -9
- package/dist/se/function-criticality.d.ts +32 -0
- package/dist/se/function-criticality.js +69 -0
- package/dist/se/grammar-snapshot.d.ts +4 -4
- package/dist/se/grammar-snapshot.js +11 -18
- package/dist/se/index.d.ts +3 -1
- package/dist/se/index.js +5 -1
- package/dist/se/metric-rules.d.ts +6 -5
- package/dist/se/metric-rules.js +7 -6
- package/dist/se/module-crossings.d.ts +10 -0
- package/dist/se/module-crossings.js +3 -1
- package/dist/se/ontology.d.ts +18 -7
- package/dist/se/ontology.js +19 -18
- package/dist/se/readiness.d.ts +4 -110
- package/dist/se/readiness.js +4 -171
- package/dist/se/risk-carriers.d.ts +66 -0
- package/dist/se/risk-carriers.js +109 -0
- package/dist/se/rule-due.d.ts +5 -14
- package/dist/se/rule-due.js +7 -18
- package/dist/se/rule-help.d.ts +1 -1
- package/dist/se/rule-help.js +8 -22
- package/dist/se/rules.d.ts +22 -13
- package/dist/se/rules.js +93 -18
- package/dist/se/similarity.js +4 -10
- package/package.json +1 -1
|
@@ -66,33 +66,6 @@ export declare const AF_RULES: readonly [{
|
|
|
66
66
|
readonly evaluate: typeof buildPlanDue;
|
|
67
67
|
readonly domain: readonly ["graph"];
|
|
68
68
|
}];
|
|
69
|
-
/** TR-01: a stamped trade study names >=1 existing CR, each carrying a relation(label: decides) edge. */
|
|
70
|
-
export declare function tradeDecisionRecorded(graph: OntologyGraph): RuleViolation[];
|
|
71
|
-
/**
|
|
72
|
-
* IR-01 (CR-SM-397): every REQ named by a stamped assumption review exists; an empty list is a
|
|
73
|
-
* legitimate outcome. That the REQ carries a verifying TEST is R-01's finding, not repeated here.
|
|
74
|
-
*/
|
|
75
|
-
export declare function assumptionReviewRequirementsExist(graph: OntologyGraph): RuleViolation[];
|
|
76
|
-
/** CR-SM-355: the outcome rules of trade / irr — silent until the analysis is stamped. */
|
|
77
|
-
export declare const TASK_OUTCOME_RULES: readonly [{
|
|
78
|
-
readonly id: "TR-01";
|
|
79
|
-
readonly name: "Trade decision recorded as CR";
|
|
80
|
-
readonly severity: "warning";
|
|
81
|
-
readonly stage: 7;
|
|
82
|
-
readonly role: "analysis";
|
|
83
|
-
readonly evaluate: typeof tradeDecisionRecorded;
|
|
84
|
-
readonly domain: readonly ["graph"];
|
|
85
|
-
}, {
|
|
86
|
-
readonly id: "IR-01";
|
|
87
|
-
readonly name: "Assumption review requirements exist";
|
|
88
|
-
readonly severity: "warning";
|
|
89
|
-
readonly stage: 7;
|
|
90
|
-
readonly role: "analysis";
|
|
91
|
-
readonly evaluate: typeof assumptionReviewRequirementsExist;
|
|
92
|
-
readonly domain: readonly ["graph"];
|
|
93
|
-
}];
|
|
94
|
-
/** Evaluate the task-outcome rules (CR-SM-355). */
|
|
95
|
-
export declare function evaluateTaskOutcomeRules(graph: OntologyGraph): RuleViolation[];
|
|
96
69
|
/** Evaluate all analysis-freshness-presence rules. */
|
|
97
70
|
export declare function evaluateAFRules(graph: OntologyGraph): RuleViolation[];
|
|
98
71
|
export {};
|
|
@@ -30,7 +30,7 @@ const ANALYSIS_WORK = {
|
|
|
30
30
|
},
|
|
31
31
|
trade: {
|
|
32
32
|
skill: 'se-trade',
|
|
33
|
-
firstStep: 'name the open decision with its options and criteria, then
|
|
33
|
+
firstStep: 'name the open decision with its options and criteria, then apply the chosen option to the model and record the decision as a done CR with relation edges to what was decided',
|
|
34
34
|
},
|
|
35
35
|
'assumption-review': {
|
|
36
36
|
skill: 'se-irr',
|
|
@@ -108,82 +108,6 @@ export const AF_RULES = [
|
|
|
108
108
|
{ id: 'AF-04', name: 'FMEA freshness stamp present', severity: 'warning', stage: 8, role: 'analysis', evaluate: fmeaFreshnessPresent, domain: ['graph'] },
|
|
109
109
|
{ id: 'AF-05', name: 'Unbuilt elements have an open CR', severity: 'warning', stage: 10, role: 'existence', evaluate: buildPlanDue, domain: ['graph'] },
|
|
110
110
|
];
|
|
111
|
-
/**
|
|
112
|
-
* Task-Ausgangsregeln fuer trade und irr (CR-SM-355, CR-SM-397): was der Task hinterlassen hat, ist
|
|
113
|
-
* im Frischestempel genannt und existiert. Ein Variantenvergleich hinterlaesst Entscheidungs-CRs
|
|
114
|
-
* (`crRefs`, TR-01), ein Annahmen-Review Anforderungen (`reqRefs`, IR-01) — eine Analyse legt keinen
|
|
115
|
-
* Bauauftrag an. Ohne Stempel feuern die Regeln nicht (dann feuert der Eintritt AF-02/AF-03).
|
|
116
|
-
* `label` wird als `Trace.label` gelesen wie bei MS-02 — `decides` ist kein TraceType, sondern das
|
|
117
|
-
* SP-1-Label einer relation-Kante.
|
|
118
|
-
*/
|
|
119
|
-
function stampedOutcome(graph, artifactId) {
|
|
120
|
-
const sys = graph.elements.find(e => e.type === 'SYS');
|
|
121
|
-
if (!sys)
|
|
122
|
-
return null;
|
|
123
|
-
const stamp = readAnalysisStamp(graph, artifactId);
|
|
124
|
-
if (stamp.state !== 'bound')
|
|
125
|
-
return null;
|
|
126
|
-
return { sys, stamp: stamp.value };
|
|
127
|
-
}
|
|
128
|
-
/** TR-01: a stamped trade study names >=1 existing CR, each carrying a relation(label: decides) edge. */
|
|
129
|
-
export function tradeDecisionRecorded(graph) {
|
|
130
|
-
const stamped = stampedOutcome(graph, 'trade');
|
|
131
|
-
if (!stamped)
|
|
132
|
-
return [];
|
|
133
|
-
const { sys } = stamped;
|
|
134
|
-
const crRefs = stamped.stamp.crRefs ?? [];
|
|
135
|
-
const base = { rule_id: 'TR-01', severity: 'warning', context: { element_type: sys.type, element_name: sys.name } };
|
|
136
|
-
if (crRefs.length === 0) {
|
|
137
|
-
return [{
|
|
138
|
-
...base,
|
|
139
|
-
element_id: sys.id,
|
|
140
|
-
message: 'Trade Study is stamped but names no decision CR (analysisFreshness.trade.crRefs is empty) — a trade without a recorded decision is a list, not a trade',
|
|
141
|
-
fix_hint: 'Record the decision as a CR with relation(label: decides) edges and list its id in analysisFreshness.trade.crRefs (se-trade)',
|
|
142
|
-
}];
|
|
143
|
-
}
|
|
144
|
-
const byId = new Map(graph.elements.map(e => [e.id, e]));
|
|
145
|
-
const decidesFrom = new Set(graph.traces.filter(t => t.type === 'relation' && t.label === 'decides').map(t => t.source));
|
|
146
|
-
return crRefs.flatMap(id => {
|
|
147
|
-
const cr = byId.get(id);
|
|
148
|
-
if (!cr || cr.type !== 'CR') {
|
|
149
|
-
return [{ ...base, element_id: sys.id, message: `Trade Study names ${id} as its decision, but no CR with that id exists`, fix_hint: 'Point analysisFreshness.trade.crRefs at an existing CR, or add the CR through graph_mutate (se-trade)' }];
|
|
150
|
-
}
|
|
151
|
-
if (!decidesFrom.has(id)) {
|
|
152
|
-
return [{ ...base, element_id: id, message: `${id} is named as a trade decision but carries no relation(label: decides) edge`, fix_hint: 'Add a relation edge from the CR to the element it decides, with label "decides" (se-trade)' }];
|
|
153
|
-
}
|
|
154
|
-
return [];
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* IR-01 (CR-SM-397): every REQ named by a stamped assumption review exists; an empty list is a
|
|
159
|
-
* legitimate outcome. That the REQ carries a verifying TEST is R-01's finding, not repeated here.
|
|
160
|
-
*/
|
|
161
|
-
export function assumptionReviewRequirementsExist(graph) {
|
|
162
|
-
const stamped = stampedOutcome(graph, 'assumption-review');
|
|
163
|
-
if (!stamped)
|
|
164
|
-
return [];
|
|
165
|
-
const { sys } = stamped;
|
|
166
|
-
const byId = new Map(graph.elements.map(e => [e.id, e]));
|
|
167
|
-
return (stamped.stamp.reqRefs ?? [])
|
|
168
|
-
.filter(id => byId.get(id)?.type !== 'REQ')
|
|
169
|
-
.map(id => ({
|
|
170
|
-
rule_id: 'IR-01',
|
|
171
|
-
severity: 'warning',
|
|
172
|
-
element_id: sys.id,
|
|
173
|
-
message: `Assumption Review names ${id} as the requirement of a load-bearing assumption, but no REQ with that id exists`,
|
|
174
|
-
fix_hint: 'Point analysisFreshness.assumption-review.reqRefs at an existing REQ, or add the REQ with its verifying TEST through graph_mutate (se-irr)',
|
|
175
|
-
context: { element_type: sys.type, element_name: sys.name },
|
|
176
|
-
}));
|
|
177
|
-
}
|
|
178
|
-
/** CR-SM-355: the outcome rules of trade / irr — silent until the analysis is stamped. */
|
|
179
|
-
export const TASK_OUTCOME_RULES = [
|
|
180
|
-
{ id: 'TR-01', name: 'Trade decision recorded as CR', severity: 'warning', stage: 7, role: 'analysis', evaluate: tradeDecisionRecorded, domain: ['graph'] },
|
|
181
|
-
{ id: 'IR-01', name: 'Assumption review requirements exist', severity: 'warning', stage: 7, role: 'analysis', evaluate: assumptionReviewRequirementsExist, domain: ['graph'] },
|
|
182
|
-
];
|
|
183
|
-
/** Evaluate the task-outcome rules (CR-SM-355). */
|
|
184
|
-
export function evaluateTaskOutcomeRules(graph) {
|
|
185
|
-
return TASK_OUTCOME_RULES.flatMap(r => r.evaluate(graph));
|
|
186
|
-
}
|
|
187
111
|
/** Evaluate all analysis-freshness-presence rules. */
|
|
188
112
|
export function evaluateAFRules(graph) {
|
|
189
113
|
return AF_RULES.flatMap(r => r.evaluate(graph));
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CR-SM-404 — Kennzahlen der Wirkkette: je FCHAIN eine Zahl, oder der Grund, warum es keine gibt.
|
|
3
|
+
*
|
|
4
|
+
* Die Leitlinie verlangt, die Realisierungsarchitektur AUF DER WIRKKETTE zu bewerten (graphcode
|
|
5
|
+
* `docs/graphcode_architektur_konzept.md`, „Kennzahlen der Wirkkette"). Bis hierher rechnete das
|
|
6
|
+
* nur ein Spike in graphcode (`scripts/spike-kettenkennzahlen.mjs`); von dort ist die Rechnung
|
|
7
|
+
* portiert, nicht neu erfunden. Gemessen 2026-10-09 ueber 10 Familie-Graphen: 76 Ketten, 31
|
|
8
|
+
* bewertbar.
|
|
9
|
+
*
|
|
10
|
+
* ## Diese Datei URTEILT NICHT
|
|
11
|
+
*
|
|
12
|
+
* Keine Regel, keine Schwelle, kein Katalogeintrag — dieselbe Trennung wie `moduleMetrics` und
|
|
13
|
+
* `functionCriticality`. Ob eine Laenge von 6 gut ist, sagt erst ein Profil.
|
|
14
|
+
*
|
|
15
|
+
* ## Nicht bewertbar heisst: KEINE Zahl
|
|
16
|
+
*
|
|
17
|
+
* Eine FCHAIN ist grammatisch eine Menge; die Reihenfolge entsteht erst aus Erzeuger ->
|
|
18
|
+
* Verbraucher (`FUNC -io-> FLOW -io-> FUNC`, beide Enden Glied). Zerfaellt die Kette, beschriebe
|
|
19
|
+
* jede Kennzahl etwas, das es nicht gibt. Eine solche Kette traegt deshalb ihre Gruende und kein
|
|
20
|
+
* einziges Zahlenfeld — das Schema laesst es nicht zu. Sie zaehlt im NENNER der Quote
|
|
21
|
+
* (`measurability`), die neben jedem Wert stehen muss wie die Bindungsquote neben RC-*.
|
|
22
|
+
*
|
|
23
|
+
* ## Wer urteilt, ob eine Kette eine Kette ist
|
|
24
|
+
*
|
|
25
|
+
* - `FC-05`: die Regel FC-05, aufgerufen, nicht nachgebaut. Ursache (fehlendes Glied, Sack) und
|
|
26
|
+
* die Nebenkomponenten stehen in ihrem Befund (`context.side_components`), nicht hier.
|
|
27
|
+
* - `loose-member`: ein Glied ohne io-Eingang oder -Ausgang. Das ist die Bedingung, unter der
|
|
28
|
+
* FC-05 sich ENTHAELT (R-31 meldet das Glied) — ohne diesen Grund haette eine solche Kette weder
|
|
29
|
+
* einen FC-05-Befund noch einen Grund und bekaeme Zahlen.
|
|
30
|
+
* CR-SM-409: gerechnet von `unwiredFuncs` (`rules.ts`), derselben Rechnung, die R-31 und die
|
|
31
|
+
* Enthaltung von FC-05 lesen — hier ueber die GLIEDER, auch ein Block als Glied zaehlt.
|
|
32
|
+
* - `no-entry` / `no-exit`: kein FLOW von bzw. zu einem Knoten AUSSERHALB der Kette. Weiter als
|
|
33
|
+
* FC-04, das nur einen ACTOR gelten laesst: eine Kette, die eine andere fortsetzt, ist messbar.
|
|
34
|
+
* - `empty`: keine FUNC (R-15).
|
|
35
|
+
*
|
|
36
|
+
* ## Ein Kettenbegriff, ein Modulbegriff
|
|
37
|
+
*
|
|
38
|
+
* Glied = direkte `FCHAIN -compose-> FUNC`-Kante, ueber `chainsByFunc` (R-30s Definition).
|
|
39
|
+
* Modul einer FUNC = direkte `allocate`-Kante, wie `module-crossings.ts` und `moduleMetrics`.
|
|
40
|
+
* Der Spike erbte das Modul ueber compose-Vorfahren; gemessen sind 326 von 326 Kettengliedern
|
|
41
|
+
* des Korpus direkt alloziert — die Vererbung kauft nichts und waere eine zweite Vorstellung von
|
|
42
|
+
* Zugehoerigkeit im selben Paket.
|
|
43
|
+
*
|
|
44
|
+
* ## CR-SM-406 — die ORTE je Kette, nur erkannt
|
|
45
|
+
*
|
|
46
|
+
* Neben jeder Zahl steht, WO sie herkommt: die Mitglieder je Rueckkopplung, die geteilten
|
|
47
|
+
* Funktionen, die Grenzen je gerichtetem Modulpaar mit ihren Vertraegen, dazu Zulauf, Importe und
|
|
48
|
+
* Uebergaben. Reine Zusatzfelder — die Zahlen aus CR-SM-404 bleiben und sind die Laenge ihrer
|
|
49
|
+
* Liste. Weiter kein Urteil.
|
|
50
|
+
*
|
|
51
|
+
* - Import und Uebergabe zaehlen nur an Gliedern, die ALLEIN dieser Kette gehoeren. Was an einer
|
|
52
|
+
* geteilten Funktion haengt, steht an der geteilten Funktion — sie ist ein eigener Ort. Ohne
|
|
53
|
+
* diese Grenze meldete jede Kette durch Gate und Store deren Zufluesse als ihre eigenen
|
|
54
|
+
* (gemessen am graphcode-Modell 2026-10-10: 333 statt 16).
|
|
55
|
+
* - Ein ACTOR als Erzeuger oder Verbraucher ist der Ein- und Ausgang der Kette, kein Ort.
|
|
56
|
+
* - Vertrag = `contractsOfFlow` aus `module-crossings.ts` (SCHEMA, sonst `UNBOUND:<flow>`), hier je
|
|
57
|
+
* Kettenkante gelesen. `moduleCrossings().pairs` selbst traegt die Vertraege des GANZEN Graphen
|
|
58
|
+
* je ungerichtetem Paar und kann „elf Kanten auf einem Vertrag" in EINER Kette nicht zeigen.
|
|
59
|
+
*
|
|
60
|
+
* ## CR-SM-408 — der ANTWORTWEG je Kette
|
|
61
|
+
*
|
|
62
|
+
* Die Glieder, auf die die Antwort an einen Akteur wartet: vom ACTOR rueckwaerts ueber die Fluesse,
|
|
63
|
+
* die `sync` tragen (`readFlowSync`; Sicht des Abnehmers, Deklaration in `ontology.ts`). Ein Fluss
|
|
64
|
+
* mit `async` ist vorab geliefert, an ihm endet der Weg. Portiert aus der Probe (graphanalyze
|
|
65
|
+
* `docs/messung/flaechen-2026-10-11/laufzeit_sync.py`), mit zwei Festlegungen des Autors, die die
|
|
66
|
+
* Probe nicht kannte:
|
|
67
|
+
*
|
|
68
|
+
* - Geraten wird nicht. Die Probe las „nicht als asynchron gelistet" als synchron; hier ist ein Fluss
|
|
69
|
+
* ohne lesbares Merkmal ein Hindernis: `answerPath` ist `null`, der Fluss steht in
|
|
70
|
+
* `answerPathBlockedBy`.
|
|
71
|
+
* - Der Weg verlaesst seine Kette nicht. Wartet ein Glied synchron auf eine FUNC, die kein Glied
|
|
72
|
+
* ist, ist das ebenso ein Hindernis. Die Kette zu schliessen ist Arbeit am Modell.
|
|
73
|
+
*
|
|
74
|
+
* Gelesen wird je Paar (Fluss, erzeugende FUNC), und zwar an jedem Abnehmer gleich: der ACTOR
|
|
75
|
+
* wartet auf das Glied, das ihm einen Fluss mit `sync` liefert (das ist die Antwort; ein Fluss mit
|
|
76
|
+
* `async` an einen ACTOR ist keine), ein Glied auf die Erzeuger seiner Eingaenge mit `sync`. Ein
|
|
77
|
+
* Fluss, den nur ein ACTOR erzeugt, ist der Eingang der Kette und fuehrt zu keinem Glied. Wer
|
|
78
|
+
* liefert — eine Funktion, die rechnet, oder eine, die nur haelt — unterscheidet die Rechnung
|
|
79
|
+
* nicht. Eine Kette ohne Antwort an einen Akteur hat den leeren Weg `[]`: niemand wartet, nichts
|
|
80
|
+
* hindert.
|
|
81
|
+
*
|
|
82
|
+
* @author andreas@siglochconsulting
|
|
83
|
+
*/
|
|
84
|
+
import { z } from 'zod/v4';
|
|
85
|
+
import { type OntologyGraph } from './ontology.js';
|
|
86
|
+
export declare const ChainMetrics: z.ZodObject<{
|
|
87
|
+
chains: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
88
|
+
measurable: z.ZodLiteral<true>;
|
|
89
|
+
length: z.ZodNumber;
|
|
90
|
+
branching: z.ZodNumber;
|
|
91
|
+
moduleBoundaries: z.ZodNullable<z.ZodNumber>;
|
|
92
|
+
feedbackLoops: z.ZodNumber;
|
|
93
|
+
sharedFuncs: z.ZodNumber;
|
|
94
|
+
bottlenecks: z.ZodNumber;
|
|
95
|
+
syncDepth: z.ZodNull;
|
|
96
|
+
errorPathDepth: z.ZodNull;
|
|
97
|
+
memberCount: z.ZodNumber;
|
|
98
|
+
fanIn: z.ZodNumber;
|
|
99
|
+
loops: z.ZodArray<z.ZodObject<{
|
|
100
|
+
id: z.ZodString;
|
|
101
|
+
members: z.ZodArray<z.ZodString>;
|
|
102
|
+
}, z.core.$strict>>;
|
|
103
|
+
shared: z.ZodArray<z.ZodString>;
|
|
104
|
+
boundaries: z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
105
|
+
from: z.ZodString;
|
|
106
|
+
to: z.ZodString;
|
|
107
|
+
edges: z.ZodNumber;
|
|
108
|
+
contracts: z.ZodArray<z.ZodString>;
|
|
109
|
+
}, z.core.$strict>>>;
|
|
110
|
+
imports: z.ZodArray<z.ZodObject<{
|
|
111
|
+
flow: z.ZodString;
|
|
112
|
+
func: z.ZodString;
|
|
113
|
+
}, z.core.$strict>>;
|
|
114
|
+
handovers: z.ZodArray<z.ZodObject<{
|
|
115
|
+
flow: z.ZodString;
|
|
116
|
+
func: z.ZodString;
|
|
117
|
+
}, z.core.$strict>>;
|
|
118
|
+
answerPath: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
119
|
+
answerPathBlockedBy: z.ZodArray<z.ZodString>;
|
|
120
|
+
chainId: z.ZodString;
|
|
121
|
+
chainName: z.ZodString;
|
|
122
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
123
|
+
measurable: z.ZodLiteral<false>;
|
|
124
|
+
reasons: z.ZodArray<z.ZodEnum<{
|
|
125
|
+
"FC-05": "FC-05";
|
|
126
|
+
"loose-member": "loose-member";
|
|
127
|
+
"no-entry": "no-entry";
|
|
128
|
+
"no-exit": "no-exit";
|
|
129
|
+
empty: "empty";
|
|
130
|
+
}>>;
|
|
131
|
+
chainId: z.ZodString;
|
|
132
|
+
chainName: z.ZodString;
|
|
133
|
+
}, z.core.$strict>], "measurable">>;
|
|
134
|
+
measurability: z.ZodObject<{
|
|
135
|
+
chains: z.ZodNumber;
|
|
136
|
+
measurable: z.ZodNumber;
|
|
137
|
+
ratio: z.ZodNullable<z.ZodNumber>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
}, z.core.$strip>;
|
|
140
|
+
export type ChainMetrics = z.infer<typeof ChainMetrics>;
|
|
141
|
+
/** Die Kennzahlen aller FCHAINs dieses Graphen und die Quote der bewertbaren. */
|
|
142
|
+
export declare function chainMetrics(graph: OntologyGraph): ChainMetrics;
|
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CR-SM-404 — Kennzahlen der Wirkkette: je FCHAIN eine Zahl, oder der Grund, warum es keine gibt.
|
|
3
|
+
*
|
|
4
|
+
* Die Leitlinie verlangt, die Realisierungsarchitektur AUF DER WIRKKETTE zu bewerten (graphcode
|
|
5
|
+
* `docs/graphcode_architektur_konzept.md`, „Kennzahlen der Wirkkette"). Bis hierher rechnete das
|
|
6
|
+
* nur ein Spike in graphcode (`scripts/spike-kettenkennzahlen.mjs`); von dort ist die Rechnung
|
|
7
|
+
* portiert, nicht neu erfunden. Gemessen 2026-10-09 ueber 10 Familie-Graphen: 76 Ketten, 31
|
|
8
|
+
* bewertbar.
|
|
9
|
+
*
|
|
10
|
+
* ## Diese Datei URTEILT NICHT
|
|
11
|
+
*
|
|
12
|
+
* Keine Regel, keine Schwelle, kein Katalogeintrag — dieselbe Trennung wie `moduleMetrics` und
|
|
13
|
+
* `functionCriticality`. Ob eine Laenge von 6 gut ist, sagt erst ein Profil.
|
|
14
|
+
*
|
|
15
|
+
* ## Nicht bewertbar heisst: KEINE Zahl
|
|
16
|
+
*
|
|
17
|
+
* Eine FCHAIN ist grammatisch eine Menge; die Reihenfolge entsteht erst aus Erzeuger ->
|
|
18
|
+
* Verbraucher (`FUNC -io-> FLOW -io-> FUNC`, beide Enden Glied). Zerfaellt die Kette, beschriebe
|
|
19
|
+
* jede Kennzahl etwas, das es nicht gibt. Eine solche Kette traegt deshalb ihre Gruende und kein
|
|
20
|
+
* einziges Zahlenfeld — das Schema laesst es nicht zu. Sie zaehlt im NENNER der Quote
|
|
21
|
+
* (`measurability`), die neben jedem Wert stehen muss wie die Bindungsquote neben RC-*.
|
|
22
|
+
*
|
|
23
|
+
* ## Wer urteilt, ob eine Kette eine Kette ist
|
|
24
|
+
*
|
|
25
|
+
* - `FC-05`: die Regel FC-05, aufgerufen, nicht nachgebaut. Ursache (fehlendes Glied, Sack) und
|
|
26
|
+
* die Nebenkomponenten stehen in ihrem Befund (`context.side_components`), nicht hier.
|
|
27
|
+
* - `loose-member`: ein Glied ohne io-Eingang oder -Ausgang. Das ist die Bedingung, unter der
|
|
28
|
+
* FC-05 sich ENTHAELT (R-31 meldet das Glied) — ohne diesen Grund haette eine solche Kette weder
|
|
29
|
+
* einen FC-05-Befund noch einen Grund und bekaeme Zahlen.
|
|
30
|
+
* CR-SM-409: gerechnet von `unwiredFuncs` (`rules.ts`), derselben Rechnung, die R-31 und die
|
|
31
|
+
* Enthaltung von FC-05 lesen — hier ueber die GLIEDER, auch ein Block als Glied zaehlt.
|
|
32
|
+
* - `no-entry` / `no-exit`: kein FLOW von bzw. zu einem Knoten AUSSERHALB der Kette. Weiter als
|
|
33
|
+
* FC-04, das nur einen ACTOR gelten laesst: eine Kette, die eine andere fortsetzt, ist messbar.
|
|
34
|
+
* - `empty`: keine FUNC (R-15).
|
|
35
|
+
*
|
|
36
|
+
* ## Ein Kettenbegriff, ein Modulbegriff
|
|
37
|
+
*
|
|
38
|
+
* Glied = direkte `FCHAIN -compose-> FUNC`-Kante, ueber `chainsByFunc` (R-30s Definition).
|
|
39
|
+
* Modul einer FUNC = direkte `allocate`-Kante, wie `module-crossings.ts` und `moduleMetrics`.
|
|
40
|
+
* Der Spike erbte das Modul ueber compose-Vorfahren; gemessen sind 326 von 326 Kettengliedern
|
|
41
|
+
* des Korpus direkt alloziert — die Vererbung kauft nichts und waere eine zweite Vorstellung von
|
|
42
|
+
* Zugehoerigkeit im selben Paket.
|
|
43
|
+
*
|
|
44
|
+
* ## CR-SM-406 — die ORTE je Kette, nur erkannt
|
|
45
|
+
*
|
|
46
|
+
* Neben jeder Zahl steht, WO sie herkommt: die Mitglieder je Rueckkopplung, die geteilten
|
|
47
|
+
* Funktionen, die Grenzen je gerichtetem Modulpaar mit ihren Vertraegen, dazu Zulauf, Importe und
|
|
48
|
+
* Uebergaben. Reine Zusatzfelder — die Zahlen aus CR-SM-404 bleiben und sind die Laenge ihrer
|
|
49
|
+
* Liste. Weiter kein Urteil.
|
|
50
|
+
*
|
|
51
|
+
* - Import und Uebergabe zaehlen nur an Gliedern, die ALLEIN dieser Kette gehoeren. Was an einer
|
|
52
|
+
* geteilten Funktion haengt, steht an der geteilten Funktion — sie ist ein eigener Ort. Ohne
|
|
53
|
+
* diese Grenze meldete jede Kette durch Gate und Store deren Zufluesse als ihre eigenen
|
|
54
|
+
* (gemessen am graphcode-Modell 2026-10-10: 333 statt 16).
|
|
55
|
+
* - Ein ACTOR als Erzeuger oder Verbraucher ist der Ein- und Ausgang der Kette, kein Ort.
|
|
56
|
+
* - Vertrag = `contractsOfFlow` aus `module-crossings.ts` (SCHEMA, sonst `UNBOUND:<flow>`), hier je
|
|
57
|
+
* Kettenkante gelesen. `moduleCrossings().pairs` selbst traegt die Vertraege des GANZEN Graphen
|
|
58
|
+
* je ungerichtetem Paar und kann „elf Kanten auf einem Vertrag" in EINER Kette nicht zeigen.
|
|
59
|
+
*
|
|
60
|
+
* ## CR-SM-408 — der ANTWORTWEG je Kette
|
|
61
|
+
*
|
|
62
|
+
* Die Glieder, auf die die Antwort an einen Akteur wartet: vom ACTOR rueckwaerts ueber die Fluesse,
|
|
63
|
+
* die `sync` tragen (`readFlowSync`; Sicht des Abnehmers, Deklaration in `ontology.ts`). Ein Fluss
|
|
64
|
+
* mit `async` ist vorab geliefert, an ihm endet der Weg. Portiert aus der Probe (graphanalyze
|
|
65
|
+
* `docs/messung/flaechen-2026-10-11/laufzeit_sync.py`), mit zwei Festlegungen des Autors, die die
|
|
66
|
+
* Probe nicht kannte:
|
|
67
|
+
*
|
|
68
|
+
* - Geraten wird nicht. Die Probe las „nicht als asynchron gelistet" als synchron; hier ist ein Fluss
|
|
69
|
+
* ohne lesbares Merkmal ein Hindernis: `answerPath` ist `null`, der Fluss steht in
|
|
70
|
+
* `answerPathBlockedBy`.
|
|
71
|
+
* - Der Weg verlaesst seine Kette nicht. Wartet ein Glied synchron auf eine FUNC, die kein Glied
|
|
72
|
+
* ist, ist das ebenso ein Hindernis. Die Kette zu schliessen ist Arbeit am Modell.
|
|
73
|
+
*
|
|
74
|
+
* Gelesen wird je Paar (Fluss, erzeugende FUNC), und zwar an jedem Abnehmer gleich: der ACTOR
|
|
75
|
+
* wartet auf das Glied, das ihm einen Fluss mit `sync` liefert (das ist die Antwort; ein Fluss mit
|
|
76
|
+
* `async` an einen ACTOR ist keine), ein Glied auf die Erzeuger seiner Eingaenge mit `sync`. Ein
|
|
77
|
+
* Fluss, den nur ein ACTOR erzeugt, ist der Eingang der Kette und fuehrt zu keinem Glied. Wer
|
|
78
|
+
* liefert — eine Funktion, die rechnet, oder eine, die nur haelt — unterscheidet die Rechnung
|
|
79
|
+
* nicht. Eine Kette ohne Antwort an einen Akteur hat den leeren Weg `[]`: niemand wartet, nichts
|
|
80
|
+
* hindert.
|
|
81
|
+
*
|
|
82
|
+
* @author andreas@siglochconsulting
|
|
83
|
+
*/
|
|
84
|
+
import { z } from 'zod/v4';
|
|
85
|
+
import { readFlowSync } from './ontology.js';
|
|
86
|
+
import { indexOf } from './graph-index.js';
|
|
87
|
+
import { chainsByFunc } from './function-criticality.js';
|
|
88
|
+
import { fc05ChainConnected } from './fchain-quality-rules.js';
|
|
89
|
+
import { unwiredFuncs } from './rules.js';
|
|
90
|
+
import { contractsOfFlow } from './module-crossings.js';
|
|
91
|
+
const count = z.number().int().nonnegative();
|
|
92
|
+
const identity = { chainId: z.string(), chainName: z.string() };
|
|
93
|
+
/** CR-SM-406: ein Fluss an der Kettengrenze und das Glied der Kette, an dem er haengt. */
|
|
94
|
+
const FlowAtFunc = z.strictObject({ flow: z.string(), func: z.string() });
|
|
95
|
+
/**
|
|
96
|
+
* Eine bewertbare Kette: die fuenf heute rechenbaren Kennzahlen plus die Engstellen-Schranke,
|
|
97
|
+
* dazu die Orte (CR-SM-406). Jede Liste ist uid-sortiert.
|
|
98
|
+
*/
|
|
99
|
+
const MeasuredChain = z.strictObject({
|
|
100
|
+
...identity,
|
|
101
|
+
measurable: z.literal(true),
|
|
102
|
+
/** Gesamtlaenge: FUNC-Schritte auf dem laengsten Pfad; eine Schleife zaehlt als EIN Schritt. */
|
|
103
|
+
length: count,
|
|
104
|
+
/** Verzweigungsgrad: groesster Ausgangsgrad eines Glieds INNERHALB der Kette. */
|
|
105
|
+
branching: count,
|
|
106
|
+
/**
|
|
107
|
+
* Modulgrenzen: Kettenkanten, deren Enden in verschiedenen MOD liegen.
|
|
108
|
+
* `null`, sobald ein Glied kein Modul hat (R-22 meldet es) — keine geratene Zahl.
|
|
109
|
+
*/
|
|
110
|
+
moduleBoundaries: count.nullable(),
|
|
111
|
+
/** Rueckkopplungen: nicht-triviale starke Komponenten ueber die Kettenkanten. */
|
|
112
|
+
feedbackLoops: count,
|
|
113
|
+
/** Geteilte Knoten: Glieder, die in mehr als einer Kette liegen. */
|
|
114
|
+
sharedFuncs: count,
|
|
115
|
+
/**
|
|
116
|
+
* Engstellen — OBERE SCHRANKE: geteilte Glieder mit Ein- UND Ausgang in der Kette. Der
|
|
117
|
+
* Konzeptbegriff verlangt „synchron durchlaufen"; ohne `FLOW.sync` zaehlt jeder Durchgang.
|
|
118
|
+
*/
|
|
119
|
+
bottlenecks: count,
|
|
120
|
+
/**
|
|
121
|
+
* Synchrone Tiefe — nie berechnet und Streichkandidat fuer den naechsten Major (CR-SM-408): der
|
|
122
|
+
* Antwortweg ist eine Menge, keine Tiefe; die Tiefe der Probe hing an der Reihenfolge der Kanten.
|
|
123
|
+
*/
|
|
124
|
+
syncDepth: z.null(),
|
|
125
|
+
/** Fehlerpfad-Tiefe — nicht berechenbar: Fehlerfluesse traegt kein Attribut (CR-SM-364, `kind` verworfen). */
|
|
126
|
+
errorPathDepth: z.null(),
|
|
127
|
+
/** Zahl der Glieder. */
|
|
128
|
+
memberCount: count,
|
|
129
|
+
/** Zulauf: groesster Eingangsgrad eines Glieds INNERHALB der Kette — das Gegenstueck zu `branching`. */
|
|
130
|
+
fanIn: count,
|
|
131
|
+
/**
|
|
132
|
+
* Die Rueckkopplungen, die `feedbackLoops` zaehlt. `id` entsteht allein aus den Mitgliedern
|
|
133
|
+
* (uids mit `+` verbunden) — dieselbe Schleife traegt in jeder Kette dieselbe Kennung.
|
|
134
|
+
*/
|
|
135
|
+
loops: z.array(z.strictObject({ id: z.string(), members: z.array(z.string()).min(2) })),
|
|
136
|
+
/** Die geteilten Glieder, die `sharedFuncs` zaehlt. */
|
|
137
|
+
shared: z.array(z.string()),
|
|
138
|
+
/**
|
|
139
|
+
* Die Modulgrenzen je GERICHTETEM Modulpaar: `edges` Kettenkanten von `from` nach `to` (ihre
|
|
140
|
+
* Summe ist `moduleBoundaries`) auf den verschiedenen Vertraegen `contracts`. `null` wie dort.
|
|
141
|
+
*/
|
|
142
|
+
boundaries: z.array(z.strictObject({
|
|
143
|
+
from: z.string(), to: z.string(), edges: count.min(1), contracts: z.array(z.string()).min(1),
|
|
144
|
+
})).nullable(),
|
|
145
|
+
/**
|
|
146
|
+
* Importe: ein Glied, das NUR in dieser Kette liegt, verbraucht einen Fluss, den mindestens
|
|
147
|
+
* eine FUNC erzeugt und kein Glied der Kette.
|
|
148
|
+
*/
|
|
149
|
+
imports: z.array(FlowAtFunc),
|
|
150
|
+
/**
|
|
151
|
+
* Uebergaben, gespiegelt: ein Glied, das nur in dieser Kette liegt, erzeugt einen Fluss, den
|
|
152
|
+
* mindestens eine FUNC verbraucht und kein Glied der Kette.
|
|
153
|
+
*/
|
|
154
|
+
handovers: z.array(FlowAtFunc),
|
|
155
|
+
/**
|
|
156
|
+
* CR-SM-408 — der Antwortweg: die Glieder, auf die die Antwort an einen ACTOR wartet (die Glieder,
|
|
157
|
+
* die einem ACTOR einen Fluss mit `sync` liefern, und rueckwaerts ueber Fluesse mit `sync` ihre
|
|
158
|
+
* Lieferanten in der Kette). `[]`, wenn kein Glied einem ACTOR einen Fluss mit `sync` liefert.
|
|
159
|
+
* `null`, sobald `answerPathBlockedBy` etwas nennt — keine geratene Menge.
|
|
160
|
+
*/
|
|
161
|
+
answerPath: z.array(z.string()).nullable(),
|
|
162
|
+
/**
|
|
163
|
+
* Die Fluesse, die die Aussage verhindern: ein Fluss von einem Glied an einen ACTOR oder von
|
|
164
|
+
* einer FUNC in ein Glied des Wegs, der das Merkmal `sync` nicht lesbar traegt, oder der `sync`
|
|
165
|
+
* traegt und von einer FUNC ausserhalb der Kette kommt. Leer genau dann, wenn `answerPath` nicht
|
|
166
|
+
* `null` ist.
|
|
167
|
+
*/
|
|
168
|
+
answerPathBlockedBy: z.array(z.string()),
|
|
169
|
+
});
|
|
170
|
+
/** Eine nicht bewertbare Kette: der Grund statt der Zahl. Reihenfolge der Gruende ist fest. */
|
|
171
|
+
const UnmeasurableChain = z.strictObject({
|
|
172
|
+
...identity,
|
|
173
|
+
measurable: z.literal(false),
|
|
174
|
+
reasons: z.array(z.enum(['FC-05', 'loose-member', 'no-entry', 'no-exit', 'empty'])).min(1),
|
|
175
|
+
});
|
|
176
|
+
// CR-SM-361: ein Zod-Vertrag, kein Typ — der Erzeuger prueft sein Ergebnis.
|
|
177
|
+
export const ChainMetrics = z.object({
|
|
178
|
+
/** Eine Zeile je FCHAIN, in GRAPH-Reihenfolge — keine Rangfolge, die Zahl ist kein Urteil. */
|
|
179
|
+
chains: z.array(z.discriminatedUnion('measurable', [MeasuredChain, UnmeasurableChain])),
|
|
180
|
+
/** Die Reichweite der Aussage. `ratio` ist `null` ohne Ketten — kein Ersatzwert. */
|
|
181
|
+
measurability: z.object({ chains: count, measurable: count, ratio: z.number().min(0).max(1).nullable() }),
|
|
182
|
+
});
|
|
183
|
+
/** Die Kennzahlen aller FCHAINs dieses Graphen und die Quote der bewertbaren. */
|
|
184
|
+
export function chainMetrics(graph) {
|
|
185
|
+
const idx = indexOf(graph);
|
|
186
|
+
const chainsOf = chainsByFunc(graph);
|
|
187
|
+
// FC-05 ist der EINE Leser fuer „gerichtet zusammenhaengend" — hier zaehlt nur, ob er meldet.
|
|
188
|
+
const fc05 = new Set(fc05ChainConnected(graph).map((v) => v.element_id));
|
|
189
|
+
// CR-SM-409: „ohne io-Eingang oder -Ausgang" rechnet EINE Stelle (R-31s Rechnung); hier zaehlt, ob ein Glied darin liegt.
|
|
190
|
+
const unwired = unwiredFuncs(graph);
|
|
191
|
+
const flowsInto = (id) => idx.in(id, 'io').map((t) => t.source).filter((s) => idx.typeOf(s) === 'FLOW');
|
|
192
|
+
const flowsOutOf = (id) => idx.out(id, 'io').map((t) => t.target).filter((s) => idx.typeOf(s) === 'FLOW');
|
|
193
|
+
const moduleOf = (func) => idx.out(func, 'allocate').map((t) => t.target).find((m) => idx.typeOf(m) === 'MOD');
|
|
194
|
+
const chains = idx.elementsOfType('FCHAIN').map((fc) => {
|
|
195
|
+
const who = { chainId: fc.id, chainName: fc.name };
|
|
196
|
+
const members = [...new Set(idx.out(fc.id, 'compose').map((t) => t.target).filter((id) => idx.typeOf(id) === 'FUNC'))].sort();
|
|
197
|
+
if (members.length === 0)
|
|
198
|
+
return { ...who, measurable: false, reasons: ['empty'] };
|
|
199
|
+
const inChain = new Set(members);
|
|
200
|
+
// Kettenkanten Erzeuger -> Verbraucher; dazu, wo die Kette von aussen gespeist wird und wo sie hinausliefert.
|
|
201
|
+
const next = new Map(members.map((m) => [m, new Set()]));
|
|
202
|
+
const carriers = new Map(); // Kettenkante `a b` -> die FLOWs, die sie tragen
|
|
203
|
+
let entry = false;
|
|
204
|
+
let exit = false;
|
|
205
|
+
for (const m of members) {
|
|
206
|
+
const ins = flowsInto(m);
|
|
207
|
+
const outs = flowsOutOf(m);
|
|
208
|
+
for (const flow of ins)
|
|
209
|
+
if (idx.in(flow, 'io').some((t) => !inChain.has(t.source)))
|
|
210
|
+
entry = true;
|
|
211
|
+
for (const flow of outs) {
|
|
212
|
+
for (const t of idx.out(flow, 'io')) {
|
|
213
|
+
if (t.target === m)
|
|
214
|
+
continue;
|
|
215
|
+
if (!inChain.has(t.target)) {
|
|
216
|
+
exit = true;
|
|
217
|
+
continue;
|
|
218
|
+
}
|
|
219
|
+
next.get(m).add(t.target);
|
|
220
|
+
const edge = `${m} ${t.target}`;
|
|
221
|
+
(carriers.get(edge) ?? carriers.set(edge, new Set()).get(edge)).add(flow);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
const reasons = [];
|
|
226
|
+
if (fc05.has(fc.id))
|
|
227
|
+
reasons.push('FC-05');
|
|
228
|
+
if (members.some((m) => unwired.has(m)))
|
|
229
|
+
reasons.push('loose-member');
|
|
230
|
+
if (!entry)
|
|
231
|
+
reasons.push('no-entry');
|
|
232
|
+
if (!exit)
|
|
233
|
+
reasons.push('no-exit');
|
|
234
|
+
if (reasons.length > 0)
|
|
235
|
+
return { ...who, measurable: false, reasons };
|
|
236
|
+
// Rueckkopplungen: Tarjan — jede starke Komponente mit mehr als einem Glied ist eine Schleife.
|
|
237
|
+
const order = new Map();
|
|
238
|
+
const low = new Map();
|
|
239
|
+
const onStack = new Set();
|
|
240
|
+
const stack = [];
|
|
241
|
+
const sccOf = new Map();
|
|
242
|
+
const loops = [];
|
|
243
|
+
const visit = (v) => {
|
|
244
|
+
order.set(v, order.size);
|
|
245
|
+
low.set(v, order.get(v));
|
|
246
|
+
stack.push(v);
|
|
247
|
+
onStack.add(v);
|
|
248
|
+
for (const w of next.get(v)) {
|
|
249
|
+
if (!order.has(w)) {
|
|
250
|
+
visit(w);
|
|
251
|
+
low.set(v, Math.min(low.get(v), low.get(w)));
|
|
252
|
+
}
|
|
253
|
+
else if (onStack.has(w))
|
|
254
|
+
low.set(v, Math.min(low.get(v), order.get(w)));
|
|
255
|
+
}
|
|
256
|
+
if (low.get(v) !== order.get(v))
|
|
257
|
+
return;
|
|
258
|
+
const comp = [];
|
|
259
|
+
let w;
|
|
260
|
+
do {
|
|
261
|
+
w = stack.pop();
|
|
262
|
+
onStack.delete(w);
|
|
263
|
+
comp.push(w);
|
|
264
|
+
} while (w !== v);
|
|
265
|
+
if (comp.length > 1)
|
|
266
|
+
loops.push({ id: comp.sort().join('+'), members: comp });
|
|
267
|
+
for (const c of comp)
|
|
268
|
+
sccOf.set(c, v);
|
|
269
|
+
};
|
|
270
|
+
for (const m of members)
|
|
271
|
+
if (!order.has(m))
|
|
272
|
+
visit(m);
|
|
273
|
+
loops.sort((a, b) => (a.id < b.id ? -1 : 1));
|
|
274
|
+
// Gesamtlaenge: laengster Pfad auf dem Kondensat — eine Schleife ist dort ein Knoten.
|
|
275
|
+
const condensed = new Map();
|
|
276
|
+
for (const [a, targets] of next) {
|
|
277
|
+
for (const b of targets) {
|
|
278
|
+
const ca = sccOf.get(a);
|
|
279
|
+
const cb = sccOf.get(b);
|
|
280
|
+
if (ca !== cb)
|
|
281
|
+
(condensed.get(ca) ?? condensed.set(ca, new Set()).get(ca)).add(cb);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
const longestFrom = new Map();
|
|
285
|
+
const longest = (c) => {
|
|
286
|
+
const known = longestFrom.get(c);
|
|
287
|
+
if (known !== undefined)
|
|
288
|
+
return known;
|
|
289
|
+
let best = 1;
|
|
290
|
+
for (const n of condensed.get(c) ?? [])
|
|
291
|
+
best = Math.max(best, 1 + longest(n));
|
|
292
|
+
longestFrom.set(c, best);
|
|
293
|
+
return best;
|
|
294
|
+
};
|
|
295
|
+
const length = Math.max(...members.map((m) => longest(sccOf.get(m))));
|
|
296
|
+
const allocated = members.every((m) => moduleOf(m) !== undefined);
|
|
297
|
+
let branching = 0;
|
|
298
|
+
const inDegree = new Map();
|
|
299
|
+
const pairs = new Map();
|
|
300
|
+
for (const [a, targets] of next) {
|
|
301
|
+
branching = Math.max(branching, targets.size);
|
|
302
|
+
for (const b of targets) {
|
|
303
|
+
inDegree.set(b, (inDegree.get(b) ?? 0) + 1);
|
|
304
|
+
const from = moduleOf(a);
|
|
305
|
+
const to = moduleOf(b);
|
|
306
|
+
if (from === undefined || to === undefined || from === to)
|
|
307
|
+
continue;
|
|
308
|
+
const key = `${from} ${to}`;
|
|
309
|
+
const pair = pairs.get(key) ?? pairs.set(key, { from, to, edges: 0, contracts: new Set() }).get(key);
|
|
310
|
+
pair.edges++;
|
|
311
|
+
for (const flow of carriers.get(`${a} ${b}`))
|
|
312
|
+
for (const c of contractsOfFlow(idx, flow))
|
|
313
|
+
pair.contracts.add(c);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
const boundaries = [...pairs.entries()].sort(([a], [b]) => (a < b ? -1 : 1))
|
|
317
|
+
.map(([, p]) => ({ ...p, contracts: [...p.contracts].sort() }));
|
|
318
|
+
const shared = members.filter((m) => (chainsOf.get(m)?.size ?? 0) > 1);
|
|
319
|
+
// Importe und Uebergaben: nur an Gliedern, die allein dieser Kette gehoeren; die andere Seite
|
|
320
|
+
// des Flusses ist mindestens eine FUNC und kein Glied (ein ACTOR ist Ein-/Ausgang, kein Ort).
|
|
321
|
+
const own = members.filter((m) => !shared.includes(m));
|
|
322
|
+
const foreign = (ends) => {
|
|
323
|
+
const funcs = ends.filter((id) => idx.typeOf(id) === 'FUNC');
|
|
324
|
+
return funcs.length > 0 && !funcs.some((f) => inChain.has(f));
|
|
325
|
+
};
|
|
326
|
+
const at = (flows, farEnds) => own.flatMap((func) => [...new Set(flows(func))].sort()
|
|
327
|
+
.filter((flow) => foreign(farEnds(flow))).map((flow) => ({ flow, func })));
|
|
328
|
+
// Antwortweg (CR-SM-408): vom ACTOR rueckwaerts ueber die Fluesse mit `sync`. Jeder Abnehmer liest
|
|
329
|
+
// den Fluss gleich — der ACTOR den Ausgang, ein Glied seinen Eingang.
|
|
330
|
+
const waits = new Set();
|
|
331
|
+
const blockedBy = new Set();
|
|
332
|
+
const open = [];
|
|
333
|
+
const follow = (flow, producer) => {
|
|
334
|
+
const sync = readFlowSync(idx.byId.get(flow)?.attributes);
|
|
335
|
+
if (sync.state !== 'bound' || (sync.value === 'sync' && !inChain.has(producer)))
|
|
336
|
+
blockedBy.add(flow);
|
|
337
|
+
else if (sync.value === 'sync' && !waits.has(producer)) {
|
|
338
|
+
waits.add(producer);
|
|
339
|
+
open.push(producer);
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
for (const m of members) {
|
|
343
|
+
for (const flow of flowsOutOf(m))
|
|
344
|
+
if (idx.out(flow, 'io').some((t) => idx.typeOf(t.target) === 'ACTOR'))
|
|
345
|
+
follow(flow, m);
|
|
346
|
+
}
|
|
347
|
+
while (open.length > 0) {
|
|
348
|
+
for (const flow of flowsInto(open.pop())) {
|
|
349
|
+
for (const t of idx.in(flow, 'io'))
|
|
350
|
+
if (idx.typeOf(t.source) === 'FUNC')
|
|
351
|
+
follow(flow, t.source);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return {
|
|
355
|
+
...who,
|
|
356
|
+
measurable: true,
|
|
357
|
+
length,
|
|
358
|
+
branching,
|
|
359
|
+
moduleBoundaries: allocated ? boundaries.reduce((n, p) => n + p.edges, 0) : null,
|
|
360
|
+
feedbackLoops: loops.length,
|
|
361
|
+
sharedFuncs: shared.length,
|
|
362
|
+
bottlenecks: shared.filter((m) => inDegree.has(m) && next.get(m).size > 0).length,
|
|
363
|
+
syncDepth: null,
|
|
364
|
+
errorPathDepth: null,
|
|
365
|
+
memberCount: members.length,
|
|
366
|
+
fanIn: Math.max(0, ...inDegree.values()),
|
|
367
|
+
loops,
|
|
368
|
+
shared,
|
|
369
|
+
boundaries: allocated ? boundaries : null,
|
|
370
|
+
imports: at(flowsInto, (flow) => idx.in(flow, 'io').map((t) => t.source)),
|
|
371
|
+
handovers: at(flowsOutOf, (flow) => idx.out(flow, 'io').map((t) => t.target)),
|
|
372
|
+
answerPath: blockedBy.size === 0 ? [...waits].sort() : null,
|
|
373
|
+
answerPathBlockedBy: [...blockedBy].sort(),
|
|
374
|
+
};
|
|
375
|
+
});
|
|
376
|
+
const measurable = chains.filter((c) => c.measurable).length;
|
|
377
|
+
return ChainMetrics.parse({
|
|
378
|
+
chains,
|
|
379
|
+
measurability: { chains: chains.length, measurable, ratio: chains.length > 0 ? measurable / chains.length : null },
|
|
380
|
+
});
|
|
381
|
+
}
|
|
@@ -10,9 +10,8 @@ import { type MarkType, type RuleRole, type RuleStage } from './readiness.js';
|
|
|
10
10
|
* All prescribed rule definitions (single source of truth for the catalog).
|
|
11
11
|
*
|
|
12
12
|
* CR-SM-235: `domain` reicht mit durch — die Grundgesamtheit, ueber die eine Regel feuert.
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* wenn es keine zweite gibt.
|
|
13
|
+
* Die Faelligkeit (`isDue`) liest sie hier statt eine eigene Tabelle zu fuehren. Eine zweite
|
|
14
|
+
* Tabelle kann nicht hinterherhinken, wenn es keine zweite gibt.
|
|
16
15
|
*/
|
|
17
16
|
/** Profile groupings — see CATALOGS. */
|
|
18
17
|
export type ProfileId = 'default' | 'se' | 'coding' | 'conformance';
|