@transitrix/diagrams 1.8.4 → 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 (254) hide show
  1. package/dist/edge-path.js +10 -1
  2. package/dist/webview/render-activities.d.ts +1 -1
  3. package/dist/webview/render-activities.js +2 -2
  4. package/dist/webview/render-fgca.js +1 -4
  5. package/package.json +7 -2
  6. package/src/edge-path.ts +15 -1
  7. package/src/webview/render-activities.ts +2 -2
  8. package/src/webview/render-fgca.ts +1 -4
  9. package/dist/__tests__/edge-path.test.d.ts +0 -1
  10. package/dist/__tests__/edge-path.test.js +0 -47
  11. package/dist/__tests__/node-size-presets.test.d.ts +0 -1
  12. package/dist/__tests__/node-size-presets.test.js +0 -30
  13. package/dist/__tests__/scope.test.d.ts +0 -1
  14. package/dist/__tests__/scope.test.js +0 -23
  15. package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
  16. package/dist/__tests__/yaml-normalize.test.js +0 -148
  17. package/dist/activities/__tests__/cpm.test.d.ts +0 -1
  18. package/dist/activities/__tests__/cpm.test.js +0 -146
  19. package/dist/activities/__tests__/gantt.test.d.ts +0 -1
  20. package/dist/activities/__tests__/gantt.test.js +0 -263
  21. package/dist/activities/__tests__/layout.test.d.ts +0 -1
  22. package/dist/activities/__tests__/layout.test.js +0 -98
  23. package/dist/activities/__tests__/validate.test.d.ts +0 -1
  24. package/dist/activities/__tests__/validate.test.js +0 -397
  25. package/dist/activity-card/__tests__/example.test.d.ts +0 -1
  26. package/dist/activity-card/__tests__/example.test.js +0 -73
  27. package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
  28. package/dist/activity-card/__tests__/layout.test.js +0 -141
  29. package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
  30. package/dist/activity-card/__tests__/resolver.test.js +0 -325
  31. package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
  32. package/dist/activity-card/__tests__/validate.test.js +0 -149
  33. package/dist/actor/__tests__/validate.test.d.ts +0 -1
  34. package/dist/actor/__tests__/validate.test.js +0 -95
  35. package/dist/applications/__tests__/validate.test.d.ts +0 -1
  36. package/dist/applications/__tests__/validate.test.js +0 -223
  37. package/dist/assertion/__tests__/example.test.d.ts +0 -1
  38. package/dist/assertion/__tests__/example.test.js +0 -32
  39. package/dist/assertion/__tests__/validate.test.d.ts +0 -1
  40. package/dist/assertion/__tests__/validate.test.js +0 -130
  41. package/dist/blocks/__tests__/layout.test.d.ts +0 -1
  42. package/dist/blocks/__tests__/layout.test.js +0 -153
  43. package/dist/blocks/__tests__/validate.test.d.ts +0 -1
  44. package/dist/blocks/__tests__/validate.test.js +0 -235
  45. package/dist/business-service/__tests__/validate.test.d.ts +0 -1
  46. package/dist/business-service/__tests__/validate.test.js +0 -135
  47. package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
  48. package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
  49. package/dist/capability-map/__tests__/address.test.d.ts +0 -1
  50. package/dist/capability-map/__tests__/address.test.js +0 -49
  51. package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
  52. package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
  53. package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
  54. package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
  55. package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
  56. package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
  57. package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
  58. package/dist/capability-map/__tests__/validate.test.js +0 -212
  59. package/dist/change/__tests__/validate.test.d.ts +0 -1
  60. package/dist/change/__tests__/validate.test.js +0 -79
  61. package/dist/codex/__tests__/example.test.d.ts +0 -1
  62. package/dist/codex/__tests__/example.test.js +0 -33
  63. package/dist/codex/__tests__/validate.test.d.ts +0 -1
  64. package/dist/codex/__tests__/validate.test.js +0 -68
  65. package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
  66. package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
  67. package/dist/compliance/__tests__/classify.test.d.ts +0 -1
  68. package/dist/compliance/__tests__/classify.test.js +0 -58
  69. package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
  70. package/dist/compliance/__tests__/confidence.test.js +0 -78
  71. package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
  72. package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
  73. package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
  74. package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
  75. package/dist/compliance/__tests__/example.test.d.ts +0 -1
  76. package/dist/compliance/__tests__/example.test.js +0 -51
  77. package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
  78. package/dist/compliance/__tests__/gap-report.test.js +0 -113
  79. package/dist/compliance/__tests__/html.test.d.ts +0 -1
  80. package/dist/compliance/__tests__/html.test.js +0 -122
  81. package/dist/compliance/__tests__/impact.test.d.ts +0 -1
  82. package/dist/compliance/__tests__/impact.test.js +0 -913
  83. package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
  84. package/dist/compliance/__tests__/markdown.test.js +0 -85
  85. package/dist/compliance/__tests__/trace.test.d.ts +0 -1
  86. package/dist/compliance/__tests__/trace.test.js +0 -144
  87. package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
  88. package/dist/compliance/__tests__/view-resolution.test.js +0 -59
  89. package/dist/compliance/__tests__/views.test.d.ts +0 -1
  90. package/dist/compliance/__tests__/views.test.js +0 -59
  91. package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
  92. package/dist/compliance-matrix/__tests__/build.test.js +0 -183
  93. package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
  94. package/dist/compliance-matrix/__tests__/example.test.js +0 -49
  95. package/dist/confidence/__tests__/score.test.d.ts +0 -1
  96. package/dist/confidence/__tests__/score.test.js +0 -188
  97. package/dist/constraint/__tests__/example.test.d.ts +0 -1
  98. package/dist/constraint/__tests__/example.test.js +0 -14
  99. package/dist/constraint/__tests__/validate.test.d.ts +0 -1
  100. package/dist/constraint/__tests__/validate.test.js +0 -58
  101. package/dist/factor/__tests__/validate.test.d.ts +0 -1
  102. package/dist/factor/__tests__/validate.test.js +0 -112
  103. package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
  104. package/dist/fgca/__tests__/chain-table.test.js +0 -158
  105. package/dist/fgca/__tests__/layout.test.d.ts +0 -1
  106. package/dist/fgca/__tests__/layout.test.js +0 -140
  107. package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
  108. package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
  109. package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
  110. package/dist/fgca/__tests__/preview-layout.test.js +0 -106
  111. package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
  112. package/dist/fgca/__tests__/resolver.test.js +0 -185
  113. package/dist/fgca/__tests__/validate.test.d.ts +0 -1
  114. package/dist/fgca/__tests__/validate.test.js +0 -125
  115. package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
  116. package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
  117. package/dist/goals/__tests__/layout.test.d.ts +0 -1
  118. package/dist/goals/__tests__/layout.test.js +0 -153
  119. package/dist/goals/__tests__/mutations.test.d.ts +0 -1
  120. package/dist/goals/__tests__/mutations.test.js +0 -134
  121. package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
  122. package/dist/goals/__tests__/parse-canonical.test.js +0 -131
  123. package/dist/goals/__tests__/validate.test.d.ts +0 -1
  124. package/dist/goals/__tests__/validate.test.js +0 -183
  125. package/dist/integration/__tests__/validate.test.d.ts +0 -1
  126. package/dist/integration/__tests__/validate.test.js +0 -169
  127. package/dist/location/__tests__/validate.test.d.ts +0 -1
  128. package/dist/location/__tests__/validate.test.js +0 -107
  129. package/dist/node/__tests__/validate.test.d.ts +0 -1
  130. package/dist/node/__tests__/validate.test.js +0 -100
  131. package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
  132. package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
  133. package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
  134. package/dist/process-blueprint/__tests__/layout.test.js +0 -196
  135. package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
  136. package/dist/process-blueprint/__tests__/validate.test.js +0 -280
  137. package/dist/process-map/__tests__/validate.test.d.ts +0 -1
  138. package/dist/process-map/__tests__/validate.test.js +0 -199
  139. package/dist/products/__tests__/validate.test.d.ts +0 -1
  140. package/dist/products/__tests__/validate.test.js +0 -210
  141. package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
  142. package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
  143. package/dist/requirement/__tests__/example.test.d.ts +0 -1
  144. package/dist/requirement/__tests__/example.test.js +0 -21
  145. package/dist/requirement/__tests__/validate.test.d.ts +0 -1
  146. package/dist/requirement/__tests__/validate.test.js +0 -80
  147. package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
  148. package/dist/scenarios/__tests__/validate.test.js +0 -183
  149. package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
  150. package/dist/stakeholder/__tests__/validate.test.js +0 -88
  151. package/dist/target-state/__tests__/validate.test.d.ts +0 -1
  152. package/dist/target-state/__tests__/validate.test.js +0 -78
  153. package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
  154. package/dist/technology-service/__tests__/validate.test.js +0 -121
  155. package/dist/theme/__tests__/tokens.test.d.ts +0 -1
  156. package/dist/theme/__tests__/tokens.test.js +0 -159
  157. package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
  158. package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
  159. package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
  160. package/dist/webview/__tests__/entry-notations.test.js +0 -62
  161. package/dist/webview/__tests__/entry.test.d.ts +0 -1
  162. package/dist/webview/__tests__/entry.test.js +0 -56
  163. package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
  164. package/dist/webview/__tests__/render-activities.test.js +0 -91
  165. package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
  166. package/dist/webview/__tests__/render-blocks.test.js +0 -175
  167. package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
  168. package/dist/webview/__tests__/render-goals.test.js +0 -120
  169. package/dist/webview/__tests__/render-process.test.d.ts +0 -1
  170. package/dist/webview/__tests__/render-process.test.js +0 -463
  171. package/dist/webview/__tests__/render-util.test.d.ts +0 -1
  172. package/dist/webview/__tests__/render-util.test.js +0 -54
  173. package/src/__tests__/edge-path.test.ts +0 -58
  174. package/src/__tests__/node-size-presets.test.ts +0 -50
  175. package/src/__tests__/scope.test.ts +0 -27
  176. package/src/__tests__/yaml-normalize.test.ts +0 -158
  177. package/src/activities/__tests__/cpm.test.ts +0 -164
  178. package/src/activities/__tests__/gantt.test.ts +0 -290
  179. package/src/activities/__tests__/layout.test.ts +0 -112
  180. package/src/activities/__tests__/validate.test.ts +0 -446
  181. package/src/activity-card/__tests__/example.test.ts +0 -83
  182. package/src/activity-card/__tests__/layout.test.ts +0 -162
  183. package/src/activity-card/__tests__/resolver.test.ts +0 -357
  184. package/src/activity-card/__tests__/validate.test.ts +0 -167
  185. package/src/actor/__tests__/validate.test.ts +0 -114
  186. package/src/applications/__tests__/validate.test.ts +0 -256
  187. package/src/assertion/__tests__/example.test.ts +0 -37
  188. package/src/assertion/__tests__/validate.test.ts +0 -142
  189. package/src/blocks/__tests__/layout.test.ts +0 -169
  190. package/src/blocks/__tests__/validate.test.ts +0 -260
  191. package/src/business-service/__tests__/validate.test.ts +0 -160
  192. package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
  193. package/src/capability-map/__tests__/address.test.ts +0 -59
  194. package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
  195. package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
  196. package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
  197. package/src/capability-map/__tests__/validate.test.ts +0 -238
  198. package/src/change/__tests__/validate.test.ts +0 -97
  199. package/src/codex/__tests__/example.test.ts +0 -40
  200. package/src/codex/__tests__/validate.test.ts +0 -84
  201. package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
  202. package/src/compliance/__tests__/classify.test.ts +0 -64
  203. package/src/compliance/__tests__/confidence.test.ts +0 -98
  204. package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
  205. package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
  206. package/src/compliance/__tests__/example.test.ts +0 -57
  207. package/src/compliance/__tests__/gap-report.test.ts +0 -129
  208. package/src/compliance/__tests__/html.test.ts +0 -142
  209. package/src/compliance/__tests__/impact.test.ts +0 -1060
  210. package/src/compliance/__tests__/markdown.test.ts +0 -95
  211. package/src/compliance/__tests__/trace.test.ts +0 -157
  212. package/src/compliance/__tests__/view-resolution.test.ts +0 -80
  213. package/src/compliance/__tests__/views.test.ts +0 -64
  214. package/src/compliance-matrix/__tests__/build.test.ts +0 -200
  215. package/src/compliance-matrix/__tests__/example.test.ts +0 -57
  216. package/src/confidence/__tests__/score.test.ts +0 -254
  217. package/src/constraint/__tests__/example.test.ts +0 -19
  218. package/src/constraint/__tests__/validate.test.ts +0 -68
  219. package/src/factor/__tests__/validate.test.ts +0 -133
  220. package/src/fgca/__tests__/chain-table.test.ts +0 -172
  221. package/src/fgca/__tests__/layout.test.ts +0 -179
  222. package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
  223. package/src/fgca/__tests__/preview-layout.test.ts +0 -124
  224. package/src/fgca/__tests__/resolver.test.ts +0 -209
  225. package/src/fgca/__tests__/validate.test.ts +0 -142
  226. package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
  227. package/src/goals/__tests__/layout.test.ts +0 -175
  228. package/src/goals/__tests__/mutations.test.ts +0 -153
  229. package/src/goals/__tests__/parse-canonical.test.ts +0 -147
  230. package/src/goals/__tests__/validate.test.ts +0 -202
  231. package/src/integration/__tests__/validate.test.ts +0 -203
  232. package/src/location/__tests__/validate.test.ts +0 -127
  233. package/src/node/__tests__/validate.test.ts +0 -118
  234. package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
  235. package/src/process-blueprint/__tests__/layout.test.ts +0 -240
  236. package/src/process-blueprint/__tests__/validate.test.ts +0 -310
  237. package/src/process-map/__tests__/validate.test.ts +0 -223
  238. package/src/products/__tests__/validate.test.ts +0 -239
  239. package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
  240. package/src/requirement/__tests__/example.test.ts +0 -24
  241. package/src/requirement/__tests__/validate.test.ts +0 -96
  242. package/src/scenarios/__tests__/validate.test.ts +0 -209
  243. package/src/stakeholder/__tests__/validate.test.ts +0 -105
  244. package/src/target-state/__tests__/validate.test.ts +0 -95
  245. package/src/technology-service/__tests__/validate.test.ts +0 -143
  246. package/src/theme/__tests__/tokens.test.ts +0 -185
  247. package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
  248. package/src/webview/__tests__/entry-notations.test.ts +0 -77
  249. package/src/webview/__tests__/entry.test.ts +0 -64
  250. package/src/webview/__tests__/render-activities.test.ts +0 -100
  251. package/src/webview/__tests__/render-blocks.test.ts +0 -206
  252. package/src/webview/__tests__/render-goals.test.ts +0 -128
  253. package/src/webview/__tests__/render-process.test.ts +0 -538
  254. package/src/webview/__tests__/render-util.test.ts +0 -66
@@ -1,57 +0,0 @@
1
- // Conformance — single-law tree + single-product view on the acme_corp worked
2
- // examples (mirrored under tests/fixtures/notation-corpus/requirement, tests/fixtures/notation-corpus/assertion). Pins the
3
- // #84 Phase 3 acceptance.
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 type { IndexAssertion, IndexRequirement } from '../types.js';
13
-
14
- const examples = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../../tests/fixtures/notation-corpus');
15
- function loadAll(dir: string): Record<string, unknown>[] {
16
- const full = path.join(examples, dir);
17
- return readdirSync(full).filter(f => f.endsWith('.yaml')).map(f => yaml.load(readFileSync(path.join(full, f), 'utf-8')) as Record<string, unknown>);
18
- }
19
-
20
- const requirements: IndexRequirement[] = loadAll('requirement').map(r => ({
21
- id: String(r.id), name: String(r.name),
22
- severity: r.severity as string | undefined,
23
- derived_from: Array.isArray(r.derived_from) ? (r.derived_from as string[]) : undefined,
24
- }));
25
- const assertions: IndexAssertion[] = loadAll('assertion').map(a => ({
26
- id: String(a.id), about: String(a.about), subject: String(a.subject),
27
- status: a.status as IndexAssertion['status'],
28
- evidenceCount: Array.isArray(a.evidence) ? a.evidence.length : 0,
29
- }));
30
- const index = buildComplianceIndex({ requirements, assertions });
31
-
32
- describe('single-law tree — LAW-PERSONAL-DATA-2017-1', () => {
33
- const tree = buildLawTree('LAW-PERSONAL-DATA-2017-1', index);
34
- it('derives the data-erasure requirement with its three assertions', () => {
35
- expect(tree.requirements.map(r => r.requirement.id)).toEqual(['REQUIREMENT-DATA-ERASURE-1']);
36
- const node = tree.requirements[0];
37
- expect(node.assertions.map(a => a.id)).toEqual([
38
- 'ASSERTION-CRM-DATA-ERASURE-1',
39
- 'ASSERTION-MOBILE-DATA-ERASURE-1',
40
- 'ASSERTION-ONBOARD-DATA-ERASURE-1',
41
- ]);
42
- expect(node.assertions.map(a => a.status).sort()).toEqual(['compliant', 'partial', 'under_review']);
43
- });
44
- it('the internal-only audit-log requirement is not under any law', () => {
45
- expect(index.requirementsByLaw.has('LAW-PERSONAL-DATA-2017-1')).toBe(true);
46
- expect(tree.requirements.some(r => r.requirement.id === 'REQUIREMENT-AUDIT-LOG-RETENTION-1')).toBe(false);
47
- });
48
- });
49
-
50
- describe('single-product view — PRODUCT-MOBILE-1', () => {
51
- it('shows the data-erasure requirement as compliant', () => {
52
- const view = buildProductView('PRODUCT-MOBILE-1', index);
53
- expect(view.requirements.map(r => r.requirement.id)).toEqual(['REQUIREMENT-DATA-ERASURE-1']);
54
- expect(view.requirements[0].assertion.status).toBe('compliant');
55
- expect(view.requirements[0].requirement.name).toBe('Personal-data erasure on request within 30 days');
56
- });
57
- });
@@ -1,129 +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 { buildComplianceIndex } from '../reverse-index.js';
7
- import { buildGapReport } from '../gap-report.js';
8
- import type { ComplianceIndexInput, IndexAssertion, IndexRequirement } from '../types.js';
9
-
10
- const input: ComplianceIndexInput = {
11
- requirements: [
12
- { id: 'REQUIREMENT-A-1', name: 'A', severity: 'high' }, // has assertions
13
- { id: 'REQUIREMENT-B-1', name: 'B', severity: 'low' }, // orphan
14
- { id: 'REQUIREMENT-C-1', name: 'C', severity: 'medium' }, // orphan
15
- { id: 'REQUIREMENT-D-1', name: 'D' }, // orphan, no severity
16
- ],
17
- assertions: [
18
- { id: 'ASSERTION-1', about: 'REQUIREMENT-A-1', subject: 'PRODUCT-1', status: 'compliant', evidenceCount: 0 }, // 007
19
- { id: 'ASSERTION-2', about: 'REQUIREMENT-A-1', subject: 'PRODUCT-2', status: 'under_review', evidenceCount: 0 }, // NOT 007
20
- { id: 'ASSERTION-3', about: 'REQUIREMENT-A-1', subject: 'PRODUCT-3', status: 'partial', evidenceCount: 2, next_review_at: '2025-01-01' }, // stale
21
- ],
22
- };
23
-
24
- describe('buildGapReport', () => {
25
- const index = buildComplianceIndex(input);
26
- const report = buildGapReport(index, { today: '2026-06-02' });
27
-
28
- it('lists requirements without assertions, severity-sorted (high→medium→low→none)', () => {
29
- expect(report.requirementsWithoutAssertions.map(r => r.id)).toEqual([
30
- 'REQUIREMENT-C-1', // medium
31
- 'REQUIREMENT-B-1', // low
32
- 'REQUIREMENT-D-1', // none
33
- ]);
34
- });
35
-
36
- it('flags only compliant/partial assertions with empty evidence (ASSERT-007)', () => {
37
- expect(report.assertionsWithoutEvidence.map(a => a.id)).toEqual(['ASSERTION-1']);
38
- // under_review with empty evidence is legitimate — not flagged.
39
- expect(report.assertionsWithoutEvidence.map(a => a.id)).not.toContain('ASSERTION-2');
40
- });
41
-
42
- it('flags assertions whose next_review_at is past today (ASSERT-008)', () => {
43
- expect(report.staleAssertions.map(a => a.id)).toEqual(['ASSERTION-3']);
44
- });
45
-
46
- it('produces no stale list when today is not supplied (clock-free)', () => {
47
- expect(buildGapReport(index, {}).staleAssertions).toEqual([]);
48
- });
49
- });
50
-
51
- // ── Conformance on the acme_corp worked examples ────────────────────────────
52
-
53
- const examples = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../../tests/fixtures/notation-corpus');
54
- function loadAll(dir: string): Record<string, unknown>[] {
55
- const full = path.join(examples, dir);
56
- return readdirSync(full).filter(f => f.endsWith('.yaml')).map(f => yaml.load(readFileSync(path.join(full, f), 'utf-8')) as Record<string, unknown>);
57
- }
58
-
59
- describe('gap report — acme_corp worked examples', () => {
60
- const requirements: IndexRequirement[] = loadAll('requirement').map(r => ({
61
- id: String(r.id), name: String(r.name), severity: r.severity as string | undefined,
62
- derived_from: Array.isArray(r.derived_from) ? (r.derived_from as string[]) : undefined,
63
- }));
64
- const assertions: IndexAssertion[] = loadAll('assertion').map(a => ({
65
- id: String(a.id), about: String(a.about), subject: String(a.subject),
66
- status: a.status as IndexAssertion['status'],
67
- next_review_at: a.next_review_at as string | undefined,
68
- evidenceCount: Array.isArray(a.evidence) ? a.evidence.length : 0,
69
- }));
70
- const report = buildGapReport(buildComplianceIndex({ requirements, assertions }), { today: '2026-06-02' });
71
-
72
- it('surfaces the internal audit-log requirement as an un-asserted gap', () => {
73
- expect(report.requirementsWithoutAssertions.map(r => r.id)).toEqual(['REQUIREMENT-AUDIT-LOG-RETENTION-1']);
74
- });
75
-
76
- it('does not flag the under_review empty-evidence assertion under ASSERT-007', () => {
77
- expect(report.assertionsWithoutEvidence).toEqual([]);
78
- });
79
-
80
- it('has no stale assertions (all acme reviews are in the future)', () => {
81
- expect(report.staleAssertions).toEqual([]);
82
- });
83
- });
84
-
85
- describe('CV-5 -- pastDeadlineRequirements', () => {
86
- it('lists requirements with past deadline and no compliant assertion', () => {
87
- const indexLocal = buildComplianceIndex({
88
- requirements: [
89
- { id: 'REQ-PD-1', name: 'Past deadline, no assertion', deadline: '2020-01-01' },
90
- { id: 'REQ-PD-2', name: 'Past deadline, non-compliant assertion', deadline: '2020-01-01' },
91
- { id: 'REQ-PD-3', name: 'Past deadline, compliant assertion', deadline: '2020-01-01' },
92
- { id: 'REQ-FU-1', name: 'Future deadline', deadline: '2099-01-01' },
93
- { id: 'REQ-ND-1', name: 'No deadline' },
94
- ],
95
- assertions: [
96
- { id: 'ASS-2', about: 'REQ-PD-2', subject: 'S', status: 'non_compliant' },
97
- { id: 'ASS-3', about: 'REQ-PD-3', subject: 'S', status: 'compliant' },
98
- ],
99
- });
100
- const r = buildGapReport(indexLocal, { today: '2026-06-09' });
101
- // REQ-PD-1 and REQ-PD-2 are past-deadline without full compliance
102
- expect(r.pastDeadlineRequirements.map(x => x.id)).toEqual(['REQ-PD-1', 'REQ-PD-2']);
103
- // REQ-PD-3 has a compliant assertion -> excluded
104
- expect(r.pastDeadlineRequirements.map(x => x.id)).not.toContain('REQ-PD-3');
105
- // Future or no deadline -> excluded
106
- expect(r.pastDeadlineRequirements.map(x => x.id)).not.toContain('REQ-FU-1');
107
- expect(r.pastDeadlineRequirements.map(x => x.id)).not.toContain('REQ-ND-1');
108
- });
109
-
110
- it('is empty when no today is supplied (clock-free)', () => {
111
- const idx2 = buildComplianceIndex({
112
- requirements: [{ id: 'REQ-PD-1', name: 'Past', deadline: '2020-01-01' }],
113
- assertions: [],
114
- });
115
- expect(buildGapReport(idx2, {}).pastDeadlineRequirements).toEqual([]);
116
- });
117
-
118
- it('sorts oldest deadline first', () => {
119
- const idx3 = buildComplianceIndex({
120
- requirements: [
121
- { id: 'REQ-A', name: 'A', deadline: '2022-06-01' },
122
- { id: 'REQ-B', name: 'B', deadline: '2019-01-01' },
123
- ],
124
- assertions: [],
125
- });
126
- const r3 = buildGapReport(idx3, { today: '2026-06-09' });
127
- expect(r3.pastDeadlineRequirements.map(x => x.id)).toEqual(['REQ-B', 'REQ-A']);
128
- });
129
- });
@@ -1,142 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { renderComplianceHtml } from '../html.js';
3
- import { emptyCanon, ingestComplianceDoc, type ComplianceCanon } from '../classify.js';
4
-
5
- function synthetic(): ComplianceCanon {
6
- const canon = emptyCanon();
7
- ingestComplianceDoc(canon, { notation: 'product', id: 'PRODUCT-M-1', name: 'Mobile App' });
8
- ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQUIREMENT-ERASURE-1', name: 'Erasure', severity: 'high', derived_from: ['LAW-X-1'] });
9
- ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQUIREMENT-LOG-1', name: 'Logs', severity: 'low' });
10
- ingestComplianceDoc(canon, {
11
- notation: 'assertion',
12
- id: 'ASSERTION-1',
13
- about: 'REQUIREMENT-ERASURE-1',
14
- subject: 'PRODUCT-M-1',
15
- status: 'compliant',
16
- evidence: [{ kind: 'note', text: 'x' }],
17
- next_review_at: '2026-09-01',
18
- });
19
- ingestComplianceDoc(canon, { id: 'LAW-X-1', name: 'Privacy Law', zone: 'codex', type: 'LAW' });
20
- return canon;
21
- }
22
-
23
- describe('renderComplianceHtml — document shell', () => {
24
- it('produces a complete HTML document with branded header and stamp', () => {
25
- const html = renderComplianceHtml(synthetic(), { mode: 'matrix' }, { today: '2026-06-03' });
26
- expect(html.startsWith('<!doctype html>')).toBe(true);
27
- expect(html).toContain('<title>Compliance Matrix</title>');
28
- expect(html).toContain('<div class="cmp-eyebrow">Transitrix · Compliance</div>');
29
- expect(html).toContain('<h1>Compliance Matrix</h1>');
30
- expect(html).toContain('Generated 2026-06-03');
31
- expect(html).toContain('@page');
32
- expect(html).toContain('size: A4 portrait');
33
- });
34
-
35
- it('escapes HTML in product and requirement names', () => {
36
- const canon = emptyCanon();
37
- ingestComplianceDoc(canon, { notation: 'product', id: 'PRODUCT-X-1', name: '<Mobile> & "Web"' });
38
- ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQUIREMENT-X-1', name: 'A & B' });
39
- const html = renderComplianceHtml(canon, { mode: 'matrix' });
40
- expect(html).not.toMatch(/<Mobile>/);
41
- expect(html).toContain('&lt;Mobile&gt; &amp; &quot;Web&quot;');
42
- expect(html).toContain('A &amp; B');
43
- });
44
- });
45
-
46
- describe('renderComplianceHtml — matrix', () => {
47
- it('renders a table with status badges and gap cells', () => {
48
- const html = renderComplianceHtml(synthetic(), { mode: 'matrix' });
49
- expect(html).toContain('<table class="cmp-matrix">');
50
- expect(html).toContain('<th>Erasure</th>');
51
- expect(html).toContain('<th>Logs</th>');
52
- expect(html).toContain('<span class="cmp-badge cmp-compliant">Compliant</span>');
53
- expect(html).toMatch(/cmp-cell-gap/);
54
- expect(html).toContain('1 products × 2 requirements');
55
- });
56
-
57
- it('shows an empty-state message when nothing was scanned', () => {
58
- const html = renderComplianceHtml(emptyCanon(), { mode: 'matrix' });
59
- expect(html).toContain('No products or requirements found');
60
- });
61
- });
62
-
63
- describe('renderComplianceHtml — law', () => {
64
- it('renders the law name, requirement block, and assertion bullet with badge', () => {
65
- const html = renderComplianceHtml(synthetic(), { mode: 'law', id: 'LAW-X-1' });
66
- expect(html).toContain('<h1>Compliance — Privacy Law</h1>');
67
- expect(html).toContain('class="cmp-req-name">Erasure');
68
- expect(html).toContain('class="cmp-req-id">REQUIREMENT-ERASURE-1');
69
- expect(html).toContain('cmp-sev cmp-sev-high');
70
- expect(html).toContain('cmp-badge cmp-compliant');
71
- expect(html).toContain('review by 2026-09-01');
72
- });
73
-
74
- it('handles an unknown law id with an empty-state message', () => {
75
- const html = renderComplianceHtml(synthetic(), { mode: 'law', id: 'LAW-NONE' });
76
- expect(html).toContain('<h1>Compliance — LAW-NONE</h1>');
77
- expect(html).toContain('No requirements derive from');
78
- });
79
- });
80
-
81
- describe('renderComplianceHtml — product', () => {
82
- it('renders the product table of asserted requirements', () => {
83
- const html = renderComplianceHtml(synthetic(), { mode: 'product', id: 'PRODUCT-M-1' });
84
- expect(html).toContain('<h1>Compliance — Mobile App</h1>');
85
- expect(html).toContain('<th>Requirement</th>');
86
- expect(html).toContain('<th>Status</th>');
87
- expect(html).toContain('cmp-badge cmp-compliant');
88
- expect(html).toContain('2026-09-01');
89
- });
90
- });
91
-
92
- describe('renderComplianceHtml — gap', () => {
93
- it('lists the un-asserted requirement and shows ✓ none for clean sections', () => {
94
- const html = renderComplianceHtml(synthetic(), { mode: 'gap' }, { today: '2026-06-02' });
95
- expect(html).toContain('Requirements without assertions');
96
- expect(html).toContain('REQUIREMENT-LOG-1');
97
- expect(html).toContain('severity low');
98
- expect(html).toContain('Assertions without evidence — ASSERT-007');
99
- expect(html).toContain('Stale assertions — ASSERT-008');
100
- expect(html).toContain('class="cmp-ok">✓ none');
101
- });
102
-
103
- it('counts gaps in the summary line', () => {
104
- const html = renderComplianceHtml(synthetic(), { mode: 'gap' });
105
- expect(html).toMatch(/1 gap\(s\)/);
106
- });
107
- });
108
-
109
- // ── CV-6: renderImpactMatrixHtml ─────────────────────────────────────────────
110
-
111
- import { renderImpactMatrixHtml } from '../html.js';
112
- import { buildImpactMatrix } from '../impact.js';
113
-
114
- describe('renderImpactMatrixHtml (CV-6)', () => {
115
- it('returns a complete HTML document with matrix title and table', () => {
116
- const canon = emptyCanon();
117
- ingestComplianceDoc(canon, { notation: 'product', id: 'PROD-1', name: 'Product One' });
118
- ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQ-1', name: 'Req One', severity: 'high' });
119
- ingestComplianceDoc(canon, { notation: 'assertion', id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
120
- const matrix = buildImpactMatrix(
121
- { products: canon.products, requirements: canon.requirements, assertions: canon.assertions, codex: canon.codex, subjects: canon.subjects },
122
- { id: 'VIEW-1', name: 'My View', subjects: { products: ['PROD-1'] }, obligations: {} },
123
- );
124
- const html = renderImpactMatrixHtml(matrix, { today: '2026-06-09' });
125
- expect(html).toContain('<table>');
126
- expect(html).toContain('My View');
127
- expect(html).toContain('VIEW-1');
128
- expect(html).toContain('OK');
129
- });
130
-
131
- it('renders gap cells with no_obligation_label text', () => {
132
- const canon = emptyCanon();
133
- ingestComplianceDoc(canon, { notation: 'product', id: 'PROD-1', name: 'P1' });
134
- ingestComplianceDoc(canon, { notation: 'requirement', id: 'REQ-1', name: 'R1' });
135
- const matrix = buildImpactMatrix(
136
- { products: canon.products, requirements: canon.requirements, assertions: canon.assertions, codex: canon.codex, subjects: canon.subjects },
137
- { id: 'V2', name: 'V2', subjects: { products: ['PROD-1'] }, obligations: {} },
138
- );
139
- const html = renderImpactMatrixHtml(matrix);
140
- expect(html).toContain('No mapped obligation');
141
- });
142
- });