@sigloch/contracts 3.2.0 → 4.0.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.
Files changed (42) hide show
  1. package/dist/harness/index.d.ts +2 -2
  2. package/dist/se/action-priority.d.ts +101 -0
  3. package/dist/se/action-priority.js +124 -0
  4. package/dist/se/analysis-freshness-rules.d.ts +5 -0
  5. package/dist/se/analysis-freshness-rules.js +5 -5
  6. package/dist/se/ao-rules.d.ts +5 -39
  7. package/dist/se/ao-rules.js +20 -13
  8. package/dist/se/conformance-rules.d.ts +2 -2
  9. package/dist/se/conformance-rules.js +36 -30
  10. package/dist/se/cr-quality-rules.d.ts +2 -1
  11. package/dist/se/cr-quality-rules.js +9 -7
  12. package/dist/se/evaluate-all.d.ts +18 -3
  13. package/dist/se/evaluate-all.js +29 -26
  14. package/dist/se/fchain-quality-rules.d.ts +2 -1
  15. package/dist/se/fchain-quality-rules.js +8 -6
  16. package/dist/se/fmea-rules.d.ts +3 -11
  17. package/dist/se/fmea-rules.js +53 -16
  18. package/dist/se/format-e-parser.d.ts +14 -1
  19. package/dist/se/format-e-parser.js +8 -3
  20. package/dist/se/index.d.ts +4 -2
  21. package/dist/se/index.js +4 -2
  22. package/dist/se/metric-rules.d.ts +47 -5
  23. package/dist/se/metric-rules.js +199 -171
  24. package/dist/se/near-duplicate-rules.d.ts +2 -0
  25. package/dist/se/near-duplicate-rules.js +2 -2
  26. package/dist/se/ontology.d.ts +55 -4
  27. package/dist/se/ontology.js +46 -6
  28. package/dist/se/policy.d.ts +65 -0
  29. package/dist/se/policy.js +100 -0
  30. package/dist/se/quality-rules.d.ts +2 -1
  31. package/dist/se/quality-rules.js +9 -7
  32. package/dist/se/readiness.d.ts +9 -1
  33. package/dist/se/readiness.js +18 -2
  34. package/dist/se/rules.d.ts +25 -5
  35. package/dist/se/rules.js +112 -47
  36. package/dist/se/schema-quality-rules.d.ts +2 -1
  37. package/dist/se/schema-quality-rules.js +6 -4
  38. package/dist/se/uc-quality-rules.d.ts +2 -1
  39. package/dist/se/uc-quality-rules.js +10 -8
  40. package/dist/se/view-rules.d.ts +2 -6
  41. package/dist/se/view-rules.js +40 -13
  42. package/package.json +2 -1
@@ -111,13 +111,15 @@ export function uc06HasPrecondition(graph) {
111
111
  // Aggregated
112
112
  // ---------------------------------------------------------------------------
113
113
  export const UC_RULES = [
114
- { id: 'UC-01', name: 'UC has requirements', severity: 'error', evaluate: uc01HasRequirements },
115
- { id: 'UC-02', name: 'UC has actor', severity: 'error', evaluate: uc02HasActor },
116
- { id: 'UC-03', name: 'UC has scenario', severity: 'warning', evaluate: uc03HasScenario },
117
- { id: 'UC-04', name: 'UC has goal', severity: 'warning', evaluate: uc04GoalDefined },
118
- { id: 'UC-05', name: 'UC has postcondition', severity: 'info', evaluate: uc05HasPostcondition },
119
- { id: 'UC-06', name: 'UC has precondition', severity: 'info', evaluate: uc06HasPrecondition },
114
+ { id: 'UC-01', name: 'UC has requirements', severity: 'error', evaluate: uc01HasRequirements, domain: ['UC'] },
115
+ { id: 'UC-02', name: 'UC has actor', severity: 'error', evaluate: uc02HasActor, domain: ['UC'] },
116
+ { id: 'UC-03', name: 'UC has scenario', severity: 'warning', evaluate: uc03HasScenario, domain: ['UC'] },
117
+ { id: 'UC-04', name: 'UC has goal', severity: 'warning', evaluate: uc04GoalDefined, domain: ['UC'] },
118
+ { id: 'UC-05', name: 'UC has postcondition', severity: 'info', evaluate: uc05HasPostcondition, domain: ['UC'] },
119
+ { id: 'UC-06', name: 'UC has precondition', severity: 'info', evaluate: uc06HasPrecondition, domain: ['UC'] },
120
120
  ];
121
- export function evaluateUCRules(graph) {
122
- return UC_RULES.flatMap(rule => rule.evaluate(graph));
121
+ // CR-SM-236: `policy` wird durchgereicht, auch wo diese Familie heute keine Schwelle hat —
122
+ // ein Sonderweg je Familie waere genau der zweite Pfad, den der Regelsatz verbietet.
123
+ export function evaluateUCRules(graph, policy) {
124
+ return UC_RULES.flatMap(rule => rule.evaluate(graph, policy));
123
125
  }
@@ -1,11 +1,7 @@
1
- /**
2
- * CR-184: View-related quality rules.
3
- * VR-01: TEST without testResult attribute (info).
4
- * CL-01: ACTOR without UCs in at least 2 distinct operatingModes (warning).
5
- */
6
1
  import type { OntologyGraph } from './ontology.js';
7
2
  import type { RuleViolation, RuleDefinition } from './rules.js';
3
+ import type { MetricPolicy } from './policy.js';
8
4
  export declare function vr01TestNoResult(graph: OntologyGraph): RuleViolation[];
9
5
  export declare function cl01ConopsCompleteness(graph: OntologyGraph): RuleViolation[];
10
6
  export declare const VIEW_RULES: RuleDefinition[];
11
- export declare function evaluateViewRules(graph: OntologyGraph): RuleViolation[];
7
+ export declare function evaluateViewRules(graph: OntologyGraph, policy: MetricPolicy): RuleViolation[];
@@ -1,15 +1,40 @@
1
+ /**
2
+ * CR-184: View-related quality rules.
3
+ * VR-01: TEST with a testRefs entry that has no result (info).
4
+ * CL-01: ACTOR without UCs in at least 2 distinct operatingModes (warning).
5
+ */
6
+ import { TestRefsSchema } from './ontology.js';
1
7
  // ---------------------------------------------------------------------------
2
- // VR-01: TEST without testResult
8
+ // VR-01: ein testRefs-Eintrag ohne Ergebnis
9
+ //
10
+ // CR-SM-231b: liest das Ergebnis PRO EINTRAG statt am Knoten. Vorher hing `testResult` am
11
+ // TEST-Knoten — bei n Eintraegen mehrdeutig: laeuft eine Abnahme als vitest UND playwright,
12
+ // kann ein einzelnes Ergebnis nicht sagen, welcher Lauf gemeint ist. Die Meldung nennt jetzt
13
+ // die Dateien ohne Ergebnis, nicht nur den Knoten.
14
+ //
15
+ // Ein TEST ohne gueltige Bindung faellt R-19 zur Last, nicht hier: sonst meldeten beide
16
+ // Regeln denselben Sachverhalt (Presence/Resolution-Trennung).
3
17
  // ---------------------------------------------------------------------------
4
18
  export function vr01TestNoResult(graph) {
5
- return graph.elements
6
- .filter(e => e.type === 'TEST' && e.attributes?.['testResult'] == null)
7
- .map(e => ({
8
- rule_id: 'VR-01',
9
- severity: 'info',
10
- element_id: e.id,
11
- message: `${e.id} has no testResult — assumed pending`,
12
- }));
19
+ const violations = [];
20
+ for (const el of graph.elements) {
21
+ if (el.type !== 'TEST')
22
+ continue;
23
+ const parsed = TestRefsSchema.safeParse(el.attributes?.testRefs);
24
+ if (!parsed.success)
25
+ continue; // keine/ungueltige Bindung R-19-Gebiet
26
+ const pending = parsed.data.filter(ref => ref.result === undefined);
27
+ if (pending.length === 0)
28
+ continue;
29
+ violations.push({
30
+ rule_id: 'VR-01',
31
+ severity: 'info',
32
+ element_id: el.id,
33
+ message: `${el.id} has ${pending.length} of ${parsed.data.length} testRefs entries without a result — assumed pending: ${pending.map(r => r.file).join(', ')}`,
34
+ fix_hint: 'Record the run outcome on the entry (result, ranAt, evidence) — a binding without a result is not evidence',
35
+ });
36
+ }
37
+ return violations;
13
38
  }
14
39
  // ---------------------------------------------------------------------------
15
40
  // CL-01: ACTOR without UCs in >= 2 distinct operatingModes
@@ -48,9 +73,11 @@ export function cl01ConopsCompleteness(graph) {
48
73
  // Aggregated array & convenience runner
49
74
  // ---------------------------------------------------------------------------
50
75
  export const VIEW_RULES = [
51
- { id: 'VR-01', name: 'TestNoResult', severity: 'info', evaluate: vr01TestNoResult },
52
- { id: 'CL-01', name: 'ConopsCompleteness', severity: 'warning', evaluate: cl01ConopsCompleteness },
76
+ { id: 'VR-01', name: 'TestNoResult', severity: 'info', evaluate: vr01TestNoResult, domain: ['TEST'] },
77
+ { id: 'CL-01', name: 'ConopsCompleteness', severity: 'warning', evaluate: cl01ConopsCompleteness, domain: ['ACTOR'] },
53
78
  ];
54
- export function evaluateViewRules(graph) {
55
- return VIEW_RULES.flatMap(rule => rule.evaluate(graph));
79
+ // CR-SM-236: `policy` wird durchgereicht, auch wo diese Familie heute keine Schwelle hat —
80
+ // ein Sonderweg je Familie waere genau der zweite Pfad, den der Regelsatz verbietet.
81
+ export function evaluateViewRules(graph, policy) {
82
+ return VIEW_RULES.flatMap(rule => rule.evaluate(graph, policy));
56
83
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sigloch/contracts",
3
- "version": "3.2.0",
3
+ "version": "4.0.0",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,6 +28,7 @@
28
28
  "prepublishOnly": "npm run build && npm run test"
29
29
  },
30
30
  "dependencies": {
31
+ "@sigloch/contracts": "^4.0.0",
31
32
  "zod": "^4.3.6"
32
33
  },
33
34
  "license": "MIT",