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,68 @@
1
+ import { documentHelp } from "../../../ir-checks/index.js";
2
+ import { lowerEffective } from "./effective.js";
3
+ import { lowerRecordSeal } from "./vaults.js";
4
+ import { LowerError, option, items, mapPairs, symName } from "./syntax.js";
5
+ export const lowerDocuments = (cx, evidence) => cx.byForm("document").map((d) => {
6
+ const form = cx.formOf(d), of = symName(option(form, "of")), from = option(form, "from"), edition = option(form, "edition"), template = option(form, "template");
7
+ const fail = (code, node, message) => {
8
+ throw new LowerError(code, message, cx.at(d, node ?? form), documentHelp);
9
+ };
10
+ if (!cx.byForm("component").some((c) => c.summary.name === of))
11
+ return fail("E_DOCUMENT_SOURCE", option(form, "of"), "Name an owning component.");
12
+ if (from?._tag !== "Vector" || !from.items.length)
13
+ return fail("E_DOCUMENT_SOURCE", from, "Choose a nonempty vector of owned evidence types.");
14
+ const sources = [];
15
+ for (const node of from.items) {
16
+ const name = symName(node);
17
+ if (!name || sources.includes(name) || !evidence.some((e) => e.name === name && e.of === of))
18
+ return fail("E_DOCUMENT_SOURCE", node, "Choose unique evidence owned by the document's component.");
19
+ sources.push(name);
20
+ }
21
+ if (edition?._tag !== "Str" || !edition.value.trim())
22
+ return fail("E_DOCUMENT_TEMPLATE", edition, "Use a fixed nonempty edition.");
23
+ const map = (node, allowed) => {
24
+ if (node?._tag !== "Map")
25
+ return fail("E_DOCUMENT_TEMPLATE", node, "Use a fixed template/field map.");
26
+ const pairs = mapPairs(node), keys = pairs.map(([k]) => symName(k));
27
+ if (new Set(keys).size !== keys.length || keys.some((k) => !k || !allowed.includes(k)))
28
+ return fail("E_DOCUMENT_TEMPLATE", node, "Use the declared template/field options once.");
29
+ return new Map(pairs.map(([k, v]) => [symName(k), v]));
30
+ };
31
+ const options = map(template, [":title", ":fields"]), title = options.get(":title"), fields = options.get(":fields");
32
+ if (title?._tag !== "Str" || !title.value.trim())
33
+ return fail("E_DOCUMENT_TEMPLATE", title ?? template, "Use a fixed nonempty document title.");
34
+ if (fields?._tag !== "Vector" || !fields.items.length)
35
+ return fail("E_DOCUMENT_TEMPLATE", fields ?? template, "Choose a nonempty ordered field vector.");
36
+ const mapped = fields.items.map((node) => {
37
+ const opts = map(node, [":label", ":from"]), label = opts.get(":label"), source = opts.get(":from");
38
+ if (label?._tag !== "Str" || !label.value.trim())
39
+ return fail("E_DOCUMENT_TEMPLATE", label ?? node, "Use a fixed nonempty field label.");
40
+ const parts = items(source), type = symName(parts[0]), field = symName(parts[1]);
41
+ if (source?._tag !== "Vector" || parts.length !== 2 || !type || !field)
42
+ return fail("E_DOCUMENT_SOURCE", source ?? node, "Use [Evidence field] for a document field.");
43
+ return { label: label.value, evidence: type, field, at: cx.at(d, parts[1]) };
44
+ });
45
+ const effective = lowerEffective(cx, d, form);
46
+ if (!effective)
47
+ return fail("E_DOCUMENT_TEMPLATE", form, "Pin an effective date window for the template edition.");
48
+ return {
49
+ name: d.summary.name,
50
+ ...lowerRecordSeal(cx, d),
51
+ ...cx.docOf(cx.payload(d).doc),
52
+ of: of,
53
+ ...(option(form, "resource")
54
+ ? {
55
+ resource: {
56
+ name: symName(option(form, "resource")) ?? "",
57
+ at: cx.at(d, option(form, "resource")),
58
+ },
59
+ }
60
+ : {}),
61
+ sources: sources,
62
+ edition: edition.value,
63
+ title: title.value,
64
+ fields: mapped,
65
+ effective,
66
+ at: cx.at(d, form),
67
+ };
68
+ });
@@ -0,0 +1,5 @@
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
+ export declare const lowerEffective: (context: LoweringContext, declaration: ElaboratedDeclaration, form: SExpr) => IR.Effective | undefined;
@@ -0,0 +1,26 @@
1
+ import { isLocalDate } from "../../../ir-checks/index.js";
2
+ import { LowerError, mapPairs, option, symName } from "./syntax.js";
3
+ export const lowerEffective = (context, declaration, form) => {
4
+ const value = option(form, "effective");
5
+ if (!value)
6
+ return undefined;
7
+ const pairs = mapPairs(value), keys = pairs.map(([k]) => symName(k));
8
+ if (value._tag !== "Map" ||
9
+ !keys.length ||
10
+ keys.length > 2 ||
11
+ new Set(keys).size !== keys.length ||
12
+ keys.some((k) => k !== ":from" && k !== ":until"))
13
+ throw new LowerError("E_EFFECTIVE_SHAPE", "Effective dates require :from and/or :until.", context.at(declaration, value), 'Use :effective {:from "YYYY-MM-DD" :until "YYYY-MM-DD"}; either boundary may be omitted.');
14
+ const date = (syntax) => {
15
+ if (syntax._tag !== "Str" || !isLocalDate(syntax.value))
16
+ throw new LowerError("E_EFFECTIVE_DATE", "Effective boundaries are fixed local-date literals.", context.at(declaration, syntax), 'Use a real "YYYY-MM-DD" date in release metadata; put fact-dependent conditions in :applies-when.');
17
+ return syntax.value;
18
+ };
19
+ const fromSyntax = pairs.find(([k]) => symName(k) === ":from")?.[1];
20
+ const untilSyntax = pairs.find(([k]) => symName(k) === ":until")?.[1];
21
+ const from = fromSyntax ? date(fromSyntax) : undefined, until = untilSyntax ? date(untilSyntax) : undefined;
22
+ if (from && until && from >= until)
23
+ throw new LowerError("E_EFFECTIVE_ORDER", "The exclusive end must follow the start.", context.at(declaration, untilSyntax), "Choose :until after :from; the start is inclusive and the end exclusive.");
24
+ const at = context.at(declaration, value);
25
+ return from ? { from, ...(until ? { until } : {}), at } : { until: until, at };
26
+ };
@@ -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 lowerEntities: (context: LoweringContext) => IR.Entity[];
@@ -0,0 +1,43 @@
1
+ import { lowerFileFields } from "./files.js";
2
+ import { lowerSealedFields } from "./vaults.js";
3
+ import {} from "./context.js";
4
+ import { mapPairs, option, symName } from "./syntax.js";
5
+ export const lowerEntities = (context) => {
6
+ const { byForm, entities, formOf, typeOf, docOf, at } = context;
7
+ return byForm("entity").map((d) => {
8
+ const e = entities.get(d.summary.name);
9
+ const form = formOf(d);
10
+ const attrsOf = (path) => {
11
+ const attrs = [];
12
+ let owner = d.summary.name;
13
+ for (const field of path) {
14
+ const entity = entities.get(owner);
15
+ attrs.push(`${entity.ns}/${field}`);
16
+ const ref = typeOf(entity.fields.find((f) => f.name === field)?.type);
17
+ owner = ref.t === "entity" ? ref.name : owner;
18
+ }
19
+ return attrs;
20
+ };
21
+ return {
22
+ name: d.summary.name,
23
+ ...docOf(e.doc),
24
+ ns: e.ns,
25
+ nsDeclared: e["ns-declared"],
26
+ ...(e.display ? { display: e.display } : {}),
27
+ fields: lowerSealedFields(context, d, lowerFileFields(context, d, e.fields.map((f) => ({ name: f.name, type: f.type, attr: `${e.ns}/${f.name}` })))),
28
+ implements: e.implements.map((b) => {
29
+ const path = b.path.split(".");
30
+ const bindings = mapPairs(option(form, "implements")).find(([k]) => symName(k) === b.role)?.[1];
31
+ const target = mapPairs(bindings).find(([k]) => symName(k) === `:${b.field}`)?.[1];
32
+ return {
33
+ role: b.role,
34
+ field: b.field,
35
+ path,
36
+ attrs: attrsOf(path),
37
+ at: at(d, target ?? form),
38
+ };
39
+ }),
40
+ at: at(d, form),
41
+ };
42
+ });
43
+ };
@@ -0,0 +1,6 @@
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 lowerEscalations: (context: LoweringContext, declaration: ElaboratedDeclaration, form: SExpr, scope: Scope) => IR.Escalation[];
@@ -0,0 +1,31 @@
1
+ import { headOf, items, LowerError, option, symName } from "./syntax.js";
2
+ export const lowerEscalations = (context, declaration, form, scope) => {
3
+ const ladder = option(form, "escalate");
4
+ if (!ladder)
5
+ return [];
6
+ const fail = (syntax) => {
7
+ throw new LowerError("E_ESCALATE_SHAPE", "Invalid escalation ladder.", context.at(declaration, syntax), "Use a literal vector of (after-due (days N) :notify who) or :reassign who steps.");
8
+ };
9
+ if (ladder._tag !== "Vector")
10
+ fail(ladder);
11
+ return items(ladder).map((step) => {
12
+ const parts = items(step), delay = parts[1], kind = symName(parts[2]);
13
+ if (headOf(step) !== "after-due" || parts.length !== 4)
14
+ fail(step);
15
+ if (kind !== ":notify" && kind !== ":reassign")
16
+ fail(parts[2]);
17
+ const count = items(delay)[1];
18
+ const afterDays = count?._tag === "Num" ? Number(count.value) : NaN;
19
+ if (headOf(delay) !== "days" ||
20
+ items(delay).length !== 2 ||
21
+ !Number.isSafeInteger(afterDays) ||
22
+ afterDays < 0)
23
+ throw new LowerError("E_ESCALATE_DELAY", "Escalation offsets are fixed nonnegative day counts.", context.at(declaration, delay), "Use (days N) with a nonnegative safe-integer literal; dynamic offsets and sub-day/year clocks are not supported.");
24
+ return {
25
+ afterDays,
26
+ kind: kind.slice(1),
27
+ who: context.lowerExpr(declaration, parts[3], scope),
28
+ at: context.at(declaration, step),
29
+ };
30
+ });
31
+ };
@@ -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 lowerEvidence: (context: LoweringContext) => IR.Evidence[];
@@ -0,0 +1,75 @@
1
+ import { auditPolicyValid, signatureHelp } from "../../../ir-checks/index.js";
2
+ import { lowerFileFields } from "./files.js";
3
+ import { lowerRecordSeal } from "./vaults.js";
4
+ import {} from "./context.js";
5
+ import { childNamed, headOf, isSym, items, option, symName, mapPairs, LowerError, VALUE, } from "./syntax.js";
6
+ export const lowerEvidence = (context) => {
7
+ const { byForm, payload, formOf, fieldScope, docOf, labelOf, lowerExpr, at } = context;
8
+ return byForm("evidence").map((d) => {
9
+ const p = payload(d);
10
+ const form = formOf(d);
11
+ const scope = fieldScope(p.fields);
12
+ const expires = option(form, "expires");
13
+ const attestForms = items(form).filter((x) => headOf(x) === "attest");
14
+ const raw = attestForms.map((f) => option(f, "audit")).find(Boolean);
15
+ let audit;
16
+ if (raw) {
17
+ const pairs = mapPairs(raw);
18
+ const value = Object.fromEntries(pairs.map(([k, v]) => [symName(k)?.replace(/^:/, ""), v._tag === "Str" ? v.value : null]));
19
+ if (raw._tag !== "Map" ||
20
+ pairs.length !== 2 ||
21
+ pairs.some(([key]) => ![":consent", ":intent"].includes(symName(key) ?? "")) ||
22
+ !auditPolicyValid(value) ||
23
+ attestForms.length !== 1 ||
24
+ p.attest[0]?.covers !== "all" ||
25
+ !p.attest[0]?.method.trim())
26
+ throw new LowerError("E_ATTEST_AUDIT", "An audited attestation needs fixed consent, intent, method and complete coverage.", at(d, raw), signatureHelp);
27
+ audit = value;
28
+ }
29
+ return {
30
+ name: d.summary.name,
31
+ ...lowerRecordSeal(context, d),
32
+ ...(items(form).find((f) => headOf(f) === "amend")
33
+ ? { amend: { at: at(d, items(form).find((f) => headOf(f) === "amend")) } }
34
+ : {}),
35
+ ...docOf(p.doc),
36
+ of: p.of,
37
+ ...labelOf(p.label),
38
+ fields: lowerFileFields(context, d, p.fields),
39
+ // signed-on is the attestation date; a declared field of the same name shadows it.
40
+ ...(expires
41
+ ? { expires: lowerExpr(d, expires, new Map([["signed-on", VALUE], ...scope])) }
42
+ : {}),
43
+ rules: p.rules.map((r) => {
44
+ const rule = childNamed(form, "rule", r.name);
45
+ const requires = option(rule, "requires");
46
+ const oneOf = headOf(requires) === "one-of";
47
+ const when = option(rule, "when");
48
+ return {
49
+ name: r.name,
50
+ ...(when ? { when: lowerExpr(d, when, scope) } : {}),
51
+ requires: {
52
+ mode: oneOf ? "one-of" : "all",
53
+ fields: (oneOf || headOf(requires) === "all-of"
54
+ ? items(requires).slice(1)
55
+ : isSym(requires)
56
+ ? [requires]
57
+ : items(requires)).map((x) => symName(x)),
58
+ },
59
+ at: at(d, rule),
60
+ };
61
+ }),
62
+ ...(p.attest[0]
63
+ ? {
64
+ attest: {
65
+ signer: p.attest[0].signer,
66
+ covers: p.attest[0].covers,
67
+ method: p.attest[0].method,
68
+ ...(audit ? { audit } : {}),
69
+ },
70
+ }
71
+ : {}),
72
+ at: at(d, form),
73
+ };
74
+ });
75
+ };
@@ -0,0 +1,4 @@
1
+ import type { ElaboratedDeclaration } from "@forma-language/forma/descriptor";
2
+ import type * as IR from "../../../world-ir/types.generated.js";
3
+ import { type LoweringContext } from "./context.js";
4
+ export declare const lowerFileFields: <F extends IR.Field>(context: LoweringContext, d: ElaboratedDeclaration, fields: readonly F[]) => F[];
@@ -0,0 +1,56 @@
1
+ import { fileShape, fileMediaType, filePolicyHelp } from "../../../ir-checks/index.js";
2
+ import {} from "./context.js";
3
+ import { items, mapPairs, option, symName, LowerError } from "./syntax.js";
4
+ export const lowerFileFields = (context, d, fields) => {
5
+ const form = context.formOf(d), raw = option(form, "files"), fail = (node, message) => {
6
+ throw new LowerError("E_FILE_POLICY", message, context.at(d, node), filePolicyHelp);
7
+ }, name = (node) => symName(node)?.replace(/^:/, "");
8
+ if (raw && raw._tag !== "Map")
9
+ return fail(raw, "File policies must be a fixed named map.");
10
+ const policies = new Map();
11
+ for (const [key, value] of mapPairs(raw)) {
12
+ const fieldName = name(key), field = fields.find((f) => f.name === fieldName);
13
+ if (!field ||
14
+ !fieldName ||
15
+ policies.has(fieldName) ||
16
+ fileShape(field.type, context.authoredTypes) !== "file")
17
+ return fail(key, "A file policy names one unique File-typed field.");
18
+ if (value._tag !== "Map")
19
+ return fail(value, "A file policy is a fixed :accept/:max-bytes map.");
20
+ const pairs = mapPairs(value), seen = new Set();
21
+ for (const [key] of pairs) {
22
+ const optionName = name(key);
23
+ if (!optionName || !["accept", "max-bytes"].includes(optionName) || seen.has(optionName))
24
+ return fail(key, "File policies allow unique :accept and :max-bytes only.");
25
+ seen.add(optionName);
26
+ }
27
+ const accept = pairs.find(([k]) => name(k) === "accept")?.[1], limit = pairs.find(([k]) => name(k) === "max-bytes")?.[1];
28
+ if (accept?._tag !== "Vector" || !accept.items.length)
29
+ return fail(accept ?? value, "Accepted media types must be a nonempty literal vector.");
30
+ const media = [];
31
+ for (const item of accept.items) {
32
+ if (item._tag !== "Str" || !fileMediaType(item.value))
33
+ return fail(item, "Use a fixed lowercase media type without a wildcard.");
34
+ media.push(item.value);
35
+ }
36
+ if (new Set(media).size !== media.length)
37
+ return fail(accept, "Accepted media types must be unique.");
38
+ if (limit?._tag !== "Num" ||
39
+ !Number.isSafeInteger(Number(limit.value)) ||
40
+ Number(limit.value) <= 0)
41
+ return fail(limit ?? value, "The file byte limit must be a positive fixed safe integer.");
42
+ policies.set(fieldName, {
43
+ accept: [...media].sort(),
44
+ maxBytes: Number(limit.value),
45
+ at: context.at(d, value),
46
+ });
47
+ }
48
+ const fieldMap = items(form).find((node) => node._tag === "Map" &&
49
+ fields.every((f) => mapPairs(node).some(([k, v]) => name(k) === f.name && v._tag !== "Map")));
50
+ return fields.map((field) => {
51
+ const shape = fileShape(field.type, context.authoredTypes), policy = policies.get(field.name), typeNode = mapPairs(fieldMap).find(([k]) => name(k) === field.name)?.[1] ?? form;
52
+ if (shape === "unsupported" || (shape === "file" && !policy))
53
+ return fail(typeNode, "Each single File field needs its own fixed upload policy.");
54
+ return policy ? { ...field, file: policy } : field;
55
+ });
56
+ };
@@ -0,0 +1,6 @@
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 lowerHolds: (context: LoweringContext, declaration: ElaboratedDeclaration, form: SExpr, scope: Scope) => IR.Hold[];
@@ -0,0 +1,35 @@
1
+ import { children, items, LowerError, option, symName } from "./syntax.js";
2
+ export const lowerHolds = (context, declaration, form, scope) => {
3
+ const names = new Set();
4
+ return children(form, "hold").map((hold) => {
5
+ const name = symName(items(hold)[1]);
6
+ if (names.has(name))
7
+ throw new LowerError("E_HOLD_NAME", "Duplicate hold name.", context.at(declaration, items(hold)[1]), "Use a unique name for each hold in this component.");
8
+ names.add(name);
9
+ const policy = option(hold, "pauses");
10
+ const help = "Use a literal nonempty vector of :dispatch, :remind and/or :escalate.";
11
+ const fail = (syntax) => {
12
+ throw new LowerError("E_HOLD_PAUSES", "Invalid hold pause policy.", context.at(declaration, syntax), help);
13
+ };
14
+ if (policy._tag !== "Vector" || !policy.items.length)
15
+ fail(policy);
16
+ const pauses = items(policy).map((syntax) => {
17
+ const value = symName(syntax);
18
+ if (value === ":due")
19
+ throw new LowerError("E_HOLD_PAUSES_DUE", "A hold cannot suspend a due-date clock.", context.at(declaration, syntax), "Cite the source permitting an extension in a :defer decision with an explicit :until date; holds never change due dates.");
20
+ if (value === ":dispatch" || value === ":remind" || value === ":escalate")
21
+ return value.slice(1);
22
+ return fail(syntax);
23
+ });
24
+ const label = option(hold, "label");
25
+ const unique = [...new Set(pauses)];
26
+ return {
27
+ name,
28
+ ...(label?._tag === "Str" ? { label: label.value } : {}),
29
+ while: context.lowerExpr(declaration, option(hold, "while"), scope),
30
+ pauses: [unique[0], ...unique.slice(1)],
31
+ ...context.citations(declaration, hold),
32
+ at: context.at(declaration, hold),
33
+ };
34
+ });
35
+ };
@@ -0,0 +1,89 @@
1
+ import { type ElaboratedDeclaration } from "@forma-language/forma/descriptor";
2
+ import type { SourceFile } from "../compile.js";
3
+ import type * as IR from "../../../world-ir/types.generated.js";
4
+ export declare const lower: (files: readonly SourceFile[], declarations: readonly ElaboratedDeclaration[]) => {
5
+ entities: IR.Entity[];
6
+ accounts: IR.Account[];
7
+ types: IR.TypeAlias[];
8
+ roles: IR.Role[];
9
+ calendars: IR.Calendar[];
10
+ derives: IR.Derive[];
11
+ evidence: IR.Evidence[];
12
+ interactions: IR.Interaction[];
13
+ layouts: IR.Layout[];
14
+ connectors: IR.Connector[];
15
+ machines: IR.Machine[];
16
+ components: {
17
+ requirements: IR.Requirement[];
18
+ actions: IR.Action[];
19
+ library?: string;
20
+ operations?: ReadonlyArray<string>;
21
+ milestones?: ReadonlyArray<IR.Milestone>;
22
+ holds?: ReadonlyArray<IR.Hold>;
23
+ resources?: readonly [IR.Resource, ...IR.Resource[]];
24
+ name: string;
25
+ doc?: string;
26
+ key: ReadonlyArray<string>;
27
+ home: IR.Home;
28
+ inputs: ReadonlyArray<IR.Field>;
29
+ params: ReadonlyArray<IR.Field>;
30
+ paramBounds?: readonly [IR.ParamBound, ...IR.ParamBound[]];
31
+ cycle?: IR.Expr;
32
+ slots: ReadonlyArray<IR.Slot>;
33
+ outputs: ReadonlyArray<IR.Output>;
34
+ machines: ReadonlyArray<{
35
+ readonly name: string;
36
+ readonly protocol: string;
37
+ readonly at: IR.Span;
38
+ }>;
39
+ invariants: ReadonlyArray<{
40
+ readonly name: string;
41
+ readonly cites?: ReadonlyArray<IR.Citation>;
42
+ readonly forbids: {
43
+ readonly action: string;
44
+ readonly subject: IR.Expr;
45
+ };
46
+ readonly while: IR.Expr;
47
+ readonly at: IR.Span;
48
+ }>;
49
+ retention?: {
50
+ readonly until: IR.Expr;
51
+ readonly disposal: string;
52
+ readonly cites?: ReadonlyArray<IR.Citation>;
53
+ readonly at: IR.Span;
54
+ };
55
+ at: IR.Span;
56
+ }[];
57
+ bundles?: IR.Bundle[];
58
+ collects?: IR.Collect[];
59
+ decisions?: {
60
+ byKind: "group" | "individual";
61
+ name: string;
62
+ doc?: string;
63
+ of: string;
64
+ by: IR.Expr;
65
+ applies: string;
66
+ when?: IR.Expr;
67
+ effect: "approve" | "reject" | "waive" | "defer" | "accept" | "add";
68
+ reason: IR.TypeRef;
69
+ until?: IR.Expr;
70
+ expires?: IR.Expr;
71
+ approvals?: IR.Expr;
72
+ distinctFrom?: ReadonlyArray<IR.Expr>;
73
+ cites?: ReadonlyArray<IR.Citation>;
74
+ at: IR.Span;
75
+ }[];
76
+ references?: IR.Source[];
77
+ notices?: IR.Notice[];
78
+ documents?: IR.Document[];
79
+ componentImports?: readonly [IR.ComponentImport, ...IR.ComponentImport[]];
80
+ componentContracts?: readonly [IR.ComponentContract, ...IR.ComponentContract[]];
81
+ vaults?: [IR.Vault, ...IR.Vault[]];
82
+ agents?: [IR.Agent, ...IR.Agent[]];
83
+ format: "worldvm/world-ir@1";
84
+ sources: {
85
+ id: string;
86
+ sha256: string;
87
+ }[];
88
+ libraries: IR.Library[];
89
+ };
@@ -0,0 +1,115 @@
1
+ import { lowerAgents } from "./agents.js";
2
+ import { lowerNotices } from "./notices.js";
3
+ import { lowerVaults } from "./vaults.js";
4
+ import { lowerDocuments } from "./documents.js";
5
+ import { lowerContracts } from "./contracts.js";
6
+ import { lowerBundles } from "./bundles.js";
7
+ import { reuseProblem } from "../../../ir-checks/index.js";
8
+ import { LowerError } from "./syntax.js";
9
+ import { lowerCollects } from "./collects.js";
10
+ import {} from "@forma-language/forma/descriptor";
11
+ import { sha256 } from "../digest.js";
12
+ import { lowerAccounts } from "./accounts.js";
13
+ import { lowerComponents } from "./components.js";
14
+ import { lowerConnectors, lowerMachines } from "./connectors.js";
15
+ import { createLoweringContext } from "./context.js";
16
+ import { lowerDecisions } from "./decisions.js";
17
+ import { lowerDerives } from "./derives.js";
18
+ import { lowerEntities } from "./entities.js";
19
+ import { lowerEvidence } from "./evidence.js";
20
+ import { lowerInteractions, lowerLayouts } from "./interactions.js";
21
+ import { lowerCalendars, lowerLibraries, lowerRoles } from "./library.js";
22
+ import { lowerPrincipals } from "./principals.js";
23
+ export const lower = (files, declarations) => {
24
+ const context = createLoweringContext(files, declarations);
25
+ const { references, authoredTypes } = context;
26
+ const roleIR = lowerRoles(context);
27
+ const entityIR = lowerEntities(context);
28
+ const calendarIR = lowerCalendars(context);
29
+ const deriveIR = lowerDerives(context);
30
+ const evidenceIR = lowerEvidence(context);
31
+ const documentIR = lowerDocuments(context, evidenceIR);
32
+ const noticeIR = lowerNotices(context, documentIR);
33
+ const evidenceByName = new Map(evidenceIR.map((e) => [e.name, e]));
34
+ const interactionIR = lowerInteractions(context, evidenceByName);
35
+ const layoutIR = lowerLayouts(context, interactionIR, evidenceByName);
36
+ const collectIR = lowerCollects(context, layoutIR);
37
+ const bundleIR = lowerBundles(context);
38
+ const connectorIR = lowerConnectors(context);
39
+ const machineIR = lowerMachines(context);
40
+ const rawComponents = lowerComponents(context);
41
+ const rawDecisions = lowerDecisions(context, rawComponents);
42
+ const { components: componentIR, decisions: decisionIR } = lowerPrincipals({
43
+ types: authoredTypes,
44
+ roles: roleIR,
45
+ entities: entityIR,
46
+ derives: deriveIR,
47
+ components: rawComponents,
48
+ decisions: rawDecisions,
49
+ }, rawComponents, rawDecisions);
50
+ const vaults = lowerVaults(context, {
51
+ types: authoredTypes,
52
+ roles: roleIR,
53
+ entities: entityIR,
54
+ components: componentIR,
55
+ derives: deriveIR,
56
+ });
57
+ const contractIR = lowerContracts(context, {
58
+ ...(vaults.length ? { vaults: vaults } : {}),
59
+ types: authoredTypes,
60
+ roles: roleIR,
61
+ components: componentIR,
62
+ evidence: evidenceIR,
63
+ interactions: interactionIR,
64
+ decisions: decisionIR,
65
+ connectors: connectorIR,
66
+ });
67
+ const agents = lowerAgents(context, componentIR);
68
+ const libraryContent = {
69
+ ...(agents.length ? { agents: agents } : {}),
70
+ ...(vaults.length ? { vaults: vaults } : {}),
71
+ ...contractIR,
72
+ ...(documentIR.length ? { documents: documentIR } : {}),
73
+ ...(noticeIR.length ? { notices: noticeIR } : {}),
74
+ ...(references.length ? { references } : {}),
75
+ ...(decisionIR.length ? { decisions: decisionIR } : {}),
76
+ ...(collectIR.length ? { collects: collectIR } : {}),
77
+ ...(bundleIR.length ? { bundles: bundleIR } : {}),
78
+ types: authoredTypes,
79
+ roles: roleIR,
80
+ calendars: calendarIR,
81
+ derives: deriveIR,
82
+ evidence: evidenceIR,
83
+ interactions: interactionIR,
84
+ layouts: layoutIR,
85
+ connectors: connectorIR,
86
+ machines: machineIR,
87
+ components: componentIR,
88
+ };
89
+ const reuseError = reuseProblem({
90
+ ...libraryContent,
91
+ format: "worldvm/world-ir@1",
92
+ sources: [],
93
+ libraries: [],
94
+ entities: entityIR,
95
+ accounts: [],
96
+ });
97
+ if (reuseError)
98
+ throw new LowerError(reuseError.code, reuseError.message, reuseError.at, reuseError.help);
99
+ const libraryIR = lowerLibraries(context, libraryContent);
100
+ const accountIR = lowerAccounts(context, entityIR, componentIR, {
101
+ types: authoredTypes,
102
+ roles: roleIR,
103
+ entities: entityIR,
104
+ components: componentIR,
105
+ derives: deriveIR,
106
+ });
107
+ return {
108
+ format: "worldvm/world-ir@1",
109
+ sources: files.map((f) => ({ id: f.id, sha256: sha256(f.text) })),
110
+ libraries: libraryIR,
111
+ ...libraryContent,
112
+ entities: entityIR,
113
+ accounts: accountIR,
114
+ };
115
+ };
@@ -0,0 +1,7 @@
1
+ import type * as IR from "../../../world-ir/types.generated.js";
2
+ import type { SourceFile } from "../compile.js";
3
+ import { type LoweringContext } from "./context.js";
4
+ /** Report the actual item before native child validation widens its span to the layout. */
5
+ export declare const layoutSourceDiagnostics: (files: readonly SourceFile[]) => IR.Diagnostic[];
6
+ export declare const lowerInteractions: (context: LoweringContext, evidenceByName: ReadonlyMap<string, IR.Evidence>) => IR.Interaction[];
7
+ export declare const lowerLayouts: (context: LoweringContext, interactionIR: readonly IR.Interaction[], evidenceByName: ReadonlyMap<string, IR.Evidence>) => IR.Layout[];