worldvm 0.0.0-stage → 0.1.0

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 (426) hide show
  1. package/AUTHORING.md +833 -0
  2. package/README.md +154 -2
  3. package/bin/worldvm.mjs +3 -0
  4. package/dist/_internal/forma/index.d.ts +1 -0
  5. package/dist/_internal/forma/index.js +1 -0
  6. package/dist/_internal/forma/world/authoring-help.d.ts +25 -0
  7. package/dist/_internal/forma/world/authoring-help.js +130 -0
  8. package/dist/_internal/forma/world/citations.d.ts +3 -0
  9. package/dist/_internal/forma/world/citations.js +26 -0
  10. package/dist/_internal/forma/world/clock-bindings.d.ts +4 -0
  11. package/dist/_internal/forma/world/clock-bindings.js +45 -0
  12. package/dist/_internal/forma/world/compile.d.ts +13 -0
  13. package/dist/_internal/forma/world/compile.js +190 -0
  14. package/dist/_internal/forma/world/coverage.d.ts +10 -0
  15. package/dist/_internal/forma/world/coverage.js +242 -0
  16. package/dist/_internal/forma/world/digest.d.ts +1 -0
  17. package/dist/_internal/forma/world/digest.js +1 -0
  18. package/dist/_internal/forma/world/documentation.d.ts +3 -0
  19. package/dist/_internal/forma/world/documentation.js +38 -0
  20. package/dist/_internal/forma/world/homes.d.ts +4 -0
  21. package/dist/_internal/forma/world/homes.js +202 -0
  22. package/dist/_internal/forma/world/index.d.ts +6 -0
  23. package/dist/_internal/forma/world/index.js +5 -0
  24. package/dist/_internal/forma/world/lowering/accounts.d.ts +4 -0
  25. package/dist/_internal/forma/world/lowering/accounts.js +36 -0
  26. package/dist/_internal/forma/world/lowering/action-policy.d.ts +5 -0
  27. package/dist/_internal/forma/world/lowering/action-policy.js +16 -0
  28. package/dist/_internal/forma/world/lowering/agents.d.ts +6 -0
  29. package/dist/_internal/forma/world/lowering/agents.js +116 -0
  30. package/dist/_internal/forma/world/lowering/bundles.d.ts +3 -0
  31. package/dist/_internal/forma/world/lowering/bundles.js +13 -0
  32. package/dist/_internal/forma/world/lowering/child-parameters.d.ts +14 -0
  33. package/dist/_internal/forma/world/lowering/child-parameters.js +36 -0
  34. package/dist/_internal/forma/world/lowering/collects.d.ts +3 -0
  35. package/dist/_internal/forma/world/lowering/collects.js +51 -0
  36. package/dist/_internal/forma/world/lowering/component-operations.d.ts +6 -0
  37. package/dist/_internal/forma/world/lowering/component-operations.js +26 -0
  38. package/dist/_internal/forma/world/lowering/components.d.ts +7 -0
  39. package/dist/_internal/forma/world/lowering/components.js +236 -0
  40. package/dist/_internal/forma/world/lowering/connectors.d.ts +4 -0
  41. package/dist/_internal/forma/world/lowering/connectors.js +31 -0
  42. package/dist/_internal/forma/world/lowering/context.d.ts +80 -0
  43. package/dist/_internal/forma/world/lowering/context.js +316 -0
  44. package/dist/_internal/forma/world/lowering/contracts.d.ts +7 -0
  45. package/dist/_internal/forma/world/lowering/contracts.js +73 -0
  46. package/dist/_internal/forma/world/lowering/decisions.d.ts +3 -0
  47. package/dist/_internal/forma/world/lowering/decisions.js +164 -0
  48. package/dist/_internal/forma/world/lowering/derives.d.ts +3 -0
  49. package/dist/_internal/forma/world/lowering/derives.js +22 -0
  50. package/dist/_internal/forma/world/lowering/discretionary.d.ts +7 -0
  51. package/dist/_internal/forma/world/lowering/discretionary.js +15 -0
  52. package/dist/_internal/forma/world/lowering/documents.d.ts +3 -0
  53. package/dist/_internal/forma/world/lowering/documents.js +68 -0
  54. package/dist/_internal/forma/world/lowering/effective.d.ts +5 -0
  55. package/dist/_internal/forma/world/lowering/effective.js +26 -0
  56. package/dist/_internal/forma/world/lowering/entities.d.ts +3 -0
  57. package/dist/_internal/forma/world/lowering/entities.js +43 -0
  58. package/dist/_internal/forma/world/lowering/escalations.d.ts +6 -0
  59. package/dist/_internal/forma/world/lowering/escalations.js +31 -0
  60. package/dist/_internal/forma/world/lowering/evidence.d.ts +3 -0
  61. package/dist/_internal/forma/world/lowering/evidence.js +75 -0
  62. package/dist/_internal/forma/world/lowering/files.d.ts +4 -0
  63. package/dist/_internal/forma/world/lowering/files.js +56 -0
  64. package/dist/_internal/forma/world/lowering/holds.d.ts +6 -0
  65. package/dist/_internal/forma/world/lowering/holds.js +35 -0
  66. package/dist/_internal/forma/world/lowering/index.d.ts +89 -0
  67. package/dist/_internal/forma/world/lowering/index.js +115 -0
  68. package/dist/_internal/forma/world/lowering/interactions.d.ts +7 -0
  69. package/dist/_internal/forma/world/lowering/interactions.js +190 -0
  70. package/dist/_internal/forma/world/lowering/library.d.ts +5 -0
  71. package/dist/_internal/forma/world/lowering/library.js +41 -0
  72. package/dist/_internal/forma/world/lowering/milestones.d.ts +6 -0
  73. package/dist/_internal/forma/world/lowering/milestones.js +17 -0
  74. package/dist/_internal/forma/world/lowering/notices.d.ts +3 -0
  75. package/dist/_internal/forma/world/lowering/notices.js +33 -0
  76. package/dist/_internal/forma/world/lowering/param-bounds.d.ts +15 -0
  77. package/dist/_internal/forma/world/lowering/param-bounds.js +71 -0
  78. package/dist/_internal/forma/world/lowering/policies.d.ts +6 -0
  79. package/dist/_internal/forma/world/lowering/policies.js +95 -0
  80. package/dist/_internal/forma/world/lowering/principals.d.ts +62 -0
  81. package/dist/_internal/forma/world/lowering/principals.js +32 -0
  82. package/dist/_internal/forma/world/lowering/recurrences.d.ts +9 -0
  83. package/dist/_internal/forma/world/lowering/recurrences.js +56 -0
  84. package/dist/_internal/forma/world/lowering/renewal.d.ts +5 -0
  85. package/dist/_internal/forma/world/lowering/renewal.js +21 -0
  86. package/dist/_internal/forma/world/lowering/resources.d.ts +6 -0
  87. package/dist/_internal/forma/world/lowering/resources.js +19 -0
  88. package/dist/_internal/forma/world/lowering/reuse.d.ts +5 -0
  89. package/dist/_internal/forma/world/lowering/reuse.js +75 -0
  90. package/dist/_internal/forma/world/lowering/sources.d.ts +10 -0
  91. package/dist/_internal/forma/world/lowering/sources.js +47 -0
  92. package/dist/_internal/forma/world/lowering/syntax.d.ts +84 -0
  93. package/dist/_internal/forma/world/lowering/syntax.js +94 -0
  94. package/dist/_internal/forma/world/lowering/vaults.d.ts +11 -0
  95. package/dist/_internal/forma/world/lowering/vaults.js +148 -0
  96. package/dist/_internal/forma/world/prelude.generated.d.ts +1 -0
  97. package/dist/_internal/forma/world/prelude.generated.js +2 -0
  98. package/dist/_internal/forma/world/properties.d.ts +9 -0
  99. package/dist/_internal/forma/world/properties.js +387 -0
  100. package/dist/_internal/forma/world/scenarios.d.ts +10 -0
  101. package/dist/_internal/forma/world/scenarios.js +757 -0
  102. package/dist/_internal/forma/world/sensitivity.d.ts +3 -0
  103. package/dist/_internal/forma/world/sensitivity.js +118 -0
  104. package/dist/_internal/forma/world/source-syntax.d.ts +6 -0
  105. package/dist/_internal/forma/world/source-syntax.js +27 -0
  106. package/dist/_internal/forma/world/status-handling.d.ts +3 -0
  107. package/dist/_internal/forma/world/status-handling.js +143 -0
  108. package/dist/_internal/forma/world/surface.d.ts +30 -0
  109. package/dist/_internal/forma/world/surface.js +213 -0
  110. package/dist/_internal/forma/world/table-expressions.d.ts +3 -0
  111. package/dist/_internal/forma/world/table-expressions.js +41 -0
  112. package/dist/_internal/forma-tools/index.d.ts +17 -0
  113. package/dist/_internal/forma-tools/index.js +124 -0
  114. package/dist/_internal/ir-checks/advances.d.ts +7 -0
  115. package/dist/_internal/ir-checks/advances.js +6 -0
  116. package/dist/_internal/ir-checks/agent-reads.d.ts +14 -0
  117. package/dist/_internal/ir-checks/agent-reads.js +118 -0
  118. package/dist/_internal/ir-checks/amendments.d.ts +3 -0
  119. package/dist/_internal/ir-checks/amendments.js +21 -0
  120. package/dist/_internal/ir-checks/canonical-json.d.ts +3 -0
  121. package/dist/_internal/ir-checks/canonical-json.js +85 -0
  122. package/dist/_internal/ir-checks/child-parameters.d.ts +2 -0
  123. package/dist/_internal/ir-checks/child-parameters.js +43 -0
  124. package/dist/_internal/ir-checks/clock-bindings.d.ts +3 -0
  125. package/dist/_internal/ir-checks/clock-bindings.js +43 -0
  126. package/dist/_internal/ir-checks/collect-types.d.ts +14 -0
  127. package/dist/_internal/ir-checks/collect-types.js +34 -0
  128. package/dist/_internal/ir-checks/component-operations.d.ts +4 -0
  129. package/dist/_internal/ir-checks/component-operations.js +23 -0
  130. package/dist/_internal/ir-checks/content-digest.d.ts +4 -0
  131. package/dist/_internal/ir-checks/content-digest.js +78 -0
  132. package/dist/_internal/ir-checks/contract-validation.d.ts +3 -0
  133. package/dist/_internal/ir-checks/contract-validation.js +307 -0
  134. package/dist/_internal/ir-checks/contracts.d.ts +25 -0
  135. package/dist/_internal/ir-checks/contracts.js +80 -0
  136. package/dist/_internal/ir-checks/dates.d.ts +2 -0
  137. package/dist/_internal/ir-checks/dates.js +7 -0
  138. package/dist/_internal/ir-checks/documents.d.ts +3 -0
  139. package/dist/_internal/ir-checks/documents.js +45 -0
  140. package/dist/_internal/ir-checks/evidence.d.ts +20 -0
  141. package/dist/_internal/ir-checks/evidence.js +56 -0
  142. package/dist/_internal/ir-checks/files.d.ts +7 -0
  143. package/dist/_internal/ir-checks/files.js +47 -0
  144. package/dist/_internal/ir-checks/index.d.ts +59 -0
  145. package/dist/_internal/ir-checks/index.js +166 -0
  146. package/dist/_internal/ir-checks/instants.d.ts +7 -0
  147. package/dist/_internal/ir-checks/instants.js +61 -0
  148. package/dist/_internal/ir-checks/notices.d.ts +4 -0
  149. package/dist/_internal/ir-checks/notices.js +58 -0
  150. package/dist/_internal/ir-checks/policy-bounds.d.ts +5 -0
  151. package/dist/_internal/ir-checks/policy-bounds.js +28 -0
  152. package/dist/_internal/ir-checks/principals.d.ts +26 -0
  153. package/dist/_internal/ir-checks/principals.js +162 -0
  154. package/dist/_internal/ir-checks/prior-cycle.d.ts +41 -0
  155. package/dist/_internal/ir-checks/prior-cycle.js +21 -0
  156. package/dist/_internal/ir-checks/read-classification.d.ts +12 -0
  157. package/dist/_internal/ir-checks/read-classification.js +67 -0
  158. package/dist/_internal/ir-checks/read-types.d.ts +2 -0
  159. package/dist/_internal/ir-checks/read-types.js +40 -0
  160. package/dist/_internal/ir-checks/resource-proofs.d.ts +4 -0
  161. package/dist/_internal/ir-checks/resource-proofs.js +98 -0
  162. package/dist/_internal/ir-checks/resources.d.ts +3 -0
  163. package/dist/_internal/ir-checks/resources.js +30 -0
  164. package/dist/_internal/ir-checks/reuse.d.ts +10 -0
  165. package/dist/_internal/ir-checks/reuse.js +99 -0
  166. package/dist/_internal/ir-checks/sealing.d.ts +14 -0
  167. package/dist/_internal/ir-checks/sealing.js +123 -0
  168. package/dist/_internal/ir-checks/sensitive-flow.d.ts +4 -0
  169. package/dist/_internal/ir-checks/sensitive-flow.js +240 -0
  170. package/dist/_internal/ir-checks/sensitivity.d.ts +19 -0
  171. package/dist/_internal/ir-checks/sensitivity.js +133 -0
  172. package/dist/_internal/ir-checks/signatures.d.ts +4 -0
  173. package/dist/_internal/ir-checks/signatures.js +22 -0
  174. package/dist/_internal/ir-checks/vaults.d.ts +10 -0
  175. package/dist/_internal/ir-checks/vaults.js +140 -0
  176. package/dist/_internal/protocol/index.d.ts +1234 -0
  177. package/dist/_internal/protocol/index.js +215 -0
  178. package/dist/_internal/reconciler/action-intents.d.ts +17 -0
  179. package/dist/_internal/reconciler/action-intents.js +161 -0
  180. package/dist/_internal/reconciler/actions.d.ts +7 -0
  181. package/dist/_internal/reconciler/actions.js +134 -0
  182. package/dist/_internal/reconciler/amendments.d.ts +12 -0
  183. package/dist/_internal/reconciler/amendments.js +52 -0
  184. package/dist/_internal/reconciler/basis.d.ts +253 -0
  185. package/dist/_internal/reconciler/basis.js +16 -0
  186. package/dist/_internal/reconciler/bundles.d.ts +22 -0
  187. package/dist/_internal/reconciler/bundles.js +110 -0
  188. package/dist/_internal/reconciler/change-detection.d.ts +5 -0
  189. package/dist/_internal/reconciler/change-detection.js +82 -0
  190. package/dist/_internal/reconciler/collection-rules.d.ts +7 -0
  191. package/dist/_internal/reconciler/collection-rules.js +46 -0
  192. package/dist/_internal/reconciler/collection-state.d.ts +11 -0
  193. package/dist/_internal/reconciler/collection-state.js +62 -0
  194. package/dist/_internal/reconciler/collection-values.d.ts +5 -0
  195. package/dist/_internal/reconciler/collection-values.js +60 -0
  196. package/dist/_internal/reconciler/collections.d.ts +35 -0
  197. package/dist/_internal/reconciler/collections.js +141 -0
  198. package/dist/_internal/reconciler/commands.d.ts +60 -0
  199. package/dist/_internal/reconciler/commands.js +468 -0
  200. package/dist/_internal/reconciler/component-operations.d.ts +48 -0
  201. package/dist/_internal/reconciler/component-operations.js +256 -0
  202. package/dist/_internal/reconciler/context.d.ts +38 -0
  203. package/dist/_internal/reconciler/context.js +44 -0
  204. package/dist/_internal/reconciler/coverage.d.ts +31 -0
  205. package/dist/_internal/reconciler/coverage.js +124 -0
  206. package/dist/_internal/reconciler/dates.d.ts +38 -0
  207. package/dist/_internal/reconciler/dates.js +121 -0
  208. package/dist/_internal/reconciler/decide.d.ts +25 -0
  209. package/dist/_internal/reconciler/decide.js +263 -0
  210. package/dist/_internal/reconciler/decision-evaluation.d.ts +9 -0
  211. package/dist/_internal/reconciler/decision-evaluation.js +67 -0
  212. package/dist/_internal/reconciler/decision-records.d.ts +14 -0
  213. package/dist/_internal/reconciler/decision-records.js +77 -0
  214. package/dist/_internal/reconciler/decision-release.d.ts +3 -0
  215. package/dist/_internal/reconciler/decision-release.js +12 -0
  216. package/dist/_internal/reconciler/dependencies.d.ts +179 -0
  217. package/dist/_internal/reconciler/dependencies.js +372 -0
  218. package/dist/_internal/reconciler/discovery.d.ts +9 -0
  219. package/dist/_internal/reconciler/discovery.js +65 -0
  220. package/dist/_internal/reconciler/document-corrections.d.ts +18 -0
  221. package/dist/_internal/reconciler/document-corrections.js +59 -0
  222. package/dist/_internal/reconciler/documents.d.ts +26 -0
  223. package/dist/_internal/reconciler/documents.js +88 -0
  224. package/dist/_internal/reconciler/effective.d.ts +6 -0
  225. package/dist/_internal/reconciler/effective.js +17 -0
  226. package/dist/_internal/reconciler/escalations.d.ts +4 -0
  227. package/dist/_internal/reconciler/escalations.js +76 -0
  228. package/dist/_internal/reconciler/evaluation.d.ts +56 -0
  229. package/dist/_internal/reconciler/evaluation.js +704 -0
  230. package/dist/_internal/reconciler/evidence-authority.d.ts +6 -0
  231. package/dist/_internal/reconciler/evidence-authority.js +70 -0
  232. package/dist/_internal/reconciler/evidence-history.d.ts +5 -0
  233. package/dist/_internal/reconciler/evidence-history.js +22 -0
  234. package/dist/_internal/reconciler/evidence-validity.d.ts +17 -0
  235. package/dist/_internal/reconciler/evidence-validity.js +135 -0
  236. package/dist/_internal/reconciler/fact-validation.d.ts +5 -0
  237. package/dist/_internal/reconciler/fact-validation.js +49 -0
  238. package/dist/_internal/reconciler/files.d.ts +9 -0
  239. package/dist/_internal/reconciler/files.js +56 -0
  240. package/dist/_internal/reconciler/graph.d.ts +40 -0
  241. package/dist/_internal/reconciler/graph.js +298 -0
  242. package/dist/_internal/reconciler/holds.d.ts +6 -0
  243. package/dist/_internal/reconciler/holds.js +18 -0
  244. package/dist/_internal/reconciler/home-definitions.d.ts +11 -0
  245. package/dist/_internal/reconciler/home-definitions.js +25 -0
  246. package/dist/_internal/reconciler/homes.d.ts +6 -0
  247. package/dist/_internal/reconciler/homes.js +32 -0
  248. package/dist/_internal/reconciler/index.d.ts +42 -0
  249. package/dist/_internal/reconciler/index.js +58 -0
  250. package/dist/_internal/reconciler/instants.d.ts +17 -0
  251. package/dist/_internal/reconciler/instants.js +56 -0
  252. package/dist/_internal/reconciler/interaction-fields.d.ts +10 -0
  253. package/dist/_internal/reconciler/interaction-fields.js +30 -0
  254. package/dist/_internal/reconciler/invariants.d.ts +8 -0
  255. package/dist/_internal/reconciler/invariants.js +34 -0
  256. package/dist/_internal/reconciler/journal.d.ts +3 -0
  257. package/dist/_internal/reconciler/journal.js +4 -0
  258. package/dist/_internal/reconciler/linking.d.ts +10 -0
  259. package/dist/_internal/reconciler/linking.js +259 -0
  260. package/dist/_internal/reconciler/memory.d.ts +32 -0
  261. package/dist/_internal/reconciler/memory.js +190 -0
  262. package/dist/_internal/reconciler/milestones.d.ts +7 -0
  263. package/dist/_internal/reconciler/milestones.js +58 -0
  264. package/dist/_internal/reconciler/missing.d.ts +18 -0
  265. package/dist/_internal/reconciler/missing.js +79 -0
  266. package/dist/_internal/reconciler/model.d.ts +350 -0
  267. package/dist/_internal/reconciler/model.js +9 -0
  268. package/dist/_internal/reconciler/notices.d.ts +14 -0
  269. package/dist/_internal/reconciler/notices.js +80 -0
  270. package/dist/_internal/reconciler/occurrences.d.ts +3 -0
  271. package/dist/_internal/reconciler/occurrences.js +30 -0
  272. package/dist/_internal/reconciler/outputs.d.ts +12 -0
  273. package/dist/_internal/reconciler/outputs.js +132 -0
  274. package/dist/_internal/reconciler/parameters.d.ts +4 -0
  275. package/dist/_internal/reconciler/parameters.js +27 -0
  276. package/dist/_internal/reconciler/policies.d.ts +22 -0
  277. package/dist/_internal/reconciler/policies.js +94 -0
  278. package/dist/_internal/reconciler/policy-edits.d.ts +11 -0
  279. package/dist/_internal/reconciler/policy-edits.js +42 -0
  280. package/dist/_internal/reconciler/policy-linking.d.ts +4 -0
  281. package/dist/_internal/reconciler/policy-linking.js +104 -0
  282. package/dist/_internal/reconciler/principal-types.d.ts +2 -0
  283. package/dist/_internal/reconciler/principal-types.js +38 -0
  284. package/dist/_internal/reconciler/prior-decisions.d.ts +3 -0
  285. package/dist/_internal/reconciler/prior-decisions.js +34 -0
  286. package/dist/_internal/reconciler/projections.d.ts +4 -0
  287. package/dist/_internal/reconciler/projections.js +85 -0
  288. package/dist/_internal/reconciler/proofs.d.ts +9 -0
  289. package/dist/_internal/reconciler/proofs.js +24 -0
  290. package/dist/_internal/reconciler/properties.d.ts +25 -0
  291. package/dist/_internal/reconciler/properties.js +67 -0
  292. package/dist/_internal/reconciler/property-eval.d.ts +5 -0
  293. package/dist/_internal/reconciler/property-eval.js +101 -0
  294. package/dist/_internal/reconciler/property-generator.d.ts +9 -0
  295. package/dist/_internal/reconciler/property-generator.js +288 -0
  296. package/dist/_internal/reconciler/property-shrink.d.ts +14 -0
  297. package/dist/_internal/reconciler/property-shrink.js +183 -0
  298. package/dist/_internal/reconciler/provenance.d.ts +8 -0
  299. package/dist/_internal/reconciler/provenance.js +61 -0
  300. package/dist/_internal/reconciler/reconcile.d.ts +32 -0
  301. package/dist/_internal/reconciler/reconcile.js +164 -0
  302. package/dist/_internal/reconciler/recurrence.d.ts +9 -0
  303. package/dist/_internal/reconciler/recurrence.js +44 -0
  304. package/dist/_internal/reconciler/requirements.d.ts +5 -0
  305. package/dist/_internal/reconciler/requirements.js +331 -0
  306. package/dist/_internal/reconciler/resource-generation.d.ts +9 -0
  307. package/dist/_internal/reconciler/resource-generation.js +17 -0
  308. package/dist/_internal/reconciler/resource-scenarios.d.ts +26 -0
  309. package/dist/_internal/reconciler/resource-scenarios.js +78 -0
  310. package/dist/_internal/reconciler/resources.d.ts +24 -0
  311. package/dist/_internal/reconciler/resources.js +178 -0
  312. package/dist/_internal/reconciler/result-digest.d.ts +13 -0
  313. package/dist/_internal/reconciler/result-digest.js +66 -0
  314. package/dist/_internal/reconciler/reuse.d.ts +16 -0
  315. package/dist/_internal/reconciler/reuse.js +119 -0
  316. package/dist/_internal/reconciler/scenarios.d.ts +32 -0
  317. package/dist/_internal/reconciler/scenarios.js +442 -0
  318. package/dist/_internal/reconciler/scheduling.d.ts +9 -0
  319. package/dist/_internal/reconciler/scheduling.js +203 -0
  320. package/dist/_internal/reconciler/sha256.d.ts +1 -0
  321. package/dist/_internal/reconciler/sha256.js +1 -0
  322. package/dist/_internal/reconciler/signatures.d.ts +13 -0
  323. package/dist/_internal/reconciler/signatures.js +37 -0
  324. package/dist/_internal/reconciler/temporal.d.ts +10 -0
  325. package/dist/_internal/reconciler/temporal.js +46 -0
  326. package/dist/_internal/reconciler/upgrades.d.ts +6 -0
  327. package/dist/_internal/reconciler/upgrades.js +65 -0
  328. package/dist/_internal/reconciler/wire.d.ts +2 -0
  329. package/dist/_internal/reconciler/wire.js +5 -0
  330. package/dist/_internal/reconciler/work.d.ts +32 -0
  331. package/dist/_internal/reconciler/work.js +101 -0
  332. package/dist/_internal/world-ir/schema.generated.d.ts +180 -0
  333. package/dist/_internal/world-ir/schema.generated.js +1127 -0
  334. package/dist/_internal/world-ir/types.generated.d.ts +1011 -0
  335. package/dist/_internal/world-ir/types.generated.js +1 -0
  336. package/dist/authoring.d.ts +9 -0
  337. package/dist/authoring.js +10 -0
  338. package/dist/catalogue.d.ts +20 -0
  339. package/dist/catalogue.js +531 -0
  340. package/dist/cli.d.ts +2 -0
  341. package/dist/cli.js +553 -0
  342. package/dist/codegen.d.ts +6 -0
  343. package/dist/codegen.js +89 -0
  344. package/dist/coverage.d.ts +60 -0
  345. package/dist/coverage.js +128 -0
  346. package/dist/deploy.d.ts +21 -0
  347. package/dist/deploy.js +72 -0
  348. package/dist/diagnostics.d.ts +9 -0
  349. package/dist/diagnostics.js +37 -0
  350. package/dist/diff.d.ts +17 -0
  351. package/dist/diff.js +19 -0
  352. package/dist/durable-object.d.ts +14 -0
  353. package/dist/durable-object.js +30 -0
  354. package/dist/explain.d.ts +113 -0
  355. package/dist/explain.js +225 -0
  356. package/dist/fixes.d.ts +4 -0
  357. package/dist/fixes.js +70 -0
  358. package/dist/fmt.d.ts +12 -0
  359. package/dist/fmt.js +39 -0
  360. package/dist/handle/open.d.ts +18 -0
  361. package/dist/handle/open.js +28 -0
  362. package/dist/handle/protocol.d.ts +12 -0
  363. package/dist/handle/protocol.js +96 -0
  364. package/dist/handle/store.d.ts +31 -0
  365. package/dist/handle/store.js +11 -0
  366. package/dist/handle/types.d.ts +37 -0
  367. package/dist/handle/types.js +1 -0
  368. package/dist/handle/world.d.ts +190 -0
  369. package/dist/handle/world.js +533 -0
  370. package/dist/http.d.ts +3 -0
  371. package/dist/http.js +72 -0
  372. package/dist/impact.d.ts +21 -0
  373. package/dist/impact.js +57 -0
  374. package/dist/index.d.ts +30 -0
  375. package/dist/index.js +43 -0
  376. package/dist/init.d.ts +13 -0
  377. package/dist/init.js +99 -0
  378. package/dist/ir-schema.json +4213 -0
  379. package/dist/lints.d.ts +8 -0
  380. package/dist/lints.js +154 -0
  381. package/dist/lsp.d.ts +14 -0
  382. package/dist/lsp.js +380 -0
  383. package/dist/manual/catalog.d.ts +12 -0
  384. package/dist/manual/catalog.js +23 -0
  385. package/dist/manual/examples.d.ts +15 -0
  386. package/dist/manual/examples.js +39 -0
  387. package/dist/manual/projections.d.ts +77 -0
  388. package/dist/manual/projections.js +344 -0
  389. package/dist/manual/prose.d.ts +19 -0
  390. package/dist/manual/prose.js +215 -0
  391. package/dist/manual/render.d.ts +76 -0
  392. package/dist/manual/render.js +250 -0
  393. package/dist/manual/text.d.ts +7 -0
  394. package/dist/manual/text.js +15 -0
  395. package/dist/mcp.d.ts +32 -0
  396. package/dist/mcp.js +269 -0
  397. package/dist/mutate.d.ts +36 -0
  398. package/dist/mutate.js +123 -0
  399. package/dist/project.d.ts +26 -0
  400. package/dist/project.js +80 -0
  401. package/dist/refine.d.ts +18 -0
  402. package/dist/refine.js +197 -0
  403. package/dist/release/diff.d.ts +45 -0
  404. package/dist/release/diff.js +103 -0
  405. package/dist/release/impact.d.ts +83 -0
  406. package/dist/release/impact.js +214 -0
  407. package/dist/release/nodes.d.ts +20 -0
  408. package/dist/release/nodes.js +118 -0
  409. package/dist/render.d.ts +19 -0
  410. package/dist/render.js +43 -0
  411. package/dist/serve.d.ts +18 -0
  412. package/dist/serve.js +140 -0
  413. package/dist/snapshot.d.ts +19 -0
  414. package/dist/snapshot.js +45 -0
  415. package/dist/sqlite.d.ts +16 -0
  416. package/dist/sqlite.js +151 -0
  417. package/dist/test.d.ts +54 -0
  418. package/dist/test.js +131 -0
  419. package/dist/world.d.ts +7 -0
  420. package/dist/world.js +5 -0
  421. package/docs/authoring/vendor-risk/example.forma +11 -0
  422. package/docs/authoring/vendor-risk/library/vendor.forma +76 -0
  423. package/docs/authoring/vendor-risk/scenarios/reviews.forma +107 -0
  424. package/docs/protocol.md +195 -0
  425. package/docs/reference.md +258 -0
  426. package/package.json +81 -3
@@ -0,0 +1,116 @@
1
+ import { sourceSyntax } from "../source-syntax.js";
2
+ import {} from "@forma-language/forma/reader";
3
+ import { agentReadHelp, sensitiveClasses } from "../../../ir-checks/index.js";
4
+ import { headOf, items, LowerError, mapPairs, spanOf, symName } from "./syntax.js";
5
+ const fail = (at, message) => {
6
+ throw new LowerError("E_AGENT_SENSITIVE_READ", message, at, agentReadHelp);
7
+ };
8
+ const read = (form, at) => {
9
+ const parts = items(form), options = new Map();
10
+ for (let n = parts[2]?._tag === "Str" ? 3 : 2; n < parts.length; n += 2) {
11
+ const key = parts[n], name = symName(key), value = parts[n + 1];
12
+ if (!name || ![":of", ":reads", ":may-read"].includes(name) || options.has(name) || !value)
13
+ fail(at(key), "Only unique :of, :reads and :may-read options belong in a static agent read contract.");
14
+ options.set(name, value);
15
+ }
16
+ const owner = options.get(":of"), paths = options.get(":reads"), grants = options.get(":may-read");
17
+ if (!owner || !symName(owner) || symName(owner).startsWith(":"))
18
+ fail(at(owner ?? form), "Name a declared owning component.");
19
+ if (paths?._tag !== "Vector" || !items(paths).length)
20
+ fail(at(paths ?? form), "Declare a nonempty vector of concrete field paths.");
21
+ const seenPaths = new Set();
22
+ for (const path of items(paths)) {
23
+ const name = symName(path), parts = name?.split(".");
24
+ if (!name ||
25
+ name.startsWith(":") ||
26
+ !parts ||
27
+ parts.length < 2 ||
28
+ parts.some((p) => !p) ||
29
+ seenPaths.has(name))
30
+ fail(at(path), "Read unique concrete input.field paths, not arbitrary expressions.");
31
+ seenPaths.add(name);
32
+ }
33
+ if (grants && grants._tag !== "Vector")
34
+ fail(at(grants), "Use a vector of exact class/vault grant maps.");
35
+ const seenGrants = new Set();
36
+ for (const grant of items(grants)) {
37
+ const pairs = mapPairs(grant), keys = pairs.map(([k]) => symName(k)), classification = symName(pairs.find(([k]) => symName(k) === ":class")?.[1]), vault = symName(pairs.find(([k]) => symName(k) === ":vault")?.[1]);
38
+ if (pairs.length !== 2 ||
39
+ new Set(keys).size !== 2 ||
40
+ !keys.every((k) => k === ":class" || k === ":vault") ||
41
+ !sensitiveClasses.some((c) => classification === `:${c}`) ||
42
+ !vault ||
43
+ vault.startsWith(":"))
44
+ fail(at(grant), "Each grant needs exactly one declared :class and named :vault.");
45
+ const key = `${classification}:${vault}`;
46
+ if (seenGrants.has(key))
47
+ fail(at(grant), "Class/vault grants must be unique.");
48
+ seenGrants.add(key);
49
+ }
50
+ return { owner: owner, paths: items(paths), grants: items(grants) };
51
+ };
52
+ /** Closed read syntax gets actionable spans before generic descriptor validation. */
53
+ export const agentSourceDiagnostics = (files) => {
54
+ const names = new Set();
55
+ for (const file of files) {
56
+ if (!file.text.includes("agent"))
57
+ continue;
58
+ try {
59
+ const parsed = sourceSyntax(file);
60
+ if (parsed.errors.length)
61
+ continue;
62
+ for (const form of parsed.forms)
63
+ if (headOf(form) === "agent") {
64
+ read(form, (e) => spanOf(file.id, e));
65
+ const name = symName(items(form)[1]);
66
+ if (!name || names.has(name))
67
+ fail(spanOf(file.id, items(form)[1] ?? form), "Agent names must be unique.");
68
+ names.add(name);
69
+ }
70
+ }
71
+ catch (error) {
72
+ if (!(error instanceof LowerError))
73
+ continue;
74
+ return [
75
+ {
76
+ code: error.code,
77
+ severity: "error",
78
+ message: error.message,
79
+ at: error.at,
80
+ help: agentReadHelp,
81
+ },
82
+ ];
83
+ }
84
+ }
85
+ return [];
86
+ };
87
+ export const lowerAgents = (context, components) => context.byForm("agent").map((d) => {
88
+ const form = context.formOf(d), syntax = read(form, (e) => context.at(d, e)), owner = symName(syntax.owner), found = components.filter((c) => c.name === owner);
89
+ if (found.length !== 1)
90
+ fail(context.at(d, syntax.owner), "Name one declared component for this read contract.");
91
+ const scope = context.componentScope(owner);
92
+ return {
93
+ name: d.summary.name,
94
+ ...context.docOf(context.payload(d).doc),
95
+ of: owner,
96
+ reads: syntax.paths.map((path) => {
97
+ try {
98
+ return context.lowerExpr(d, path, scope);
99
+ }
100
+ catch (error) {
101
+ if (!(error instanceof LowerError))
102
+ throw error;
103
+ return fail(context.at(d, path), "The requested field path is not statically resolvable.");
104
+ }
105
+ }),
106
+ mayRead: syntax.grants.map((grant) => {
107
+ const pairs = mapPairs(grant);
108
+ return {
109
+ class: symName(pairs.find(([k]) => symName(k) === ":class")[1]).slice(1),
110
+ vault: symName(pairs.find(([k]) => symName(k) === ":vault")[1]),
111
+ at: context.at(d, grant),
112
+ };
113
+ }),
114
+ at: context.at(d, form),
115
+ };
116
+ });
@@ -0,0 +1,3 @@
1
+ import type * as IR from "../../../world-ir/types.generated.js";
2
+ import type { LoweringContext } from "./context.js";
3
+ export declare const lowerBundles: (cx: LoweringContext) => IR.Bundle[];
@@ -0,0 +1,13 @@
1
+ import { LowerError, option, symName } from "./syntax.js";
2
+ export const lowerBundles = (cx) => cx.byForm("bundle").map((d) => {
3
+ const form = cx.formOf(d), label = option(form, "label");
4
+ if (label?._tag !== "Str" || !label.value.trim())
5
+ throw new LowerError("E_BUNDLE_LABEL", "A bundle needs a nonempty presentation label.", cx.at(d, label ?? form), 'Add :label "Finish onboarding" or another readable session title.');
6
+ return {
7
+ name: d.summary.name,
8
+ ...cx.docOf(cx.payload(d).doc),
9
+ role: symName(option(form, "for")),
10
+ label: label.value,
11
+ at: cx.at(d, form),
12
+ };
13
+ });
@@ -0,0 +1,14 @@
1
+ import type { LoweringContext } from "./context.js";
2
+ export declare const lowerChildParameters: (cx: LoweringContext, d: Parameters<typeof cx.formOf>[0], slot: Parameters<typeof cx.at>[1], child: string) => {
3
+ with?: never;
4
+ } | {
5
+ with: readonly [{
6
+ name: string;
7
+ value: import("../../../world-ir/types.generated.js").PolicyNumber;
8
+ at: import("../../../world-ir/types.generated.js").Span;
9
+ }, ...{
10
+ name: string;
11
+ value: import("../../../world-ir/types.generated.js").PolicyNumber;
12
+ at: import("../../../world-ir/types.generated.js").Span;
13
+ }[]];
14
+ };
@@ -0,0 +1,36 @@
1
+ import { policyValueWithin } from "../../../ir-checks/index.js";
2
+ import { lowerParamBounds, lowerPolicyNumber } from "./param-bounds.js";
3
+ import { option, symName, LowerError } from "./syntax.js";
4
+ export const lowerChildParameters = (cx, d, slot, child) => {
5
+ const value = option(slot, "with");
6
+ if (!value)
7
+ return {};
8
+ const fail = (at, message) => {
9
+ throw new LowerError("E_PARAM_OUT_OF_BOUNDS", message, cx.at(d, at), "Use :with {:parameter fixed-value} for the child's declared Int/Duration bounds, in the declared unit and tightening interval. Provide fixed literals in an acyclic composition; expressions and unbounded parameters are not supported.");
10
+ };
11
+ if (value._tag !== "Map")
12
+ return fail(value, ":with requires a parameter map.");
13
+ const target = cx.byForm("component").find((x) => x.summary.name === child), payload = cx.components.get(child), bounds = lowerParamBounds(cx, target, cx.formOf(target), payload.params), names = new Set();
14
+ const params = value.pairs.map(([key, v]) => {
15
+ const name = symName(key)?.replace(/^:/, "");
16
+ if (!name || names.has(name))
17
+ return fail(key, "Name each child parameter once.");
18
+ names.add(name);
19
+ const bound = bounds.find((b) => b.name === name);
20
+ if (!bound)
21
+ return fail(key, "Only bounded parameters declared by the child may be set.");
22
+ let parsed;
23
+ try {
24
+ parsed = lowerPolicyNumber(cx, d, v);
25
+ }
26
+ catch (error) {
27
+ if (error instanceof LowerError)
28
+ return fail(v, "A child parameter needs a fixed safe integer or duration literal.");
29
+ throw error;
30
+ }
31
+ if (!policyValueWithin(bound, parsed))
32
+ return fail(v, "The child parameter is outside its declared tightening interval or unit.");
33
+ return { name, value: parsed, at: cx.at(d, v) };
34
+ });
35
+ return params.length ? { with: [params[0], ...params.slice(1)] } : {};
36
+ };
@@ -0,0 +1,3 @@
1
+ import type * as IR from "../../../world-ir/types.generated.js";
2
+ import type { LoweringContext } from "./context.js";
3
+ export declare const lowerCollects: (context: LoweringContext, layouts: readonly IR.Layout[]) => IR.Collect[];
@@ -0,0 +1,51 @@
1
+ import { collectionType } from "../../../ir-checks/index.js";
2
+ import { headOf, items, LowerError, option, symName } from "./syntax.js";
3
+ export const lowerCollects = (context, layouts) => context.byForm("collect").map((declaration) => {
4
+ const form = context.formOf(declaration), facts = items(option(form, "facts")).map((f) => symName(f).replace(/^:/, "")), layout = option(form, "layout"), name = symName(layout), found = layouts.find((l) => l.name === name);
5
+ const role = context.roles.get(symName(option(form, "from")));
6
+ if (facts.some((name) => !collectionType(role.fields.find((f) => f.name === name).type, context.authoredTypes)))
7
+ throw new LowerError("E_COLLECT_TYPE", "Collection supports scalar source fields only.", context.at(declaration, option(form, "facts")), "Collect scalar strings, enums, numbers, booleans or dates/instants; relationship and structured fields need a separate typed operation.");
8
+ const shown = [];
9
+ let unconditional = true;
10
+ const visit = (item) => {
11
+ if (item.kind === "field") {
12
+ shown.push(item.name);
13
+ if (item.showWhen)
14
+ unconditional = false;
15
+ }
16
+ else if (item.kind === "group") {
17
+ if (item.showWhen)
18
+ unconditional = false;
19
+ item.items.forEach(visit);
20
+ }
21
+ else
22
+ unconditional = false;
23
+ };
24
+ found?.steps.forEach((step) => step.items.forEach(visit));
25
+ if (!found ||
26
+ !unconditional ||
27
+ shown.length !== facts.length ||
28
+ new Set(shown).size !== shown.length ||
29
+ facts.some((f) => !shown.includes(f)))
30
+ throw new LowerError("E_COLLECT_LAYOUT", "A collection layout must show exactly its source facts unconditionally.", context.at(declaration, layout), "Use a declared layout with each collected field exactly once, optionally in unconditional groups; omit guards, widgets and document signatures.");
31
+ const interval = option(form, "confirm-after");
32
+ let confirmAfter;
33
+ if (interval) {
34
+ const unit = headOf(interval), value = items(interval)[1], n = value?._tag === "Num" ? Number(value.value) : NaN;
35
+ if ((unit !== "days" && unit !== "years" && unit !== "hours" && unit !== "minutes") ||
36
+ items(interval).length !== 2 ||
37
+ !Number.isSafeInteger(n) ||
38
+ n <= 0)
39
+ throw new LowerError("E_COLLECT_INTERVAL", "Confirmation windows must be fixed positive safe-integer durations.", context.at(declaration, interval), "Use (days N), (years N), (hours N) or (minutes N) with a positive safe-integer literal; zero, dynamic and fractional windows are not supported.");
40
+ confirmAfter = { n, unit, at: context.at(declaration, interval) };
41
+ }
42
+ return {
43
+ name: declaration.summary.name,
44
+ ...context.docOf(context.payload(declaration).doc),
45
+ from: symName(option(form, "from")),
46
+ facts: [facts[0], ...facts.slice(1)],
47
+ layout: name,
48
+ ...(confirmAfter ? { confirmAfter } : {}),
49
+ at: context.at(declaration, form),
50
+ };
51
+ });
@@ -0,0 +1,6 @@
1
+ import type { LoweringContext } from "./context.js";
2
+ export declare const lowerComponentOperations: (cx: LoweringContext, d: Parameters<typeof cx.formOf>[0]) => {
3
+ operations?: never;
4
+ } | {
5
+ operations: string[];
6
+ };
@@ -0,0 +1,26 @@
1
+ import { items, option, symName, LowerError } from "./syntax.js";
2
+ export const lowerComponentOperations = (cx, d) => {
3
+ const form = cx.formOf(d), value = option(form, "operations");
4
+ if (!value)
5
+ return {};
6
+ const fail = (at) => {
7
+ throw new LowerError("E_NOT_AN_OPERATION", "Public operations must select unique, unambiguous authored actions or decisions owned by this component.", cx.at(d, at), "Use :operations [action-name decision-name] with owned authored names; use [] to expose none. Private helpers and requirements are not operations.");
8
+ };
9
+ if (value._tag !== "Vector")
10
+ return fail(value);
11
+ const owner = d.summary.name, actions = cx.components.get(owner).actions.map((a) => a.name), decisions = cx
12
+ .byForm("decision")
13
+ .filter((x) => symName(option(cx.formOf(x), "of")) === owner)
14
+ .map((x) => x.summary.name);
15
+ const names = [];
16
+ for (const item of items(value)) {
17
+ const name = symName(item);
18
+ if (!name ||
19
+ name.startsWith(":") ||
20
+ names.includes(name) ||
21
+ [...actions, ...decisions].filter((n) => n === name).length !== 1)
22
+ fail(item);
23
+ names.push(name);
24
+ }
25
+ return { operations: names };
26
+ };
@@ -0,0 +1,7 @@
1
+ import { type ElaboratedDeclaration } from "@forma-language/forma/descriptor";
2
+ import { type SExpr } from "@forma-language/forma/reader";
3
+ import type * as IR from "../../../world-ir/types.generated.js";
4
+ import { type LoweringContext } from "./context.js";
5
+ import { type Scope } from "./syntax.js";
6
+ export declare const lowerComponents: (context: LoweringContext) => IR.Component[];
7
+ export declare function lowerAccepts(context: LoweringContext, d: ElaboratedDeclaration, e: SExpr, scope: Scope): IR.Accepts;
@@ -0,0 +1,236 @@
1
+ import { canonicalConditionText } from "../surface.js";
2
+ import { lowerChildParameters } from "./child-parameters.js";
3
+ import { lowerComponentOperations } from "./component-operations.js";
4
+ import { stableWorkIdentity } from "../../../ir-checks/index.js";
5
+ import {} from "@forma-language/forma/descriptor";
6
+ import {} from "@forma-language/forma/reader";
7
+ import {} from "./context.js";
8
+ import { lowerDiscretionary } from "./discretionary.js";
9
+ import { lowerEscalations } from "./escalations.js";
10
+ import { lowerReuse } from "./reuse.js";
11
+ import { lowerRenewal } from "./renewal.js";
12
+ import { lowerEffective } from "./effective.js";
13
+ import { lowerRecurrence } from "./recurrences.js";
14
+ import { lowerMilestones } from "./milestones.js";
15
+ import { lowerParamBounds } from "./param-bounds.js";
16
+ import { lowerHolds } from "./holds.js";
17
+ import { lowerResources } from "./resources.js";
18
+ import { lowerActionPolicy } from "./action-policy.js";
19
+ import { childNamed, children, headOf, items, LowerError, mapPairs, option, symName, } from "./syntax.js";
20
+ export const lowerComponents = (context) => {
21
+ const { byForm, components, formOf, componentScope, docOf, homeOf, lowerExpr, lowerTyped, maybe, citations, labelOf, at, source, } = context;
22
+ return byForm("component").map((d) => {
23
+ const c = components.get(d.summary.name);
24
+ const form = formOf(d);
25
+ const scope = componentScope(d.summary.name);
26
+ const cycle = option(form, "cycle");
27
+ const paramBounds = lowerParamBounds(context, d, form, c.params);
28
+ const holds = lowerHolds(context, d, form, scope);
29
+ const resources = lowerResources(context, d, form, scope);
30
+ const milestones = lowerMilestones(context, d, form, scope);
31
+ const outputPath = (segments, here) => {
32
+ let owner = d.summary.name;
33
+ for (const [i, segment] of segments.entries()) {
34
+ const component = components.get(owner);
35
+ const last = i === segments.length - 1;
36
+ const slot = component.slots.find((s) => s.name === segment);
37
+ if (slot && !last) {
38
+ owner = slot.component;
39
+ continue;
40
+ }
41
+ if (last &&
42
+ (slot ||
43
+ component.outputs.some((o) => o.name === segment) ||
44
+ component.requirements.some((r) => r.name === segment)))
45
+ return;
46
+ throw new LowerError("E_OUTPUT_PATH", `${segments.join(".")} does not name an output, requirement or child of ${owner}.`, here, "Use a declared local requirement or a published child output; private data fields are not status outputs.");
47
+ }
48
+ };
49
+ return {
50
+ name: d.summary.name,
51
+ ...lowerComponentOperations(context, d),
52
+ ...(option(form, "library") ? { library: symName(option(form, "library")) } : {}),
53
+ ...docOf(c.doc),
54
+ ...(holds.length ? { holds } : {}),
55
+ ...(resources.length ? { resources: [resources[0], ...resources.slice(1)] } : {}),
56
+ ...(milestones.length ? { milestones } : {}),
57
+ key: c.key,
58
+ home: homeOf(d.summary.name),
59
+ inputs: c.inputs,
60
+ params: c.params,
61
+ ...(paramBounds.length
62
+ ? { paramBounds: [paramBounds[0], ...paramBounds.slice(1)] }
63
+ : {}),
64
+ ...(cycle ? { cycle: lowerExpr(d, cycle, scope) } : {}),
65
+ requirements: c.requirements.map((r) => {
66
+ const x = childNamed(form, "requirement", r.name);
67
+ const accepts = option(x, "accepts");
68
+ const reuse = lowerReuse(context, d, x);
69
+ const lowerOption = (key) => maybe(d, option(x, key), scope);
70
+ const appliesWhen = lowerOption("applies-when");
71
+ const requirementCycle = lowerOption("cycle");
72
+ const due = lowerOption("due");
73
+ const remind = lowerOption("remind");
74
+ const renewWithin = lowerRenewal(context, d, x);
75
+ const effective = lowerEffective(context, d, x);
76
+ const recur = lowerRecurrence(context, d, x, scope);
77
+ const escalate = lowerEscalations(context, d, x, scope);
78
+ return {
79
+ ...lowerDiscretionary(context, d, x, r.name),
80
+ name: r.name,
81
+ ...citations(d, x),
82
+ ...labelOf(r.label),
83
+ ...(appliesWhen ? { appliesWhen } : {}),
84
+ satisfiedBy: lowerExpr(d, option(x, "satisfied-by"), scope),
85
+ ...(reuse ? { reuse } : {}),
86
+ ...(accepts ? { accepts: lowerAccepts(context, d, accepts, scope) } : {}),
87
+ ...(requirementCycle ? { cycle: requirementCycle } : {}),
88
+ ...(recur ? { recur } : {}),
89
+ ...(effective ? { effective } : {}),
90
+ ...(due ? { due } : {}),
91
+ ...(remind ? { remind } : {}),
92
+ ...(renewWithin ? { renewWithin } : {}),
93
+ ...(escalate.length ? { escalate } : {}),
94
+ at: at(d, x),
95
+ };
96
+ }),
97
+ actions: c.actions.map((a) => {
98
+ const x = childNamed(form, "action", a.name);
99
+ const via = option(x, "via");
100
+ const assignee = option(x, "assignee");
101
+ const idempotency = option(x, "idempotency");
102
+ const targets = typeof a.advances === "string" ? [a.advances] : a.advances;
103
+ const targetAt = at(d, option(x, "advances"));
104
+ if (!targets.length || new Set(targets).size !== targets.length)
105
+ throw new LowerError("E_ADVANCES", "Advance a nonempty list of unique requirement names.", targetAt, "Use one declared requirement name or a nonempty vector of distinct local names.");
106
+ if (targets.length > 1 &&
107
+ targets.some((name) => {
108
+ const requirement = childNamed(form, "requirement", name);
109
+ return ["cycle", "recur", "renew-within", "accepts", "reuse"].some((key) => option(requirement, key));
110
+ }))
111
+ throw new LowerError("E_ADVANCES_SCOPE", "Multi-target work requires ordinary requirements in one occurrence.", targetAt, "Use separate actions for recurring, renewal or prior-cycle proof; share a keyed component or declare evidence reuse explicitly.");
112
+ const action = {
113
+ ...lowerActionPolicy(context, d, x),
114
+ name: a.name,
115
+ ...labelOf(a.label),
116
+ advances: typeof a.advances === "string"
117
+ ? a.advances
118
+ : [targets[0], ...targets.slice(1)],
119
+ needs: items(option(x, "needs")).map((n) => ({
120
+ expr: lowerExpr(d, n, scope),
121
+ text: canonicalConditionText(source(d, n)),
122
+ })),
123
+ ...(assignee ? { assignee: lowerExpr(d, assignee, scope) } : {}),
124
+ ...(assignee
125
+ ? {
126
+ assigneeKind: ["role", "entity"].includes(lowerTyped(d, assignee, scope).type.t)
127
+ ? "entity"
128
+ : "group",
129
+ }
130
+ : {}),
131
+ via: headOf(via) === "interaction"
132
+ ? { kind: "interaction", name: symName(items(via)[1]) }
133
+ : {
134
+ kind: "connector",
135
+ connector: headOf(via),
136
+ capability: symName(items(via)[1]),
137
+ },
138
+ ...(idempotency
139
+ ? { idempotency: items(idempotency).map((i) => lowerExpr(d, i, scope)) }
140
+ : {}),
141
+ at: at(d, x),
142
+ };
143
+ if (targets.length > 1 && !stableWorkIdentity(c, action))
144
+ throw new LowerError("E_ADVANCES_SCOPE", "Multi-target work identity must stay in its entity home.", at(d, option(x, "idempotency")), "Use stable component key inputs and include its first entity reference, or use self. Computed facts/constants cannot identify shared work.");
145
+ return action;
146
+ }),
147
+ slots: c.slots.map((s) => {
148
+ const x = childNamed(form, s.mode, s.name);
149
+ const appliesWhen = maybe(d, option(x, "applies-when"), scope);
150
+ return {
151
+ ...lowerDiscretionary(context, d, x, s.name),
152
+ mode: s.mode,
153
+ name: s.name,
154
+ component: s.component,
155
+ ...lowerChildParameters(context, d, x, s.component),
156
+ bind: mapPairs(option(x, "bind")).map(([k, v]) => ({
157
+ input: symName(k).replace(/^:/, ""),
158
+ expr: lowerExpr(d, v, scope),
159
+ })),
160
+ ...(appliesWhen ? { appliesWhen } : {}),
161
+ at: at(d, x),
162
+ };
163
+ }),
164
+ outputs: c.outputs.map((o) => {
165
+ const x = childNamed(form, "output", o.name);
166
+ const expr = items(x).at(-1);
167
+ const op = headOf(expr);
168
+ if (op !== "all-of" && op !== "any-of" && op !== "status-of")
169
+ throw new LowerError("E_OUTPUT", "An output is (all-of …), (any-of …) or (status-of …).", at(d, expr));
170
+ return {
171
+ name: o.name,
172
+ ...labelOf(o.label),
173
+ op,
174
+ paths: items(expr)
175
+ .slice(1)
176
+ .map((p) => {
177
+ const segments = symName(p).split(".");
178
+ outputPath(segments, at(d, p));
179
+ return { segments, at: at(d, p) };
180
+ }),
181
+ at: at(d, x),
182
+ };
183
+ }),
184
+ machines: c.machines.map((m) => ({
185
+ name: m.name,
186
+ protocol: m.protocol,
187
+ at: at(d, childNamed(form, "machine", m.name)),
188
+ })),
189
+ invariants: c.invariants.map((i) => {
190
+ const x = childNamed(form, "invariant", i.name);
191
+ const forbids = option(x, "forbids");
192
+ return {
193
+ name: i.name,
194
+ ...citations(d, x),
195
+ forbids: {
196
+ action: symName(option(forbids, "action-kind") ?? items(forbids)[1]).replace(/^:/, ""),
197
+ subject: lowerExpr(d, option(forbids, "subject"), scope),
198
+ },
199
+ while: lowerExpr(d, option(x, "while"), scope),
200
+ at: at(d, x),
201
+ };
202
+ }),
203
+ ...(c.retention[0]
204
+ ? (() => {
205
+ const x = children(form, "retention")[0];
206
+ return {
207
+ retention: {
208
+ ...citations(d, x),
209
+ until: lowerExpr(d, option(x, "until"), scope),
210
+ disposal: c.retention[0].disposal,
211
+ at: at(d, x),
212
+ },
213
+ };
214
+ })()
215
+ : {}),
216
+ at: at(d, form),
217
+ };
218
+ });
219
+ };
220
+ export function lowerAccepts(context, d, e, scope) {
221
+ const { at, lowerExpr } = context;
222
+ if (headOf(e) !== "prior-cycle")
223
+ throw new LowerError("E_ACCEPTS", "Only (prior-cycle …) acceptance is supported.", at(d, e));
224
+ const name = (key) => symName(option(e, key));
225
+ const within = option(e, "within");
226
+ const confirm = option(e, "confirm");
227
+ const label = option(e, "label");
228
+ return {
229
+ kind: "prior-cycle",
230
+ ...(name("from") ? { from: name("from") } : {}),
231
+ ...(name("with") ? { with: name("with") } : {}),
232
+ ...(within ? { within: lowerExpr(d, within, scope) } : {}),
233
+ ...(confirm ? { confirm: lowerExpr(d, confirm, scope) } : {}),
234
+ ...(label?._tag === "Str" ? { label: label.value } : {}),
235
+ };
236
+ }
@@ -0,0 +1,4 @@
1
+ import type * as IR from "../../../world-ir/types.generated.js";
2
+ import { type LoweringContext } from "./context.js";
3
+ export declare const lowerConnectors: (context: LoweringContext) => IR.Connector[];
4
+ export declare const lowerMachines: (context: LoweringContext) => IR.Machine[];
@@ -0,0 +1,31 @@
1
+ import {} from "./context.js";
2
+ export const lowerConnectors = (context) => {
3
+ const { byForm, payload, docOf, at, formOf } = context;
4
+ return byForm("connector").map((d) => {
5
+ const p = payload(d);
6
+ return {
7
+ name: d.summary.name,
8
+ ...docOf(p.doc),
9
+ capabilities: p.capabilities,
10
+ signals: p.signals,
11
+ owns: p.owns,
12
+ at: at(d, formOf(d)),
13
+ };
14
+ });
15
+ };
16
+ export const lowerMachines = (context) => {
17
+ const { byForm, payload, docOf, at, formOf } = context;
18
+ return byForm("machine").map((d) => {
19
+ const p = payload(d);
20
+ return {
21
+ name: d.summary.name,
22
+ ...docOf(p.doc),
23
+ signal: p.signal,
24
+ initial: p.initial,
25
+ final: p.final,
26
+ states: p.states.map((s) => ({ name: s.name, label: s.label })),
27
+ transitions: p.transitions.map((t) => ({ from: t.from, to: t.to })),
28
+ at: at(d, formOf(d)),
29
+ };
30
+ });
31
+ };
@@ -0,0 +1,80 @@
1
+ import { type ElaboratedDeclaration } from "@forma-language/forma/descriptor";
2
+ import { type SExpr } from "@forma-language/forma/reader";
3
+ import type { SourceFile } from "../compile.js";
4
+ import type * as IR from "../../../world-ir/types.generated.js";
5
+ import { type ComponentPayload, type Fields, type SType, type Scope } from "./syntax.js";
6
+ export declare const makeSyntaxContext: (files: readonly SourceFile[], declarations: readonly ElaboratedDeclaration[]) => {
7
+ authoredTypes: IR.TypeAlias[];
8
+ byForm: (form: string) => ElaboratedDeclaration[];
9
+ payload: <T>(d: ElaboratedDeclaration) => T;
10
+ formOf: (d: ElaboratedDeclaration) => SExpr;
11
+ at: (d: ElaboratedDeclaration, e: SExpr) => IR.Span;
12
+ source: (d: ElaboratedDeclaration, e: SExpr) => string;
13
+ };
14
+ export type SyntaxContext = ReturnType<typeof makeSyntaxContext>;
15
+ export declare const createLoweringContext: (files: readonly SourceFile[], declarations: readonly ElaboratedDeclaration[]) => {
16
+ references: IR.Source[];
17
+ citations: (d: ElaboratedDeclaration, form: SExpr) => {
18
+ cites?: readonly IR.Citation[];
19
+ };
20
+ roles: Map<string, {
21
+ doc?: string;
22
+ fields: Fields;
23
+ }>;
24
+ entities: Map<string, {
25
+ doc?: string;
26
+ ns: string;
27
+ "ns-declared": boolean;
28
+ display?: string;
29
+ fields: Fields;
30
+ implements: ReadonlyArray<{
31
+ role: string;
32
+ field: string;
33
+ path: string;
34
+ }>;
35
+ }>;
36
+ components: Map<string, ComponentPayload>;
37
+ derives: Map<string, {
38
+ doc?: string;
39
+ params: Fields;
40
+ returns: IR.TypeRef;
41
+ }>;
42
+ evidenceNames: Set<string>;
43
+ decisionNames: Set<string>;
44
+ calendarNames: Set<string>;
45
+ libraries: {
46
+ name: string;
47
+ doc?: string;
48
+ version: string;
49
+ subject: string;
50
+ }[];
51
+ subject: string | undefined;
52
+ typeOf: (ref: IR.TypeRef | undefined, seen?: ReadonlySet<string>) => SType;
53
+ homeOf: (name: string, visiting?: ReadonlySet<string>) => IR.InputHome | undefined;
54
+ fieldType: (owner: SType, field: string) => SType | undefined;
55
+ componentScope: (name: string) => Scope;
56
+ fieldScope: (fields: Fields) => Scope;
57
+ lowerExpr: (d: ElaboratedDeclaration, e: SExpr, scope: Scope) => IR.Expr;
58
+ lowerTyped: (d: ElaboratedDeclaration, e: SExpr, scope: Scope, paramTypes?: readonly SType[]) => {
59
+ expr: IR.Expr;
60
+ type: SType;
61
+ };
62
+ maybe: (d: ElaboratedDeclaration, e: SExpr | undefined, scope: Scope) => IR.Expr | undefined;
63
+ docOf: (doc: string | undefined) => {
64
+ doc?: never;
65
+ } | {
66
+ doc: string;
67
+ };
68
+ labelOf: (label: string | undefined) => {
69
+ label?: never;
70
+ } | {
71
+ label: string;
72
+ };
73
+ authoredTypes: IR.TypeAlias[];
74
+ byForm: (form: string) => ElaboratedDeclaration[];
75
+ payload: <T>(d: ElaboratedDeclaration) => T;
76
+ formOf: (d: ElaboratedDeclaration) => SExpr;
77
+ at: (d: ElaboratedDeclaration, e: SExpr) => IR.Span;
78
+ source: (d: ElaboratedDeclaration, e: SExpr) => string;
79
+ };
80
+ export type LoweringContext = ReturnType<typeof createLoweringContext>;