@transitrix/diagrams 1.8.6 → 1.8.8

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 (251) hide show
  1. package/dist/fgca/index.js +10 -10
  2. package/dist/fgca/layout.js +1 -1
  3. package/dist/fgca/nodeTypes.js +4 -4
  4. package/dist/index.js +33 -33
  5. package/package.json +8 -2
  6. package/dist/__tests__/edge-path.test.d.ts +0 -1
  7. package/dist/__tests__/edge-path.test.js +0 -55
  8. package/dist/__tests__/node-size-presets.test.d.ts +0 -1
  9. package/dist/__tests__/node-size-presets.test.js +0 -30
  10. package/dist/__tests__/scope.test.d.ts +0 -1
  11. package/dist/__tests__/scope.test.js +0 -23
  12. package/dist/__tests__/yaml-normalize.test.d.ts +0 -1
  13. package/dist/__tests__/yaml-normalize.test.js +0 -148
  14. package/dist/activities/__tests__/cpm.test.d.ts +0 -1
  15. package/dist/activities/__tests__/cpm.test.js +0 -146
  16. package/dist/activities/__tests__/gantt.test.d.ts +0 -1
  17. package/dist/activities/__tests__/gantt.test.js +0 -263
  18. package/dist/activities/__tests__/layout.test.d.ts +0 -1
  19. package/dist/activities/__tests__/layout.test.js +0 -98
  20. package/dist/activities/__tests__/validate.test.d.ts +0 -1
  21. package/dist/activities/__tests__/validate.test.js +0 -397
  22. package/dist/activity-card/__tests__/example.test.d.ts +0 -1
  23. package/dist/activity-card/__tests__/example.test.js +0 -73
  24. package/dist/activity-card/__tests__/layout.test.d.ts +0 -1
  25. package/dist/activity-card/__tests__/layout.test.js +0 -141
  26. package/dist/activity-card/__tests__/resolver.test.d.ts +0 -1
  27. package/dist/activity-card/__tests__/resolver.test.js +0 -325
  28. package/dist/activity-card/__tests__/validate.test.d.ts +0 -1
  29. package/dist/activity-card/__tests__/validate.test.js +0 -149
  30. package/dist/actor/__tests__/validate.test.d.ts +0 -1
  31. package/dist/actor/__tests__/validate.test.js +0 -95
  32. package/dist/applications/__tests__/validate.test.d.ts +0 -1
  33. package/dist/applications/__tests__/validate.test.js +0 -223
  34. package/dist/assertion/__tests__/example.test.d.ts +0 -1
  35. package/dist/assertion/__tests__/example.test.js +0 -32
  36. package/dist/assertion/__tests__/validate.test.d.ts +0 -1
  37. package/dist/assertion/__tests__/validate.test.js +0 -130
  38. package/dist/blocks/__tests__/layout.test.d.ts +0 -1
  39. package/dist/blocks/__tests__/layout.test.js +0 -153
  40. package/dist/blocks/__tests__/validate.test.d.ts +0 -1
  41. package/dist/blocks/__tests__/validate.test.js +0 -235
  42. package/dist/business-service/__tests__/validate.test.d.ts +0 -1
  43. package/dist/business-service/__tests__/validate.test.js +0 -135
  44. package/dist/capability-map/__tests__/CapabilityMapView.test.d.ts +0 -1
  45. package/dist/capability-map/__tests__/CapabilityMapView.test.js +0 -217
  46. package/dist/capability-map/__tests__/address.test.d.ts +0 -1
  47. package/dist/capability-map/__tests__/address.test.js +0 -49
  48. package/dist/capability-map/__tests__/dsm-layout.test.d.ts +0 -1
  49. package/dist/capability-map/__tests__/dsm-layout.test.js +0 -46
  50. package/dist/capability-map/__tests__/dsm-mutations.test.d.ts +0 -1
  51. package/dist/capability-map/__tests__/dsm-mutations.test.js +0 -125
  52. package/dist/capability-map/__tests__/dsm-validate.test.d.ts +0 -1
  53. package/dist/capability-map/__tests__/dsm-validate.test.js +0 -56
  54. package/dist/capability-map/__tests__/validate.test.d.ts +0 -1
  55. package/dist/capability-map/__tests__/validate.test.js +0 -212
  56. package/dist/change/__tests__/validate.test.d.ts +0 -1
  57. package/dist/change/__tests__/validate.test.js +0 -79
  58. package/dist/codex/__tests__/example.test.d.ts +0 -1
  59. package/dist/codex/__tests__/example.test.js +0 -33
  60. package/dist/codex/__tests__/validate.test.d.ts +0 -1
  61. package/dist/codex/__tests__/validate.test.js +0 -68
  62. package/dist/compliance/__tests__/canon-catalog.test.d.ts +0 -1
  63. package/dist/compliance/__tests__/canon-catalog.test.js +0 -60
  64. package/dist/compliance/__tests__/classify.test.d.ts +0 -1
  65. package/dist/compliance/__tests__/classify.test.js +0 -58
  66. package/dist/compliance/__tests__/confidence.test.d.ts +0 -1
  67. package/dist/compliance/__tests__/confidence.test.js +0 -78
  68. package/dist/compliance/__tests__/coverage-metric.test.d.ts +0 -1
  69. package/dist/compliance/__tests__/coverage-metric.test.js +0 -264
  70. package/dist/compliance/__tests__/demo-scenario.test.d.ts +0 -1
  71. package/dist/compliance/__tests__/demo-scenario.test.js +0 -226
  72. package/dist/compliance/__tests__/example.test.d.ts +0 -1
  73. package/dist/compliance/__tests__/example.test.js +0 -51
  74. package/dist/compliance/__tests__/gap-report.test.d.ts +0 -1
  75. package/dist/compliance/__tests__/gap-report.test.js +0 -113
  76. package/dist/compliance/__tests__/html.test.d.ts +0 -1
  77. package/dist/compliance/__tests__/html.test.js +0 -122
  78. package/dist/compliance/__tests__/impact.test.d.ts +0 -1
  79. package/dist/compliance/__tests__/impact.test.js +0 -913
  80. package/dist/compliance/__tests__/markdown.test.d.ts +0 -1
  81. package/dist/compliance/__tests__/markdown.test.js +0 -85
  82. package/dist/compliance/__tests__/trace.test.d.ts +0 -1
  83. package/dist/compliance/__tests__/trace.test.js +0 -144
  84. package/dist/compliance/__tests__/view-resolution.test.d.ts +0 -1
  85. package/dist/compliance/__tests__/view-resolution.test.js +0 -59
  86. package/dist/compliance/__tests__/views.test.d.ts +0 -1
  87. package/dist/compliance/__tests__/views.test.js +0 -59
  88. package/dist/compliance-matrix/__tests__/build.test.d.ts +0 -1
  89. package/dist/compliance-matrix/__tests__/build.test.js +0 -183
  90. package/dist/compliance-matrix/__tests__/example.test.d.ts +0 -1
  91. package/dist/compliance-matrix/__tests__/example.test.js +0 -49
  92. package/dist/confidence/__tests__/score.test.d.ts +0 -1
  93. package/dist/confidence/__tests__/score.test.js +0 -188
  94. package/dist/constraint/__tests__/example.test.d.ts +0 -1
  95. package/dist/constraint/__tests__/example.test.js +0 -14
  96. package/dist/constraint/__tests__/validate.test.d.ts +0 -1
  97. package/dist/constraint/__tests__/validate.test.js +0 -58
  98. package/dist/factor/__tests__/validate.test.d.ts +0 -1
  99. package/dist/factor/__tests__/validate.test.js +0 -112
  100. package/dist/fgca/__tests__/chain-table.test.d.ts +0 -1
  101. package/dist/fgca/__tests__/chain-table.test.js +0 -158
  102. package/dist/fgca/__tests__/layout.test.d.ts +0 -1
  103. package/dist/fgca/__tests__/layout.test.js +0 -140
  104. package/dist/fgca/__tests__/parse-canonical.test.d.ts +0 -1
  105. package/dist/fgca/__tests__/parse-canonical.test.js +0 -268
  106. package/dist/fgca/__tests__/preview-layout.test.d.ts +0 -1
  107. package/dist/fgca/__tests__/preview-layout.test.js +0 -106
  108. package/dist/fgca/__tests__/resolver.test.d.ts +0 -1
  109. package/dist/fgca/__tests__/resolver.test.js +0 -185
  110. package/dist/fgca/__tests__/validate.test.d.ts +0 -1
  111. package/dist/fgca/__tests__/validate.test.js +0 -125
  112. package/dist/goals/__tests__/GoalTreeView.test.d.ts +0 -1
  113. package/dist/goals/__tests__/GoalTreeView.test.js +0 -337
  114. package/dist/goals/__tests__/layout.test.d.ts +0 -1
  115. package/dist/goals/__tests__/layout.test.js +0 -153
  116. package/dist/goals/__tests__/mutations.test.d.ts +0 -1
  117. package/dist/goals/__tests__/mutations.test.js +0 -134
  118. package/dist/goals/__tests__/parse-canonical.test.d.ts +0 -1
  119. package/dist/goals/__tests__/parse-canonical.test.js +0 -131
  120. package/dist/goals/__tests__/validate.test.d.ts +0 -1
  121. package/dist/goals/__tests__/validate.test.js +0 -183
  122. package/dist/integration/__tests__/validate.test.d.ts +0 -1
  123. package/dist/integration/__tests__/validate.test.js +0 -169
  124. package/dist/location/__tests__/validate.test.d.ts +0 -1
  125. package/dist/location/__tests__/validate.test.js +0 -107
  126. package/dist/node/__tests__/validate.test.d.ts +0 -1
  127. package/dist/node/__tests__/validate.test.js +0 -100
  128. package/dist/process-blueprint/__tests__/compliance-lane.test.d.ts +0 -1
  129. package/dist/process-blueprint/__tests__/compliance-lane.test.js +0 -272
  130. package/dist/process-blueprint/__tests__/layout.test.d.ts +0 -1
  131. package/dist/process-blueprint/__tests__/layout.test.js +0 -196
  132. package/dist/process-blueprint/__tests__/validate.test.d.ts +0 -1
  133. package/dist/process-blueprint/__tests__/validate.test.js +0 -280
  134. package/dist/process-map/__tests__/validate.test.d.ts +0 -1
  135. package/dist/process-map/__tests__/validate.test.js +0 -199
  136. package/dist/products/__tests__/validate.test.d.ts +0 -1
  137. package/dist/products/__tests__/validate.test.js +0 -210
  138. package/dist/repo-validate/__tests__/validate-repo.test.d.ts +0 -1
  139. package/dist/repo-validate/__tests__/validate-repo.test.js +0 -576
  140. package/dist/requirement/__tests__/example.test.d.ts +0 -1
  141. package/dist/requirement/__tests__/example.test.js +0 -21
  142. package/dist/requirement/__tests__/validate.test.d.ts +0 -1
  143. package/dist/requirement/__tests__/validate.test.js +0 -80
  144. package/dist/scenarios/__tests__/validate.test.d.ts +0 -1
  145. package/dist/scenarios/__tests__/validate.test.js +0 -183
  146. package/dist/stakeholder/__tests__/validate.test.d.ts +0 -1
  147. package/dist/stakeholder/__tests__/validate.test.js +0 -88
  148. package/dist/target-state/__tests__/validate.test.d.ts +0 -1
  149. package/dist/target-state/__tests__/validate.test.js +0 -78
  150. package/dist/technology-service/__tests__/validate.test.d.ts +0 -1
  151. package/dist/technology-service/__tests__/validate.test.js +0 -121
  152. package/dist/theme/__tests__/tokens.test.d.ts +0 -1
  153. package/dist/theme/__tests__/tokens.test.js +0 -159
  154. package/dist/webview/__tests__/entity-text-layout.test.d.ts +0 -1
  155. package/dist/webview/__tests__/entity-text-layout.test.js +0 -155
  156. package/dist/webview/__tests__/entry-notations.test.d.ts +0 -1
  157. package/dist/webview/__tests__/entry-notations.test.js +0 -62
  158. package/dist/webview/__tests__/entry.test.d.ts +0 -1
  159. package/dist/webview/__tests__/entry.test.js +0 -56
  160. package/dist/webview/__tests__/render-activities.test.d.ts +0 -1
  161. package/dist/webview/__tests__/render-activities.test.js +0 -91
  162. package/dist/webview/__tests__/render-blocks.test.d.ts +0 -1
  163. package/dist/webview/__tests__/render-blocks.test.js +0 -175
  164. package/dist/webview/__tests__/render-goals.test.d.ts +0 -1
  165. package/dist/webview/__tests__/render-goals.test.js +0 -120
  166. package/dist/webview/__tests__/render-process.test.d.ts +0 -1
  167. package/dist/webview/__tests__/render-process.test.js +0 -463
  168. package/dist/webview/__tests__/render-util.test.d.ts +0 -1
  169. package/dist/webview/__tests__/render-util.test.js +0 -54
  170. package/src/__tests__/edge-path.test.ts +0 -67
  171. package/src/__tests__/node-size-presets.test.ts +0 -50
  172. package/src/__tests__/scope.test.ts +0 -27
  173. package/src/__tests__/yaml-normalize.test.ts +0 -158
  174. package/src/activities/__tests__/cpm.test.ts +0 -164
  175. package/src/activities/__tests__/gantt.test.ts +0 -290
  176. package/src/activities/__tests__/layout.test.ts +0 -112
  177. package/src/activities/__tests__/validate.test.ts +0 -446
  178. package/src/activity-card/__tests__/example.test.ts +0 -83
  179. package/src/activity-card/__tests__/layout.test.ts +0 -162
  180. package/src/activity-card/__tests__/resolver.test.ts +0 -357
  181. package/src/activity-card/__tests__/validate.test.ts +0 -167
  182. package/src/actor/__tests__/validate.test.ts +0 -114
  183. package/src/applications/__tests__/validate.test.ts +0 -256
  184. package/src/assertion/__tests__/example.test.ts +0 -37
  185. package/src/assertion/__tests__/validate.test.ts +0 -142
  186. package/src/blocks/__tests__/layout.test.ts +0 -169
  187. package/src/blocks/__tests__/validate.test.ts +0 -260
  188. package/src/business-service/__tests__/validate.test.ts +0 -160
  189. package/src/capability-map/__tests__/CapabilityMapView.test.tsx +0 -232
  190. package/src/capability-map/__tests__/address.test.ts +0 -59
  191. package/src/capability-map/__tests__/dsm-layout.test.ts +0 -52
  192. package/src/capability-map/__tests__/dsm-mutations.test.ts +0 -141
  193. package/src/capability-map/__tests__/dsm-validate.test.ts +0 -65
  194. package/src/capability-map/__tests__/validate.test.ts +0 -238
  195. package/src/change/__tests__/validate.test.ts +0 -97
  196. package/src/codex/__tests__/example.test.ts +0 -40
  197. package/src/codex/__tests__/validate.test.ts +0 -84
  198. package/src/compliance/__tests__/canon-catalog.test.ts +0 -68
  199. package/src/compliance/__tests__/classify.test.ts +0 -64
  200. package/src/compliance/__tests__/confidence.test.ts +0 -98
  201. package/src/compliance/__tests__/coverage-metric.test.ts +0 -300
  202. package/src/compliance/__tests__/demo-scenario.test.ts +0 -273
  203. package/src/compliance/__tests__/example.test.ts +0 -57
  204. package/src/compliance/__tests__/gap-report.test.ts +0 -129
  205. package/src/compliance/__tests__/html.test.ts +0 -142
  206. package/src/compliance/__tests__/impact.test.ts +0 -1060
  207. package/src/compliance/__tests__/markdown.test.ts +0 -95
  208. package/src/compliance/__tests__/trace.test.ts +0 -157
  209. package/src/compliance/__tests__/view-resolution.test.ts +0 -80
  210. package/src/compliance/__tests__/views.test.ts +0 -64
  211. package/src/compliance-matrix/__tests__/build.test.ts +0 -200
  212. package/src/compliance-matrix/__tests__/example.test.ts +0 -57
  213. package/src/confidence/__tests__/score.test.ts +0 -254
  214. package/src/constraint/__tests__/example.test.ts +0 -19
  215. package/src/constraint/__tests__/validate.test.ts +0 -68
  216. package/src/factor/__tests__/validate.test.ts +0 -133
  217. package/src/fgca/__tests__/chain-table.test.ts +0 -172
  218. package/src/fgca/__tests__/layout.test.ts +0 -179
  219. package/src/fgca/__tests__/parse-canonical.test.ts +0 -296
  220. package/src/fgca/__tests__/preview-layout.test.ts +0 -124
  221. package/src/fgca/__tests__/resolver.test.ts +0 -209
  222. package/src/fgca/__tests__/validate.test.ts +0 -142
  223. package/src/goals/__tests__/GoalTreeView.test.tsx +0 -361
  224. package/src/goals/__tests__/layout.test.ts +0 -175
  225. package/src/goals/__tests__/mutations.test.ts +0 -153
  226. package/src/goals/__tests__/parse-canonical.test.ts +0 -147
  227. package/src/goals/__tests__/validate.test.ts +0 -202
  228. package/src/integration/__tests__/validate.test.ts +0 -203
  229. package/src/location/__tests__/validate.test.ts +0 -127
  230. package/src/node/__tests__/validate.test.ts +0 -118
  231. package/src/process-blueprint/__tests__/compliance-lane.test.ts +0 -320
  232. package/src/process-blueprint/__tests__/layout.test.ts +0 -240
  233. package/src/process-blueprint/__tests__/validate.test.ts +0 -310
  234. package/src/process-map/__tests__/validate.test.ts +0 -223
  235. package/src/products/__tests__/validate.test.ts +0 -239
  236. package/src/repo-validate/__tests__/validate-repo.test.ts +0 -699
  237. package/src/requirement/__tests__/example.test.ts +0 -24
  238. package/src/requirement/__tests__/validate.test.ts +0 -96
  239. package/src/scenarios/__tests__/validate.test.ts +0 -209
  240. package/src/stakeholder/__tests__/validate.test.ts +0 -105
  241. package/src/target-state/__tests__/validate.test.ts +0 -95
  242. package/src/technology-service/__tests__/validate.test.ts +0 -143
  243. package/src/theme/__tests__/tokens.test.ts +0 -185
  244. package/src/webview/__tests__/entity-text-layout.test.ts +0 -182
  245. package/src/webview/__tests__/entry-notations.test.ts +0 -77
  246. package/src/webview/__tests__/entry.test.ts +0 -64
  247. package/src/webview/__tests__/render-activities.test.ts +0 -100
  248. package/src/webview/__tests__/render-blocks.test.ts +0 -206
  249. package/src/webview/__tests__/render-goals.test.ts +0 -128
  250. package/src/webview/__tests__/render-process.test.ts +0 -538
  251. package/src/webview/__tests__/render-util.test.ts +0 -66
@@ -1,913 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { emptyCanon } from '../classify.js';
3
- import { buildImpactMatrix, renderImpactMarkdown, parseImpactViewConfig, COMPLIANCE_IMPACT_DEFAULTS, extractObjectDetails, extractProcessFlowTasks, mergeStageTaskDetails, computeDeadlineStatus, } from '../impact.js';
4
- // Industry- and regime-agnostic synthetic fixture: opaque ids only, no real
5
- // regulator / product names, per #166 acceptance ("Output is aggregates only —
6
- // no subject/obligation names tied to any real corpus").
7
- function buildCanon() {
8
- const canon = emptyCanon();
9
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
10
- canon.products.push({ id: 'PRODUCT-B-1', name: 'Product B' });
11
- canon.requirements.push({ id: 'REQUIREMENT-FOO-1', name: 'Foo', derived_from: ['LAW-X-1'] }, { id: 'REQUIREMENT-BAR-1', name: 'Bar', derived_from: ['LAW-X-1', 'REGULATION-Y-1'] }, { id: 'REQUIREMENT-BAZ-1', name: 'Baz', derived_from: ['REGULATION-Y-1'] },
12
- // Internal-only requirement, no codex derivation:
13
- { id: 'REQUIREMENT-INT-1', name: 'Internal-only' });
14
- canon.assertions.push(
15
- // (PRODUCT-A-1, FOO) — two assertions; partial wins over compliant per §5.2 step 4.
16
- { id: 'ASSERTION-1', about: 'REQUIREMENT-FOO-1', subject: 'PRODUCT-A-1', status: 'compliant' }, { id: 'ASSERTION-2', about: 'REQUIREMENT-FOO-1', subject: 'PRODUCT-A-1', status: 'partial' },
17
- // (PRODUCT-A-1, BAR) — single n_a → modelled fact ("No obligation applies").
18
- { id: 'ASSERTION-3', about: 'REQUIREMENT-BAR-1', subject: 'PRODUCT-A-1', status: 'n_a' },
19
- // (PRODUCT-B-1, BAR) — non_compliant.
20
- { id: 'ASSERTION-4', about: 'REQUIREMENT-BAR-1', subject: 'PRODUCT-B-1', status: 'non_compliant' },
21
- // (PRODUCT-B-1, BAZ) — under_review beats compliant.
22
- { id: 'ASSERTION-5', about: 'REQUIREMENT-BAZ-1', subject: 'PRODUCT-B-1', status: 'under_review' }, { id: 'ASSERTION-6', about: 'REQUIREMENT-BAZ-1', subject: 'PRODUCT-B-1', status: 'compliant' });
23
- return canon;
24
- }
25
- const baseConfig = {
26
- id: 'COMPLIANCE_IMPACT-FIXTURE-1',
27
- name: 'Fixture matrix',
28
- subjects: { products: ['PRODUCT-A-1', 'PRODUCT-B-1'] },
29
- obligations: {},
30
- };
31
- describe('buildImpactMatrix', () => {
32
- it('aggregates statuses per §5.2 step 4 — non_compliant > partial > under_review > compliant', () => {
33
- const canon = buildCanon();
34
- const matrix = buildImpactMatrix(canon, {
35
- ...baseConfig,
36
- obligations: { include: ['REQUIREMENT-FOO-1', 'REQUIREMENT-BAR-1', 'REQUIREMENT-BAZ-1'] },
37
- });
38
- expect(matrix.columns.map(c => c.label)).toEqual(['PRODUCT-A-1', 'PRODUCT-B-1']);
39
- expect(matrix.rows.map(r => r.id)).toEqual(['REQUIREMENT-BAR-1', 'REQUIREMENT-BAZ-1', 'REQUIREMENT-FOO-1']);
40
- const cellFor = (req, subject) => {
41
- const r = matrix.rows.findIndex(x => x.id === req);
42
- const c = matrix.columns.findIndex(col => col.label === subject);
43
- return matrix.cells[r][c];
44
- };
45
- expect(cellFor('REQUIREMENT-FOO-1', 'PRODUCT-A-1').status).toBe('partial');
46
- expect(cellFor('REQUIREMENT-FOO-1', 'PRODUCT-A-1').kind).toBe('bound');
47
- expect(cellFor('REQUIREMENT-BAR-1', 'PRODUCT-A-1').kind).toBe('n_a_only');
48
- expect(cellFor('REQUIREMENT-BAR-1', 'PRODUCT-B-1').status).toBe('non_compliant');
49
- expect(cellFor('REQUIREMENT-BAZ-1', 'PRODUCT-B-1').status).toBe('under_review');
50
- expect(cellFor('REQUIREMENT-FOO-1', 'PRODUCT-B-1').kind).toBe('gap');
51
- expect(cellFor('REQUIREMENT-BAZ-1', 'PRODUCT-A-1').kind).toBe('gap');
52
- });
53
- it('selects obligations by `filter.derived_from_codex`', () => {
54
- const canon = buildCanon();
55
- const matrix = buildImpactMatrix(canon, {
56
- ...baseConfig,
57
- obligations: { filter: { derived_from_codex: ['REGULATION-Y-1'] } },
58
- });
59
- expect(matrix.rows.map(r => r.id)).toEqual(['REQUIREMENT-BAR-1', 'REQUIREMENT-BAZ-1']);
60
- });
61
- it('`include` wins when both `include` and `filter` are present (COMPIMP-007)', () => {
62
- const canon = buildCanon();
63
- const matrix = buildImpactMatrix(canon, {
64
- ...baseConfig,
65
- obligations: {
66
- include: ['REQUIREMENT-INT-1'],
67
- filter: { derived_from_codex: ['LAW-X-1'] },
68
- },
69
- });
70
- expect(matrix.rows.map(r => r.id)).toEqual(['REQUIREMENT-INT-1']);
71
- });
72
- it('distinguishes modelling gap from n_a-only per §5.3', () => {
73
- const canon = buildCanon();
74
- const matrix = buildImpactMatrix(canon, {
75
- ...baseConfig,
76
- obligations: { include: ['REQUIREMENT-BAR-1'] },
77
- });
78
- const aCell = matrix.cells[0][matrix.columns.findIndex(c => c.label === 'PRODUCT-A-1')];
79
- const bCell = matrix.cells[0][matrix.columns.findIndex(c => c.label === 'PRODUCT-B-1')];
80
- expect(aCell.kind).toBe('n_a_only');
81
- expect(bCell.kind).toBe('bound');
82
- expect(bCell.status).toBe('non_compliant');
83
- });
84
- it('respects `status_display.show` — filtered-out statuses leave the cell as a gap', () => {
85
- const canon = buildCanon();
86
- const matrix = buildImpactMatrix(canon, {
87
- ...baseConfig,
88
- obligations: { include: ['REQUIREMENT-BAZ-1'] },
89
- status_display: { show: ['non_compliant'] }, // under_review + compliant filtered out
90
- });
91
- const cell = matrix.cells[0][matrix.columns.findIndex(c => c.label === 'PRODUCT-B-1')];
92
- expect(cell.kind).toBe('gap');
93
- });
94
- it('keeps subjects with no binding obligation as columns so the gap is visible', () => {
95
- const canon = buildCanon();
96
- const matrix = buildImpactMatrix(canon, {
97
- ...baseConfig,
98
- subjects: { products: ['PRODUCT-A-1', 'PRODUCT-B-1', 'PRODUCT-NONE-1'] },
99
- obligations: { include: ['REQUIREMENT-FOO-1'] },
100
- });
101
- expect(matrix.columns.map(c => c.label)).toContain('PRODUCT-NONE-1');
102
- const cell = matrix.cells[0][matrix.columns.findIndex(c => c.label === 'PRODUCT-NONE-1')];
103
- expect(cell.kind).toBe('gap');
104
- });
105
- it('orders rows alphabetically by name when `order_rows_by: name`', () => {
106
- const canon = buildCanon();
107
- const matrix = buildImpactMatrix(canon, {
108
- ...baseConfig,
109
- obligations: { include: ['REQUIREMENT-FOO-1', 'REQUIREMENT-BAR-1', 'REQUIREMENT-BAZ-1'] },
110
- order_rows_by: 'name',
111
- });
112
- expect(matrix.rows.map(r => r.name)).toEqual(['Bar', 'Baz', 'Foo']);
113
- });
114
- });
115
- describe('renderImpactMarkdown', () => {
116
- it('renders a header, table, and §5.3 legend', () => {
117
- const canon = buildCanon();
118
- const matrix = buildImpactMatrix(canon, {
119
- ...baseConfig,
120
- obligations: { include: ['REQUIREMENT-FOO-1', 'REQUIREMENT-BAR-1'] },
121
- });
122
- const md = renderImpactMarkdown(matrix);
123
- expect(md).toContain('# Fixture matrix');
124
- expect(md).toContain('View ID: `COMPLIANCE_IMPACT-FIXTURE-1`');
125
- expect(md).toContain('| Obligation | PRODUCT-A-1 | PRODUCT-B-1 |');
126
- expect(md).toContain('PARTIAL');
127
- expect(md).toContain('FAIL');
128
- expect(md).toContain('No mapped obligation (current model)');
129
- expect(md).toContain('No obligation applies');
130
- expect(md).toContain('## Legend');
131
- });
132
- it('honours custom empty-cell labels', () => {
133
- const canon = buildCanon();
134
- const matrix = buildImpactMatrix(canon, {
135
- ...baseConfig,
136
- obligations: { include: ['REQUIREMENT-FOO-1', 'REQUIREMENT-BAR-1'] },
137
- empty_cells: {
138
- no_obligation_label: 'GAP',
139
- no_obligation_applies_label: 'EXCLUDED',
140
- },
141
- });
142
- const md = renderImpactMarkdown(matrix);
143
- expect(md).toContain('GAP');
144
- expect(md).toContain('EXCLUDED');
145
- expect(md).not.toContain('No mapped obligation (current model)');
146
- });
147
- it('renders a placeholder when zero obligations are selected', () => {
148
- const canon = buildCanon();
149
- const matrix = buildImpactMatrix(canon, {
150
- ...baseConfig,
151
- obligations: { include: ['REQUIREMENT-DOES-NOT-EXIST-1'] },
152
- });
153
- const md = renderImpactMarkdown(matrix);
154
- expect(md).toContain('No obligations in scope');
155
- });
156
- it('propagates snapshot_at into the matrix and renders it', () => {
157
- const canon = buildCanon();
158
- const matrix = buildImpactMatrix(canon, { ...baseConfig, snapshot_at: '2026-06-09' });
159
- expect(matrix.snapshotAt).toBe('2026-06-09');
160
- const md = renderImpactMarkdown(matrix);
161
- expect(md).toContain('Report snapshot: 2026-06-09');
162
- });
163
- it('resolves capability subject names from canon.subjects', () => {
164
- const canon = emptyCanon();
165
- canon.subjects.push({ id: 'CAPABILITY-CRM-1', name: 'CRM Platform' });
166
- canon.requirements.push({ id: 'REQUIREMENT-FOO-1', name: 'Foo' });
167
- canon.assertions.push({
168
- id: 'ASSERTION-1',
169
- about: 'REQUIREMENT-FOO-1',
170
- subject: 'CAPABILITY-CRM-1',
171
- status: 'compliant',
172
- });
173
- const matrix = buildImpactMatrix(canon, {
174
- id: 'V-1', name: 'Test',
175
- subjects: { capabilities: ['CAPABILITY-CRM-1'] },
176
- obligations: {},
177
- });
178
- expect(matrix.columns[0].subjectId).toBe('CAPABILITY-CRM-1');
179
- expect(matrix.columns[0].subjectName).toBe('CRM Platform');
180
- expect(matrix.cells[0][0].status).toBe('compliant');
181
- });
182
- it('resolves process subject names from canon.subjects', () => {
183
- const canon = emptyCanon();
184
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
185
- canon.requirements.push({ id: 'REQUIREMENT-BAR-1', name: 'Bar' });
186
- canon.assertions.push({
187
- id: 'ASSERTION-P1',
188
- about: 'REQUIREMENT-BAR-1',
189
- subject: 'PROCESS-CS-1',
190
- status: 'partial',
191
- });
192
- const matrix = buildImpactMatrix(canon, {
193
- id: 'V-2', name: 'Test',
194
- subjects: { processes: ['PROCESS-CS-1'] },
195
- obligations: {},
196
- });
197
- expect(matrix.columns[0].subjectName).toBe('Customer Support');
198
- expect(matrix.cells[0][0].status).toBe('partial');
199
- });
200
- it('mixed product + capability columns — names resolved from respective buckets', () => {
201
- const canon = buildCanon();
202
- canon.subjects.push({ id: 'CAPABILITY-CRM-1', name: 'CRM' });
203
- canon.requirements.push({ id: 'REQUIREMENT-CRM-1', name: 'CRM req' });
204
- canon.assertions.push({
205
- id: 'ASSERTION-CRM-1',
206
- about: 'REQUIREMENT-CRM-1',
207
- subject: 'CAPABILITY-CRM-1',
208
- status: 'under_review',
209
- });
210
- const matrix = buildImpactMatrix(canon, {
211
- id: 'V-3', name: 'Mixed',
212
- subjects: { products: ['PRODUCT-A-1'], capabilities: ['CAPABILITY-CRM-1'] },
213
- obligations: {},
214
- });
215
- expect(matrix.columns.map(c => c.subjectId)).toEqual(['PRODUCT-A-1', 'CAPABILITY-CRM-1']);
216
- expect(matrix.columns[0].subjectName).toBe('Product A');
217
- expect(matrix.columns[1].subjectName).toBe('CRM');
218
- });
219
- it('pending_owner cell renders as bound with PENDING status', () => {
220
- const canon = emptyCanon();
221
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
222
- canon.requirements.push({ id: 'REQUIREMENT-PO-1', name: 'PO req' });
223
- canon.assertions.push({
224
- id: 'ASSERTION-PO-1',
225
- about: 'REQUIREMENT-PO-1',
226
- subject: 'PRODUCT-A-1',
227
- status: 'pending_owner',
228
- owner_to_confirm: 'alice@example.com',
229
- });
230
- const matrix = buildImpactMatrix(canon, {
231
- id: 'V-PO', name: 'PO Test',
232
- subjects: { products: ['PRODUCT-A-1'] },
233
- obligations: {},
234
- });
235
- expect(matrix.cells[0][0].kind).toBe('bound');
236
- expect(matrix.cells[0][0].status).toBe('pending_owner');
237
- expect(matrix.cells[0][0].assertions[0].owner_to_confirm).toBe('alice@example.com');
238
- });
239
- it('pending_owner loses to partial in aggregation', () => {
240
- const canon = emptyCanon();
241
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
242
- canon.requirements.push({ id: 'REQUIREMENT-PO-2', name: 'PO req 2' });
243
- canon.assertions.push({ id: 'ASSERTION-PO-2a', about: 'REQUIREMENT-PO-2', subject: 'PRODUCT-A-1', status: 'partial' }, { id: 'ASSERTION-PO-2b', about: 'REQUIREMENT-PO-2', subject: 'PRODUCT-A-1', status: 'pending_owner' });
244
- const matrix = buildImpactMatrix(canon, {
245
- id: 'V-PO2', name: 'PO Agg',
246
- subjects: { products: ['PRODUCT-A-1'] },
247
- obligations: {},
248
- });
249
- expect(matrix.cells[0][0].status).toBe('partial');
250
- });
251
- });
252
- // ── parseImpactViewConfig ───────────────────────────────────────────────────
253
- describe('parseImpactViewConfig', () => {
254
- it('returns ok:false for a non-object', () => {
255
- const r = parseImpactViewConfig(null);
256
- expect(r.ok).toBe(false);
257
- });
258
- it('returns ok:false when id is missing', () => {
259
- const r = parseImpactViewConfig({ name: 'X', subjects: {} });
260
- expect(r.ok).toBe(false);
261
- if (!r.ok)
262
- expect(r.errors.some(e => e.includes('id'))).toBe(true);
263
- });
264
- it('returns ok:false when name is missing', () => {
265
- const r = parseImpactViewConfig({ id: 'X', subjects: {} });
266
- expect(r.ok).toBe(false);
267
- if (!r.ok)
268
- expect(r.errors.some(e => e.includes('name'))).toBe(true);
269
- });
270
- it('unwraps the top-level view: wrapper', () => {
271
- const r = parseImpactViewConfig({ view: { id: 'V-1', name: 'My view', subjects: {} } });
272
- expect(r.ok).toBe(true);
273
- if (r.ok)
274
- expect(r.config.id).toBe('V-1');
275
- });
276
- it('fills all optional fields from COMPLIANCE_IMPACT_DEFAULTS', () => {
277
- const r = parseImpactViewConfig({ id: 'V-1', name: 'My view', subjects: {} });
278
- expect(r.ok).toBe(true);
279
- if (!r.ok)
280
- return;
281
- const c = r.config;
282
- expect(c.subjects.products).toEqual([]);
283
- expect(c.subjects.processes).toEqual([]);
284
- expect(c.subjects.capabilities).toEqual([]);
285
- expect(c.status_display?.show).toEqual(COMPLIANCE_IMPACT_DEFAULTS.status_display.show);
286
- expect(c.order_rows_by).toBe('id');
287
- expect(c.empty_cells?.no_obligation_label).toBe(COMPLIANCE_IMPACT_DEFAULTS.empty_cells.no_obligation_label);
288
- expect(c.empty_cells?.no_obligation_applies_label).toBe(COMPLIANCE_IMPACT_DEFAULTS.empty_cells.no_obligation_applies_label);
289
- });
290
- it('preserves explicit subject lists and snapshot_at', () => {
291
- const r = parseImpactViewConfig({
292
- id: 'V-2',
293
- name: 'View 2',
294
- snapshot_at: '2026-01-01',
295
- subjects: { products: ['PRODUCT-A-1', 'PRODUCT-B-1'] },
296
- });
297
- expect(r.ok).toBe(true);
298
- if (!r.ok)
299
- return;
300
- expect(r.config.subjects.products).toEqual(['PRODUCT-A-1', 'PRODUCT-B-1']);
301
- expect(r.config.snapshot_at).toBe('2026-01-01');
302
- });
303
- it('applies custom order_rows_by:name', () => {
304
- const r = parseImpactViewConfig({ id: 'V-3', name: 'V', subjects: {}, order_rows_by: 'name' });
305
- expect(r.ok).toBe(true);
306
- if (r.ok)
307
- expect(r.config.order_rows_by).toBe('name');
308
- });
309
- it('parses obligation filter correctly', () => {
310
- const r = parseImpactViewConfig({
311
- id: 'V-4',
312
- name: 'V',
313
- subjects: {},
314
- obligations: { filter: { derived_from_codex: ['LAW-X-1'] } },
315
- });
316
- expect(r.ok).toBe(true);
317
- if (r.ok)
318
- expect(r.config.obligations.filter?.derived_from_codex).toEqual(['LAW-X-1']);
319
- });
320
- });
321
- describe('CV-3a — stage grouping (ImpactColumn, extractObjectDetails, buildImpactMatrix stage grain)', () => {
322
- it('default product grain: columns are plain ImpactColumn with label=subjectId', () => {
323
- const canon = buildCanon();
324
- const matrix = buildImpactMatrix(canon, baseConfig);
325
- expect(matrix.columns.map(c => c.subjectId)).toEqual(['PRODUCT-A-1', 'PRODUCT-B-1']);
326
- expect(matrix.columns.map(c => c.label)).toEqual(['PRODUCT-A-1', 'PRODUCT-B-1']);
327
- expect(matrix.columns.every(c => !c.stageId)).toBe(true);
328
- });
329
- it('product-stage grain: expands columns by stage, label is subjectId:stageId', () => {
330
- const canon = buildCanon();
331
- const matrix = buildImpactMatrix(canon, { ...baseConfig, subjects: { products: ['PRODUCT-A-1'] }, grouping: { columns: 'product-stage' } }, [{ objectId: 'PRODUCT-A-1', details: [{ id: 'STAGE-1', name: 'Stage One' }, { id: 'STAGE-2', name: 'Stage Two' }] }]);
332
- expect(matrix.columns.map(c => c.label)).toEqual(['PRODUCT-A-1:STAGE-1', 'PRODUCT-A-1:STAGE-2']);
333
- expect(matrix.columns.map(c => c.stageId)).toEqual(['STAGE-1', 'STAGE-2']);
334
- });
335
- it('assertion without realised_via fills every stage column for its subject', () => {
336
- const canon = emptyCanon();
337
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
338
- // Assertion with no realised_via — covers the whole subject.
339
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
340
- const matrix = buildImpactMatrix(canon, {
341
- id: 'V', name: 'V',
342
- subjects: { products: ['PROD-1'] },
343
- obligations: {},
344
- grouping: { columns: 'product-stage' },
345
- }, [{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1' }, { id: 'S2', name: 's2' }] }]);
346
- // Both stage columns should be bound (no realised_via means all stages inherit).
347
- expect(matrix.cells[0][0].kind).toBe('bound');
348
- expect(matrix.cells[0][1].kind).toBe('bound');
349
- });
350
- it('assertion with realised_via fills only the matching stage column', () => {
351
- const canon = emptyCanon();
352
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
353
- // Assertion only covers STAGE-A.
354
- canon.assertions.push({
355
- id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant',
356
- realised_via: ['STAGE-A'],
357
- });
358
- const matrix = buildImpactMatrix(canon, {
359
- id: 'V', name: 'V',
360
- subjects: { products: ['PROD-1'] },
361
- obligations: {},
362
- grouping: { columns: 'product-stage' },
363
- }, [{ objectId: 'PROD-1', details: [{ id: 'STAGE-A', name: 'a' }, { id: 'STAGE-B', name: 'b' }] }]);
364
- expect(matrix.cells[0][0].kind).toBe('bound'); // STAGE-A: covered
365
- expect(matrix.cells[0][1].kind).toBe('gap'); // STAGE-B: gap
366
- });
367
- it('subject with no stage mapping falls back to single product-grain column', () => {
368
- const canon = buildCanon();
369
- const matrix = buildImpactMatrix(canon, {
370
- ...baseConfig,
371
- subjects: { products: ['PRODUCT-A-1', 'PRODUCT-B-1'] },
372
- grouping: { columns: 'product-stage' },
373
- },
374
- // Only provide stages for A — B falls back to a single column.
375
- [{ objectId: 'PRODUCT-A-1', details: [{ id: 'S1', name: 's1' }] }]);
376
- expect(matrix.columns.map(c => c.label)).toEqual(['PRODUCT-A-1:S1', 'PRODUCT-B-1']);
377
- // PRODUCT-B-1 fallback column: no stageId.
378
- expect(matrix.columns[1].stageId).toBeUndefined();
379
- });
380
- it('extractObjectDetails — returns null for non-blueprint docs', () => {
381
- expect(extractObjectDetails(null)).toBeNull();
382
- expect(extractObjectDetails({ notation: 'requirement', id: 'R1' })).toBeNull();
383
- expect(extractObjectDetails({ process_blueprint: { details: [{ id: 'S1' }] } })).toBeNull(); // missing id
384
- });
385
- it('extractObjectDetails — extracts subjectId and stages from process_blueprint wrapper', () => {
386
- const doc = { process_blueprint: { id: 'PROC-1', notation: 'process_blueprint', stages: [{ id: 'S1', name: 'Stage One' }, { id: 'S2', name: 'Stage Two' }] } };
387
- const sg = extractObjectDetails(doc);
388
- expect(sg).not.toBeNull();
389
- expect(sg.objectId).toBe('PROC-1');
390
- expect(sg.details.map((s) => s.id)).toEqual(['S1', 'S2']);
391
- });
392
- it('renderImpactMarkdown uses column labels in the table header', () => {
393
- const canon = emptyCanon();
394
- canon.requirements.push({ id: 'REQ-1', name: 'Req' });
395
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
396
- const matrix = buildImpactMatrix(canon, {
397
- id: 'V', name: 'Stage Report',
398
- subjects: { products: ['PROD-1'] },
399
- obligations: {},
400
- grouping: { columns: 'product-stage' },
401
- }, [{ objectId: 'PROD-1', details: [{ id: 'S1', name: 'Stage One' }] }]);
402
- const md = renderImpactMarkdown(matrix);
403
- expect(md).toContain('PROD-1:S1');
404
- });
405
- });
406
- describe('CV-3 -- blueprint-lane decorations + obligations lane', () => {
407
- it('computeDeadlineStatus function is available', () => {
408
- expect(typeof computeDeadlineStatus).toBe('function');
409
- });
410
- it('cell.decoration.isNew = false when no snapshot_at', () => {
411
- const canon = emptyCanon();
412
- canon.requirements.push({ id: 'REQ-1', name: 'R1', admitted_at: '2026-01-01' });
413
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
414
- const matrix = buildImpactMatrix(canon, {
415
- id: 'V', name: 'V',
416
- subjects: { products: ['PROD-1'] },
417
- obligations: {},
418
- });
419
- expect(matrix.cells[0][0].decoration.isNew).toBe(false);
420
- });
421
- it('cell.decoration.isNew = true when req admitted after snapshot_at', () => {
422
- const canon = emptyCanon();
423
- canon.requirements.push({ id: 'REQ-1', name: 'R1', admitted_at: '2026-06-01' });
424
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
425
- const matrix = buildImpactMatrix(canon, {
426
- id: 'V', name: 'V',
427
- snapshot_at: '2026-05-01',
428
- subjects: { products: ['PROD-1'] },
429
- obligations: {},
430
- });
431
- // admitted_at (2026-06-01) > snapshot_at (2026-05-01) -> isNew
432
- expect(matrix.cells[0][0].decoration.isNew).toBe(true);
433
- });
434
- it('cell.decoration.isUrgent = true when gap + past_due deadline', () => {
435
- const canon = emptyCanon();
436
- canon.requirements.push({ id: 'REQ-1', name: 'R1', deadline: '2000-01-01' });
437
- // No assertion -> gap cell
438
- const matrix = buildImpactMatrix(canon, {
439
- id: 'V', name: 'V',
440
- subjects: { products: ['PROD-1'] },
441
- obligations: {},
442
- });
443
- expect(matrix.cells[0][0].kind).toBe('gap');
444
- expect(matrix.cells[0][0].decoration.isUrgent).toBe(true);
445
- expect(matrix.cells[0][0].decoration.deadlineStatus).toBe('past_due');
446
- });
447
- it('cell.decoration.isUrgent = false on bound cell even with past deadline', () => {
448
- const canon = emptyCanon();
449
- canon.requirements.push({ id: 'REQ-1', name: 'R1', deadline: '2000-01-01' });
450
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
451
- const matrix = buildImpactMatrix(canon, {
452
- id: 'V', name: 'V',
453
- subjects: { products: ['PROD-1'] },
454
- obligations: {},
455
- });
456
- expect(matrix.cells[0][0].kind).toBe('bound');
457
- // Not urgent: cell is bound, not a gap
458
- expect(matrix.cells[0][0].decoration.isUrgent).toBe(false);
459
- });
460
- it('obligationsLane lists derived_from codex IDs for non-gap columns', () => {
461
- const canon = emptyCanon();
462
- canon.requirements.push({ id: 'REQ-1', name: 'R1', derived_from: ['LAW-X', 'REG-Y'] });
463
- canon.requirements.push({ id: 'REQ-2', name: 'R2', derived_from: ['LAW-X'] });
464
- // Only REQ-1 is bound in PROD-1 column; REQ-2 is a gap
465
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
466
- const matrix = buildImpactMatrix(canon, {
467
- id: 'V', name: 'V',
468
- subjects: { products: ['PROD-1'] },
469
- obligations: {},
470
- });
471
- // obligationsLane[0] (PROD-1 column): REQ-1 is bound -> derived_from -> LAW-X, REG-Y sorted
472
- expect(matrix.obligationsLane[0]).toEqual(['LAW-X', 'REG-Y']);
473
- });
474
- it('obligationsLane is empty for columns with only gap cells', () => {
475
- const canon = emptyCanon();
476
- canon.requirements.push({ id: 'REQ-1', name: 'R1', derived_from: ['LAW-X'] });
477
- // No assertions -> all gaps
478
- const matrix = buildImpactMatrix(canon, {
479
- id: 'V', name: 'V',
480
- subjects: { products: ['PROD-1'] },
481
- obligations: {},
482
- });
483
- expect(matrix.obligationsLane[0]).toEqual([]);
484
- });
485
- });
486
- describe('computeDeadlineStatus', () => {
487
- it('returns none for missing deadline', () => {
488
- expect(computeDeadlineStatus(undefined, '2026-06-01')).toBe('none');
489
- });
490
- it('returns past_due when deadline < today', () => {
491
- expect(computeDeadlineStatus('2026-01-01', '2026-06-01')).toBe('past_due');
492
- });
493
- it('returns in_force within 30 days', () => {
494
- expect(computeDeadlineStatus('2026-06-20', '2026-06-01')).toBe('in_force');
495
- });
496
- it('returns upcoming more than 30 days away', () => {
497
- expect(computeDeadlineStatus('2026-12-31', '2026-06-01')).toBe('upcoming');
498
- });
499
- });
500
- // ── parseImpactViewConfig — grouping field ────────────────────────────────────
501
- describe('parseImpactViewConfig — grouping field', () => {
502
- it('parses grouping.columns: product-stage', () => {
503
- const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'product-stage' } });
504
- expect(r.ok).toBe(true);
505
- if (r.ok)
506
- expect(r.config.grouping?.columns).toBe('product-stage');
507
- });
508
- it('parses grouping.columns: product-stage-task', () => {
509
- const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'product-stage-task' } });
510
- expect(r.ok).toBe(true);
511
- if (r.ok)
512
- expect(r.config.grouping?.columns).toBe('product-stage-task');
513
- });
514
- it('parses grouping.columns: product (coarsest grain)', () => {
515
- const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'product' } });
516
- expect(r.ok).toBe(true);
517
- if (r.ok)
518
- expect(r.config.grouping?.columns).toBe('product');
519
- });
520
- it('normalises backward-compat alias object-details → product-stage', () => {
521
- const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'object-details' } });
522
- expect(r.ok).toBe(true);
523
- if (r.ok)
524
- expect(r.config.grouping?.columns).toBe('product-stage');
525
- });
526
- it('normalises backward-compat alias object → product', () => {
527
- const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'object' } });
528
- expect(r.ok).toBe(true);
529
- if (r.ok)
530
- expect(r.config.grouping?.columns).toBe('product');
531
- });
532
- it('leaves grouping undefined when the field is absent', () => {
533
- const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {} });
534
- expect(r.ok).toBe(true);
535
- if (r.ok)
536
- expect(r.config.grouping).toBeUndefined();
537
- });
538
- it('leaves grouping undefined for an unrecognised columns value', () => {
539
- const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: 'unknown-grain' } });
540
- expect(r.ok).toBe(true);
541
- if (r.ok)
542
- expect(r.config.grouping).toBeUndefined();
543
- });
544
- });
545
- // ── CV-3a — product-stage-task grain ─────────────────────────────────────────
546
- describe('CV-3a — product-stage-task grain (buildImpactMatrix, buildTaskColumns)', () => {
547
- it('expands columns to (subject, stage, task) triples; label is subjectId:stageId:taskId', () => {
548
- const canon = emptyCanon();
549
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
550
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
551
- const matrix = buildImpactMatrix(canon, {
552
- id: 'V', name: 'V',
553
- subjects: { products: ['PROD-1'] },
554
- obligations: {},
555
- grouping: { columns: 'product-stage-task' },
556
- }, [{
557
- objectId: 'PROD-1',
558
- details: [
559
- { id: 'STAGE-A', name: 'Stage A', tasks: [{ id: 'TASK-1', name: 'Task 1' }, { id: 'TASK-2', name: 'Task 2' }] },
560
- ],
561
- }]);
562
- expect(matrix.columns.map(c => c.label)).toEqual(['PROD-1:STAGE-A:TASK-1', 'PROD-1:STAGE-A:TASK-2']);
563
- expect(matrix.columns[0]).toMatchObject({ subjectId: 'PROD-1', stageId: 'STAGE-A', taskId: 'TASK-1' });
564
- expect(matrix.columns[1]).toMatchObject({ subjectId: 'PROD-1', stageId: 'STAGE-A', taskId: 'TASK-2' });
565
- });
566
- it('assertion without realised_via fills every task column for its subject', () => {
567
- const canon = emptyCanon();
568
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
569
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant' });
570
- const matrix = buildImpactMatrix(canon, {
571
- id: 'V', name: 'V',
572
- subjects: { products: ['PROD-1'] },
573
- obligations: {},
574
- grouping: { columns: 'product-stage-task' },
575
- }, [{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1', tasks: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] }] }]);
576
- expect(matrix.cells[0][0].kind).toBe('bound');
577
- expect(matrix.cells[0][1].kind).toBe('bound');
578
- });
579
- it('assertion with realised_via: [taskId] fills only the matching task column', () => {
580
- const canon = emptyCanon();
581
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
582
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant', realised_via: ['T1'] });
583
- const matrix = buildImpactMatrix(canon, {
584
- id: 'V', name: 'V',
585
- subjects: { products: ['PROD-1'] },
586
- obligations: {},
587
- grouping: { columns: 'product-stage-task' },
588
- }, [{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1', tasks: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] }] }]);
589
- expect(matrix.cells[0][0].kind).toBe('bound'); // T1: covered
590
- expect(matrix.cells[0][1].kind).toBe('gap'); // T2: not covered
591
- });
592
- it('assertion with realised_via: [stageId] fills all task columns in that stage', () => {
593
- const canon = emptyCanon();
594
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
595
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROD-1', status: 'compliant', realised_via: ['S1'] });
596
- const matrix = buildImpactMatrix(canon, {
597
- id: 'V', name: 'V',
598
- subjects: { products: ['PROD-1'] },
599
- obligations: {},
600
- grouping: { columns: 'product-stage-task' },
601
- }, [{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1', tasks: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] }] }]);
602
- expect(matrix.cells[0][0].kind).toBe('bound');
603
- expect(matrix.cells[0][1].kind).toBe('bound');
604
- });
605
- it('stage with no tasks falls back to stage-grain column', () => {
606
- const canon = emptyCanon();
607
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
608
- const matrix = buildImpactMatrix(canon, {
609
- id: 'V', name: 'V',
610
- subjects: { products: ['PROD-1'] },
611
- obligations: {},
612
- grouping: { columns: 'product-stage-task' },
613
- }, [{ objectId: 'PROD-1', details: [{ id: 'S1', name: 's1' }] }]);
614
- expect(matrix.columns.map(c => c.label)).toEqual(['PROD-1:S1']);
615
- expect(matrix.columns[0].taskId).toBeUndefined();
616
- expect(matrix.columns[0].stageId).toBe('S1');
617
- });
618
- it('subject with no objectDetails falls back to product-grain column', () => {
619
- const canon = emptyCanon();
620
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
621
- const matrix = buildImpactMatrix(canon, {
622
- id: 'V', name: 'V',
623
- subjects: { products: ['PROD-1'] },
624
- obligations: {},
625
- grouping: { columns: 'product-stage-task' },
626
- });
627
- expect(matrix.columns.map(c => c.label)).toEqual(['PROD-1']);
628
- expect(matrix.columns[0].stageId).toBeUndefined();
629
- });
630
- });
631
- // ── extractProcessFlowTasks ───────────────────────────────────────────────────
632
- describe('extractProcessFlowTasks', () => {
633
- it('returns null for non-process documents', () => {
634
- expect(extractProcessFlowTasks(null)).toBeNull();
635
- expect(extractProcessFlowTasks({ notation: 'requirement', id: 'R1' })).toBeNull();
636
- expect(extractProcessFlowTasks({ notation: 'process_blueprint', id: 'BP-1' })).toBeNull();
637
- });
638
- it('returns null when process has no flow.steps', () => {
639
- expect(extractProcessFlowTasks({ notation: 'process', id: 'PROC-1' })).toBeNull();
640
- expect(extractProcessFlowTasks({ notation: 'process', id: 'PROC-1', flow: { sequence: [] } })).toBeNull();
641
- });
642
- it('returns null when no task-type steps exist', () => {
643
- const doc = {
644
- notation: 'process', id: 'PROC-1',
645
- flow: { steps: [
646
- { id: 'S-1', type: 'startEvent' },
647
- { id: 'G-1', type: 'exclusiveGateway' },
648
- { id: 'E-1', type: 'endEvent' },
649
- ] },
650
- };
651
- expect(extractProcessFlowTasks(doc)).toBeNull();
652
- });
653
- it('extracts task-type steps and skips events/gateways', () => {
654
- const doc = {
655
- notation: 'process', id: 'PROC-1',
656
- flow: { steps: [
657
- { id: 'S-1', type: 'startEvent' },
658
- { id: 'STEP-T1', type: 'task', name: 'Task One' },
659
- { id: 'G-1', type: 'exclusiveGateway', name: 'Branch?' },
660
- { id: 'STEP-T2', type: 'userTask', name: 'User Task' },
661
- { id: 'E-1', type: 'endEvent' },
662
- ] },
663
- };
664
- const result = extractProcessFlowTasks(doc);
665
- expect(result).not.toBeNull();
666
- expect(result.objectId).toBe('PROC-1');
667
- expect(result.details.map(d => d.id)).toEqual(['STEP-T1', 'STEP-T2']);
668
- expect(result.details[0].name).toBe('Task One');
669
- });
670
- it('falls back to step id as name when name is absent', () => {
671
- const doc = {
672
- notation: 'process', id: 'PROC-1',
673
- flow: { steps: [{ id: 'STEP-T1', type: 'serviceTask' }] },
674
- };
675
- const result = extractProcessFlowTasks(doc);
676
- expect(result.details[0].name).toBe('STEP-T1');
677
- });
678
- });
679
- // ── mergeStageTaskDetails ─────────────────────────────────────────────────────
680
- describe('mergeStageTaskDetails', () => {
681
- const stages = {
682
- objectId: 'PROC-1',
683
- details: [
684
- { id: 'S1', name: 'Stage 1' },
685
- { id: 'S2', name: 'Stage 2' },
686
- ],
687
- };
688
- it('returns stageInput unchanged when taskInput is null', () => {
689
- expect(mergeStageTaskDetails(stages, null)).toBe(stages);
690
- });
691
- it('returns stageInput unchanged when objectIds do not match', () => {
692
- const other = { objectId: 'PROC-99', details: [{ id: 'T1', name: 't1' }] };
693
- expect(mergeStageTaskDetails(stages, other)).toBe(stages);
694
- });
695
- it('embeds all tasks into every stage when no stageOwner map is provided', () => {
696
- const tasks = { objectId: 'PROC-1', details: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] };
697
- const merged = mergeStageTaskDetails(stages, tasks);
698
- expect(merged.objectId).toBe('PROC-1');
699
- expect(merged.details[0].tasks?.map(t => t.id)).toEqual(['T1', 'T2']);
700
- expect(merged.details[1].tasks?.map(t => t.id)).toEqual(['T1', 'T2']);
701
- });
702
- it('distributes tasks by stageOwner map', () => {
703
- const tasks = { objectId: 'PROC-1', details: [{ id: 'T1', name: 't1' }, { id: 'T2', name: 't2' }] };
704
- const merged = mergeStageTaskDetails(stages, tasks, { S1: ['T1'], S2: ['T2'] });
705
- expect(merged.details[0].tasks?.map(t => t.id)).toEqual(['T1']);
706
- expect(merged.details[1].tasks?.map(t => t.id)).toEqual(['T2']);
707
- });
708
- it('leaves stages without matching stageOwner entries task-free', () => {
709
- const tasks = { objectId: 'PROC-1', details: [{ id: 'T1', name: 't1' }] };
710
- const merged = mergeStageTaskDetails(stages, tasks, { S1: ['T1'], S2: [] });
711
- expect(merged.details[0].tasks?.map(t => t.id)).toEqual(['T1']);
712
- // S2 has no tasks in stageOwner, filter returns [] → no tasks embedded
713
- expect(merged.details[1].tasks).toBeUndefined();
714
- });
715
- });
716
- // ── COMPIMP-010 — subject type label invariant (#345) ────────────────────────
717
- describe('COMPIMP-010 — subject type label invariant (#345)', () => {
718
- it('process-only view: columns carry subjectType=process and plain ID labels (regression)', () => {
719
- const canon = emptyCanon();
720
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
721
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
722
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PROCESS-CS-1', status: 'compliant' });
723
- const matrix = buildImpactMatrix(canon, {
724
- id: 'V', name: 'Process-only',
725
- subjects: { processes: ['PROCESS-CS-1'] },
726
- obligations: {},
727
- });
728
- expect(matrix.columns).toHaveLength(1);
729
- expect(matrix.columns[0].subjectType).toBe('process');
730
- // Process-only: label is just the ID — no [PRODUCT] prefix (regression)
731
- expect(matrix.columns[0].label).toBe('PROCESS-CS-1');
732
- expect(matrix.columns[0].label).not.toContain('[PRODUCT]');
733
- expect(matrix.cells[0][0].status).toBe('compliant');
734
- });
735
- it('product-only view: columns carry subjectType=product and plain ID labels', () => {
736
- const canon = emptyCanon();
737
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
738
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
739
- canon.assertions.push({ id: 'ASS-1', about: 'REQ-1', subject: 'PRODUCT-A-1', status: 'compliant' });
740
- const matrix = buildImpactMatrix(canon, {
741
- id: 'V', name: 'Product-only',
742
- subjects: { products: ['PRODUCT-A-1'] },
743
- obligations: {},
744
- });
745
- expect(matrix.columns[0].subjectType).toBe('product');
746
- expect(matrix.columns[0].label).toBe('PRODUCT-A-1');
747
- expect(matrix.columns[0].label).not.toContain('[PROCESS]');
748
- expect(matrix.findings).toHaveLength(0);
749
- });
750
- it('combined view: product columns carry [PRODUCT] badge; process columns carry [PROCESS] badge', () => {
751
- const canon = emptyCanon();
752
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
753
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
754
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
755
- const matrix = buildImpactMatrix(canon, {
756
- id: 'V', name: 'Combined',
757
- subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
758
- obligations: {},
759
- });
760
- expect(matrix.columns).toHaveLength(2);
761
- const prodCol = matrix.columns.find(c => c.subjectId === 'PRODUCT-A-1');
762
- const procCol = matrix.columns.find(c => c.subjectId === 'PROCESS-CS-1');
763
- expect(prodCol.subjectType).toBe('product');
764
- expect(prodCol.label).toBe('[PRODUCT] PRODUCT-A-1');
765
- expect(procCol.subjectType).toBe('process');
766
- expect(procCol.label).toBe('[PROCESS] PROCESS-CS-1');
767
- });
768
- it('combined view: markdown renders [PRODUCT] / [PROCESS] column headers', () => {
769
- const canon = emptyCanon();
770
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
771
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
772
- canon.requirements.push({ id: 'REQ-1', name: 'R1' });
773
- const matrix = buildImpactMatrix(canon, {
774
- id: 'V', name: 'Combined',
775
- subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
776
- obligations: {},
777
- });
778
- const md = renderImpactMarkdown(matrix);
779
- expect(md).toContain('[PRODUCT] PRODUCT-A-1');
780
- expect(md).toContain('[PROCESS] PROCESS-CS-1');
781
- });
782
- it('capability column always has subjectType=capability', () => {
783
- const canon = emptyCanon();
784
- canon.subjects.push({ id: 'CAPABILITY-CRM-1', name: 'CRM' });
785
- const matrix = buildImpactMatrix(canon, {
786
- id: 'V', name: 'Cap',
787
- subjects: { capabilities: ['CAPABILITY-CRM-1'] },
788
- obligations: {},
789
- });
790
- expect(matrix.columns[0].subjectType).toBe('capability');
791
- });
792
- it('COMPIMP-009 warning: product-* grouping with process-only subjects', () => {
793
- const canon = emptyCanon();
794
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'CS' });
795
- const matrix = buildImpactMatrix(canon, {
796
- id: 'V', name: 'V',
797
- subjects: { processes: ['PROCESS-CS-1'] },
798
- obligations: {},
799
- grouping: { columns: 'product' },
800
- });
801
- const c009 = matrix.findings.find(f => f.code === 'COMPIMP-009');
802
- expect(c009).toBeDefined();
803
- expect(c009.severity).toBe('warning');
804
- expect(c009.message).toContain('process');
805
- });
806
- it('COMPIMP-010 error: product-stage grouping with process subjects', () => {
807
- const canon = emptyCanon();
808
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'CS' });
809
- const matrix = buildImpactMatrix(canon, {
810
- id: 'V', name: 'V',
811
- subjects: { processes: ['PROCESS-CS-1'] },
812
- obligations: {},
813
- grouping: { columns: 'product-stage' },
814
- }, [{ objectId: 'PROCESS-CS-1', details: [{ id: 'STAGE-A', name: 'Stage A' }] }]);
815
- const c010 = matrix.findings.find(f => f.code === 'COMPIMP-010');
816
- expect(c010).toBeDefined();
817
- expect(c010.severity).toBe('error');
818
- expect(c010.message).toContain('process-stage');
819
- });
820
- it('no COMPIMP-010 when process-stage grouping is used for process subjects', () => {
821
- const canon = emptyCanon();
822
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'CS' });
823
- const matrix = buildImpactMatrix(canon, {
824
- id: 'V', name: 'V',
825
- subjects: { processes: ['PROCESS-CS-1'] },
826
- obligations: {},
827
- grouping: { columns: 'process-stage' },
828
- }, [{ objectId: 'PROCESS-CS-1', details: [{ id: 'STAGE-A', name: 'Stage A' }] }]);
829
- expect(matrix.findings.some(f => f.code === 'COMPIMP-010')).toBe(false);
830
- });
831
- it('parseImpactViewConfig accepts process-centric column values', () => {
832
- for (const col of ['process', 'process-stage', 'process-stage-task']) {
833
- const r = parseImpactViewConfig({ id: 'V', name: 'V', subjects: {}, grouping: { columns: col } });
834
- expect(r.ok).toBe(true);
835
- if (r.ok)
836
- expect(r.config.grouping?.columns).toBe(col);
837
- }
838
- });
839
- it('matrix.findings is empty for a conformant product-only view', () => {
840
- const canon = emptyCanon();
841
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
842
- const matrix = buildImpactMatrix(canon, {
843
- id: 'V', name: 'V',
844
- subjects: { products: ['PRODUCT-A-1'] },
845
- obligations: {},
846
- });
847
- expect(matrix.findings).toEqual([]);
848
- });
849
- it('COMPIMP-011 error: report_type=product with subjects.processes strips process columns', () => {
850
- const canon = emptyCanon();
851
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
852
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
853
- const matrix = buildImpactMatrix(canon, {
854
- id: 'V', name: 'V',
855
- report_type: 'product',
856
- subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
857
- obligations: {},
858
- });
859
- // COMPIMP-011 fires
860
- const c011 = matrix.findings.find(f => f.code === 'COMPIMP-011');
861
- expect(c011).toBeDefined();
862
- expect(c011.severity).toBe('error');
863
- // Spurious PROCESS column is stripped
864
- expect(matrix.columns).toHaveLength(1);
865
- expect(matrix.columns[0].subjectType).toBe('product');
866
- expect(matrix.columns[0].subjectId).toBe('PRODUCT-A-1');
867
- });
868
- it('COMPIMP-011 error: report_type=process with subjects.products strips product columns', () => {
869
- const canon = emptyCanon();
870
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
871
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
872
- const matrix = buildImpactMatrix(canon, {
873
- id: 'V', name: 'V',
874
- report_type: 'process',
875
- subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
876
- obligations: {},
877
- });
878
- const c011 = matrix.findings.find(f => f.code === 'COMPIMP-011');
879
- expect(c011).toBeDefined();
880
- expect(c011.severity).toBe('error');
881
- // Spurious PRODUCT column is stripped
882
- expect(matrix.columns).toHaveLength(1);
883
- expect(matrix.columns[0].subjectType).toBe('process');
884
- expect(matrix.columns[0].subjectId).toBe('PROCESS-CS-1');
885
- });
886
- it('report_type=combined allows both product and process columns without COMPIMP-011', () => {
887
- const canon = emptyCanon();
888
- canon.products.push({ id: 'PRODUCT-A-1', name: 'Product A' });
889
- canon.subjects.push({ id: 'PROCESS-CS-1', name: 'Customer Support' });
890
- const matrix = buildImpactMatrix(canon, {
891
- id: 'V', name: 'V',
892
- report_type: 'combined',
893
- subjects: { products: ['PRODUCT-A-1'], processes: ['PROCESS-CS-1'] },
894
- obligations: {},
895
- });
896
- expect(matrix.findings.some(f => f.code === 'COMPIMP-011')).toBe(false);
897
- expect(matrix.columns).toHaveLength(2);
898
- });
899
- it('parseImpactViewConfig round-trips report_type', () => {
900
- for (const rt of ['product', 'process', 'combined']) {
901
- const r = parseImpactViewConfig({ id: 'V', name: 'V', report_type: rt, subjects: {}, obligations: {} });
902
- expect(r.ok).toBe(true);
903
- if (r.ok)
904
- expect(r.config.report_type).toBe(rt);
905
- }
906
- });
907
- it('parseImpactViewConfig ignores unknown report_type values', () => {
908
- const r = parseImpactViewConfig({ id: 'V', name: 'V', report_type: 'unknown-type', subjects: {}, obligations: {} });
909
- expect(r.ok).toBe(true);
910
- if (r.ok)
911
- expect(r.config.report_type).toBeUndefined();
912
- });
913
- });