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/dist/impact.js ADDED
@@ -0,0 +1,57 @@
1
+ import { resolve } from "node:path";
2
+ import { loadProject } from "./project.js";
3
+ import { previewImpact } from "./release/impact.js";
4
+ import { readSnapshot } from "./snapshot.js";
5
+ export const impactDirectories = async (before, after, options) => {
6
+ const [a, b] = await Promise.all([loadProject(before), loadProject(after)]);
7
+ const base = {
8
+ format: "worldvm/impact-report@1",
9
+ command: "impact",
10
+ old: a.directory,
11
+ new: b.directory,
12
+ snapshot: resolve(options.world),
13
+ };
14
+ const errors = [
15
+ ...a.diagnostics.map((d) => ({ ...d, side: "old" })),
16
+ ...b.diagnostics.map((d) => ({ ...d, side: "new" })),
17
+ ].filter((d) => d.severity === "error");
18
+ if (errors.length || !a.ir || !b.ir)
19
+ return { ...base, ok: false, diagnostics: errors, impact: null };
20
+ const read = await readSnapshot(options.world, [a.ir, b.ir], "E_IMPACT_SNAPSHOT");
21
+ if ("diagnostic" in read)
22
+ return { ...base, ok: false, diagnostics: [read.diagnostic], impact: null };
23
+ let impact;
24
+ try {
25
+ impact = previewImpact(a.ir, b.ir, { ...read.snapshot, at: options.at });
26
+ }
27
+ catch (cause) {
28
+ return {
29
+ ...base,
30
+ ok: false,
31
+ diagnostics: [
32
+ {
33
+ code: "E_IMPACT_AT",
34
+ severity: "error",
35
+ message: String(cause),
36
+ at: null,
37
+ help: "Pass --at as YYYY-MM-DD or YYYY-MM-DDTHH:MM and a snapshot both releases can evaluate.",
38
+ fix: null,
39
+ },
40
+ ],
41
+ impact: null,
42
+ };
43
+ }
44
+ const unsound = impact.unexpected.length
45
+ ? [
46
+ {
47
+ code: "E_IMPACT_UNSOUND",
48
+ severity: "error",
49
+ message: `${impact.unexpected.length} changes fall outside the definitions whose dependency digests changed.`,
50
+ at: null,
51
+ help: "A dependency is missing from the node graph; report this world and edit so the digest rules can be fixed.",
52
+ fix: null,
53
+ },
54
+ ]
55
+ : [];
56
+ return { ...base, ok: !unsound.length, diagnostics: unsound, impact };
57
+ };
@@ -0,0 +1,30 @@
1
+ import { type CliDiagnostic } from "./project.js";
2
+ export { loadProject, type Project, type CliDiagnostic, type Fix } from "./project.js";
3
+ export interface CheckReport {
4
+ readonly format: "worldvm/check@1";
5
+ readonly command: "check";
6
+ readonly directory: string;
7
+ readonly ok: boolean;
8
+ readonly files: readonly string[];
9
+ readonly diagnostics: readonly CliDiagnostic[];
10
+ readonly statistics: {
11
+ readonly accounts: number;
12
+ readonly components: number;
13
+ readonly requirements: number;
14
+ readonly scenarios: number;
15
+ readonly properties: number;
16
+ } | null;
17
+ }
18
+ export declare const checkDirectory: (directory: string, options?: {
19
+ readonly core?: boolean;
20
+ }) => Promise<CheckReport>;
21
+ export { testDirectory, type TestReport, type TestOptions, type TestFailure, type PropertyTestFailure, } from "./test.js";
22
+ export { coverageDirectory, type CoverageReport, type CoverageDefinition, type CoverageReference, } from "./coverage.js";
23
+ export { initWorld, STARTER, type InitResult } from "./init.js";
24
+ export { CATALOGUE, explain, type CatalogueEntry } from "./catalogue.js";
25
+ export { renderDirectory, type RenderReport, type RenderOptions, type RenderFormat, } from "./render.js";
26
+ export { explainDirectory, explainReconciliation, type ExplainReport, type ExplainOptions, type ExplainedInstance, type ExplainedRequirement, type ExplainedWork, } from "./explain.js";
27
+ export { readSnapshot, type WorldSnapshot } from "./snapshot.js";
28
+ export { diffDirectories, type DiffReport, type SidedDiagnostic } from "./diff.js";
29
+ export { impactDirectories, type ImpactReport, type ImpactOptions } from "./impact.js";
30
+ export { handleMessage, serveStdio, tools as mcpTools, serverInfo, protocolVersions, } from "./mcp.js";
package/dist/index.js ADDED
@@ -0,0 +1,43 @@
1
+ import { coreDiagnostics } from "./_internal/forma/world/index.js";
2
+ import { loadProject } from "./project.js";
3
+ export { loadProject } from "./project.js";
4
+ export const checkDirectory = async (directory, options = {}) => {
5
+ const project = await loadProject(directory), ir = project.ir;
6
+ return {
7
+ format: "worldvm/check@1",
8
+ command: "check",
9
+ directory: project.directory,
10
+ ok: ir !== null && !project.diagnostics.some((d) => d.severity === "error"),
11
+ files: project.files.map((f) => f.id),
12
+ diagnostics: [
13
+ ...project.diagnostics,
14
+ ...(options.core
15
+ ? coreDiagnostics(project.files).map((d) => ({
16
+ ...d,
17
+ at: d.at ?? null,
18
+ help: d.help ?? "",
19
+ fix: null,
20
+ }))
21
+ : []),
22
+ ],
23
+ statistics: ir
24
+ ? {
25
+ accounts: ir.accounts.length,
26
+ components: ir.components.length,
27
+ requirements: ir.components.reduce((n, c) => n + c.requirements.length, 0),
28
+ scenarios: ir.scenarios?.length ?? 0,
29
+ properties: ir.properties?.length ?? 0,
30
+ }
31
+ : null,
32
+ };
33
+ };
34
+ export { testDirectory, } from "./test.js";
35
+ export { coverageDirectory, } from "./coverage.js";
36
+ export { initWorld, STARTER } from "./init.js";
37
+ export { CATALOGUE, explain } from "./catalogue.js";
38
+ export { renderDirectory, } from "./render.js";
39
+ export { explainDirectory, explainReconciliation, } from "./explain.js";
40
+ export { readSnapshot } from "./snapshot.js";
41
+ export { diffDirectories } from "./diff.js";
42
+ export { impactDirectories } from "./impact.js";
43
+ export { handleMessage, serveStdio, tools as mcpTools, serverInfo, protocolVersions, } from "./mcp.js";
package/dist/init.d.ts ADDED
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The starter world written by `worldvm init`. It is the smallest world that passes
3
+ * check, test and coverage with no warnings, and AUTHORING.md walks through it.
4
+ * Synthetic data; illustrative only.
5
+ */
6
+ export declare const REFERENCE = "# Core world-language reference\n\nA world is a directory of `.forma` files: a library with roles and components, entities\nand an account that binds them, plus scenarios and properties. Start with `worldvm init`;\nloop `worldvm check .`, `worldvm test .`, `worldvm coverage . --mutate`.\n\nSyntax below uses `\u2026` for repetition and `[optional]` for optional syntax; those markers\nare not source. The fenced examples **together form one complete world**, in order.\nSynthetic policy and data; illustrative only. This page is compiled and tested.\nFor the deeper guide, see `AUTHORING.md` in the installed package\n(`node_modules/worldvm/AUTHORING.md`). In a scaffold, this file is `REFERENCE.md`; the examples stand alone.\n\nThe **core forms** are `source`, `entity`, `evidence`, `component`, `requirement`,\n`action`, `output`, `decision`, `scenario` and `property`. `worldvm check . --core`\nadds an `I_EXTENDED_FORM` info diagnostic at each extended declaration or child form;\nit does not reject a valid world. LSP clients can set `initializationOptions.core: true`. The surrounding declarations shown below (`library`,\n`role`, `interaction`, `layout`, `account`, plus their children) are **extended**.\nAll forms outside the ten-name core set are extended, including `attest`, `step`,\n`field`, `sign` and `for-each`; expression calls and scenario data are not declarations.\n\nFirst declare the library that owns the forms:\n\n```lisp\n(library example.training \"Annual safety training.\" :version \"1.0\" :subject training/worker)\n```\n\n| Form | Syntax | Common mistakes |\n| ------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |\n| `source` | `(source name \"doc\" :kind :policy :url \"url\" :as-of \"YYYY-MM-DD\")` | Cite a declared name, not a URL; use a real calendar date. |\n| `role` | `(role ns/name \"doc\" {:field Type \u2026})` | Roles describe interfaces, not stored records; include every field components read. |\n| `entity` | `(entity Name \"doc\" :ns :pkg.name :display field :implements {role {role-field field}} {:field Type \u2026})` | Namespace must start with the account package; map every role field with the same type. |\n| `evidence` | `(evidence Name \"doc\" :of Component [:expires date-expr] {:field Type \u2026} (attest \u2026))` | Declare it at top level; use `valid` for expiring evidence (`attested` ignores expiry); expiry may only read signed fields and `signed-on`. |\n| `interaction` | `(interaction Name \"doc\" :actor who :produces Evidence :layout Layout)` | Actor must resolve to a person or group; evidence fields belong in the evidence declaration. |\n| `layout` | `(layout Name \"doc\" (step id \"Label\" (field field) \u2026 (sign)))` | Use declared evidence fields; include a signing step for attested evidence. |\n| `component` | `(component Name \"doc\" :key [input \u2026] :inputs {:input Type \u2026} children \u2026)` | Put an entity-reference input first in the key; requirements go inside this form; list callable actions/decisions in `:operations`. |\n| `requirement` | `(requirement name :cites [(source \"clause\")] [:applies-when truth] :satisfied-by truth)` | Child of a component, never top level; conditions use Kleene Truth with `and`, `or`, `not`; `satisfied?` is false for NotApplicable. |\n| `action` | `(action name :advances requirement :assignee who :via (interaction Name))` | Child of a component; match the interaction actor and signer; an action does not itself set arbitrary facts. |\n| `output` | `(output name (all-of requirement-or-output \u2026))` | Child of a component; `all-of` accepts NotApplicable, unlike conjoining `satisfied?` checks; read locally as `self.name`. |\n| `decision` | `(decision name \"doc\" :of Component :applies requirement :by who :effect :approve :reason String [:expires duration] :cites [\u2026])` | Top level, not a component child; name a requirement of that component; approval requires the declared authority. |\n| `account` | `(account name \"doc\" :requires {library \"version\"} :package pkg (for-each role Component))` | Require the exact library version; map roles with entities' `:implements` before running components. |\n| `scenario` | `(scenario name \"doc\" :world account (given \u2026) (at \"date\" \u2026) (do \u2026) \u2026)` | `:world` names an account; time must advance; `given` is trusted history, `do` exercises command checks. |\n| `property` | `(property name \"doc\" :world account :at \"date\" :for-all (x Entity) predicate)` | Quantify an entity, not a role; use Bool `and`/`or`/`not` and `=`/`!=` here; a reference is not an assertion. |\n\n## Library forms\n\n`source`, `role`, `evidence`, `interaction` and `layout`, respectively:\n\n```lisp\n(source safety-policy \"Synthetic annual safety policy.\"\n :kind :policy :url \"https://example.invalid/safety\" :as-of \"2026-11-01\")\n```\n\n```lisp\n(role training/worker \"A worker and their reviewing group.\" {:name String :reviewers Group})\n```\n\n```lisp\n(evidence Completion \"Signed course completion.\" :of Training\n :expires (months-after signed-on 12)\n {:course String}\n (attest :signer worker :covers :all :method :otp))\n```\n\nEvidence can contain `(rule name :when condition :requires fields)`. The optional\n`:when` reads signed evidence fields and uses three-valued Truth. An omitted condition\nalways applies; a false condition skips the rule, and Unknown prevents attestation.\n`:requires` accepts a single `field`, `(one-of a b \u2026)` to require at least one filled\nfield, or `(all-of a b \u2026)` to require every listed field. Groups must be nonempty\nand contain declared field names. For example,\n`(rule documents :when (= document-choice :list-b-and-c) :requires (all-of list-b list-c))`\nrequires both document fields for that signed choice. The interaction's layout must\nshow required fields whenever the rule applies; a `one-of` group needs a visible alternative.\n\nFor a signal-driven protocol, declare `(machine Protocol \u2026 :signal updated \u2026)` and\na `(connector provider \u2026 :capabilities [] :signals [updated] :owns [Protocol])`.\nAn inbound-only connector uses an empty capabilities vector. A `component-contract`\nmay omit `:capabilities`; it defaults to `[]`.\n\n```lisp\n(interaction CompletionEntry \"Record the finished course.\"\n :actor worker :produces Completion :layout CompletionLayout)\n```\n\nAn interaction can supply signed evidence fields with `:fixes`, for example\n`:fixes {:examination :remote}` for an evidence field typed `(Union :in-person :remote)`.\nFixed values must be scalar literals matching the evidence field type. Omit these\nfields from the layout; they count as covered by the interaction. They cannot also\nuse `:binds`, `:prefill` or `:proposes`. Conflicting submissions are refused, including\nunsigned drafts. The stored evidence and signature include the fixed values, so\nevidence rules and explanations read them as signed fields. Two actions can share\none evidence type through different interactions; a remote action can use `:needs`\nto require enrollment before that interaction is eligible.\n\n```lisp\n(layout CompletionLayout \"Record and sign.\"\n (step record \"Record\" (field course) (sign)))\n```\n\n`component` contains `requirement`, `action` and `output`. This single fence keeps the\nparentheses and child scope visible:\n\n```lisp\n(component Training \"Track one worker's training.\"\n :key [worker] :inputs {:worker (Id training/worker)} :operations [complete waive-training]\n (requirement completed\n :cites [(safety-policy \"1: workers complete training every year\")]\n :satisfied-by (valid Completion))\n (action complete :advances completed :assignee worker :via (interaction CompletionEntry))\n (output done (all-of completed)))\n```\n\nExplanations follow the branch that decides a condition, in source order. A passing\n`or` reports the first passing branch and that branch's evidence. A failing `and`\nreports the first failing branch. A failing `or` reports every branch's failure;\na passing `and` reports every branch's success. Combined details do not select a\nsingle evidence record. If no `or` branch passes and at least one is Unknown, the\nresult is Unknown and the explanation includes the unresolved branches and the\nfailed branches. An `and` with no failing branch and at least one Unknown likewise\nreports all branches. Every branch is evaluated, including its dependencies and\ntime cutoffs; choosing an explanation does not short-circuit evaluation.\n\n`decision` records a judgment; it affects satisfaction only when a rule reads it with\n`(decided waive-training)`. This example deliberately keeps completion evidence required:\n\n```lisp\n(decision waive-training \"Record a reviewer's approval.\"\n :of Training :applies completed :by (members worker.reviewers)\n :effect :approve :reason String :expires (months 6)\n :cites [(safety-policy \"2: reviewers document exceptions\")])\n```\n\n## Account and proof\n\nA machine declared inside a component can anchor a case clock:\n`:due (business-days-after (entered-at case :referred) 10 :calendar us-federal)`.\nDeclare the calendar and the machine's protocol state. This works for plain signal-driven\nmachines, including connector-owned machines, without a resource or a separate date fact.\n`entered-at` returns the UTC Date of the first observation in the latest visit to the state.\nConsecutive duplicate states preserve it; leaving and re-entering resets it. After departure\nthe last entry date remains available; before an observed entry it is Unknown. Managed-resource\nmachines restrict history to the current acquisition generation. `resource-generation` and\n`attested-for` require a managed resource.\n\n`entity` and `account` bind stored records to the library:\n\n```lisp\n(entity Person \"A synthetic worker.\" :ns :example.person :display name\n :implements {training/worker {:name name :reviewers reviewers}}\n {:name String :reviewers Group})\n```\n\n```lisp\n(account example \"A synthetic training account.\"\n :requires {example.training \"1.0\"} :package example\n (for-each training/worker Training))\n```\n\n`scenario` tests missing, current and expired evidence through the action:\n\n```lisp\n(scenario completes-and-expires \"Training lasts twelve months.\" :world example\n (given (entity Person ana {:name \"Ana\" :reviewers \"Safety\"}) (actor ana))\n (at \"2026-11-02\" (expect (status (Training ana) completed) :Open))\n (do (perform (Training ana) complete :by ana :values {:course \"Safety 101\"}))\n (at \"2026-11-03\" (expect (status (Training ana) done) :Satisfied))\n (at \"2027-11-03\" (expect (status (Training ana) completed) :Open)))\n```\n\n`property` explores generated worlds at a fixed instant:\n\n```lisp\n(property done-needs-evidence \"Completion requires signed evidence.\"\n :world example :at \"2026-11-03\" :for-all (p Person)\n (given (entity Person p {:name \"Synthetic worker\" :reviewers \"Safety\"})\n (evidence Completion :for (Training p) :requirement completed :by p\n :values {:course \"Safety 101\"}))\n (implies (= (status (Training p) done) :Satisfied)\n (attested (Training p) Completion)))\n```\n\nAn optional `given` block before the predicate uses scenario entity, evidence and\nsignal records. It must declare the quantified alias with the quantified entity type.\nEach generated case keeps those entities and explicit facts and varies unspecified\nfields. Seeded evidence and signals are retained; random history does not replace\nthe same evidence type or machine on the same occurrence. As in scenarios, `given`\nis trusted history, not an exercise of action eligibility.\nCounterexample shrinking preserves the authored seed facts and records.\n\n`test` and `coverage`, in text and JSON, count the generated cases in which each\n`implies` antecedent was true, once per case even with multiple quantified entities.\nZero produces `W_PROPERTY_VACUOUS`. This is a warning: vacuity alone does not fail\neither command. A false or Unknown property still fails. Add seed facts and evidence\nthat reach the antecedent to test the claim.\n\nUse calendar `(months N)` and `(months-after signed-on N)` for calendar periods. Comparisons use `=` and `!=` everywhere. Logic uses `and`, `or`, `not`: Kleene Truth\nin conditions and ordinary Bool in properties. Write `(and a b)` or `(or a b)`;\nTruth contexts also accept a collection as a single argument. To roll up\noptional requirements use an `all-of` output and read it with `(met? self.done)`.\n`worldvm explain W_ATTESTED_EXPIRING` explains why expiry requires `valid`.\n\n## Structured host reads\n\nThe operating protocol exposes `facts` alongside `status`, `work`, `operations` and\n`explain`. Facts include the asserting actor, valid time and retained command ID.\nWork prerequisites are structured addresses derived from IR, with canonical display\ntext; evidence prerequisites name their producing requirements. Compound conditions\nremain opaque display reasons. Status includes observed machine states and entry\ntimes. Explanations include selected evidence values. Hosts can gate subject reads\nwith `canRead`; see `docs/protocol.md` in the installed package (\"Structured subject reads\") for schemas\nand the trusted embedding boundary.\n\n## CLI: impact on a live world\n\nDeploy checked source, then serve the stored release without the source directory:\n\n```sh\nworldvm deploy deployed-world --db world.db --account example\nworldvm serve --db world.db\n# In another terminal, while serve is running (or after it stops):\nworldvm snapshot --db world.db --account example --out snapshot.json\nworldvm impact deployed-world proposed-world --world snapshot.json --at 2026-11-10\nworldvm explain deployed-world --world snapshot.json --subject hire-123 --at 2026-11-10\n```\n\n`snapshot` reads committed state in one read transaction without changing the database.\n`--account` must name the account used by the server. Deploy stores that account with the release.\nWithout `--out`, the JSON goes to stdout. The `worldvm/world@1` snapshot contains\n`accounts`, `world` and an optional `release` identifying the release that last wrote\nthe records. The evaluation instant is supplied to `impact` or `explain` with `--at`.\n\nStop `serve` before deploying another release. One process per SQLite file is required;\na busy SQLite write lock is refused with a message to stop `serve`, but an idle server\ncannot be detected. Snapshot export is a read-only exception to this rule.\n\n```sh\nworldvm deploy proposed-world --db world.db --account example --at 2026-11-10 --dry-run\nworldvm deploy proposed-world --db world.db --account example --at 2026-11-10 --json\nworldvm serve --db world.db --clock 2026-11-11 --ui\nworldvm mcp --db world.db --actor '{\"id\":\"agent:ops\",\"kind\":\"agent\"}'\n```\n\nDeploy refuses the same compile and authoring errors as `check`, before opening SQLite.\nIt reports old and new release IDs, requirement and work changes, and every changed\nsubject. `--at` controls impact evaluation and defaults to now. `--dry-run` checks and\npreviews without changing or creating the database. Deployment retains compiled IR,\naccount and deployment timestamp in the `releases` table, in deployment order. The last\nrow is active, including when an earlier release is deployed again. Records, receipts\nand proposals are preserved; statuses are recomputed under the new rules, with no data\nmigration. The SQLite format is `worldvm/sqlite-store@3`; older files are refused and\nrequire a new database.\n\n`serve <directory> --db world.db` is a development shortcut for deploy, then serve;\nit requires a world with one account. `serve --db` and `mcp --db` use stored IR.\nEmbedders can use `open({ store: sqlite(\"world.db\") })` for the deployed release.\nExplicit `open({ source, store })` still refuses records from another release unless\n`activate: true` is supplied. That embedding option recomputes status and preserves\nrecords; use CLI deploy to retain deployment history. Time passing requires a tick or\na later server clock, not another deployment.\n";
7
+ export declare const STARTER: Readonly<Record<string, string>>;
8
+ export interface InitResult {
9
+ readonly directory: string;
10
+ readonly files: readonly string[];
11
+ }
12
+ /** Write the starter world; refuses a directory that already holds files. */
13
+ export declare const initWorld: (input: string) => Promise<InitResult>;
package/dist/init.js ADDED
@@ -0,0 +1,99 @@
1
+ import { mkdir, readdir, writeFile } from "node:fs/promises";
2
+ import { dirname, join, resolve } from "node:path";
3
+ /**
4
+ * The starter world written by `worldvm init`. It is the smallest world that passes
5
+ * check, test and coverage with no warnings, and AUTHORING.md walks through it.
6
+ * Synthetic data; illustrative only.
7
+ */
8
+ // Kept identical to docs/reference.md by reference-doc.test.ts. Embedded so init works
9
+ // without a checkout or a network connection.
10
+ export const REFERENCE = '# Core world-language reference\n\nA world is a directory of `.forma` files: a library with roles and components, entities\nand an account that binds them, plus scenarios and properties. Start with `worldvm init`;\nloop `worldvm check .`, `worldvm test .`, `worldvm coverage . --mutate`.\n\nSyntax below uses `…` for repetition and `[optional]` for optional syntax; those markers\nare not source. The fenced examples **together form one complete world**, in order.\nSynthetic policy and data; illustrative only. This page is compiled and tested.\nFor the deeper guide, see `AUTHORING.md` in the installed package\n(`node_modules/worldvm/AUTHORING.md`). In a scaffold, this file is `REFERENCE.md`; the examples stand alone.\n\nThe **core forms** are `source`, `entity`, `evidence`, `component`, `requirement`,\n`action`, `output`, `decision`, `scenario` and `property`. `worldvm check . --core`\nadds an `I_EXTENDED_FORM` info diagnostic at each extended declaration or child form;\nit does not reject a valid world. LSP clients can set `initializationOptions.core: true`. The surrounding declarations shown below (`library`,\n`role`, `interaction`, `layout`, `account`, plus their children) are **extended**.\nAll forms outside the ten-name core set are extended, including `attest`, `step`,\n`field`, `sign` and `for-each`; expression calls and scenario data are not declarations.\n\nFirst declare the library that owns the forms:\n\n```lisp\n(library example.training "Annual safety training." :version "1.0" :subject training/worker)\n```\n\n| Form | Syntax | Common mistakes |\n| ------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |\n| `source` | `(source name "doc" :kind :policy :url "url" :as-of "YYYY-MM-DD")` | Cite a declared name, not a URL; use a real calendar date. |\n| `role` | `(role ns/name "doc" {:field Type …})` | Roles describe interfaces, not stored records; include every field components read. |\n| `entity` | `(entity Name "doc" :ns :pkg.name :display field :implements {role {role-field field}} {:field Type …})` | Namespace must start with the account package; map every role field with the same type. |\n| `evidence` | `(evidence Name "doc" :of Component [:expires date-expr] {:field Type …} (attest …))` | Declare it at top level; use `valid` for expiring evidence (`attested` ignores expiry); expiry may only read signed fields and `signed-on`. |\n| `interaction` | `(interaction Name "doc" :actor who :produces Evidence :layout Layout)` | Actor must resolve to a person or group; evidence fields belong in the evidence declaration. |\n| `layout` | `(layout Name "doc" (step id "Label" (field field) … (sign)))` | Use declared evidence fields; include a signing step for attested evidence. |\n| `component` | `(component Name "doc" :key [input …] :inputs {:input Type …} children …)` | Put an entity-reference input first in the key; requirements go inside this form; list callable actions/decisions in `:operations`. |\n| `requirement` | `(requirement name :cites [(source "clause")] [:applies-when truth] :satisfied-by truth)` | Child of a component, never top level; conditions use Kleene Truth with `and`, `or`, `not`; `satisfied?` is false for NotApplicable. |\n| `action` | `(action name :advances requirement :assignee who :via (interaction Name))` | Child of a component; match the interaction actor and signer; an action does not itself set arbitrary facts. |\n| `output` | `(output name (all-of requirement-or-output …))` | Child of a component; `all-of` accepts NotApplicable, unlike conjoining `satisfied?` checks; read locally as `self.name`. |\n| `decision` | `(decision name "doc" :of Component :applies requirement :by who :effect :approve :reason String [:expires duration] :cites […])` | Top level, not a component child; name a requirement of that component; approval requires the declared authority. |\n| `account` | `(account name "doc" :requires {library "version"} :package pkg (for-each role Component))` | Require the exact library version; map roles with entities\' `:implements` before running components. |\n| `scenario` | `(scenario name "doc" :world account (given …) (at "date" …) (do …) …)` | `:world` names an account; time must advance; `given` is trusted history, `do` exercises command checks. |\n| `property` | `(property name "doc" :world account :at "date" :for-all (x Entity) predicate)` | Quantify an entity, not a role; use Bool `and`/`or`/`not` and `=`/`!=` here; a reference is not an assertion. |\n\n## Library forms\n\n`source`, `role`, `evidence`, `interaction` and `layout`, respectively:\n\n```lisp\n(source safety-policy "Synthetic annual safety policy."\n :kind :policy :url "https://example.invalid/safety" :as-of "2026-11-01")\n```\n\n```lisp\n(role training/worker "A worker and their reviewing group." {:name String :reviewers Group})\n```\n\n```lisp\n(evidence Completion "Signed course completion." :of Training\n :expires (months-after signed-on 12)\n {:course String}\n (attest :signer worker :covers :all :method :otp))\n```\n\nEvidence can contain `(rule name :when condition :requires fields)`. The optional\n`:when` reads signed evidence fields and uses three-valued Truth. An omitted condition\nalways applies; a false condition skips the rule, and Unknown prevents attestation.\n`:requires` accepts a single `field`, `(one-of a b …)` to require at least one filled\nfield, or `(all-of a b …)` to require every listed field. Groups must be nonempty\nand contain declared field names. For example,\n`(rule documents :when (= document-choice :list-b-and-c) :requires (all-of list-b list-c))`\nrequires both document fields for that signed choice. The interaction\'s layout must\nshow required fields whenever the rule applies; a `one-of` group needs a visible alternative.\n\nFor a signal-driven protocol, declare `(machine Protocol … :signal updated …)` and\na `(connector provider … :capabilities [] :signals [updated] :owns [Protocol])`.\nAn inbound-only connector uses an empty capabilities vector. A `component-contract`\nmay omit `:capabilities`; it defaults to `[]`.\n\n```lisp\n(interaction CompletionEntry "Record the finished course."\n :actor worker :produces Completion :layout CompletionLayout)\n```\n\nAn interaction can supply signed evidence fields with `:fixes`, for example\n`:fixes {:examination :remote}` for an evidence field typed `(Union :in-person :remote)`.\nFixed values must be scalar literals matching the evidence field type. Omit these\nfields from the layout; they count as covered by the interaction. They cannot also\nuse `:binds`, `:prefill` or `:proposes`. Conflicting submissions are refused, including\nunsigned drafts. The stored evidence and signature include the fixed values, so\nevidence rules and explanations read them as signed fields. Two actions can share\none evidence type through different interactions; a remote action can use `:needs`\nto require enrollment before that interaction is eligible.\n\n```lisp\n(layout CompletionLayout "Record and sign."\n (step record "Record" (field course) (sign)))\n```\n\n`component` contains `requirement`, `action` and `output`. This single fence keeps the\nparentheses and child scope visible:\n\n```lisp\n(component Training "Track one worker\'s training."\n :key [worker] :inputs {:worker (Id training/worker)} :operations [complete waive-training]\n (requirement completed\n :cites [(safety-policy "1: workers complete training every year")]\n :satisfied-by (valid Completion))\n (action complete :advances completed :assignee worker :via (interaction CompletionEntry))\n (output done (all-of completed)))\n```\n\nExplanations follow the branch that decides a condition, in source order. A passing\n`or` reports the first passing branch and that branch\'s evidence. A failing `and`\nreports the first failing branch. A failing `or` reports every branch\'s failure;\na passing `and` reports every branch\'s success. Combined details do not select a\nsingle evidence record. If no `or` branch passes and at least one is Unknown, the\nresult is Unknown and the explanation includes the unresolved branches and the\nfailed branches. An `and` with no failing branch and at least one Unknown likewise\nreports all branches. Every branch is evaluated, including its dependencies and\ntime cutoffs; choosing an explanation does not short-circuit evaluation.\n\n`decision` records a judgment; it affects satisfaction only when a rule reads it with\n`(decided waive-training)`. This example deliberately keeps completion evidence required:\n\n```lisp\n(decision waive-training "Record a reviewer\'s approval."\n :of Training :applies completed :by (members worker.reviewers)\n :effect :approve :reason String :expires (months 6)\n :cites [(safety-policy "2: reviewers document exceptions")])\n```\n\n## Account and proof\n\nA machine declared inside a component can anchor a case clock:\n`:due (business-days-after (entered-at case :referred) 10 :calendar us-federal)`.\nDeclare the calendar and the machine\'s protocol state. This works for plain signal-driven\nmachines, including connector-owned machines, without a resource or a separate date fact.\n`entered-at` returns the UTC Date of the first observation in the latest visit to the state.\nConsecutive duplicate states preserve it; leaving and re-entering resets it. After departure\nthe last entry date remains available; before an observed entry it is Unknown. Managed-resource\nmachines restrict history to the current acquisition generation. `resource-generation` and\n`attested-for` require a managed resource.\n\n`entity` and `account` bind stored records to the library:\n\n```lisp\n(entity Person "A synthetic worker." :ns :example.person :display name\n :implements {training/worker {:name name :reviewers reviewers}}\n {:name String :reviewers Group})\n```\n\n```lisp\n(account example "A synthetic training account."\n :requires {example.training "1.0"} :package example\n (for-each training/worker Training))\n```\n\n`scenario` tests missing, current and expired evidence through the action:\n\n```lisp\n(scenario completes-and-expires "Training lasts twelve months." :world example\n (given (entity Person ana {:name "Ana" :reviewers "Safety"}) (actor ana))\n (at "2026-11-02" (expect (status (Training ana) completed) :Open))\n (do (perform (Training ana) complete :by ana :values {:course "Safety 101"}))\n (at "2026-11-03" (expect (status (Training ana) done) :Satisfied))\n (at "2027-11-03" (expect (status (Training ana) completed) :Open)))\n```\n\n`property` explores generated worlds at a fixed instant:\n\n```lisp\n(property done-needs-evidence "Completion requires signed evidence."\n :world example :at "2026-11-03" :for-all (p Person)\n (given (entity Person p {:name "Synthetic worker" :reviewers "Safety"})\n (evidence Completion :for (Training p) :requirement completed :by p\n :values {:course "Safety 101"}))\n (implies (= (status (Training p) done) :Satisfied)\n (attested (Training p) Completion)))\n```\n\nAn optional `given` block before the predicate uses scenario entity, evidence and\nsignal records. It must declare the quantified alias with the quantified entity type.\nEach generated case keeps those entities and explicit facts and varies unspecified\nfields. Seeded evidence and signals are retained; random history does not replace\nthe same evidence type or machine on the same occurrence. As in scenarios, `given`\nis trusted history, not an exercise of action eligibility.\nCounterexample shrinking preserves the authored seed facts and records.\n\n`test` and `coverage`, in text and JSON, count the generated cases in which each\n`implies` antecedent was true, once per case even with multiple quantified entities.\nZero produces `W_PROPERTY_VACUOUS`. This is a warning: vacuity alone does not fail\neither command. A false or Unknown property still fails. Add seed facts and evidence\nthat reach the antecedent to test the claim.\n\nUse calendar `(months N)` and `(months-after signed-on N)` for calendar periods. Comparisons use `=` and `!=` everywhere. Logic uses `and`, `or`, `not`: Kleene Truth\nin conditions and ordinary Bool in properties. Write `(and a b)` or `(or a b)`;\nTruth contexts also accept a collection as a single argument. To roll up\noptional requirements use an `all-of` output and read it with `(met? self.done)`.\n`worldvm explain W_ATTESTED_EXPIRING` explains why expiry requires `valid`.\n\n## Structured host reads\n\nThe operating protocol exposes `facts` alongside `status`, `work`, `operations` and\n`explain`. Facts include the asserting actor, valid time and retained command ID.\nWork prerequisites are structured addresses derived from IR, with canonical display\ntext; evidence prerequisites name their producing requirements. Compound conditions\nremain opaque display reasons. Status includes observed machine states and entry\ntimes. Explanations include selected evidence values. Hosts can gate subject reads\nwith `canRead`; see `docs/protocol.md` in the installed package ("Structured subject reads") for schemas\nand the trusted embedding boundary.\n\n## CLI: impact on a live world\n\nDeploy checked source, then serve the stored release without the source directory:\n\n```sh\nworldvm deploy deployed-world --db world.db --account example\nworldvm serve --db world.db\n# In another terminal, while serve is running (or after it stops):\nworldvm snapshot --db world.db --account example --out snapshot.json\nworldvm impact deployed-world proposed-world --world snapshot.json --at 2026-11-10\nworldvm explain deployed-world --world snapshot.json --subject hire-123 --at 2026-11-10\n```\n\n`snapshot` reads committed state in one read transaction without changing the database.\n`--account` must name the account used by the server. Deploy stores that account with the release.\nWithout `--out`, the JSON goes to stdout. The `worldvm/world@1` snapshot contains\n`accounts`, `world` and an optional `release` identifying the release that last wrote\nthe records. The evaluation instant is supplied to `impact` or `explain` with `--at`.\n\nStop `serve` before deploying another release. One process per SQLite file is required;\na busy SQLite write lock is refused with a message to stop `serve`, but an idle server\ncannot be detected. Snapshot export is a read-only exception to this rule.\n\n```sh\nworldvm deploy proposed-world --db world.db --account example --at 2026-11-10 --dry-run\nworldvm deploy proposed-world --db world.db --account example --at 2026-11-10 --json\nworldvm serve --db world.db --clock 2026-11-11 --ui\nworldvm mcp --db world.db --actor \'{"id":"agent:ops","kind":"agent"}\'\n```\n\nDeploy refuses the same compile and authoring errors as `check`, before opening SQLite.\nIt reports old and new release IDs, requirement and work changes, and every changed\nsubject. `--at` controls impact evaluation and defaults to now. `--dry-run` checks and\npreviews without changing or creating the database. Deployment retains compiled IR,\naccount and deployment timestamp in the `releases` table, in deployment order. The last\nrow is active, including when an earlier release is deployed again. Records, receipts\nand proposals are preserved; statuses are recomputed under the new rules, with no data\nmigration. The SQLite format is `worldvm/sqlite-store@3`; older files are refused and\nrequire a new database.\n\n`serve <directory> --db world.db` is a development shortcut for deploy, then serve;\nit requires a world with one account. `serve --db` and `mcp --db` use stored IR.\nEmbedders can use `open({ store: sqlite("world.db") })` for the deployed release.\nExplicit `open({ source, store })` still refuses records from another release unless\n`activate: true` is supplied. That embedding option recomputes status and preserves\nrecords; use CLI deploy to retain deployment history. Time passing requires a tick or\na later server clock, not another deployment.\n';
11
+ export const STARTER = {
12
+ "library/starter.forma": `;; Starter library. Synthetic and illustrative; not legal or compliance advice.
13
+ ;; A library declares roles (the shapes it needs), evidence, interactions and components.
14
+ (library example.starter
15
+ "Annual policy acknowledgement for one synthetic subject."
16
+ :version "1.0" :subject starter/subject)
17
+
18
+ (role starter/person "A person who signs on behalf of a subject." {:name String})
19
+ (role starter/subject "The record the requirements are about."
20
+ {:name String :owner (Id starter/person) :opened Date})
21
+
22
+ (source starter-policy "Synthetic starter policy; not legal or compliance advice."
23
+ :kind :policy :url "https://example.invalid/starter-policy" :as-of "2026-01-01")
24
+
25
+ ;; Evidence is a signed record. (valid E) is false once :expires passes; (attested E) is not.
26
+ (evidence Acknowledgement "The owner's signed policy acknowledgement." :of Onboarding
27
+ :expires (months-after signed-on 12)
28
+ {:summary String}
29
+ (attest :signer subject.owner :covers :all :method :otp))
30
+
31
+ (layout AcknowledgementLayout "Record and sign the acknowledgement."
32
+ (step record "Record" (field summary) (sign)))
33
+ (interaction AcknowledgementEntry "Sign the policy acknowledgement."
34
+ :actor subject.owner :produces Acknowledgement :layout AcknowledgementLayout)
35
+
36
+ ;; A component is instantiated once per key. Requirements are three-valued (Truth).
37
+ (component Onboarding "Track the requirements for one subject."
38
+ :key [subject] :inputs {:subject (Id starter/subject)} :operations [acknowledge]
39
+ (requirement acknowledged
40
+ :cites [(starter-policy "1: the owner acknowledges the policy every 12 months")]
41
+ :satisfied-by (valid Acknowledgement))
42
+ (action acknowledge :advances acknowledged :assignee subject.owner
43
+ :via (interaction AcknowledgementEntry))
44
+ (output complete (all-of acknowledged)))
45
+ `,
46
+ "example.forma": `;; The example account: concrete entities that implement the library's roles.
47
+ (entity Person "A synthetic person." :ns :example.person :display name
48
+ :implements {starter/person {:name name}} {:name String})
49
+ (entity Subject "A synthetic subject." :ns :example.subject :display name
50
+ :implements {starter/subject {:name name :owner owner :opened opened}}
51
+ {:name String :owner (Id Person) :opened Date})
52
+ (account example "An isolated synthetic starter account."
53
+ :requires {example.starter "1.0"} :package example
54
+ (for-each starter/subject Onboarding))
55
+ `,
56
+ "scenarios/starter.forma": `;; Scenarios are worked examples; properties are claims over generated worlds.
57
+ (scenario acknowledgement-lasts-a-year "An acknowledgement satisfies the requirement for 12 months." :world example
58
+ (given (entity Person owner {:name "Owner"})
59
+ (entity Subject s {:name "Subject" :owner owner :opened "2026-01-01"})
60
+ (actor owner))
61
+ (at "2026-01-01" (expect (status (Onboarding s) acknowledged) :Open))
62
+ (do (evidence Acknowledgement :for (Onboarding s) :requirement acknowledged :by owner
63
+ :values {:summary "Read and agreed"}))
64
+ (at "2026-01-02" (expect (status (Onboarding s) complete) :Satisfied))
65
+ (at "2027-01-02" (expect (status (Onboarding s) acknowledged) :Open)))
66
+
67
+ (property complete-means-acknowledged "A complete subject has a signed acknowledgement."
68
+ :world example :at "2026-06-01" :for-all (s Subject)
69
+ (implies (= (status (Onboarding s) complete) :Satisfied)
70
+ (attested (Onboarding s) Acknowledgement)))
71
+ `,
72
+ "REFERENCE.md": REFERENCE,
73
+ "README.md": `# Starter world
74
+
75
+ Synthetic and illustrative; not legal or compliance advice.
76
+
77
+ worldvm check . # compile and lint
78
+ worldvm test . # run scenarios and properties
79
+ worldvm coverage . --mutate # branch measurements and surviving semantic mutants
80
+
81
+ Edit library/starter.forma, add scenarios under scenarios/, and rerun the loop.
82
+ Read [REFERENCE.md](REFERENCE.md) for core syntax, examples and common mistakes.
83
+ `,
84
+ };
85
+ /** Write the starter world; refuses a directory that already holds files. */
86
+ export const initWorld = async (input) => {
87
+ const directory = resolve(input);
88
+ await mkdir(directory, { recursive: true });
89
+ const existing = (await readdir(directory)).filter((n) => !n.startsWith("."));
90
+ if (existing.length)
91
+ throw new Error(`${directory} is not empty; choose a new or empty directory.`);
92
+ const files = Object.keys(STARTER).sort();
93
+ for (const file of files) {
94
+ const path = join(directory, file);
95
+ await mkdir(dirname(path), { recursive: true });
96
+ await writeFile(path, STARTER[file], { flag: "wx" });
97
+ }
98
+ return { directory, files };
99
+ };