@transitrix/diagrams 1.8.6 → 1.8.7
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/package.json +7 -2
- package/dist/__tests__/edge-path.test.d.ts +0 -1
- package/dist/__tests__/edge-path.test.js +0 -55
- package/dist/__tests__/node-size-presets.test.d.ts +0 -1
- package/dist/__tests__/node-size-presets.test.js +0 -30
- package/dist/__tests__/scope.test.d.ts +0 -1
- package/dist/__tests__/scope.test.js +0 -23
- package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
- package/dist/__tests__/yaml-normalize.test.js +0 -148
- package/dist/activities/__tests__/cpm.test.d.ts +0 -1
- package/dist/activities/__tests__/cpm.test.js +0 -146
- package/dist/activities/__tests__/gantt.test.d.ts +0 -1
- package/dist/activities/__tests__/gantt.test.js +0 -263
- package/dist/activities/__tests__/layout.test.d.ts +0 -1
- package/dist/activities/__tests__/layout.test.js +0 -98
- package/dist/activities/__tests__/validate.test.d.ts +0 -1
- package/dist/activities/__tests__/validate.test.js +0 -397
- package/dist/activity-card/__tests__/example.test.d.ts +0 -1
- package/dist/activity-card/__tests__/example.test.js +0 -73
- package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
- package/dist/activity-card/__tests__/layout.test.js +0 -141
- package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
- package/dist/activity-card/__tests__/resolver.test.js +0 -325
- package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
- package/dist/activity-card/__tests__/validate.test.js +0 -149
- package/dist/actor/__tests__/validate.test.d.ts +0 -1
- package/dist/actor/__tests__/validate.test.js +0 -95
- package/dist/applications/__tests__/validate.test.d.ts +0 -1
- package/dist/applications/__tests__/validate.test.js +0 -223
- package/dist/assertion/__tests__/example.test.d.ts +0 -1
- package/dist/assertion/__tests__/example.test.js +0 -32
- package/dist/assertion/__tests__/validate.test.d.ts +0 -1
- package/dist/assertion/__tests__/validate.test.js +0 -130
- package/dist/blocks/__tests__/layout.test.d.ts +0 -1
- package/dist/blocks/__tests__/layout.test.js +0 -153
- package/dist/blocks/__tests__/validate.test.d.ts +0 -1
- package/dist/blocks/__tests__/validate.test.js +0 -235
- package/dist/business-service/__tests__/validate.test.d.ts +0 -1
- package/dist/business-service/__tests__/validate.test.js +0 -135
- package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
- package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
- package/dist/capability-map/__tests__/address.test.d.ts +0 -1
- package/dist/capability-map/__tests__/address.test.js +0 -49
- package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
- package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
- package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
- package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
- package/dist/capability-map/__tests__/validate.test.js +0 -212
- package/dist/change/__tests__/validate.test.d.ts +0 -1
- package/dist/change/__tests__/validate.test.js +0 -79
- package/dist/codex/__tests__/example.test.d.ts +0 -1
- package/dist/codex/__tests__/example.test.js +0 -33
- package/dist/codex/__tests__/validate.test.d.ts +0 -1
- package/dist/codex/__tests__/validate.test.js +0 -68
- package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
- package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
- package/dist/compliance/__tests__/classify.test.d.ts +0 -1
- package/dist/compliance/__tests__/classify.test.js +0 -58
- package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
- package/dist/compliance/__tests__/confidence.test.js +0 -78
- package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
- package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
- package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
- package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
- package/dist/compliance/__tests__/example.test.d.ts +0 -1
- package/dist/compliance/__tests__/example.test.js +0 -51
- package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
- package/dist/compliance/__tests__/gap-report.test.js +0 -113
- package/dist/compliance/__tests__/html.test.d.ts +0 -1
- package/dist/compliance/__tests__/html.test.js +0 -122
- package/dist/compliance/__tests__/impact.test.d.ts +0 -1
- package/dist/compliance/__tests__/impact.test.js +0 -913
- package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
- package/dist/compliance/__tests__/markdown.test.js +0 -85
- package/dist/compliance/__tests__/trace.test.d.ts +0 -1
- package/dist/compliance/__tests__/trace.test.js +0 -144
- package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
- package/dist/compliance/__tests__/view-resolution.test.js +0 -59
- package/dist/compliance/__tests__/views.test.d.ts +0 -1
- package/dist/compliance/__tests__/views.test.js +0 -59
- package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/build.test.js +0 -183
- package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
- package/dist/compliance-matrix/__tests__/example.test.js +0 -49
- package/dist/confidence/__tests__/score.test.d.ts +0 -1
- package/dist/confidence/__tests__/score.test.js +0 -188
- package/dist/constraint/__tests__/example.test.d.ts +0 -1
- package/dist/constraint/__tests__/example.test.js +0 -14
- package/dist/constraint/__tests__/validate.test.d.ts +0 -1
- package/dist/constraint/__tests__/validate.test.js +0 -58
- package/dist/factor/__tests__/validate.test.d.ts +0 -1
- package/dist/factor/__tests__/validate.test.js +0 -112
- package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
- package/dist/fgca/__tests__/chain-table.test.js +0 -158
- package/dist/fgca/__tests__/layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/layout.test.js +0 -140
- package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
- package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
- package/dist/fgca/__tests__/preview-layout.test.js +0 -106
- package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
- package/dist/fgca/__tests__/resolver.test.js +0 -185
- package/dist/fgca/__tests__/validate.test.d.ts +0 -1
- package/dist/fgca/__tests__/validate.test.js +0 -125
- package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
- package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
- package/dist/goals/__tests__/layout.test.d.ts +0 -1
- package/dist/goals/__tests__/layout.test.js +0 -153
- package/dist/goals/__tests__/mutations.test.d.ts +0 -1
- package/dist/goals/__tests__/mutations.test.js +0 -134
- package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
- package/dist/goals/__tests__/parse-canonical.test.js +0 -131
- package/dist/goals/__tests__/validate.test.d.ts +0 -1
- package/dist/goals/__tests__/validate.test.js +0 -183
- package/dist/integration/__tests__/validate.test.d.ts +0 -1
- package/dist/integration/__tests__/validate.test.js +0 -169
- package/dist/location/__tests__/validate.test.d.ts +0 -1
- package/dist/location/__tests__/validate.test.js +0 -107
- package/dist/node/__tests__/validate.test.d.ts +0 -1
- package/dist/node/__tests__/validate.test.js +0 -100
- package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
- package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/layout.test.js +0 -196
- package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
- package/dist/process-blueprint/__tests__/validate.test.js +0 -280
- package/dist/process-map/__tests__/validate.test.d.ts +0 -1
- package/dist/process-map/__tests__/validate.test.js +0 -199
- package/dist/products/__tests__/validate.test.d.ts +0 -1
- package/dist/products/__tests__/validate.test.js +0 -210
- package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
- package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
- package/dist/requirement/__tests__/example.test.d.ts +0 -1
- package/dist/requirement/__tests__/example.test.js +0 -21
- package/dist/requirement/__tests__/validate.test.d.ts +0 -1
- package/dist/requirement/__tests__/validate.test.js +0 -80
- package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
- package/dist/scenarios/__tests__/validate.test.js +0 -183
- package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
- package/dist/stakeholder/__tests__/validate.test.js +0 -88
- package/dist/target-state/__tests__/validate.test.d.ts +0 -1
- package/dist/target-state/__tests__/validate.test.js +0 -78
- package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
- package/dist/technology-service/__tests__/validate.test.js +0 -121
- package/dist/theme/__tests__/tokens.test.d.ts +0 -1
- package/dist/theme/__tests__/tokens.test.js +0 -159
- package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
- package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
- package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
- package/dist/webview/__tests__/entry-notations.test.js +0 -62
- package/dist/webview/__tests__/entry.test.d.ts +0 -1
- package/dist/webview/__tests__/entry.test.js +0 -56
- package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
- package/dist/webview/__tests__/render-activities.test.js +0 -91
- package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
- package/dist/webview/__tests__/render-blocks.test.js +0 -175
- package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
- package/dist/webview/__tests__/render-goals.test.js +0 -120
- package/dist/webview/__tests__/render-process.test.d.ts +0 -1
- package/dist/webview/__tests__/render-process.test.js +0 -463
- package/dist/webview/__tests__/render-util.test.d.ts +0 -1
- package/dist/webview/__tests__/render-util.test.js +0 -54
- package/src/__tests__/edge-path.test.ts +0 -67
- package/src/__tests__/node-size-presets.test.ts +0 -50
- package/src/__tests__/scope.test.ts +0 -27
- package/src/__tests__/yaml-normalize.test.ts +0 -158
- package/src/activities/__tests__/cpm.test.ts +0 -164
- package/src/activities/__tests__/gantt.test.ts +0 -290
- package/src/activities/__tests__/layout.test.ts +0 -112
- package/src/activities/__tests__/validate.test.ts +0 -446
- package/src/activity-card/__tests__/example.test.ts +0 -83
- package/src/activity-card/__tests__/layout.test.ts +0 -162
- package/src/activity-card/__tests__/resolver.test.ts +0 -357
- package/src/activity-card/__tests__/validate.test.ts +0 -167
- package/src/actor/__tests__/validate.test.ts +0 -114
- package/src/applications/__tests__/validate.test.ts +0 -256
- package/src/assertion/__tests__/example.test.ts +0 -37
- package/src/assertion/__tests__/validate.test.ts +0 -142
- package/src/blocks/__tests__/layout.test.ts +0 -169
- package/src/blocks/__tests__/validate.test.ts +0 -260
- package/src/business-service/__tests__/validate.test.ts +0 -160
- package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
- package/src/capability-map/__tests__/address.test.ts +0 -59
- package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
- package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
- package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
- package/src/capability-map/__tests__/validate.test.ts +0 -238
- package/src/change/__tests__/validate.test.ts +0 -97
- package/src/codex/__tests__/example.test.ts +0 -40
- package/src/codex/__tests__/validate.test.ts +0 -84
- package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
- package/src/compliance/__tests__/classify.test.ts +0 -64
- package/src/compliance/__tests__/confidence.test.ts +0 -98
- package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
- package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
- package/src/compliance/__tests__/example.test.ts +0 -57
- package/src/compliance/__tests__/gap-report.test.ts +0 -129
- package/src/compliance/__tests__/html.test.ts +0 -142
- package/src/compliance/__tests__/impact.test.ts +0 -1060
- package/src/compliance/__tests__/markdown.test.ts +0 -95
- package/src/compliance/__tests__/trace.test.ts +0 -157
- package/src/compliance/__tests__/view-resolution.test.ts +0 -80
- package/src/compliance/__tests__/views.test.ts +0 -64
- package/src/compliance-matrix/__tests__/build.test.ts +0 -200
- package/src/compliance-matrix/__tests__/example.test.ts +0 -57
- package/src/confidence/__tests__/score.test.ts +0 -254
- package/src/constraint/__tests__/example.test.ts +0 -19
- package/src/constraint/__tests__/validate.test.ts +0 -68
- package/src/factor/__tests__/validate.test.ts +0 -133
- package/src/fgca/__tests__/chain-table.test.ts +0 -172
- package/src/fgca/__tests__/layout.test.ts +0 -179
- package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
- package/src/fgca/__tests__/preview-layout.test.ts +0 -124
- package/src/fgca/__tests__/resolver.test.ts +0 -209
- package/src/fgca/__tests__/validate.test.ts +0 -142
- package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
- package/src/goals/__tests__/layout.test.ts +0 -175
- package/src/goals/__tests__/mutations.test.ts +0 -153
- package/src/goals/__tests__/parse-canonical.test.ts +0 -147
- package/src/goals/__tests__/validate.test.ts +0 -202
- package/src/integration/__tests__/validate.test.ts +0 -203
- package/src/location/__tests__/validate.test.ts +0 -127
- package/src/node/__tests__/validate.test.ts +0 -118
- package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
- package/src/process-blueprint/__tests__/layout.test.ts +0 -240
- package/src/process-blueprint/__tests__/validate.test.ts +0 -310
- package/src/process-map/__tests__/validate.test.ts +0 -223
- package/src/products/__tests__/validate.test.ts +0 -239
- package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
- package/src/requirement/__tests__/example.test.ts +0 -24
- package/src/requirement/__tests__/validate.test.ts +0 -96
- package/src/scenarios/__tests__/validate.test.ts +0 -209
- package/src/stakeholder/__tests__/validate.test.ts +0 -105
- package/src/target-state/__tests__/validate.test.ts +0 -95
- package/src/technology-service/__tests__/validate.test.ts +0 -143
- package/src/theme/__tests__/tokens.test.ts +0 -185
- package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
- package/src/webview/__tests__/entry-notations.test.ts +0 -77
- package/src/webview/__tests__/entry.test.ts +0 -64
- package/src/webview/__tests__/render-activities.test.ts +0 -100
- package/src/webview/__tests__/render-blocks.test.ts +0 -206
- package/src/webview/__tests__/render-goals.test.ts +0 -128
- package/src/webview/__tests__/render-process.test.ts +0 -538
- package/src/webview/__tests__/render-util.test.ts +0 -66
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// Bridge from the compliance index projections to the DQ-1 confidence module
|
|
2
|
-
// (vkgeorgia/strategy#162 — DQ-2). Pins that:
|
|
3
|
-
// • element TYPEs lift to REQUIREMENT / ASSERTION (decay lookup keys),
|
|
4
|
-
// • admitted_at flows through to the freshness curve,
|
|
5
|
-
// • the §11.6 header line matches the spec example shape,
|
|
6
|
-
// • an empty view suppresses the header (caller-controlled).
|
|
7
|
-
|
|
8
|
-
import { describe, it, expect } from 'vitest';
|
|
9
|
-
import {
|
|
10
|
-
assertionToScoringElement,
|
|
11
|
-
complianceConfidenceHeader,
|
|
12
|
-
requirementToScoringElement,
|
|
13
|
-
scoreComplianceView,
|
|
14
|
-
} from '../confidence.js';
|
|
15
|
-
import type { IndexAssertion, IndexRequirement } from '../types.js';
|
|
16
|
-
|
|
17
|
-
const req = (over: Partial<IndexRequirement> = {}): IndexRequirement => ({
|
|
18
|
-
id: 'REQUIREMENT-1', name: 'R', admitted_at: '2026-05-01', ...over,
|
|
19
|
-
});
|
|
20
|
-
const ass = (over: Partial<IndexAssertion> = {}): IndexAssertion => ({
|
|
21
|
-
id: 'ASSERTION-1', about: 'REQUIREMENT-1', subject: 'PRODUCT-1',
|
|
22
|
-
status: 'compliant', admitted_at: '2026-05-01', ...over,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
describe('requirementToScoringElement / assertionToScoringElement', () => {
|
|
26
|
-
it('lifts the index projection to a ScoringElement', () => {
|
|
27
|
-
expect(requirementToScoringElement(req())).toEqual({
|
|
28
|
-
type: 'REQUIREMENT', admitted_at: '2026-05-01',
|
|
29
|
-
});
|
|
30
|
-
expect(assertionToScoringElement(ass())).toEqual({
|
|
31
|
-
type: 'ASSERTION', admitted_at: '2026-05-01',
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('leaves sources undefined — v1 has no field-zone provenance to resolve', () => {
|
|
36
|
-
// Documents the §11.5 behaviour: until DSM/Studio ingest field-zone
|
|
37
|
-
// source_quality, every element scores unsourced and is counted separately.
|
|
38
|
-
expect(requirementToScoringElement(req()).sources).toBeUndefined();
|
|
39
|
-
expect(assertionToScoringElement(ass()).sources).toBeUndefined();
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it('preserves an absent admitted_at as undefined', () => {
|
|
43
|
-
expect(requirementToScoringElement(req({ admitted_at: undefined })).admitted_at).toBeUndefined();
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe('scoreComplianceView', () => {
|
|
48
|
-
it('scores the union of requirements + assertions and reports today', () => {
|
|
49
|
-
const v = scoreComplianceView([req()], [ass()], '2026-06-07');
|
|
50
|
-
expect(v.today).toBe('2026-06-07');
|
|
51
|
-
expect(v.elements).toHaveLength(2);
|
|
52
|
-
expect(v.composite.element_count).toBe(2);
|
|
53
|
-
// Two fresh elements (37 days old, ≤ implicit fresh_days=180) → freshness=1.0,
|
|
54
|
-
// but no sources → source_trust=0.25 floor → confidence=0.25, band D.
|
|
55
|
-
for (const e of v.elements) {
|
|
56
|
-
expect(e.freshness).toBe(1.0);
|
|
57
|
-
expect(e.source_trust).toBe(0.25);
|
|
58
|
-
expect(e.confidence).toBe(0.25);
|
|
59
|
-
expect(e.sourced).toBe(false);
|
|
60
|
-
}
|
|
61
|
-
expect(v.composite.band).toBe('D');
|
|
62
|
-
expect(v.composite.coverage).toBe(0);
|
|
63
|
-
expect(v.composite.unsourced_count).toBe(2);
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
it('returns the degenerate composite for an empty view', () => {
|
|
67
|
-
const v = scoreComplianceView([], [], '2026-06-07');
|
|
68
|
-
expect(v.composite.element_count).toBe(0);
|
|
69
|
-
expect(v.elements).toHaveLength(0);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('honours per-TYPE decay overrides from the manifest config', () => {
|
|
73
|
-
// ASSERTION decays faster than REQUIREMENT — exercise the by_type lookup.
|
|
74
|
-
const v = scoreComplianceView(
|
|
75
|
-
[req({ admitted_at: '2025-01-01' })],
|
|
76
|
-
[ass({ admitted_at: '2025-01-01' })],
|
|
77
|
-
'2026-06-07',
|
|
78
|
-
{
|
|
79
|
-
by_type: {
|
|
80
|
-
REQUIREMENT: { fresh_days: 1000, stale_days: 2000, floor: 0.5 },
|
|
81
|
-
ASSERTION: { fresh_days: 30, stale_days: 60, floor: 0.1 },
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
);
|
|
85
|
-
// Requirement is still well within fresh_days=1000 → freshness 1.0.
|
|
86
|
-
expect(v.elements[0].freshness).toBe(1.0);
|
|
87
|
-
// Assertion is well past stale_days=60 → freshness floors at 0.1.
|
|
88
|
-
expect(v.elements[1].freshness).toBeCloseTo(0.1, 10);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
describe('complianceConfidenceHeader', () => {
|
|
93
|
-
it('formats the §11.6 example shape and returns empty for an empty view', () => {
|
|
94
|
-
expect(complianceConfidenceHeader([], [], '2026-06-07')).toBe('');
|
|
95
|
-
const line = complianceConfidenceHeader([req()], [ass()], '2026-06-07');
|
|
96
|
-
expect(line).toMatch(/^Data confidence \(as of 2026-06-07\): D \(weakest link\) · 0\.25 mean · 0% sourced$/);
|
|
97
|
-
});
|
|
98
|
-
});
|
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
parseCoverageMetricConfig,
|
|
4
|
-
buildCoverageMatrix,
|
|
5
|
-
type CoverageMetricConfig,
|
|
6
|
-
} from '../coverage-metric.js';
|
|
7
|
-
import { emptyCanon, ingestComplianceDoc } from '../classify.js';
|
|
8
|
-
import type { ComplianceCanon } from '../classify.js';
|
|
9
|
-
|
|
10
|
-
// ── parseCoverageMetricConfig ─────────────────────────────────────────────────
|
|
11
|
-
|
|
12
|
-
describe('parseCoverageMetricConfig', () => {
|
|
13
|
-
it('rejects null', () => {
|
|
14
|
-
const r = parseCoverageMetricConfig(null);
|
|
15
|
-
expect(r.ok).toBe(false);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it('rejects missing id', () => {
|
|
19
|
-
const r = parseCoverageMetricConfig({ view: { name: 'x' } });
|
|
20
|
-
expect(r.ok).toBe(false);
|
|
21
|
-
if (!r.ok) expect(r.errors.some(e => e.includes('id'))).toBe(true);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('parses minimal config via view: wrapper', () => {
|
|
25
|
-
const r = parseCoverageMetricConfig({
|
|
26
|
-
view: { id: 'CM-1', name: 'Test' },
|
|
27
|
-
});
|
|
28
|
-
expect(r.ok).toBe(true);
|
|
29
|
-
if (r.ok) {
|
|
30
|
-
expect(r.config.id).toBe('CM-1');
|
|
31
|
-
expect(r.config.name).toBe('Test');
|
|
32
|
-
expect(r.config.thresholds.green).toBe(0.8);
|
|
33
|
-
expect(r.config.thresholds.amber).toBe(0.5);
|
|
34
|
-
expect(r.config.regimes).toBeUndefined();
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it('parses view: wrapper with regimes.include and subjects', () => {
|
|
39
|
-
const r = parseCoverageMetricConfig({
|
|
40
|
-
view: {
|
|
41
|
-
id: 'CM-2',
|
|
42
|
-
name: 'EU Coverage',
|
|
43
|
-
description: 'desc',
|
|
44
|
-
regimes: { include: ['LAW-GDPR-1'] },
|
|
45
|
-
subjects: { products: ['PRODUCT-1'] },
|
|
46
|
-
thresholds: { green: 0.9, amber: 0.6 },
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
expect(r.ok).toBe(true);
|
|
50
|
-
if (r.ok) {
|
|
51
|
-
expect(r.config.regimes?.include).toEqual(['LAW-GDPR-1']);
|
|
52
|
-
expect(r.config.subjects?.products).toEqual(['PRODUCT-1']);
|
|
53
|
-
expect(r.config.thresholds.green).toBe(0.9);
|
|
54
|
-
expect(r.config.thresholds.amber).toBe(0.6);
|
|
55
|
-
expect(r.config.warnings).toBeUndefined();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('parses view: wrapper with regimes.filter', () => {
|
|
60
|
-
const r = parseCoverageMetricConfig({
|
|
61
|
-
view: {
|
|
62
|
-
id: 'CM-3',
|
|
63
|
-
name: 'EU Filter',
|
|
64
|
-
regimes: { filter: { jurisdiction: ['EU'], codex_type: ['regulation'] } },
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
expect(r.ok).toBe(true);
|
|
68
|
-
if (r.ok) {
|
|
69
|
-
expect(r.config.regimes?.filter?.jurisdiction).toEqual(['EU']);
|
|
70
|
-
expect(r.config.regimes?.filter?.codex_type).toEqual(['regulation']);
|
|
71
|
-
expect(r.config.regimes?.include).toBeUndefined();
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('warns COVMET-007 when both regimes.include and regimes.filter are set', () => {
|
|
76
|
-
const r = parseCoverageMetricConfig({
|
|
77
|
-
view: {
|
|
78
|
-
id: 'CM-4',
|
|
79
|
-
name: 'Both',
|
|
80
|
-
regimes: {
|
|
81
|
-
include: ['LAW-GDPR-1'],
|
|
82
|
-
filter: { jurisdiction: ['EU'] },
|
|
83
|
-
},
|
|
84
|
-
},
|
|
85
|
-
});
|
|
86
|
-
expect(r.ok).toBe(true);
|
|
87
|
-
if (r.ok) {
|
|
88
|
-
expect(r.config.warnings?.some(w => w.includes('COVMET-007'))).toBe(true);
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
it('accepts bare (unwrapped) object without wrapper warning', () => {
|
|
93
|
-
const r = parseCoverageMetricConfig({ id: 'CM-5', name: 'Bare' });
|
|
94
|
-
expect(r.ok).toBe(true);
|
|
95
|
-
if (r.ok) {
|
|
96
|
-
expect(r.config.warnings?.some(w => w.includes('COVMET-DEPRECATED'))).toBeFalsy();
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
|
-
// ── Backward compatibility: deprecated coverage_metric: wrapper ──────────────
|
|
101
|
-
|
|
102
|
-
it('accepts deprecated coverage_metric: wrapper with COVMET-DEPRECATED warning', () => {
|
|
103
|
-
const r = parseCoverageMetricConfig({
|
|
104
|
-
coverage_metric: { id: 'CM-6', name: 'Legacy' },
|
|
105
|
-
});
|
|
106
|
-
expect(r.ok).toBe(true);
|
|
107
|
-
if (r.ok) {
|
|
108
|
-
expect(r.config.warnings?.some(w => w.includes('COVMET-DEPRECATED'))).toBe(true);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('maps deprecated scope.codex to regimes.include', () => {
|
|
113
|
-
const r = parseCoverageMetricConfig({
|
|
114
|
-
coverage_metric: {
|
|
115
|
-
id: 'CM-7',
|
|
116
|
-
name: 'Legacy Scope',
|
|
117
|
-
scope: {
|
|
118
|
-
codex: ['LAW-GDPR-1', 'LAW-NIS2-1'],
|
|
119
|
-
subjects: { products: ['PRODUCT-1'] },
|
|
120
|
-
},
|
|
121
|
-
thresholds: { green: 0.9, amber: 0.6 },
|
|
122
|
-
},
|
|
123
|
-
});
|
|
124
|
-
expect(r.ok).toBe(true);
|
|
125
|
-
if (r.ok) {
|
|
126
|
-
expect(r.config.regimes?.include).toEqual(['LAW-GDPR-1', 'LAW-NIS2-1']);
|
|
127
|
-
expect(r.config.subjects?.products).toEqual(['PRODUCT-1']);
|
|
128
|
-
expect(r.config.thresholds.green).toBe(0.9);
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
// ── buildCoverageMatrix ───────────────────────────────────────────────────────
|
|
134
|
-
|
|
135
|
-
function makeCanon(): ComplianceCanon {
|
|
136
|
-
const canon = emptyCanon();
|
|
137
|
-
ingestComplianceDoc(canon, { id: 'LAW-GDPR-1', name: 'GDPR', zone: 'codex', jurisdiction: 'EU' });
|
|
138
|
-
ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQ-1', name: 'Lawful basis', derived_from: ['LAW-GDPR-1'] });
|
|
139
|
-
ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQ-2', name: 'Data minimisation', derived_from: ['LAW-GDPR-1'] });
|
|
140
|
-
ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQ-3', name: 'Breach notification', derived_from: ['LAW-GDPR-1'] });
|
|
141
|
-
ingestComplianceDoc(canon, { notation: 'product', id: 'PRODUCT-1', name: 'E-commerce' });
|
|
142
|
-
ingestComplianceDoc(canon, { notation: 'assertion', id: 'ASSERTION-1', about: 'REQ-1', subject: 'PRODUCT-1', status: 'compliant' });
|
|
143
|
-
ingestComplianceDoc(canon, { notation: 'assertion', id: 'ASSERTION-2', about: 'REQ-2', subject: 'PRODUCT-1', status: 'partial' });
|
|
144
|
-
// REQ-3 has no assertion → gap
|
|
145
|
-
return canon;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
function makeConfig(overrides?: Partial<CoverageMetricConfig>): CoverageMetricConfig {
|
|
149
|
-
return {
|
|
150
|
-
id: 'CM-TEST-1',
|
|
151
|
-
name: 'Test Coverage',
|
|
152
|
-
regimes: { include: ['LAW-GDPR-1'] },
|
|
153
|
-
subjects: { products: ['PRODUCT-1'] },
|
|
154
|
-
thresholds: { green: 0.8, amber: 0.5 },
|
|
155
|
-
...overrides,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
describe('buildCoverageMatrix', () => {
|
|
160
|
-
it('returns correct row counts', () => {
|
|
161
|
-
const matrix = buildCoverageMatrix(makeCanon(), makeConfig());
|
|
162
|
-
expect(matrix.rows).toHaveLength(1);
|
|
163
|
-
const row = matrix.rows[0];
|
|
164
|
-
expect(row.codexId).toBe('LAW-GDPR-1');
|
|
165
|
-
expect(row.totalRequirements).toBe(3);
|
|
166
|
-
expect(row.compliant).toBe(1);
|
|
167
|
-
expect(row.partial).toBe(1);
|
|
168
|
-
expect(row.gap).toBe(1);
|
|
169
|
-
expect(row.coveredCount).toBe(2);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('computes coverage percentage correctly', () => {
|
|
173
|
-
const row = buildCoverageMatrix(makeCanon(), makeConfig()).rows[0];
|
|
174
|
-
expect(row.coveragePct).toBeCloseTo(2 / 3, 5);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
it('assigns amber RAG status for ~67% coverage with green=0.80, amber=0.50', () => {
|
|
178
|
-
expect(buildCoverageMatrix(makeCanon(), makeConfig()).rows[0].ragStatus).toBe('amber');
|
|
179
|
-
});
|
|
180
|
-
|
|
181
|
-
it('assigns green RAG when all requirements covered', () => {
|
|
182
|
-
const canon = makeCanon();
|
|
183
|
-
ingestComplianceDoc(canon, { notation: 'assertion', id: 'ASSERTION-3', about: 'REQ-3', subject: 'PRODUCT-1', status: 'compliant' });
|
|
184
|
-
const matrix = buildCoverageMatrix(canon, makeConfig());
|
|
185
|
-
expect(matrix.rows[0].ragStatus).toBe('green');
|
|
186
|
-
expect(matrix.rows[0].coveragePct).toBe(1);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('assigns red RAG when coverage < amber threshold', () => {
|
|
190
|
-
const matrix = buildCoverageMatrix(makeCanon(), makeConfig({ thresholds: { green: 0.9, amber: 0.8 } }));
|
|
191
|
-
expect(matrix.rows[0].ragStatus).toBe('red');
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
it('returns no_data when codex has no requirements', () => {
|
|
195
|
-
const canon = emptyCanon();
|
|
196
|
-
ingestComplianceDoc(canon, { id: 'LAW-EMPTY-1', name: 'Empty Law', zone: 'codex', jurisdiction: 'XX' });
|
|
197
|
-
const matrix = buildCoverageMatrix(canon, makeConfig({ regimes: { include: ['LAW-EMPTY-1'] } }));
|
|
198
|
-
expect(matrix.rows[0].ragStatus).toBe('no_data');
|
|
199
|
-
expect(matrix.rows[0].totalRequirements).toBe(0);
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('includes jurisdiction from scanned canon', () => {
|
|
203
|
-
expect(buildCoverageMatrix(makeCanon(), makeConfig()).rows[0].jurisdiction).toBe('EU');
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('handles multiple codex entries via regimes.include', () => {
|
|
207
|
-
const canon = makeCanon();
|
|
208
|
-
ingestComplianceDoc(canon, { id: 'LAW-NIS2-1', name: 'NIS2', zone: 'codex', jurisdiction: 'EU' });
|
|
209
|
-
ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQ-NIS-1', name: 'Incident reporting', derived_from: ['LAW-NIS2-1'] });
|
|
210
|
-
const matrix = buildCoverageMatrix(canon, makeConfig({ regimes: { include: ['LAW-GDPR-1', 'LAW-NIS2-1'] } }));
|
|
211
|
-
expect(matrix.rows).toHaveLength(2);
|
|
212
|
-
expect(matrix.rows[1].codexId).toBe('LAW-NIS2-1');
|
|
213
|
-
expect(matrix.rows[1].gap).toBe(1);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it('respects product scope — ignores assertions for other products', () => {
|
|
217
|
-
const canon = makeCanon();
|
|
218
|
-
ingestComplianceDoc(canon, { notation: 'product', id: 'PRODUCT-2', name: 'Support' });
|
|
219
|
-
ingestComplianceDoc(canon, { notation: 'assertion', id: 'ASSERTION-OUT', about: 'REQ-3', subject: 'PRODUCT-2', status: 'compliant' });
|
|
220
|
-
const matrix = buildCoverageMatrix(canon, makeConfig({
|
|
221
|
-
regimes: { include: ['LAW-GDPR-1'] },
|
|
222
|
-
subjects: { products: ['PRODUCT-1'] },
|
|
223
|
-
}));
|
|
224
|
-
expect(matrix.rows[0].gap).toBe(1);
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
it('counts non_compliant separately', () => {
|
|
228
|
-
const canon = makeCanon();
|
|
229
|
-
ingestComplianceDoc(canon, { notation: 'assertion', id: 'ASSERTION-FAIL', about: 'REQ-3', subject: 'PRODUCT-1', status: 'non_compliant' });
|
|
230
|
-
const matrix = buildCoverageMatrix(canon, makeConfig());
|
|
231
|
-
expect(matrix.rows[0].non_compliant).toBe(1);
|
|
232
|
-
expect(matrix.rows[0].gap).toBe(0);
|
|
233
|
-
expect(matrix.rows[0].coveredCount).toBe(2);
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
it('counts pending_owner separately and does not include it in coveredCount', () => {
|
|
237
|
-
const canon = makeCanon();
|
|
238
|
-
ingestComplianceDoc(canon, { notation: 'assertion', id: 'ASSERTION-PO', about: 'REQ-3', subject: 'PRODUCT-1', status: 'pending_owner', owner_to_confirm: 'alice' });
|
|
239
|
-
const matrix = buildCoverageMatrix(canon, makeConfig());
|
|
240
|
-
expect(matrix.rows[0].pending_owner).toBe(1);
|
|
241
|
-
expect(matrix.rows[0].gap).toBe(0);
|
|
242
|
-
expect(matrix.rows[0].coveredCount).toBe(2);
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
// ── regimes.filter ───────────────────────────────────────────────────────────
|
|
246
|
-
|
|
247
|
-
it('resolves codex via regimes.filter.jurisdiction', () => {
|
|
248
|
-
const canon = makeCanon();
|
|
249
|
-
ingestComplianceDoc(canon, { id: 'LAW-CCPA-1', name: 'CCPA', zone: 'codex', jurisdiction: 'US' });
|
|
250
|
-
// regimes.filter: only EU laws → should return LAW-GDPR-1 only
|
|
251
|
-
const matrix = buildCoverageMatrix(canon, makeConfig({
|
|
252
|
-
regimes: { filter: { jurisdiction: ['EU'] } },
|
|
253
|
-
}));
|
|
254
|
-
expect(matrix.rows.every(r => r.codexId !== 'LAW-CCPA-1')).toBe(true);
|
|
255
|
-
expect(matrix.rows.some(r => r.codexId === 'LAW-GDPR-1')).toBe(true);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('resolves codex via regimes.filter.codex_type', () => {
|
|
259
|
-
const canon = emptyCanon();
|
|
260
|
-
ingestComplianceDoc(canon, { id: 'LAW-A', name: 'Regulation A', zone: 'codex', type: 'regulation' });
|
|
261
|
-
ingestComplianceDoc(canon, { id: 'LAW-B', name: 'Standard B', zone: 'codex', type: 'standard' });
|
|
262
|
-
const matrix = buildCoverageMatrix(canon, makeConfig({
|
|
263
|
-
regimes: { filter: { codex_type: ['regulation'] } },
|
|
264
|
-
}));
|
|
265
|
-
expect(matrix.rows.map(r => r.codexId)).toEqual(['LAW-A']);
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
// ── Zero-config: all canon codex entries ─────────────────────────────────────
|
|
269
|
-
|
|
270
|
-
it('zero-config (no regimes) enumerates all canon codex', () => {
|
|
271
|
-
const canon = makeCanon();
|
|
272
|
-
ingestComplianceDoc(canon, { id: 'LAW-NIS2-1', name: 'NIS2', zone: 'codex', jurisdiction: 'EU' });
|
|
273
|
-
const matrix = buildCoverageMatrix(canon, makeConfig({ regimes: undefined }));
|
|
274
|
-
expect(matrix.rows.map(r => r.codexId)).toContain('LAW-GDPR-1');
|
|
275
|
-
expect(matrix.rows.map(r => r.codexId)).toContain('LAW-NIS2-1');
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
// ── Backward compat: deprecated config still produces correct matrix ─────────
|
|
279
|
-
|
|
280
|
-
it('deprecated scope.codex via parseCoverageMetricConfig maps to correct matrix', () => {
|
|
281
|
-
const r = parseCoverageMetricConfig({
|
|
282
|
-
coverage_metric: {
|
|
283
|
-
id: 'CM-LEGACY',
|
|
284
|
-
name: 'Legacy',
|
|
285
|
-
scope: {
|
|
286
|
-
codex: ['LAW-GDPR-1'],
|
|
287
|
-
subjects: { products: ['PRODUCT-1'] },
|
|
288
|
-
},
|
|
289
|
-
thresholds: { green: 0.8, amber: 0.5 },
|
|
290
|
-
},
|
|
291
|
-
});
|
|
292
|
-
expect(r.ok).toBe(true);
|
|
293
|
-
if (r.ok) {
|
|
294
|
-
const matrix = buildCoverageMatrix(makeCanon(), r.config);
|
|
295
|
-
expect(matrix.rows).toHaveLength(1);
|
|
296
|
-
expect(matrix.rows[0].codexId).toBe('LAW-GDPR-1');
|
|
297
|
-
expect(matrix.rows[0].coveredCount).toBe(2);
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
});
|
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
// Conformance test for the NorthBay Retail EU compliance demo scenario
|
|
2
|
-
// (strategy hub #178). Validates that the demo data files load without errors,
|
|
3
|
-
// produce the expected matrix shape, and exercise all four compliance statuses.
|
|
4
|
-
|
|
5
|
-
import { describe, it, expect } from 'vitest';
|
|
6
|
-
import { readdirSync, readFileSync } from 'node:fs';
|
|
7
|
-
import { fileURLToPath } from 'node:url';
|
|
8
|
-
import path from 'node:path';
|
|
9
|
-
import yaml from 'js-yaml';
|
|
10
|
-
import { buildComplianceIndex } from '../reverse-index.js';
|
|
11
|
-
import { buildLawTree, buildProductView } from '../views.js';
|
|
12
|
-
import { buildGapReport } from '../gap-report.js';
|
|
13
|
-
import { parseImpactViewConfig, buildImpactMatrix } from '../impact.js';
|
|
14
|
-
import { emptyCanon, ingestComplianceDoc } from '../classify.js';
|
|
15
|
-
import type { IndexAssertion, IndexRequirement, ComplianceIndex } from '../types.js';
|
|
16
|
-
|
|
17
|
-
const EXAMPLES = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../../tests/fixtures/notation-corpus');
|
|
18
|
-
|
|
19
|
-
function loadYamlDir(dir: string): Record<string, unknown>[] {
|
|
20
|
-
const full = path.join(EXAMPLES, dir);
|
|
21
|
-
return readdirSync(full)
|
|
22
|
-
.filter(f => f.endsWith('.yaml'))
|
|
23
|
-
.map(f => yaml.load(readFileSync(path.join(full, f), 'utf-8')) as Record<string, unknown>);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
function loadYamlFile(relPath: string): unknown {
|
|
27
|
-
return yaml.load(readFileSync(path.join(EXAMPLES, relPath), 'utf-8'));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// ── Build the demo canon ─────────────────────────────────────────────────────
|
|
31
|
-
|
|
32
|
-
const requirements: IndexRequirement[] = loadYamlDir('compliance/requirements').map(r => ({
|
|
33
|
-
id: String(r.id),
|
|
34
|
-
name: String(r.name),
|
|
35
|
-
severity: r.severity as string | undefined,
|
|
36
|
-
derived_from: Array.isArray(r.derived_from) ? (r.derived_from as string[]) : undefined,
|
|
37
|
-
deadline: typeof r.deadline === 'string' ? r.deadline : undefined,
|
|
38
|
-
}));
|
|
39
|
-
|
|
40
|
-
const assertions: IndexAssertion[] = loadYamlDir('compliance/assertions').map(a => ({
|
|
41
|
-
id: String(a.id),
|
|
42
|
-
about: String(a.about),
|
|
43
|
-
subject: String(a.subject),
|
|
44
|
-
status: a.status as IndexAssertion['status'],
|
|
45
|
-
realised_via: Array.isArray(a.realised_via) ? (a.realised_via as string[]) : undefined,
|
|
46
|
-
assessed_at: typeof a.assessed_at === 'string' ? a.assessed_at : undefined,
|
|
47
|
-
next_review_at: typeof a.next_review_at === 'string' ? a.next_review_at : undefined,
|
|
48
|
-
evidenceCount: Array.isArray(a.evidence) ? (a.evidence as unknown[]).length : 0,
|
|
49
|
-
}));
|
|
50
|
-
|
|
51
|
-
const index: ComplianceIndex = buildComplianceIndex({ requirements, assertions });
|
|
52
|
-
|
|
53
|
-
// ── Demo data integrity ──────────────────────────────────────────────────────
|
|
54
|
-
|
|
55
|
-
describe('demo scenario — data integrity', () => {
|
|
56
|
-
it('loads 5 requirements from the demo scenario', () => {
|
|
57
|
-
expect(requirements).toHaveLength(5);
|
|
58
|
-
const ids = requirements.map(r => r.id).sort();
|
|
59
|
-
expect(ids).toEqual([
|
|
60
|
-
'REQUIREMENT-GDPR-CONSENT-1',
|
|
61
|
-
'REQUIREMENT-GDPR-DATA-ERASURE-1',
|
|
62
|
-
'REQUIREMENT-GDPR-PORTABILITY-1',
|
|
63
|
-
'REQUIREMENT-NIS2-INCIDENT-REPORT-1',
|
|
64
|
-
'REQUIREMENT-NIS2-SUPPLY-CHAIN-1',
|
|
65
|
-
]);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it('loads 5 assertions covering all four compliance statuses', () => {
|
|
69
|
-
expect(assertions).toHaveLength(5);
|
|
70
|
-
const statuses = assertions.map(a => a.status).sort();
|
|
71
|
-
expect(statuses).toContain('compliant');
|
|
72
|
-
expect(statuses).toContain('partial');
|
|
73
|
-
expect(statuses).toContain('non_compliant');
|
|
74
|
-
expect(statuses).toContain('under_review');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('requirements have deadline fields on 3 of 5', () => {
|
|
78
|
-
const withDeadline = requirements.filter(r => r.deadline != null);
|
|
79
|
-
expect(withDeadline).toHaveLength(3);
|
|
80
|
-
const ids = withDeadline.map(r => r.id).sort();
|
|
81
|
-
expect(ids).toEqual([
|
|
82
|
-
'REQUIREMENT-GDPR-CONSENT-1',
|
|
83
|
-
'REQUIREMENT-GDPR-DATA-ERASURE-1',
|
|
84
|
-
'REQUIREMENT-NIS2-INCIDENT-REPORT-1',
|
|
85
|
-
]);
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
it('REQUIREMENT-GDPR-DATA-ERASURE-1 has a past-due deadline', () => {
|
|
89
|
-
const req = requirements.find(r => r.id === 'REQUIREMENT-GDPR-DATA-ERASURE-1');
|
|
90
|
-
expect(req?.deadline).toBe('2025-12-31');
|
|
91
|
-
// 2025-12-31 is in the past relative to any 2026+ date
|
|
92
|
-
expect(req!.deadline! < '2026-01-01').toBe(true);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
// ── Single-law trees ─────────────────────────────────────────────────────────
|
|
97
|
-
|
|
98
|
-
describe('single-law tree — LAW-GDPR-1', () => {
|
|
99
|
-
const tree = buildLawTree('LAW-GDPR-1', index);
|
|
100
|
-
|
|
101
|
-
it('has 3 GDPR requirements', () => {
|
|
102
|
-
expect(tree.requirements).toHaveLength(3);
|
|
103
|
-
const ids = tree.requirements.map(r => r.requirement.id).sort();
|
|
104
|
-
expect(ids).toEqual([
|
|
105
|
-
'REQUIREMENT-GDPR-CONSENT-1',
|
|
106
|
-
'REQUIREMENT-GDPR-DATA-ERASURE-1',
|
|
107
|
-
'REQUIREMENT-GDPR-PORTABILITY-1',
|
|
108
|
-
]);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('erasure requirement has 2 assertions (one per product)', () => {
|
|
112
|
-
const erasure = tree.requirements.find(r => r.requirement.id === 'REQUIREMENT-GDPR-DATA-ERASURE-1');
|
|
113
|
-
expect(erasure).toBeDefined();
|
|
114
|
-
expect(erasure!.assertions).toHaveLength(2);
|
|
115
|
-
const statuses = erasure!.assertions.map(a => a.status).sort();
|
|
116
|
-
expect(statuses).toEqual(['compliant', 'non_compliant']);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('consent requirement has exactly one partial assertion', () => {
|
|
120
|
-
const consent = tree.requirements.find(r => r.requirement.id === 'REQUIREMENT-GDPR-CONSENT-1');
|
|
121
|
-
expect(consent!.assertions).toHaveLength(1);
|
|
122
|
-
expect(consent!.assertions[0].status).toBe('partial');
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it('portability requirement is compliant', () => {
|
|
126
|
-
const portability = tree.requirements.find(r => r.requirement.id === 'REQUIREMENT-GDPR-PORTABILITY-1');
|
|
127
|
-
expect(portability!.assertions).toHaveLength(1);
|
|
128
|
-
expect(portability!.assertions[0].status).toBe('compliant');
|
|
129
|
-
});
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
describe('single-law tree — LAW-NIS2-1', () => {
|
|
133
|
-
const tree = buildLawTree('LAW-NIS2-1', index);
|
|
134
|
-
|
|
135
|
-
it('has 2 NIS2 requirements', () => {
|
|
136
|
-
expect(tree.requirements).toHaveLength(2);
|
|
137
|
-
const ids = tree.requirements.map(r => r.requirement.id).sort();
|
|
138
|
-
expect(ids).toEqual([
|
|
139
|
-
'REQUIREMENT-NIS2-INCIDENT-REPORT-1',
|
|
140
|
-
'REQUIREMENT-NIS2-SUPPLY-CHAIN-1',
|
|
141
|
-
]);
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
it('incident-report requirement has one under_review assertion', () => {
|
|
145
|
-
const incident = tree.requirements.find(r => r.requirement.id === 'REQUIREMENT-NIS2-INCIDENT-REPORT-1');
|
|
146
|
-
expect(incident!.assertions).toHaveLength(1);
|
|
147
|
-
expect(incident!.assertions[0].status).toBe('under_review');
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
it('supply-chain requirement has no assertions — deliberate gap', () => {
|
|
151
|
-
const supplyChain = tree.requirements.find(r => r.requirement.id === 'REQUIREMENT-NIS2-SUPPLY-CHAIN-1');
|
|
152
|
-
expect(supplyChain!.assertions).toHaveLength(0);
|
|
153
|
-
});
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
// ── Single-product views ─────────────────────────────────────────────────────
|
|
157
|
-
|
|
158
|
-
describe('single-product view — PRODUCT-ECOMM-1', () => {
|
|
159
|
-
const view = buildProductView('PRODUCT-ECOMM-1', index);
|
|
160
|
-
|
|
161
|
-
it('covers 4 requirements (4 assertions with PRODUCT-ECOMM-1 as subject)', () => {
|
|
162
|
-
expect(view.requirements).toHaveLength(4);
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
it('includes non_compliant erasure status', () => {
|
|
166
|
-
const erasure = view.requirements.find(r => r.requirement.id === 'REQUIREMENT-GDPR-DATA-ERASURE-1');
|
|
167
|
-
expect(erasure).toBeDefined();
|
|
168
|
-
expect(erasure!.assertion.status).toBe('non_compliant');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
describe('single-product view — PRODUCT-SUPPORT-1', () => {
|
|
173
|
-
const view = buildProductView('PRODUCT-SUPPORT-1', index);
|
|
174
|
-
|
|
175
|
-
it('has exactly 1 assertion (erasure only)', () => {
|
|
176
|
-
expect(view.requirements).toHaveLength(1);
|
|
177
|
-
expect(view.requirements[0].requirement.id).toBe('REQUIREMENT-GDPR-DATA-ERASURE-1');
|
|
178
|
-
expect(view.requirements[0].assertion.status).toBe('compliant');
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
// ── Gap report ───────────────────────────────────────────────────────────────
|
|
183
|
-
|
|
184
|
-
describe('gap report', () => {
|
|
185
|
-
const today = '2026-06-10';
|
|
186
|
-
const report = buildGapReport(index, { today });
|
|
187
|
-
|
|
188
|
-
it('NIS2 supply-chain requirement appears in requirements-without-assertions', () => {
|
|
189
|
-
const gap = report.requirementsWithoutAssertions.find(
|
|
190
|
-
r => r.id === 'REQUIREMENT-NIS2-SUPPLY-CHAIN-1',
|
|
191
|
-
);
|
|
192
|
-
expect(gap).toBeDefined();
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it('non_compliant erasure requirement is NOT in requirements-without-assertions', () => {
|
|
196
|
-
const gap = report.requirementsWithoutAssertions.find(
|
|
197
|
-
r => r.id === 'REQUIREMENT-GDPR-DATA-ERASURE-1',
|
|
198
|
-
);
|
|
199
|
-
expect(gap).toBeUndefined();
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('erasure requirement is NOT in pastDeadlineRequirements — it has a compliant assertion for PRODUCT-SUPPORT-1', () => {
|
|
203
|
-
// buildGapReport only surfaces a past-deadline req when ALL its assertions
|
|
204
|
-
// are non-compliant. PRODUCT-SUPPORT-1 has a compliant assertion for erasure,
|
|
205
|
-
// so the requirement is excluded from the past-deadline gap list even though
|
|
206
|
-
// PRODUCT-ECOMM-1 is non_compliant.
|
|
207
|
-
const overdue = report.pastDeadlineRequirements.find(
|
|
208
|
-
r => r.id === 'REQUIREMENT-GDPR-DATA-ERASURE-1',
|
|
209
|
-
);
|
|
210
|
-
expect(overdue).toBeUndefined();
|
|
211
|
-
});
|
|
212
|
-
});
|
|
213
|
-
|
|
214
|
-
// ── Compliance-impact view-config ────────────────────────────────────────────
|
|
215
|
-
|
|
216
|
-
describe('compliance-impact view-config — gdpr-nis2', () => {
|
|
217
|
-
const raw = loadYamlFile('compliance-impact/gdpr-nis2.compliance-impact.view.yaml');
|
|
218
|
-
const result = parseImpactViewConfig(raw);
|
|
219
|
-
|
|
220
|
-
it('parses without errors', () => {
|
|
221
|
-
expect(result.ok).toBe(true);
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
it('scopes to PRODUCT-ECOMM-1 and PRODUCT-SUPPORT-1', () => {
|
|
225
|
-
if (!result.ok) throw new Error('parse failed');
|
|
226
|
-
expect(result.config.subjects.products).toEqual(['PRODUCT-ECOMM-1', 'PRODUCT-SUPPORT-1']);
|
|
227
|
-
});
|
|
228
|
-
|
|
229
|
-
it('filters obligations to LAW-GDPR-1 and LAW-NIS2-1', () => {
|
|
230
|
-
if (!result.ok) throw new Error('parse failed');
|
|
231
|
-
expect(result.config.obligations.filter?.derived_from_codex).toEqual(['LAW-GDPR-1', 'LAW-NIS2-1']);
|
|
232
|
-
});
|
|
233
|
-
|
|
234
|
-
it('builds a matrix with 2 products and 5 requirements scoped to the two laws', () => {
|
|
235
|
-
if (!result.ok) throw new Error('parse failed');
|
|
236
|
-
|
|
237
|
-
// Build the canon using ingestComplianceDoc (same path as the Studio extension).
|
|
238
|
-
const canon = emptyCanon();
|
|
239
|
-
for (const r of loadYamlDir('compliance/requirements')) ingestComplianceDoc(canon, r);
|
|
240
|
-
for (const a of loadYamlDir('compliance/assertions')) ingestComplianceDoc(canon, a);
|
|
241
|
-
// Add the two products.
|
|
242
|
-
canon.products.push({ id: 'PRODUCT-ECOMM-1', name: 'E-Commerce Platform' });
|
|
243
|
-
canon.products.push({ id: 'PRODUCT-SUPPORT-1', name: 'Customer Support Service' });
|
|
244
|
-
|
|
245
|
-
const matrix = buildImpactMatrix(canon, result.config);
|
|
246
|
-
expect(matrix.columns).toHaveLength(2);
|
|
247
|
-
// 5 requirements are split: 3 GDPR + 2 NIS2 — all 5 should appear.
|
|
248
|
-
expect(matrix.rows).toHaveLength(5);
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
// ── Regression: existing worked examples unaffected ─────────────────────────
|
|
253
|
-
|
|
254
|
-
describe('regression — existing tests/fixtures/notation-corpus/requirement + tests/fixtures/notation-corpus/assertion unchanged', () => {
|
|
255
|
-
const reqs: IndexRequirement[] = loadYamlDir('requirement').map(r => ({
|
|
256
|
-
id: String(r.id),
|
|
257
|
-
name: String(r.name),
|
|
258
|
-
derived_from: Array.isArray(r.derived_from) ? (r.derived_from as string[]) : undefined,
|
|
259
|
-
}));
|
|
260
|
-
const asns: IndexAssertion[] = loadYamlDir('assertion').map(a => ({
|
|
261
|
-
id: String(a.id),
|
|
262
|
-
about: String(a.about),
|
|
263
|
-
subject: String(a.subject),
|
|
264
|
-
status: a.status as IndexAssertion['status'],
|
|
265
|
-
}));
|
|
266
|
-
const idx = buildComplianceIndex({ requirements: reqs, assertions: asns });
|
|
267
|
-
|
|
268
|
-
it('original LAW-PERSONAL-DATA-2017-1 tree still resolves correctly', () => {
|
|
269
|
-
const tree = buildLawTree('LAW-PERSONAL-DATA-2017-1', idx);
|
|
270
|
-
expect(tree.requirements.map(r => r.requirement.id)).toEqual(['REQUIREMENT-DATA-ERASURE-1']);
|
|
271
|
-
expect(tree.requirements[0].assertions).toHaveLength(3);
|
|
272
|
-
});
|
|
273
|
-
});
|