@topogram/cli 0.3.64 → 0.3.66

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 (278) hide show
  1. package/package.json +1 -1
  2. package/src/adoption/plan/index.js +716 -0
  3. package/src/adoption/plan.js +12 -703
  4. package/src/adoption/reporting.js +1 -1
  5. package/src/agent-brief.js +7 -21
  6. package/src/agent-ops/query-builders/auth.js +375 -0
  7. package/src/agent-ops/query-builders/change-risk/change-plan.js +123 -0
  8. package/src/agent-ops/query-builders/change-risk/import-plan.js +49 -0
  9. package/src/agent-ops/query-builders/change-risk/maintained.js +286 -0
  10. package/src/agent-ops/query-builders/change-risk/review-packets.js +123 -0
  11. package/src/agent-ops/query-builders/change-risk/risk.js +189 -0
  12. package/src/agent-ops/query-builders/change-risk.js +25 -0
  13. package/src/agent-ops/query-builders/common.js +149 -0
  14. package/src/agent-ops/query-builders/maintained-risk.js +539 -0
  15. package/src/agent-ops/query-builders/maintained-shared.js +120 -0
  16. package/src/agent-ops/query-builders/multi-agent.js +547 -0
  17. package/src/agent-ops/query-builders/projection-impacts.js +514 -0
  18. package/src/agent-ops/query-builders/work-packets.js +417 -0
  19. package/src/agent-ops/query-builders/workflow-context-shared.js +300 -0
  20. package/src/agent-ops/query-builders/workflow-context.js +398 -0
  21. package/src/agent-ops/query-builders/workflow-presets-core.js +677 -0
  22. package/src/agent-ops/query-builders/workflow-presets.js +341 -0
  23. package/src/agent-ops/query-builders.d.ts +26 -26
  24. package/src/agent-ops/query-builders.js +42 -5021
  25. package/src/archive/jsonl.js +2 -2
  26. package/src/archive/resolver-bridge.js +1 -1
  27. package/src/archive/unarchive.js +2 -1
  28. package/src/catalog/constants.js +10 -0
  29. package/src/catalog/copy.js +65 -0
  30. package/src/catalog/diagnostics.js +15 -0
  31. package/src/catalog/entries.js +42 -0
  32. package/src/catalog/files.js +67 -0
  33. package/src/catalog/provenance.js +123 -0
  34. package/src/catalog/source.js +150 -0
  35. package/src/catalog/validation.js +252 -0
  36. package/src/catalog.d.ts +2 -0
  37. package/src/catalog.js +18 -746
  38. package/src/cli/command-parsers/project.js +3 -0
  39. package/src/cli/command-parsers/shared.js +1 -1
  40. package/src/cli/commands/agent.js +2 -2
  41. package/src/cli/commands/catalog/check.js +31 -0
  42. package/src/cli/commands/catalog/copy.js +59 -0
  43. package/src/cli/commands/catalog/doctor.js +248 -0
  44. package/src/cli/commands/catalog/help.js +21 -0
  45. package/src/cli/commands/catalog/list.js +52 -0
  46. package/src/cli/commands/catalog/runner.js +92 -0
  47. package/src/cli/commands/catalog/shared.js +17 -0
  48. package/src/cli/commands/catalog/show.js +134 -0
  49. package/src/cli/commands/catalog.js +30 -615
  50. package/src/cli/commands/check.js +3 -3
  51. package/src/cli/commands/doctor.js +2 -9
  52. package/src/cli/commands/generator-policy/package-info.js +162 -0
  53. package/src/cli/commands/generator-policy/payloads.js +372 -0
  54. package/src/cli/commands/generator-policy/printers.js +159 -0
  55. package/src/cli/commands/generator-policy/runner.js +81 -0
  56. package/src/cli/commands/generator-policy/shared.js +39 -0
  57. package/src/cli/commands/generator-policy.js +15 -783
  58. package/src/cli/commands/import/adopt.js +170 -0
  59. package/src/cli/commands/import/check.js +91 -0
  60. package/src/cli/commands/import/diff.js +84 -0
  61. package/src/cli/commands/import/help.js +47 -0
  62. package/src/cli/commands/import/paths.js +269 -0
  63. package/src/cli/commands/import/plan.js +292 -0
  64. package/src/cli/commands/import/refresh.js +471 -0
  65. package/src/cli/commands/import/status-history.js +196 -0
  66. package/src/cli/commands/import/workspace.js +233 -0
  67. package/src/cli/commands/import.js +33 -1732
  68. package/src/cli/commands/migrate.js +153 -0
  69. package/src/cli/commands/package/constants.js +17 -0
  70. package/src/cli/commands/package/doctor.js +240 -0
  71. package/src/cli/commands/package/help.js +27 -0
  72. package/src/cli/commands/package/lockfile.js +135 -0
  73. package/src/cli/commands/package/npm.js +97 -0
  74. package/src/cli/commands/package/reporting.js +35 -0
  75. package/src/cli/commands/package/runner.js +33 -0
  76. package/src/cli/commands/package/shared.js +9 -0
  77. package/src/cli/commands/package/update-cli.js +252 -0
  78. package/src/cli/commands/package/versions.js +35 -0
  79. package/src/cli/commands/package.js +29 -813
  80. package/src/cli/commands/query/change-plan.js +68 -0
  81. package/src/cli/commands/query/definitions.js +202 -0
  82. package/src/cli/commands/query/import-adopt.js +121 -0
  83. package/src/cli/commands/query/runner/artifacts.js +102 -0
  84. package/src/cli/commands/query/runner/boundaries.js +211 -0
  85. package/src/cli/commands/query/runner/change.js +182 -0
  86. package/src/cli/commands/query/runner/import-adopt.js +111 -0
  87. package/src/cli/commands/query/runner/index.js +31 -0
  88. package/src/cli/commands/query/runner/output.js +12 -0
  89. package/src/cli/commands/query/runner/workflow.js +241 -0
  90. package/src/cli/commands/query/runner.js +3 -0
  91. package/src/cli/commands/query/workflow-context.js +5 -0
  92. package/src/cli/commands/query/workspace.js +270 -0
  93. package/src/cli/commands/query.js +9 -1300
  94. package/src/cli/commands/source.js +3 -12
  95. package/src/cli/commands/template/baseline.js +100 -0
  96. package/src/cli/commands/template/check.js +467 -0
  97. package/src/cli/commands/template/constants.js +8 -0
  98. package/src/cli/commands/template/diagnostics.js +26 -0
  99. package/src/cli/commands/template/help.js +28 -0
  100. package/src/cli/commands/template/lifecycle.js +404 -0
  101. package/src/cli/commands/template/list-show.js +287 -0
  102. package/src/cli/commands/template/policy.js +422 -0
  103. package/src/cli/commands/template/shared.js +127 -0
  104. package/src/cli/commands/template/updates.js +352 -0
  105. package/src/cli/commands/template-runner.js +6 -6
  106. package/src/cli/commands/template.js +41 -2143
  107. package/src/cli/commands/trust.js +1 -1
  108. package/src/cli/commands/workflow.js +6 -1
  109. package/src/cli/dispatcher.js +6 -1
  110. package/src/cli/help.js +15 -14
  111. package/src/cli/migration-guidance.js +1 -1
  112. package/src/cli/output-safety.js +2 -1
  113. package/src/cli/path-normalization.js +3 -13
  114. package/src/generator/api/contracts.js +497 -0
  115. package/src/generator/api/metadata.js +221 -0
  116. package/src/generator/api/openapi.js +559 -0
  117. package/src/generator/api/schema.js +124 -0
  118. package/src/generator/api/types.d.ts +98 -0
  119. package/src/generator/api.js +3 -1195
  120. package/src/generator/context/domain-page.js +1 -1
  121. package/src/generator/context/shared/domain-sdlc.js +282 -0
  122. package/src/generator/context/shared/maintained-boundary.js +665 -0
  123. package/src/generator/context/shared/metrics.js +85 -0
  124. package/src/generator/context/shared/primitives.js +64 -0
  125. package/src/generator/context/shared/relationships.js +453 -0
  126. package/src/generator/context/shared/summaries.js +263 -0
  127. package/src/generator/context/shared/types.d.ts +207 -0
  128. package/src/generator/context/shared.d.ts +42 -0
  129. package/src/generator/context/shared.js +80 -1390
  130. package/src/generator/context/slice/core.js +397 -0
  131. package/src/generator/context/slice/sdlc.js +417 -0
  132. package/src/generator/context/slice/ui-packets.js +183 -0
  133. package/src/generator/context/slice.js +2 -859
  134. package/src/generator/context/task-mode.js +2 -2
  135. package/src/generator/registry/index.js +507 -0
  136. package/src/generator/registry.js +18 -504
  137. package/src/generator/runtime/environment/index.js +666 -0
  138. package/src/generator/runtime/environment.js +4 -666
  139. package/src/generator/runtime/runtime-check/index.js +554 -0
  140. package/src/generator/runtime/runtime-check.js +4 -554
  141. package/src/generator/runtime/shared/index.js +572 -0
  142. package/src/generator/runtime/shared.js +19 -570
  143. package/src/generator/sdlc/doc-page.js +1 -1
  144. package/src/generator/shared.d.ts +2 -0
  145. package/src/generator/surfaces/databases/lifecycle-shared.js +1 -1
  146. package/src/generator/surfaces/native/swiftui-templates/README.generated.md +1 -1
  147. package/src/generator/surfaces/shared.d.ts +3 -0
  148. package/src/generator/widget-conformance/behavior-report.js +258 -0
  149. package/src/generator/widget-conformance/checks.js +371 -0
  150. package/src/generator/widget-conformance/projection-context.js +200 -0
  151. package/src/generator/widget-conformance/report.js +166 -0
  152. package/src/generator/widget-conformance/types.d.ts +121 -0
  153. package/src/generator/widget-conformance.js +3 -824
  154. package/src/import/core/context.d.ts +3 -0
  155. package/src/import/core/context.js +5 -7
  156. package/src/import/core/contracts.d.ts +1 -0
  157. package/src/import/core/registry.d.ts +4 -0
  158. package/src/import/core/runner/candidates.js +337 -0
  159. package/src/import/core/runner/options.js +22 -0
  160. package/src/import/core/runner/reports.js +51 -0
  161. package/src/import/core/runner/run.js +79 -0
  162. package/src/import/core/runner/tracks.js +150 -0
  163. package/src/import/core/runner/ui-drafts.js +393 -0
  164. package/src/import/core/runner.js +3 -698
  165. package/src/import/core/shared/api-routes.js +221 -0
  166. package/src/import/core/shared/candidates.js +97 -0
  167. package/src/import/core/shared/files.js +177 -0
  168. package/src/import/core/shared/next-app.js +389 -0
  169. package/src/import/core/shared/types.d.ts +51 -0
  170. package/src/import/core/shared/ui-routes.js +230 -0
  171. package/src/import/core/shared.js +60 -861
  172. package/src/new-project/constants.js +128 -0
  173. package/src/new-project/create.js +90 -0
  174. package/src/new-project/json.js +28 -0
  175. package/src/new-project/metadata.js +96 -0
  176. package/src/new-project/package-spec.js +161 -0
  177. package/src/new-project/project-files.js +351 -0
  178. package/src/new-project/template-policy.js +269 -0
  179. package/src/new-project/template-resolution.js +370 -0
  180. package/src/new-project/template-snapshots.js +442 -0
  181. package/src/new-project/template-updates.js +512 -0
  182. package/src/new-project/types.d.ts +83 -0
  183. package/src/new-project.js +6 -2277
  184. package/src/parser.d.ts +87 -1
  185. package/src/parser.js +118 -0
  186. package/src/policy/review-boundaries.d.ts +15 -0
  187. package/src/project-config/index.js +591 -0
  188. package/src/project-config.js +19 -561
  189. package/src/resolver/enrich/acceptance-criterion.js +2 -0
  190. package/src/resolver/enrich/bug.js +2 -0
  191. package/src/resolver/enrich/pitch.js +2 -0
  192. package/src/resolver/enrich/requirement.js +2 -0
  193. package/src/resolver/enrich/task.js +2 -0
  194. package/src/resolver/index.js +19 -2089
  195. package/src/resolver/normalize.js +384 -1
  196. package/src/resolver/plans.js +168 -0
  197. package/src/resolver/projections-api.js +494 -0
  198. package/src/resolver/projections-db.js +133 -0
  199. package/src/resolver/projections-ui.js +317 -0
  200. package/src/resolver/shapes.js +251 -0
  201. package/src/resolver/shared.js +278 -0
  202. package/src/resolver/widgets.js +132 -0
  203. package/src/sdlc/adopt.js +6 -5
  204. package/src/sdlc/paths.js +3 -5
  205. package/src/sdlc/scaffold.js +2 -1
  206. package/src/template-trust/constants.js +62 -0
  207. package/src/template-trust/content.js +258 -0
  208. package/src/template-trust/diff.js +92 -0
  209. package/src/template-trust/policy.js +61 -0
  210. package/src/template-trust/record.js +90 -0
  211. package/src/template-trust/status.js +182 -0
  212. package/src/template-trust.js +24 -687
  213. package/src/text-helpers.d.ts +1 -0
  214. package/src/topogram-types.d.ts +69 -0
  215. package/src/validator/common.js +488 -0
  216. package/src/validator/data-model.js +237 -0
  217. package/src/validator/docs.js +167 -0
  218. package/src/validator/expressions.js +146 -1
  219. package/src/validator/index.d.ts +23 -0
  220. package/src/validator/index.js +32 -3585
  221. package/src/validator/kinds.d.ts +41 -0
  222. package/src/validator/kinds.js +2 -0
  223. package/src/validator/model-helpers.js +46 -0
  224. package/src/validator/per-kind/acceptance-criterion.js +5 -0
  225. package/src/validator/per-kind/bug.js +6 -0
  226. package/src/validator/per-kind/domain.js +15 -2
  227. package/src/validator/per-kind/pitch.js +7 -0
  228. package/src/validator/per-kind/requirement.js +5 -0
  229. package/src/validator/per-kind/task.js +7 -0
  230. package/src/validator/per-kind/widget.js +14 -0
  231. package/src/validator/projections/api-http-async.js +410 -0
  232. package/src/validator/projections/api-http-authz.js +88 -0
  233. package/src/validator/projections/api-http-core.js +205 -0
  234. package/src/validator/projections/api-http-policies.js +339 -0
  235. package/src/validator/projections/api-http-responses.js +233 -0
  236. package/src/validator/projections/api-http.js +44 -0
  237. package/src/validator/projections/db.js +353 -0
  238. package/src/validator/projections/generator-defaults.js +45 -0
  239. package/src/validator/projections/helpers.js +87 -0
  240. package/src/validator/projections/ui-helpers.js +214 -0
  241. package/src/validator/projections/ui-navigation.js +344 -0
  242. package/src/validator/projections/ui-structure.js +364 -0
  243. package/src/validator/projections/ui-widgets.js +493 -0
  244. package/src/validator/projections/ui.js +46 -0
  245. package/src/validator/registry.js +48 -1
  246. package/src/validator/utils.d.ts +20 -0
  247. package/src/validator/utils.js +115 -12
  248. package/src/widget-behavior.d.ts +1 -0
  249. package/src/workflows/import-app/api/collect.js +221 -0
  250. package/src/workflows/import-app/api/openapi.js +257 -0
  251. package/src/workflows/import-app/api/routes.js +327 -0
  252. package/src/workflows/import-app/api/sources.js +22 -0
  253. package/src/workflows/import-app/api.js +2 -797
  254. package/src/workflows/reconcile/adoption-plan/build.js +212 -0
  255. package/src/workflows/reconcile/adoption-plan/dependencies.js +75 -0
  256. package/src/workflows/reconcile/adoption-plan/outputs.js +153 -0
  257. package/src/workflows/reconcile/adoption-plan/paths.js +58 -0
  258. package/src/workflows/reconcile/adoption-plan/projection-patches.js +177 -0
  259. package/src/workflows/reconcile/adoption-plan/reasons.js +107 -0
  260. package/src/workflows/reconcile/adoption-plan.js +30 -740
  261. package/src/workflows/reconcile/auth/closures.js +115 -0
  262. package/src/workflows/reconcile/auth/formatters.js +142 -0
  263. package/src/workflows/reconcile/auth/inference.js +330 -0
  264. package/src/workflows/reconcile/auth/roles.js +122 -0
  265. package/src/workflows/reconcile/auth.js +35 -690
  266. package/src/workflows/reconcile/bundle-core/index.js +600 -0
  267. package/src/workflows/reconcile/bundle-core.js +12 -598
  268. package/src/workflows/reconcile/candidate-model.js +18 -2
  269. package/src/workflows/reconcile/canonical-surface.js +1 -1
  270. package/src/workflows/reconcile/impacts/adoption-plan.js +196 -0
  271. package/src/workflows/reconcile/impacts/indexes.js +105 -0
  272. package/src/workflows/reconcile/impacts/patches.js +252 -0
  273. package/src/workflows/reconcile/impacts/reports.js +80 -0
  274. package/src/workflows/reconcile/impacts.js +14 -623
  275. package/src/workflows/reconcile/renderers.js +41 -6
  276. package/src/workflows/shared.js +5 -11
  277. package/src/workspace-docs.d.ts +29 -0
  278. package/src/workspace-paths.js +328 -0
@@ -1 +1,384 @@
1
- export { normalizeStatement } from "./index.js";
1
+ import {
2
+ collectFieldMap,
3
+ getFieldValue,
4
+ stringValue,
5
+ symbolValue,
6
+ symbolValues,
7
+ valueAsArray
8
+ } from "../validator.js";
9
+ import {
10
+ normalizeDomainScopeList,
11
+ normalizeFieldsBlock,
12
+ parseRuleExpression,
13
+ resolveDomainTag,
14
+ resolveReference,
15
+ resolveReferenceList,
16
+ toRef
17
+ } from "./shared.js";
18
+ import {
19
+ normalizeWidgetBehaviors,
20
+ normalizeWidgetEvents,
21
+ normalizeWidgetProps,
22
+ normalizeWidgetSlots
23
+ } from "./widgets.js";
24
+ import {
25
+ parseInvariantBlock,
26
+ parseKeyBlock,
27
+ parseOverridesBlock,
28
+ parseRelationBlock,
29
+ parseRenameBlock
30
+ } from "./shapes.js";
31
+ import {
32
+ parseProjectionHttpAsyncBlock,
33
+ parseProjectionHttpAuthzBlock,
34
+ parseProjectionHttpBlock,
35
+ parseProjectionHttpCacheBlock,
36
+ parseProjectionHttpCallbacksBlock,
37
+ parseProjectionHttpDeleteBlock,
38
+ parseProjectionHttpDownloadBlock,
39
+ parseProjectionHttpErrorsBlock,
40
+ parseProjectionHttpFieldsBlock,
41
+ parseProjectionHttpIdempotencyBlock,
42
+ parseProjectionHttpPreconditionsBlock,
43
+ parseProjectionHttpResponsesBlock,
44
+ parseProjectionHttpStatusBlock
45
+ } from "./projections-api.js";
46
+ import {
47
+ parseProjectionUiActionsBlock,
48
+ parseProjectionUiAppShellBlock,
49
+ parseProjectionUiCollectionsBlock,
50
+ parseProjectionWidgetBindingsBlock,
51
+ parseProjectionUiDesignBlock,
52
+ parseProjectionUiIosBlock,
53
+ parseProjectionUiLookupsBlock,
54
+ parseProjectionUiNavigationBlock,
55
+ parseProjectionUiRoutesBlock,
56
+ parseProjectionUiScreenRegionsBlock,
57
+ parseProjectionUiScreensBlock,
58
+ parseProjectionUiVisibilityBlock,
59
+ parseProjectionUiWebBlock
60
+ } from "./projections-ui.js";
61
+ import {
62
+ parseProjectionDbColumnsBlock,
63
+ parseProjectionDbIndexesBlock,
64
+ parseProjectionDbKeysBlock,
65
+ parseProjectionDbLifecycleBlock,
66
+ parseProjectionDbRelationsBlock,
67
+ parseProjectionDbTablesBlock,
68
+ parseProjectionGeneratorDefaultsBlock
69
+ } from "./projections-db.js";
70
+
71
+ export function normalizeStatement(statement, registry) {
72
+ const fieldMap = collectFieldMap(statement);
73
+ const base = {
74
+ kind: statement.kind,
75
+ id: statement.id,
76
+ name: stringValue(getFieldValue(statement, "name")),
77
+ description: stringValue(getFieldValue(statement, "description")),
78
+ status: symbolValue(getFieldValue(statement, "status")),
79
+ from: statement.from
80
+ ? {
81
+ id: statement.from.value,
82
+ target: toRef(resolveReference(registry, statement.from.value))
83
+ }
84
+ : null,
85
+ loc: statement.loc
86
+ };
87
+
88
+ switch (statement.kind) {
89
+ case "enum":
90
+ return {
91
+ ...base,
92
+ values: symbolValues(getFieldValue(statement, "values"))
93
+ };
94
+ case "actor":
95
+ case "role":
96
+ return base;
97
+ case "entity":
98
+ return {
99
+ ...base,
100
+ usesTerms: resolveReferenceList(registry, getFieldValue(statement, "uses_terms")),
101
+ fields: normalizeFieldsBlock(statement),
102
+ keys: parseKeyBlock(statement),
103
+ relations: parseRelationBlock(statement, registry),
104
+ invariants: parseInvariantBlock(statement),
105
+ resolvedDomain: resolveDomainTag(statement, registry)
106
+ };
107
+ case "shape":
108
+ return {
109
+ ...base,
110
+ include: symbolValues(getFieldValue(statement, "include")),
111
+ exclude: symbolValues(getFieldValue(statement, "exclude")),
112
+ derivedFrom: resolveReferenceList(registry, getFieldValue(statement, "derived_from")),
113
+ fields: normalizeFieldsBlock(statement),
114
+ rename: parseRenameBlock(statement),
115
+ overrides: parseOverridesBlock(statement)
116
+ };
117
+ case "capability":
118
+ return {
119
+ ...base,
120
+ actors: resolveReferenceList(registry, getFieldValue(statement, "actors")),
121
+ roles: resolveReferenceList(registry, getFieldValue(statement, "roles")),
122
+ reads: resolveReferenceList(registry, getFieldValue(statement, "reads")),
123
+ creates: resolveReferenceList(registry, getFieldValue(statement, "creates")),
124
+ updates: resolveReferenceList(registry, getFieldValue(statement, "updates")),
125
+ deletes: resolveReferenceList(registry, getFieldValue(statement, "deletes")),
126
+ input: resolveReferenceList(registry, getFieldValue(statement, "input")),
127
+ output: resolveReferenceList(registry, getFieldValue(statement, "output")),
128
+ resolvedDomain: resolveDomainTag(statement, registry)
129
+ };
130
+ case "widget":
131
+ return {
132
+ ...base,
133
+ category: symbolValue(getFieldValue(statement, "category")),
134
+ props: normalizeWidgetProps(statement),
135
+ events: normalizeWidgetEvents(statement, registry),
136
+ slots: normalizeWidgetSlots(statement),
137
+ behavior: symbolValues(getFieldValue(statement, "behavior")),
138
+ behaviors: normalizeWidgetBehaviors(statement),
139
+ patterns: symbolValues(getFieldValue(statement, "patterns")),
140
+ regions: symbolValues(getFieldValue(statement, "regions")),
141
+ approvals: symbolValues(getFieldValue(statement, "approvals")),
142
+ lookups: resolveReferenceList(registry, getFieldValue(statement, "lookups")),
143
+ dependencies: resolveReferenceList(registry, getFieldValue(statement, "dependencies")),
144
+ version: stringValue(getFieldValue(statement, "version"))
145
+ };
146
+ case "rule":
147
+ return {
148
+ ...base,
149
+ appliesTo: resolveReferenceList(registry, getFieldValue(statement, "applies_to")),
150
+ actors: resolveReferenceList(registry, getFieldValue(statement, "actors")),
151
+ roles: resolveReferenceList(registry, getFieldValue(statement, "roles")),
152
+ condition: valueAsArray(getFieldValue(statement, "condition")).map((item) => item.value),
153
+ conditionNode: getFieldValue(statement, "condition") ? parseRuleExpression(getFieldValue(statement, "condition")) : null,
154
+ requirement: valueAsArray(getFieldValue(statement, "requirement")).map((item) => item.value),
155
+ requirementNode: getFieldValue(statement, "requirement") ? parseRuleExpression(getFieldValue(statement, "requirement")) : null,
156
+ fromRequirement: getFieldValue(statement, "from_requirement")
157
+ ? {
158
+ id: symbolValue(getFieldValue(statement, "from_requirement")),
159
+ target: toRef(resolveReference(registry, symbolValue(getFieldValue(statement, "from_requirement"))))
160
+ }
161
+ : null,
162
+ severity: symbolValue(getFieldValue(statement, "severity")),
163
+ sourceOfTruth: resolveReferenceList(registry, getFieldValue(statement, "source_of_truth")),
164
+ resolvedDomain: resolveDomainTag(statement, registry)
165
+ };
166
+ case "decision":
167
+ return {
168
+ ...base,
169
+ context: symbolValues(getFieldValue(statement, "context")),
170
+ consequences: symbolValues(getFieldValue(statement, "consequences")),
171
+ pitch: getFieldValue(statement, "pitch")
172
+ ? {
173
+ id: symbolValue(getFieldValue(statement, "pitch")),
174
+ target: toRef(resolveReference(registry, symbolValue(getFieldValue(statement, "pitch"))))
175
+ }
176
+ : null,
177
+ supersedes: resolveReferenceList(registry, getFieldValue(statement, "supersedes")),
178
+ resolvedDomain: resolveDomainTag(statement, registry)
179
+ };
180
+ case "projection":
181
+ return {
182
+ ...base,
183
+ type: symbolValue(getFieldValue(statement, "type")),
184
+ realizes: resolveReferenceList(registry, getFieldValue(statement, "realizes")),
185
+ outputs: symbolValues(getFieldValue(statement, "outputs")),
186
+ endpoints: parseProjectionHttpBlock(statement, registry),
187
+ errorResponses: parseProjectionHttpErrorsBlock(statement, registry),
188
+ wireFields: parseProjectionHttpFieldsBlock(statement, registry),
189
+ responses: parseProjectionHttpResponsesBlock(statement, registry),
190
+ preconditions: parseProjectionHttpPreconditionsBlock(statement, registry),
191
+ idempotency: parseProjectionHttpIdempotencyBlock(statement, registry),
192
+ cache: parseProjectionHttpCacheBlock(statement, registry),
193
+ deleteSemantics: parseProjectionHttpDeleteBlock(statement, registry),
194
+ asyncJobs: parseProjectionHttpAsyncBlock(statement, registry),
195
+ asyncStatus: parseProjectionHttpStatusBlock(statement, registry),
196
+ downloads: parseProjectionHttpDownloadBlock(statement, registry),
197
+ authorization: parseProjectionHttpAuthzBlock(statement, registry),
198
+ callbacks: parseProjectionHttpCallbacksBlock(statement, registry),
199
+ http: parseProjectionHttpBlock(statement, registry),
200
+ httpErrors: parseProjectionHttpErrorsBlock(statement, registry),
201
+ httpFields: parseProjectionHttpFieldsBlock(statement, registry),
202
+ httpResponses: parseProjectionHttpResponsesBlock(statement, registry),
203
+ httpPreconditions: parseProjectionHttpPreconditionsBlock(statement, registry),
204
+ httpIdempotency: parseProjectionHttpIdempotencyBlock(statement, registry),
205
+ httpCache: parseProjectionHttpCacheBlock(statement, registry),
206
+ httpDelete: parseProjectionHttpDeleteBlock(statement, registry),
207
+ httpAsync: parseProjectionHttpAsyncBlock(statement, registry),
208
+ httpStatus: parseProjectionHttpStatusBlock(statement, registry),
209
+ httpDownload: parseProjectionHttpDownloadBlock(statement, registry),
210
+ httpAuthz: parseProjectionHttpAuthzBlock(statement, registry),
211
+ httpCallbacks: parseProjectionHttpCallbacksBlock(statement, registry),
212
+ uiScreens: parseProjectionUiScreensBlock(statement, registry),
213
+ screens: parseProjectionUiScreensBlock(statement, registry),
214
+ uiCollections: parseProjectionUiCollectionsBlock(statement),
215
+ collectionViews: parseProjectionUiCollectionsBlock(statement),
216
+ uiActions: parseProjectionUiActionsBlock(statement, registry),
217
+ screenActions: parseProjectionUiActionsBlock(statement, registry),
218
+ uiVisibility: parseProjectionUiVisibilityBlock(statement, registry),
219
+ visibilityRules: parseProjectionUiVisibilityBlock(statement, registry),
220
+ uiLookups: parseProjectionUiLookupsBlock(statement, registry),
221
+ fieldLookups: parseProjectionUiLookupsBlock(statement, registry),
222
+ uiRoutes: parseProjectionUiRoutesBlock(statement),
223
+ screenRoutes: parseProjectionUiRoutesBlock(statement),
224
+ uiWeb: parseProjectionUiWebBlock(statement, registry),
225
+ webHints: parseProjectionUiWebBlock(statement, registry),
226
+ uiIos: parseProjectionUiIosBlock(statement, registry),
227
+ iosHints: parseProjectionUiIosBlock(statement, registry),
228
+ uiAppShell: parseProjectionUiAppShellBlock(statement),
229
+ appShell: parseProjectionUiAppShellBlock(statement),
230
+ uiDesign: parseProjectionUiDesignBlock(statement),
231
+ designTokens: parseProjectionUiDesignBlock(statement),
232
+ uiNavigation: parseProjectionUiNavigationBlock(statement),
233
+ navigation: parseProjectionUiNavigationBlock(statement),
234
+ uiScreenRegions: parseProjectionUiScreenRegionsBlock(statement),
235
+ screenRegions: parseProjectionUiScreenRegionsBlock(statement),
236
+ widgetBindings: parseProjectionWidgetBindingsBlock(statement, registry),
237
+ dbTables: parseProjectionDbTablesBlock(statement, registry),
238
+ tables: parseProjectionDbTablesBlock(statement, registry),
239
+ dbColumns: parseProjectionDbColumnsBlock(statement, registry),
240
+ columns: parseProjectionDbColumnsBlock(statement, registry),
241
+ dbKeys: parseProjectionDbKeysBlock(statement, registry),
242
+ keys: parseProjectionDbKeysBlock(statement, registry),
243
+ dbIndexes: parseProjectionDbIndexesBlock(statement, registry),
244
+ indexes: parseProjectionDbIndexesBlock(statement, registry),
245
+ dbRelations: parseProjectionDbRelationsBlock(statement, registry),
246
+ relations: parseProjectionDbRelationsBlock(statement, registry),
247
+ dbLifecycle: parseProjectionDbLifecycleBlock(statement, registry),
248
+ lifecycle: parseProjectionDbLifecycleBlock(statement, registry),
249
+ generatorDefaults: parseProjectionGeneratorDefaultsBlock(statement)
250
+ };
251
+ case "orchestration":
252
+ return {
253
+ ...base,
254
+ inputs: resolveReferenceList(registry, getFieldValue(statement, "inputs")),
255
+ steps: symbolValues(getFieldValue(statement, "steps")),
256
+ outputs: symbolValues(getFieldValue(statement, "outputs")),
257
+ resolvedDomain: resolveDomainTag(statement, registry)
258
+ };
259
+ case "verification":
260
+ return {
261
+ ...base,
262
+ validates: resolveReferenceList(registry, getFieldValue(statement, "validates")),
263
+ method: symbolValue(getFieldValue(statement, "method")),
264
+ scenarios: symbolValues(getFieldValue(statement, "scenarios")),
265
+ requirementRefs: resolveReferenceList(registry, getFieldValue(statement, "requirement_refs")),
266
+ acceptanceRefs: resolveReferenceList(registry, getFieldValue(statement, "acceptance_refs")),
267
+ fixesBugs: resolveReferenceList(registry, getFieldValue(statement, "fixes_bugs")),
268
+ resolvedDomain: resolveDomainTag(statement, registry)
269
+ };
270
+ case "operation":
271
+ return {
272
+ ...base,
273
+ observes: resolveReferenceList(registry, getFieldValue(statement, "observes")),
274
+ metrics: symbolValues(getFieldValue(statement, "metrics")),
275
+ alerts: symbolValues(getFieldValue(statement, "alerts")),
276
+ resolvedDomain: resolveDomainTag(statement, registry)
277
+ };
278
+ case "term":
279
+ return {
280
+ ...base,
281
+ aliases: symbolValues(getFieldValue(statement, "aliases")),
282
+ excludes: symbolValues(getFieldValue(statement, "excludes"))
283
+ };
284
+ case "domain":
285
+ return {
286
+ ...base,
287
+ inScope: normalizeDomainScopeList(statement, "in_scope"),
288
+ outOfScope: normalizeDomainScopeList(statement, "out_of_scope"),
289
+ owners: resolveReferenceList(registry, getFieldValue(statement, "owners")),
290
+ parentDomain: getFieldValue(statement, "parent_domain")
291
+ ? {
292
+ id: symbolValue(getFieldValue(statement, "parent_domain")),
293
+ target: toRef(resolveReference(registry, symbolValue(getFieldValue(statement, "parent_domain"))))
294
+ }
295
+ : null,
296
+ aliases: normalizeDomainScopeList(statement, "aliases")
297
+ };
298
+ case "pitch":
299
+ return {
300
+ ...base,
301
+ priority: symbolValue(getFieldValue(statement, "priority")),
302
+ appetite: stringValue(getFieldValue(statement, "appetite")) || symbolValue(getFieldValue(statement, "appetite")),
303
+ problem: stringValue(getFieldValue(statement, "problem")),
304
+ solutionSketch: stringValue(getFieldValue(statement, "solution_sketch")),
305
+ rabbitHoles: stringValue(getFieldValue(statement, "rabbit_holes")) || symbolValues(getFieldValue(statement, "rabbit_holes")),
306
+ noGoAreas: stringValue(getFieldValue(statement, "no_go_areas")) || symbolValues(getFieldValue(statement, "no_go_areas")),
307
+ affects: resolveReferenceList(registry, getFieldValue(statement, "affects")),
308
+ decisions: resolveReferenceList(registry, getFieldValue(statement, "decisions")),
309
+ updated: stringValue(getFieldValue(statement, "updated")),
310
+ resolvedDomain: resolveDomainTag(statement, registry)
311
+ };
312
+ case "requirement":
313
+ return {
314
+ ...base,
315
+ priority: symbolValue(getFieldValue(statement, "priority")),
316
+ pitch: getFieldValue(statement, "pitch")
317
+ ? {
318
+ id: symbolValue(getFieldValue(statement, "pitch")),
319
+ target: toRef(resolveReference(registry, symbolValue(getFieldValue(statement, "pitch"))))
320
+ }
321
+ : null,
322
+ affects: resolveReferenceList(registry, getFieldValue(statement, "affects")),
323
+ introducesRules: resolveReferenceList(registry, getFieldValue(statement, "introduces_rules")),
324
+ respectsRules: resolveReferenceList(registry, getFieldValue(statement, "respects_rules")),
325
+ supersedes: resolveReferenceList(registry, getFieldValue(statement, "supersedes")),
326
+ updated: stringValue(getFieldValue(statement, "updated")),
327
+ resolvedDomain: resolveDomainTag(statement, registry)
328
+ };
329
+ case "acceptance_criterion":
330
+ return {
331
+ ...base,
332
+ requirement: getFieldValue(statement, "requirement")
333
+ ? {
334
+ id: symbolValue(getFieldValue(statement, "requirement")),
335
+ target: toRef(resolveReference(registry, symbolValue(getFieldValue(statement, "requirement"))))
336
+ }
337
+ : null,
338
+ supersedes: resolveReferenceList(registry, getFieldValue(statement, "supersedes")),
339
+ updated: stringValue(getFieldValue(statement, "updated"))
340
+ };
341
+ case "task":
342
+ return {
343
+ ...base,
344
+ priority: symbolValue(getFieldValue(statement, "priority")),
345
+ workType: symbolValue(getFieldValue(statement, "work_type")),
346
+ affects: resolveReferenceList(registry, getFieldValue(statement, "affects")),
347
+ satisfies: resolveReferenceList(registry, getFieldValue(statement, "satisfies")),
348
+ acceptanceRefs: resolveReferenceList(registry, getFieldValue(statement, "acceptance_refs")),
349
+ blocks: resolveReferenceList(registry, getFieldValue(statement, "blocks")),
350
+ blockedBy: resolveReferenceList(registry, getFieldValue(statement, "blocked_by")),
351
+ claimedBy: resolveReferenceList(registry, getFieldValue(statement, "claimed_by")),
352
+ introducesDecisions: resolveReferenceList(registry, getFieldValue(statement, "introduces_decisions")),
353
+ modifies: resolveReferenceList(registry, getFieldValue(statement, "modifies")),
354
+ introduces: resolveReferenceList(registry, getFieldValue(statement, "introduces")),
355
+ removes: resolveReferenceList(registry, getFieldValue(statement, "removes")),
356
+ updated: stringValue(getFieldValue(statement, "updated")),
357
+ resolvedDomain: resolveDomainTag(statement, registry)
358
+ };
359
+ case "bug":
360
+ return {
361
+ ...base,
362
+ priority: symbolValue(getFieldValue(statement, "priority")),
363
+ severity: symbolValue(getFieldValue(statement, "severity")),
364
+ affects: resolveReferenceList(registry, getFieldValue(statement, "affects")),
365
+ violates: resolveReferenceList(registry, getFieldValue(statement, "violates")),
366
+ surfacesRule: resolveReferenceList(registry, getFieldValue(statement, "surfaces_rule")),
367
+ introducedIn: resolveReferenceList(registry, getFieldValue(statement, "introduced_in")),
368
+ fixedIn: resolveReferenceList(registry, getFieldValue(statement, "fixed_in")),
369
+ fixedInRelease: stringValue(getFieldValue(statement, "fixed_in_release")) || symbolValue(getFieldValue(statement, "fixed_in_release")),
370
+ fixedInVerification: resolveReferenceList(registry, getFieldValue(statement, "fixed_in_verification")),
371
+ reproduction: stringValue(getFieldValue(statement, "reproduction")),
372
+ modifies: resolveReferenceList(registry, getFieldValue(statement, "modifies")),
373
+ introduces: resolveReferenceList(registry, getFieldValue(statement, "introduces")),
374
+ removes: resolveReferenceList(registry, getFieldValue(statement, "removes")),
375
+ updated: stringValue(getFieldValue(statement, "updated")),
376
+ resolvedDomain: resolveDomainTag(statement, registry)
377
+ };
378
+ default:
379
+ return {
380
+ ...base,
381
+ fields: [...fieldMap.keys()]
382
+ };
383
+ }
384
+ }
@@ -0,0 +1,168 @@
1
+ import { parseReferenceNodes, parseSymbolNodes } from "./shared.js";
2
+
3
+ export function buildCapabilityFlow(statement) {
4
+ const effects = [];
5
+
6
+ for (const [kind, refs] of [
7
+ ["read", statement.reads],
8
+ ["create", statement.creates],
9
+ ["update", statement.updates],
10
+ ["delete", statement.deletes]
11
+ ]) {
12
+ for (const ref of refs) {
13
+ effects.push({
14
+ type: "effect",
15
+ action: kind,
16
+ target: ref.target || { id: ref.id, kind: null }
17
+ });
18
+ }
19
+ }
20
+
21
+ return {
22
+ type: "capability_flow",
23
+ actors: parseReferenceNodes(statement.actors),
24
+ roles: parseReferenceNodes(statement.roles),
25
+ effects,
26
+ contracts: {
27
+ input: statement.input.map((ref) => ref.target || { id: ref.id, kind: null }),
28
+ output: statement.output.map((ref) => ref.target || { id: ref.id, kind: null })
29
+ }
30
+ };
31
+ }
32
+
33
+ export function buildRulePolicy(statement) {
34
+ return {
35
+ type: "policy",
36
+ appliesTo: statement.appliesTo.map((ref) => ref.target || { id: ref.id, kind: null }),
37
+ actors: statement.actors.map((ref) => ref.target || { id: ref.id, kind: null }),
38
+ roles: statement.roles.map((ref) => ref.target || { id: ref.id, kind: null }),
39
+ condition: statement.conditionNode,
40
+ requirement: statement.requirementNode,
41
+ severity: statement.severity,
42
+ sourceOfTruth: statement.sourceOfTruth.map((ref) => ref.target || { id: ref.id, kind: null })
43
+ };
44
+ }
45
+
46
+ export function buildDecisionRecord(statement) {
47
+ return {
48
+ type: "decision_record",
49
+ context: parseSymbolNodes(statement.context),
50
+ consequences: parseSymbolNodes(statement.consequences),
51
+ status: statement.status
52
+ };
53
+ }
54
+
55
+ export function buildProjectionPlan(statement) {
56
+ return {
57
+ type: "projection_plan",
58
+ projectionType: statement.type,
59
+ realizes: statement.realizes.map((ref, index) => ({
60
+ order: index,
61
+ target: ref.target || { id: ref.id, kind: null }
62
+ })),
63
+ outputs: parseSymbolNodes(statement.outputs),
64
+ endpoints: statement.http,
65
+ errorResponses: statement.httpErrors,
66
+ wireFields: statement.httpFields,
67
+ responses: statement.httpResponses,
68
+ preconditions: statement.httpPreconditions,
69
+ idempotency: statement.httpIdempotency,
70
+ cache: statement.httpCache,
71
+ deleteSemantics: statement.httpDelete,
72
+ asyncJobs: statement.httpAsync,
73
+ asyncStatus: statement.httpStatus,
74
+ downloads: statement.httpDownload,
75
+ authorization: statement.httpAuthz,
76
+ callbacks: statement.httpCallbacks,
77
+ screens: statement.uiScreens,
78
+ collectionViews: statement.uiCollections,
79
+ screenActions: statement.uiActions,
80
+ visibilityRules: statement.uiVisibility,
81
+ fieldLookups: statement.uiLookups,
82
+ screenRoutes: statement.uiRoutes,
83
+ webHints: statement.uiWeb,
84
+ iosHints: statement.uiIos,
85
+ appShell: statement.uiAppShell,
86
+ designTokens: statement.uiDesign,
87
+ navigation: statement.uiNavigation,
88
+ screenRegions: statement.uiScreenRegions,
89
+ widgetBindings: statement.widgetBindings,
90
+ tables: statement.dbTables,
91
+ columns: statement.dbColumns,
92
+ keys: statement.dbKeys,
93
+ indexes: statement.dbIndexes,
94
+ relations: statement.dbRelations,
95
+ lifecycle: statement.dbLifecycle,
96
+ http: statement.http,
97
+ httpErrors: statement.httpErrors,
98
+ httpFields: statement.httpFields,
99
+ httpResponses: statement.httpResponses,
100
+ httpPreconditions: statement.httpPreconditions,
101
+ httpIdempotency: statement.httpIdempotency,
102
+ httpCache: statement.httpCache,
103
+ httpDelete: statement.httpDelete,
104
+ httpAsync: statement.httpAsync,
105
+ httpStatus: statement.httpStatus,
106
+ httpDownload: statement.httpDownload,
107
+ httpAuthz: statement.httpAuthz,
108
+ httpCallbacks: statement.httpCallbacks,
109
+ uiScreens: statement.uiScreens,
110
+ uiCollections: statement.uiCollections,
111
+ uiActions: statement.uiActions,
112
+ uiVisibility: statement.uiVisibility,
113
+ uiRoutes: statement.uiRoutes,
114
+ uiWeb: statement.uiWeb,
115
+ uiDesign: statement.uiDesign,
116
+ dbTables: statement.dbTables,
117
+ dbColumns: statement.dbColumns,
118
+ dbKeys: statement.dbKeys,
119
+ dbIndexes: statement.dbIndexes,
120
+ dbRelations: statement.dbRelations,
121
+ dbLifecycle: statement.dbLifecycle,
122
+ generatorDefaults: statement.generatorDefaults
123
+ };
124
+ }
125
+
126
+ export function buildVerificationPlan(statement) {
127
+ return {
128
+ type: "verification_plan",
129
+ method: statement.method,
130
+ validates: statement.validates.map((ref, index) => ({
131
+ order: index,
132
+ target: ref.target || { id: ref.id, kind: null }
133
+ })),
134
+ scenarios: parseSymbolNodes(statement.scenarios)
135
+ };
136
+ }
137
+
138
+ export function buildOperationMonitoring(statement) {
139
+ return {
140
+ type: "operation_monitoring",
141
+ observes: statement.observes.map((ref, index) => ({
142
+ order: index,
143
+ target: ref.target || { id: ref.id, kind: null }
144
+ })),
145
+ metrics: parseSymbolNodes(statement.metrics),
146
+ alerts: parseSymbolNodes(statement.alerts)
147
+ };
148
+ }
149
+
150
+ export function buildOrchestrationPlan(statement) {
151
+ return {
152
+ type: "orchestration_plan",
153
+ inputs: statement.inputs.map((ref, index) => ({
154
+ order: index,
155
+ target: ref.target || { id: ref.id, kind: null }
156
+ })),
157
+ steps: parseSymbolNodes(statement.steps),
158
+ outputs: parseSymbolNodes(statement.outputs)
159
+ };
160
+ }
161
+
162
+ export function buildTermVocabulary(statement) {
163
+ return {
164
+ type: "term_vocabulary",
165
+ aliases: parseSymbolNodes(statement.aliases),
166
+ excludes: parseSymbolNodes(statement.excludes)
167
+ };
168
+ }