worldvm 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (426) hide show
  1. package/AUTHORING.md +833 -0
  2. package/README.md +154 -2
  3. package/bin/worldvm.mjs +3 -0
  4. package/dist/_internal/forma/index.d.ts +1 -0
  5. package/dist/_internal/forma/index.js +1 -0
  6. package/dist/_internal/forma/world/authoring-help.d.ts +25 -0
  7. package/dist/_internal/forma/world/authoring-help.js +130 -0
  8. package/dist/_internal/forma/world/citations.d.ts +3 -0
  9. package/dist/_internal/forma/world/citations.js +26 -0
  10. package/dist/_internal/forma/world/clock-bindings.d.ts +4 -0
  11. package/dist/_internal/forma/world/clock-bindings.js +45 -0
  12. package/dist/_internal/forma/world/compile.d.ts +13 -0
  13. package/dist/_internal/forma/world/compile.js +190 -0
  14. package/dist/_internal/forma/world/coverage.d.ts +10 -0
  15. package/dist/_internal/forma/world/coverage.js +242 -0
  16. package/dist/_internal/forma/world/digest.d.ts +1 -0
  17. package/dist/_internal/forma/world/digest.js +1 -0
  18. package/dist/_internal/forma/world/documentation.d.ts +3 -0
  19. package/dist/_internal/forma/world/documentation.js +38 -0
  20. package/dist/_internal/forma/world/homes.d.ts +4 -0
  21. package/dist/_internal/forma/world/homes.js +202 -0
  22. package/dist/_internal/forma/world/index.d.ts +6 -0
  23. package/dist/_internal/forma/world/index.js +5 -0
  24. package/dist/_internal/forma/world/lowering/accounts.d.ts +4 -0
  25. package/dist/_internal/forma/world/lowering/accounts.js +36 -0
  26. package/dist/_internal/forma/world/lowering/action-policy.d.ts +5 -0
  27. package/dist/_internal/forma/world/lowering/action-policy.js +16 -0
  28. package/dist/_internal/forma/world/lowering/agents.d.ts +6 -0
  29. package/dist/_internal/forma/world/lowering/agents.js +116 -0
  30. package/dist/_internal/forma/world/lowering/bundles.d.ts +3 -0
  31. package/dist/_internal/forma/world/lowering/bundles.js +13 -0
  32. package/dist/_internal/forma/world/lowering/child-parameters.d.ts +14 -0
  33. package/dist/_internal/forma/world/lowering/child-parameters.js +36 -0
  34. package/dist/_internal/forma/world/lowering/collects.d.ts +3 -0
  35. package/dist/_internal/forma/world/lowering/collects.js +51 -0
  36. package/dist/_internal/forma/world/lowering/component-operations.d.ts +6 -0
  37. package/dist/_internal/forma/world/lowering/component-operations.js +26 -0
  38. package/dist/_internal/forma/world/lowering/components.d.ts +7 -0
  39. package/dist/_internal/forma/world/lowering/components.js +236 -0
  40. package/dist/_internal/forma/world/lowering/connectors.d.ts +4 -0
  41. package/dist/_internal/forma/world/lowering/connectors.js +31 -0
  42. package/dist/_internal/forma/world/lowering/context.d.ts +80 -0
  43. package/dist/_internal/forma/world/lowering/context.js +316 -0
  44. package/dist/_internal/forma/world/lowering/contracts.d.ts +7 -0
  45. package/dist/_internal/forma/world/lowering/contracts.js +73 -0
  46. package/dist/_internal/forma/world/lowering/decisions.d.ts +3 -0
  47. package/dist/_internal/forma/world/lowering/decisions.js +164 -0
  48. package/dist/_internal/forma/world/lowering/derives.d.ts +3 -0
  49. package/dist/_internal/forma/world/lowering/derives.js +22 -0
  50. package/dist/_internal/forma/world/lowering/discretionary.d.ts +7 -0
  51. package/dist/_internal/forma/world/lowering/discretionary.js +15 -0
  52. package/dist/_internal/forma/world/lowering/documents.d.ts +3 -0
  53. package/dist/_internal/forma/world/lowering/documents.js +68 -0
  54. package/dist/_internal/forma/world/lowering/effective.d.ts +5 -0
  55. package/dist/_internal/forma/world/lowering/effective.js +26 -0
  56. package/dist/_internal/forma/world/lowering/entities.d.ts +3 -0
  57. package/dist/_internal/forma/world/lowering/entities.js +43 -0
  58. package/dist/_internal/forma/world/lowering/escalations.d.ts +6 -0
  59. package/dist/_internal/forma/world/lowering/escalations.js +31 -0
  60. package/dist/_internal/forma/world/lowering/evidence.d.ts +3 -0
  61. package/dist/_internal/forma/world/lowering/evidence.js +75 -0
  62. package/dist/_internal/forma/world/lowering/files.d.ts +4 -0
  63. package/dist/_internal/forma/world/lowering/files.js +56 -0
  64. package/dist/_internal/forma/world/lowering/holds.d.ts +6 -0
  65. package/dist/_internal/forma/world/lowering/holds.js +35 -0
  66. package/dist/_internal/forma/world/lowering/index.d.ts +89 -0
  67. package/dist/_internal/forma/world/lowering/index.js +115 -0
  68. package/dist/_internal/forma/world/lowering/interactions.d.ts +7 -0
  69. package/dist/_internal/forma/world/lowering/interactions.js +190 -0
  70. package/dist/_internal/forma/world/lowering/library.d.ts +5 -0
  71. package/dist/_internal/forma/world/lowering/library.js +41 -0
  72. package/dist/_internal/forma/world/lowering/milestones.d.ts +6 -0
  73. package/dist/_internal/forma/world/lowering/milestones.js +17 -0
  74. package/dist/_internal/forma/world/lowering/notices.d.ts +3 -0
  75. package/dist/_internal/forma/world/lowering/notices.js +33 -0
  76. package/dist/_internal/forma/world/lowering/param-bounds.d.ts +15 -0
  77. package/dist/_internal/forma/world/lowering/param-bounds.js +71 -0
  78. package/dist/_internal/forma/world/lowering/policies.d.ts +6 -0
  79. package/dist/_internal/forma/world/lowering/policies.js +95 -0
  80. package/dist/_internal/forma/world/lowering/principals.d.ts +62 -0
  81. package/dist/_internal/forma/world/lowering/principals.js +32 -0
  82. package/dist/_internal/forma/world/lowering/recurrences.d.ts +9 -0
  83. package/dist/_internal/forma/world/lowering/recurrences.js +56 -0
  84. package/dist/_internal/forma/world/lowering/renewal.d.ts +5 -0
  85. package/dist/_internal/forma/world/lowering/renewal.js +21 -0
  86. package/dist/_internal/forma/world/lowering/resources.d.ts +6 -0
  87. package/dist/_internal/forma/world/lowering/resources.js +19 -0
  88. package/dist/_internal/forma/world/lowering/reuse.d.ts +5 -0
  89. package/dist/_internal/forma/world/lowering/reuse.js +75 -0
  90. package/dist/_internal/forma/world/lowering/sources.d.ts +10 -0
  91. package/dist/_internal/forma/world/lowering/sources.js +47 -0
  92. package/dist/_internal/forma/world/lowering/syntax.d.ts +84 -0
  93. package/dist/_internal/forma/world/lowering/syntax.js +94 -0
  94. package/dist/_internal/forma/world/lowering/vaults.d.ts +11 -0
  95. package/dist/_internal/forma/world/lowering/vaults.js +148 -0
  96. package/dist/_internal/forma/world/prelude.generated.d.ts +1 -0
  97. package/dist/_internal/forma/world/prelude.generated.js +2 -0
  98. package/dist/_internal/forma/world/properties.d.ts +9 -0
  99. package/dist/_internal/forma/world/properties.js +387 -0
  100. package/dist/_internal/forma/world/scenarios.d.ts +10 -0
  101. package/dist/_internal/forma/world/scenarios.js +757 -0
  102. package/dist/_internal/forma/world/sensitivity.d.ts +3 -0
  103. package/dist/_internal/forma/world/sensitivity.js +118 -0
  104. package/dist/_internal/forma/world/source-syntax.d.ts +6 -0
  105. package/dist/_internal/forma/world/source-syntax.js +27 -0
  106. package/dist/_internal/forma/world/status-handling.d.ts +3 -0
  107. package/dist/_internal/forma/world/status-handling.js +143 -0
  108. package/dist/_internal/forma/world/surface.d.ts +30 -0
  109. package/dist/_internal/forma/world/surface.js +213 -0
  110. package/dist/_internal/forma/world/table-expressions.d.ts +3 -0
  111. package/dist/_internal/forma/world/table-expressions.js +41 -0
  112. package/dist/_internal/forma-tools/index.d.ts +17 -0
  113. package/dist/_internal/forma-tools/index.js +124 -0
  114. package/dist/_internal/ir-checks/advances.d.ts +7 -0
  115. package/dist/_internal/ir-checks/advances.js +6 -0
  116. package/dist/_internal/ir-checks/agent-reads.d.ts +14 -0
  117. package/dist/_internal/ir-checks/agent-reads.js +118 -0
  118. package/dist/_internal/ir-checks/amendments.d.ts +3 -0
  119. package/dist/_internal/ir-checks/amendments.js +21 -0
  120. package/dist/_internal/ir-checks/canonical-json.d.ts +3 -0
  121. package/dist/_internal/ir-checks/canonical-json.js +85 -0
  122. package/dist/_internal/ir-checks/child-parameters.d.ts +2 -0
  123. package/dist/_internal/ir-checks/child-parameters.js +43 -0
  124. package/dist/_internal/ir-checks/clock-bindings.d.ts +3 -0
  125. package/dist/_internal/ir-checks/clock-bindings.js +43 -0
  126. package/dist/_internal/ir-checks/collect-types.d.ts +14 -0
  127. package/dist/_internal/ir-checks/collect-types.js +34 -0
  128. package/dist/_internal/ir-checks/component-operations.d.ts +4 -0
  129. package/dist/_internal/ir-checks/component-operations.js +23 -0
  130. package/dist/_internal/ir-checks/content-digest.d.ts +4 -0
  131. package/dist/_internal/ir-checks/content-digest.js +78 -0
  132. package/dist/_internal/ir-checks/contract-validation.d.ts +3 -0
  133. package/dist/_internal/ir-checks/contract-validation.js +307 -0
  134. package/dist/_internal/ir-checks/contracts.d.ts +25 -0
  135. package/dist/_internal/ir-checks/contracts.js +80 -0
  136. package/dist/_internal/ir-checks/dates.d.ts +2 -0
  137. package/dist/_internal/ir-checks/dates.js +7 -0
  138. package/dist/_internal/ir-checks/documents.d.ts +3 -0
  139. package/dist/_internal/ir-checks/documents.js +45 -0
  140. package/dist/_internal/ir-checks/evidence.d.ts +20 -0
  141. package/dist/_internal/ir-checks/evidence.js +56 -0
  142. package/dist/_internal/ir-checks/files.d.ts +7 -0
  143. package/dist/_internal/ir-checks/files.js +47 -0
  144. package/dist/_internal/ir-checks/index.d.ts +59 -0
  145. package/dist/_internal/ir-checks/index.js +166 -0
  146. package/dist/_internal/ir-checks/instants.d.ts +7 -0
  147. package/dist/_internal/ir-checks/instants.js +61 -0
  148. package/dist/_internal/ir-checks/notices.d.ts +4 -0
  149. package/dist/_internal/ir-checks/notices.js +58 -0
  150. package/dist/_internal/ir-checks/policy-bounds.d.ts +5 -0
  151. package/dist/_internal/ir-checks/policy-bounds.js +28 -0
  152. package/dist/_internal/ir-checks/principals.d.ts +26 -0
  153. package/dist/_internal/ir-checks/principals.js +162 -0
  154. package/dist/_internal/ir-checks/prior-cycle.d.ts +41 -0
  155. package/dist/_internal/ir-checks/prior-cycle.js +21 -0
  156. package/dist/_internal/ir-checks/read-classification.d.ts +12 -0
  157. package/dist/_internal/ir-checks/read-classification.js +67 -0
  158. package/dist/_internal/ir-checks/read-types.d.ts +2 -0
  159. package/dist/_internal/ir-checks/read-types.js +40 -0
  160. package/dist/_internal/ir-checks/resource-proofs.d.ts +4 -0
  161. package/dist/_internal/ir-checks/resource-proofs.js +98 -0
  162. package/dist/_internal/ir-checks/resources.d.ts +3 -0
  163. package/dist/_internal/ir-checks/resources.js +30 -0
  164. package/dist/_internal/ir-checks/reuse.d.ts +10 -0
  165. package/dist/_internal/ir-checks/reuse.js +99 -0
  166. package/dist/_internal/ir-checks/sealing.d.ts +14 -0
  167. package/dist/_internal/ir-checks/sealing.js +123 -0
  168. package/dist/_internal/ir-checks/sensitive-flow.d.ts +4 -0
  169. package/dist/_internal/ir-checks/sensitive-flow.js +240 -0
  170. package/dist/_internal/ir-checks/sensitivity.d.ts +19 -0
  171. package/dist/_internal/ir-checks/sensitivity.js +133 -0
  172. package/dist/_internal/ir-checks/signatures.d.ts +4 -0
  173. package/dist/_internal/ir-checks/signatures.js +22 -0
  174. package/dist/_internal/ir-checks/vaults.d.ts +10 -0
  175. package/dist/_internal/ir-checks/vaults.js +140 -0
  176. package/dist/_internal/protocol/index.d.ts +1234 -0
  177. package/dist/_internal/protocol/index.js +215 -0
  178. package/dist/_internal/reconciler/action-intents.d.ts +17 -0
  179. package/dist/_internal/reconciler/action-intents.js +161 -0
  180. package/dist/_internal/reconciler/actions.d.ts +7 -0
  181. package/dist/_internal/reconciler/actions.js +134 -0
  182. package/dist/_internal/reconciler/amendments.d.ts +12 -0
  183. package/dist/_internal/reconciler/amendments.js +52 -0
  184. package/dist/_internal/reconciler/basis.d.ts +253 -0
  185. package/dist/_internal/reconciler/basis.js +16 -0
  186. package/dist/_internal/reconciler/bundles.d.ts +22 -0
  187. package/dist/_internal/reconciler/bundles.js +110 -0
  188. package/dist/_internal/reconciler/change-detection.d.ts +5 -0
  189. package/dist/_internal/reconciler/change-detection.js +82 -0
  190. package/dist/_internal/reconciler/collection-rules.d.ts +7 -0
  191. package/dist/_internal/reconciler/collection-rules.js +46 -0
  192. package/dist/_internal/reconciler/collection-state.d.ts +11 -0
  193. package/dist/_internal/reconciler/collection-state.js +62 -0
  194. package/dist/_internal/reconciler/collection-values.d.ts +5 -0
  195. package/dist/_internal/reconciler/collection-values.js +60 -0
  196. package/dist/_internal/reconciler/collections.d.ts +35 -0
  197. package/dist/_internal/reconciler/collections.js +141 -0
  198. package/dist/_internal/reconciler/commands.d.ts +60 -0
  199. package/dist/_internal/reconciler/commands.js +468 -0
  200. package/dist/_internal/reconciler/component-operations.d.ts +48 -0
  201. package/dist/_internal/reconciler/component-operations.js +256 -0
  202. package/dist/_internal/reconciler/context.d.ts +38 -0
  203. package/dist/_internal/reconciler/context.js +44 -0
  204. package/dist/_internal/reconciler/coverage.d.ts +31 -0
  205. package/dist/_internal/reconciler/coverage.js +124 -0
  206. package/dist/_internal/reconciler/dates.d.ts +38 -0
  207. package/dist/_internal/reconciler/dates.js +121 -0
  208. package/dist/_internal/reconciler/decide.d.ts +25 -0
  209. package/dist/_internal/reconciler/decide.js +263 -0
  210. package/dist/_internal/reconciler/decision-evaluation.d.ts +9 -0
  211. package/dist/_internal/reconciler/decision-evaluation.js +67 -0
  212. package/dist/_internal/reconciler/decision-records.d.ts +14 -0
  213. package/dist/_internal/reconciler/decision-records.js +77 -0
  214. package/dist/_internal/reconciler/decision-release.d.ts +3 -0
  215. package/dist/_internal/reconciler/decision-release.js +12 -0
  216. package/dist/_internal/reconciler/dependencies.d.ts +179 -0
  217. package/dist/_internal/reconciler/dependencies.js +372 -0
  218. package/dist/_internal/reconciler/discovery.d.ts +9 -0
  219. package/dist/_internal/reconciler/discovery.js +65 -0
  220. package/dist/_internal/reconciler/document-corrections.d.ts +18 -0
  221. package/dist/_internal/reconciler/document-corrections.js +59 -0
  222. package/dist/_internal/reconciler/documents.d.ts +26 -0
  223. package/dist/_internal/reconciler/documents.js +88 -0
  224. package/dist/_internal/reconciler/effective.d.ts +6 -0
  225. package/dist/_internal/reconciler/effective.js +17 -0
  226. package/dist/_internal/reconciler/escalations.d.ts +4 -0
  227. package/dist/_internal/reconciler/escalations.js +76 -0
  228. package/dist/_internal/reconciler/evaluation.d.ts +56 -0
  229. package/dist/_internal/reconciler/evaluation.js +704 -0
  230. package/dist/_internal/reconciler/evidence-authority.d.ts +6 -0
  231. package/dist/_internal/reconciler/evidence-authority.js +70 -0
  232. package/dist/_internal/reconciler/evidence-history.d.ts +5 -0
  233. package/dist/_internal/reconciler/evidence-history.js +22 -0
  234. package/dist/_internal/reconciler/evidence-validity.d.ts +17 -0
  235. package/dist/_internal/reconciler/evidence-validity.js +135 -0
  236. package/dist/_internal/reconciler/fact-validation.d.ts +5 -0
  237. package/dist/_internal/reconciler/fact-validation.js +49 -0
  238. package/dist/_internal/reconciler/files.d.ts +9 -0
  239. package/dist/_internal/reconciler/files.js +56 -0
  240. package/dist/_internal/reconciler/graph.d.ts +40 -0
  241. package/dist/_internal/reconciler/graph.js +298 -0
  242. package/dist/_internal/reconciler/holds.d.ts +6 -0
  243. package/dist/_internal/reconciler/holds.js +18 -0
  244. package/dist/_internal/reconciler/home-definitions.d.ts +11 -0
  245. package/dist/_internal/reconciler/home-definitions.js +25 -0
  246. package/dist/_internal/reconciler/homes.d.ts +6 -0
  247. package/dist/_internal/reconciler/homes.js +32 -0
  248. package/dist/_internal/reconciler/index.d.ts +42 -0
  249. package/dist/_internal/reconciler/index.js +58 -0
  250. package/dist/_internal/reconciler/instants.d.ts +17 -0
  251. package/dist/_internal/reconciler/instants.js +56 -0
  252. package/dist/_internal/reconciler/interaction-fields.d.ts +10 -0
  253. package/dist/_internal/reconciler/interaction-fields.js +30 -0
  254. package/dist/_internal/reconciler/invariants.d.ts +8 -0
  255. package/dist/_internal/reconciler/invariants.js +34 -0
  256. package/dist/_internal/reconciler/journal.d.ts +3 -0
  257. package/dist/_internal/reconciler/journal.js +4 -0
  258. package/dist/_internal/reconciler/linking.d.ts +10 -0
  259. package/dist/_internal/reconciler/linking.js +259 -0
  260. package/dist/_internal/reconciler/memory.d.ts +32 -0
  261. package/dist/_internal/reconciler/memory.js +190 -0
  262. package/dist/_internal/reconciler/milestones.d.ts +7 -0
  263. package/dist/_internal/reconciler/milestones.js +58 -0
  264. package/dist/_internal/reconciler/missing.d.ts +18 -0
  265. package/dist/_internal/reconciler/missing.js +79 -0
  266. package/dist/_internal/reconciler/model.d.ts +350 -0
  267. package/dist/_internal/reconciler/model.js +9 -0
  268. package/dist/_internal/reconciler/notices.d.ts +14 -0
  269. package/dist/_internal/reconciler/notices.js +80 -0
  270. package/dist/_internal/reconciler/occurrences.d.ts +3 -0
  271. package/dist/_internal/reconciler/occurrences.js +30 -0
  272. package/dist/_internal/reconciler/outputs.d.ts +12 -0
  273. package/dist/_internal/reconciler/outputs.js +132 -0
  274. package/dist/_internal/reconciler/parameters.d.ts +4 -0
  275. package/dist/_internal/reconciler/parameters.js +27 -0
  276. package/dist/_internal/reconciler/policies.d.ts +22 -0
  277. package/dist/_internal/reconciler/policies.js +94 -0
  278. package/dist/_internal/reconciler/policy-edits.d.ts +11 -0
  279. package/dist/_internal/reconciler/policy-edits.js +42 -0
  280. package/dist/_internal/reconciler/policy-linking.d.ts +4 -0
  281. package/dist/_internal/reconciler/policy-linking.js +104 -0
  282. package/dist/_internal/reconciler/principal-types.d.ts +2 -0
  283. package/dist/_internal/reconciler/principal-types.js +38 -0
  284. package/dist/_internal/reconciler/prior-decisions.d.ts +3 -0
  285. package/dist/_internal/reconciler/prior-decisions.js +34 -0
  286. package/dist/_internal/reconciler/projections.d.ts +4 -0
  287. package/dist/_internal/reconciler/projections.js +85 -0
  288. package/dist/_internal/reconciler/proofs.d.ts +9 -0
  289. package/dist/_internal/reconciler/proofs.js +24 -0
  290. package/dist/_internal/reconciler/properties.d.ts +25 -0
  291. package/dist/_internal/reconciler/properties.js +67 -0
  292. package/dist/_internal/reconciler/property-eval.d.ts +5 -0
  293. package/dist/_internal/reconciler/property-eval.js +101 -0
  294. package/dist/_internal/reconciler/property-generator.d.ts +9 -0
  295. package/dist/_internal/reconciler/property-generator.js +288 -0
  296. package/dist/_internal/reconciler/property-shrink.d.ts +14 -0
  297. package/dist/_internal/reconciler/property-shrink.js +183 -0
  298. package/dist/_internal/reconciler/provenance.d.ts +8 -0
  299. package/dist/_internal/reconciler/provenance.js +61 -0
  300. package/dist/_internal/reconciler/reconcile.d.ts +32 -0
  301. package/dist/_internal/reconciler/reconcile.js +164 -0
  302. package/dist/_internal/reconciler/recurrence.d.ts +9 -0
  303. package/dist/_internal/reconciler/recurrence.js +44 -0
  304. package/dist/_internal/reconciler/requirements.d.ts +5 -0
  305. package/dist/_internal/reconciler/requirements.js +331 -0
  306. package/dist/_internal/reconciler/resource-generation.d.ts +9 -0
  307. package/dist/_internal/reconciler/resource-generation.js +17 -0
  308. package/dist/_internal/reconciler/resource-scenarios.d.ts +26 -0
  309. package/dist/_internal/reconciler/resource-scenarios.js +78 -0
  310. package/dist/_internal/reconciler/resources.d.ts +24 -0
  311. package/dist/_internal/reconciler/resources.js +178 -0
  312. package/dist/_internal/reconciler/result-digest.d.ts +13 -0
  313. package/dist/_internal/reconciler/result-digest.js +66 -0
  314. package/dist/_internal/reconciler/reuse.d.ts +16 -0
  315. package/dist/_internal/reconciler/reuse.js +119 -0
  316. package/dist/_internal/reconciler/scenarios.d.ts +32 -0
  317. package/dist/_internal/reconciler/scenarios.js +442 -0
  318. package/dist/_internal/reconciler/scheduling.d.ts +9 -0
  319. package/dist/_internal/reconciler/scheduling.js +203 -0
  320. package/dist/_internal/reconciler/sha256.d.ts +1 -0
  321. package/dist/_internal/reconciler/sha256.js +1 -0
  322. package/dist/_internal/reconciler/signatures.d.ts +13 -0
  323. package/dist/_internal/reconciler/signatures.js +37 -0
  324. package/dist/_internal/reconciler/temporal.d.ts +10 -0
  325. package/dist/_internal/reconciler/temporal.js +46 -0
  326. package/dist/_internal/reconciler/upgrades.d.ts +6 -0
  327. package/dist/_internal/reconciler/upgrades.js +65 -0
  328. package/dist/_internal/reconciler/wire.d.ts +2 -0
  329. package/dist/_internal/reconciler/wire.js +5 -0
  330. package/dist/_internal/reconciler/work.d.ts +32 -0
  331. package/dist/_internal/reconciler/work.js +101 -0
  332. package/dist/_internal/world-ir/schema.generated.d.ts +180 -0
  333. package/dist/_internal/world-ir/schema.generated.js +1127 -0
  334. package/dist/_internal/world-ir/types.generated.d.ts +1011 -0
  335. package/dist/_internal/world-ir/types.generated.js +1 -0
  336. package/dist/authoring.d.ts +9 -0
  337. package/dist/authoring.js +10 -0
  338. package/dist/catalogue.d.ts +20 -0
  339. package/dist/catalogue.js +531 -0
  340. package/dist/cli.d.ts +2 -0
  341. package/dist/cli.js +553 -0
  342. package/dist/codegen.d.ts +6 -0
  343. package/dist/codegen.js +89 -0
  344. package/dist/coverage.d.ts +60 -0
  345. package/dist/coverage.js +128 -0
  346. package/dist/deploy.d.ts +21 -0
  347. package/dist/deploy.js +72 -0
  348. package/dist/diagnostics.d.ts +9 -0
  349. package/dist/diagnostics.js +37 -0
  350. package/dist/diff.d.ts +17 -0
  351. package/dist/diff.js +19 -0
  352. package/dist/durable-object.d.ts +14 -0
  353. package/dist/durable-object.js +30 -0
  354. package/dist/explain.d.ts +113 -0
  355. package/dist/explain.js +225 -0
  356. package/dist/fixes.d.ts +4 -0
  357. package/dist/fixes.js +70 -0
  358. package/dist/fmt.d.ts +12 -0
  359. package/dist/fmt.js +39 -0
  360. package/dist/handle/open.d.ts +18 -0
  361. package/dist/handle/open.js +28 -0
  362. package/dist/handle/protocol.d.ts +12 -0
  363. package/dist/handle/protocol.js +96 -0
  364. package/dist/handle/store.d.ts +31 -0
  365. package/dist/handle/store.js +11 -0
  366. package/dist/handle/types.d.ts +37 -0
  367. package/dist/handle/types.js +1 -0
  368. package/dist/handle/world.d.ts +190 -0
  369. package/dist/handle/world.js +533 -0
  370. package/dist/http.d.ts +3 -0
  371. package/dist/http.js +72 -0
  372. package/dist/impact.d.ts +21 -0
  373. package/dist/impact.js +57 -0
  374. package/dist/index.d.ts +30 -0
  375. package/dist/index.js +43 -0
  376. package/dist/init.d.ts +13 -0
  377. package/dist/init.js +99 -0
  378. package/dist/ir-schema.json +4213 -0
  379. package/dist/lints.d.ts +8 -0
  380. package/dist/lints.js +154 -0
  381. package/dist/lsp.d.ts +14 -0
  382. package/dist/lsp.js +380 -0
  383. package/dist/manual/catalog.d.ts +12 -0
  384. package/dist/manual/catalog.js +23 -0
  385. package/dist/manual/examples.d.ts +15 -0
  386. package/dist/manual/examples.js +39 -0
  387. package/dist/manual/projections.d.ts +77 -0
  388. package/dist/manual/projections.js +344 -0
  389. package/dist/manual/prose.d.ts +19 -0
  390. package/dist/manual/prose.js +215 -0
  391. package/dist/manual/render.d.ts +76 -0
  392. package/dist/manual/render.js +250 -0
  393. package/dist/manual/text.d.ts +7 -0
  394. package/dist/manual/text.js +15 -0
  395. package/dist/mcp.d.ts +32 -0
  396. package/dist/mcp.js +269 -0
  397. package/dist/mutate.d.ts +36 -0
  398. package/dist/mutate.js +123 -0
  399. package/dist/project.d.ts +26 -0
  400. package/dist/project.js +80 -0
  401. package/dist/refine.d.ts +18 -0
  402. package/dist/refine.js +197 -0
  403. package/dist/release/diff.d.ts +45 -0
  404. package/dist/release/diff.js +103 -0
  405. package/dist/release/impact.d.ts +83 -0
  406. package/dist/release/impact.js +214 -0
  407. package/dist/release/nodes.d.ts +20 -0
  408. package/dist/release/nodes.js +118 -0
  409. package/dist/render.d.ts +19 -0
  410. package/dist/render.js +43 -0
  411. package/dist/serve.d.ts +18 -0
  412. package/dist/serve.js +140 -0
  413. package/dist/snapshot.d.ts +19 -0
  414. package/dist/snapshot.js +45 -0
  415. package/dist/sqlite.d.ts +16 -0
  416. package/dist/sqlite.js +151 -0
  417. package/dist/test.d.ts +54 -0
  418. package/dist/test.js +131 -0
  419. package/dist/world.d.ts +7 -0
  420. package/dist/world.js +5 -0
  421. package/docs/authoring/vendor-risk/example.forma +11 -0
  422. package/docs/authoring/vendor-risk/library/vendor.forma +76 -0
  423. package/docs/authoring/vendor-risk/scenarios/reviews.forma +107 -0
  424. package/docs/protocol.md +195 -0
  425. package/docs/reference.md +258 -0
  426. package/package.json +81 -3
@@ -0,0 +1,183 @@
1
+ import { sensitivePayload, semanticJson } from "../ir-checks/index.js";
2
+ import { runScenario } from "./scenarios.js";
3
+ import { evaluateProperty } from "./property-eval.js";
4
+ import { Unknown } from "./reconcile.js";
5
+ const size = (s) => s.given.reduce((n, e) => n + 1 + e.fields.length, 0) + (s.records?.length ?? 0);
6
+ const uses = (v, name) => v.k === "entity"
7
+ ? v.name === name
8
+ : v.k === "literal"
9
+ ? v.value === name
10
+ : v.key.some((k) => uses(k, name));
11
+ const withoutEntity = (s, name) => ({
12
+ ...s,
13
+ given: s.given
14
+ .filter((e) => e.name !== name)
15
+ .map((e) => ({ ...e, fields: e.fields.filter((f) => !uses(f.value, name)) })),
16
+ ...(s.records
17
+ ? {
18
+ records: s.records.filter((r) => !uses(r.by, name) &&
19
+ !r.target.key.some((v) => uses(v, name)) &&
20
+ !(r.kind === "evidence" && r.values.some((f) => uses(f.value, name)))),
21
+ }
22
+ : {}),
23
+ });
24
+ const render = (ir, property, scenario, binding) => {
25
+ const aliases = new Map(ir.types.map((t) => [t.name, t.type]));
26
+ const resolve = (t, seen = new Set()) => {
27
+ if (Array.isArray(t)) {
28
+ const payload = sensitivePayload(t);
29
+ return payload
30
+ ? resolve(payload, seen)
31
+ : t[0] === "Option" || t[0] === "Brand"
32
+ ? resolve(t[1], seen)
33
+ : t;
34
+ }
35
+ if (typeof t !== "string" || !aliases.has(t) || seen.has(t))
36
+ return t;
37
+ seen.add(t);
38
+ return resolve(aliases.get(t), seen);
39
+ };
40
+ const value = (v, expected) => {
41
+ if (v.k === "entity")
42
+ return v.name;
43
+ if (v.k === "instance")
44
+ return instance(v);
45
+ if (v.value === null)
46
+ return "nil";
47
+ const type = resolve(expected);
48
+ if (Array.isArray(type) && type[0] === "Id")
49
+ return String(v.value);
50
+ if (type === "Keyword" || (Array.isArray(type) && type[0] === "Union"))
51
+ return `:${v.value}`;
52
+ return JSON.stringify(v.value);
53
+ };
54
+ const instance = (target) => {
55
+ const c = ir.components.find((c) => c.name === target.component);
56
+ return `(${target.component} ${target.key.map((v, i) => value(v, c.inputs.find((f) => f.name === c.key[i]).type)).join(" ")}${target.cycle === undefined ? "" : ` :cycle ${target.cycle}`})`;
57
+ };
58
+ const fields = (data, declared) => `{${data.map((f) => `:${f.name} ${value(f.value, declared.find((d) => d.name === f.name).type)}`).join(" ")}}`;
59
+ const rows = scenario.given.map((e) => `(entity ${e.entity} ${e.name} ${fields(e.fields, ir.entities.find((t) => t.name === e.entity).fields)})`);
60
+ for (const r of scenario.records ?? []) {
61
+ const by = r.by.k === "entity"
62
+ ? r.by.name
63
+ : r.by.k === "literal"
64
+ ? JSON.stringify(r.by.value)
65
+ : (() => {
66
+ throw new Error("Invalid generated actor");
67
+ })();
68
+ const on = r.date ? ` :on ${JSON.stringify(r.date)}` : "";
69
+ rows.push(r.kind === "signal"
70
+ ? `(signal ${instance(r.target)} ${r.machine} :state :${r.state} :by ${by}${on})`
71
+ : `(evidence ${r.evidence} :for ${instance(r.target)} :requirement ${r.requirement} :status :${r.status} :by ${by}${on} :values ${fields(r.values, ir.evidence.find((e) => e.name === r.evidence).fields)})`);
72
+ }
73
+ const lines = [
74
+ `(scenario ${scenario.name} ${JSON.stringify(scenario.doc ?? "Synthetic counterexample.")} :world ${scenario.world}`,
75
+ ...rows.map((row, i) => `${i === 0 ? " (given " : " "}${row}${i === rows.length - 1 ? ")" : ""}`),
76
+ ` (at ${JSON.stringify(property.date)} (expect (property ${property.name} :for ${binding}) true)))`,
77
+ ];
78
+ if (!property.given && lines.length > 10)
79
+ throw new Error("Counterexample exceeds the bounded eight-record input contract.");
80
+ return lines.join("\n") + "\n";
81
+ };
82
+ /** Greedy deletion preserves the selected failure class; retained evidence payloads stay intact. */
83
+ export const shrinkPropertyFailure = (ir, property, failure, options = {}) => {
84
+ const max = options.maxAttempts ?? 10000;
85
+ if (!Number.isSafeInteger(max) || max < 1 || max > 100000)
86
+ throw new RangeError("Shrink attempts must be 1–100000.");
87
+ let current = failure.scenario, attempts = 0, limited = false;
88
+ const reproduces = (input) => {
89
+ if (property.given?.some((seed) => {
90
+ const entity = input.given.find((e) => e.name === seed.name && e.entity === seed.entity);
91
+ return (!entity ||
92
+ seed.fields.some((field) => !entity.fields.some((f) => semanticJson(f) === semanticJson(field))));
93
+ }) ||
94
+ property.records?.some((seed) => !input.records?.some((r) => semanticJson(r) === semanticJson(seed))))
95
+ return false;
96
+ if (!input.given.some((e) => e.name === failure.binding && e.entity === property.binding.entity))
97
+ return false;
98
+ const observed = runScenario(ir, input);
99
+ if (!observed.passed || !observed.steps[0])
100
+ return false;
101
+ const result = evaluateProperty(property, observed.world, observed.steps[0].reconciliation, failure.binding);
102
+ return result !== true && (result instanceof Unknown ? "Unknown" : "false") === failure.actual;
103
+ };
104
+ if (!reproduces(current))
105
+ throw new Error("Input does not reproduce the selected property failure.");
106
+ const keep = (candidate) => {
107
+ if (attempts >= max) {
108
+ limited = true;
109
+ return false;
110
+ }
111
+ attempts++;
112
+ if (!reproduces(candidate))
113
+ return false;
114
+ current = candidate;
115
+ return true;
116
+ };
117
+ while (!limited) {
118
+ let changed = false;
119
+ for (let i = 0; i < (current.records?.length ?? 0); i++) {
120
+ if (keep({ ...current, records: current.records.filter((_, j) => j !== i) })) {
121
+ changed = true;
122
+ break;
123
+ }
124
+ }
125
+ if (changed)
126
+ continue;
127
+ for (const e of current.given) {
128
+ if (e.name !== failure.binding && keep(withoutEntity(current, e.name))) {
129
+ changed = true;
130
+ break;
131
+ }
132
+ }
133
+ if (changed)
134
+ continue;
135
+ for (const e of current.given) {
136
+ for (let i = 0; i < e.fields.length; i++) {
137
+ if (keep({
138
+ ...current,
139
+ given: current.given.map((x) => x.name === e.name ? { ...x, fields: x.fields.filter((_, j) => j !== i) } : x),
140
+ })) {
141
+ changed = true;
142
+ break;
143
+ }
144
+ }
145
+ if (changed)
146
+ break;
147
+ }
148
+ if (!changed)
149
+ break;
150
+ }
151
+ let name = `counterexample-${property.name}-${failure.seed}-${failure.index}`;
152
+ while (ir.scenarios?.some((s) => s.name === name))
153
+ name += "-replay";
154
+ const scenario = {
155
+ ...current,
156
+ name,
157
+ doc: `Synthetic seed ${failure.seed}, case ${failure.index}, ${failure.actual}.`,
158
+ steps: [
159
+ {
160
+ kind: "at",
161
+ date: property.date,
162
+ expects: [
163
+ {
164
+ kind: "property",
165
+ name: property.name,
166
+ binding: failure.binding,
167
+ expected: true,
168
+ at: property.predicate.at,
169
+ },
170
+ ],
171
+ at: property.at,
172
+ },
173
+ ],
174
+ };
175
+ return {
176
+ scenario,
177
+ source: render(ir, property, scenario, failure.binding),
178
+ attempts,
179
+ complete: !limited,
180
+ originalSize: size(failure.scenario),
181
+ shrunkSize: size(scenario),
182
+ };
183
+ };
@@ -0,0 +1,8 @@
1
+ import type { Basis } from "./basis.js";
2
+ import { ReadSet, type Dependency } from "./dependencies.js";
3
+ import type { Instance, Program, WorldReconciliation } from "./reconcile.js";
4
+ /** Internal projections can be provisional during discovery. Retain their Basis reads instead. */
5
+ export declare const structuralObservation: (d: Dependency) => boolean;
6
+ /** Reconstruct the indexed discovery closure for each home, independently of whole-world root
7
+ * enumeration. Excluded candidate roots matter: changing their predicates may add a member. */
8
+ export declare const discoveryProvenance: (b: Basis, instances: ReadonlyMap<string, Instance>, roots: WorldReconciliation["roots"], observations: ReadonlyMap<string, ReadSet>, homeOf: (p: Program, inst: Instance) => string | undefined) => ((p: Program, home: string) => ReadonlyMap<string, Dependency>);
@@ -0,0 +1,61 @@
1
+ import { ReadSet, observeBasis, programDependency } from "./dependencies.js";
2
+ import { rootCandidates } from "./discovery.js";
3
+ /** Internal projections can be provisional during discovery. Retain their Basis reads instead. */
4
+ export const structuralObservation = (d) => d.kind !== "input" && d.kind !== "members" && d.kind !== "status" && d.kind !== "slot";
5
+ /** Reconstruct the indexed discovery closure for each home, independently of whole-world root
6
+ * enumeration. Excluded candidate roots matter: changing their predicates may add a member. */
7
+ export const discoveryProvenance = (b, instances, roots, observations, homeOf) => {
8
+ const rootKey = (account, component, subject) => JSON.stringify([account, component, subject]);
9
+ const byRoot = new Map();
10
+ for (const root of roots) {
11
+ const inst = instances.get(root.instance);
12
+ const key = rootKey(root.account, inst.component, root.subject);
13
+ const ids = byRoot.get(key) ?? [];
14
+ ids.push(inst.id);
15
+ byRoot.set(key, ids);
16
+ }
17
+ const plans = new Map();
18
+ const homes = new Map();
19
+ return (p, home) => {
20
+ let cached = homes.get(p);
21
+ if (!cached)
22
+ homes.set(p, (cached = new Map()));
23
+ const found = cached.get(home);
24
+ if (found)
25
+ return found;
26
+ let seeds = plans.get(p);
27
+ if (!seeds)
28
+ plans.set(p, (seeds = new Map()));
29
+ const reads = new ReadSet();
30
+ reads.add(programDependency(p));
31
+ const pending = new Set([home]);
32
+ const visited = new Set();
33
+ for (const target of pending) {
34
+ let plan = seeds.get(target);
35
+ if (!plan) {
36
+ const observed = new ReadSet();
37
+ const candidates = rootCandidates(p, observeBasis(b, observed), target);
38
+ plan = { candidates, reads: observed.snapshot() };
39
+ seeds.set(target, plan);
40
+ }
41
+ reads.merge(plan.reads);
42
+ const queue = plan.candidates.flatMap((r) => byRoot.get(rootKey(p.account.name, r.component, r.subject)) ?? []);
43
+ for (let cursor = 0; cursor < queue.length; cursor++) {
44
+ const id = queue[cursor];
45
+ if (visited.has(id))
46
+ continue;
47
+ visited.add(id);
48
+ const inst = instances.get(id);
49
+ reads.merge(observations.get(id).entries());
50
+ const owner = homeOf(p, inst);
51
+ if (owner !== undefined)
52
+ pending.add(owner);
53
+ for (const slot of inst.children)
54
+ queue.push(...slot.instances);
55
+ }
56
+ }
57
+ const result = reads.snapshot();
58
+ cached.set(home, result);
59
+ return result;
60
+ };
61
+ };
@@ -0,0 +1,32 @@
1
+ import { type Basis } from "./basis.js";
2
+ import { type TimePoint } from "./instants.js";
3
+ import { type Program, type SubjectHome, type SubjectReconciliation, type WorldReconciliation } from "./model.js";
4
+ export declare const reconcile: (programs: readonly Program[], b: Basis, now?: TimePoint) => WorldReconciliation;
5
+ /** Evaluate one home and its synchronous read closure. Only that home's occurrences escape. */
6
+ export declare const reconcileSubject: (p: Program, b: Basis, subject: string | SubjectHome, now?: TimePoint) => SubjectReconciliation;
7
+ /** The program an instance was reconciled under. */
8
+ export declare const programFor: (recon: WorldReconciliation, instance: string) => Program | undefined;
9
+ /** Every started machine, its state, and the transitions its protocol allows next. */
10
+ export declare const machines: (recon: WorldReconciliation, b: Basis, now?: TimePoint) => {
11
+ readonly instance: string;
12
+ readonly machine: string;
13
+ readonly signal: string;
14
+ readonly state: {
15
+ readonly name: string;
16
+ readonly label: string;
17
+ };
18
+ readonly next: ReadonlyArray<{
19
+ readonly name: string;
20
+ readonly label: string;
21
+ }>;
22
+ }[];
23
+ /** How each entity presents itself: its declared :display field, else its id. */
24
+ export declare const displayNames: (programs: readonly Program[], b: Basis, now?: TimePoint) => Map<string, string>;
25
+ export { Unknown, type ActionResult, type InteractionField, type ChildSlot, type HoldResult, type MilestoneResult, type Duration, type EscalationIntent, type EscalationResult, type Instance, type InstRef, type OutputResult, type Program, type ReasonNode, type Reconciliation, type RequirementResult, type RenewalResult, type RecurrencePeriod, type Status, type Step, type SubjectHome, type SubjectReconciliation, type Truth, type UpgradeConsequence, type Value, type WorkIntent, type Violation, type WorldReconciliation, } from "./model.js";
26
+ export { link, linkAll, LinkError } from "./linking.js";
27
+ export { allOf, anyOf } from "./outputs.js";
28
+ export { canonicalDecision, digest, proofOf, verifyProof } from "./proofs.js";
29
+ export { canTransition, describeValue, evaluateFor, evaluateIn, evaluateValues, machineState, } from "./evaluation.js";
30
+ export { occurrenceHome } from "./homes.js";
31
+ export { admit } from "./invariants.js";
32
+ export { planUpgrade } from "./upgrades.js";
@@ -0,0 +1,164 @@
1
+ import {} from "./basis.js";
2
+ import { createEvaluationContext } from "./context.js";
3
+ import {} from "./instants.js";
4
+ import { ReadSet } from "./dependencies.js";
5
+ import { rootCandidates } from "./discovery.js";
6
+ import { assertSnapshot, machineState } from "./evaluation.js";
7
+ import { buildInstanceGraph } from "./graph.js";
8
+ import { entityHomes, occurrenceHome } from "./homes.js";
9
+ import { assertFiniteClock } from "./linking.js";
10
+ import {} from "./model.js";
11
+ import { finishReconciliation } from "./projections.js";
12
+ import { discoveryProvenance, structuralObservation } from "./provenance.js";
13
+ import { evaluate } from "./requirements.js";
14
+ import { nextWake } from "./temporal.js";
15
+ export const reconcile = (programs, b, now = b.now) => reconcileKernel(programs, b, now);
16
+ /** Evaluate one home and its synchronous read closure. Only that home's occurrences escape. */
17
+ export const reconcileSubject = (p, b, subject, now = b.now) => {
18
+ assertSnapshot(b, now);
19
+ entityHomes(p);
20
+ assertFiniteClock(p.ir);
21
+ const home = typeof subject === "string" ? { kind: "entity", id: subject } : subject;
22
+ const members = new Map();
23
+ const visited = new Set();
24
+ const add = (root) => {
25
+ let ids = members.get(root.component);
26
+ if (!ids)
27
+ members.set(root.component, (ids = new Set()));
28
+ if (ids.has(root.subject))
29
+ return false;
30
+ ids.add(root.subject);
31
+ return true;
32
+ };
33
+ const include = (target) => {
34
+ const key = target.id;
35
+ if (visited.has(key))
36
+ return false;
37
+ visited.add(key);
38
+ const roots = rootCandidates(p, b, target.id);
39
+ let changed = false;
40
+ for (const root of roots)
41
+ changed = add(root) || changed;
42
+ return changed;
43
+ };
44
+ include(home);
45
+ let graph = new Map();
46
+ const scope = {
47
+ home,
48
+ reads: new ReadSet(),
49
+ subjects: (component, namespaces) => [...(members.get(component) ?? [])]
50
+ .filter((id) => namespaces.includes(b.nsOf(id) ?? ""))
51
+ .sort(),
52
+ complete: (instances) => {
53
+ graph = instances;
54
+ let changed = false;
55
+ for (const inst of instances.values()) {
56
+ const target = occurrenceHome(p, inst, instances);
57
+ if (target)
58
+ changed = include(target) || changed;
59
+ }
60
+ return !changed;
61
+ },
62
+ select: (inst) => {
63
+ const target = occurrenceHome(p, inst, graph);
64
+ return target?.id === home.id;
65
+ },
66
+ };
67
+ while (true) {
68
+ const result = reconcileKernel([p], b, now, scope);
69
+ if (result) {
70
+ const dependsOn = scope.reads.snapshot();
71
+ return {
72
+ ...result,
73
+ home,
74
+ dependsOn,
75
+ ...nextWake(dependsOn.values(), now),
76
+ ...([...p.components.values()].some((c) => c.resources?.length) &&
77
+ [...graph.values()].some((i) => i.children.some((s) => s.applies === "unknown"))
78
+ ? { applicabilityUnknown: true }
79
+ : {}),
80
+ };
81
+ }
82
+ }
83
+ };
84
+ /** The program an instance was reconciled under. */
85
+ export const programFor = (recon, instance) => {
86
+ const inst = recon.instances.get(instance);
87
+ return inst ? recon.programs.find((p) => p.account.name === inst.account) : undefined;
88
+ };
89
+ /** Every started machine, its state, and the transitions its protocol allows next. */
90
+ export const machines = (recon, b, now = b.now) => {
91
+ assertSnapshot(b, now);
92
+ const out = [];
93
+ for (const inst of recon.instances.values()) {
94
+ const p = programFor(recon, inst.id);
95
+ for (const use of p.components.get(inst.component).machines) {
96
+ const protocol = p.machines.get(use.protocol);
97
+ const state = machineState(b, inst.id, use.name);
98
+ if (!protocol || state === null)
99
+ continue;
100
+ const label = (name) => protocol.states.find((s) => s.name === name)?.label ?? name;
101
+ out.push({
102
+ instance: inst.id,
103
+ machine: use.name,
104
+ signal: protocol.signal,
105
+ state: { name: state, label: label(state) },
106
+ next: protocol.transitions
107
+ .filter((t) => t.from === state)
108
+ .map((t) => ({ name: t.to, label: label(t.to) })),
109
+ });
110
+ }
111
+ }
112
+ return out;
113
+ };
114
+ /** How each entity presents itself: its declared :display field, else its id. */
115
+ export const displayNames = (programs, b, now = b.now) => {
116
+ assertSnapshot(b, now);
117
+ const names = new Map();
118
+ for (const id of b.entities()) {
119
+ const entity = programs.map((p) => p.entities.get(b.nsOf(id) ?? "")).find(Boolean);
120
+ const shown = entity?.display ? b.fact(id, `${entity.ns}/${entity.display}`)?.v : undefined;
121
+ names.set(id, shown === undefined ? id : String(shown));
122
+ }
123
+ return names;
124
+ };
125
+ const reconcileKernel = (programs, b, now = b.now, scope) => {
126
+ assertSnapshot(b, now);
127
+ for (const program of programs) {
128
+ entityHomes(program);
129
+ assertFiniteClock(program.ir);
130
+ }
131
+ const ctx = createEvaluationContext(programs, b, now, scope);
132
+ buildInstanceGraph(ctx);
133
+ if (ctx.scope && !ctx.scope.complete(ctx.instances))
134
+ return undefined;
135
+ const discoveryReads = discoveryProvenance(ctx.b, ctx.instances, ctx.roots, ctx.observations, (p, inst) => occurrenceHome(p, inst, ctx.instances)?.id);
136
+ for (const inst of ctx.instances.values())
137
+ if (!ctx.scope || ctx.scope.select(inst))
138
+ evaluate(ctx, inst);
139
+ // Finish current projections before probes can resolve a previously untaken reference.
140
+ let temporalCursor = 0, discoveryCursor = 0;
141
+ while (temporalCursor < ctx.temporalJobs.length || discoveryCursor < ctx.discoveryJobs.length) {
142
+ while (temporalCursor < ctx.temporalJobs.length)
143
+ ctx.temporalJobs[temporalCursor++]();
144
+ if (discoveryCursor < ctx.discoveryJobs.length)
145
+ ctx.discoveryJobs[discoveryCursor++]();
146
+ }
147
+ ctx.temporalJobs.length = 0;
148
+ ctx.discoveryJobs.length = 0;
149
+ for (const [id, reads] of ctx.discoveryReadSets)
150
+ ctx.observations.get(id).merge(reads.entries(), structuralObservation);
151
+ const result = finishReconciliation(ctx, discoveryReads);
152
+ return ctx.state.uncertainMembership &&
153
+ programs.some((p) => [...p.components.values()].some((c) => c.resources?.length))
154
+ ? { ...result, applicabilityUnknown: true }
155
+ : result;
156
+ };
157
+ export { Unknown, } from "./model.js";
158
+ export { link, linkAll, LinkError } from "./linking.js";
159
+ export { allOf, anyOf } from "./outputs.js";
160
+ export { canonicalDecision, digest, proofOf, verifyProof } from "./proofs.js";
161
+ export { canTransition, describeValue, evaluateFor, evaluateIn, evaluateValues, machineState, } from "./evaluation.js";
162
+ export { occurrenceHome } from "./homes.js";
163
+ export { admit } from "./invariants.js";
164
+ export { planUpgrade } from "./upgrades.js";
@@ -0,0 +1,9 @@
1
+ import type * as IR from "../world-ir/types.generated.js";
2
+ import type { Cx, RecurrencePeriod, Truth } from "./model.js";
3
+ export interface RecurrenceRead {
4
+ readonly truth: Truth;
5
+ readonly period: RecurrencePeriod | null;
6
+ readonly reason: string;
7
+ }
8
+ /** Calculate from the original anchor: leap-day clamping must not accumulate drift. */
9
+ export declare const readRecurrence: (cx: Cx, recurrence: IR.Recurrence) => RecurrenceRead;
@@ -0,0 +1,44 @@
1
+ import { localDateAt } from "./instants.js";
2
+ import { isLocalDate as date } from "../ir-checks/index.js";
3
+ import { addDays, addYears, daysBetween } from "./dates.js";
4
+ import { evaluateIn, isUnknown } from "./evaluation.js";
5
+ /** Calculate from the original anchor: leap-day clamping must not accumulate drift. */
6
+ export const readRecurrence = (cx, recurrence) => {
7
+ const anchor = evaluateIn(cx, recurrence.from), now = localDateAt(cx.b.now);
8
+ if (isUnknown(anchor) || !date(anchor))
9
+ return {
10
+ truth: "unknown",
11
+ period: null,
12
+ reason: isUnknown(anchor) ? anchor.why : "Recurrence anchor is not a valid local date",
13
+ };
14
+ if (now < anchor) {
15
+ cx.temporal?.add(anchor);
16
+ return { truth: false, period: null, reason: `Starts on ${anchor}` };
17
+ }
18
+ const { n, unit } = recurrence.every;
19
+ if (!Number.isSafeInteger(n) || n <= 0 || (unit !== "days" && unit !== "years"))
20
+ return { truth: "unknown", period: null, reason: "Invalid recurrence interval" };
21
+ const shift = (index) => {
22
+ try {
23
+ const result = unit === "years" ? addYears(anchor, index * n) : addDays(anchor, index * n);
24
+ return date(result) ? result : null;
25
+ }
26
+ catch {
27
+ return null;
28
+ }
29
+ };
30
+ let index = unit === "years"
31
+ ? Math.floor((Number(now.slice(0, 4)) - Number(anchor.slice(0, 4))) / n)
32
+ : Math.floor(daysBetween(anchor, now) / n);
33
+ let start = shift(index);
34
+ if (start > now)
35
+ start = shift(--index);
36
+ const next = shift(index + 1);
37
+ if (next)
38
+ cx.temporal?.add(next);
39
+ return {
40
+ truth: true,
41
+ period: { index, start, next },
42
+ reason: `Period ${index + 1} starts on ${start}`,
43
+ };
44
+ };
@@ -0,0 +1,5 @@
1
+ import { type EvaluationContext } from "./context.js";
2
+ import type * as IR from "../world-ir/types.generated.js";
3
+ import { type Cx, type EvaluationResult, type Instance, type RequirementResult } from "./model.js";
4
+ export declare function evaluate(ctx: EvaluationContext, inst: Instance): EvaluationResult;
5
+ export declare const evaluateRequirements: (ctx: EvaluationContext, inst: Instance, baseCx: Cx, component: IR.Component, partial: Map<string, RequirementResult>) => RequirementResult[];