@azx-pbc/axiom-runtime 0.0.0-stage → 0.0.1

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 (755) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +714 -2
  3. package/dist/cache/index.d.ts +191 -0
  4. package/dist/cache/index.d.ts.map +1 -0
  5. package/dist/cache/index.js +361 -0
  6. package/dist/cache/index.js.map +1 -0
  7. package/dist/canonical/jcs.d.ts +78 -0
  8. package/dist/canonical/jcs.d.ts.map +1 -0
  9. package/dist/canonical/jcs.js +500 -0
  10. package/dist/canonical/jcs.js.map +1 -0
  11. package/dist/canonical/restricted-json.d.ts +7 -0
  12. package/dist/canonical/restricted-json.d.ts.map +1 -0
  13. package/dist/canonical/restricted-json.js +318 -0
  14. package/dist/canonical/restricted-json.js.map +1 -0
  15. package/dist/canonical/restricted-value.d.ts +59 -0
  16. package/dist/canonical/restricted-value.d.ts.map +1 -0
  17. package/dist/canonical/restricted-value.js +156 -0
  18. package/dist/canonical/restricted-value.js.map +1 -0
  19. package/dist/canonical/restricted.d.ts +85 -0
  20. package/dist/canonical/restricted.d.ts.map +1 -0
  21. package/dist/canonical/restricted.js +163 -0
  22. package/dist/canonical/restricted.js.map +1 -0
  23. package/dist/canonical/signature.d.ts +38 -0
  24. package/dist/canonical/signature.d.ts.map +1 -0
  25. package/dist/canonical/signature.js +47 -0
  26. package/dist/canonical/signature.js.map +1 -0
  27. package/dist/eval/access/delivery.d.ts +63 -0
  28. package/dist/eval/access/delivery.d.ts.map +1 -0
  29. package/dist/eval/access/delivery.js +98 -0
  30. package/dist/eval/access/delivery.js.map +1 -0
  31. package/dist/eval/access/overlay.d.ts +72 -0
  32. package/dist/eval/access/overlay.d.ts.map +1 -0
  33. package/dist/eval/access/overlay.js +402 -0
  34. package/dist/eval/access/overlay.js.map +1 -0
  35. package/dist/eval/access/projection.d.ts +159 -0
  36. package/dist/eval/access/projection.d.ts.map +1 -0
  37. package/dist/eval/access/projection.js +211 -0
  38. package/dist/eval/access/projection.js.map +1 -0
  39. package/dist/eval/access/window.d.ts +128 -0
  40. package/dist/eval/access/window.d.ts.map +1 -0
  41. package/dist/eval/access/window.js +254 -0
  42. package/dist/eval/access/window.js.map +1 -0
  43. package/dist/eval/access/write.d.ts +113 -0
  44. package/dist/eval/access/write.d.ts.map +1 -0
  45. package/dist/eval/access/write.js +119 -0
  46. package/dist/eval/access/write.js.map +1 -0
  47. package/dist/eval/addressing.d.ts +131 -0
  48. package/dist/eval/addressing.d.ts.map +1 -0
  49. package/dist/eval/addressing.js +270 -0
  50. package/dist/eval/addressing.js.map +1 -0
  51. package/dist/eval/budget.d.ts +143 -0
  52. package/dist/eval/budget.d.ts.map +1 -0
  53. package/dist/eval/budget.js +387 -0
  54. package/dist/eval/budget.js.map +1 -0
  55. package/dist/eval/computed.d.ts +46 -0
  56. package/dist/eval/computed.d.ts.map +1 -0
  57. package/dist/eval/computed.js +89 -0
  58. package/dist/eval/computed.js.map +1 -0
  59. package/dist/eval/denials.d.ts +64 -0
  60. package/dist/eval/denials.d.ts.map +1 -0
  61. package/dist/eval/denials.js +87 -0
  62. package/dist/eval/denials.js.map +1 -0
  63. package/dist/eval/engine/cancellation.d.ts +12 -0
  64. package/dist/eval/engine/cancellation.d.ts.map +1 -0
  65. package/dist/eval/engine/cancellation.js +56 -0
  66. package/dist/eval/engine/cancellation.js.map +1 -0
  67. package/dist/eval/engine/delta.d.ts +104 -0
  68. package/dist/eval/engine/delta.d.ts.map +1 -0
  69. package/dist/eval/engine/delta.js +466 -0
  70. package/dist/eval/engine/delta.js.map +1 -0
  71. package/dist/eval/engine/deps.d.ts +136 -0
  72. package/dist/eval/engine/deps.d.ts.map +1 -0
  73. package/dist/eval/engine/deps.js +345 -0
  74. package/dist/eval/engine/deps.js.map +1 -0
  75. package/dist/eval/engine/identity.d.ts +128 -0
  76. package/dist/eval/engine/identity.d.ts.map +1 -0
  77. package/dist/eval/engine/identity.js +398 -0
  78. package/dist/eval/engine/identity.js.map +1 -0
  79. package/dist/eval/engine/index.d.ts +200 -0
  80. package/dist/eval/engine/index.d.ts.map +1 -0
  81. package/dist/eval/engine/index.js +1242 -0
  82. package/dist/eval/engine/index.js.map +1 -0
  83. package/dist/eval/engine/measurement.d.ts +23 -0
  84. package/dist/eval/engine/measurement.d.ts.map +1 -0
  85. package/dist/eval/engine/measurement.js +42 -0
  86. package/dist/eval/engine/measurement.js.map +1 -0
  87. package/dist/eval/engine/naive.d.ts +19 -0
  88. package/dist/eval/engine/naive.d.ts.map +1 -0
  89. package/dist/eval/engine/naive.js +59 -0
  90. package/dist/eval/engine/naive.js.map +1 -0
  91. package/dist/eval/engine/ops.d.ts +214 -0
  92. package/dist/eval/engine/ops.d.ts.map +1 -0
  93. package/dist/eval/engine/ops.js +1422 -0
  94. package/dist/eval/engine/ops.js.map +1 -0
  95. package/dist/eval/engine/patches.d.ts +40 -0
  96. package/dist/eval/engine/patches.d.ts.map +1 -0
  97. package/dist/eval/engine/patches.js +125 -0
  98. package/dist/eval/engine/patches.js.map +1 -0
  99. package/dist/eval/engine/ports.d.ts +71 -0
  100. package/dist/eval/engine/ports.d.ts.map +1 -0
  101. package/dist/eval/engine/ports.js +2 -0
  102. package/dist/eval/engine/ports.js.map +1 -0
  103. package/dist/eval/engine/session.d.ts +116 -0
  104. package/dist/eval/engine/session.d.ts.map +1 -0
  105. package/dist/eval/engine/session.js +653 -0
  106. package/dist/eval/engine/session.js.map +1 -0
  107. package/dist/eval/engine/snapshot.d.ts +97 -0
  108. package/dist/eval/engine/snapshot.d.ts.map +1 -0
  109. package/dist/eval/engine/snapshot.js +221 -0
  110. package/dist/eval/engine/snapshot.js.map +1 -0
  111. package/dist/eval/engine/subscriptions.d.ts +47 -0
  112. package/dist/eval/engine/subscriptions.d.ts.map +1 -0
  113. package/dist/eval/engine/subscriptions.js +103 -0
  114. package/dist/eval/engine/subscriptions.js.map +1 -0
  115. package/dist/eval/engine/trace.d.ts +77 -0
  116. package/dist/eval/engine/trace.d.ts.map +1 -0
  117. package/dist/eval/engine/trace.js +140 -0
  118. package/dist/eval/engine/trace.js.map +1 -0
  119. package/dist/eval/error-diagnostic.d.ts +26 -0
  120. package/dist/eval/error-diagnostic.d.ts.map +1 -0
  121. package/dist/eval/error-diagnostic.js +63 -0
  122. package/dist/eval/error-diagnostic.js.map +1 -0
  123. package/dist/eval/evaluate-expr.d.ts +44 -0
  124. package/dist/eval/evaluate-expr.d.ts.map +1 -0
  125. package/dist/eval/evaluate-expr.js +149 -0
  126. package/dist/eval/evaluate-expr.js.map +1 -0
  127. package/dist/eval/evaluate.d.ts +282 -0
  128. package/dist/eval/evaluate.d.ts.map +1 -0
  129. package/dist/eval/evaluate.js +391 -0
  130. package/dist/eval/evaluate.js.map +1 -0
  131. package/dist/eval/evolution/relocate.d.ts +72 -0
  132. package/dist/eval/evolution/relocate.d.ts.map +1 -0
  133. package/dist/eval/evolution/relocate.js +427 -0
  134. package/dist/eval/evolution/relocate.js.map +1 -0
  135. package/dist/eval/evolution/select.d.ts +11 -0
  136. package/dist/eval/evolution/select.d.ts.map +1 -0
  137. package/dist/eval/evolution/select.js +53 -0
  138. package/dist/eval/evolution/select.js.map +1 -0
  139. package/dist/eval/evolution/upcast.d.ts +13 -0
  140. package/dist/eval/evolution/upcast.d.ts.map +1 -0
  141. package/dist/eval/evolution/upcast.js +88 -0
  142. package/dist/eval/evolution/upcast.js.map +1 -0
  143. package/dist/eval/expr/aggregates.d.ts +75 -0
  144. package/dist/eval/expr/aggregates.d.ts.map +1 -0
  145. package/dist/eval/expr/aggregates.js +991 -0
  146. package/dist/eval/expr/aggregates.js.map +1 -0
  147. package/dist/eval/expr/arithmetic.d.ts +26 -0
  148. package/dist/eval/expr/arithmetic.d.ts.map +1 -0
  149. package/dist/eval/expr/arithmetic.js +387 -0
  150. package/dist/eval/expr/arithmetic.js.map +1 -0
  151. package/dist/eval/expr/between.d.ts +17 -0
  152. package/dist/eval/expr/between.d.ts.map +1 -0
  153. package/dist/eval/expr/between.js +46 -0
  154. package/dist/eval/expr/between.js.map +1 -0
  155. package/dist/eval/expr/binder.d.ts +96 -0
  156. package/dist/eval/expr/binder.d.ts.map +1 -0
  157. package/dist/eval/expr/binder.js +253 -0
  158. package/dist/eval/expr/binder.js.map +1 -0
  159. package/dist/eval/expr/call-dispatch.d.ts +28 -0
  160. package/dist/eval/expr/call-dispatch.d.ts.map +1 -0
  161. package/dist/eval/expr/call-dispatch.js +114 -0
  162. package/dist/eval/expr/call-dispatch.js.map +1 -0
  163. package/dist/eval/expr/collections.d.ts +20 -0
  164. package/dist/eval/expr/collections.d.ts.map +1 -0
  165. package/dist/eval/expr/collections.js +66 -0
  166. package/dist/eval/expr/collections.js.map +1 -0
  167. package/dist/eval/expr/compare.d.ts +36 -0
  168. package/dist/eval/expr/compare.d.ts.map +1 -0
  169. package/dist/eval/expr/compare.js +115 -0
  170. package/dist/eval/expr/compare.js.map +1 -0
  171. package/dist/eval/expr/datasets.d.ts +28 -0
  172. package/dist/eval/expr/datasets.d.ts.map +1 -0
  173. package/dist/eval/expr/datasets.js +304 -0
  174. package/dist/eval/expr/datasets.js.map +1 -0
  175. package/dist/eval/expr/digest.d.ts +23 -0
  176. package/dist/eval/expr/digest.d.ts.map +1 -0
  177. package/dist/eval/expr/digest.js +89 -0
  178. package/dist/eval/expr/digest.js.map +1 -0
  179. package/dist/eval/expr/domains.d.ts +19 -0
  180. package/dist/eval/expr/domains.d.ts.map +1 -0
  181. package/dist/eval/expr/domains.js +18 -0
  182. package/dist/eval/expr/domains.js.map +1 -0
  183. package/dist/eval/expr/host.d.ts +152 -0
  184. package/dist/eval/expr/host.d.ts.map +1 -0
  185. package/dist/eval/expr/host.js +36 -0
  186. package/dist/eval/expr/host.js.map +1 -0
  187. package/dist/eval/expr/lists.d.ts +24 -0
  188. package/dist/eval/expr/lists.d.ts.map +1 -0
  189. package/dist/eval/expr/lists.js +155 -0
  190. package/dist/eval/expr/lists.js.map +1 -0
  191. package/dist/eval/expr/member.d.ts +15 -0
  192. package/dist/eval/expr/member.d.ts.map +1 -0
  193. package/dist/eval/expr/member.js +32 -0
  194. package/dist/eval/expr/member.js.map +1 -0
  195. package/dist/eval/expr/money-ops.d.ts +10 -0
  196. package/dist/eval/expr/money-ops.d.ts.map +1 -0
  197. package/dist/eval/expr/money-ops.js +17 -0
  198. package/dist/eval/expr/money-ops.js.map +1 -0
  199. package/dist/eval/expr/operands.d.ts +27 -0
  200. package/dist/eval/expr/operands.d.ts.map +1 -0
  201. package/dist/eval/expr/operands.js +167 -0
  202. package/dist/eval/expr/operands.js.map +1 -0
  203. package/dist/eval/expr/presence.d.ts +27 -0
  204. package/dist/eval/expr/presence.d.ts.map +1 -0
  205. package/dist/eval/expr/presence.js +140 -0
  206. package/dist/eval/expr/presence.js.map +1 -0
  207. package/dist/eval/expr/records.d.ts +22 -0
  208. package/dist/eval/expr/records.d.ts.map +1 -0
  209. package/dist/eval/expr/records.js +101 -0
  210. package/dist/eval/expr/records.js.map +1 -0
  211. package/dist/eval/expr/rule-refs.d.ts +25 -0
  212. package/dist/eval/expr/rule-refs.d.ts.map +1 -0
  213. package/dist/eval/expr/rule-refs.js +60 -0
  214. package/dist/eval/expr/rule-refs.js.map +1 -0
  215. package/dist/eval/expr/sequences.d.ts +26 -0
  216. package/dist/eval/expr/sequences.d.ts.map +1 -0
  217. package/dist/eval/expr/sequences.js +151 -0
  218. package/dist/eval/expr/sequences.js.map +1 -0
  219. package/dist/eval/expr/value.d.ts +99 -0
  220. package/dist/eval/expr/value.d.ts.map +1 -0
  221. package/dist/eval/expr/value.js +14 -0
  222. package/dist/eval/expr/value.js.map +1 -0
  223. package/dist/eval/expression.d.ts +142 -0
  224. package/dist/eval/expression.d.ts.map +1 -0
  225. package/dist/eval/expression.js +446 -0
  226. package/dist/eval/expression.js.map +1 -0
  227. package/dist/eval/firing.d.ts +68 -0
  228. package/dist/eval/firing.d.ts.map +1 -0
  229. package/dist/eval/firing.js +222 -0
  230. package/dist/eval/firing.js.map +1 -0
  231. package/dist/eval/gate.d.ts +110 -0
  232. package/dist/eval/gate.d.ts.map +1 -0
  233. package/dist/eval/gate.js +278 -0
  234. package/dist/eval/gate.js.map +1 -0
  235. package/dist/eval/layout-visibility.d.ts +18 -0
  236. package/dist/eval/layout-visibility.d.ts.map +1 -0
  237. package/dist/eval/layout-visibility.js +61 -0
  238. package/dist/eval/layout-visibility.js.map +1 -0
  239. package/dist/eval/option-availability.d.ts +26 -0
  240. package/dist/eval/option-availability.d.ts.map +1 -0
  241. package/dist/eval/option-availability.js +580 -0
  242. package/dist/eval/option-availability.js.map +1 -0
  243. package/dist/eval/options-boundary.d.ts +15 -0
  244. package/dist/eval/options-boundary.d.ts.map +1 -0
  245. package/dist/eval/options-boundary.js +40 -0
  246. package/dist/eval/options-boundary.js.map +1 -0
  247. package/dist/eval/options.d.ts +99 -0
  248. package/dist/eval/options.d.ts.map +1 -0
  249. package/dist/eval/options.js +96 -0
  250. package/dist/eval/options.js.map +1 -0
  251. package/dist/eval/overrides.d.ts +116 -0
  252. package/dist/eval/overrides.d.ts.map +1 -0
  253. package/dist/eval/overrides.js +176 -0
  254. package/dist/eval/overrides.js.map +1 -0
  255. package/dist/eval/paths.d.ts +25 -0
  256. package/dist/eval/paths.d.ts.map +1 -0
  257. package/dist/eval/paths.js +47 -0
  258. package/dist/eval/paths.js.map +1 -0
  259. package/dist/eval/presentation-reads.d.ts +20 -0
  260. package/dist/eval/presentation-reads.d.ts.map +1 -0
  261. package/dist/eval/presentation-reads.js +2 -0
  262. package/dist/eval/presentation-reads.js.map +1 -0
  263. package/dist/eval/presentation.d.ts +122 -0
  264. package/dist/eval/presentation.d.ts.map +1 -0
  265. package/dist/eval/presentation.js +255 -0
  266. package/dist/eval/presentation.js.map +1 -0
  267. package/dist/eval/reader/context-value.d.ts +41 -0
  268. package/dist/eval/reader/context-value.d.ts.map +1 -0
  269. package/dist/eval/reader/context-value.js +129 -0
  270. package/dist/eval/reader/context-value.js.map +1 -0
  271. package/dist/eval/reader/covered.d.ts +53 -0
  272. package/dist/eval/reader/covered.d.ts.map +1 -0
  273. package/dist/eval/reader/covered.js +139 -0
  274. package/dist/eval/reader/covered.js.map +1 -0
  275. package/dist/eval/reader/declarations.d.ts +182 -0
  276. package/dist/eval/reader/declarations.d.ts.map +1 -0
  277. package/dist/eval/reader/declarations.js +153 -0
  278. package/dist/eval/reader/declarations.js.map +1 -0
  279. package/dist/eval/reader/member-access.d.ts +87 -0
  280. package/dist/eval/reader/member-access.d.ts.map +1 -0
  281. package/dist/eval/reader/member-access.js +212 -0
  282. package/dist/eval/reader/member-access.js.map +1 -0
  283. package/dist/eval/reader/memo.d.ts +34 -0
  284. package/dist/eval/reader/memo.d.ts.map +1 -0
  285. package/dist/eval/reader/memo.js +67 -0
  286. package/dist/eval/reader/memo.js.map +1 -0
  287. package/dist/eval/reader/overlay.d.ts +74 -0
  288. package/dist/eval/reader/overlay.d.ts.map +1 -0
  289. package/dist/eval/reader/overlay.js +365 -0
  290. package/dist/eval/reader/overlay.js.map +1 -0
  291. package/dist/eval/reader/questions.d.ts +37 -0
  292. package/dist/eval/reader/questions.d.ts.map +1 -0
  293. package/dist/eval/reader/questions.js +78 -0
  294. package/dist/eval/reader/questions.js.map +1 -0
  295. package/dist/eval/reader/resolve.d.ts +84 -0
  296. package/dist/eval/reader/resolve.d.ts.map +1 -0
  297. package/dist/eval/reader/resolve.js +310 -0
  298. package/dist/eval/reader/resolve.js.map +1 -0
  299. package/dist/eval/reader/value-read.d.ts +50 -0
  300. package/dist/eval/reader/value-read.d.ts.map +1 -0
  301. package/dist/eval/reader/value-read.js +133 -0
  302. package/dist/eval/reader/value-read.js.map +1 -0
  303. package/dist/eval/reader/withheld.d.ts +48 -0
  304. package/dist/eval/reader/withheld.d.ts.map +1 -0
  305. package/dist/eval/reader/withheld.js +108 -0
  306. package/dist/eval/reader/withheld.js.map +1 -0
  307. package/dist/eval/reader-paths.d.ts +24 -0
  308. package/dist/eval/reader-paths.d.ts.map +1 -0
  309. package/dist/eval/reader-paths.js +23 -0
  310. package/dist/eval/reader-paths.js.map +1 -0
  311. package/dist/eval/reader.d.ts +281 -0
  312. package/dist/eval/reader.d.ts.map +1 -0
  313. package/dist/eval/reader.js +560 -0
  314. package/dist/eval/reader.js.map +1 -0
  315. package/dist/eval/receipt.d.ts +37 -0
  316. package/dist/eval/receipt.d.ts.map +1 -0
  317. package/dist/eval/receipt.js +222 -0
  318. package/dist/eval/receipt.js.map +1 -0
  319. package/dist/eval/report/assemble.d.ts +84 -0
  320. package/dist/eval/report/assemble.d.ts.map +1 -0
  321. package/dist/eval/report/assemble.js +277 -0
  322. package/dist/eval/report/assemble.js.map +1 -0
  323. package/dist/eval/report/fold.d.ts +18 -0
  324. package/dist/eval/report/fold.d.ts.map +1 -0
  325. package/dist/eval/report/fold.js +58 -0
  326. package/dist/eval/report/fold.js.map +1 -0
  327. package/dist/eval/rule/alternatives.d.ts +23 -0
  328. package/dist/eval/rule/alternatives.d.ts.map +1 -0
  329. package/dist/eval/rule/alternatives.js +46 -0
  330. package/dist/eval/rule/alternatives.js.map +1 -0
  331. package/dist/eval/rule/behaviour.d.ts +47 -0
  332. package/dist/eval/rule/behaviour.d.ts.map +1 -0
  333. package/dist/eval/rule/behaviour.js +249 -0
  334. package/dist/eval/rule/behaviour.js.map +1 -0
  335. package/dist/eval/rule/compute.d.ts +46 -0
  336. package/dist/eval/rule/compute.d.ts.map +1 -0
  337. package/dist/eval/rule/compute.js +158 -0
  338. package/dist/eval/rule/compute.js.map +1 -0
  339. package/dist/eval/rule/create-state.d.ts +42 -0
  340. package/dist/eval/rule/create-state.d.ts.map +1 -0
  341. package/dist/eval/rule/create-state.js +134 -0
  342. package/dist/eval/rule/create-state.js.map +1 -0
  343. package/dist/eval/rule/diagnostics.d.ts +24 -0
  344. package/dist/eval/rule/diagnostics.d.ts.map +1 -0
  345. package/dist/eval/rule/diagnostics.js +45 -0
  346. package/dist/eval/rule/diagnostics.js.map +1 -0
  347. package/dist/eval/rule/execution.d.ts +24 -0
  348. package/dist/eval/rule/execution.d.ts.map +1 -0
  349. package/dist/eval/rule/execution.js +495 -0
  350. package/dist/eval/rule/execution.js.map +1 -0
  351. package/dist/eval/rule/gate.d.ts +12 -0
  352. package/dist/eval/rule/gate.d.ts.map +1 -0
  353. package/dist/eval/rule/gate.js +34 -0
  354. package/dist/eval/rule/gate.js.map +1 -0
  355. package/dist/eval/rule/item.d.ts +11 -0
  356. package/dist/eval/rule/item.d.ts.map +1 -0
  357. package/dist/eval/rule/item.js +265 -0
  358. package/dist/eval/rule/item.js.map +1 -0
  359. package/dist/eval/rule/prepare.d.ts +64 -0
  360. package/dist/eval/rule/prepare.d.ts.map +1 -0
  361. package/dist/eval/rule/prepare.js +131 -0
  362. package/dist/eval/rule/prepare.js.map +1 -0
  363. package/dist/eval/rule/result.d.ts +97 -0
  364. package/dist/eval/rule/result.d.ts.map +1 -0
  365. package/dist/eval/rule/result.js +347 -0
  366. package/dist/eval/rule/result.js.map +1 -0
  367. package/dist/eval/rule/runner.d.ts +128 -0
  368. package/dist/eval/rule/runner.d.ts.map +1 -0
  369. package/dist/eval/rule/runner.js +296 -0
  370. package/dist/eval/rule/runner.js.map +1 -0
  371. package/dist/eval/rule/screen.d.ts +32 -0
  372. package/dist/eval/rule/screen.d.ts.map +1 -0
  373. package/dist/eval/rule/screen.js +73 -0
  374. package/dist/eval/rule/screen.js.map +1 -0
  375. package/dist/eval/rule/state.d.ts +137 -0
  376. package/dist/eval/rule/state.d.ts.map +1 -0
  377. package/dist/eval/rule/state.js +2 -0
  378. package/dist/eval/rule/state.js.map +1 -0
  379. package/dist/eval/rule/steps.d.ts +44 -0
  380. package/dist/eval/rule/steps.d.ts.map +1 -0
  381. package/dist/eval/rule/steps.js +367 -0
  382. package/dist/eval/rule/steps.js.map +1 -0
  383. package/dist/eval/rule/visibility.d.ts +18 -0
  384. package/dist/eval/rule/visibility.d.ts.map +1 -0
  385. package/dist/eval/rule/visibility.js +79 -0
  386. package/dist/eval/rule/visibility.js.map +1 -0
  387. package/dist/eval/seal.d.ts +74 -0
  388. package/dist/eval/seal.d.ts.map +1 -0
  389. package/dist/eval/seal.js +154 -0
  390. package/dist/eval/seal.js.map +1 -0
  391. package/dist/eval/signature-coverage.d.ts +19 -0
  392. package/dist/eval/signature-coverage.d.ts.map +1 -0
  393. package/dist/eval/signature-coverage.js +160 -0
  394. package/dist/eval/signature-coverage.js.map +1 -0
  395. package/dist/eval/state/derive.d.ts +72 -0
  396. package/dist/eval/state/derive.d.ts.map +1 -0
  397. package/dist/eval/state/derive.js +61 -0
  398. package/dist/eval/state/derive.js.map +1 -0
  399. package/dist/eval/state/describe.d.ts +18 -0
  400. package/dist/eval/state/describe.d.ts.map +1 -0
  401. package/dist/eval/state/describe.js +19 -0
  402. package/dist/eval/state/describe.js.map +1 -0
  403. package/dist/eval/state/field-state.d.ts +471 -0
  404. package/dist/eval/state/field-state.d.ts.map +1 -0
  405. package/dist/eval/state/field-state.js +1604 -0
  406. package/dist/eval/state/field-state.js.map +1 -0
  407. package/dist/eval/state/measurement.d.ts +136 -0
  408. package/dist/eval/state/measurement.d.ts.map +1 -0
  409. package/dist/eval/state/measurement.js +209 -0
  410. package/dist/eval/state/measurement.js.map +1 -0
  411. package/dist/eval/state/options.d.ts +21 -0
  412. package/dist/eval/state/options.d.ts.map +1 -0
  413. package/dist/eval/state/options.js +3 -0
  414. package/dist/eval/state/options.js.map +1 -0
  415. package/dist/eval/state/readiness.d.ts +400 -0
  416. package/dist/eval/state/readiness.d.ts.map +1 -0
  417. package/dist/eval/state/readiness.js +1067 -0
  418. package/dist/eval/state/readiness.js.map +1 -0
  419. package/dist/eval/state/snapshot.d.ts +130 -0
  420. package/dist/eval/state/snapshot.d.ts.map +1 -0
  421. package/dist/eval/state/snapshot.js +35 -0
  422. package/dist/eval/state/snapshot.js.map +1 -0
  423. package/dist/eval/state/unavailable-options.d.ts +54 -0
  424. package/dist/eval/state/unavailable-options.d.ts.map +1 -0
  425. package/dist/eval/state/unavailable-options.js +82 -0
  426. package/dist/eval/state/unavailable-options.js.map +1 -0
  427. package/dist/eval/state/value-state.d.ts +38 -0
  428. package/dist/eval/state/value-state.d.ts.map +1 -0
  429. package/dist/eval/state/value-state.js +52 -0
  430. package/dist/eval/state/value-state.js.map +1 -0
  431. package/dist/eval/submission/admission.d.ts +50 -0
  432. package/dist/eval/submission/admission.d.ts.map +1 -0
  433. package/dist/eval/submission/admission.js +174 -0
  434. package/dist/eval/submission/admission.js.map +1 -0
  435. package/dist/eval/submission/authority.d.ts +71 -0
  436. package/dist/eval/submission/authority.d.ts.map +1 -0
  437. package/dist/eval/submission/authority.js +118 -0
  438. package/dist/eval/submission/authority.js.map +1 -0
  439. package/dist/eval/submission/datasets.d.ts +28 -0
  440. package/dist/eval/submission/datasets.d.ts.map +1 -0
  441. package/dist/eval/submission/datasets.js +109 -0
  442. package/dist/eval/submission/datasets.js.map +1 -0
  443. package/dist/eval/submission/index.d.ts +15 -0
  444. package/dist/eval/submission/index.d.ts.map +1 -0
  445. package/dist/eval/submission/index.js +13 -0
  446. package/dist/eval/submission/index.js.map +1 -0
  447. package/dist/eval/submission/refusals.d.ts +103 -0
  448. package/dist/eval/submission/refusals.d.ts.map +1 -0
  449. package/dist/eval/submission/refusals.js +15 -0
  450. package/dist/eval/submission/refusals.js.map +1 -0
  451. package/dist/eval/submission/signatures.d.ts +7 -0
  452. package/dist/eval/submission/signatures.d.ts.map +1 -0
  453. package/dist/eval/submission/signatures.js +215 -0
  454. package/dist/eval/submission/signatures.js.map +1 -0
  455. package/dist/eval/submission/writes.d.ts +51 -0
  456. package/dist/eval/submission/writes.d.ts.map +1 -0
  457. package/dist/eval/submission/writes.js +203 -0
  458. package/dist/eval/submission/writes.js.map +1 -0
  459. package/dist/eval/submission.d.ts +53 -0
  460. package/dist/eval/submission.d.ts.map +1 -0
  461. package/dist/eval/submission.js +521 -0
  462. package/dist/eval/submission.js.map +1 -0
  463. package/dist/eval/suggestions-to-engine.d.ts +18 -0
  464. package/dist/eval/suggestions-to-engine.d.ts.map +1 -0
  465. package/dist/eval/suggestions-to-engine.js +40 -0
  466. package/dist/eval/suggestions-to-engine.js.map +1 -0
  467. package/dist/eval/suggestions.d.ts +17 -0
  468. package/dist/eval/suggestions.d.ts.map +1 -0
  469. package/dist/eval/suggestions.js +314 -0
  470. package/dist/eval/suggestions.js.map +1 -0
  471. package/dist/eval/undecided.d.ts +64 -0
  472. package/dist/eval/undecided.d.ts.map +1 -0
  473. package/dist/eval/undecided.js +101 -0
  474. package/dist/eval/undecided.js.map +1 -0
  475. package/dist/eval/verdict.d.ts +66 -0
  476. package/dist/eval/verdict.d.ts.map +1 -0
  477. package/dist/eval/verdict.js +106 -0
  478. package/dist/eval/verdict.js.map +1 -0
  479. package/dist/eval/verify-signature.d.ts +78 -0
  480. package/dist/eval/verify-signature.d.ts.map +1 -0
  481. package/dist/eval/verify-signature.js +185 -0
  482. package/dist/eval/verify-signature.js.map +1 -0
  483. package/dist/eval/version-dispatch.d.ts +38 -0
  484. package/dist/eval/version-dispatch.d.ts.map +1 -0
  485. package/dist/eval/version-dispatch.js +61 -0
  486. package/dist/eval/version-dispatch.js.map +1 -0
  487. package/dist/eval/visibility.d.ts +33 -0
  488. package/dist/eval/visibility.d.ts.map +1 -0
  489. package/dist/eval/visibility.js +83 -0
  490. package/dist/eval/visibility.js.map +1 -0
  491. package/dist/evaluate.d.ts +24 -0
  492. package/dist/evaluate.d.ts.map +1 -0
  493. package/dist/evaluate.js +18 -0
  494. package/dist/evaluate.js.map +1 -0
  495. package/dist/expr/builtin-docs.d.ts +51 -0
  496. package/dist/expr/builtin-docs.d.ts.map +1 -0
  497. package/dist/expr/builtin-docs.js +874 -0
  498. package/dist/expr/builtin-docs.js.map +1 -0
  499. package/dist/expr/builtins.d.ts +50 -0
  500. package/dist/expr/builtins.d.ts.map +1 -0
  501. package/dist/expr/builtins.js +966 -0
  502. package/dist/expr/builtins.js.map +1 -0
  503. package/dist/expr/decimal-precision.d.ts +39 -0
  504. package/dist/expr/decimal-precision.d.ts.map +1 -0
  505. package/dist/expr/decimal-precision.js +62 -0
  506. package/dist/expr/decimal-precision.js.map +1 -0
  507. package/dist/expr/decimal.d.ts +172 -0
  508. package/dist/expr/decimal.d.ts.map +1 -0
  509. package/dist/expr/decimal.js +782 -0
  510. package/dist/expr/decimal.js.map +1 -0
  511. package/dist/expr/deprecations.d.ts +34 -0
  512. package/dist/expr/deprecations.d.ts.map +1 -0
  513. package/dist/expr/deprecations.js +17 -0
  514. package/dist/expr/deprecations.js.map +1 -0
  515. package/dist/expr/diagnostics.d.ts +21 -0
  516. package/dist/expr/diagnostics.d.ts.map +1 -0
  517. package/dist/expr/diagnostics.js +231 -0
  518. package/dist/expr/diagnostics.js.map +1 -0
  519. package/dist/expr/direction.d.ts +30 -0
  520. package/dist/expr/direction.d.ts.map +1 -0
  521. package/dist/expr/direction.js +77 -0
  522. package/dist/expr/direction.js.map +1 -0
  523. package/dist/expr/example-expression.d.ts +62 -0
  524. package/dist/expr/example-expression.d.ts.map +1 -0
  525. package/dist/expr/example-expression.js +670 -0
  526. package/dist/expr/example-expression.js.map +1 -0
  527. package/dist/expr/instant.d.ts +49 -0
  528. package/dist/expr/instant.d.ts.map +1 -0
  529. package/dist/expr/instant.js +111 -0
  530. package/dist/expr/instant.js.map +1 -0
  531. package/dist/expr/logic.d.ts +17 -0
  532. package/dist/expr/logic.d.ts.map +1 -0
  533. package/dist/expr/logic.js +65 -0
  534. package/dist/expr/logic.js.map +1 -0
  535. package/dist/expr/messages.d.ts +45 -0
  536. package/dist/expr/messages.d.ts.map +1 -0
  537. package/dist/expr/messages.js +280 -0
  538. package/dist/expr/messages.js.map +1 -0
  539. package/dist/expr/money.d.ts +38 -0
  540. package/dist/expr/money.d.ts.map +1 -0
  541. package/dist/expr/money.js +127 -0
  542. package/dist/expr/money.js.map +1 -0
  543. package/dist/expr/ordering.d.ts +56 -0
  544. package/dist/expr/ordering.d.ts.map +1 -0
  545. package/dist/expr/ordering.js +167 -0
  546. package/dist/expr/ordering.js.map +1 -0
  547. package/dist/expr/pattern.d.ts +44 -0
  548. package/dist/expr/pattern.d.ts.map +1 -0
  549. package/dist/expr/pattern.js +458 -0
  550. package/dist/expr/pattern.js.map +1 -0
  551. package/dist/expr/plain-date.d.ts +90 -0
  552. package/dist/expr/plain-date.d.ts.map +1 -0
  553. package/dist/expr/plain-date.js +230 -0
  554. package/dist/expr/plain-date.js.map +1 -0
  555. package/dist/expr/plural-categories.d.ts +8 -0
  556. package/dist/expr/plural-categories.d.ts.map +1 -0
  557. package/dist/expr/plural-categories.js +15 -0
  558. package/dist/expr/plural-categories.js.map +1 -0
  559. package/dist/expr/plural-keys.d.ts +39 -0
  560. package/dist/expr/plural-keys.d.ts.map +1 -0
  561. package/dist/expr/plural-keys.js +46 -0
  562. package/dist/expr/plural-keys.js.map +1 -0
  563. package/dist/expr/plural.d.ts +33 -0
  564. package/dist/expr/plural.d.ts.map +1 -0
  565. package/dist/expr/plural.js +50 -0
  566. package/dist/expr/plural.js.map +1 -0
  567. package/dist/expr/quantity.d.ts +31 -0
  568. package/dist/expr/quantity.d.ts.map +1 -0
  569. package/dist/expr/quantity.js +83 -0
  570. package/dist/expr/quantity.js.map +1 -0
  571. package/dist/expr/reduce.d.ts +50 -0
  572. package/dist/expr/reduce.d.ts.map +1 -0
  573. package/dist/expr/reduce.js +236 -0
  574. package/dist/expr/reduce.js.map +1 -0
  575. package/dist/expr/regex.d.ts +108 -0
  576. package/dist/expr/regex.d.ts.map +1 -0
  577. package/dist/expr/regex.js +1207 -0
  578. package/dist/expr/regex.js.map +1 -0
  579. package/dist/expr/select-locale.d.ts +67 -0
  580. package/dist/expr/select-locale.d.ts.map +1 -0
  581. package/dist/expr/select-locale.js +219 -0
  582. package/dist/expr/select-locale.js.map +1 -0
  583. package/dist/expr/sequences.d.ts +123 -0
  584. package/dist/expr/sequences.d.ts.map +1 -0
  585. package/dist/expr/sequences.js +234 -0
  586. package/dist/expr/sequences.js.map +1 -0
  587. package/dist/expr/strings.d.ts +50 -0
  588. package/dist/expr/strings.d.ts.map +1 -0
  589. package/dist/expr/strings.js +184 -0
  590. package/dist/expr/strings.js.map +1 -0
  591. package/dist/expr/validation.d.ts +32 -0
  592. package/dist/expr/validation.d.ts.map +1 -0
  593. package/dist/expr/validation.js +182 -0
  594. package/dist/expr/validation.js.map +1 -0
  595. package/dist/graph/freeze.d.ts +4 -0
  596. package/dist/graph/freeze.d.ts.map +1 -0
  597. package/dist/graph/freeze.js +52 -0
  598. package/dist/graph/freeze.js.map +1 -0
  599. package/dist/graph/index.d.ts +15 -0
  600. package/dist/graph/index.d.ts.map +1 -0
  601. package/dist/graph/index.js +13 -0
  602. package/dist/graph/index.js.map +1 -0
  603. package/dist/graph/inspect.d.ts +76 -0
  604. package/dist/graph/inspect.d.ts.map +1 -0
  605. package/dist/graph/inspect.js +263 -0
  606. package/dist/graph/inspect.js.map +1 -0
  607. package/dist/graph/read-walk.d.ts +101 -0
  608. package/dist/graph/read-walk.d.ts.map +1 -0
  609. package/dist/graph/read-walk.js +358 -0
  610. package/dist/graph/read-walk.js.map +1 -0
  611. package/dist/graph/record-index.d.ts +24 -0
  612. package/dist/graph/record-index.d.ts.map +1 -0
  613. package/dist/graph/record-index.js +35 -0
  614. package/dist/graph/record-index.js.map +1 -0
  615. package/dist/index.d.ts +104 -0
  616. package/dist/index.d.ts.map +1 -0
  617. package/dist/index.js +139 -0
  618. package/dist/index.js.map +1 -0
  619. package/dist/lookup/digest.d.ts +51 -0
  620. package/dist/lookup/digest.d.ts.map +1 -0
  621. package/dist/lookup/digest.js +46 -0
  622. package/dist/lookup/digest.js.map +1 -0
  623. package/dist/lookup/index.d.ts +28 -0
  624. package/dist/lookup/index.d.ts.map +1 -0
  625. package/dist/lookup/index.js +27 -0
  626. package/dist/lookup/index.js.map +1 -0
  627. package/dist/lookup/install.d.ts +48 -0
  628. package/dist/lookup/install.d.ts.map +1 -0
  629. package/dist/lookup/install.js +315 -0
  630. package/dist/lookup/install.js.map +1 -0
  631. package/dist/lookup/pass.d.ts +55 -0
  632. package/dist/lookup/pass.d.ts.map +1 -0
  633. package/dist/lookup/pass.js +212 -0
  634. package/dist/lookup/pass.js.map +1 -0
  635. package/dist/lookup/pins.d.ts +34 -0
  636. package/dist/lookup/pins.d.ts.map +1 -0
  637. package/dist/lookup/pins.js +39 -0
  638. package/dist/lookup/pins.js.map +1 -0
  639. package/dist/lookup/provenance.d.ts +23 -0
  640. package/dist/lookup/provenance.d.ts.map +1 -0
  641. package/dist/lookup/provenance.js +78 -0
  642. package/dist/lookup/provenance.js.map +1 -0
  643. package/dist/lookup/readiness.d.ts +13 -0
  644. package/dist/lookup/readiness.d.ts.map +1 -0
  645. package/dist/lookup/readiness.js +57 -0
  646. package/dist/lookup/readiness.js.map +1 -0
  647. package/dist/lookup/resolve.d.ts +24 -0
  648. package/dist/lookup/resolve.d.ts.map +1 -0
  649. package/dist/lookup/resolve.js +201 -0
  650. package/dist/lookup/resolve.js.map +1 -0
  651. package/dist/lookup/store.d.ts +41 -0
  652. package/dist/lookup/store.d.ts.map +1 -0
  653. package/dist/lookup/store.js +74 -0
  654. package/dist/lookup/store.js.map +1 -0
  655. package/dist/model/access.d.ts +200 -0
  656. package/dist/model/access.d.ts.map +1 -0
  657. package/dist/model/access.js +125 -0
  658. package/dist/model/access.js.map +1 -0
  659. package/dist/model/artifact-members.d.ts +3 -0
  660. package/dist/model/artifact-members.d.ts.map +1 -0
  661. package/dist/model/artifact-members.js +38 -0
  662. package/dist/model/artifact-members.js.map +1 -0
  663. package/dist/model/composition.d.ts +47 -0
  664. package/dist/model/composition.d.ts.map +1 -0
  665. package/dist/model/composition.js +66 -0
  666. package/dist/model/composition.js.map +1 -0
  667. package/dist/model/domain.d.ts +51 -0
  668. package/dist/model/domain.d.ts.map +1 -0
  669. package/dist/model/domain.js +75 -0
  670. package/dist/model/domain.js.map +1 -0
  671. package/dist/model/duration.d.ts +31 -0
  672. package/dist/model/duration.d.ts.map +1 -0
  673. package/dist/model/duration.js +136 -0
  674. package/dist/model/duration.js.map +1 -0
  675. package/dist/model/errors.d.ts +58 -0
  676. package/dist/model/errors.d.ts.map +1 -0
  677. package/dist/model/errors.js +81 -0
  678. package/dist/model/errors.js.map +1 -0
  679. package/dist/model/evolution.d.ts +177 -0
  680. package/dist/model/evolution.d.ts.map +1 -0
  681. package/dist/model/evolution.js +5 -0
  682. package/dist/model/evolution.js.map +1 -0
  683. package/dist/model/expr-children.d.ts +15 -0
  684. package/dist/model/expr-children.d.ts.map +1 -0
  685. package/dist/model/expr-children.js +45 -0
  686. package/dist/model/expr-children.js.map +1 -0
  687. package/dist/model/guards.d.ts +9 -0
  688. package/dist/model/guards.d.ts.map +1 -0
  689. package/dist/model/guards.js +11 -0
  690. package/dist/model/guards.js.map +1 -0
  691. package/dist/model/input.d.ts +42 -0
  692. package/dist/model/input.d.ts.map +1 -0
  693. package/dist/model/input.js +26 -0
  694. package/dist/model/input.js.map +1 -0
  695. package/dist/model/integer.d.ts +14 -0
  696. package/dist/model/integer.d.ts.map +1 -0
  697. package/dist/model/integer.js +16 -0
  698. package/dist/model/integer.js.map +1 -0
  699. package/dist/model/intrinsic.d.ts +18 -0
  700. package/dist/model/intrinsic.d.ts.map +1 -0
  701. package/dist/model/intrinsic.js +21 -0
  702. package/dist/model/intrinsic.js.map +1 -0
  703. package/dist/model/layout.d.ts +129 -0
  704. package/dist/model/layout.d.ts.map +1 -0
  705. package/dist/model/layout.js +2 -0
  706. package/dist/model/layout.js.map +1 -0
  707. package/dist/model/media.d.ts +33 -0
  708. package/dist/model/media.d.ts.map +1 -0
  709. package/dist/model/media.js +86 -0
  710. package/dist/model/media.js.map +1 -0
  711. package/dist/model/members.generated.d.ts +11 -0
  712. package/dist/model/members.generated.d.ts.map +1 -0
  713. package/dist/model/members.generated.js +71 -0
  714. package/dist/model/members.generated.js.map +1 -0
  715. package/dist/model/row-address.d.ts +27 -0
  716. package/dist/model/row-address.d.ts.map +1 -0
  717. package/dist/model/row-address.js +146 -0
  718. package/dist/model/row-address.js.map +1 -0
  719. package/dist/model/schema.d.ts +108 -0
  720. package/dist/model/schema.d.ts.map +1 -0
  721. package/dist/model/schema.js +2 -0
  722. package/dist/model/schema.js.map +1 -0
  723. package/dist/model/shape.d.ts +193 -0
  724. package/dist/model/shape.d.ts.map +1 -0
  725. package/dist/model/shape.js +2 -0
  726. package/dist/model/shape.js.map +1 -0
  727. package/dist/model/time.d.ts +61 -0
  728. package/dist/model/time.d.ts.map +1 -0
  729. package/dist/model/time.js +110 -0
  730. package/dist/model/time.js.map +1 -0
  731. package/dist/model/types.d.ts +1329 -0
  732. package/dist/model/types.d.ts.map +1 -0
  733. package/dist/model/types.js +424 -0
  734. package/dist/model/types.js.map +1 -0
  735. package/dist/model/values.d.ts +91 -0
  736. package/dist/model/values.d.ts.map +1 -0
  737. package/dist/model/values.js +195 -0
  738. package/dist/model/values.js.map +1 -0
  739. package/dist/model/wire.d.ts +356 -0
  740. package/dist/model/wire.d.ts.map +1 -0
  741. package/dist/model/wire.js +1504 -0
  742. package/dist/model/wire.js.map +1 -0
  743. package/dist/offline/index.d.ts +374 -0
  744. package/dist/offline/index.d.ts.map +1 -0
  745. package/dist/offline/index.js +422 -0
  746. package/dist/offline/index.js.map +1 -0
  747. package/dist/testing.d.ts +30 -0
  748. package/dist/testing.d.ts.map +1 -0
  749. package/dist/testing.js +42 -0
  750. package/dist/testing.js.map +1 -0
  751. package/dist/version.d.ts +30 -0
  752. package/dist/version.d.ts.map +1 -0
  753. package/dist/version.js +116 -0
  754. package/dist/version.js.map +1 -0
  755. package/package.json +98 -3
@@ -0,0 +1,315 @@
1
+ import { canonicalizeRestricted, canonicalHash } from '../canonical/jcs.js';
2
+ import { daysFromCivil, parsePlainDate } from '../expr/plain-date.js';
3
+ import { AxiomError, LateBoundTypeMismatch } from '../model/errors.js';
4
+ import { toHostWireValue, wireDeclarationOfColumn } from '../model/wire.js';
5
+ /**
6
+ * The row-count bounds a bounded `COLLECT` hit may declare, `DATA-3.1.5`: the metaschema's
7
+ * `collectLimit` states the same `minimum` and `maximum`, so a document outside them is already
8
+ * one the compiler refuses. The runtime restates the bound rather than trusting the document,
9
+ * because a store may be handed one no compiler produced.
10
+ */
11
+ const COLLECT_LIMIT_MIN = 1;
12
+ const COLLECT_LIMIT_MAX = 1000;
13
+ /** Canonical text of a key or member, with the table named in any refusal. */
14
+ export function canonicalKey(value, context) {
15
+ try {
16
+ return canonicalizeRestricted(value);
17
+ }
18
+ catch (error) {
19
+ if (error instanceof AxiomError) {
20
+ throw new AxiomError(error.code, `${context}: ${error.message}`, error.path);
21
+ }
22
+ throw error;
23
+ }
24
+ }
25
+ /** A plain date as epoch days, with the table named in any refusal. */
26
+ export function dateToDay(text, context) {
27
+ const date = parsePlainDate(text, context);
28
+ return daysFromCivil(date.year, date.month, date.day);
29
+ }
30
+ /** Refuses a table the store cannot answer from, naming it in the error path. */
31
+ export function refuseTable(tableId, message) {
32
+ throw new AxiomError('ENGINE_ERROR', message, tableId);
33
+ }
34
+ function documentProblem(document, detail) {
35
+ return { tableId: document.tableId, detail };
36
+ }
37
+ function problem(kind, tableId, detail) {
38
+ return { kind, tableId, detail };
39
+ }
40
+ /**
41
+ * Checks every document, refuses the first that cannot answer a call, then refuses a set of
42
+ * versions that cannot be one installation. Both checks run before any version is prepared,
43
+ * so a refused catalog leaves no half-installed store.
44
+ */
45
+ export function prepareInstallation(documents) {
46
+ for (const document of documents) {
47
+ const problems = documentProblems(document);
48
+ const first = problems[0];
49
+ if (first !== undefined)
50
+ refuseTable(first.tableId, first.detail);
51
+ }
52
+ const problems = datasetInstallationProblems(documents);
53
+ const first = problems[0];
54
+ if (first !== undefined)
55
+ refuseTable(first.tableId, first.detail);
56
+ const tables = new Map();
57
+ for (const document of documents)
58
+ addDocument(tables, prepare(document));
59
+ return tables;
60
+ }
61
+ /** Adds one prepared version to its table, keeping versions ordered by window start. */
62
+ function addDocument(tables, prepared) {
63
+ const document = prepared.document;
64
+ const known = tables.get(document.tableId);
65
+ if (known === undefined) {
66
+ tables.set(document.tableId, { versions: [prepared] });
67
+ return;
68
+ }
69
+ const versions = [...known.versions, prepared].sort((a, b) => {
70
+ const left = a.effectiveFrom ?? 0;
71
+ const right = b.effectiveFrom ?? 0;
72
+ return left - right;
73
+ });
74
+ tables.set(document.tableId, { versions });
75
+ }
76
+ /** A problem one dataset document has on its own, before any version is compared. */
77
+ function documentProblems(document) {
78
+ const problems = [];
79
+ const from = document.effectiveFrom;
80
+ const to = document.effectiveTo;
81
+ if (document.binding === 'behavior') {
82
+ if (from !== undefined || to !== undefined) {
83
+ problems.push(documentProblem(document, `table ${document.tableId} is behavior-bound and declares no effective range`));
84
+ }
85
+ return problems;
86
+ }
87
+ if (from === undefined || to === undefined) {
88
+ problems.push(documentProblem(document, `table ${document.tableId} is data-bound and must declare effectiveFrom and effectiveTo`));
89
+ return problems;
90
+ }
91
+ // The metaschema checks the spelling of a date, not that it is one, and says nothing about
92
+ // the order of the two bounds.
93
+ const start = dateToDay(from, document.tableId);
94
+ const end = dateToDay(to, document.tableId);
95
+ if (start >= end) {
96
+ problems.push(documentProblem(document, `table ${document.tableId} has an empty effective range`));
97
+ }
98
+ return problems;
99
+ }
100
+ /**
101
+ * The invariants a set of table versions must satisfy to be one installation.
102
+ *
103
+ * A table id names one table; a data-bound table's versions are distinguished by their
104
+ * half-open windows, so two versions covering one date would make a resolution ambiguous
105
+ * and two versions sharing a number would make provenance unreproducible. The check is
106
+ * exported because the compiler refuses the same catalog at publish time: the store cannot
107
+ * be the first place an operator learns that two published windows overlap.
108
+ */
109
+ export function datasetInstallationProblems(documents) {
110
+ const problems = [];
111
+ const versions = new Map();
112
+ for (const document of documents) {
113
+ const known = versions.get(document.tableId);
114
+ if (known === undefined)
115
+ versions.set(document.tableId, [document]);
116
+ else
117
+ known.push(document);
118
+ }
119
+ for (const [tableId, group] of versions) {
120
+ // A table id names one table, so its versions agree on what kind of table it is and how
121
+ // it is clocked. A catalog that mixes them would let `in_set`, `lookup`
122
+ // or `decide` answer from a version of another kind.
123
+ const kinds = new Set(group.map((document) => document.kind));
124
+ const bindings = new Set(group.map((document) => document.binding));
125
+ if (kinds.size > 1) {
126
+ problems.push(problem('inconsistent_table', tableId, `table ${tableId} is declared as more than one kind (${[...kinds].sort().join(', ')}); makes the table id name one table`));
127
+ }
128
+ if (bindings.size > 1) {
129
+ problems.push(problem('inconsistent_table', tableId, `table ${tableId} declares more than one clock binding (${[...bindings].sort().join(', ')}); makes the table id name one table`));
130
+ }
131
+ const numbers = new Set();
132
+ for (const document of group) {
133
+ if (numbers.has(document.tableVersion)) {
134
+ problems.push(problem('duplicate_version', tableId, `table ${tableId} version ${String(document.tableVersion)} is declared twice`));
135
+ }
136
+ numbers.add(document.tableVersion);
137
+ }
138
+ if (group.some((document) => document.binding === 'behavior') && group.length > 1) {
139
+ problems.push(problem('multiple_behavior_versions', tableId, `table ${tableId} is behavior-bound and pins to the case, so it declares one version`));
140
+ continue;
141
+ }
142
+ const windowsByVersion = new Map();
143
+ for (const document of group) {
144
+ const from = document.effectiveFrom;
145
+ const to = document.effectiveTo;
146
+ // A repeated version number is already a problem of its own; comparing it with itself
147
+ // would report the same mistake twice.
148
+ if (from === undefined || to === undefined)
149
+ continue;
150
+ if (!windowsByVersion.has(document.tableVersion)) {
151
+ windowsByVersion.set(document.tableVersion, {
152
+ version: document.tableVersion,
153
+ from: dateToDay(from, tableId),
154
+ to: dateToDay(to, tableId),
155
+ });
156
+ }
157
+ }
158
+ const windows = [...windowsByVersion.values()];
159
+ windows.sort((a, b) => a.from - b.from);
160
+ for (let index = 1; index < windows.length; index += 1) {
161
+ const previous = windows[index - 1];
162
+ const current = windows[index];
163
+ if (previous === undefined || current === undefined)
164
+ continue;
165
+ if (current.from < previous.to) {
166
+ problems.push(problem('overlapping_window', tableId, `table ${tableId} versions ${String(previous.version)} and ${String(current.version)} have overlapping effective windows`));
167
+ }
168
+ // A version's number increases with the window it covers, so an
169
+ // older window carrying a higher number is a publication that went backwards.
170
+ if (current.version <= previous.version) {
171
+ problems.push(problem('version_order', tableId, `table ${tableId} version ${String(current.version)} covers a later window than version ${String(previous.version)}; makes the version increase with each publication`));
172
+ }
173
+ }
174
+ }
175
+ return problems;
176
+ }
177
+ /** One column value against its declared primitive, with the row and column named. */
178
+ function checkColumnValue(document, column, value, path) {
179
+ try {
180
+ return toHostWireValue(value, path, wireDeclarationOfColumn(column));
181
+ }
182
+ catch (error) {
183
+ if (!(error instanceof AxiomError))
184
+ throw error;
185
+ const detail = `table ${document.tableId} column ${column.columnId}: ${error.message}`;
186
+ if (error instanceof LateBoundTypeMismatch) {
187
+ // The dataset document is host data, so a wrong domain keeps the late-bound code and the
188
+ // domains it names; only the table and column are added for the operator reading the log.
189
+ throw new LateBoundTypeMismatch(path, error.declaredDomain, error.receivedDomain, detail);
190
+ }
191
+ throw new AxiomError(error.code, detail, path);
192
+ }
193
+ }
194
+ /** Everything one document must satisfy before it can answer a call. */
195
+ function prepare(document) {
196
+ if (document.kind === 'set') {
197
+ const members = new Set();
198
+ for (const value of document.values ?? [])
199
+ members.add(canonicalKey(value, document.tableId));
200
+ return {
201
+ document,
202
+ hitPolicy: 'UNIQUE',
203
+ keyColumns: [],
204
+ effectiveFrom: document.effectiveFrom === undefined
205
+ ? undefined
206
+ : dateToDay(document.effectiveFrom, document.tableId),
207
+ effectiveTo: document.effectiveTo === undefined
208
+ ? undefined
209
+ : dateToDay(document.effectiveTo, document.tableId),
210
+ digest: canonicalHash(document),
211
+ rowsByKey: new Map(),
212
+ members,
213
+ };
214
+ }
215
+ const hitPolicy = document.hitPolicy;
216
+ if (hitPolicy === undefined) {
217
+ refuseTable(document.tableId, `table ${document.tableId} declares no hitPolicy`);
218
+ }
219
+ if (hitPolicy === 'COLLECT') {
220
+ // A collection is bounded by its declaration, never by how many rows happen to match
221
+ //
222
+ const limit = document.collectLimit;
223
+ if (limit === undefined ||
224
+ !Number.isSafeInteger(limit) ||
225
+ limit < COLLECT_LIMIT_MIN ||
226
+ limit > COLLECT_LIMIT_MAX) {
227
+ refuseTable(document.tableId, `table ${document.tableId} is COLLECT and declares no collectLimit of ${String(COLLECT_LIMIT_MIN)}..${String(COLLECT_LIMIT_MAX)}`);
228
+ }
229
+ }
230
+ const columns = document.columns ?? [];
231
+ const columnIds = new Set();
232
+ for (const column of columns) {
233
+ if (columnIds.has(column.columnId)) {
234
+ refuseTable(document.tableId, `table ${document.tableId} declares column ${column.columnId} twice`);
235
+ }
236
+ columnIds.add(column.columnId);
237
+ }
238
+ const keyColumns = columns.filter((column) => column.role === 'key');
239
+ const outputColumns = columns.filter((column) => column.role === 'output');
240
+ if (keyColumns.length === 0) {
241
+ refuseTable(document.tableId, `table ${document.tableId} declares no key column`);
242
+ }
243
+ const rowsByKey = new Map();
244
+ const rowIds = new Set();
245
+ const documents = document.rows ?? [];
246
+ documents.forEach((row, index) => {
247
+ const path = `${document.tableId}.rows[${String(index)}]`;
248
+ if (rowIds.has(row.rowId)) {
249
+ refuseTable(document.tableId, `table ${document.tableId} declares rowId ${row.rowId} twice`);
250
+ }
251
+ rowIds.add(row.rowId);
252
+ if (row.key.length !== keyColumns.length) {
253
+ refuseTable(document.tableId, `table ${document.tableId} row ${row.rowId} carries ${String(row.key.length)} key values for ${String(keyColumns.length)} key columns`);
254
+ }
255
+ keyColumns.forEach((column, keyIndex) => {
256
+ checkColumnValue(document, column, row.key[keyIndex], `${path}.key[${String(keyIndex)}]`);
257
+ });
258
+ if (document.kind === 'lookup') {
259
+ // A keyed lookup either resolves or does not, so every lookup row carries an output
260
+ // and no outcome at all.
261
+ if (row.outcome !== undefined) {
262
+ refuseTable(document.tableId, `table ${document.tableId} row ${row.rowId} is a lookup row and declares no outcome`);
263
+ }
264
+ if (row.output === undefined) {
265
+ refuseTable(document.tableId, `table ${document.tableId} row ${row.rowId} declares no output`);
266
+ }
267
+ }
268
+ else {
269
+ if (row.outcome === undefined) {
270
+ refuseTable(document.tableId, `table ${document.tableId} row ${row.rowId} is a decision row and declares no outcome`);
271
+ }
272
+ if (row.outcome === 'PASS' && row.output === undefined) {
273
+ refuseTable(document.tableId, `table ${document.tableId} row ${row.rowId} is a PASS row and declares no output`);
274
+ }
275
+ }
276
+ if (row.output !== undefined) {
277
+ const members = Object.keys(row.output).sort();
278
+ const declared = outputColumns.map((column) => column.columnId).sort();
279
+ if (members.length !== declared.length ||
280
+ members.some((name, memberIndex) => name !== declared[memberIndex])) {
281
+ refuseTable(document.tableId, `table ${document.tableId} row ${row.rowId} output members do not match the declared output columns`);
282
+ }
283
+ for (const column of outputColumns) {
284
+ checkColumnValue(document, column, row.output[column.columnId], `${path}.output.${column.columnId}`);
285
+ }
286
+ }
287
+ const key = canonicalKey(row.key, document.tableId);
288
+ const matching = rowsByKey.get(key);
289
+ if (matching === undefined) {
290
+ rowsByKey.set(key, [row]);
291
+ return;
292
+ }
293
+ // Under `UNIQUE` a second row with the same key would make the answer depend on search
294
+ // order, so the table is refused rather than compiled.
295
+ if (hitPolicy === 'UNIQUE') {
296
+ refuseTable(document.tableId, `table ${document.tableId} has two rows with the same key ${row.rowId} and ${matching[0]?.rowId ?? ''}`);
297
+ }
298
+ matching.push(row);
299
+ });
300
+ return {
301
+ document,
302
+ hitPolicy,
303
+ keyColumns,
304
+ effectiveFrom: document.effectiveFrom === undefined
305
+ ? undefined
306
+ : dateToDay(document.effectiveFrom, document.tableId),
307
+ effectiveTo: document.effectiveTo === undefined
308
+ ? undefined
309
+ : dateToDay(document.effectiveTo, document.tableId),
310
+ digest: canonicalHash(document),
311
+ rowsByKey,
312
+ members: undefined,
313
+ };
314
+ }
315
+ //# sourceMappingURL=install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install.js","sourceRoot":"","sources":["../../src/lookup/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAC5E,OAAO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CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,QAAQ,KAAK,SAAS,EAAE,CAAC;YAC3B,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;YAC1B,OAAO;QACT,CAAC;QACD,uFAAuF;QACvF,uDAAuD;QACvD,IAAI,SAAS,KAAK,QAAQ,EAAE,CAAC;YAC3B,WAAW,CACT,QAAQ,CAAC,OAAO,EAChB,SAAS,QAAQ,CAAC,OAAO,mCAAmC,GAAG,CAAC,KAAK,QAAQ,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,EAAE,CACxG,CAAC;QACJ,CAAC;QACD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,QAAQ;QACR,SAAS;QACT,UAAU;QACV,aAAa,EACX,QAAQ,CAAC,aAAa,KAAK,SAAS;YAClC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC;QACzD,WAAW,EACT,QAAQ,CAAC,WAAW,KAAK,SAAS;YAChC,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,OAAO,CAAC;QACvD,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC;QAC/B,SAAS;QACT,OAAO,EAAE,SAAS;KACnB,CAAC;AACJ,CAAC","sourcesContent":["import { canonicalizeRestricted, canonicalHash } from '../canonical/jcs.js';\nimport { daysFromCivil, parsePlainDate } from '../expr/plain-date.js';\nimport { AxiomError, LateBoundTypeMismatch } from '../model/errors.js';\nimport type {\n DatasetColumn,\n HitPolicy,\n LookupRow,\n LookupTableDocument,\n WireValue,\n} from '../model/types.js';\nimport { toHostWireValue, wireDeclarationOfColumn } from '../model/wire.js';\n\n/**\n * The row-count bounds a bounded `COLLECT` hit may declare, `DATA-3.1.5`: the metaschema's\n * `collectLimit` states the same `minimum` and `maximum`, so a document outside them is already\n * one the compiler refuses. The runtime restates the bound rather than trusting the document,\n * because a store may be handed one no compiler produced.\n */\nconst COLLECT_LIMIT_MIN = 1;\nconst COLLECT_LIMIT_MAX = 1000;\n\n/** Canonical text of a key or member, with the table named in any refusal. */\nexport function canonicalKey(value: unknown, context: string): string {\n try {\n return canonicalizeRestricted(value);\n } catch (error) {\n if (error instanceof AxiomError) {\n throw new AxiomError(error.code, `${context}: ${error.message}`, error.path);\n }\n throw error;\n }\n}\n\n/** A plain date as epoch days, with the table named in any refusal. */\nexport function dateToDay(text: string, context: string): number {\n const date = parsePlainDate(text, context);\n return daysFromCivil(date.year, date.month, date.day);\n}\n\n/** Refuses a table the store cannot answer from, naming it in the error path. */\nexport function refuseTable(tableId: string, message: string): never {\n throw new AxiomError('ENGINE_ERROR', message, tableId);\n}\n\n/** One table version's resolution facts, derived once when the table is added. */\nexport interface PreparedVersion {\n readonly document: LookupTableDocument;\n readonly hitPolicy: HitPolicy;\n readonly keyColumns: readonly DatasetColumn[];\n /** Inclusive start and exclusive end of a data-bound window, in epoch days. */\n readonly effectiveFrom: number | undefined;\n readonly effectiveTo: number | undefined;\n readonly digest: string;\n /** Rows by canonical key, in source order, so `COLLECT` can return every match. */\n readonly rowsByKey: ReadonlyMap<string, readonly LookupRow[]>;\n /** Set members, when this version is a set table. */\n readonly members: ReadonlySet<string> | undefined;\n}\n\n/** One table's versions, ordered by the start of their effective window. */\nexport interface PreparedTable {\n readonly versions: readonly PreparedVersion[];\n}\n\n/**\n * A way one dataset document cannot answer a call: its clock binding and its window are the\n * two members a store cannot repair/.\n */\ninterface DatasetDocumentProblem {\n readonly tableId: string;\n readonly detail: string;\n}\n\n/** A way a set of table versions cannot be installed together. */\nexport interface DatasetInstallationProblem {\n readonly kind:\n | 'duplicate_version'\n | 'overlapping_window'\n | 'multiple_behavior_versions'\n | 'version_order'\n | 'inconsistent_table';\n readonly tableId: string;\n readonly detail: string;\n}\n\nfunction documentProblem(document: LookupTableDocument, detail: string): DatasetDocumentProblem {\n return { tableId: document.tableId, detail };\n}\n\nfunction problem(\n kind: DatasetInstallationProblem['kind'],\n tableId: string,\n detail: string,\n): DatasetInstallationProblem {\n return { kind, tableId, detail };\n}\n\n/**\n * Checks every document, refuses the first that cannot answer a call, then refuses a set of\n * versions that cannot be one installation. Both checks run before any version is prepared,\n * so a refused catalog leaves no half-installed store.\n */\nexport function prepareInstallation(\n documents: readonly LookupTableDocument[],\n): ReadonlyMap<string, PreparedTable> {\n for (const document of documents) {\n const problems = documentProblems(document);\n const first = problems[0];\n if (first !== undefined) refuseTable(first.tableId, first.detail);\n }\n const problems = datasetInstallationProblems(documents);\n const first = problems[0];\n if (first !== undefined) refuseTable(first.tableId, first.detail);\n const tables = new Map<string, PreparedTable>();\n for (const document of documents) addDocument(tables, prepare(document));\n return tables;\n}\n\n/** Adds one prepared version to its table, keeping versions ordered by window start. */\nfunction addDocument(tables: Map<string, PreparedTable>, prepared: PreparedVersion): void {\n const document = prepared.document;\n const known = tables.get(document.tableId);\n if (known === undefined) {\n tables.set(document.tableId, { versions: [prepared] });\n return;\n }\n const versions = [...known.versions, prepared].sort((a, b) => {\n const left = a.effectiveFrom ?? 0;\n const right = b.effectiveFrom ?? 0;\n return left - right;\n });\n tables.set(document.tableId, { versions });\n}\n\n/** A problem one dataset document has on its own, before any version is compared. */\nfunction documentProblems(document: LookupTableDocument): readonly DatasetDocumentProblem[] {\n const problems: DatasetDocumentProblem[] = [];\n const from = document.effectiveFrom;\n const to = document.effectiveTo;\n if (document.binding === 'behavior') {\n if (from !== undefined || to !== undefined) {\n problems.push(\n documentProblem(\n document,\n `table ${document.tableId} is behavior-bound and declares no effective range`,\n ),\n );\n }\n return problems;\n }\n if (from === undefined || to === undefined) {\n problems.push(\n documentProblem(\n document,\n `table ${document.tableId} is data-bound and must declare effectiveFrom and effectiveTo`,\n ),\n );\n return problems;\n }\n // The metaschema checks the spelling of a date, not that it is one, and says nothing about\n // the order of the two bounds.\n const start = dateToDay(from, document.tableId);\n const end = dateToDay(to, document.tableId);\n if (start >= end) {\n problems.push(\n documentProblem(document, `table ${document.tableId} has an empty effective range`),\n );\n }\n return problems;\n}\n\n/**\n * The invariants a set of table versions must satisfy to be one installation.\n *\n * A table id names one table; a data-bound table's versions are distinguished by their\n * half-open windows, so two versions covering one date would make a resolution ambiguous\n * and two versions sharing a number would make provenance unreproducible. The check is\n * exported because the compiler refuses the same catalog at publish time: the store cannot\n * be the first place an operator learns that two published windows overlap.\n */\nexport function datasetInstallationProblems(\n documents: readonly LookupTableDocument[],\n): readonly DatasetInstallationProblem[] {\n const problems: DatasetInstallationProblem[] = [];\n const versions = new Map<string, LookupTableDocument[]>();\n for (const document of documents) {\n const known = versions.get(document.tableId);\n if (known === undefined) versions.set(document.tableId, [document]);\n else known.push(document);\n }\n for (const [tableId, group] of versions) {\n // A table id names one table, so its versions agree on what kind of table it is and how\n // it is clocked. A catalog that mixes them would let `in_set`, `lookup`\n // or `decide` answer from a version of another kind.\n const kinds = new Set(group.map((document) => document.kind));\n const bindings = new Set(group.map((document) => document.binding));\n if (kinds.size > 1) {\n problems.push(\n problem(\n 'inconsistent_table',\n tableId,\n `table ${tableId} is declared as more than one kind (${[...kinds].sort().join(', ')}); makes the table id name one table`,\n ),\n );\n }\n if (bindings.size > 1) {\n problems.push(\n problem(\n 'inconsistent_table',\n tableId,\n `table ${tableId} declares more than one clock binding (${[...bindings].sort().join(', ')}); makes the table id name one table`,\n ),\n );\n }\n const numbers = new Set<number>();\n for (const document of group) {\n if (numbers.has(document.tableVersion)) {\n problems.push(\n problem(\n 'duplicate_version',\n tableId,\n `table ${tableId} version ${String(document.tableVersion)} is declared twice`,\n ),\n );\n }\n numbers.add(document.tableVersion);\n }\n if (group.some((document) => document.binding === 'behavior') && group.length > 1) {\n problems.push(\n problem(\n 'multiple_behavior_versions',\n tableId,\n `table ${tableId} is behavior-bound and pins to the case, so it declares one version`,\n ),\n );\n continue;\n }\n const windowsByVersion = new Map<number, { version: number; from: number; to: number }>();\n for (const document of group) {\n const from = document.effectiveFrom;\n const to = document.effectiveTo;\n // A repeated version number is already a problem of its own; comparing it with itself\n // would report the same mistake twice.\n if (from === undefined || to === undefined) continue;\n if (!windowsByVersion.has(document.tableVersion)) {\n windowsByVersion.set(document.tableVersion, {\n version: document.tableVersion,\n from: dateToDay(from, tableId),\n to: dateToDay(to, tableId),\n });\n }\n }\n const windows = [...windowsByVersion.values()];\n windows.sort((a, b) => a.from - b.from);\n for (let index = 1; index < windows.length; index += 1) {\n const previous = windows[index - 1];\n const current = windows[index];\n if (previous === undefined || current === undefined) continue;\n if (current.from < previous.to) {\n problems.push(\n problem(\n 'overlapping_window',\n tableId,\n `table ${tableId} versions ${String(previous.version)} and ${String(current.version)} have overlapping effective windows`,\n ),\n );\n }\n // A version's number increases with the window it covers, so an\n // older window carrying a higher number is a publication that went backwards.\n if (current.version <= previous.version) {\n problems.push(\n problem(\n 'version_order',\n tableId,\n `table ${tableId} version ${String(current.version)} covers a later window than version ${String(previous.version)}; makes the version increase with each publication`,\n ),\n );\n }\n }\n }\n return problems;\n}\n\n/** One column value against its declared primitive, with the row and column named. */\nfunction checkColumnValue(\n document: LookupTableDocument,\n column: DatasetColumn,\n value: unknown,\n path: string,\n): WireValue {\n try {\n return toHostWireValue(value, path, wireDeclarationOfColumn(column));\n } catch (error) {\n if (!(error instanceof AxiomError)) throw error;\n const detail = `table ${document.tableId} column ${column.columnId}: ${error.message}`;\n if (error instanceof LateBoundTypeMismatch) {\n // The dataset document is host data, so a wrong domain keeps the late-bound code and the\n // domains it names; only the table and column are added for the operator reading the log.\n throw new LateBoundTypeMismatch(path, error.declaredDomain, error.receivedDomain, detail);\n }\n throw new AxiomError(error.code, detail, path);\n }\n}\n\n/** Everything one document must satisfy before it can answer a call. */\nfunction prepare(document: LookupTableDocument): PreparedVersion {\n if (document.kind === 'set') {\n const members = new Set<string>();\n for (const value of document.values ?? []) members.add(canonicalKey(value, document.tableId));\n return {\n document,\n hitPolicy: 'UNIQUE',\n keyColumns: [],\n effectiveFrom:\n document.effectiveFrom === undefined\n ? undefined\n : dateToDay(document.effectiveFrom, document.tableId),\n effectiveTo:\n document.effectiveTo === undefined\n ? undefined\n : dateToDay(document.effectiveTo, document.tableId),\n digest: canonicalHash(document),\n rowsByKey: new Map(),\n members,\n };\n }\n\n const hitPolicy = document.hitPolicy;\n if (hitPolicy === undefined) {\n refuseTable(document.tableId, `table ${document.tableId} declares no hitPolicy`);\n }\n if (hitPolicy === 'COLLECT') {\n // A collection is bounded by its declaration, never by how many rows happen to match\n //\n const limit = document.collectLimit;\n if (\n limit === undefined ||\n !Number.isSafeInteger(limit) ||\n limit < COLLECT_LIMIT_MIN ||\n limit > COLLECT_LIMIT_MAX\n ) {\n refuseTable(\n document.tableId,\n `table ${document.tableId} is COLLECT and declares no collectLimit of ${String(COLLECT_LIMIT_MIN)}..${String(COLLECT_LIMIT_MAX)}`,\n );\n }\n }\n const columns = document.columns ?? [];\n const columnIds = new Set<string>();\n for (const column of columns) {\n if (columnIds.has(column.columnId)) {\n refuseTable(\n document.tableId,\n `table ${document.tableId} declares column ${column.columnId} twice`,\n );\n }\n columnIds.add(column.columnId);\n }\n const keyColumns = columns.filter((column) => column.role === 'key');\n const outputColumns = columns.filter((column) => column.role === 'output');\n if (keyColumns.length === 0) {\n refuseTable(document.tableId, `table ${document.tableId} declares no key column`);\n }\n\n const rowsByKey = new Map<string, LookupRow[]>();\n const rowIds = new Set<string>();\n const documents = document.rows ?? [];\n documents.forEach((row, index) => {\n const path = `${document.tableId}.rows[${String(index)}]`;\n if (rowIds.has(row.rowId)) {\n refuseTable(document.tableId, `table ${document.tableId} declares rowId ${row.rowId} twice`);\n }\n rowIds.add(row.rowId);\n if (row.key.length !== keyColumns.length) {\n refuseTable(\n document.tableId,\n `table ${document.tableId} row ${row.rowId} carries ${String(row.key.length)} key values for ${String(keyColumns.length)} key columns`,\n );\n }\n keyColumns.forEach((column, keyIndex) => {\n checkColumnValue(document, column, row.key[keyIndex], `${path}.key[${String(keyIndex)}]`);\n });\n if (document.kind === 'lookup') {\n // A keyed lookup either resolves or does not, so every lookup row carries an output\n // and no outcome at all.\n if (row.outcome !== undefined) {\n refuseTable(\n document.tableId,\n `table ${document.tableId} row ${row.rowId} is a lookup row and declares no outcome`,\n );\n }\n if (row.output === undefined) {\n refuseTable(\n document.tableId,\n `table ${document.tableId} row ${row.rowId} declares no output`,\n );\n }\n } else {\n if (row.outcome === undefined) {\n refuseTable(\n document.tableId,\n `table ${document.tableId} row ${row.rowId} is a decision row and declares no outcome`,\n );\n }\n if (row.outcome === 'PASS' && row.output === undefined) {\n refuseTable(\n document.tableId,\n `table ${document.tableId} row ${row.rowId} is a PASS row and declares no output`,\n );\n }\n }\n if (row.output !== undefined) {\n const members = Object.keys(row.output).sort();\n const declared = outputColumns.map((column) => column.columnId).sort();\n if (\n members.length !== declared.length ||\n members.some((name, memberIndex) => name !== declared[memberIndex])\n ) {\n refuseTable(\n document.tableId,\n `table ${document.tableId} row ${row.rowId} output members do not match the declared output columns`,\n );\n }\n for (const column of outputColumns) {\n checkColumnValue(\n document,\n column,\n row.output[column.columnId],\n `${path}.output.${column.columnId}`,\n );\n }\n }\n const key = canonicalKey(row.key, document.tableId);\n const matching = rowsByKey.get(key);\n if (matching === undefined) {\n rowsByKey.set(key, [row]);\n return;\n }\n // Under `UNIQUE` a second row with the same key would make the answer depend on search\n // order, so the table is refused rather than compiled.\n if (hitPolicy === 'UNIQUE') {\n refuseTable(\n document.tableId,\n `table ${document.tableId} has two rows with the same key ${row.rowId} and ${matching[0]?.rowId ?? ''}`,\n );\n }\n matching.push(row);\n });\n\n return {\n document,\n hitPolicy,\n keyColumns,\n effectiveFrom:\n document.effectiveFrom === undefined\n ? undefined\n : dateToDay(document.effectiveFrom, document.tableId),\n effectiveTo:\n document.effectiveTo === undefined\n ? undefined\n : dateToDay(document.effectiveTo, document.tableId),\n digest: canonicalHash(document),\n rowsByKey,\n members: undefined,\n };\n}\n"]}
@@ -0,0 +1,55 @@
1
+ import type { DatasetRef } from '../model/schema.js';
2
+ import type { LookupPort, LookupProvenance } from '../model/types.js';
3
+ /**
4
+ * A port that answers an identical call from the store once and repeats the answer for the
5
+ * rest of the pass.
6
+ *
7
+ * The memo is deliberately not a cache: it is built per evaluation pass and is released
8
+ * with it, so it cannot serve a resolution from another record, another record date or
9
+ * another set of table versions. A miss, an undetermined answer and a stale refusal are
10
+ * recorded too — the store's answer is the fact being reused, not only its hits.
11
+ */
12
+ export declare function memoizeLookup(port: LookupPort): LookupPort;
13
+ /**
14
+ * A port that refuses a table version other than the one the artifact pins, and a pairing whose
15
+ * held document is not the document the pin names.
16
+ *
17
+ * The pin is the version the schema was published against, so a store serving any other
18
+ * version — older or newer — is answering from data the artifact was never checked with: the
19
+ * call goes `STALE` with `version_mismatch` rather than falling back to what the store holds.
20
+ * That is what "must not fall back to the newest available version" means,
21
+ * and it is what makes a replay seven years later resolve the rows the decision was made on.
22
+ *
23
+ * A version is not bytes: a table republished under the pinned version keeps its name while its
24
+ * document changes. When the store can state the canonical digest of the version it holds
25
+ * (`DigestBearingPort`, which `MemoryLookupStore` implements), every pin the store can answer is
26
+ * compared before any rule reads a value, and a difference is refused with the `tableId`,
27
+ * `tableVersion`, `expected` and `actual` offline admission also states. A pin that names no
28
+ * digest cannot be verified at all and is refused too, rather than silently answering from
29
+ * version alone; an artifact that declares no pins is not paired through here at all.
30
+ */
31
+ export declare function pinLookup(port: LookupPort, pins: readonly DatasetRef[]): LookupPort;
32
+ /**
33
+ * The lookups one evaluation resolved, deduplicated and ordered.
34
+ *
35
+ * The list is provenance rather than a call log: two rules resolving the same row of the same
36
+ * table version produced one fact about what the report was resolved against, so an identical
37
+ * entry is recorded once. Entries are canonically sorted, so the order does not depend on
38
+ * which rule happened to run first and the report hash is reproducible.
39
+ *
40
+ * The canonical token is derived once per distinct provenance object. The port memo hands back
41
+ * the same resolution object for a repeated call, so a query asked once per row is
42
+ * canonicalised once rather than once per call.
43
+ */
44
+ export declare class ProvenanceLedger {
45
+ private readonly entries;
46
+ private readonly attributed;
47
+ private readonly tokens;
48
+ /** Records one resolution, attributed to the rule that made it when there is one. */
49
+ record(provenance: LookupProvenance, ruleId: string | undefined): void;
50
+ /** Every entry, canonically ordered. */
51
+ all(): readonly LookupProvenance[];
52
+ /** One rule's own entries, canonically ordered. */
53
+ forRule(ruleId: string | undefined): readonly LookupProvenance[];
54
+ }
55
+ //# sourceMappingURL=pass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pass.d.ts","sourceRoot":"","sources":["../../src/lookup/pass.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EACV,UAAU,EACV,gBAAgB,EAMjB,MAAM,mBAAmB,CAAC;AAkF3B;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,UAAU,CA6C1D;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,UAAU,EAAE,GAAG,UAAU,CAwCnF;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAuC;IAC/D,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAoD;IAC/E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA2C;IAElE,qFAAqF;IACrF,MAAM,CAAC,UAAU,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAWrE;IAED,wCAAwC;IACxC,GAAG,IAAI,SAAS,gBAAgB,EAAE,CAEjC;IAED,mDAAmD;IACnD,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,gBAAgB,EAAE,CAE/D;CACF"}
@@ -0,0 +1,212 @@
1
+ import { canonicalizeRestricted } from '../canonical/jcs.js';
2
+ import { compareCodePoints } from '../expr/strings.js';
3
+ import { AxiomError } from '../model/errors.js';
4
+ import { datasetDigestMismatch, digestReaderOf, refuseDatasetDigestMismatch } from './digest.js';
5
+ /**
6
+ * The two wrappers every evaluation pass puts around the host's lookup port, so neither the
7
+ * expression language nor the host store has to carry them.
8
+ *
9
+ * `pinLookup` binds resolution to the versions an artifact was compiled against
10
+ * `memoizeLookup` answers an identical call once per pass
11
+ * a decision table read by three rules is one store round trip, and the
12
+ * memo dies with the pass, so no result outlives the input it was resolved from.
13
+ */
14
+ /** The canonical text one call is keyed by: the operation, its table, its operand and date. */
15
+ function token(...parts) {
16
+ return canonicalizeRestricted(parts);
17
+ }
18
+ function setToken(tokens, tableId, value, recordDate) {
19
+ const date = recordDate ?? null;
20
+ let byValue = tokens.get(tableId);
21
+ if (byValue === undefined) {
22
+ byValue = new Map();
23
+ tokens.set(tableId, byValue);
24
+ }
25
+ let byDate = byValue.get(value);
26
+ if (byDate === undefined) {
27
+ byDate = new Map();
28
+ byValue.set(value, byDate);
29
+ }
30
+ const known = byDate.get(date);
31
+ if (known !== undefined)
32
+ return known;
33
+ const text = token('in_set', tableId, value, date);
34
+ byDate.set(date, text);
35
+ return text;
36
+ }
37
+ function decideToken(tokens, tableId, inputs, asOf) {
38
+ let byTable = tokens.get(inputs);
39
+ if (byTable === undefined) {
40
+ byTable = new Map();
41
+ tokens.set(inputs, byTable);
42
+ }
43
+ let byDate = byTable.get(tableId);
44
+ if (byDate === undefined) {
45
+ byDate = new Map();
46
+ byTable.set(tableId, byDate);
47
+ }
48
+ const date = asOf ?? null;
49
+ const known = byDate.get(date);
50
+ if (known !== undefined)
51
+ return known;
52
+ const text = token('decide', tableId, inputs, date);
53
+ byDate.set(date, text);
54
+ return text;
55
+ }
56
+ /**
57
+ * A port that answers an identical call from the store once and repeats the answer for the
58
+ * rest of the pass.
59
+ *
60
+ * The memo is deliberately not a cache: it is built per evaluation pass and is released
61
+ * with it, so it cannot serve a resolution from another record, another record date or
62
+ * another set of table versions. A miss, an undetermined answer and a stale refusal are
63
+ * recorded too — the store's answer is the fact being reused, not only its hits.
64
+ */
65
+ export function memoizeLookup(port) {
66
+ const sets = new Map();
67
+ const resolutions = new Map();
68
+ // The token indexes die with the pass, like the memos they front, so a value resolved from
69
+ // one record can never name the resolution of another.
70
+ const setTokens = new Map();
71
+ const decideTokens = new WeakMap();
72
+ const rememberSet = (key, resolve) => {
73
+ const known = sets.get(key);
74
+ if (known !== undefined)
75
+ return known;
76
+ const resolution = resolve();
77
+ sets.set(key, resolution);
78
+ return resolution;
79
+ };
80
+ const remember = (key, resolve) => {
81
+ const known = resolutions.get(key);
82
+ if (known !== undefined)
83
+ return known;
84
+ const resolution = resolve();
85
+ resolutions.set(key, resolution);
86
+ return resolution;
87
+ };
88
+ return {
89
+ contains(tableId, value, recordDate) {
90
+ return rememberSet(setToken(setTokens, tableId, value, recordDate), () => port.contains(tableId, value, recordDate));
91
+ },
92
+ resolve(tableId, keys, asOf) {
93
+ return remember(token('lookup', tableId, keys, asOf ?? null), () => port.resolve(tableId, keys, asOf));
94
+ },
95
+ decide(tableId, inputs, asOf) {
96
+ // A `decide` is queried by the input record it names, so that record is its identity
97
+ // for the pass: two rules reading the same inputs resolve one answer.
98
+ return remember(decideToken(decideTokens, tableId, inputs, asOf), () => port.decide(tableId, inputs, asOf));
99
+ },
100
+ decideKeys(tableId, keys, asOf) {
101
+ return remember(token('decide_keys', tableId, keys, asOf ?? null), () => port.decideKeys(tableId, keys, asOf));
102
+ },
103
+ };
104
+ }
105
+ /**
106
+ * A port that refuses a table version other than the one the artifact pins, and a pairing whose
107
+ * held document is not the document the pin names.
108
+ *
109
+ * The pin is the version the schema was published against, so a store serving any other
110
+ * version — older or newer — is answering from data the artifact was never checked with: the
111
+ * call goes `STALE` with `version_mismatch` rather than falling back to what the store holds.
112
+ * That is what "must not fall back to the newest available version" means,
113
+ * and it is what makes a replay seven years later resolve the rows the decision was made on.
114
+ *
115
+ * A version is not bytes: a table republished under the pinned version keeps its name while its
116
+ * document changes. When the store can state the canonical digest of the version it holds
117
+ * (`DigestBearingPort`, which `MemoryLookupStore` implements), every pin the store can answer is
118
+ * compared before any rule reads a value, and a difference is refused with the `tableId`,
119
+ * `tableVersion`, `expected` and `actual` offline admission also states. A pin that names no
120
+ * digest cannot be verified at all and is refused too, rather than silently answering from
121
+ * version alone; an artifact that declares no pins is not paired through here at all.
122
+ */
123
+ export function pinLookup(port, pins) {
124
+ const byTable = new Map();
125
+ const digestOf = digestReaderOf(port);
126
+ for (const pin of pins) {
127
+ if (typeof pin.sha256 !== 'string') {
128
+ throw new AxiomError('ENGINE_ERROR', `table ${pin.tableId} version ${String(pin.tableVersion)} pins no canonical digest, so its bytes cannot be verified`, pin.tableId);
129
+ }
130
+ byTable.set(pin.tableId, pin);
131
+ // A port that cannot state its digests has its documents outside what this package can see;
132
+ // offline admission is then the only door that verified them.
133
+ if (digestOf === undefined)
134
+ continue;
135
+ const actual = digestOf(pin.tableId, pin.tableVersion);
136
+ if (actual === undefined)
137
+ continue;
138
+ const mismatch = datasetDigestMismatch(pin, actual);
139
+ if (mismatch !== undefined)
140
+ refuseDatasetDigestMismatch(mismatch);
141
+ }
142
+ const wrongVersion = (table) => {
143
+ const pin = byTable.get(table.tableId);
144
+ return pin !== undefined && table.tableVersion !== pin.tableVersion;
145
+ };
146
+ const pinnedSet = (resolution) => {
147
+ if (resolution.outcome === 'STALE' || !wrongVersion(resolution.table))
148
+ return resolution;
149
+ return { outcome: 'STALE', tableId: resolution.table.tableId, reason: 'version_mismatch' };
150
+ };
151
+ const pinnedResolution = (resolution) => {
152
+ if (resolution.outcome === 'STALE')
153
+ return resolution;
154
+ const table = resolution.table;
155
+ if (table === undefined || !wrongVersion(table))
156
+ return resolution;
157
+ return { outcome: 'STALE', tableId: table.tableId, reason: 'version_mismatch' };
158
+ };
159
+ return {
160
+ contains: (tableId, value, recordDate) => pinnedSet(port.contains(tableId, value, recordDate)),
161
+ resolve: (tableId, keys, asOf) => pinnedResolution(port.resolve(tableId, keys, asOf)),
162
+ decide: (tableId, inputs, asOf) => pinnedResolution(port.decide(tableId, inputs, asOf)),
163
+ decideKeys: (tableId, keys, asOf) => pinnedResolution(port.decideKeys(tableId, keys, asOf)),
164
+ };
165
+ }
166
+ /**
167
+ * The lookups one evaluation resolved, deduplicated and ordered.
168
+ *
169
+ * The list is provenance rather than a call log: two rules resolving the same row of the same
170
+ * table version produced one fact about what the report was resolved against, so an identical
171
+ * entry is recorded once. Entries are canonically sorted, so the order does not depend on
172
+ * which rule happened to run first and the report hash is reproducible.
173
+ *
174
+ * The canonical token is derived once per distinct provenance object. The port memo hands back
175
+ * the same resolution object for a repeated call, so a query asked once per row is
176
+ * canonicalised once rather than once per call.
177
+ */
178
+ export class ProvenanceLedger {
179
+ entries = new Map();
180
+ attributed = new Map();
181
+ tokens = new WeakMap();
182
+ /** Records one resolution, attributed to the rule that made it when there is one. */
183
+ record(provenance, ruleId) {
184
+ let token = this.tokens.get(provenance);
185
+ if (token === undefined) {
186
+ token = canonicalizeRestricted(provenance);
187
+ this.tokens.set(provenance, token);
188
+ }
189
+ this.entries.set(token, provenance);
190
+ if (ruleId === undefined)
191
+ return;
192
+ const attributed = this.attributed.get(ruleId) ?? new Map();
193
+ attributed.set(token, provenance);
194
+ this.attributed.set(ruleId, attributed);
195
+ }
196
+ /** Every entry, canonically ordered. */
197
+ all() {
198
+ return sortedProvenance(this.entries);
199
+ }
200
+ /** One rule's own entries, canonically ordered. */
201
+ forRule(ruleId) {
202
+ return ruleId === undefined ? [] : sortedProvenance(this.attributed.get(ruleId));
203
+ }
204
+ }
205
+ function sortedProvenance(entries) {
206
+ if (entries === undefined)
207
+ return [];
208
+ return [...entries.entries()]
209
+ .sort(([left], [right]) => compareCodePoints(left, right))
210
+ .map(([, provenance]) => provenance);
211
+ }
212
+ //# sourceMappingURL=pass.js.map