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,372 @@
1
+ /** Tuple keys distinguish opaque ids and scalar types without delimiter collisions. */
2
+ export const dependencyKey = (d) => {
3
+ switch (d.kind) {
4
+ case "lifecycle":
5
+ return JSON.stringify([d.kind, d.account, d.instance]);
6
+ case "lifecycles":
7
+ case "resources":
8
+ return JSON.stringify([d.kind, d.account, d.home]);
9
+ case "document":
10
+ case "notice-delivery":
11
+ case "notice-acknowledgment":
12
+ return JSON.stringify([d.kind, d.account, d.home, d.key]);
13
+ case "file":
14
+ return JSON.stringify([d.kind, d.account, d.home, d.digest]);
15
+ case "scoped-evidence":
16
+ return JSON.stringify([d.kind, d.scope]);
17
+ case "milestone":
18
+ return JSON.stringify([d.kind, d.instance, d.name]);
19
+ case "confirmation":
20
+ case "fact":
21
+ return JSON.stringify([d.kind, d.entity, d.attribute]);
22
+ case "entities":
23
+ return JSON.stringify([d.kind, d.namespace]);
24
+ case "matching":
25
+ return JSON.stringify([d.kind, d.attribute, d.where]);
26
+ case "namespace":
27
+ return JSON.stringify([d.kind, d.entity]);
28
+ case "evidence":
29
+ return JSON.stringify([d.kind, d.occurrence]);
30
+ case "instance-evidence":
31
+ case "decisions":
32
+ case "members":
33
+ return JSON.stringify([d.kind, d.instance]);
34
+ case "acceptance":
35
+ return JSON.stringify([d.kind, d.instance, d.requirement]);
36
+ case "signals":
37
+ return JSON.stringify([d.kind, d.instance, d.machine]);
38
+ case "dispatch":
39
+ return JSON.stringify([d.kind, d.key]);
40
+ case "clock":
41
+ return JSON.stringify([d.kind]);
42
+ case "time":
43
+ return JSON.stringify([d.kind, d.instance, ...d.path]);
44
+ case "program":
45
+ return JSON.stringify([d.kind, d.account]);
46
+ case "input":
47
+ case "status":
48
+ case "slot":
49
+ return JSON.stringify([d.kind, d.instance, d.name]);
50
+ }
51
+ };
52
+ const programDependencies = new WeakMap();
53
+ export const programDependency = (p) => {
54
+ const cached = programDependencies.get(p);
55
+ if (cached)
56
+ return cached;
57
+ const dependency = {
58
+ kind: "program",
59
+ account: p.account.name,
60
+ value: {
61
+ library: p.library,
62
+ package: p.account.package,
63
+ params: p.account.params,
64
+ roots: p.account.forEach,
65
+ ...(p.account.policies?.length ? { policies: p.account.policies } : {}),
66
+ entities: p.ir.entities,
67
+ },
68
+ };
69
+ programDependencies.set(p, dependency);
70
+ return dependency;
71
+ };
72
+ export class ReadSet {
73
+ entriesByKey = new Map();
74
+ cached;
75
+ add(d, key = dependencyKey(d)) {
76
+ if (this.entriesByKey.get(key) === d)
77
+ return;
78
+ if (this.cached)
79
+ this.entriesByKey = new Map(this.entriesByKey);
80
+ this.entriesByKey.set(key, d);
81
+ this.cached = undefined;
82
+ }
83
+ merge(entries, keep) {
84
+ for (const [key, value] of entries)
85
+ if (!keep || keep(value))
86
+ this.add(value, key);
87
+ }
88
+ entries() {
89
+ return this.entriesByKey.entries();
90
+ }
91
+ values() {
92
+ return this.entriesByKey.values();
93
+ }
94
+ snapshot() {
95
+ if (!this.cached) {
96
+ this.entriesByKey = new Map([...this.entriesByKey].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0)));
97
+ this.cached = this.entriesByKey;
98
+ }
99
+ return this.cached;
100
+ }
101
+ }
102
+ /** Internal projections can differ by consumer in cycles; keep them occurrence-local. */
103
+ export const isLocalDependency = (d) => d.kind === "time" ||
104
+ d.kind === "input" ||
105
+ d.kind === "members" ||
106
+ d.kind === "status" ||
107
+ d.kind === "slot";
108
+ /** Immutable union of sorted maps without copying shared observations into every result. */
109
+ export class DependencyMap {
110
+ shared;
111
+ local;
112
+ constructor(shared, local) {
113
+ this.shared = shared;
114
+ this.local = local;
115
+ }
116
+ get size() {
117
+ let n = this.shared.size;
118
+ for (const key of this.local.keys())
119
+ if (!this.shared.has(key))
120
+ n++;
121
+ return n;
122
+ }
123
+ get(key) {
124
+ return this.local.get(key) ?? this.shared.get(key);
125
+ }
126
+ has(key) {
127
+ return this.local.has(key) || this.shared.has(key);
128
+ }
129
+ *entries() {
130
+ const left = this.shared.entries(), right = this.local.entries();
131
+ let a = left.next(), b = right.next();
132
+ while (!a.done || !b.done) {
133
+ if (b.done || (!a.done && a.value[0] < b.value[0])) {
134
+ yield a.value;
135
+ a = left.next();
136
+ }
137
+ else {
138
+ yield b.value;
139
+ if (!a.done && a.value[0] === b.value[0])
140
+ a = left.next();
141
+ b = right.next();
142
+ }
143
+ }
144
+ }
145
+ [Symbol.iterator]() {
146
+ return this.entries();
147
+ }
148
+ *keys() {
149
+ for (const [key] of this)
150
+ yield key;
151
+ }
152
+ *values() {
153
+ for (const [, value] of this)
154
+ yield value;
155
+ }
156
+ forEach(callback, thisArg) {
157
+ for (const [key, value] of this)
158
+ callback.call(thisArg, value, key, this);
159
+ }
160
+ toJSON() {
161
+ return [...this].sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
162
+ }
163
+ }
164
+ const pools = new WeakMap();
165
+ const sameValue = (a, b) => a === b ||
166
+ (Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((v, i) => v === b[i]));
167
+ /** Shared prototype methods avoid a set of query closures for every occurrence. */
168
+ class ObservedBasis {
169
+ b;
170
+ reads;
171
+ pool;
172
+ constructor(b, reads) {
173
+ this.b = b;
174
+ this.reads = reads;
175
+ let pool = pools.get(b);
176
+ if (!pool) {
177
+ pool = new Map();
178
+ pools.set(b, pool);
179
+ }
180
+ this.pool = pool;
181
+ }
182
+ add(d) {
183
+ const key = dependencyKey(d), previous = this.pool.get(key);
184
+ if (previous && sameValue(previous.dependency.value, d.value))
185
+ this.reads.add(previous.dependency, previous.key);
186
+ else {
187
+ const canonicalKey = previous?.key ?? key;
188
+ this.pool.set(canonicalKey, { key: canonicalKey, dependency: d });
189
+ this.reads.add(d, canonicalKey);
190
+ }
191
+ }
192
+ get now() {
193
+ const value = this.b.now;
194
+ this.add({ kind: "clock", value });
195
+ return value;
196
+ }
197
+ lifecycle(account, instance) {
198
+ const value = this.b.lifecycle?.(account, instance);
199
+ this.add({ kind: "lifecycle", account, instance, value: value ?? null });
200
+ return value;
201
+ }
202
+ lifecycleRecords(account, home) {
203
+ const value = this.b.lifecycleRecords?.(account, home) ?? [];
204
+ this.add({ kind: "lifecycles", account, home, value });
205
+ return value;
206
+ }
207
+ resourceRecords(account, home) {
208
+ const value = this.b.resourceRecords?.(account, home) ?? [];
209
+ this.add({ kind: "resources", account, home, value });
210
+ return value;
211
+ }
212
+ document(account, home, key) {
213
+ const value = this.b.document?.(account, home, key);
214
+ this.add({ kind: "document", account, home, key, value: value ?? null });
215
+ return value;
216
+ }
217
+ noticeDelivery(account, home, key) {
218
+ const value = this.b.noticeDelivery?.(account, home, key);
219
+ this.add({ kind: "notice-delivery", account, home, key, value: value ?? null });
220
+ return value;
221
+ }
222
+ noticeAcknowledgment(account, home, key) {
223
+ const value = this.b.noticeAcknowledgment?.(account, home, key);
224
+ this.add({ kind: "notice-acknowledgment", account, home, key, value: value ?? null });
225
+ return value;
226
+ }
227
+ file(account, home, digest) {
228
+ const value = this.b.file?.(account, home, digest);
229
+ this.add({ kind: "file", account, home, digest, value: value ?? null });
230
+ return value;
231
+ }
232
+ fact(entity, attribute) {
233
+ const value = this.b.fact(entity, attribute);
234
+ this.add({ kind: "fact", entity, attribute, value: value ?? null });
235
+ return value;
236
+ }
237
+ confirmation(entity, attribute) {
238
+ const value = this.b.confirmation?.(entity, attribute);
239
+ this.add({ kind: "confirmation", entity, attribute, value: value ?? null });
240
+ return value;
241
+ }
242
+ entities(namespace) {
243
+ const value = this.b.entities(namespace);
244
+ this.add({ kind: "entities", namespace: namespace ?? null, value: [...value].sort() });
245
+ return value;
246
+ }
247
+ matching(attribute, where) {
248
+ const value = this.b.matching(attribute, where);
249
+ this.add({ kind: "matching", attribute, where, value: [...value].sort() });
250
+ return value;
251
+ }
252
+ nsOf(entity) {
253
+ const value = this.b.nsOf(entity);
254
+ this.add({ kind: "namespace", entity, value: value ?? null });
255
+ return value;
256
+ }
257
+ evidence(occurrence) {
258
+ const value = this.b.evidence(occurrence);
259
+ this.add({ kind: "evidence", occurrence, value });
260
+ return value;
261
+ }
262
+ evidenceIn(scope) {
263
+ const value = this.b.evidenceIn?.(scope) ?? [];
264
+ this.add({ kind: "scoped-evidence", scope, value });
265
+ return value;
266
+ }
267
+ evidenceOf(instance) {
268
+ const value = this.b.evidenceOf(instance);
269
+ this.add({ kind: "instance-evidence", instance, value });
270
+ return value;
271
+ }
272
+ milestone(instance, name) {
273
+ const value = this.b.milestone?.(instance, name);
274
+ this.add({ kind: "milestone", instance, name, value: value ?? null });
275
+ return value;
276
+ }
277
+ decisions(instance) {
278
+ const value = this.b.decisions?.(instance) ?? [];
279
+ this.add({ kind: "decisions", instance, value });
280
+ return value;
281
+ }
282
+ acceptance(instance, requirement) {
283
+ const value = this.b.acceptance(instance, requirement);
284
+ this.add({ kind: "acceptance", instance, requirement, value: value ?? null });
285
+ return value;
286
+ }
287
+ history(instance, machine) {
288
+ const value = this.b.history(instance, machine);
289
+ this.add({ kind: "signals", instance, machine, value });
290
+ return value;
291
+ }
292
+ dispatched(key) {
293
+ const value = this.b.dispatched(key);
294
+ this.add({ kind: "dispatch", key, value: value ?? null });
295
+ return value;
296
+ }
297
+ }
298
+ /** Observe every query, interning identical observations without caching query results. */
299
+ export const observeBasis = (b, reads) => new ObservedBasis(b, reads);
300
+ class ForecastBasis {
301
+ b;
302
+ now;
303
+ constructor(b, now) {
304
+ this.b = b;
305
+ this.now = now;
306
+ }
307
+ lifecycle(account, instance) {
308
+ return this.b.lifecycle?.(account, instance);
309
+ }
310
+ lifecycleRecords(account, home) {
311
+ return this.b.lifecycleRecords?.(account, home) ?? [];
312
+ }
313
+ resourceRecords(account, home) {
314
+ return this.b.resourceRecords?.(account, home) ?? [];
315
+ }
316
+ document(account, home, key) {
317
+ return this.b.document?.(account, home, key);
318
+ }
319
+ noticeDelivery(account, home, key) {
320
+ return this.b.noticeDelivery?.(account, home, key);
321
+ }
322
+ noticeAcknowledgment(account, home, key) {
323
+ return this.b.noticeAcknowledgment?.(account, home, key);
324
+ }
325
+ file(account, home, digest) {
326
+ return this.b.file?.(account, home, digest);
327
+ }
328
+ fact(entity, attribute) {
329
+ return this.b.fact(entity, attribute);
330
+ }
331
+ confirmation(entity, attribute) {
332
+ return this.b.confirmation?.(entity, attribute);
333
+ }
334
+ entities(namespace) {
335
+ return this.b.entities(namespace);
336
+ }
337
+ matching(attribute, where) {
338
+ return this.b.matching(attribute, where);
339
+ }
340
+ nsOf(entity) {
341
+ return this.b.nsOf(entity);
342
+ }
343
+ evidence(occurrence) {
344
+ return this.b.evidence(occurrence);
345
+ }
346
+ evidenceIn(scope) {
347
+ return this.b.evidenceIn?.(scope) ?? [];
348
+ }
349
+ evidenceOf(instance) {
350
+ return this.b.evidenceOf(instance);
351
+ }
352
+ milestone(instance, name) {
353
+ return this.b.milestone?.(instance, name);
354
+ }
355
+ decisions(instance) {
356
+ return this.b.decisions?.(instance) ?? [];
357
+ }
358
+ acceptance(instance, requirement) {
359
+ return this.b.acceptance(instance, requirement);
360
+ }
361
+ history(instance, machine) {
362
+ return this.b.history(instance, machine);
363
+ }
364
+ dispatched(key) {
365
+ return this.b.dispatched(key);
366
+ }
367
+ }
368
+ /** Forecast time over the current snapshot, retaining its actual clock observation. */
369
+ export const forecastBasis = (b, now) => {
370
+ void b.now;
371
+ return new ForecastBasis(b, now);
372
+ };
@@ -0,0 +1,9 @@
1
+ import type { Basis } from "./basis.js";
2
+ import type { Program } from "./reconcile.js";
3
+ export interface RootCandidate {
4
+ readonly subject: string;
5
+ readonly component: string;
6
+ }
7
+ /** Conservative root seeds for an entity id, reached through incoming typed references. Final home filtering
8
+ * belongs to occurrence discovery: an ordinary reference need not be a home binding. */
9
+ export declare const rootCandidates: (p: Program, b: Basis, subject: string) => readonly RootCandidate[];
@@ -0,0 +1,65 @@
1
+ const plans = new WeakMap();
2
+ const referenceTypes = (type, aliases, seen = new Set()) => {
3
+ if (typeof type === "string") {
4
+ const alias = aliases.get(type);
5
+ return alias && !seen.has(type) ? referenceTypes(alias, aliases, new Set([...seen, type])) : [];
6
+ }
7
+ if (type[0] === "Id" && typeof type[1] === "string")
8
+ return [type[1]];
9
+ if (type[0] === "Option" || type[0] === "Union")
10
+ return type.slice(1).flatMap((t) => referenceTypes(t, aliases, seen));
11
+ return [];
12
+ };
13
+ const references = (p) => {
14
+ const cached = plans.get(p);
15
+ if (cached)
16
+ return cached;
17
+ const owned = p.ir.entities.filter((e) => e.ns.split(".")[0] === p.account.package.name);
18
+ const aliases = new Map(p.ir.types.map((t) => [t.name, t.type]));
19
+ const plan = [];
20
+ for (const source of owned)
21
+ for (const field of source.fields) {
22
+ const targets = referenceTypes(field.type, aliases);
23
+ if (targets.length === 0)
24
+ continue;
25
+ for (const entity of p.ir.entities)
26
+ if (targets.includes(entity.name) ||
27
+ (owned.includes(entity) && entity.implements.some((b) => targets.includes(b.role))))
28
+ plan.push({ attr: field.attr, source: source.ns, target: entity.ns });
29
+ }
30
+ plans.set(p, plan);
31
+ return plan;
32
+ };
33
+ /** Conservative root seeds for an entity id, reached through incoming typed references. Final home filtering
34
+ * belongs to occurrence discovery: an ordinary reference need not be a home binding. */
35
+ export const rootCandidates = (p, b, subject) => {
36
+ const plan = references(p);
37
+ const queue = [{ id: subject, ns: b.nsOf(subject) }];
38
+ const visited = new Set();
39
+ const roots = new Map();
40
+ for (let cursor = 0; cursor < queue.length; cursor++) {
41
+ const { id, ns } = queue[cursor];
42
+ const key = JSON.stringify([id, ns]);
43
+ if (visited.has(key))
44
+ continue;
45
+ visited.add(key);
46
+ for (const root of p.roots)
47
+ if (ns !== undefined && root.namespaces.includes(ns)) {
48
+ let members = roots.get(root.component);
49
+ if (!members)
50
+ roots.set(root.component, (members = new Set()));
51
+ members.add(id);
52
+ }
53
+ for (const ref of plan) {
54
+ if (ns !== undefined && ref.target !== ns)
55
+ continue;
56
+ for (const candidate of b.matching(ref.attr, id)) {
57
+ const actual = b.nsOf(candidate);
58
+ if (actual !== undefined && actual !== ref.source)
59
+ continue;
60
+ queue.push({ id: candidate, ns: ref.source });
61
+ }
62
+ }
63
+ }
64
+ return [...new Set(p.roots.map((r) => r.component))].flatMap((component) => [...(roots.get(component) ?? [])].sort().map((subject) => ({ component, subject })));
65
+ };
@@ -0,0 +1,18 @@
1
+ import type * as IR from "../world-ir/types.generated.js";
2
+ import type { Basis, EvidenceRecord } from "./basis.js";
3
+ import type { Program } from "./model.js";
4
+ export interface DocumentCorrection {
5
+ readonly previous: Pick<EvidenceRecord, "id" | "type" | "by" | "at" | "signature">;
6
+ readonly previousDigest: string;
7
+ readonly evidence: string;
8
+ readonly by: string;
9
+ readonly at: string;
10
+ readonly reason: string;
11
+ readonly fields: readonly {
12
+ readonly label: string;
13
+ readonly before: string;
14
+ readonly after: string;
15
+ }[];
16
+ }
17
+ /** Historical values follow the same disclosure and type mapping as the current template. */
18
+ export declare const documentCorrections: (p: Program, snapshot: Basis, document: IR.Document, evidence: readonly EvidenceRecord[]) => readonly DocumentCorrection[] | undefined;
@@ -0,0 +1,59 @@
1
+ import { collectionValue } from "./collection-values.js";
2
+ import { evidenceOccurrences } from "./evidence-history.js";
3
+ import { signatureValid } from "./signatures.js";
4
+ import { timeOrder } from "./instants.js";
5
+ import { canonicalJson } from "./result-digest.js";
6
+ import { sha256 } from "./sha256.js";
7
+ /** Historical values follow the same disclosure and type mapping as the current template. */
8
+ export const documentCorrections = (p, snapshot, document, evidence) => {
9
+ const corrections = [];
10
+ for (const source of evidence) {
11
+ let record = source;
12
+ const seen = new Set([record.id]), chain = [];
13
+ while (record.amendment) {
14
+ const link = record.amendment, matches = snapshot.evidence(record.occurrence).filter((e) => e.id === link.previous), previous = matches[0];
15
+ if (matches.length !== 1 ||
16
+ !previous ||
17
+ seen.has(previous.id) ||
18
+ previous.status !== "attested" ||
19
+ previous.type !== record.type ||
20
+ !signatureValid(previous) ||
21
+ !link.reason.trim() ||
22
+ link.reason.length > 2000 ||
23
+ timeOrder(previous.at, record.at) > 0 ||
24
+ JSON.stringify(evidenceOccurrences(previous)) !==
25
+ JSON.stringify(evidenceOccurrences(record)) ||
26
+ link.previousDigest !== sha256(canonicalJson(previous)))
27
+ return;
28
+ const fields = [];
29
+ for (const mapping of document.fields.filter((f) => f.evidence === record.type)) {
30
+ const field = p.evidence.get(record.type).fields.find((f) => f.name === mapping.field), display = (e) => {
31
+ const raw = e.values[mapping.field];
32
+ return raw === undefined || raw === "" ? "" : collectionValue(p, field.type, raw);
33
+ }, before = display(previous), after = display(record);
34
+ if (before === undefined || after === undefined)
35
+ return;
36
+ fields.push({ label: mapping.label, before: String(before), after: String(after) });
37
+ }
38
+ chain.push({
39
+ previous: {
40
+ id: previous.id,
41
+ type: previous.type,
42
+ by: previous.by,
43
+ at: previous.at,
44
+ ...(previous.signature ? { signature: previous.signature } : {}),
45
+ },
46
+ previousDigest: link.previousDigest,
47
+ evidence: record.id,
48
+ by: record.by,
49
+ at: record.at,
50
+ reason: link.reason,
51
+ fields,
52
+ });
53
+ seen.add(previous.id);
54
+ record = previous;
55
+ }
56
+ corrections.push(...chain.reverse());
57
+ }
58
+ return corrections;
59
+ };
@@ -0,0 +1,26 @@
1
+ import type { Cx } from "./model.js";
2
+ import type { Basis, EvidenceRecord } from "./basis.js";
3
+ import type { WorldReconciliation } from "./model.js";
4
+ import { type DocumentCorrection } from "./document-corrections.js";
5
+ export type { DocumentCorrection } from "./document-corrections.js";
6
+ export interface DocumentIntent {
7
+ readonly key: string;
8
+ readonly account: string;
9
+ readonly home: string;
10
+ readonly instance: string;
11
+ readonly document: string;
12
+ readonly edition: string;
13
+ readonly templateDigest: string;
14
+ readonly sourceDigest: string;
15
+ readonly title: string;
16
+ readonly signedAt: string;
17
+ readonly evidence: readonly EvidenceRecord[];
18
+ readonly corrections?: readonly DocumentCorrection[];
19
+ readonly fields: readonly {
20
+ readonly label: string;
21
+ readonly value: string;
22
+ }[];
23
+ }
24
+ /** Passive after-commit work: rendering and blob I/O belong to the host's Workflow Layers. */
25
+ export declare const documentIntents: (recon: WorldReconciliation, snapshot: Basis, sourceIds?: readonly string[]) => readonly DocumentIntent[];
26
+ export declare const documentIntentsFor: (cx: Cx, sourceIds?: readonly string[]) => readonly DocumentIntent[];
@@ -0,0 +1,88 @@
1
+ import { resourceProofRecords } from "./resource-generation.js";
2
+ import { contentDigest } from "../ir-checks/index.js";
3
+ import { assertSnapshot, attested, instanceContext } from "./evaluation.js";
4
+ import { occurrenceHome } from "./homes.js";
5
+ import { validEvidence } from "./commands.js";
6
+ import { collectionValue } from "./collection-values.js";
7
+ import { localDateAt, timeOrder } from "./instants.js";
8
+ import { canonicalJson } from "./result-digest.js";
9
+ import { sha256 } from "./sha256.js";
10
+ import { documentCorrections } from "./document-corrections.js";
11
+ /** Passive after-commit work: rendering and blob I/O belong to the host's Workflow Layers. */
12
+ export const documentIntents = (recon, snapshot, sourceIds) => {
13
+ assertSnapshot(snapshot, recon.now);
14
+ const intents = [];
15
+ for (const inst of recon.instances.values()) {
16
+ intents.push(...documentIntentsFor(instanceContext(recon, snapshot, inst), sourceIds));
17
+ }
18
+ return intents.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
19
+ };
20
+ export const documentIntentsFor = (cx, sourceIds) => {
21
+ if (!cx.inst || !cx.k)
22
+ return [];
23
+ // Document proof belongs to its declared sources, independent of the consuming requirement.
24
+ const { occurrence: _occurrence, proofPeriod: _period, ...sourceContext } = cx;
25
+ const inst = cx.inst, p = cx.p, snapshot = cx.b, intents = [], home = occurrenceHome(p, inst, cx.k.instances)?.id;
26
+ if (!home)
27
+ return [];
28
+ for (const document of p.ir.documents ?? []) {
29
+ if (document.of !== inst.component)
30
+ continue;
31
+ const evidence = [];
32
+ for (const type of document.sources) {
33
+ const scoped = document.resource
34
+ ? resourceProofRecords(p, snapshot, inst, document.resource.name, type)
35
+ : undefined;
36
+ const trace = { steps: [] };
37
+ if (attested({ ...sourceContext, trace }, type, sourceIds
38
+ ? (scoped ?? snapshot.evidenceOf(inst.id)).filter((e) => e.type === type && sourceIds.includes(e.id))
39
+ : scoped) !== true)
40
+ break;
41
+ const record = trace.witness?.evidence;
42
+ if (!record || !validEvidence(p, type, record.values, record.at))
43
+ break;
44
+ evidence.push(record);
45
+ }
46
+ if (evidence.length !== document.sources.length)
47
+ continue;
48
+ const signedAt = evidence.reduce((a, e) => (timeOrder(a, e.at) < 0 ? e.at : a), evidence[0].at), date = localDateAt(signedAt), window = document.effective;
49
+ if ((window.from && date < window.from) || (window.until && date >= window.until))
50
+ continue;
51
+ const fields = [];
52
+ for (const mapping of document.fields) {
53
+ const record = evidence.find((e) => e.type === mapping.evidence), field = p.evidence.get(mapping.evidence).fields.find((f) => f.name === mapping.field), raw = record.values[mapping.field], value = raw === undefined || raw === "" ? "" : collectionValue(p, field.type, raw);
54
+ if (value === undefined)
55
+ break;
56
+ fields.push({ label: mapping.label, value: String(value) });
57
+ }
58
+ if (fields.length !== document.fields.length)
59
+ continue;
60
+ const corrections = documentCorrections(p, snapshot, document, evidence);
61
+ if (!corrections)
62
+ continue;
63
+ const templateDigest = contentDigest(document), sourceDigest = sha256(canonicalJson(corrections.length ? { evidence, corrections } : evidence));
64
+ intents.push({
65
+ key: sha256(canonicalJson({
66
+ account: inst.account,
67
+ home,
68
+ instance: inst.id,
69
+ document: document.name,
70
+ templateDigest,
71
+ sourceDigest,
72
+ })),
73
+ account: inst.account,
74
+ home,
75
+ instance: inst.id,
76
+ document: document.name,
77
+ edition: document.edition,
78
+ templateDigest,
79
+ sourceDigest,
80
+ title: document.title,
81
+ signedAt,
82
+ evidence,
83
+ ...(corrections.length ? { corrections } : {}),
84
+ fields,
85
+ });
86
+ }
87
+ return intents.sort((a, b) => (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
88
+ };
@@ -0,0 +1,6 @@
1
+ import type * as IR from "../world-ir/types.generated.js";
2
+ import type { Cx, Truth } from "./model.js";
3
+ export declare const readEffective: (cx: Cx, window: IR.Effective) => {
4
+ truth: Truth;
5
+ reason: string;
6
+ };
@@ -0,0 +1,17 @@
1
+ import { localDateAt } from "./instants.js";
2
+ import { isLocalDate } from "../ir-checks/index.js";
3
+ export const readEffective = (cx, window) => {
4
+ const { from, until } = window, now = localDateAt(cx.b.now);
5
+ if ((from === undefined && until === undefined) ||
6
+ (from !== undefined && !isLocalDate(from)) ||
7
+ (until !== undefined && !isLocalDate(until)) ||
8
+ (from && until && from >= until))
9
+ return { truth: "unknown", reason: "Invalid effective date metadata" };
10
+ for (const boundary of [from, until])
11
+ if (boundary && boundary > now)
12
+ cx.temporal?.add(boundary);
13
+ return {
14
+ truth: (!from || now >= from) && (!until || now < until),
15
+ reason: `From ${from ?? "unbounded"} (inclusive), until ${until ?? "unbounded"} (exclusive)`,
16
+ };
17
+ };
@@ -0,0 +1,4 @@
1
+ import type { EvaluationContext } from "./context.js";
2
+ import type * as IR from "../world-ir/types.generated.js";
3
+ import type { Cx, EscalationResult, HoldResult, Instance, RequirementResult } from "./model.js";
4
+ export declare const evaluateEscalations: (ctx: EvaluationContext, inst: Instance, cx: Cx, component: IR.Component, requirements: readonly RequirementResult[], holds: readonly HoldResult[]) => EscalationResult[];