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,34 @@
1
+ import {} from "./basis.js";
2
+ import {} from "./dates.js";
3
+ import { assertSnapshot, evaluateIn, instanceContext, machineState } from "./evaluation.js";
4
+ import {} from "./model.js";
5
+ /** Would a command of `kind` against `subject` violate a declared invariant at `now`? */
6
+ export const admit = (recon, b, now, command) => {
7
+ assertSnapshot(b, now);
8
+ const violations = [];
9
+ for (const inst of recon.instances.values()) {
10
+ const p = recon.programs.find((x) => x.account.name === inst.account);
11
+ const component = p.components.get(inst.component);
12
+ if (!component.invariants.length)
13
+ continue;
14
+ const cx = instanceContext(recon, b, inst);
15
+ for (const invariant of component.invariants) {
16
+ if (invariant.forbids.action !== command.kind)
17
+ continue;
18
+ if (evaluateIn(cx, invariant.forbids.subject) !== command.subject)
19
+ continue;
20
+ if (evaluateIn(cx, invariant.while) !== true)
21
+ continue;
22
+ const states = component.machines
23
+ .map((m) => machineState(b, inst.id, m.name))
24
+ .filter(Boolean);
25
+ violations.push({
26
+ instance: inst.id,
27
+ invariant: invariant.name,
28
+ reason: `${invariant.name} holds while ${inst.id} is ${states.join(", ")}`,
29
+ at: invariant.at,
30
+ });
31
+ }
32
+ }
33
+ return violations;
34
+ };
@@ -0,0 +1,3 @@
1
+ import type { JournalEntry } from "./basis.js";
2
+ import type { World } from "./memory.js";
3
+ export declare const log: (world: World, entry: Omit<JournalEntry, "id">) => World;
@@ -0,0 +1,4 @@
1
+ export const log = (world, entry) => ({
2
+ ...world,
3
+ journal: [...world.journal, { ...entry, id: `tx-${world.journal.length + 1}` }],
4
+ });
@@ -0,0 +1,10 @@
1
+ import type * as IR from "../world-ir/types.generated.js";
2
+ import { type Program } from "./model.js";
3
+ export declare class LinkError extends Error {
4
+ }
5
+ export declare const finiteClocks: WeakSet<IR.WorldIR>;
6
+ export declare const assertFiniteClock: (ir: IR.WorldIR) => void;
7
+ export declare const rewrite: <T>(value: T, f: (expr: IR.Expr) => IR.Expr | undefined) => T;
8
+ export declare const link: (ir: IR.WorldIR, accountName: string) => Program;
9
+ /** Every account in a compiled IR, linked. */
10
+ export declare const linkAll: (ir: IR.WorldIR) => Program[];
@@ -0,0 +1,259 @@
1
+ import { agentReadDiagnostics } from "../ir-checks/index.js";
2
+ import { sensitivityDiagnostics } from "../ir-checks/index.js";
3
+ import { vaultDiagnostics } from "../ir-checks/index.js";
4
+ import { resourceProofDiagnostics } from "../ir-checks/index.js";
5
+ import { amendmentDiagnostics } from "../ir-checks/index.js";
6
+ import { resourceDiagnostics } from "../ir-checks/index.js";
7
+ import { signatureDiagnostics } from "../ir-checks/index.js";
8
+ import { noticeDiagnostics } from "../ir-checks/index.js";
9
+ import { documentDiagnostics } from "../ir-checks/index.js";
10
+ import { fileFieldDiagnostics } from "../ir-checks/index.js";
11
+ import { childParameterDiagnostics } from "../ir-checks/index.js";
12
+ import { componentContractDiagnostics } from "../ir-checks/index.js";
13
+ import { advanceTargets, stableWorkIdentity, reuseProblem } from "../ir-checks/index.js";
14
+ import { withReuseDecisions } from "./reuse.js";
15
+ import { policyRelease, validatePolicies } from "./policy-linking.js";
16
+ import { evidenceScopeDiagnostics, finiteTimeDiagnostics, instantLiteralDiagnostics, clockBindingDiagnostics, } from "../ir-checks/index.js";
17
+ import { makeCalendar } from "./dates.js";
18
+ import { constant } from "./evaluation.js";
19
+ import {} from "./model.js";
20
+ import { withPriorDecisions } from "./prior-decisions.js";
21
+ import { withPrincipalKinds } from "./principal-types.js";
22
+ import { sha256 } from "./sha256.js";
23
+ export class LinkError extends Error {
24
+ }
25
+ export const finiteClocks = new WeakSet();
26
+ // Only successful byte-identical authored content may reuse publish validation.
27
+ // Bound fingerprints without retaining IRs; account binding/policy checks still run.
28
+ const validatedSources = new Set();
29
+ // Canonical source/account inputs determine the outgoing bytes. Retain only expected
30
+ // digests, never shared runtime views; incoming objects are still fingerprinted each time.
31
+ const resolvedDigests = new Map();
32
+ const linkedSources = new WeakMap();
33
+ const fingerprint = (ir) => {
34
+ let reusable = true;
35
+ const bytes = JSON.stringify(ir, function (key, value) {
36
+ const prototype = value && typeof value === "object" ? Object.getPrototypeOf(value) : null;
37
+ if (this[key] !== value ||
38
+ (prototype !== null && prototype !== Object.prototype && !Array.isArray(value)) ||
39
+ value === undefined ||
40
+ typeof value === "function" ||
41
+ typeof value === "symbol" ||
42
+ (typeof value === "number" && !Number.isFinite(value)))
43
+ reusable = false;
44
+ return value;
45
+ });
46
+ return { digest: sha256(bytes), reusable };
47
+ };
48
+ export const assertFiniteClock = (ir) => {
49
+ if (finiteClocks.has(ir))
50
+ return;
51
+ const [diagnostic] = [
52
+ ...finiteTimeDiagnostics(ir),
53
+ ...evidenceScopeDiagnostics(ir),
54
+ ...instantLiteralDiagnostics(ir),
55
+ ...clockBindingDiagnostics(ir),
56
+ ];
57
+ if (diagnostic) {
58
+ const at = diagnostic.at;
59
+ throw new LinkError(`${diagnostic.code}: ${diagnostic.message}${at ? ` (${at.src}:${at.line}:${at.col})` : ""} ${diagnostic.help} Republish this model.`);
60
+ }
61
+ finiteClocks.add(ir);
62
+ };
63
+ export const rewrite = (value, f) => {
64
+ if (Array.isArray(value))
65
+ return value.map((v) => rewrite(v, f));
66
+ if (value && typeof value === "object") {
67
+ const replaced = "k" in value ? f(value) : undefined;
68
+ if (replaced)
69
+ return replaced;
70
+ return Object.fromEntries(Object.entries(value).map(([k, v]) => [k, k === "at" ? v : rewrite(v, f)]));
71
+ }
72
+ return value;
73
+ };
74
+ export const link = (ir, accountName) => {
75
+ // Relinking an unchanged owned result needs authored reads, including contract policy
76
+ // expressions. Never recover through an edited source/result or a raw-IR clone.
77
+ const authored = linkedSources.get(ir);
78
+ let source = fingerprint(ir);
79
+ if (authored && source.digest === authored.resolvedDigest) {
80
+ const original = fingerprint(authored.ir);
81
+ if (original.digest === authored.sourceDigest) {
82
+ ir = authored.ir;
83
+ source = original;
84
+ }
85
+ }
86
+ const sourceDigest = source.digest;
87
+ const sourceIR = ir;
88
+ if (!source.reusable || !validatedSources.has(sourceDigest)) {
89
+ const vaultError = vaultDiagnostics(ir).find((d) => d.severity === "error");
90
+ if (vaultError)
91
+ throw new LinkError(`${vaultError.code}: ${vaultError.message} ${vaultError.help}`);
92
+ const agentError = agentReadDiagnostics(ir)[0];
93
+ if (agentError)
94
+ throw new LinkError(`${agentError.code}: ${agentError.message} ${agentError.help}`);
95
+ const sensitive = sensitivityDiagnostics(ir)[0];
96
+ if (sensitive)
97
+ throw new LinkError(`${sensitive.code}: ${sensitive.message} ${sensitive.help}`);
98
+ const proofError = resourceProofDiagnostics(ir)[0];
99
+ if (proofError)
100
+ throw new LinkError(`${proofError.code}: ${proofError.message} ${proofError.help}`);
101
+ const resourceError = resourceDiagnostics(ir)[0];
102
+ if (resourceError)
103
+ throw new LinkError(`${resourceError.code}: ${resourceError.message} ${resourceError.help}`);
104
+ const amendmentError = amendmentDiagnostics(ir)[0];
105
+ if (amendmentError)
106
+ throw new LinkError(`${amendmentError.code}: ${amendmentError.message} ${amendmentError.help}`);
107
+ const signatureError = signatureDiagnostics(ir)[0];
108
+ if (signatureError)
109
+ throw new LinkError(`${signatureError.code}: ${signatureError.message} ${signatureError.help}`);
110
+ const noticeError = noticeDiagnostics(ir)[0];
111
+ if (noticeError)
112
+ throw new LinkError(`${noticeError.code}: ${noticeError.message} ${noticeError.help}`);
113
+ const documentError = documentDiagnostics(ir)[0];
114
+ if (documentError)
115
+ throw new LinkError(`${documentError.code}: ${documentError.message} ${documentError.help}`);
116
+ const fileError = fileFieldDiagnostics(ir)[0];
117
+ if (fileError)
118
+ throw new LinkError(`${fileError.code}: ${fileError.message} ${fileError.help}`);
119
+ const parameterError = childParameterDiagnostics(ir)[0];
120
+ if (parameterError)
121
+ throw new LinkError(`${parameterError.code}: ${parameterError.message} (${parameterError.at?.src}:${parameterError.at?.line}:${parameterError.at?.col}) ${parameterError.help}`);
122
+ const contractError = componentContractDiagnostics(ir)[0];
123
+ if (contractError)
124
+ throw new LinkError(`${contractError.code}: ${contractError.message} (${contractError.at?.src}:${contractError.at?.line}:${contractError.at?.col}) ${contractError.help}`);
125
+ if (source.reusable)
126
+ validatedSources.add(sourceDigest);
127
+ if (validatedSources.size > 64)
128
+ validatedSources.delete(validatedSources.values().next().value);
129
+ }
130
+ try {
131
+ ir = withPrincipalKinds(withPriorDecisions(withReuseDecisions(ir)));
132
+ }
133
+ catch (error) {
134
+ throw new LinkError(error instanceof Error ? error.message : String(error));
135
+ }
136
+ const account = ir.accounts.find((a) => a.name === accountName);
137
+ if (!account)
138
+ throw new LinkError(`No account ${accountName}`);
139
+ const pin = account.requires[0];
140
+ const library = ir.libraries.find((l) => l.name === pin?.library && l.version === pin?.version);
141
+ if (!library)
142
+ throw new LinkError(`${accountName} requires an unpublished library`);
143
+ assertFiniteClock(ir);
144
+ for (const bundle of ir.bundles ?? []) {
145
+ if (!ir.roles.some((r) => r.name === bundle.role))
146
+ throw new LinkError(`E_BUNDLE_ROLE: ${bundle.name} must name a declared role (${bundle.at.src}:${bundle.at.line}:${bundle.at.col}). Republish :for with a declared role.`);
147
+ if (!bundle.label.trim())
148
+ throw new LinkError(`E_BUNDLE_LABEL: ${bundle.name} needs a nonempty label (${bundle.at.src}:${bundle.at.line}:${bundle.at.col}). Republish a readable session title.`);
149
+ }
150
+ const reuseError = reuseProblem(ir);
151
+ if (reuseError)
152
+ throw new LinkError(`${reuseError.code}: ${reuseError.message}. ${reuseError.help}`);
153
+ for (const component of ir.components)
154
+ for (const action of component.actions) {
155
+ const names = advanceTargets(action), requirements = names.map((name) => component.requirements.find((r) => r.name === name));
156
+ const code = !names.length || new Set(names).size !== names.length
157
+ ? "E_ADVANCES"
158
+ : requirements.some((r) => !r)
159
+ ? "E_UNKNOWN_REQUIREMENT"
160
+ : names.length > 1 &&
161
+ (!stableWorkIdentity(component, action) ||
162
+ requirements.some((r) => r.cycle || r.recur || r.renewWithin || r.accepts || r.reuse))
163
+ ? "E_ADVANCES_SCOPE"
164
+ : null;
165
+ if (code)
166
+ throw new LinkError(`${code}: ${component.name}/${action.name} has incompatible targets (${action.at.src}:${action.at.line}:${action.at.col}). Use unique ordinary local targets and stable key inputs including the first entity key or self; separate actions for distinct proof scopes.`);
167
+ }
168
+ const packaged = ir.entities.filter((e) => e.ns.split(".")[0] === account.package.name);
169
+ const bindings = new Map();
170
+ for (const role of ir.roles)
171
+ for (const field of role.fields) {
172
+ const found = packaged.flatMap((e) => e.implements
173
+ .filter((b) => b.role === role.name && b.field === field.name)
174
+ .map((b) => ({ attrs: b.attrs, entity: e.name })));
175
+ if (found.length > 1)
176
+ throw new LinkError(`${accountName}: more than one entity implements ${role.name}`);
177
+ if (found[0])
178
+ bindings.set(`${role.name}.${field.name}`, found[0]);
179
+ }
180
+ const resolveRead = (expr) => {
181
+ if (expr.k !== "read")
182
+ return undefined;
183
+ const binding = bindings.get(`${expr.role}.${expr.field}`);
184
+ if (!binding)
185
+ throw new LinkError(`${accountName} does not bind ${expr.role}.${expr.field}`);
186
+ let of = rewrite(expr.of, resolveRead);
187
+ for (const attr of binding.attrs)
188
+ of = {
189
+ k: "attr",
190
+ attr,
191
+ of,
192
+ meta: { path: expr.meta.path, via: `${expr.role}.${expr.field}` },
193
+ at: expr.at,
194
+ };
195
+ return of;
196
+ };
197
+ // Test predicates have their own typed read nodes and retain their authored environment.
198
+ const { scenarios, properties, ...runtime } = ir;
199
+ const resolved = {
200
+ ...rewrite(runtime, resolveRead),
201
+ ...(scenarios ? { scenarios } : {}),
202
+ ...(properties ? { properties } : {}),
203
+ };
204
+ const roots = account.forEach.map((f) => ({
205
+ component: f.component,
206
+ namespaces: packaged
207
+ .filter((e) => e.implements.some((b) => b.role === f.role))
208
+ .map((e) => e.ns),
209
+ }));
210
+ const program = {
211
+ sourceIR,
212
+ ir: resolved,
213
+ account: resolved.accounts.find((a) => a.name === accountName),
214
+ library,
215
+ release: policyRelease(account, library),
216
+ components: new Map(resolved.components.map((c) => [c.name, c])),
217
+ derives: new Map(resolved.derives.map((d) => [d.name, d])),
218
+ evidence: new Map(resolved.evidence.map((e) => [e.name, e])),
219
+ interactions: new Map(resolved.interactions.map((i) => [i.name, i])),
220
+ machines: new Map(resolved.machines.map((m) => [m.name, m])),
221
+ connectors: new Map(resolved.connectors.map((c) => [c.name, c])),
222
+ calendars: new Map(resolved.calendars.map((c) => [
223
+ c.name,
224
+ makeCalendar(c.name, c.version, c.weekend, c.holidays),
225
+ ])),
226
+ entities: new Map(resolved.entities.map((e) => [e.ns, e])),
227
+ bindings,
228
+ params: new Map(),
229
+ roots,
230
+ };
231
+ const params = new Map();
232
+ for (const p of program.account.params)
233
+ params.set(p.name, constant(program, p.value));
234
+ const linked = { ...program, params };
235
+ try {
236
+ validatePolicies(linked);
237
+ }
238
+ catch (error) {
239
+ throw new LinkError(error instanceof Error ? error.message : String(error));
240
+ }
241
+ const identity = source.reusable ? JSON.stringify([sourceDigest, accountName]) : undefined;
242
+ let resolvedDigest = identity ? resolvedDigests.get(identity) : undefined;
243
+ if (!resolvedDigest) {
244
+ resolvedDigest = sha256(JSON.stringify(resolved));
245
+ if (identity) {
246
+ resolvedDigests.set(identity, resolvedDigest);
247
+ if (resolvedDigests.size > 64)
248
+ resolvedDigests.delete(resolvedDigests.keys().next().value);
249
+ }
250
+ }
251
+ linkedSources.set(resolved, {
252
+ ir: sourceIR,
253
+ sourceDigest,
254
+ resolvedDigest,
255
+ });
256
+ return linked;
257
+ };
258
+ /** Every account in a compiled IR, linked. */
259
+ export const linkAll = (ir) => ir.accounts.map((a) => link(ir, a.name));
@@ -0,0 +1,32 @@
1
+ import type { TimePoint } from "./instants.js";
2
+ import type { AcceptanceRecord, ConfirmationRecord, Basis, DispatchRecord, DecisionRecord, EvidenceRecord, Fact, FileRecord, DocumentRecord, NoticeDeliveryRecord, NoticeAcknowledgmentRecord, JournalEntry, MilestoneRecord, SignalRecord } from "./basis.js";
3
+ export interface OperationReceipt {
4
+ readonly account: string;
5
+ readonly id: string;
6
+ readonly digest: string;
7
+ readonly instance: string;
8
+ readonly operation: string;
9
+ readonly kind: "action" | "decision";
10
+ readonly at: TimePoint;
11
+ }
12
+ export interface World {
13
+ readonly redactions?: readonly import("./basis.js").RedactionObservation[];
14
+ readonly lifecycles?: readonly import("./basis.js").LifecycleRecord[];
15
+ readonly resources?: readonly import("./basis.js").ResourceRecord[];
16
+ readonly noticeDeliveries?: readonly NoticeDeliveryRecord[];
17
+ readonly noticeAcknowledgments?: readonly NoticeAcknowledgmentRecord[];
18
+ readonly documents?: readonly DocumentRecord[];
19
+ readonly files?: readonly FileRecord[];
20
+ readonly operationReceipts?: readonly OperationReceipt[];
21
+ readonly confirmations?: readonly ConfirmationRecord[];
22
+ readonly milestones?: readonly MilestoneRecord[];
23
+ readonly facts: readonly Fact[];
24
+ readonly evidence: readonly EvidenceRecord[];
25
+ readonly decisions?: readonly DecisionRecord[];
26
+ readonly acceptances: readonly AcceptanceRecord[];
27
+ readonly signals: readonly SignalRecord[];
28
+ readonly dispatches: readonly DispatchRecord[];
29
+ readonly journal: readonly JournalEntry[];
30
+ }
31
+ export declare const emptyWorld: World;
32
+ export declare const basis: (world: World, now: TimePoint) => Basis;
@@ -0,0 +1,190 @@
1
+ import { normalizeInstant } from "../ir-checks/index.js";
2
+ import { timeOrder } from "./instants.js";
3
+ export const emptyWorld = {
4
+ facts: [],
5
+ evidence: [],
6
+ acceptances: [],
7
+ signals: [],
8
+ dispatches: [],
9
+ journal: [],
10
+ };
11
+ export const basis = (world, now) => {
12
+ if (now.length !== 10) {
13
+ const normalized = normalizeInstant(now);
14
+ if (!normalized)
15
+ throw new RangeError("Invalid snapshot instant");
16
+ now = normalized;
17
+ }
18
+ const facts = new Map();
19
+ const byNs = new Map();
20
+ const nsOf = new Map();
21
+ for (const f of world.facts) {
22
+ if (timeOrder(f.at, now) > 0)
23
+ continue;
24
+ let attributes = facts.get(f.e);
25
+ if (!attributes) {
26
+ facts.set(f.e, (attributes = new Map()));
27
+ const ns = f.a.slice(0, f.a.indexOf("/"));
28
+ nsOf.set(f.e, ns);
29
+ let members = byNs.get(ns);
30
+ if (!members)
31
+ byNs.set(ns, (members = new Set()));
32
+ members.add(f.e);
33
+ }
34
+ const previous = attributes.get(f.a);
35
+ if (!previous || timeOrder(previous.at, f.at) <= 0)
36
+ attributes.set(f.a, f);
37
+ }
38
+ const redactions = world.redactions?.filter((r) => timeOrder(r.at, now) <= 0);
39
+ for (const r of redactions ?? []) {
40
+ if (!facts.has(r.entity))
41
+ facts.set(r.entity, new Map());
42
+ if (r.attribute) {
43
+ const ns = r.attribute.slice(0, r.attribute.indexOf("/"));
44
+ if (!nsOf.has(r.entity))
45
+ nsOf.set(r.entity, ns);
46
+ if (!byNs.has(ns))
47
+ byNs.set(ns, new Set());
48
+ byNs.get(ns).add(r.entity);
49
+ }
50
+ }
51
+ const evidence = new Map();
52
+ const matches = new Map();
53
+ for (const [entity, attributes] of facts)
54
+ for (const f of attributes.values()) {
55
+ if (f.v === null)
56
+ continue;
57
+ let values = matches.get(f.a);
58
+ if (!values)
59
+ matches.set(f.a, (values = new Map()));
60
+ let ids = values.get(f.v);
61
+ if (!ids)
62
+ values.set(f.v, (ids = []));
63
+ ids.push(entity);
64
+ }
65
+ for (const values of matches.values())
66
+ for (const ids of values.values())
67
+ ids.sort();
68
+ const byScope = new Map();
69
+ const byInstance = new Map();
70
+ const push = (map, key, e) => {
71
+ const list = map.get(key);
72
+ if (list)
73
+ list.push(e);
74
+ else
75
+ map.set(key, [e]);
76
+ };
77
+ for (const e of world.evidence)
78
+ if (timeOrder(e.at, now) <= 0) {
79
+ for (const scope of new Set(e.reuseScopes ?? []))
80
+ push(byScope, scope, e);
81
+ const instances = new Set();
82
+ for (const occurrence of new Set([e.occurrence, ...(e.occurrences ?? [])])) {
83
+ push(evidence, occurrence, e);
84
+ instances.add(occurrence.slice(0, occurrence.lastIndexOf("/")));
85
+ }
86
+ for (const instance of instances)
87
+ push(byInstance, instance, e);
88
+ }
89
+ const milestones = new Map();
90
+ for (const record of world.milestones ?? []) {
91
+ const key = JSON.stringify([record.instance, record.milestone]);
92
+ // Append order is authoritative: later attempts cannot overwrite the first record.
93
+ if (timeOrder(record.at, now) <= 0 && !milestones.has(key))
94
+ milestones.set(key, record);
95
+ }
96
+ const decisions = new Map();
97
+ for (const record of world.decisions ?? [])
98
+ if (timeOrder(record.at, now) <= 0) {
99
+ let list = decisions.get(record.instance);
100
+ if (!list)
101
+ decisions.set(record.instance, (list = []));
102
+ list.push(record);
103
+ }
104
+ const acceptances = new Map(world.acceptances
105
+ .filter((a) => timeOrder(a.at, now) <= 0)
106
+ .map((a) => [`${a.instance}\u0000${a.requirement}`, a]));
107
+ const histories = new Map();
108
+ for (const s of world.signals)
109
+ if (timeOrder(s.at, now) <= 0) {
110
+ const key = `${s.instance}\u0000${s.machine}`;
111
+ const list = histories.get(key);
112
+ if (list)
113
+ list.push(s);
114
+ else
115
+ histories.set(key, [s]);
116
+ }
117
+ const confirmations = new Map();
118
+ for (const record of world.confirmations ?? []) {
119
+ if (timeOrder(record.at, now) > 0)
120
+ continue;
121
+ const key = JSON.stringify([record.entity, record.attribute]);
122
+ const previous = confirmations.get(key);
123
+ if (!previous || timeOrder(previous.at, record.at) <= 0)
124
+ confirmations.set(key, record);
125
+ }
126
+ const dispatches = new Map(world.dispatches.filter((d) => timeOrder(d.at, now) <= 0).map((d) => [d.key, d]));
127
+ const immutableIndex = (records) => {
128
+ const index = new Map();
129
+ for (const record of records) {
130
+ const key = JSON.stringify([record.account, record.home, record.key]);
131
+ if (timeOrder(record.at, now) <= 0 && !index.has(key))
132
+ index.set(key, record);
133
+ }
134
+ return (account, home, key) => index.get(JSON.stringify([account, home, key]));
135
+ };
136
+ const document = immutableIndex(world.documents ?? []), noticeDelivery = immutableIndex(world.noticeDeliveries ?? []), noticeAcknowledgment = immutableIndex(world.noticeAcknowledgments ?? []);
137
+ const files = new Map();
138
+ for (const record of world.files ?? []) {
139
+ if (timeOrder(record.at, now) > 0)
140
+ continue;
141
+ const key = JSON.stringify([record.account, record.home, record.digest]), previous = files.get(key);
142
+ if (!previous || timeOrder(previous.at, record.at) <= 0)
143
+ files.set(key, record);
144
+ }
145
+ const lifecycles = new Map(), lifecycleHomes = new Map(), resources = new Map();
146
+ for (const record of world.lifecycles ?? [])
147
+ if (timeOrder(record.at, now) <= 0)
148
+ lifecycles.set(JSON.stringify([record.account, record.instance]), record);
149
+ for (const record of lifecycles.values()) {
150
+ const key = JSON.stringify([record.account, record.home]), records = lifecycleHomes.get(key) ?? [];
151
+ records.push(record);
152
+ lifecycleHomes.set(key, records);
153
+ }
154
+ for (const record of world.resources ?? []) {
155
+ if (timeOrder(record.at, now) > 0)
156
+ continue;
157
+ const key = JSON.stringify([record.account, record.home]), records = resources.get(key) ?? [];
158
+ records.push(record);
159
+ resources.set(key, records);
160
+ }
161
+ return {
162
+ ...(redactions?.length
163
+ ? { redactions: (entity) => redactions.filter((r) => r.entity === entity) }
164
+ : {}),
165
+ now,
166
+ lifecycleRecords: (account, home) => lifecycleHomes.get(JSON.stringify([account, home])) ?? [],
167
+ lifecycle: (account, instance) => lifecycles.get(JSON.stringify([account, instance])),
168
+ resourceRecords: (account, home) => resources.get(JSON.stringify([account, home])) ?? [],
169
+ document,
170
+ noticeDelivery,
171
+ noticeAcknowledgment,
172
+ file: (account, home, digest) => files.get(JSON.stringify([account, home, digest])),
173
+ fact: (e, a) => {
174
+ const f = facts.get(e)?.get(a);
175
+ return f && f.v !== null ? f : undefined;
176
+ },
177
+ confirmation: (e, a) => confirmations.get(JSON.stringify([e, a])),
178
+ entities: (ns) => (ns === undefined ? [...facts.keys()] : [...(byNs.get(ns) ?? [])]),
179
+ matching: (a, v) => matches.get(a)?.get(v) ?? [],
180
+ nsOf: (e) => nsOf.get(e),
181
+ evidence: (occurrence) => evidence.get(occurrence) ?? [],
182
+ evidenceIn: (scope) => byScope.get(scope) ?? [],
183
+ evidenceOf: (instance) => byInstance.get(instance) ?? [],
184
+ milestone: (instance, name) => milestones.get(JSON.stringify([instance, name])),
185
+ decisions: (instance) => decisions.get(instance) ?? [],
186
+ acceptance: (instance, requirement) => acceptances.get(`${instance}\u0000${requirement}`),
187
+ history: (instance, machine) => histories.get(`${instance}\u0000${machine}`) ?? [],
188
+ dispatched: (key) => dispatches.get(key),
189
+ };
190
+ };
@@ -0,0 +1,7 @@
1
+ import type * as IR from "../world-ir/types.generated.js";
2
+ import type { EvaluationContext } from "./context.js";
3
+ import type { World } from "./memory.js";
4
+ import type { Cx, MilestoneResult, WorldReconciliation } from "./model.js";
5
+ export declare const evaluateMilestones: (ctx: EvaluationContext, cx: Cx, component: IR.Component) => MilestoneResult[];
6
+ /** In-memory host admission; durable hosts enforce the same unique occurrence/name key. */
7
+ export declare const recordMilestones: (result: WorldReconciliation, world: World) => World;
@@ -0,0 +1,58 @@
1
+ import { observeBasis, programDependency, ReadSet } from "./dependencies.js";
2
+ import { evaluateIn, instanceEnv, isUnknown, truth } from "./evaluation.js";
3
+ import { semanticJson } from "./result-digest.js";
4
+ import { timed } from "./scheduling.js";
5
+ import { sha256 } from "./sha256.js";
6
+ export const evaluateMilestones = (ctx, cx, component) => (component.milestones ?? []).map((milestone, index) => {
7
+ const instance = cx.inst.id;
8
+ const program = ctx.programOf.get(instance);
9
+ const existing = cx.b.milestone?.(instance, milestone.name);
10
+ // A separate read set makes the capture independent of other consumers and graph scope.
11
+ const reads = new ReadSet();
12
+ reads.add(programDependency(program));
13
+ const env = instanceEnv(program, cx.inst, (name) => ctx.state.status(cx.inst, name), reads);
14
+ const read = timed(ctx, { ...cx, b: observeBasis(ctx.b, reads), reads, env }, ["milestone", String(index), milestone.name], `${milestone.label ?? milestone.name}: condition changes`, (c) => {
15
+ const value = evaluateIn(c, milestone.when);
16
+ return { condition: truth(value), unknown: isUnknown(value) ? value.why : null };
17
+ });
18
+ cx.reads.merge(reads.entries());
19
+ // Temporal jobs can discover additional dependencies after this call.
20
+ ctx.temporalJobs.push(() => cx.reads.merge(reads.entries()));
21
+ const record = existing ??
22
+ (read.condition === true
23
+ ? {
24
+ instance,
25
+ milestone: milestone.name,
26
+ at: ctx.now,
27
+ release: program.release,
28
+ basis: { at: ctx.now, digest: `sha256:${sha256(semanticJson([...reads.snapshot()]))}` },
29
+ }
30
+ : null);
31
+ return {
32
+ name: milestone.name,
33
+ label: milestone.label ?? milestone.name,
34
+ ...read,
35
+ reached: record !== null,
36
+ pending: !existing && record !== null,
37
+ record,
38
+ finding: existing && read.condition === false ? "regressed" : null,
39
+ at: milestone.at,
40
+ };
41
+ });
42
+ /** In-memory host admission; durable hosts enforce the same unique occurrence/name key. */
43
+ export const recordMilestones = (result, world) => {
44
+ const records = [...(world.milestones ?? [])];
45
+ const key = (r) => JSON.stringify([r.instance, r.milestone]);
46
+ const seen = new Set(records.map(key));
47
+ for (const reconciliation of result.results.values())
48
+ for (const milestone of reconciliation.milestones ?? []) {
49
+ const record = milestone.record;
50
+ if (!milestone.pending || !record || seen.has(key(record)))
51
+ continue;
52
+ seen.add(key(record));
53
+ records.push(record);
54
+ }
55
+ return records.length === (world.milestones?.length ?? 0)
56
+ ? world
57
+ : { ...world, milestones: records };
58
+ };
@@ -0,0 +1,18 @@
1
+ import type * as IR from "../world-ir/types.generated.js";
2
+ import type { Cx } from "./model.js";
3
+ /** A display reason plus the IR address a host can act on. Compounds remain opaque. */
4
+ export interface Missing {
5
+ readonly text: string;
6
+ readonly kind: "requirement" | "evidence" | "fact" | "machine" | "other";
7
+ readonly requirement?: string;
8
+ readonly instance?: string;
9
+ readonly evidence?: string;
10
+ readonly producedBy?: readonly {
11
+ readonly requirement: string;
12
+ readonly instance: string;
13
+ }[];
14
+ readonly fact?: string;
15
+ readonly machine?: string;
16
+ readonly states?: readonly string[];
17
+ }
18
+ export declare const missingCondition: (cx: Cx, text: string, expr: IR.Expr) => Missing;