@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.
Files changed (247) hide show
  1. package/package.json +7 -2
  2. package/dist/__tests__/edge-path.test.d.ts +0 -1
  3. package/dist/__tests__/edge-path.test.js +0 -55
  4. package/dist/__tests__/node-size-presets.test.d.ts +0 -1
  5. package/dist/__tests__/node-size-presets.test.js +0 -30
  6. package/dist/__tests__/scope.test.d.ts +0 -1
  7. package/dist/__tests__/scope.test.js +0 -23
  8. package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
  9. package/dist/__tests__/yaml-normalize.test.js +0 -148
  10. package/dist/activities/__tests__/cpm.test.d.ts +0 -1
  11. package/dist/activities/__tests__/cpm.test.js +0 -146
  12. package/dist/activities/__tests__/gantt.test.d.ts +0 -1
  13. package/dist/activities/__tests__/gantt.test.js +0 -263
  14. package/dist/activities/__tests__/layout.test.d.ts +0 -1
  15. package/dist/activities/__tests__/layout.test.js +0 -98
  16. package/dist/activities/__tests__/validate.test.d.ts +0 -1
  17. package/dist/activities/__tests__/validate.test.js +0 -397
  18. package/dist/activity-card/__tests__/example.test.d.ts +0 -1
  19. package/dist/activity-card/__tests__/example.test.js +0 -73
  20. package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
  21. package/dist/activity-card/__tests__/layout.test.js +0 -141
  22. package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
  23. package/dist/activity-card/__tests__/resolver.test.js +0 -325
  24. package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
  25. package/dist/activity-card/__tests__/validate.test.js +0 -149
  26. package/dist/actor/__tests__/validate.test.d.ts +0 -1
  27. package/dist/actor/__tests__/validate.test.js +0 -95
  28. package/dist/applications/__tests__/validate.test.d.ts +0 -1
  29. package/dist/applications/__tests__/validate.test.js +0 -223
  30. package/dist/assertion/__tests__/example.test.d.ts +0 -1
  31. package/dist/assertion/__tests__/example.test.js +0 -32
  32. package/dist/assertion/__tests__/validate.test.d.ts +0 -1
  33. package/dist/assertion/__tests__/validate.test.js +0 -130
  34. package/dist/blocks/__tests__/layout.test.d.ts +0 -1
  35. package/dist/blocks/__tests__/layout.test.js +0 -153
  36. package/dist/blocks/__tests__/validate.test.d.ts +0 -1
  37. package/dist/blocks/__tests__/validate.test.js +0 -235
  38. package/dist/business-service/__tests__/validate.test.d.ts +0 -1
  39. package/dist/business-service/__tests__/validate.test.js +0 -135
  40. package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
  41. package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
  42. package/dist/capability-map/__tests__/address.test.d.ts +0 -1
  43. package/dist/capability-map/__tests__/address.test.js +0 -49
  44. package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
  45. package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
  46. package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
  47. package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
  48. package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
  49. package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
  50. package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
  51. package/dist/capability-map/__tests__/validate.test.js +0 -212
  52. package/dist/change/__tests__/validate.test.d.ts +0 -1
  53. package/dist/change/__tests__/validate.test.js +0 -79
  54. package/dist/codex/__tests__/example.test.d.ts +0 -1
  55. package/dist/codex/__tests__/example.test.js +0 -33
  56. package/dist/codex/__tests__/validate.test.d.ts +0 -1
  57. package/dist/codex/__tests__/validate.test.js +0 -68
  58. package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
  59. package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
  60. package/dist/compliance/__tests__/classify.test.d.ts +0 -1
  61. package/dist/compliance/__tests__/classify.test.js +0 -58
  62. package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
  63. package/dist/compliance/__tests__/confidence.test.js +0 -78
  64. package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
  65. package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
  66. package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
  67. package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
  68. package/dist/compliance/__tests__/example.test.d.ts +0 -1
  69. package/dist/compliance/__tests__/example.test.js +0 -51
  70. package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
  71. package/dist/compliance/__tests__/gap-report.test.js +0 -113
  72. package/dist/compliance/__tests__/html.test.d.ts +0 -1
  73. package/dist/compliance/__tests__/html.test.js +0 -122
  74. package/dist/compliance/__tests__/impact.test.d.ts +0 -1
  75. package/dist/compliance/__tests__/impact.test.js +0 -913
  76. package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
  77. package/dist/compliance/__tests__/markdown.test.js +0 -85
  78. package/dist/compliance/__tests__/trace.test.d.ts +0 -1
  79. package/dist/compliance/__tests__/trace.test.js +0 -144
  80. package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
  81. package/dist/compliance/__tests__/view-resolution.test.js +0 -59
  82. package/dist/compliance/__tests__/views.test.d.ts +0 -1
  83. package/dist/compliance/__tests__/views.test.js +0 -59
  84. package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
  85. package/dist/compliance-matrix/__tests__/build.test.js +0 -183
  86. package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
  87. package/dist/compliance-matrix/__tests__/example.test.js +0 -49
  88. package/dist/confidence/__tests__/score.test.d.ts +0 -1
  89. package/dist/confidence/__tests__/score.test.js +0 -188
  90. package/dist/constraint/__tests__/example.test.d.ts +0 -1
  91. package/dist/constraint/__tests__/example.test.js +0 -14
  92. package/dist/constraint/__tests__/validate.test.d.ts +0 -1
  93. package/dist/constraint/__tests__/validate.test.js +0 -58
  94. package/dist/factor/__tests__/validate.test.d.ts +0 -1
  95. package/dist/factor/__tests__/validate.test.js +0 -112
  96. package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
  97. package/dist/fgca/__tests__/chain-table.test.js +0 -158
  98. package/dist/fgca/__tests__/layout.test.d.ts +0 -1
  99. package/dist/fgca/__tests__/layout.test.js +0 -140
  100. package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
  101. package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
  102. package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
  103. package/dist/fgca/__tests__/preview-layout.test.js +0 -106
  104. package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
  105. package/dist/fgca/__tests__/resolver.test.js +0 -185
  106. package/dist/fgca/__tests__/validate.test.d.ts +0 -1
  107. package/dist/fgca/__tests__/validate.test.js +0 -125
  108. package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
  109. package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
  110. package/dist/goals/__tests__/layout.test.d.ts +0 -1
  111. package/dist/goals/__tests__/layout.test.js +0 -153
  112. package/dist/goals/__tests__/mutations.test.d.ts +0 -1
  113. package/dist/goals/__tests__/mutations.test.js +0 -134
  114. package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
  115. package/dist/goals/__tests__/parse-canonical.test.js +0 -131
  116. package/dist/goals/__tests__/validate.test.d.ts +0 -1
  117. package/dist/goals/__tests__/validate.test.js +0 -183
  118. package/dist/integration/__tests__/validate.test.d.ts +0 -1
  119. package/dist/integration/__tests__/validate.test.js +0 -169
  120. package/dist/location/__tests__/validate.test.d.ts +0 -1
  121. package/dist/location/__tests__/validate.test.js +0 -107
  122. package/dist/node/__tests__/validate.test.d.ts +0 -1
  123. package/dist/node/__tests__/validate.test.js +0 -100
  124. package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
  125. package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
  126. package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
  127. package/dist/process-blueprint/__tests__/layout.test.js +0 -196
  128. package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
  129. package/dist/process-blueprint/__tests__/validate.test.js +0 -280
  130. package/dist/process-map/__tests__/validate.test.d.ts +0 -1
  131. package/dist/process-map/__tests__/validate.test.js +0 -199
  132. package/dist/products/__tests__/validate.test.d.ts +0 -1
  133. package/dist/products/__tests__/validate.test.js +0 -210
  134. package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
  135. package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
  136. package/dist/requirement/__tests__/example.test.d.ts +0 -1
  137. package/dist/requirement/__tests__/example.test.js +0 -21
  138. package/dist/requirement/__tests__/validate.test.d.ts +0 -1
  139. package/dist/requirement/__tests__/validate.test.js +0 -80
  140. package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
  141. package/dist/scenarios/__tests__/validate.test.js +0 -183
  142. package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
  143. package/dist/stakeholder/__tests__/validate.test.js +0 -88
  144. package/dist/target-state/__tests__/validate.test.d.ts +0 -1
  145. package/dist/target-state/__tests__/validate.test.js +0 -78
  146. package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
  147. package/dist/technology-service/__tests__/validate.test.js +0 -121
  148. package/dist/theme/__tests__/tokens.test.d.ts +0 -1
  149. package/dist/theme/__tests__/tokens.test.js +0 -159
  150. package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
  151. package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
  152. package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
  153. package/dist/webview/__tests__/entry-notations.test.js +0 -62
  154. package/dist/webview/__tests__/entry.test.d.ts +0 -1
  155. package/dist/webview/__tests__/entry.test.js +0 -56
  156. package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
  157. package/dist/webview/__tests__/render-activities.test.js +0 -91
  158. package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
  159. package/dist/webview/__tests__/render-blocks.test.js +0 -175
  160. package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
  161. package/dist/webview/__tests__/render-goals.test.js +0 -120
  162. package/dist/webview/__tests__/render-process.test.d.ts +0 -1
  163. package/dist/webview/__tests__/render-process.test.js +0 -463
  164. package/dist/webview/__tests__/render-util.test.d.ts +0 -1
  165. package/dist/webview/__tests__/render-util.test.js +0 -54
  166. package/src/__tests__/edge-path.test.ts +0 -67
  167. package/src/__tests__/node-size-presets.test.ts +0 -50
  168. package/src/__tests__/scope.test.ts +0 -27
  169. package/src/__tests__/yaml-normalize.test.ts +0 -158
  170. package/src/activities/__tests__/cpm.test.ts +0 -164
  171. package/src/activities/__tests__/gantt.test.ts +0 -290
  172. package/src/activities/__tests__/layout.test.ts +0 -112
  173. package/src/activities/__tests__/validate.test.ts +0 -446
  174. package/src/activity-card/__tests__/example.test.ts +0 -83
  175. package/src/activity-card/__tests__/layout.test.ts +0 -162
  176. package/src/activity-card/__tests__/resolver.test.ts +0 -357
  177. package/src/activity-card/__tests__/validate.test.ts +0 -167
  178. package/src/actor/__tests__/validate.test.ts +0 -114
  179. package/src/applications/__tests__/validate.test.ts +0 -256
  180. package/src/assertion/__tests__/example.test.ts +0 -37
  181. package/src/assertion/__tests__/validate.test.ts +0 -142
  182. package/src/blocks/__tests__/layout.test.ts +0 -169
  183. package/src/blocks/__tests__/validate.test.ts +0 -260
  184. package/src/business-service/__tests__/validate.test.ts +0 -160
  185. package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
  186. package/src/capability-map/__tests__/address.test.ts +0 -59
  187. package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
  188. package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
  189. package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
  190. package/src/capability-map/__tests__/validate.test.ts +0 -238
  191. package/src/change/__tests__/validate.test.ts +0 -97
  192. package/src/codex/__tests__/example.test.ts +0 -40
  193. package/src/codex/__tests__/validate.test.ts +0 -84
  194. package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
  195. package/src/compliance/__tests__/classify.test.ts +0 -64
  196. package/src/compliance/__tests__/confidence.test.ts +0 -98
  197. package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
  198. package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
  199. package/src/compliance/__tests__/example.test.ts +0 -57
  200. package/src/compliance/__tests__/gap-report.test.ts +0 -129
  201. package/src/compliance/__tests__/html.test.ts +0 -142
  202. package/src/compliance/__tests__/impact.test.ts +0 -1060
  203. package/src/compliance/__tests__/markdown.test.ts +0 -95
  204. package/src/compliance/__tests__/trace.test.ts +0 -157
  205. package/src/compliance/__tests__/view-resolution.test.ts +0 -80
  206. package/src/compliance/__tests__/views.test.ts +0 -64
  207. package/src/compliance-matrix/__tests__/build.test.ts +0 -200
  208. package/src/compliance-matrix/__tests__/example.test.ts +0 -57
  209. package/src/confidence/__tests__/score.test.ts +0 -254
  210. package/src/constraint/__tests__/example.test.ts +0 -19
  211. package/src/constraint/__tests__/validate.test.ts +0 -68
  212. package/src/factor/__tests__/validate.test.ts +0 -133
  213. package/src/fgca/__tests__/chain-table.test.ts +0 -172
  214. package/src/fgca/__tests__/layout.test.ts +0 -179
  215. package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
  216. package/src/fgca/__tests__/preview-layout.test.ts +0 -124
  217. package/src/fgca/__tests__/resolver.test.ts +0 -209
  218. package/src/fgca/__tests__/validate.test.ts +0 -142
  219. package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
  220. package/src/goals/__tests__/layout.test.ts +0 -175
  221. package/src/goals/__tests__/mutations.test.ts +0 -153
  222. package/src/goals/__tests__/parse-canonical.test.ts +0 -147
  223. package/src/goals/__tests__/validate.test.ts +0 -202
  224. package/src/integration/__tests__/validate.test.ts +0 -203
  225. package/src/location/__tests__/validate.test.ts +0 -127
  226. package/src/node/__tests__/validate.test.ts +0 -118
  227. package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
  228. package/src/process-blueprint/__tests__/layout.test.ts +0 -240
  229. package/src/process-blueprint/__tests__/validate.test.ts +0 -310
  230. package/src/process-map/__tests__/validate.test.ts +0 -223
  231. package/src/products/__tests__/validate.test.ts +0 -239
  232. package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
  233. package/src/requirement/__tests__/example.test.ts +0 -24
  234. package/src/requirement/__tests__/validate.test.ts +0 -96
  235. package/src/scenarios/__tests__/validate.test.ts +0 -209
  236. package/src/stakeholder/__tests__/validate.test.ts +0 -105
  237. package/src/target-state/__tests__/validate.test.ts +0 -95
  238. package/src/technology-service/__tests__/validate.test.ts +0 -143
  239. package/src/theme/__tests__/tokens.test.ts +0 -185
  240. package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
  241. package/src/webview/__tests__/entry-notations.test.ts +0 -77
  242. package/src/webview/__tests__/entry.test.ts +0 -64
  243. package/src/webview/__tests__/render-activities.test.ts +0 -100
  244. package/src/webview/__tests__/render-blocks.test.ts +0 -206
  245. package/src/webview/__tests__/render-goals.test.ts +0 -128
  246. package/src/webview/__tests__/render-process.test.ts +0 -538
  247. package/src/webview/__tests__/render-util.test.ts +0 -66
@@ -1 +0,0 @@
1
- export {};
@@ -1,85 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { readdirSync, readFileSync } from 'node:fs';
3
- import { fileURLToPath } from 'node:url';
4
- import path from 'node:path';
5
- import yaml from 'js-yaml';
6
- import { renderComplianceMarkdown } from '../markdown.js';
7
- import { emptyCanon, ingestComplianceDoc } from '../classify.js';
8
- function synthetic() {
9
- const canon = emptyCanon();
10
- ingestComplianceDoc(canon, { notation: 'product', id: 'PRODUCT-M-1', name: 'Mobile App' });
11
- ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQUIREMENT-ERASURE-1', name: 'Erasure', severity: 'high', derived_from: ['LAW-X-1'] });
12
- ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQUIREMENT-LOG-1', name: 'Logs', severity: 'low' });
13
- ingestComplianceDoc(canon, { notation: 'assertion', id: 'ASSERTION-1', about: 'REQUIREMENT-ERASURE-1', subject: 'PRODUCT-M-1', status: 'compliant', evidence: [{ kind: 'note', text: 'x' }], next_review_at: '2026-09-01' });
14
- ingestComplianceDoc(canon, { id: 'LAW-X-1', name: 'Privacy Law', zone: 'codex', type: 'LAW' });
15
- return canon;
16
- }
17
- describe('renderComplianceMarkdown — matrix', () => {
18
- it('renders a table with status cells and gap dashes', () => {
19
- const md = renderComplianceMarkdown(synthetic(), { mode: 'matrix' });
20
- expect(md).toContain('# Compliance Matrix');
21
- expect(md).toContain('| Product \\ Requirement | Erasure | Logs |');
22
- expect(md).toMatch(/\| Mobile App \| Compliant \| — \|/);
23
- });
24
- });
25
- describe('renderComplianceMarkdown — law', () => {
26
- it('renders the law name and its requirement with the assertion bullet', () => {
27
- const md = renderComplianceMarkdown(synthetic(), { mode: 'law', id: 'LAW-X-1' });
28
- expect(md).toContain('# Compliance — Privacy Law');
29
- expect(md).toContain('## Erasure (`REQUIREMENT-ERASURE-1`) — severity: high');
30
- expect(md).toContain('- **Compliant** — `ASSERTION-1`');
31
- });
32
- });
33
- describe('renderComplianceMarkdown — product', () => {
34
- it('renders the product table of asserted requirements', () => {
35
- const md = renderComplianceMarkdown(synthetic(), { mode: 'product', id: 'PRODUCT-M-1' });
36
- expect(md).toContain('# Compliance — Mobile App');
37
- expect(md).toContain('| Requirement | Status | Assertion | Next review |');
38
- expect(md).toMatch(/\| Erasure \(`REQUIREMENT-ERASURE-1`\) \| Compliant \| `ASSERTION-1` \| 2026-09-01 \|/);
39
- });
40
- });
41
- describe('renderComplianceMarkdown — gap', () => {
42
- it('lists the un-asserted requirement as a checklist item', () => {
43
- const md = renderComplianceMarkdown(synthetic(), { mode: 'gap' }, { today: '2026-06-02' });
44
- expect(md).toContain('## Requirements without assertions (1)');
45
- expect(md).toContain('- [ ] `REQUIREMENT-LOG-1` Logs — severity: low');
46
- expect(md).toContain('## Assertions without evidence — ASSERT-007 (0)');
47
- });
48
- });
49
- // ── Conformance: build canon by ingesting the acme example files ────────────
50
- const examples = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../../tests/fixtures/notation-corpus');
51
- function ingestDir(canon, dir) {
52
- const full = path.join(examples, dir);
53
- for (const f of readdirSync(full)) {
54
- if (!f.endsWith('.yaml'))
55
- continue;
56
- ingestComplianceDoc(canon, yaml.load(readFileSync(path.join(full, f), 'utf-8')));
57
- }
58
- }
59
- describe('renderComplianceMarkdown — acme conformance', () => {
60
- const canon = emptyCanon();
61
- ingestDir(canon, 'product');
62
- ingestDir(canon, 'requirement');
63
- ingestDir(canon, 'assertion');
64
- it('matrix marks the dangling PRODUCT-MOBILE-1 row and shows compliant + gaps', () => {
65
- const md = renderComplianceMarkdown(canon, { mode: 'matrix' });
66
- expect(md).toContain('PRODUCT-MOBILE-1 ⚠');
67
- expect(md).toContain('Compliant');
68
- expect(md).toContain('—'); // at least one gap dash
69
- });
70
- it('gap report surfaces the un-asserted audit-log requirement', () => {
71
- const md = renderComplianceMarkdown(canon, { mode: 'gap' }, { today: '2026-06-02' });
72
- expect(md).toContain('`REQUIREMENT-AUDIT-LOG-RETENTION-1`');
73
- });
74
- });
75
- describe('gapMarkdown CV-5 pastDeadlineRequirements section', () => {
76
- it('includes the 4th section in output', () => {
77
- const canon = emptyCanon();
78
- ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQ-PD-1', name: 'Past', deadline: '2020-01-01' });
79
- const md = renderComplianceMarkdown(canon, { mode: 'gap' }, { today: '2026-06-09' });
80
- expect(md).toContain('Past-deadline requirements');
81
- expect(md).toContain('REQ-PD-1');
82
- expect(md).toContain('2020-01-01');
83
- expect(md).toContain('4 checks');
84
- });
85
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,144 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { buildComplianceIndex } from '../reverse-index.js';
3
- import { buildRequirementTrace, buildTraceElementCatalog } from '../trace.js';
4
- // Requirement traceability + hierarchy view.
5
- //
6
- // The two halves the view exposes:
7
- // 1. Trace chain — derived_from → REQUIREMENT → ASSERTION → subject +
8
- // realised_via.
9
- // 2. Hierarchy — parent chain + children via the `parent` field
10
- // (15-requirement.md §2.4 / ELEMENT_PRIMITIVES.md §7.13).
11
- const input = {
12
- requirements: [
13
- // A broad legislative parent decomposed into two child requirements.
14
- { id: 'REQUIREMENT-DATA-PROTECTION-1', name: 'Personal-data protection', origin: 'legislative', derived_from: ['REGULATION-GDPR-2016-1'], element_kind: 'requirement' },
15
- { id: 'REQUIREMENT-DATA-ERASURE-1', name: 'Erase on request within 30 days', origin: 'legislative', parent: 'REQUIREMENT-DATA-PROTECTION-1', derived_from: ['REGULATION-GDPR-2016-1'], element_kind: 'requirement' },
16
- { id: 'REQUIREMENT-DATA-CONSENT-1', name: 'Obtain consent before processing', origin: 'legislative', parent: 'REQUIREMENT-DATA-PROTECTION-1', element_kind: 'requirement' },
17
- // A process-product sub-requirement below the erasure duty (cross-origin).
18
- { id: 'REQUIREMENT-ERASURE-SLA-1', name: 'Erasure SOP — 30d target', origin: 'process-product', parent: 'REQUIREMENT-DATA-ERASURE-1', element_kind: 'requirement' },
19
- // Constraint hierarchy (mirror pattern).
20
- { id: 'CONSTRAINT-EEA-TRANSFER-1', name: 'No transfer outside EEA without safeguards', element_kind: 'constraint' },
21
- { id: 'CONSTRAINT-EEA-ANALYTICS-1', name: 'No PII in analytics logs', parent: 'CONSTRAINT-EEA-TRANSFER-1', element_kind: 'constraint' },
22
- // Internal-only requirement — no source, no parent — for the empty-case sanity check.
23
- { id: 'REQUIREMENT-INTERNAL-1', name: 'Internal-only', element_kind: 'requirement' },
24
- ],
25
- assertions: [
26
- { id: 'ASSERTION-1', about: 'REQUIREMENT-DATA-ERASURE-1', subject: 'PRODUCT-MOBILE-1', realised_via: ['CAPABILITY-V1', 'PROCESS-PURGE-1'], status: 'compliant' },
27
- { id: 'ASSERTION-2', about: 'REQUIREMENT-DATA-ERASURE-1', subject: 'PRODUCT-WEB-1', status: 'partial' },
28
- { id: 'ASSERTION-3', about: 'REQUIREMENT-DATA-CONSENT-1', subject: 'PRODUCT-WEB-1', status: 'compliant' },
29
- ],
30
- };
31
- const codex = [
32
- { id: 'REGULATION-GDPR-2016-1', name: 'GDPR', type: 'REGULATION', jurisdiction: 'EU' },
33
- ];
34
- const catalog = buildTraceElementCatalog([{ id: 'PRODUCT-MOBILE-1', name: 'Mobile app' }, { id: 'PRODUCT-WEB-1', name: 'Web app' }], [{ id: 'CAPABILITY-V1', name: 'Erasure capability v1' }, { id: 'PROCESS-PURGE-1', name: 'Purge process' }]);
35
- describe('buildComplianceIndex — requirementsByParent', () => {
36
- const idx = buildComplianceIndex(input);
37
- it('groups children of the same parent', () => {
38
- const children = idx.requirementsByParent.get('REQUIREMENT-DATA-PROTECTION-1');
39
- expect(children?.map(r => r.id).sort()).toEqual(['REQUIREMENT-DATA-CONSENT-1', 'REQUIREMENT-DATA-ERASURE-1']);
40
- });
41
- it('groups CONSTRAINT children the same way (element_kind-agnostic)', () => {
42
- const children = idx.requirementsByParent.get('CONSTRAINT-EEA-TRANSFER-1');
43
- expect(children?.map(r => r.id)).toEqual(['CONSTRAINT-EEA-ANALYTICS-1']);
44
- });
45
- it('returns undefined for a leaf with no children', () => {
46
- expect(idx.requirementsByParent.has('REQUIREMENT-INTERNAL-1')).toBe(false);
47
- });
48
- });
49
- describe('buildRequirementTrace — trace chain', () => {
50
- const idx = buildComplianceIndex(input);
51
- it('resolves derived_from codex artefacts on the sources block', () => {
52
- const trace = buildRequirementTrace('REQUIREMENT-DATA-ERASURE-1', idx, catalog, codex);
53
- expect(trace.sources).toHaveLength(1);
54
- expect(trace.sources[0].id).toBe('REGULATION-GDPR-2016-1');
55
- expect(trace.sources[0].codex?.jurisdiction).toBe('EU');
56
- });
57
- it('keeps a dangling derived_from ref with no codex when the artefact is missing', () => {
58
- const local = {
59
- requirements: [{ id: 'REQUIREMENT-X-1', name: 'X', derived_from: ['LAW-MISSING-1'] }],
60
- assertions: [],
61
- };
62
- const trace = buildRequirementTrace('REQUIREMENT-X-1', buildComplianceIndex(local), catalog);
63
- expect(trace.sources).toEqual([{ id: 'LAW-MISSING-1' }]);
64
- });
65
- it('lists ASSERTIONs id-sorted, each with resolved subject + realised_via names', () => {
66
- const trace = buildRequirementTrace('REQUIREMENT-DATA-ERASURE-1', idx, catalog, codex);
67
- expect(trace.assertions.map(a => a.assertion.id)).toEqual(['ASSERTION-1', 'ASSERTION-2']);
68
- expect(trace.assertions[0].subject).toEqual({ id: 'PRODUCT-MOBILE-1', name: 'Mobile app' });
69
- expect(trace.assertions[0].realisedVia.map(r => r.name)).toEqual(['Erasure capability v1', 'Purge process']);
70
- });
71
- it('returns an empty assertions list for a REQUIREMENT with no filed claim', () => {
72
- const trace = buildRequirementTrace('REQUIREMENT-DATA-PROTECTION-1', idx, catalog);
73
- expect(trace.assertions).toEqual([]);
74
- });
75
- it('returns an empty assertions list for a CONSTRAINT (16-assertion.md §1 — CONSTRAINT-side out of v1)', () => {
76
- const trace = buildRequirementTrace('CONSTRAINT-EEA-TRANSFER-1', idx, catalog);
77
- expect(trace.assertions).toEqual([]);
78
- });
79
- it('falls back to id when the subject / realised_via element is not in the catalog (dangling ref)', () => {
80
- const local = {
81
- requirements: [{ id: 'REQUIREMENT-Y-1', name: 'Y' }],
82
- assertions: [{ id: 'ASSERTION-9', about: 'REQUIREMENT-Y-1', subject: 'PRODUCT-GONE-1', realised_via: ['CAPABILITY-GONE-1'], status: 'n_a' }],
83
- };
84
- const trace = buildRequirementTrace('REQUIREMENT-Y-1', buildComplianceIndex(local), catalog);
85
- expect(trace.assertions[0].subject).toEqual({ id: 'PRODUCT-GONE-1' });
86
- expect(trace.assertions[0].realisedVia).toEqual([{ id: 'CAPABILITY-GONE-1' }]);
87
- });
88
- });
89
- describe('buildRequirementTrace — hierarchy', () => {
90
- const idx = buildComplianceIndex(input);
91
- it('walks ancestors: immediate parent first, root last', () => {
92
- const trace = buildRequirementTrace('REQUIREMENT-ERASURE-SLA-1', idx, catalog);
93
- expect(trace.ancestors.map(r => r.id)).toEqual([
94
- 'REQUIREMENT-DATA-ERASURE-1',
95
- 'REQUIREMENT-DATA-PROTECTION-1',
96
- ]);
97
- });
98
- it('lists direct children id-sorted', () => {
99
- const trace = buildRequirementTrace('REQUIREMENT-DATA-PROTECTION-1', idx, catalog);
100
- expect(trace.children.map(r => r.id)).toEqual([
101
- 'REQUIREMENT-DATA-CONSENT-1',
102
- 'REQUIREMENT-DATA-ERASURE-1',
103
- ]);
104
- });
105
- it('handles a top-level requirement (no ancestors) with no children', () => {
106
- const trace = buildRequirementTrace('REQUIREMENT-INTERNAL-1', idx, catalog);
107
- expect(trace.ancestors).toEqual([]);
108
- expect(trace.children).toEqual([]);
109
- });
110
- it('supports CONSTRAINT hierarchy the same way', () => {
111
- const trace = buildRequirementTrace('CONSTRAINT-EEA-ANALYTICS-1', idx, catalog);
112
- expect(trace.ancestors.map(r => r.id)).toEqual(['CONSTRAINT-EEA-TRANSFER-1']);
113
- });
114
- it('terminates at a missing parent without throwing (broken model)', () => {
115
- const local = {
116
- requirements: [{ id: 'REQUIREMENT-ORPHAN-1', name: 'Orphan', parent: 'REQUIREMENT-GONE-1' }],
117
- assertions: [],
118
- };
119
- const trace = buildRequirementTrace('REQUIREMENT-ORPHAN-1', buildComplianceIndex(local), catalog);
120
- expect(trace.ancestors).toEqual([]);
121
- });
122
- it('breaks a parent cycle rather than looping', () => {
123
- // A → B → A (misauthored).
124
- const local = {
125
- requirements: [
126
- { id: 'REQUIREMENT-A-1', name: 'A', parent: 'REQUIREMENT-B-1' },
127
- { id: 'REQUIREMENT-B-1', name: 'B', parent: 'REQUIREMENT-A-1' },
128
- ],
129
- assertions: [],
130
- };
131
- const trace = buildRequirementTrace('REQUIREMENT-A-1', buildComplianceIndex(local), catalog);
132
- expect(trace.ancestors.map(r => r.id)).toEqual(['REQUIREMENT-B-1']);
133
- });
134
- });
135
- describe('buildRequirementTrace — dangling target', () => {
136
- it('returns a stub carrying the id as name when the requirement is not scanned', () => {
137
- const trace = buildRequirementTrace('REQUIREMENT-UNKNOWN-1', buildComplianceIndex({ requirements: [], assertions: [] }), catalog);
138
- expect(trace.requirement).toEqual({ id: 'REQUIREMENT-UNKNOWN-1', name: 'REQUIREMENT-UNKNOWN-1' });
139
- expect(trace.sources).toEqual([]);
140
- expect(trace.assertions).toEqual([]);
141
- expect(trace.ancestors).toEqual([]);
142
- expect(trace.children).toEqual([]);
143
- });
144
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,59 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { emptyCanon } from '../classify.js';
3
- import { catalogFromMap } from '../canon-catalog.js';
4
- import { collectImpactViewResolutionFindings } from '../impact.js';
5
- import { collectCoverageViewResolutionFindings } from '../coverage-metric.js';
6
- const catalog = catalogFromMap(new Map([
7
- ['PRODUCT-ECOMM-1', 'PRODUCT'],
8
- ['REQUIREMENT-GDPR-1', 'REQUIREMENT'],
9
- ['LAW-GDPR-1', 'LAW'],
10
- ]));
11
- const complianceCanon = emptyCanon();
12
- complianceCanon.products.push({ id: 'PRODUCT-ECOMM-1', name: 'E-Commerce' });
13
- complianceCanon.requirements.push({ id: 'REQUIREMENT-GDPR-1', name: 'GDPR req' });
14
- complianceCanon.codex.push({ id: 'LAW-GDPR-1', name: 'GDPR' });
15
- describe('collectImpactViewResolutionFindings', () => {
16
- const base = {
17
- id: 'test-impact',
18
- name: 'Test',
19
- subjects: { products: ['PRODUCT-ECOMM-1'], processes: [], capabilities: [] },
20
- obligations: { filter: { derived_from_codex: ['LAW-GDPR-1'] } },
21
- status_display: { show: ['compliant'] },
22
- empty_cells: {},
23
- order_rows_by: 'id',
24
- };
25
- it('passes when subjects and regimes resolve', () => {
26
- expect(collectImpactViewResolutionFindings(base, catalog, complianceCanon)).toEqual([]);
27
- });
28
- it('flags unresolved subjects and regimes', () => {
29
- const findings = collectImpactViewResolutionFindings({
30
- ...base,
31
- subjects: { products: ['PRODUCT-MISSING-1'], processes: [], capabilities: [] },
32
- obligations: { include: ['REQUIREMENT-MISSING-1'], filter: { derived_from_codex: ['LAW-MISSING-1'] } },
33
- }, catalog, complianceCanon);
34
- expect(findings.some((f) => f.code === 'COMPIMP-REF' && f.message.includes('PRODUCT-MISSING-1'))).toBe(true);
35
- expect(findings.some((f) => f.message.includes('REQUIREMENT-MISSING-1'))).toBe(true);
36
- expect(findings.some((f) => f.message.includes('LAW-MISSING-1'))).toBe(true);
37
- });
38
- });
39
- describe('collectCoverageViewResolutionFindings', () => {
40
- const base = {
41
- id: 'test-coverage',
42
- name: 'Test',
43
- thresholds: { green: 0.9, amber: 0.7 },
44
- subjects: { products: ['PRODUCT-ECOMM-1'] },
45
- regimes: { include: ['LAW-GDPR-1'] },
46
- };
47
- it('passes when products and regimes resolve', () => {
48
- expect(collectCoverageViewResolutionFindings(base, catalog, complianceCanon)).toEqual([]);
49
- });
50
- it('flags unresolved product and regime refs', () => {
51
- const findings = collectCoverageViewResolutionFindings({
52
- ...base,
53
- subjects: { products: ['PRODUCT-MISSING-1'] },
54
- regimes: { include: ['LAW-MISSING-1'] },
55
- }, catalog, complianceCanon);
56
- expect(findings.some((f) => f.code === 'COVMET-REF')).toBe(true);
57
- expect(findings).toHaveLength(2);
58
- });
59
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,59 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { buildComplianceIndex } from '../reverse-index.js';
3
- import { buildLawTree, buildProductView } from '../views.js';
4
- const input = {
5
- requirements: [
6
- { id: 'REQUIREMENT-A-1', name: 'A', severity: 'high', derived_from: ['LAW-X-1'] },
7
- { id: 'REQUIREMENT-B-1', name: 'B', severity: 'low', derived_from: ['LAW-X-1', 'REGULATION-Y-1'] },
8
- { id: 'REQUIREMENT-C-1', name: 'C' }, // internal-only, no law
9
- ],
10
- assertions: [
11
- { id: 'ASSERTION-2', about: 'REQUIREMENT-A-1', subject: 'PRODUCT-M-1', status: 'compliant' },
12
- { id: 'ASSERTION-1', about: 'REQUIREMENT-A-1', subject: 'CAPABILITY-V2', status: 'under_review' },
13
- { id: 'ASSERTION-3', about: 'REQUIREMENT-B-1', subject: 'PRODUCT-M-1', status: 'partial' },
14
- ],
15
- };
16
- describe('buildComplianceIndex', () => {
17
- const idx = buildComplianceIndex(input);
18
- it('indexes requirements by the laws they derive from', () => {
19
- expect(idx.requirementsByLaw.get('LAW-X-1')?.map(r => r.id)).toEqual(['REQUIREMENT-A-1', 'REQUIREMENT-B-1']);
20
- expect(idx.requirementsByLaw.get('REGULATION-Y-1')?.map(r => r.id)).toEqual(['REQUIREMENT-B-1']);
21
- expect(idx.requirementsByLaw.has('LAW-NONE-1')).toBe(false);
22
- });
23
- it('indexes assertions by requirement and by subject', () => {
24
- expect(idx.assertionsByRequirement.get('REQUIREMENT-A-1')?.map(a => a.id).sort()).toEqual(['ASSERTION-1', 'ASSERTION-2']);
25
- expect(idx.assertionsBySubject.get('PRODUCT-M-1')?.map(a => a.id).sort()).toEqual(['ASSERTION-2', 'ASSERTION-3']);
26
- });
27
- });
28
- describe('buildLawTree', () => {
29
- const idx = buildComplianceIndex(input);
30
- it('lists requirements derived from the law, each with its id-sorted assertions', () => {
31
- const tree = buildLawTree('LAW-X-1', idx);
32
- expect(tree.requirements.map(r => r.requirement.id)).toEqual(['REQUIREMENT-A-1', 'REQUIREMENT-B-1']);
33
- expect(tree.requirements[0].assertions.map(a => a.id)).toEqual(['ASSERTION-1', 'ASSERTION-2']);
34
- expect(tree.requirements[0].assertions.map(a => a.status)).toEqual(['under_review', 'compliant']);
35
- });
36
- it('returns an empty tree for an unknown law', () => {
37
- expect(buildLawTree('LAW-NONE-1', idx).requirements).toEqual([]);
38
- });
39
- });
40
- describe('buildProductView', () => {
41
- const idx = buildComplianceIndex(input);
42
- it('lists the requirements the product is asserted against, with status, requirement-id-sorted', () => {
43
- const view = buildProductView('PRODUCT-M-1', idx);
44
- expect(view.requirements.map(r => r.requirement.id)).toEqual(['REQUIREMENT-A-1', 'REQUIREMENT-B-1']);
45
- expect(view.requirements.map(r => r.assertion.status)).toEqual(['compliant', 'partial']);
46
- expect(view.requirements[0].requirement.name).toBe('A');
47
- });
48
- it('falls back to the id as name when the requirement is not in the scan (dangling about)', () => {
49
- const idx2 = buildComplianceIndex({
50
- requirements: [],
51
- assertions: [{ id: 'ASSERTION-9', about: 'REQUIREMENT-GONE-1', subject: 'PRODUCT-M-1', status: 'n_a' }],
52
- });
53
- const view = buildProductView('PRODUCT-M-1', idx2);
54
- expect(view.requirements[0].requirement).toEqual({ id: 'REQUIREMENT-GONE-1', name: 'REQUIREMENT-GONE-1' });
55
- });
56
- it('returns an empty view for a product with no assertions', () => {
57
- expect(buildProductView('PRODUCT-NONE-1', idx).requirements).toEqual([]);
58
- });
59
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,183 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { buildComplianceMatrix, filterComplianceMatrix } from '../build.js';
3
- function input(over = {}) {
4
- return {
5
- products: [
6
- { id: 'PRODUCT-ECOMM-1', name: 'E-Commerce' },
7
- { id: 'PRODUCT-SUPPORT-1', name: 'Support' },
8
- ],
9
- requirements: [
10
- { id: 'REQUIREMENT-DATA-ERASURE-1', name: 'Erasure', severity: 'high' },
11
- { id: 'REQUIREMENT-AUDIT-LOG-RETENTION-1', name: 'Audit logs', severity: 'medium' },
12
- ],
13
- assertions: [
14
- { id: 'ASSERTION-1', about: 'REQUIREMENT-DATA-ERASURE-1', subject: 'PRODUCT-ECOMM-1', status: 'compliant' },
15
- ],
16
- ...over,
17
- };
18
- }
19
- describe('buildComplianceMatrix', () => {
20
- it('sorts products as rows and requirements as columns by id', () => {
21
- const m = buildComplianceMatrix(input());
22
- expect(m.products.map(p => p.id)).toEqual(['PRODUCT-ECOMM-1', 'PRODUCT-SUPPORT-1']);
23
- expect(m.requirements.map(r => r.id)).toEqual([
24
- 'REQUIREMENT-AUDIT-LOG-RETENTION-1',
25
- 'REQUIREMENT-DATA-ERASURE-1',
26
- ]);
27
- });
28
- it('places an assertion status in the (product, requirement) cell and gaps elsewhere', () => {
29
- const m = buildComplianceMatrix(input());
30
- // row 0 = ECOMM; col 1 = DATA-ERASURE (after the sort)
31
- expect(m.cells[0][1]).toMatchObject({ status: 'compliant', assertionId: 'ASSERTION-1' });
32
- expect(m.cells[0][0].status).toBeUndefined(); // ECOMM × AUDIT-LOG → gap
33
- expect(m.cells[1][1].status).toBeUndefined(); // SUPPORT × DATA-ERASURE → gap
34
- expect(m.summary).toMatchObject({ products: 2, requirements: 2, assertions: 1, gaps: 3 });
35
- });
36
- it('adds a product-typed assertion subject with no product file as an unresolved row', () => {
37
- const m = buildComplianceMatrix(input({
38
- assertions: [
39
- { id: 'A1', about: 'REQUIREMENT-DATA-ERASURE-1', subject: 'PRODUCT-MOBILE-1', status: 'partial' },
40
- ],
41
- }));
42
- const mobile = m.products.find(p => p.id === 'PRODUCT-MOBILE-1');
43
- expect(mobile).toMatchObject({ unresolved: true });
44
- const col = m.requirements.findIndex(r => r.id === 'REQUIREMENT-DATA-ERASURE-1');
45
- const row = m.products.findIndex(p => p.id === 'PRODUCT-MOBILE-1');
46
- expect(m.cells[row][col].status).toBe('partial');
47
- });
48
- it('ignores assertions whose subject is not a PRODUCT', () => {
49
- const m = buildComplianceMatrix(input({
50
- assertions: [
51
- { id: 'A1', about: 'REQUIREMENT-DATA-ERASURE-1', subject: 'CAPABILITY-V2', status: 'compliant' },
52
- { id: 'A2', about: 'REQUIREMENT-DATA-ERASURE-1', subject: 'PROCESS-X-1', status: 'partial' },
53
- ],
54
- }));
55
- expect(m.summary.assertions).toBe(0);
56
- expect(m.products.map(p => p.id)).toEqual(['PRODUCT-ECOMM-1', 'PRODUCT-SUPPORT-1']);
57
- });
58
- });
59
- describe('buildComplianceMatrix — jurisdiction resolution (F16)', () => {
60
- it('resolves Requirement.jurisdictions from derived_from → codex', () => {
61
- const m = buildComplianceMatrix(input({
62
- requirements: [
63
- { id: 'REQUIREMENT-DATA-ERASURE-1', name: 'Erasure', severity: 'high',
64
- derived_from: ['LAW-PERSONAL-DATA-2017-1'] },
65
- { id: 'REQUIREMENT-AUDIT-LOG-RETENTION-1', name: 'Audit logs', severity: 'medium',
66
- derived_from: ['LAW-AUDIT-2020-1', 'LAW-PERSONAL-DATA-2017-1'] },
67
- ],
68
- codex: [
69
- { id: 'LAW-PERSONAL-DATA-2017-1', jurisdiction: 'ge' },
70
- { id: 'LAW-AUDIT-2020-1', jurisdiction: 'eu' },
71
- ],
72
- }));
73
- const erasure = m.requirements.find(r => r.id === 'REQUIREMENT-DATA-ERASURE-1');
74
- const audit = m.requirements.find(r => r.id === 'REQUIREMENT-AUDIT-LOG-RETENTION-1');
75
- expect(erasure.jurisdictions).toEqual(['ge']);
76
- // Sorted, deduplicated union.
77
- expect(audit.jurisdictions).toEqual(['eu', 'ge']);
78
- });
79
- it('leaves jurisdictions undefined when no codex source resolves', () => {
80
- const m = buildComplianceMatrix(input({
81
- requirements: [
82
- { id: 'REQUIREMENT-INTERNAL-1', name: 'Internal', severity: 'low' },
83
- { id: 'REQUIREMENT-DANGLING-1', name: 'Dangling', severity: 'low',
84
- derived_from: ['LAW-MISSING-1'] },
85
- ],
86
- codex: [{ id: 'LAW-OTHER-1', jurisdiction: 'us' }],
87
- }));
88
- expect(m.requirements.find(r => r.id === 'REQUIREMENT-INTERNAL-1').jurisdictions).toBeUndefined();
89
- expect(m.requirements.find(r => r.id === 'REQUIREMENT-DANGLING-1').jurisdictions).toBeUndefined();
90
- });
91
- it('ignores codex entries with no jurisdiction (e.g. internal POLICY)', () => {
92
- const m = buildComplianceMatrix(input({
93
- requirements: [
94
- { id: 'REQUIREMENT-DATA-ERASURE-1', name: 'Erasure', severity: 'high',
95
- derived_from: ['POLICY-INTERNAL-1'] },
96
- ],
97
- codex: [{ id: 'POLICY-INTERNAL-1' }],
98
- }));
99
- expect(m.requirements[0].jurisdictions).toBeUndefined();
100
- });
101
- it('works with no codex input (backwards-compatible)', () => {
102
- const m = buildComplianceMatrix(input({
103
- requirements: [
104
- { id: 'REQUIREMENT-DATA-ERASURE-1', name: 'Erasure', severity: 'high',
105
- derived_from: ['LAW-PERSONAL-DATA-2017-1'] },
106
- ],
107
- }));
108
- expect(m.requirements[0].jurisdictions).toBeUndefined();
109
- });
110
- });
111
- describe('filterComplianceMatrix', () => {
112
- it('trims requirement columns by severity', () => {
113
- const m = buildComplianceMatrix(input());
114
- const f = filterComplianceMatrix(m, { severities: ['high'] });
115
- expect(f.requirements.map(r => r.id)).toEqual(['REQUIREMENT-DATA-ERASURE-1']);
116
- expect(f.cells[0]).toHaveLength(1);
117
- expect(f.cells[0][0]).toMatchObject({ status: 'compliant' });
118
- });
119
- it('blanks cells whose status is filtered out, preserving the grid shape', () => {
120
- const m = buildComplianceMatrix(input());
121
- const f = filterComplianceMatrix(m, { statuses: ['non_compliant'] });
122
- // The compliant cell is now hidden (treated as a gap); columns unchanged.
123
- expect(f.requirements).toHaveLength(2);
124
- expect(f.cells[0][1].status).toBeUndefined();
125
- expect(f.summary.assertions).toBe(0);
126
- });
127
- it('is a no-op when no filter dimension is set', () => {
128
- const m = buildComplianceMatrix(input());
129
- const f = filterComplianceMatrix(m, {});
130
- expect(f.summary).toEqual(m.summary);
131
- });
132
- it('keeps only columns whose resolved jurisdiction is in the filter (F16)', () => {
133
- const m = buildComplianceMatrix(input({
134
- requirements: [
135
- { id: 'REQUIREMENT-DATA-ERASURE-1', name: 'Erasure', severity: 'high',
136
- derived_from: ['LAW-PERSONAL-DATA-2017-1'] },
137
- { id: 'REQUIREMENT-AUDIT-LOG-RETENTION-1', name: 'Audit logs', severity: 'medium',
138
- derived_from: ['LAW-AUDIT-2020-1'] },
139
- ],
140
- codex: [
141
- { id: 'LAW-PERSONAL-DATA-2017-1', jurisdiction: 'ge' },
142
- { id: 'LAW-AUDIT-2020-1', jurisdiction: 'eu' },
143
- ],
144
- }));
145
- const f = filterComplianceMatrix(m, { jurisdictions: ['ge'] });
146
- expect(f.requirements.map(r => r.id)).toEqual(['REQUIREMENT-DATA-ERASURE-1']);
147
- expect(f.cells[0]).toHaveLength(1);
148
- });
149
- it('drops requirements with no resolved jurisdiction when the filter is active', () => {
150
- const m = buildComplianceMatrix(input({
151
- requirements: [
152
- { id: 'REQUIREMENT-DATA-ERASURE-1', name: 'Erasure', severity: 'high',
153
- derived_from: ['LAW-PERSONAL-DATA-2017-1'] },
154
- { id: 'REQUIREMENT-INTERNAL-1', name: 'Internal', severity: 'low' },
155
- ],
156
- codex: [{ id: 'LAW-PERSONAL-DATA-2017-1', jurisdiction: 'ge' }],
157
- }));
158
- const f = filterComplianceMatrix(m, { jurisdictions: ['ge'] });
159
- expect(f.requirements.map(r => r.id)).toEqual(['REQUIREMENT-DATA-ERASURE-1']);
160
- });
161
- it('combines jurisdiction filter with severity (intersection)', () => {
162
- const m = buildComplianceMatrix(input({
163
- requirements: [
164
- { id: 'REQUIREMENT-DATA-ERASURE-1', name: 'Erasure', severity: 'high',
165
- derived_from: ['LAW-PERSONAL-DATA-2017-1'] },
166
- { id: 'REQUIREMENT-DATA-PORTABILITY-1', name: 'Portability', severity: 'medium',
167
- derived_from: ['LAW-PERSONAL-DATA-2017-1'] },
168
- ],
169
- codex: [{ id: 'LAW-PERSONAL-DATA-2017-1', jurisdiction: 'ge' }],
170
- }));
171
- const f = filterComplianceMatrix(m, { jurisdictions: ['ge'], severities: ['high'] });
172
- expect(f.requirements.map(r => r.id)).toEqual(['REQUIREMENT-DATA-ERASURE-1']);
173
- });
174
- it('empty jurisdiction array is treated as no-filter on that dimension', () => {
175
- const m = buildComplianceMatrix(input({
176
- requirements: [
177
- { id: 'REQUIREMENT-INTERNAL-1', name: 'Internal', severity: 'low' },
178
- ],
179
- }));
180
- const f = filterComplianceMatrix(m, { jurisdictions: [] });
181
- expect(f.requirements).toHaveLength(1);
182
- });
183
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,49 +0,0 @@
1
- // Conformance test — the compliance matrix on the acme_corp worked examples
2
- // (mirrored under tests/fixtures/notation-corpus/product, tests/fixtures/notation-corpus/requirement, tests/fixtures/notation-corpus/assertion).
3
- // Pins the #84 Phase 2 acceptance: the matrix renders correctly and gaps are
4
- // obvious.
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 { buildComplianceMatrix } from '../build.js';
11
- const examples = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../../tests/fixtures/notation-corpus');
12
- function loadAll(dir) {
13
- const full = path.join(examples, dir);
14
- return readdirSync(full)
15
- .filter(f => f.endsWith('.yaml'))
16
- .map(f => yaml.load(readFileSync(path.join(full, f), 'utf-8')));
17
- }
18
- describe('compliance matrix — acme_corp worked examples', () => {
19
- const products = loadAll('product').map(p => ({ id: String(p.id), name: String(p.name) }));
20
- const requirements = loadAll('requirement').map(r => ({
21
- id: String(r.id), name: String(r.name), severity: r.severity,
22
- }));
23
- const assertions = loadAll('assertion').map(a => ({
24
- id: String(a.id), about: String(a.about), subject: String(a.subject),
25
- status: a.status,
26
- assessed_at: a.assessed_at,
27
- next_review_at: a.next_review_at,
28
- }));
29
- const m = buildComplianceMatrix({ products, requirements, assertions });
30
- it('rows = the two product files plus the dangling PRODUCT-MOBILE-1 subject', () => {
31
- expect(m.products.map(p => p.id)).toEqual([
32
- 'PRODUCT-ECOMM-1', 'PRODUCT-MOBILE-1', 'PRODUCT-SUPPORT-1',
33
- ]);
34
- expect(m.products.find(p => p.id === 'PRODUCT-MOBILE-1')?.unresolved).toBe(true);
35
- });
36
- it('columns = the two requirements', () => {
37
- expect(m.requirements.map(r => r.id)).toEqual([
38
- 'REQUIREMENT-AUDIT-LOG-RETENTION-1', 'REQUIREMENT-DATA-ERASURE-1',
39
- ]);
40
- });
41
- it('the only product-subject assertion (mobile → data-erasure) is compliant; everything else is a gap', () => {
42
- const row = m.products.findIndex(p => p.id === 'PRODUCT-MOBILE-1');
43
- const col = m.requirements.findIndex(r => r.id === 'REQUIREMENT-DATA-ERASURE-1');
44
- expect(m.cells[row][col]).toMatchObject({ status: 'compliant', assertionId: 'ASSERTION-MOBILE-DATA-ERASURE-1' });
45
- // 3 products × 2 requirements = 6 cells; 1 filled → 5 gaps. The CRM
46
- // (capability) and onboarding (process) assertions are not in the matrix.
47
- expect(m.summary).toMatchObject({ products: 3, requirements: 2, assertions: 1, gaps: 5 });
48
- });
49
- });
@@ -1 +0,0 @@
1
- export {};