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
package/README.md CHANGED
@@ -1,3 +1,155 @@
1
- # Temporary Holding Version
1
+ # WorldVM
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ WorldVM is a requirement runtime. You declare what must be true in a _world_ (a directory of
4
+ `.forma` files: requirements, evidence, deadlines and who may act), and WorldVM computes, for
5
+ every subject, what is satisfied, what is missing, who must act next, and why.
6
+
7
+ ## Status
8
+
9
+ `worldvm` 0.1.0 is a **preview**. Read this before depending on it.
10
+
11
+ - **The package is published for evaluation, all rights reserved, with no licence granted yet.**
12
+ - **Breaking changes are expected** in every 0.x release: the world language, the protocol
13
+ and the storage format.
14
+ - **SQLite only, one process per database file.** Stop `serve` before you `deploy` to the
15
+ same file. Multi-process storage and Postgres are not available.
16
+ - **`serve` has no authentication.** The `x-worldvm-actor` header is a trusted, development-only
17
+ identity. Put your own authentication in front of it, or embed WorldVM instead.
18
+ - **`/v1/changes` is live only.** There is no replay cursor; after a disconnect, read the
19
+ current status and work again.
20
+ - Node prints an `ExperimentalWarning` for `node:sqlite` when you embed the SQLite store.
21
+ - Example worlds and data are synthetic, and their rules are illustrative, not legal or
22
+ compliance advice.
23
+
24
+ ## Install
25
+
26
+ Requires Node 22.5 or later. Effect and Forma are peer dependencies:
27
+
28
+ ```sh
29
+ npm install worldvm effect@^4.1.1 @forma-language/forma@^0.6.0
30
+ ```
31
+
32
+ ## A first world
33
+
34
+ Run these in an empty project after installing:
35
+
36
+ ```sh
37
+ npx worldvm init my-world # writes a minimal passing world and REFERENCE.md
38
+ npx worldvm check my-world # compile, link accounts, report diagnostics
39
+ npx worldvm test my-world # run scenarios and seeded properties
40
+ npx worldvm coverage my-world # which requirements and cited clauses the tests reach
41
+ ```
42
+
43
+ `check` prints `check: passed; 3 source files, 1 requirements`, and `test` passes one scenario
44
+ and one property. Edit `my-world/library/starter.forma`, add scenarios under
45
+ `my-world/scenarios/`, and rerun the loop.
46
+
47
+ Serve it over HTTP on a SQLite file:
48
+
49
+ ```sh
50
+ npx worldvm serve my-world --db my-world.db --port 3000 --clock 2026-03-01
51
+ ```
52
+
53
+ In another terminal:
54
+
55
+ ```sh
56
+ curl http://127.0.0.1:3000/v1/assert -H 'content-type: application/json' \
57
+ -H 'x-worldvm-actor: {"id":"system:hr","kind":"service"}' \
58
+ -d '{"type":"Person","subject":"olu","id":"hr-1","values":{"name":"Olu"}}'
59
+ curl http://127.0.0.1:3000/v1/assert -H 'content-type: application/json' \
60
+ -H 'x-worldvm-actor: {"id":"system:hr","kind":"service"}' \
61
+ -d '{"type":"Subject","subject":"s1","id":"hr-2","values":{"name":"Synthetic subject","owner":"olu","opened":"2026-01-01"}}'
62
+ curl http://127.0.0.1:3000/v1/work -H 'content-type: application/json' \
63
+ -H 'x-worldvm-actor: {"id":"olu","kind":"human"}' \
64
+ -d '{"type":"Subject","subject":"s1"}'
65
+ ```
66
+
67
+ The last call lists one eligible action, `acknowledge`, assigned to `olu`.
68
+
69
+ ## Run a world inside your application
70
+
71
+ The same world, embedded with a SQLite store. Save this as `embed.mjs` next to `my-world`
72
+ and run `node embed.mjs`:
73
+
74
+ ```js
75
+ import { open } from "worldvm";
76
+ import { sqlite } from "worldvm/sqlite";
77
+
78
+ const world = await open({
79
+ source: "./my-world",
80
+ store: sqlite("embedded.db"),
81
+ clock: () => "2026-03-01", // a fixed clock for the example; omit it to use the real clock
82
+ });
83
+ try {
84
+ await world.subject("Person", "olu").assert({ name: "Olu" }, { by: "system:hr" });
85
+ const subject = world.subject("Subject", "s1");
86
+ await subject.assert(
87
+ { name: "Synthetic subject", owner: "olu", opened: "2026-01-01" },
88
+ { by: "system:hr" },
89
+ );
90
+ console.log(subject.work()); // one eligible action: acknowledge, assigned to olu
91
+ const result = await subject.perform("acknowledge", {
92
+ by: "olu",
93
+ values: { summary: "Read and agreed" },
94
+ });
95
+ if (!result.accepted) throw new Error(result.codes.join(", "));
96
+ console.log(subject.status().instances[0].requirements); // acknowledged: Satisfied
97
+ console.log(JSON.stringify(subject.explain("acknowledged"), null, 2)); // cites starter-policy
98
+ console.log(subject.status("2027-03-02").instances[0].requirements); // a year later: Open
99
+ } finally {
100
+ await world.close();
101
+ }
102
+ ```
103
+
104
+ ## Documentation
105
+
106
+ These files ship in the package, so they match the version you installed:
107
+
108
+ - `node_modules/worldvm/docs/reference.md`: the core language on one page. `worldvm init`
109
+ also writes it into each new world as `REFERENCE.md`.
110
+ - `node_modules/worldvm/AUTHORING.md`: the full authoring guide, including every form, Truth
111
+ and comparisons, scenarios, properties and the diagnostics catalogue.
112
+ - `node_modules/worldvm/docs/protocol.md`: the operating protocol (library, HTTP and MCP).
113
+ - `node_modules/worldvm/docs/authoring/vendor-risk/`: a complete synthetic example world.
114
+
115
+ `worldvm explain <code>` prints the cause, an example and the fix for any diagnostic code;
116
+ `worldvm explain --list` lists them.
117
+
118
+ ## Commands
119
+
120
+ Every command has its own `--help`. JSON mode (`--json`) writes one versioned result to
121
+ stdout; human diagnostics go to stderr. Exit 0 means success, 1 a failed check or test, and 2
122
+ invalid usage.
123
+
124
+ | Command | What it does |
125
+ | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
126
+ | `init <dir>` | Scaffold a minimal passing world |
127
+ | `check <dir> [--core]` | Compile, link accounts and lint; diagnostics carry locations, help and fixes |
128
+ | `test <dir> [--scenario name] [--seed n] [--cases n]` | Run scenarios and seeded properties; failures include a shrunk counterexample |
129
+ | `coverage <dir> [--mutate]` | Measure which requirements and cited clauses tests reach; `--mutate` reports surviving mutants |
130
+ | `render <dir> [--format markdown\|html] [--account name]` | Write the human-readable manual, with citations and examples |
131
+ | `explain <dir> --scenario name [--at instant]` | Explain each status, due date and work item at a scenario instant |
132
+ | `explain <dir> --world snapshot.json --subject id --at t` | Explain a live subject from a snapshot |
133
+ | `diff <old> <new>` | Semantic diff of two releases; formatting and moves are not changes |
134
+ | `impact <old> <new> --world snapshot.json --at t` | Preview a release over a recorded population |
135
+ | `deploy <dir> --db file.db --account id [--dry-run]` | Check a world, preview its impact and record it as the active release |
136
+ | `serve [dir] --db file.db [--port n] [--clock t] [--ui]` | Serve the deployed release over HTTP; with a directory, deploy then serve |
137
+ | `snapshot --db file.db --account id [--out file]` | Export committed state as a `worldvm/world@1` snapshot |
138
+ | `fmt [--check] <dir\|files>` | Format `.forma` files |
139
+ | `lsp` | Language Server Protocol on stdio |
140
+ | `mcp [--world dir] [--db file.db --actor json]` | Model Context Protocol server on stdio |
141
+ | `codegen <dir> [--out file]` | Emit TypeScript entity, evidence and operation types |
142
+
143
+ ## Exports
144
+
145
+ | Import | Contents |
146
+ | ------------------------ | ----------------------------------------------------------------------- |
147
+ | `worldvm` | `open()`, `memory()`, `operate()` and the subject handle API |
148
+ | `worldvm/sqlite` | `sqlite(file)`, the single-file store |
149
+ | `worldvm/http` | `createHandler(world)`, a `(Request) => Promise<Response>` HTTP handler |
150
+ | `worldvm/serve` | `serve()`, the Node HTTP server behind `worldvm serve` |
151
+ | `worldvm/cli` | Node-only command APIs and result types |
152
+ | `worldvm/authoring` | Filesystem-free projections and manual renderers |
153
+ | `worldvm/diagnostics` | The diagnostics catalogue |
154
+ | `worldvm/durable-object` | `durableObject(storage)`, a Cloudflare Durable Object SQLite store |
155
+ | `worldvm/ir-schema.json` | JSON Schema for compiled world IR |
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ import { main } from "../dist/cli.js";
3
+ process.exitCode = await main();
@@ -0,0 +1 @@
1
+ export * from "./world/index.js";
@@ -0,0 +1 @@
1
+ export * from "./world/index.js";
@@ -0,0 +1,25 @@
1
+ import type * as IR from "../../world-ir/types.generated.js";
2
+ export declare const CORE_FORMS: Set<string>;
3
+ export type FormMetadata = {
4
+ readonly name: string;
5
+ readonly tier: "core" | "extended";
6
+ };
7
+ export declare const formMetadata: (name: string) => FormMetadata;
8
+ /** Top-level forms an author may write in a .forma file, sorted. */
9
+ export declare const TOP_LEVEL_FORMS: string[] & {
10
+ metadata: FormMetadata[];
11
+ };
12
+ /** Child forms by parent form, e.g. component → requirement, action, output. */
13
+ export declare const CHILD_FORMS: ReadonlyMap<string, readonly string[]> & {
14
+ metadata: Map<string, FormMetadata[]>;
15
+ };
16
+ /** The single closest form name within two edits, if any. */
17
+ export declare const suggestForm: (name: string, candidates?: readonly string[]) => string | undefined;
18
+ export declare const TRUTH_HELP = "Conditions use three-valued Truth (true, false or Unknown). Use and, or, not, = and != in requirements and properties. A Bool field is already a condition: write record.flag or (not record.flag). Collapse Truth with true?, false? or unknown? when a Bool is needed.";
19
+ /** Help for a diagnostic whose code alone says too little; undefined keeps the existing help. */
20
+ export declare const authoringHelp: (d: {
21
+ readonly code: string;
22
+ readonly message: string;
23
+ }) => string | undefined;
24
+ /** `attested` ignores :expires; an expiring record almost always wants `valid`. */
25
+ export declare const attestedExpiryDiagnostics: (ir: IR.WorldIR) => IR.Diagnostic[];
@@ -0,0 +1,130 @@
1
+ import { worldPrelude } from "./prelude.generated.js";
2
+ // Authoring help for diagnostics Forma's elaborator reports without WorldVM context. Form names
3
+ // come from the prelude itself so the lists cannot drift from what actually elaborates.
4
+ const declared = [...worldPrelude.matchAll(/\(form\s*\(\s*([a-z][\w?/-]*)/g)].map((m) => m[1]);
5
+ export const CORE_FORMS = new Set([
6
+ "source",
7
+ "entity",
8
+ "evidence",
9
+ "component",
10
+ "requirement",
11
+ "action",
12
+ "output",
13
+ "decision",
14
+ "scenario",
15
+ "property",
16
+ ]);
17
+ export const formMetadata = (name) => ({
18
+ name,
19
+ tier: CORE_FORMS.has(name) ? "core" : "extended",
20
+ });
21
+ /** Top-level forms an author may write in a .forma file, sorted. */
22
+ export const TOP_LEVEL_FORMS = Object.assign([...new Set([...declared.filter((n) => !n.includes("/")), "type"])].sort(), {
23
+ metadata: declared
24
+ .filter((n) => !n.includes("/"))
25
+ .concat("type")
26
+ .sort()
27
+ .map(formMetadata),
28
+ });
29
+ const children = new Map();
30
+ for (const name of declared) {
31
+ const [group, child] = name.split("/");
32
+ if (!child || !group?.endsWith("-child"))
33
+ continue;
34
+ const parent = group.slice(0, -"-child".length);
35
+ children.set(parent, [...(children.get(parent) ?? []), child].sort());
36
+ }
37
+ /** Child forms by parent form, e.g. component → requirement, action, output. */
38
+ export const CHILD_FORMS = Object.assign(children, {
39
+ metadata: new Map([...children].map(([parent, names]) => [parent, names.map(formMetadata)])),
40
+ });
41
+ const distance = (a, b) => {
42
+ const row = Array.from({ length: b.length + 1 }, (_, i) => i);
43
+ for (let i = 1; i <= a.length; i++) {
44
+ let previous = row[0];
45
+ row[0] = i;
46
+ for (let j = 1; j <= b.length; j++) {
47
+ const current = row[j];
48
+ row[j] = Math.min(row[j] + 1, row[j - 1] + 1, previous + (a[i - 1] === b[j - 1] ? 0 : 1));
49
+ previous = current;
50
+ }
51
+ }
52
+ return row[b.length];
53
+ };
54
+ /** The single closest form name within two edits, if any. */
55
+ export const suggestForm = (name, candidates = TOP_LEVEL_FORMS) => {
56
+ const ranked = candidates
57
+ .map((c) => [c, distance(name, c)])
58
+ .filter(([, d]) => d <= 2)
59
+ .sort((a, b) => a[1] - b[1]);
60
+ return ranked.length && (ranked.length === 1 || ranked[0][1] < ranked[1][1])
61
+ ? ranked[0][0]
62
+ : undefined;
63
+ };
64
+ const parentsOf = (child) => [...CHILD_FORMS].filter(([, names]) => names.includes(child)).map(([parent]) => parent);
65
+ export const TRUTH_HELP = "Conditions use three-valued Truth (true, false or Unknown). Use and, or, not, = and != in requirements and properties. A Bool field is already a condition: write record.flag or (not record.flag). Collapse Truth with true?, false? or unknown? when a Bool is needed.";
66
+ /** Help for a diagnostic whose code alone says too little; undefined keeps the existing help. */
67
+ export const authoringHelp = (d) => {
68
+ if (d.code === "E_ELABORATE_MALFORMED_FORM" &&
69
+ d.message.includes("Missing required option :signal"))
70
+ return "Give the machine :signal a signal name. Declare that name in a (connector … :capabilities [] :signals [signal-name] :owns [MachineName]); the connector must own the machine even when it only receives signals.";
71
+ if (d.code === "E_ELABORATE_UNKNOWN_FORM") {
72
+ const name = /Unknown form '([^']+)'/.exec(d.message)?.[1] ?? "";
73
+ const parents = parentsOf(name);
74
+ const forms = `Top-level forms: ${TOP_LEVEL_FORMS.join(", ")}.`;
75
+ if (parents.length)
76
+ return `${name} is only valid inside ${parents.map((p) => `(${p} …)`).join(" or ")}. ${forms}`;
77
+ const suggestion = suggestForm(name);
78
+ return `${suggestion ? `Did you mean ${suggestion}? ` : ""}${forms} See AUTHORING.md, Forms reference.`;
79
+ }
80
+ if (d.code === "E_ELABORATE_VALIDATION_FAILED") {
81
+ const parent = /Expected child form ([a-z][\w-]*)-child/.exec(d.message)?.[1];
82
+ const names = parent ? CHILD_FORMS.get(parent) : undefined;
83
+ if (names)
84
+ return `Inside (${parent} …) each child form is one of: ${names.join(", ")}. Check the spelling of the child form's head.`;
85
+ }
86
+ if (d.code === "E_ELABORATE_HOLE_TYPE") {
87
+ if (d.message.startsWith("Unknown reference "))
88
+ return "Declare the referenced name with the required form. For a component's (machine local Protocol), declare (machine Protocol … :signal signal-name …). Declare signal-name in a (connector … :capabilities [] :signals [signal-name] :owns [Protocol]); signal-only connectors still declare ownership.";
89
+ if (/\bTruth\b/.test(d.message) && /\bBool\b/.test(d.message))
90
+ return TRUTH_HELP;
91
+ const unknown = /Unknown type (\S+)/.exec(d.message)?.[1];
92
+ if (unknown)
93
+ return `Declare ${unknown} with (type ${unknown} …), (role …) or (entity …) before using it, or use a built-in type: String, Int, Float, Bool, Date, Instant, Keyword, Group, (Id Role-or-Entity), (Option T), (Union :a :b). See AUTHORING.md, Forms reference.`;
94
+ return "This expression's type does not fit the field it is written in. Requirement conditions are Truth, :due is a Date or Instant, durations are (days n), (months n) or (years n). See AUTHORING.md.";
95
+ }
96
+ if (d.code === "W_NO_PRODUCER")
97
+ return "Nothing assigns work for this requirement, so when it is open no one is asked to act. Add (action <name> :advances <requirement> :assignee <who> :via (interaction <Interaction>)) to give it a producer. If the requirement only detects a condition (for example an active record whose review lapsed), keep it in an output and accept this warning.";
98
+ return undefined;
99
+ };
100
+ const ref = (e) => e && typeof e === "object" && e.k === "ref"
101
+ ? e.name
102
+ : undefined;
103
+ /** `attested` ignores :expires; an expiring record almost always wants `valid`. */
104
+ export const attestedExpiryDiagnostics = (ir) => {
105
+ const expiring = new Set(ir.evidence.filter((e) => e.expires).map((e) => e.name));
106
+ const diagnostics = [];
107
+ const walk = (value) => {
108
+ if (Array.isArray(value))
109
+ return value.forEach(walk);
110
+ if (!value || typeof value !== "object")
111
+ return;
112
+ const node = value;
113
+ const evidence = node.k === "call" && node.fn === "attested"
114
+ ? ref(node.args && node.args[0])
115
+ : undefined;
116
+ if (typeof evidence === "string" && expiring.has(evidence))
117
+ diagnostics.push({
118
+ code: "W_ATTESTED_EXPIRING",
119
+ severity: "warning",
120
+ message: `(attested ${evidence}) stays true after ${evidence} expires; ${evidence} declares :expires.`,
121
+ help: `attested means "was ever signed" and ignores :expires. Use (valid ${evidence}) to require an unexpired record; keep attested only if history is what you mean.`,
122
+ ...(node.at ? { at: node.at } : {}),
123
+ });
124
+ for (const [key, child] of Object.entries(node))
125
+ if (key !== "at")
126
+ walk(child);
127
+ };
128
+ walk(ir.components);
129
+ return diagnostics;
130
+ };
@@ -0,0 +1,3 @@
1
+ import type * as IR from "../../world-ir/types.generated.js";
2
+ /** Citation absence is visible without certifying an author's interpretation of the source. */
3
+ export declare const citationDiagnostics: (ir: IR.WorldIR) => readonly IR.Diagnostic[];
@@ -0,0 +1,26 @@
1
+ /** Citation absence is visible without certifying an author's interpretation of the source. */
2
+ export const citationDiagnostics = (ir) => {
3
+ const diagnostics = [];
4
+ const check = (name, node) => {
5
+ if (node.cites?.length)
6
+ return;
7
+ diagnostics.push({
8
+ code: "W_UNCITED",
9
+ severity: "warning",
10
+ message: `Missing citation for ${name}.`,
11
+ at: node.at,
12
+ help: 'Declare the authority with (source name ...), then add :cites [(name "specific clause")] to this clause. Reference worlds are illustrative, not legal or audit advice.',
13
+ });
14
+ };
15
+ for (const component of ir.components) {
16
+ for (const requirement of component.requirements)
17
+ check(`${component.name}/${requirement.name}`, requirement);
18
+ for (const invariant of component.invariants)
19
+ check(`${component.name}/${invariant.name}`, invariant);
20
+ if (component.retention)
21
+ check(`${component.name}/retention`, component.retention);
22
+ }
23
+ for (const decision of ir.decisions ?? [])
24
+ check(decision.name, decision);
25
+ return diagnostics;
26
+ };
@@ -0,0 +1,4 @@
1
+ import type * as IR from "../../world-ir/types.generated.js";
2
+ import type { SourceFile } from "./compile.js";
3
+ /** Keep binder tokens in source diagnostics; the canonical field IR omits their spans. */
4
+ export declare const clockBindingDiagnostics: (files: readonly SourceFile[]) => IR.Diagnostic[];
@@ -0,0 +1,45 @@
1
+ import { sourceSyntax } from "./source-syntax.js";
2
+ import {} from "@forma-language/forma/reader";
3
+ import { headOf, items, mapPairs, option, spanOf, symName } from "./lowering/syntax.js";
4
+ /** Keep binder tokens in source diagnostics; the canonical field IR omits their spans. */
5
+ export const clockBindingDiagnostics = (files) => {
6
+ const out = [];
7
+ for (const file of files) {
8
+ const parsed = sourceSyntax(file);
9
+ if (parsed.errors.length)
10
+ continue;
11
+ const binding = (node) => {
12
+ if (!["today", "now"].includes(symName(node)?.replace(/^:/, "") ?? ""))
13
+ return;
14
+ out.push({
15
+ code: "E_CLOCK_BINDING",
16
+ severity: "error",
17
+ message: "Clock names cannot be shadowed by runtime bindings.",
18
+ help: "Rename the binding; today and now are reserved clock expressions. Access role/entity fields through their paths.",
19
+ at: spanOf(file.id, node),
20
+ });
21
+ };
22
+ const walk = (node) => {
23
+ const head = headOf(node);
24
+ if (head === "type" || head === "quote")
25
+ return;
26
+ if (["component", "derive", "account"].includes(head ?? ""))
27
+ for (const key of ["inputs", "params"])
28
+ for (const [name] of mapPairs(option(node, key)))
29
+ binding(name);
30
+ if (head === "evidence")
31
+ for (const [name] of mapPairs(items(node).find((n) => n._tag === "Map")))
32
+ binding(name);
33
+ if (head === "fn")
34
+ for (const param of items(items(node)[1]))
35
+ binding(param);
36
+ if (node._tag === "List" || node._tag === "Vector" || node._tag === "Set")
37
+ node.items.forEach(walk);
38
+ if (node._tag === "Map")
39
+ for (const [, value] of node.pairs)
40
+ walk(value);
41
+ };
42
+ parsed.forms.forEach(walk);
43
+ }
44
+ return out;
45
+ };
@@ -0,0 +1,13 @@
1
+ import { type SurfaceDiagnostic } from "./surface.js";
2
+ import type * as IR from "../../world-ir/types.generated.js";
3
+ export interface SourceFile {
4
+ readonly id: string;
5
+ readonly text: string;
6
+ }
7
+ export interface CompileResult {
8
+ readonly ok: boolean;
9
+ readonly ir: IR.WorldIR | null;
10
+ readonly diagnostics: readonly SurfaceDiagnostic[];
11
+ }
12
+ export declare const compileWorld: (files: readonly SourceFile[]) => CompileResult;
13
+ export { KERNEL_FUNCTIONS, type ListNode } from "./lowering/syntax.js";
@@ -0,0 +1,190 @@
1
+ import { diagnosticCode, elaborationSource, operatorDiagnostics, } from "./surface.js";
2
+ import { agentSourceDiagnostics } from "./lowering/agents.js";
3
+ import { agentReadDiagnostics } from "../../ir-checks/index.js";
4
+ import { sensitivitySourceDiagnostics } from "./sensitivity.js";
5
+ import { vaultSourceDiagnostics } from "./lowering/vaults.js";
6
+ import { vaultDiagnostics } from "../../ir-checks/index.js";
7
+ import { sensitivityDiagnostics } from "../../ir-checks/index.js";
8
+ import { resourceProofDiagnostics } from "../../ir-checks/index.js";
9
+ import { amendmentDiagnostics } from "../../ir-checks/index.js";
10
+ import { resourceDiagnostics } from "../../ir-checks/index.js";
11
+ import { signatureDiagnostics } from "../../ir-checks/index.js";
12
+ import { noticeDiagnostics } from "../../ir-checks/index.js";
13
+ import { documentDiagnostics } from "../../ir-checks/index.js";
14
+ import { fileFieldDiagnostics } from "../../ir-checks/index.js";
15
+ import { statusHandlingDiagnostics } from "./status-handling.js";
16
+ import { childParameterDiagnostics } from "../../ir-checks/index.js";
17
+ import { componentContractDiagnostics } from "../../ir-checks/index.js";
18
+ import { clockBindingDiagnostics } from "./clock-bindings.js";
19
+ import { layoutSourceDiagnostics } from "./lowering/interactions.js";
20
+ // Forma elaborates against the byte-stable virtual world.lisp prelude. Construct-family
21
+ // lowering modules preserve reader spans and emit canonical JSON; this boundary orders
22
+ // compilation and publish diagnostics for both Node and browser callers.
23
+ import { bootstrapFromSources, elaborateSources, } from "@forma-language/forma/descriptor";
24
+ import { preludeSource } from "@forma-language/forma/preludes";
25
+ import { evidenceScopeDiagnostics, finiteTimeDiagnostics, instantLiteralDiagnostics, } from "../../ir-checks/index.js";
26
+ import { attestedExpiryDiagnostics, authoringHelp } from "./authoring-help.js";
27
+ import { citationDiagnostics } from "./citations.js";
28
+ import { requirementDiagnostics } from "./coverage.js";
29
+ import { documentationDiagnostics } from "./documentation.js";
30
+ import { homeDiagnostics } from "./homes.js";
31
+ import { recurrenceDiagnostics } from "./lowering/recurrences.js";
32
+ import { lower } from "./lowering/index.js";
33
+ import { LowerError } from "./lowering/syntax.js";
34
+ import { worldPrelude } from "./prelude.generated.js";
35
+ import { compileProperties } from "./properties.js";
36
+ import { compileScenarios } from "./scenarios.js";
37
+ import { tableEnvironment } from "./table-expressions.js";
38
+ let bootstrapped;
39
+ // UPSTREAM: derives.lisp expands :type signatures until Forma transports prelude aliases there.
40
+ const prelude = () => (bootstrapped ??= bootstrapFromSources(preludeSource("compiler.lisp"), worldPrelude));
41
+ export const compileWorld = (files) => {
42
+ const operators = operatorDiagnostics(files);
43
+ if (operators.length)
44
+ return { ok: false, ir: null, diagnostics: operators };
45
+ const adapted = new Map(files.map((f) => [f.id, elaborationSource(f)]));
46
+ const sensitivity = sensitivitySourceDiagnostics(files);
47
+ if (sensitivity.length)
48
+ return { ok: false, ir: null, diagnostics: sensitivity };
49
+ const vaults = vaultSourceDiagnostics(files);
50
+ if (vaults.length)
51
+ return { ok: false, ir: null, diagnostics: vaults };
52
+ const bindings = clockBindingDiagnostics(files);
53
+ if (bindings.length)
54
+ return { ok: false, ir: null, diagnostics: bindings };
55
+ const recurrenceErrors = recurrenceDiagnostics(files);
56
+ if (recurrenceErrors.length)
57
+ return { ok: false, ir: null, diagnostics: recurrenceErrors };
58
+ const layoutErrors = layoutSourceDiagnostics(files);
59
+ if (layoutErrors.length)
60
+ return { ok: false, ir: null, diagnostics: layoutErrors };
61
+ const agentErrors = agentSourceDiagnostics(files);
62
+ if (agentErrors.length)
63
+ return { ok: false, ir: null, diagnostics: agentErrors };
64
+ const elaborated = elaborateSources(files.map((f) => ({ sourceId: f.id, source: adapted.get(f.id).source })), { prelude: prelude(), semanticEnv: tableEnvironment() });
65
+ const diagnostics = elaborated.diagnostics.map((raw) => {
66
+ const d = {
67
+ ...raw,
68
+ code: diagnosticCode(raw.code, raw.severity),
69
+ ...(raw.span ? { span: adapted.get(raw.span.sourceId)?.span(raw.span) ?? raw.span } : {}),
70
+ };
71
+ return {
72
+ code: d.code,
73
+ severity: d.severity,
74
+ message: d.message,
75
+ ...(authoringHelp(d) ? { help: authoringHelp(d) } : {}),
76
+ ...(["E_COLLECT_FROM", "E_COLLECT_FACTS", "E_COLLECT_READONLY"].includes(d.code)
77
+ ? {
78
+ help: "Use :from Role with a nonempty vector of unique declared :facts. Collect directly writable fields; for reference paths, collect the referenced record's own role fields instead.",
79
+ }
80
+ : {}),
81
+ ...(["E_BINDS_SHAPE", "E_BINDS_TARGET", "E_BINDS_TYPE", "E_BINDS_CONFLICT"].includes(d.code)
82
+ ? {
83
+ help: "Use :binds {:evidence-field input.role-field} with compatible types. Bind each field once; use the legacy options only for other fields. Reference-path facts are read-only.",
84
+ }
85
+ : {}),
86
+ ...(d.code === "E_BUNDLE_ROLE"
87
+ ? {
88
+ help: "Use :for with a declared role, such as :for compliance/principal. A bundle projects assigned work; it grants no authority.",
89
+ }
90
+ : {}),
91
+ ...(d.code === "E_UNKNOWN_REQUIREMENT"
92
+ ? { help: "Name only requirements declared in the same component." }
93
+ : {}),
94
+ ...(d.code === "E_UNKNOWN_FIELD"
95
+ ? { help: "Use a declared evidence or role field name." }
96
+ : {}),
97
+ ...(d.code === "E_TABLE_SHAPE"
98
+ ? {
99
+ help: "Use (table keyword-parameter :value result ... :else fallback), with unique declared keyword rows and :else last; select a named derive parameter.",
100
+ }
101
+ : {}),
102
+ ...(d.code === "E_TABLE_NOT_EXHAUSTIVE"
103
+ ? {
104
+ help: "Cover every value of the parameter's keyword union, or add an explicit :else fallback; open Keyword parameters always need :else.",
105
+ }
106
+ : {}),
107
+ ...(d.code === "E_NO_HOME"
108
+ ? {
109
+ help: "The first key input must be an entity reference (Id E), directly or through another component's home. Put the reference first, for example [employee client] instead of [client].",
110
+ }
111
+ : {}),
112
+ ...(d.code === "E_SOURCE_KIND"
113
+ ? { help: "Choose :law, :regulation, :guidance, :framework, :contract or :policy." }
114
+ : {}),
115
+ ...(d.span
116
+ ? {
117
+ at: {
118
+ src: d.span.sourceId,
119
+ from: d.span.startOffset,
120
+ to: d.span.endOffset,
121
+ line: d.span.startLine ?? 1,
122
+ col: d.span.startColumn ?? 1,
123
+ },
124
+ }
125
+ : {}),
126
+ };
127
+ });
128
+ if (!elaborated.ok)
129
+ return { ok: false, ir: null, diagnostics };
130
+ try {
131
+ const model = lower(files, elaborated.declarations.map((d) => ({ ...d, span: adapted.get(d.sourceId).span(d.span) })));
132
+ const claims = compileProperties(model, files);
133
+ const withClaims = {
134
+ ...model,
135
+ ...(claims.properties.length ? { properties: claims.properties } : {}),
136
+ };
137
+ const examples = compileScenarios(withClaims, files);
138
+ const ir = {
139
+ ...withClaims,
140
+ ...(examples.scenarios.length ? { scenarios: examples.scenarios } : {}),
141
+ };
142
+ const checked = [
143
+ ...vaultDiagnostics(ir),
144
+ ...agentReadDiagnostics(ir),
145
+ ...sensitivityDiagnostics(ir),
146
+ ...documentDiagnostics(ir),
147
+ ...noticeDiagnostics(ir),
148
+ ...signatureDiagnostics(ir),
149
+ ...amendmentDiagnostics(ir),
150
+ ...resourceDiagnostics(ir),
151
+ ...resourceProofDiagnostics(ir),
152
+ ...fileFieldDiagnostics(ir),
153
+ ...childParameterDiagnostics(ir),
154
+ ...componentContractDiagnostics(ir),
155
+ ...statusHandlingDiagnostics(ir),
156
+ ...examples.diagnostics,
157
+ ...claims.diagnostics,
158
+ ...diagnostics,
159
+ ...homeDiagnostics(ir),
160
+ ...finiteTimeDiagnostics(ir),
161
+ ...instantLiteralDiagnostics(ir),
162
+ ...evidenceScopeDiagnostics(ir),
163
+ ...citationDiagnostics(ir),
164
+ ...documentationDiagnostics(ir),
165
+ ...requirementDiagnostics(ir),
166
+ ...attestedExpiryDiagnostics(ir),
167
+ ];
168
+ const ok = !checked.some((d) => d.severity === "error");
169
+ return { ok, ir: ok ? ir : null, diagnostics: checked };
170
+ }
171
+ catch (error) {
172
+ if (!(error instanceof LowerError))
173
+ throw error;
174
+ return {
175
+ ok: false,
176
+ ir: null,
177
+ diagnostics: [
178
+ ...diagnostics,
179
+ {
180
+ code: error.code,
181
+ severity: "error",
182
+ message: error.message,
183
+ at: error.at,
184
+ ...(error.help ? { help: error.help } : {}),
185
+ },
186
+ ],
187
+ };
188
+ }
189
+ };
190
+ export { KERNEL_FUNCTIONS } from "./lowering/syntax.js";
@@ -0,0 +1,10 @@
1
+ import type * as IR from "../../world-ir/types.generated.js";
2
+ export interface DefinitionReference {
3
+ readonly kind: "scenario" | "property";
4
+ readonly name: string;
5
+ }
6
+ export declare const definitionReferences: (ir: Pick<IR.WorldIR, "scenarios" | "properties" | "decisions"> & {
7
+ readonly components: readonly Omit<IR.Component, "home">[];
8
+ }) => ReadonlyMap<string, readonly DefinitionReference[]>;
9
+ /** Advisory reference analysis deliberately over-approximates reads; it proves no reachability. */
10
+ export declare const requirementDiagnostics: (ir: IR.WorldIR) => readonly IR.Diagnostic[];