@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,209 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import * as fs from 'node:fs';
3
- import * as path from 'node:path';
4
- import yaml from 'js-yaml';
5
- import { resolveFGCA, isFGCAViewDoc } from '../resolver.js';
6
- import { parseCanonicalFGCA } from '../parse-canonical.js';
7
-
8
- // ── Inline canon element store (mirrors strategy-2026 data split into per-element form) ─
9
-
10
- const ELEMENTS = [
11
- { notation: 'driver', id: 'FACTOR-1', name: 'Competitive market pressure', type: 'external' },
12
- { notation: 'driver', id: 'FACTOR-2', name: 'Digital adoption acceleration', type: 'external' },
13
- { notation: 'goal', id: 'GOAL-1', name: 'Grow revenue by 20%', factors: ['FACTOR-1', 'FACTOR-2'] },
14
- { notation: 'goal', id: 'GOAL-2', name: 'Reduce operational costs', factors: ['FACTOR-2'] },
15
- { notation: 'goal', id: 'GOAL-3', name: 'Improve customer retention', factors: ['FACTOR-1'] },
16
- { notation: 'change', id: 'CHANGE-1', name: 'Launch new product line', goals: ['GOAL-1'] },
17
- { notation: 'change', id: 'CHANGE-2', name: 'Automate manual processes', goals: ['GOAL-2'] },
18
- { notation: 'change', id: 'CHANGE-3', name: 'Enhance support platform', goals: ['GOAL-3'] },
19
- { notation: 'activity', id: 'ACTIVITY-1', name: 'Market research', changes: ['CHANGE-1'] },
20
- { notation: 'activity', id: 'ACTIVITY-2', name: 'MVP development', changes: ['CHANGE-1'] },
21
- { notation: 'activity', id: 'ACTIVITY-3', name: 'Process audit', changes: ['CHANGE-2'] },
22
- { notation: 'activity', id: 'ACTIVITY-4', name: 'RPA tooling rollout', changes: ['CHANGE-2'] },
23
- { notation: 'activity', id: 'ACTIVITY-5', name: 'CRM implementation', changes: ['CHANGE-3'] },
24
- ];
25
-
26
- const SOURCES = { elements: ELEMENTS, relations: [] };
27
-
28
- const VIEW_DOC = {
29
- notation: 'dgca',
30
- id: 'FGCA-STRAT-1',
31
- name: 'Strategy 2026 — FGCA chain',
32
- spec_version: '0.1',
33
- view_config: {
34
- goals: { filter: 'all' },
35
- factors: { surface: 'derived' },
36
- changes: { surface: 'derived' },
37
- activities: { surface: 'derived' },
38
- },
39
- };
40
-
41
- // ── isFGCAViewDoc ─────────────────────────────────────────────────────────────
42
-
43
- describe('isFGCAViewDoc', () => {
44
- it('returns true for a view_config-based doc', () => {
45
- expect(isFGCAViewDoc(VIEW_DOC)).toBe(true);
46
- });
47
-
48
- it('returns false for an inline doc with factors/goals arrays', () => {
49
- expect(isFGCAViewDoc({
50
- notation: 'dgca', id: 'FGCA-1', name: 'x',
51
- factors: [], goals: [], changes: [], activities: [],
52
- })).toBe(false);
53
- });
54
-
55
- it('returns false for non-objects', () => {
56
- expect(isFGCAViewDoc(null)).toBe(false);
57
- expect(isFGCAViewDoc('string')).toBe(false);
58
- expect(isFGCAViewDoc(42)).toBe(false);
59
- });
60
- });
61
-
62
- // ── resolveFGCA — goals.filter=all (default) ──────────────────────────────────
63
-
64
- describe('resolveFGCA — goals.filter=all', () => {
65
- it('includes all goals, changes, and activities', () => {
66
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
67
- expect((doc['goals'] as unknown[]).length).toBe(3);
68
- expect((doc['changes'] as unknown[]).length).toBe(3);
69
- expect((doc['actions'] as unknown[]).length).toBe(5);
70
- });
71
-
72
- it('derives factors from all goal.factors[] refs', () => {
73
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
74
- const factorIds = (doc['factors'] as Array<{ id: string }>).map((f) => f.id);
75
- expect(factorIds).toContain('FACTOR-1');
76
- expect(factorIds).toContain('FACTOR-2');
77
- expect(factorIds.length).toBe(2);
78
- });
79
-
80
- it('passes parseCanonicalFGCA and produces a fully valid internal doc', () => {
81
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
82
- const r = parseCanonicalFGCA(doc);
83
- expect(r.valid).toBe(true);
84
- expect(r.errors).toEqual([]);
85
- expect(r.parsed?.goals).toHaveLength(3);
86
- expect(r.parsed?.factors).toHaveLength(2);
87
- expect(r.parsed?.changes).toHaveLength(3);
88
- expect(r.parsed?.activities).toHaveLength(5);
89
- });
90
-
91
- it('carries view doc metadata (id, name, spec_version)', () => {
92
- const doc = resolveFGCA(VIEW_DOC, SOURCES);
93
- expect(doc['notation']).toBe('dgca');
94
- expect(doc['id']).toBe('FGCA-STRAT-1');
95
- expect(doc['name']).toBe('Strategy 2026 — FGCA chain');
96
- expect(doc['spec_version']).toBe('0.1');
97
- });
98
- });
99
-
100
- // ── resolveFGCA — goals.filter=ids ────────────────────────────────────────────
101
-
102
- describe('resolveFGCA — goals.filter=ids', () => {
103
- it('narrows to the specified goal and its derived changes + activities', () => {
104
- const viewDoc = {
105
- ...VIEW_DOC,
106
- view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
107
- };
108
- const doc = resolveFGCA(viewDoc, SOURCES);
109
- const goalIds = (doc['goals'] as Array<{ id: string }>).map((g) => g.id);
110
- expect(goalIds).toEqual(['GOAL-1']);
111
- const changeIds = (doc['changes'] as Array<{ id: string }>).map((c) => c.id);
112
- expect(changeIds).toEqual(['CHANGE-1']);
113
- const actIds = (doc['actions'] as Array<{ id: string }>).map((a) => a.id).sort();
114
- expect(actIds).toEqual(['ACTIVITY-1', 'ACTIVITY-2']);
115
- const r = parseCanonicalFGCA(doc);
116
- expect(r.valid).toBe(true);
117
- });
118
-
119
- it('returns empty arrays when none of the requested ids exist in canon', () => {
120
- const viewDoc = {
121
- ...VIEW_DOC,
122
- view_config: { goals: { filter: 'ids', ids: ['GOAL-NONEXISTENT-1'] }, factors: { surface: 'derived' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
123
- };
124
- const doc = resolveFGCA(viewDoc, SOURCES);
125
- expect((doc['goals'] as unknown[]).length).toBe(0);
126
- expect((doc['changes'] as unknown[]).length).toBe(0);
127
- expect((doc['factors'] as unknown[]).length).toBe(0);
128
- });
129
- });
130
-
131
- // ── resolveFGCA — surface=all ─────────────────────────────────────────────────
132
-
133
- describe('resolveFGCA — surface=all', () => {
134
- it('factors.surface=all includes every factor even when only some are referenced', () => {
135
- const viewDoc = {
136
- ...VIEW_DOC,
137
- view_config: { goals: { filter: 'ids', ids: ['GOAL-3'] }, factors: { surface: 'all' }, changes: { surface: 'derived' }, activities: { surface: 'derived' } },
138
- };
139
- const doc = resolveFGCA(viewDoc, SOURCES);
140
- // GOAL-3 only references FACTOR-1, but surface=all → both factors
141
- expect((doc['factors'] as unknown[]).length).toBe(2);
142
- });
143
-
144
- it('changes.surface=all includes every change', () => {
145
- const viewDoc = {
146
- ...VIEW_DOC,
147
- view_config: { goals: { filter: 'ids', ids: ['GOAL-1'] }, factors: { surface: 'derived' }, changes: { surface: 'all' }, activities: { surface: 'derived' } },
148
- };
149
- const doc = resolveFGCA(viewDoc, SOURCES);
150
- expect((doc['changes'] as unknown[]).length).toBe(3);
151
- });
152
- });
153
-
154
- // ── resolveFGCA — empty / degenerate inputs ───────────────────────────────────
155
-
156
- describe('resolveFGCA — empty sources', () => {
157
- it('returns empty arrays when canon has no elements', () => {
158
- const doc = resolveFGCA(VIEW_DOC, { elements: [], relations: [] });
159
- expect((doc['goals'] as unknown[]).length).toBe(0);
160
- expect((doc['factors'] as unknown[]).length).toBe(0);
161
- expect((doc['changes'] as unknown[]).length).toBe(0);
162
- expect((doc['actions'] as unknown[]).length).toBe(0);
163
- });
164
-
165
- it('returns empty arrays for a non-object viewDoc', () => {
166
- const doc = resolveFGCA(null, SOURCES);
167
- expect((doc['goals'] as unknown[]).length).toBe(0);
168
- });
169
- });
170
-
171
- // ── File-based regression — resolver + canon fixture + parseCanonicalFGCA ─────
172
-
173
- describe('resolveFGCA — file-based regression against canon fixture', () => {
174
- const CANON_ROOT = path.resolve(
175
- process.cwd(), '..', '..', 'tests', 'fixtures', 'notation-corpus', 'dgca', 'canon',
176
- );
177
- const VIEW_DIR = path.join(CANON_ROOT, 'views');
178
- const ELEM_DIR = path.join(CANON_ROOT, 'elements');
179
-
180
- function loadYamlsUnder(dir: string): unknown[] {
181
- if (!fs.existsSync(dir)) return [];
182
- const out: unknown[] = [];
183
- function walk(d: string) {
184
- for (const entry of fs.readdirSync(d, { withFileTypes: true })) {
185
- const full = path.join(d, entry.name);
186
- if (entry.isDirectory()) { walk(full); }
187
- else if (entry.name.endsWith('.yaml')) { out.push(yaml.load(fs.readFileSync(full, 'utf8'))); }
188
- }
189
- }
190
- walk(dir);
191
- return out;
192
- }
193
-
194
- const viewFiles = fs.existsSync(VIEW_DIR)
195
- ? fs.readdirSync(VIEW_DIR).filter((f) => f.endsWith('.transitrix.yaml'))
196
- : [];
197
-
198
- for (const file of viewFiles) {
199
- it(`resolves ${file} against canon fixtures and passes parseCanonicalFGCA`, () => {
200
- const viewDoc = yaml.load(fs.readFileSync(path.join(VIEW_DIR, file), 'utf8'));
201
- expect(isFGCAViewDoc(viewDoc)).toBe(true);
202
- const elements = loadYamlsUnder(ELEM_DIR);
203
- const doc = resolveFGCA(viewDoc, { elements, relations: [] });
204
- const r = parseCanonicalFGCA(doc);
205
- expect(r.valid).toBe(true);
206
- expect(r.errors).toEqual([]);
207
- });
208
- }
209
- });
@@ -1,142 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import { validateFGCADoc } from '../validate.js';
3
-
4
- const VALID_DOC = {
5
- notation: 'dgca',
6
- factors: [{ id: 1, name: 'Market pressure' }],
7
- goals: [{ id: 1, name: 'Grow revenue', factor: [{ id: 1 }] }],
8
- changes: [{ id: 1, name: 'Launch product', goal_id: 1, activity_ids: [1] }],
9
- actions: [{ id: 1, name: 'Market research', goal_id: 1 }],
10
- };
11
-
12
- describe('validateFGCADoc', () => {
13
- it('accepts a valid document', () => {
14
- const result = validateFGCADoc(VALID_DOC);
15
- expect(result.valid).toBe(true);
16
- expect(result.errors).toHaveLength(0);
17
- });
18
-
19
- it('rejects non-object input', () => {
20
- expect(validateFGCADoc('string').valid).toBe(false);
21
- expect(validateFGCADoc(null).valid).toBe(false);
22
- expect(validateFGCADoc(42).valid).toBe(false);
23
- });
24
-
25
- it('errors on missing notation field', () => {
26
- const { notation: _, ...without } = VALID_DOC;
27
- const result = validateFGCADoc(without);
28
- expect(result.valid).toBe(false);
29
- expect(result.errors[0].code).toBe('MISSING_NOTATION');
30
- });
31
-
32
- it('errors on wrong notation value', () => {
33
- const result = validateFGCADoc({ ...VALID_DOC, notation: 'goals' });
34
- expect(result.valid).toBe(false);
35
- expect(result.errors[0].code).toBe('WRONG_NOTATION');
36
- });
37
-
38
- it('errors when factors array is missing', () => {
39
- const { factors: _, ...without } = VALID_DOC;
40
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
41
- expect(result.valid).toBe(false);
42
- expect(result.errors.some(e => e.path === 'factors')).toBe(true);
43
- });
44
-
45
- it('errors when goals array is missing', () => {
46
- const { goals: _, ...without } = VALID_DOC;
47
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
48
- expect(result.valid).toBe(false);
49
- expect(result.errors.some(e => e.path === 'goals')).toBe(true);
50
- });
51
-
52
- it('errors when changes array is missing', () => {
53
- const { changes: _, ...without } = VALID_DOC;
54
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
55
- expect(result.valid).toBe(false);
56
- expect(result.errors.some(e => e.path === 'changes')).toBe(true);
57
- });
58
-
59
- it('errors when actions array is missing', () => {
60
- const { actions: _, ...without } = VALID_DOC;
61
- const result = validateFGCADoc({ ...without, notation: 'dgca' });
62
- expect(result.valid).toBe(false);
63
- expect(result.errors.some(e => e.path === 'actions')).toBe(true);
64
- });
65
-
66
- it('errors on empty factor name', () => {
67
- const result = validateFGCADoc({ ...VALID_DOC, factors: [{ id: 1, name: '' }] });
68
- expect(result.valid).toBe(false);
69
- expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
70
- });
71
-
72
- it('errors on empty goal name', () => {
73
- const result = validateFGCADoc({ ...VALID_DOC, goals: [{ id: 1, name: ' ', factor: [] }] });
74
- expect(result.valid).toBe(false);
75
- expect(result.errors.some(e => e.code === 'EMPTY_NAME')).toBe(true);
76
- });
77
-
78
- it('warns on broken factor reference in goal', () => {
79
- const result = validateFGCADoc({
80
- ...VALID_DOC,
81
- goals: [{ id: 1, name: 'Goal', factor: [{ id: 99 }] }],
82
- });
83
- expect(result.valid).toBe(true);
84
- expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('factor 99'))).toBe(true);
85
- });
86
-
87
- it('warns on broken goal reference in change', () => {
88
- const result = validateFGCADoc({
89
- ...VALID_DOC,
90
- changes: [{ id: 1, name: 'Change', goal_id: 99, activity_ids: [] }],
91
- });
92
- expect(result.valid).toBe(true);
93
- expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('goal 99'))).toBe(true);
94
- });
95
-
96
- it('warns on broken activity reference in change', () => {
97
- const result = validateFGCADoc({
98
- ...VALID_DOC,
99
- changes: [{ id: 1, name: 'Change', goal_id: 1, activity_ids: [99] }],
100
- });
101
- expect(result.valid).toBe(true);
102
- expect(result.warnings.some(w => w.code === 'BROKEN_REF' && w.message.includes('activity 99'))).toBe(true);
103
- });
104
-
105
- it('accepts a document with empty arrays', () => {
106
- const result = validateFGCADoc({
107
- notation: 'dgca',
108
- factors: [],
109
- goals: [],
110
- changes: [],
111
- actions: [],
112
- });
113
- expect(result.valid).toBe(true);
114
- });
115
-
116
- it('accepts optional spec_version field', () => {
117
- const result = validateFGCADoc({ ...VALID_DOC, spec_version: '0.1' });
118
- expect(result.valid).toBe(true);
119
- });
120
-
121
- // Pre-release blocker regression (orchestrator review 2026-05-21).
122
- it('[blocker] tolerates a null element in goals[] without throwing', () => {
123
- const r = validateFGCADoc({ ...VALID_DOC, goals: [null] });
124
- expect(r.valid).toBe(false);
125
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
126
- });
127
- it('[blocker] tolerates a string element in factors[] without throwing', () => {
128
- const r = validateFGCADoc({ ...VALID_DOC, factors: ['x'] });
129
- expect(r.valid).toBe(false);
130
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
131
- });
132
- it('[blocker] tolerates a null element in changes[] without throwing', () => {
133
- const r = validateFGCADoc({ ...VALID_DOC, changes: [null] });
134
- expect(r.valid).toBe(false);
135
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
136
- });
137
- it('[blocker] tolerates a null element in actions[] without throwing', () => {
138
- const r = validateFGCADoc({ ...VALID_DOC, actions: [null] });
139
- expect(r.valid).toBe(false);
140
- expect(r.errors.some(e => e.code === 'SCHEMA_INVALID')).toBe(true);
141
- });
142
- });