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

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 +1210 -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,422 @@
1
+ import { canonicalHash, canonicalHashOwned, copyRestricted } from '../canonical/jcs.js';
2
+ import { objectShapeViolation, prototypeOf, setOwn } from '../canonical/restricted.js';
3
+ import { AxiomError } from '../model/errors.js';
4
+ import { isRecord } from '../model/values.js';
5
+ import { refusalOf } from '../model/wire.js';
6
+ const OUTCOMES = new Set(['PASS', 'FAIL', 'UNKNOWN', 'DEFERRED']);
7
+ function reportRefusal(path, detail) {
8
+ return { code: 'ENGINE_ERROR', path, detail };
9
+ }
10
+ /**
11
+ * Reads a stored report body into `EvaluationReport`, `readSealedReport()`.
12
+ *
13
+ * A report arrives from storage as JSON, so it is untrusted like any other stored value. Two
14
+ * facts make it a sealed report rather than a JSON object that looks like one: the required
15
+ * top-level members are present with their declared kinds, and `reportHash` equals the canonical
16
+ * hash of the body without it. The second is the seal itself, recomputed; a host that skipped it
17
+ * would be trusting a digest it had not checked.
18
+ *
19
+ * The nested rule results, diagnostics and lookup provenance are not re-validated here. They were
20
+ * produced by this runtime and are covered by the same digest, so a successful hash check proves
21
+ * the bytes are the ones the runtime sealed. A body the restricted profile cannot canonicalise is
22
+ * a boundary refusal, not a thrown error: the seal cannot be recomputed over it at all.
23
+ */
24
+ /** Reads an own property only so ambient `Object.prototype` properties never satisfy a report field. */
25
+ function ownMember(record, key) {
26
+ return Object.hasOwn(record, key) ? record[key] : undefined;
27
+ }
28
+ export function readSealedReport(value) {
29
+ if (!isRecord(value)) {
30
+ return { ok: false, refusal: reportRefusal('$', 'the report is not a JSON object') };
31
+ }
32
+ const prototype = prototypeOf(value);
33
+ if (prototype !== Object.prototype && prototype !== null) {
34
+ return {
35
+ ok: false,
36
+ refusal: reportRefusal('$', 'the report is not a plain JSON object'),
37
+ };
38
+ }
39
+ const violation = objectShapeViolation(value);
40
+ if (violation !== undefined) {
41
+ return {
42
+ ok: false,
43
+ refusal: reportRefusal('$', `restricted JSON refuses ${violation}`),
44
+ };
45
+ }
46
+ const schemaId = ownMember(value, 'schemaId');
47
+ const schemaVersion = ownMember(value, 'schemaVersion');
48
+ const exprVersion = ownMember(value, 'exprVersion');
49
+ const behaviorHash = ownMember(value, 'behaviorHash');
50
+ const reportHash = ownMember(value, 'reportHash');
51
+ const status = ownMember(value, 'status');
52
+ if (typeof schemaId !== 'string') {
53
+ return { ok: false, refusal: reportRefusal('$.schemaId', 'the report names no schema') };
54
+ }
55
+ if (typeof schemaVersion !== 'number' || !Number.isInteger(schemaVersion)) {
56
+ return {
57
+ ok: false,
58
+ refusal: reportRefusal('$.schemaVersion', 'the report version is not an integer'),
59
+ };
60
+ }
61
+ if (exprVersion !== 1) {
62
+ return { ok: false, refusal: reportRefusal('$.exprVersion', 'the report is not Expr v1') };
63
+ }
64
+ if (typeof behaviorHash !== 'string') {
65
+ return { ok: false, refusal: reportRefusal('$.behaviorHash', 'the report names no behaviour') };
66
+ }
67
+ if (typeof reportHash !== 'string') {
68
+ return { ok: false, refusal: reportRefusal('$.reportHash', 'the report carries no seal') };
69
+ }
70
+ if (typeof status !== 'string' || !OUTCOMES.has(status)) {
71
+ return { ok: false, refusal: reportRefusal('$.status', 'the report has no known outcome') };
72
+ }
73
+ for (const member of ['access', 'rules', 'diagnostics', 'lookups']) {
74
+ if (!Array.isArray(ownMember(value, member))) {
75
+ return {
76
+ ok: false,
77
+ refusal: reportRefusal(`$.${member}`, `the report's ${member} is not a list`),
78
+ };
79
+ }
80
+ }
81
+ // Copy and validate every nested member through the restricted profile before sealing so the
82
+ // admitted report is a clean plain tree detached from caller mutations, getters, symbols, or
83
+ // non-plain prototypes.
84
+ let copied;
85
+ try {
86
+ copied = copyRestricted(value);
87
+ }
88
+ catch (error) {
89
+ if (!(error instanceof AxiomError))
90
+ throw error;
91
+ return { ok: false, refusal: refusalOf(error) };
92
+ }
93
+ if (!isRecord(copied)) {
94
+ return { ok: false, refusal: reportRefusal('$', 'the report is not a JSON object') };
95
+ }
96
+ const body = {};
97
+ for (const key of Object.keys(copied)) {
98
+ // Own-property definition keeps prototype-accessor names like `__proto__` as own data so the
99
+ // recomputed seal covers every own member the returned report carries.
100
+ if (key !== 'reportHash')
101
+ setOwn(body, key, copied[key]);
102
+ }
103
+ let computed;
104
+ try {
105
+ computed = canonicalHashOwned(body);
106
+ }
107
+ catch (error) {
108
+ if (!(error instanceof AxiomError))
109
+ throw error;
110
+ return { ok: false, refusal: refusalOf(error) };
111
+ }
112
+ if (computed !== reportHash) {
113
+ return {
114
+ ok: false,
115
+ refusal: reportRefusal('$.reportHash', 'the report body does not hash to its seal'),
116
+ };
117
+ }
118
+ // Every member checked above is the member `EvaluationReport` declares, and the seal proves the
119
+ // rest of the bytes are the ones this runtime produced. The assertion states that proof.
120
+ return { ok: true, report: reportValue(copied) };
121
+ }
122
+ /** The one assertion `readSealedReport` makes, after the checks above discharged its receipt. */
123
+ function reportValue(value) {
124
+ return value;
125
+ }
126
+ /** The key one dataset version is filed under; the version is part of the identity. */
127
+ function datasetKey(tableId, tableVersion) {
128
+ return `${tableId}\u0000${String(tableVersion)}`;
129
+ }
130
+ /** The key one artifact version is filed under. */
131
+ function artifactKey(artifactId, artifactVersion) {
132
+ return `${artifactId}\u0000${String(artifactVersion)}`;
133
+ }
134
+ /** Lexicographic code-unit ordering matching SQLite's default BINARY collation for ASCII/ISO text. */
135
+ function compareText(left, right) {
136
+ if (left < right)
137
+ return -1;
138
+ if (left > right)
139
+ return 1;
140
+ return 0;
141
+ }
142
+ /** Queue ordering matching SQLite's `ORDER BY queued_at, submission_id`. */
143
+ function compareEnvelopeOrder(left, right) {
144
+ return (compareText(left.queuedAt, right.queuedAt) || compareText(left.submissionId, right.submissionId));
145
+ }
146
+ /**
147
+ * A reference `OfflineStore` over maps, for tests and for a host whose "durable" medium is the
148
+ * process lifetime.
149
+ *
150
+ * It is deliberately small and synchronous underneath: every method validates before it writes,
151
+ * so `publish` is atomic in the only sense a single-threaded runtime can offer. It is not the
152
+ * offline proof. A host that needs durability implements this interface over its own store; the
153
+ * SQLite proof in `test/offline` is the executable contract for the transaction and claim
154
+ * semantics.
155
+ */
156
+ export class MemoryOfflineStore {
157
+ artifacts = new Map();
158
+ datasets = new Map();
159
+ drafts = new Map();
160
+ reports = new Map();
161
+ submissions = new Map();
162
+ claimed = new Map();
163
+ sent = new Map();
164
+ async readArtifact(pin) {
165
+ const held = this.artifacts.get(artifactKey(pin.artifactId, pin.artifactVersion));
166
+ if (held === undefined || held.sha256 !== pin.sha256)
167
+ return undefined;
168
+ if (canonicalHash(held.document) !== held.sha256) {
169
+ throw new Error(`the stored artifact ${held.artifactId} v${String(held.artifactVersion)} does not hash to its digest`);
170
+ }
171
+ return held;
172
+ }
173
+ async readDatasets(pins) {
174
+ const found = [];
175
+ for (const pin of pins) {
176
+ const held = this.datasets.get(datasetKey(pin.tableId, pin.tableVersion));
177
+ if (held === undefined || held.sha256 !== pin.sha256)
178
+ continue;
179
+ if (canonicalHash(held.document) !== held.sha256) {
180
+ throw new Error(`the stored dataset ${held.tableId} v${String(held.tableVersion)} does not hash to its digest`);
181
+ }
182
+ found.push(held);
183
+ }
184
+ return found;
185
+ }
186
+ async publish(request) {
187
+ const actual = canonicalHash(request.artifact);
188
+ if (actual !== request.expectedSha256) {
189
+ return {
190
+ kind: 'refused',
191
+ reason: 'artifact_digest_mismatch',
192
+ expected: request.expectedSha256,
193
+ actual,
194
+ };
195
+ }
196
+ const artifactId = request.artifact.schemaId;
197
+ const artifactVersion = request.artifact.schemaVersion;
198
+ const heldArtifact = this.artifacts.get(artifactKey(artifactId, artifactVersion));
199
+ if (heldArtifact !== undefined && heldArtifact.sha256 !== actual) {
200
+ return {
201
+ kind: 'refused',
202
+ reason: 'artifact_conflict',
203
+ artifactId,
204
+ artifactVersion,
205
+ held: heldArtifact.sha256,
206
+ offered: actual,
207
+ };
208
+ }
209
+ const pins = new Map();
210
+ for (const ref of request.artifact.datasets ?? []) {
211
+ pins.set(datasetKey(ref.tableId, ref.tableVersion), {
212
+ tableId: ref.tableId,
213
+ tableVersion: ref.tableVersion,
214
+ sha256: ref.sha256,
215
+ });
216
+ }
217
+ const supplied = request.datasets ?? [];
218
+ const unpinned = [];
219
+ const mismatched = [];
220
+ const conflicts = [];
221
+ const offered = [];
222
+ for (const document of supplied) {
223
+ const pin = pins.get(datasetKey(document.tableId, document.tableVersion));
224
+ const digest = canonicalHash(document);
225
+ if (pin === undefined) {
226
+ unpinned.push({ tableId: document.tableId, tableVersion: document.tableVersion });
227
+ continue;
228
+ }
229
+ if (pin.sha256 !== digest) {
230
+ mismatched.push({
231
+ tableId: document.tableId,
232
+ tableVersion: document.tableVersion,
233
+ expected: pin.sha256,
234
+ actual: digest,
235
+ });
236
+ continue;
237
+ }
238
+ const held = this.datasets.get(datasetKey(document.tableId, document.tableVersion));
239
+ if (held !== undefined && held.sha256 !== digest) {
240
+ conflicts.push({
241
+ tableId: document.tableId,
242
+ tableVersion: document.tableVersion,
243
+ expected: held.sha256,
244
+ actual: digest,
245
+ });
246
+ continue;
247
+ }
248
+ offered.push({
249
+ tableId: document.tableId,
250
+ tableVersion: document.tableVersion,
251
+ sha256: digest,
252
+ document,
253
+ });
254
+ }
255
+ if (unpinned.length > 0)
256
+ return { kind: 'refused', reason: 'dataset_unpinned', tables: unpinned };
257
+ if (mismatched.length > 0) {
258
+ return { kind: 'refused', reason: 'dataset_digest_mismatch', tables: mismatched };
259
+ }
260
+ if (conflicts.length > 0)
261
+ return { kind: 'refused', reason: 'dataset_conflict', tables: conflicts };
262
+ // Validation is complete, so the writes below are one step from the caller's point of view.
263
+ const artifact = {
264
+ artifactId,
265
+ artifactVersion,
266
+ sha256: actual,
267
+ document: request.artifact,
268
+ };
269
+ this.artifacts.set(artifactKey(artifactId, artifactVersion), artifact);
270
+ for (const dataset of offered) {
271
+ this.datasets.set(datasetKey(dataset.tableId, dataset.tableVersion), dataset);
272
+ }
273
+ return { kind: 'published', artifact, datasets: offered };
274
+ }
275
+ async saveDraft(draft) {
276
+ this.drafts.set(draft.draftId, draft);
277
+ }
278
+ async readDraft(draftId) {
279
+ return this.drafts.get(draftId);
280
+ }
281
+ async deleteDraft(draftId) {
282
+ return this.drafts.delete(draftId);
283
+ }
284
+ async saveReport(report) {
285
+ const admission = readSealedReport(report.report);
286
+ if (!admission.ok || admission.report.reportHash !== report.reportHash)
287
+ return false;
288
+ const held = this.reports.get(report.reportId);
289
+ if (held !== undefined)
290
+ return held.reportHash === report.reportHash;
291
+ this.reports.set(report.reportId, report);
292
+ return true;
293
+ }
294
+ async readReport(reportId) {
295
+ const held = this.reports.get(reportId);
296
+ if (held === undefined)
297
+ return undefined;
298
+ const admission = readSealedReport(held.report);
299
+ if (!admission.ok) {
300
+ throw new Error(`the stored report ${reportId} is not sealed: ${admission.refusal.detail}`);
301
+ }
302
+ if (admission.report.reportHash !== held.reportHash) {
303
+ throw new Error(`the stored report ${reportId} does not match its recorded digest`);
304
+ }
305
+ return held;
306
+ }
307
+ async enqueue(submission) {
308
+ if (this.submissions.has(submission.submissionId))
309
+ return 'existing';
310
+ this.submissions.set(submission.submissionId, submission);
311
+ return 'queued';
312
+ }
313
+ async readSubmissions() {
314
+ const ordered = [...this.submissions.values()].sort(compareEnvelopeOrder);
315
+ return ordered.map((submission) => {
316
+ const active = this.claimed.get(submission.submissionId);
317
+ if (active !== undefined) {
318
+ return {
319
+ status: 'claimed',
320
+ submission,
321
+ claimant: active.claimant,
322
+ claimedAt: active.claimedAt,
323
+ };
324
+ }
325
+ const sentAt = this.sent.get(submission.submissionId);
326
+ if (sentAt !== undefined) {
327
+ return {
328
+ status: 'sent',
329
+ submission,
330
+ sentAt,
331
+ };
332
+ }
333
+ return {
334
+ status: 'queued',
335
+ submission,
336
+ };
337
+ });
338
+ }
339
+ async claimNext(request) {
340
+ // One synchronous pass: no other call can observe a half-claimed row in this runtime.
341
+ // A token owns at most one claim: it is the only guard `markSent` and `requeue` read, so a
342
+ // token with two rows would leave the second stranded forever. Both SQLite adapters guard
343
+ // this in the conditional update with `NOT EXISTS` and keep `claim_token TEXT UNIQUE` as the
344
+ // schema invariant, so all implementations answer `undefined` without throwing.
345
+ if (this.claimedByToken(request.claimToken) !== undefined)
346
+ return undefined;
347
+ let oldest;
348
+ for (const submission of this.submissions.values()) {
349
+ if (this.claimed.has(submission.submissionId) || this.sent.has(submission.submissionId)) {
350
+ continue;
351
+ }
352
+ if (oldest === undefined || compareEnvelopeOrder(submission, oldest) < 0) {
353
+ oldest = submission;
354
+ }
355
+ }
356
+ if (oldest === undefined)
357
+ return undefined;
358
+ this.claimed.set(oldest.submissionId, {
359
+ submissionId: oldest.submissionId,
360
+ claimant: request.claimant,
361
+ claimedAt: request.claimedAt,
362
+ claimToken: request.claimToken,
363
+ });
364
+ return {
365
+ submission: oldest,
366
+ claimant: request.claimant,
367
+ claimToken: request.claimToken,
368
+ claimedAt: request.claimedAt,
369
+ };
370
+ }
371
+ async markSent(claimToken, sentAt) {
372
+ const submissionId = this.claimedByToken(claimToken);
373
+ if (submissionId === undefined)
374
+ return false;
375
+ this.claimed.delete(submissionId);
376
+ this.sent.set(submissionId, sentAt);
377
+ return true;
378
+ }
379
+ async deleteSubmission(submissionId) {
380
+ const held = this.submissions.delete(submissionId);
381
+ if (!held)
382
+ return false;
383
+ this.claimed.delete(submissionId);
384
+ this.sent.delete(submissionId);
385
+ return true;
386
+ }
387
+ async requeue(claimToken) {
388
+ const submissionId = this.claimedByToken(claimToken);
389
+ if (submissionId === undefined)
390
+ return false;
391
+ this.claimed.delete(submissionId);
392
+ return true;
393
+ }
394
+ async reclaimStale(request) {
395
+ const reclaimed = [];
396
+ if (request.submissionId !== undefined) {
397
+ const claim = this.claimed.get(request.submissionId);
398
+ if (claim !== undefined && claim.claimedAt < request.staleBefore) {
399
+ this.claimed.delete(request.submissionId);
400
+ reclaimed.push(request.submissionId);
401
+ }
402
+ return reclaimed;
403
+ }
404
+ for (const [submissionId, claim] of this.claimed) {
405
+ if (claim.claimedAt < request.staleBefore) {
406
+ reclaimed.push(submissionId);
407
+ }
408
+ }
409
+ for (const submissionId of reclaimed) {
410
+ this.claimed.delete(submissionId);
411
+ }
412
+ return reclaimed.sort(compareText);
413
+ }
414
+ claimedByToken(claimToken) {
415
+ for (const [submissionId, claim] of this.claimed) {
416
+ if (claim.claimToken === claimToken)
417
+ return submissionId;
418
+ }
419
+ return undefined;
420
+ }
421
+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C;QACD,KAAK,MAAM,YAAY,IAAI,SAAS,EAAE,CAAC;YACrC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC;QACD,OAAO,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrC,CAAC;IAEO,cAAc,CAAC,UAAkB;QACvC,KAAK,MAAM,CAAC,YAAY,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjD,IAAI,KAAK,CAAC,UAAU,KAAK,UAAU;gBAAE,OAAO,YAAY,CAAC;QAC3D,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;CACF","sourcesContent":["import { canonicalHash, canonicalHashOwned, copyRestricted } from '../canonical/jcs.js';\nimport { objectShapeViolation, prototypeOf, setOwn } from '../canonical/restricted.js';\nimport { AxiomError } from '../model/errors.js';\nimport type { DatasetDigestMismatch } from '../lookup/digest.js';\nimport type { CompiledSchema } from '../model/schema.js';\nimport type { EvaluationReport, LookupTableDocument } from '../model/types.js';\nimport { isRecord } from '../model/values.js';\nimport type { BoundaryRefusal } from '../model/wire.js';\nimport { refusalOf } from '../model/wire.js';\n\n/**\n * The storage contract a device implements, and nothing a runtime can implement for it.\n *\n * Offline admission (`admitOfflineArtifact`) answers whether the bytes a device holds may be\n * evaluated. It does not answer where those bytes came from, whether a write survived a restart,\n * or which process may send a queued submission. Those are storage questions, and a host answers\n * them better than this package can: a browser has IndexedDB, a device has SQLite, and a Node\n * service has a file it chooses. This module states the smallest surface the device lane needs so\n * that two hosts cannot invent two incompatible meanings of \"cached artifact\" or \"claimed\n * submission\".\n *\n * Two rules give the contract its meaning:\n *\n * - Every stored artifact and dataset carries the canonical digest the offline gate matches on.\n * A version is a name; the digest is the bytes. A store that files a document under a version\n * without its digest cannot serve `admitOfflineArtifact`, and one that serves bytes which no\n * longer hash to the recorded digest is corrupt rather than merely missing.\n * - `publish` and `claimNext` are the two operations with concurrency in their statement. A host\n * performs each in one transaction: a partially published artifact would leave a version whose\n * datasets are absent, and a claim that is not atomic would let two workers send one record.\n *\n * Everything else is a host choice: sync policy, conflict resolution, retry, encryption and the\n * clock. The contract states no clock and no network so that an implementation cannot hide\n * either behind a store method.\n */\n\n/** The identity and bytes of one artifact version, as a device files it. */\nexport interface ArtifactPin {\n /** The artifact's `schemaId`. */\n readonly artifactId: string;\n /** The artifact's `schemaVersion`. */\n readonly artifactVersion: number;\n /** The restricted-JSON canonical SHA-256 of the artifact document. */\n readonly sha256: string;\n}\n\n/** The identity and bytes of one dataset version, as the artifact's pin names it. */\nexport interface DatasetPin {\n readonly tableId: string;\n readonly tableVersion: number;\n /** The restricted-JSON canonical SHA-256 of the dataset document. */\n readonly sha256: string;\n}\n\n/** One artifact version and the document it names. */\nexport interface StoredArtifact extends ArtifactPin {\n readonly document: CompiledSchema;\n}\n\n/** One dataset version and the document it names. */\nexport interface StoredDataset extends DatasetPin {\n readonly document: LookupTableDocument;\n}\n\n/**\n * A draft: the values a device kept between visits, under the version they were recorded at.\n *\n * The row keys travel beside the values because an assigned row's identity is minted rather than\n * recorded, so the keys are the only statement of which row is which after a restart\n * (`spec/semantics/identity-v1.md`). A draft carries no verdict and no report: every decision is\n * the server's to make again on reopen ([ACCESS-7.1.1]).\n */\nexport interface StoredDraft {\n /** The host's key for one draft, unique within the device. */\n readonly draftId: string;\n readonly schemaId: string;\n readonly schemaVersion: number;\n readonly values: Readonly<Record<string, unknown>>;\n readonly rowKeys: Readonly<Record<string, readonly (string | number)[]>>;\n /** The host's timestamp, so the store never reads a clock. */\n readonly updatedAt: string;\n}\n\n/** A sealed report and the digest that binds it. */\nexport interface StoredReport {\n /** The host's key for one report, unique within the device. */\n readonly reportId: string;\n readonly schemaId: string;\n readonly schemaVersion: number;\n /** The digest computed by `evaluate`'s seal, copied from the report body. */\n readonly reportHash: string;\n /** The sealed report, exactly as the runtime returned it. */\n readonly report: EvaluationReport;\n /** The host's timestamp, so the store never reads a clock. */\n readonly sealedAt: string;\n}\n\n/** One submission waiting to reach the server. */\nexport interface SubmissionEnvelope {\n /** The host's key for one submission. Re-enqueuing the same id is a no-op. */\n readonly submissionId: string;\n readonly schemaId: string;\n readonly schemaVersion: number;\n /** The artifact the submission was evaluated under, so the server can name the decision. */\n readonly artifactSha256: string;\n /** The report this submission carries, by the store's report key. */\n readonly reportId: string;\n /** The report's sealed digest, so the server can verify the evidence it receives. */\n readonly reportHash: string;\n /** The exported record the server accepts. */\n readonly payload: Readonly<Record<string, unknown>>;\n /** The host's timestamp, so the store never reads a clock. */\n readonly queuedAt: string;\n /**\n * The principal authority under which this submission was queued.\n *\n * Persisted so a later flush on a shared device never adopts another user's ambient session.\n * Omitted only for legacy rows migrated before schema v2 recorded authority; a host flushing a\n * row whose `principal` is absent or blank must refuse to adopt the ambient session.\n */\n readonly principal?: string;\n}\n\n/** Where one submission sits in the device's queue. */\nexport type SubmissionStatus = 'queued' | 'claimed' | 'sent';\n\n/**\n * One persisted submission and its current queue state, as returned by `readSubmissions()`.\n *\n * Active `claimToken` values are deliberately omitted so inspecting the queue cannot grant\n * another caller the right to finish or requeue a live worker's claim.\n */\nexport type StoredSubmission =\n | {\n readonly status: 'queued';\n readonly submission: SubmissionEnvelope;\n }\n | {\n readonly status: 'claimed';\n readonly submission: SubmissionEnvelope;\n readonly claimant: string;\n readonly claimedAt: string;\n }\n | {\n readonly status: 'sent';\n readonly submission: SubmissionEnvelope;\n readonly sentAt: string;\n };\n\n/**\n * Host-supplied lease cutoff for reopening abandoned claims.\n *\n * Every timestamp is supplied by the host so the store reads no clock. Claims with\n * `claimedAt < staleBefore` (UTC ISO-8601 lexicographic order) are returned to `queued` with\n * their claim token cleared, preventing a revived worker from completing a reclaimed row.\n */\nexport interface ReclaimStaleRequest {\n /** Cutoff timestamp; only claims with `claimedAt < staleBefore` are reopened. */\n readonly staleBefore: string;\n /** When provided, only this submission is eligible; when omitted, all stale claims reopen. */\n readonly submissionId?: string;\n}\n\n/**\n * Who is claiming the next queued submission.\n *\n * The host supplies the token because identity is the host's to mint: a browser has `crypto`, a\n * device may have a keystore, and a process may have a transaction id. The store uses the token\n * only to guard `markSent` and `requeue`, so possession of it is the right to finish the claim.\n */\nexport interface ClaimRequest {\n readonly claimant: string;\n readonly claimToken: string;\n /** The host's timestamp, so the store never reads a clock. */\n readonly claimedAt: string;\n}\n\n/** One claimed submission and the token that completes it. */\nexport interface SubmissionClaim {\n readonly submission: SubmissionEnvelope;\n readonly claimant: string;\n readonly claimToken: string;\n readonly claimedAt: string;\n}\n\n/** What a host asks the store to publish. */\nexport interface PublishRequest {\n readonly artifact: CompiledSchema;\n /** The digest the host was told to expect; admission will ask for the same value. */\n readonly expectedSha256: string;\n /**\n * The dataset documents this publication installs.\n *\n * A supplied document the artifact does not pin is refused: it would be stored under a version\n * no artifact states, and the next publication would have to guess which one is authoritative.\n * A pin this publication does not install is not refused here; the offline gate names it as\n * missing when a caller admits the artifact, which keeps reachability a property of the\n * artifact's rules rather than a second copy of that walk in the store.\n */\n readonly datasets?: readonly LookupTableDocument[];\n}\n\n/** A dataset a publication offered that the artifact does not pin. */\nexport interface UnpinnedDataset {\n readonly tableId: string;\n readonly tableVersion: number;\n}\n\n/** A publication the store refused, with the facts a host logs or renders. */\nexport type PublishRefusal =\n | {\n readonly kind: 'refused';\n readonly reason: 'artifact_digest_mismatch';\n readonly expected: string;\n readonly actual: string;\n }\n | {\n readonly kind: 'refused';\n /** The id and version are already taken by different bytes. */\n readonly reason: 'artifact_conflict';\n readonly artifactId: string;\n readonly artifactVersion: number;\n readonly held: string;\n readonly offered: string;\n }\n | {\n readonly kind: 'refused';\n /** A supplied document's canonical digest is not the digest the artifact pins. */\n readonly reason: 'dataset_digest_mismatch';\n readonly tables: readonly DatasetDigestMismatch[];\n }\n | {\n readonly kind: 'refused';\n /** The version is already taken by different bytes another artifact may pin. */\n readonly reason: 'dataset_conflict';\n readonly tables: readonly DatasetDigestMismatch[];\n }\n | {\n readonly kind: 'refused';\n readonly reason: 'dataset_unpinned';\n readonly tables: readonly UnpinnedDataset[];\n };\n\n/** The answer to one publication: the artifact and datasets now held, or the refusal. */\nexport type PublishResult =\n | {\n readonly kind: 'published';\n readonly artifact: StoredArtifact;\n readonly datasets: readonly StoredDataset[];\n }\n | PublishRefusal;\n\n/** Whether an enqueue created a row or found the id already queued. */\nexport type EnqueueOutcome = 'queued' | 'existing';\n\n/**\n * The device's storage, stated as operations a host can implement over any durable medium.\n *\n * A store never reads a clock, never fetches and never decides policy: every timestamp and token\n * is supplied by the host, and every refusal is a value rather than a throw. The two operations\n * marked atomic are the contract's concurrency surface.\n */\nexport interface OfflineStore {\n /**\n * The artifact at exactly this id, version and digest, or `undefined`.\n *\n * An implementation verifies the stored document against the digest it filed it under and\n * refuses corrupt bytes rather than returning them: admission would refuse them later, but a\n * host that read them would have already accepted the integrity of its own storage.\n */\n readArtifact(pin: ArtifactPin): Promise<StoredArtifact | undefined>;\n\n /**\n * The datasets held at exactly the supplied pins, in the pins' order.\n *\n * A pin whose bytes are absent or hash to another digest is omitted; the caller hands the\n * result to `admitOfflineArtifact`, which names what is missing or mismatched.\n */\n readDatasets(pins: readonly DatasetPin[]): Promise<readonly StoredDataset[]>;\n\n /**\n * Publishes one artifact and its datasets atomically, or writes nothing.\n *\n * The operation is idempotent for identical bytes and refuses a digest mismatch, a version\n * already taken by different bytes, a supplied dataset the artifact does not pin, or a\n * supplied dataset whose digest is not the pinned one. A host implements it as one\n * transaction; an interrupted publication is never observable.\n */\n publish(request: PublishRequest): Promise<PublishResult>;\n\n /** Keeps one draft, replacing the previous draft at the same id. */\n saveDraft(draft: StoredDraft): Promise<void>;\n\n /** The draft at this id, or `undefined`. Bytes that do not read back as a draft are refused. */\n readDraft(draftId: string): Promise<StoredDraft | undefined>;\n\n /** Forgets one draft, answering whether a row was removed. */\n deleteDraft(draftId: string): Promise<boolean>;\n\n /**\n * Keeps one sealed report, answering `false` when the id is already held under another digest.\n *\n * An identical report is idempotent and answers `true`. The digest is checked against the\n * report body before the write, so a caller cannot file bytes whose `reportHash` no longer\n * describes them.\n */\n saveReport(report: StoredReport): Promise<boolean>;\n\n /** The report at this id, or `undefined`. */\n readReport(reportId: string): Promise<StoredReport | undefined>;\n\n /** Adds one submission to the queue; an id already present is left untouched. */\n enqueue(submission: SubmissionEnvelope): Promise<EnqueueOutcome>;\n\n /**\n * Lists every submission currently stored in the queue, ordered by `(queuedAt, submissionId)`.\n *\n * Enables status reporting, reconciliation, and host-controlled stale-claim inspection without\n * exposing active `claimToken` values.\n *\n * On shared or multi-principal devices, this method returns rows queued under every principal in\n * the store. Callers rendering a submission list or status view for an active user must filter\n * by the signed-in `principal` (and exclude rows with absent or mismatched `principal`) rather\n * than displaying another principal's queued payload.\n */\n readSubmissions(): Promise<readonly StoredSubmission[]>;\n\n /**\n * Claims the oldest queued submission by `(queuedAt, submissionId)` for one claimant.\n *\n * This operation is atomic across processes: exactly one caller may observe a claim for one\n * submission, and every later caller sees the next queued row or `undefined`. A host\n * implements it with a single conditional update (or an exclusive transaction that selects and\n * updates), never with a read followed by an unconditional write.\n *\n * A claim token identifies one claim. A token that already owns a claimed row is answered\n * `undefined` (never throwing a constraint error), so `markSent` and `requeue` can never be\n * ambiguous about which row the caller means. In SQL, the conditional update guards against an\n * active token with `NOT EXISTS` while `claim_token TEXT UNIQUE` remains as a schema invariant.\n */\n claimNext(request: ClaimRequest): Promise<SubmissionClaim | undefined>;\n\n /**\n * Marks the submission claimed under `claimToken` as sent. Answers `false` when the token owns\n * no claimed row, so a stale worker cannot complete another worker's claim.\n */\n markSent(claimToken: string, sentAt: string): Promise<boolean>;\n\n /**\n * Removes one submission from this device, in any state.\n *\n * This is the user's delete and the host's retention boundary. A `sent` row is removed after\n * the server acknowledges it; a refused or otherwise terminal row stays until this is called,\n * because a store does not decide how long a person's record may sit on their device. Answers\n * `false` when the id owns no row.\n */\n deleteSubmission(submissionId: string): Promise<boolean>;\n\n /**\n * Returns the submission claimed under `claimToken` to `queued`. Answers `false` when the token\n * owns no claimed row.\n *\n * This is the active claimant's retry primitive when a send fails transiently and the worker\n * still holds its token. When a claimant dies and its token is lost, use `reclaimStale`.\n */\n requeue(claimToken: string): Promise<boolean>;\n\n /**\n * Atomically returns stale claimed submissions (`claimedAt < staleBefore`) back to `queued`,\n * clearing their claim tokens so dead claimants cannot later complete or requeue them.\n *\n * When `request.submissionId` is supplied, only that row is eligible; when omitted, every\n * claimed row earlier than `request.staleBefore` is reopened. Never touches `queued` or `sent`\n * rows, reads no clock, and returns the reopened `submissionId`s in lexicographic order.\n */\n reclaimStale(request: ReclaimStaleRequest): Promise<readonly string[]>;\n}\n\n/** A sealed report this reader accepted, or the refusal that says why it did not. */\nexport type SealedReportAdmission =\n | { readonly ok: true; readonly report: EvaluationReport }\n | { readonly ok: false; readonly refusal: BoundaryRefusal };\n\nconst OUTCOMES: ReadonlySet<string> = new Set(['PASS', 'FAIL', 'UNKNOWN', 'DEFERRED']);\n\nfunction reportRefusal(path: string, detail: string): BoundaryRefusal {\n return { code: 'ENGINE_ERROR', path, detail };\n}\n\n/**\n * Reads a stored report body into `EvaluationReport`, `readSealedReport()`.\n *\n * A report arrives from storage as JSON, so it is untrusted like any other stored value. Two\n * facts make it a sealed report rather than a JSON object that looks like one: the required\n * top-level members are present with their declared kinds, and `reportHash` equals the canonical\n * hash of the body without it. The second is the seal itself, recomputed; a host that skipped it\n * would be trusting a digest it had not checked.\n *\n * The nested rule results, diagnostics and lookup provenance are not re-validated here. They were\n * produced by this runtime and are covered by the same digest, so a successful hash check proves\n * the bytes are the ones the runtime sealed. A body the restricted profile cannot canonicalise is\n * a boundary refusal, not a thrown error: the seal cannot be recomputed over it at all.\n */\n/** Reads an own property only so ambient `Object.prototype` properties never satisfy a report field. */\nfunction ownMember(record: Readonly<Record<string, unknown>>, key: string): unknown {\n return Object.hasOwn(record, key) ? record[key] : undefined;\n}\n\nexport function readSealedReport(value: unknown): SealedReportAdmission {\n if (!isRecord(value)) {\n return { ok: false, refusal: reportRefusal('$', 'the report is not a JSON object') };\n }\n const prototype = prototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n return {\n ok: false,\n refusal: reportRefusal('$', 'the report is not a plain JSON object'),\n };\n }\n const violation = objectShapeViolation(value);\n if (violation !== undefined) {\n return {\n ok: false,\n refusal: reportRefusal('$', `restricted JSON refuses ${violation}`),\n };\n }\n const schemaId = ownMember(value, 'schemaId');\n const schemaVersion = ownMember(value, 'schemaVersion');\n const exprVersion = ownMember(value, 'exprVersion');\n const behaviorHash = ownMember(value, 'behaviorHash');\n const reportHash = ownMember(value, 'reportHash');\n const status = ownMember(value, 'status');\n if (typeof schemaId !== 'string') {\n return { ok: false, refusal: reportRefusal('$.schemaId', 'the report names no schema') };\n }\n if (typeof schemaVersion !== 'number' || !Number.isInteger(schemaVersion)) {\n return {\n ok: false,\n refusal: reportRefusal('$.schemaVersion', 'the report version is not an integer'),\n };\n }\n if (exprVersion !== 1) {\n return { ok: false, refusal: reportRefusal('$.exprVersion', 'the report is not Expr v1') };\n }\n if (typeof behaviorHash !== 'string') {\n return { ok: false, refusal: reportRefusal('$.behaviorHash', 'the report names no behaviour') };\n }\n if (typeof reportHash !== 'string') {\n return { ok: false, refusal: reportRefusal('$.reportHash', 'the report carries no seal') };\n }\n if (typeof status !== 'string' || !OUTCOMES.has(status)) {\n return { ok: false, refusal: reportRefusal('$.status', 'the report has no known outcome') };\n }\n for (const member of ['access', 'rules', 'diagnostics', 'lookups'] as const) {\n if (!Array.isArray(ownMember(value, member))) {\n return {\n ok: false,\n refusal: reportRefusal(`$.${member}`, `the report's ${member} is not a list`),\n };\n }\n }\n // Copy and validate every nested member through the restricted profile before sealing so the\n // admitted report is a clean plain tree detached from caller mutations, getters, symbols, or\n // non-plain prototypes.\n let copied: unknown;\n try {\n copied = copyRestricted(value);\n } catch (error) {\n if (!(error instanceof AxiomError)) throw error;\n return { ok: false, refusal: refusalOf(error) };\n }\n if (!isRecord(copied)) {\n return { ok: false, refusal: reportRefusal('$', 'the report is not a JSON object') };\n }\n const body: Record<string, unknown> = {};\n for (const key of Object.keys(copied)) {\n // Own-property definition keeps prototype-accessor names like `__proto__` as own data so the\n // recomputed seal covers every own member the returned report carries.\n if (key !== 'reportHash') setOwn(body, key, copied[key]);\n }\n let computed: string;\n try {\n computed = canonicalHashOwned(body);\n } catch (error) {\n if (!(error instanceof AxiomError)) throw error;\n return { ok: false, refusal: refusalOf(error) };\n }\n if (computed !== reportHash) {\n return {\n ok: false,\n refusal: reportRefusal('$.reportHash', 'the report body does not hash to its seal'),\n };\n }\n // Every member checked above is the member `EvaluationReport` declares, and the seal proves the\n // rest of the bytes are the ones this runtime produced. The assertion states that proof.\n return { ok: true, report: reportValue(copied) };\n}\n\n/** The one assertion `readSealedReport` makes, after the checks above discharged its receipt. */\nfunction reportValue(value: unknown): EvaluationReport {\n return value as EvaluationReport;\n}\n\n/** The key one dataset version is filed under; the version is part of the identity. */\nfunction datasetKey(tableId: string, tableVersion: number): string {\n return `${tableId}\\u0000${String(tableVersion)}`;\n}\n\n/** The key one artifact version is filed under. */\nfunction artifactKey(artifactId: string, artifactVersion: number): string {\n return `${artifactId}\\u0000${String(artifactVersion)}`;\n}\n\n/** Lexicographic code-unit ordering matching SQLite's default BINARY collation for ASCII/ISO text. */\nfunction compareText(left: string, right: string): number {\n if (left < right) return -1;\n if (left > right) return 1;\n return 0;\n}\n\n/** Queue ordering matching SQLite's `ORDER BY queued_at, submission_id`. */\nfunction compareEnvelopeOrder(left: SubmissionEnvelope, right: SubmissionEnvelope): number {\n return (\n compareText(left.queuedAt, right.queuedAt) || compareText(left.submissionId, right.submissionId)\n );\n}\n\n/**\n * A reference `OfflineStore` over maps, for tests and for a host whose \"durable\" medium is the\n * process lifetime.\n *\n * It is deliberately small and synchronous underneath: every method validates before it writes,\n * so `publish` is atomic in the only sense a single-threaded runtime can offer. It is not the\n * offline proof. A host that needs durability implements this interface over its own store; the\n * SQLite proof in `test/offline` is the executable contract for the transaction and claim\n * semantics.\n */\nexport class MemoryOfflineStore implements OfflineStore {\n private readonly artifacts = new Map<string, StoredArtifact>();\n private readonly datasets = new Map<string, StoredDataset>();\n private readonly drafts = new Map<string, StoredDraft>();\n private readonly reports = new Map<string, StoredReport>();\n private readonly submissions = new Map<string, SubmissionEnvelope>();\n private readonly claimed = new Map<\n string,\n {\n readonly submissionId: string;\n readonly claimant: string;\n readonly claimedAt: string;\n readonly claimToken: string;\n }\n >();\n private readonly sent = new Map<string, string>();\n\n async readArtifact(pin: ArtifactPin): Promise<StoredArtifact | undefined> {\n const held = this.artifacts.get(artifactKey(pin.artifactId, pin.artifactVersion));\n if (held === undefined || held.sha256 !== pin.sha256) return undefined;\n if (canonicalHash(held.document) !== held.sha256) {\n throw new Error(\n `the stored artifact ${held.artifactId} v${String(held.artifactVersion)} does not hash to its digest`,\n );\n }\n return held;\n }\n\n async readDatasets(pins: readonly DatasetPin[]): Promise<readonly StoredDataset[]> {\n const found: StoredDataset[] = [];\n for (const pin of pins) {\n const held = this.datasets.get(datasetKey(pin.tableId, pin.tableVersion));\n if (held === undefined || held.sha256 !== pin.sha256) continue;\n if (canonicalHash(held.document) !== held.sha256) {\n throw new Error(\n `the stored dataset ${held.tableId} v${String(held.tableVersion)} does not hash to its digest`,\n );\n }\n found.push(held);\n }\n return found;\n }\n\n async publish(request: PublishRequest): Promise<PublishResult> {\n const actual = canonicalHash(request.artifact);\n if (actual !== request.expectedSha256) {\n return {\n kind: 'refused',\n reason: 'artifact_digest_mismatch',\n expected: request.expectedSha256,\n actual,\n };\n }\n const artifactId = request.artifact.schemaId;\n const artifactVersion = request.artifact.schemaVersion;\n const heldArtifact = this.artifacts.get(artifactKey(artifactId, artifactVersion));\n if (heldArtifact !== undefined && heldArtifact.sha256 !== actual) {\n return {\n kind: 'refused',\n reason: 'artifact_conflict',\n artifactId,\n artifactVersion,\n held: heldArtifact.sha256,\n offered: actual,\n };\n }\n const pins = new Map<string, DatasetPin>();\n for (const ref of request.artifact.datasets ?? []) {\n pins.set(datasetKey(ref.tableId, ref.tableVersion), {\n tableId: ref.tableId,\n tableVersion: ref.tableVersion,\n sha256: ref.sha256,\n });\n }\n const supplied = request.datasets ?? [];\n const unpinned: UnpinnedDataset[] = [];\n const mismatched: DatasetDigestMismatch[] = [];\n const conflicts: DatasetDigestMismatch[] = [];\n const offered: StoredDataset[] = [];\n for (const document of supplied) {\n const pin = pins.get(datasetKey(document.tableId, document.tableVersion));\n const digest = canonicalHash(document);\n if (pin === undefined) {\n unpinned.push({ tableId: document.tableId, tableVersion: document.tableVersion });\n continue;\n }\n if (pin.sha256 !== digest) {\n mismatched.push({\n tableId: document.tableId,\n tableVersion: document.tableVersion,\n expected: pin.sha256,\n actual: digest,\n });\n continue;\n }\n const held = this.datasets.get(datasetKey(document.tableId, document.tableVersion));\n if (held !== undefined && held.sha256 !== digest) {\n conflicts.push({\n tableId: document.tableId,\n tableVersion: document.tableVersion,\n expected: held.sha256,\n actual: digest,\n });\n continue;\n }\n offered.push({\n tableId: document.tableId,\n tableVersion: document.tableVersion,\n sha256: digest,\n document,\n });\n }\n if (unpinned.length > 0)\n return { kind: 'refused', reason: 'dataset_unpinned', tables: unpinned };\n if (mismatched.length > 0) {\n return { kind: 'refused', reason: 'dataset_digest_mismatch', tables: mismatched };\n }\n if (conflicts.length > 0)\n return { kind: 'refused', reason: 'dataset_conflict', tables: conflicts };\n // Validation is complete, so the writes below are one step from the caller's point of view.\n const artifact: StoredArtifact = {\n artifactId,\n artifactVersion,\n sha256: actual,\n document: request.artifact,\n };\n this.artifacts.set(artifactKey(artifactId, artifactVersion), artifact);\n for (const dataset of offered) {\n this.datasets.set(datasetKey(dataset.tableId, dataset.tableVersion), dataset);\n }\n return { kind: 'published', artifact, datasets: offered };\n }\n\n async saveDraft(draft: StoredDraft): Promise<void> {\n this.drafts.set(draft.draftId, draft);\n }\n\n async readDraft(draftId: string): Promise<StoredDraft | undefined> {\n return this.drafts.get(draftId);\n }\n\n async deleteDraft(draftId: string): Promise<boolean> {\n return this.drafts.delete(draftId);\n }\n\n async saveReport(report: StoredReport): Promise<boolean> {\n const admission = readSealedReport(report.report);\n if (!admission.ok || admission.report.reportHash !== report.reportHash) return false;\n const held = this.reports.get(report.reportId);\n if (held !== undefined) return held.reportHash === report.reportHash;\n this.reports.set(report.reportId, report);\n return true;\n }\n\n async readReport(reportId: string): Promise<StoredReport | undefined> {\n const held = this.reports.get(reportId);\n if (held === undefined) return undefined;\n const admission = readSealedReport(held.report);\n if (!admission.ok) {\n throw new Error(`the stored report ${reportId} is not sealed: ${admission.refusal.detail}`);\n }\n if (admission.report.reportHash !== held.reportHash) {\n throw new Error(`the stored report ${reportId} does not match its recorded digest`);\n }\n return held;\n }\n\n async enqueue(submission: SubmissionEnvelope): Promise<EnqueueOutcome> {\n if (this.submissions.has(submission.submissionId)) return 'existing';\n this.submissions.set(submission.submissionId, submission);\n return 'queued';\n }\n\n async readSubmissions(): Promise<readonly StoredSubmission[]> {\n const ordered = [...this.submissions.values()].sort(compareEnvelopeOrder);\n return ordered.map((submission): StoredSubmission => {\n const active = this.claimed.get(submission.submissionId);\n if (active !== undefined) {\n return {\n status: 'claimed',\n submission,\n claimant: active.claimant,\n claimedAt: active.claimedAt,\n };\n }\n const sentAt = this.sent.get(submission.submissionId);\n if (sentAt !== undefined) {\n return {\n status: 'sent',\n submission,\n sentAt,\n };\n }\n return {\n status: 'queued',\n submission,\n };\n });\n }\n\n async claimNext(request: ClaimRequest): Promise<SubmissionClaim | undefined> {\n // One synchronous pass: no other call can observe a half-claimed row in this runtime.\n // A token owns at most one claim: it is the only guard `markSent` and `requeue` read, so a\n // token with two rows would leave the second stranded forever. Both SQLite adapters guard\n // this in the conditional update with `NOT EXISTS` and keep `claim_token TEXT UNIQUE` as the\n // schema invariant, so all implementations answer `undefined` without throwing.\n if (this.claimedByToken(request.claimToken) !== undefined) return undefined;\n let oldest: SubmissionEnvelope | undefined;\n for (const submission of this.submissions.values()) {\n if (this.claimed.has(submission.submissionId) || this.sent.has(submission.submissionId)) {\n continue;\n }\n if (oldest === undefined || compareEnvelopeOrder(submission, oldest) < 0) {\n oldest = submission;\n }\n }\n if (oldest === undefined) return undefined;\n this.claimed.set(oldest.submissionId, {\n submissionId: oldest.submissionId,\n claimant: request.claimant,\n claimedAt: request.claimedAt,\n claimToken: request.claimToken,\n });\n return {\n submission: oldest,\n claimant: request.claimant,\n claimToken: request.claimToken,\n claimedAt: request.claimedAt,\n };\n }\n\n async markSent(claimToken: string, sentAt: string): Promise<boolean> {\n const submissionId = this.claimedByToken(claimToken);\n if (submissionId === undefined) return false;\n this.claimed.delete(submissionId);\n this.sent.set(submissionId, sentAt);\n return true;\n }\n\n async deleteSubmission(submissionId: string): Promise<boolean> {\n const held = this.submissions.delete(submissionId);\n if (!held) return false;\n this.claimed.delete(submissionId);\n this.sent.delete(submissionId);\n return true;\n }\n\n async requeue(claimToken: string): Promise<boolean> {\n const submissionId = this.claimedByToken(claimToken);\n if (submissionId === undefined) return false;\n this.claimed.delete(submissionId);\n return true;\n }\n\n async reclaimStale(request: ReclaimStaleRequest): Promise<readonly string[]> {\n const reclaimed: string[] = [];\n if (request.submissionId !== undefined) {\n const claim = this.claimed.get(request.submissionId);\n if (claim !== undefined && claim.claimedAt < request.staleBefore) {\n this.claimed.delete(request.submissionId);\n reclaimed.push(request.submissionId);\n }\n return reclaimed;\n }\n for (const [submissionId, claim] of this.claimed) {\n if (claim.claimedAt < request.staleBefore) {\n reclaimed.push(submissionId);\n }\n }\n for (const submissionId of reclaimed) {\n this.claimed.delete(submissionId);\n }\n return reclaimed.sort(compareText);\n }\n\n private claimedByToken(claimToken: string): string | undefined {\n for (const [submissionId, claim] of this.claimed) {\n if (claim.claimToken === claimToken) return submissionId;\n }\n return undefined;\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * `@azx-pbc/axiom-runtime/testing` — the repository's own measurement and parity surface.
3
+ *
4
+ * **Not a host API.** Nothing here carries a compatibility guarantee: the shape of a parity
5
+ * oracle follows the tests that compare against it, and a counter follows the budget a benchmark
6
+ * states. This repository's gates, benches and packed-surface suites are the only consumers, and
7
+ * none of these names is exported from `.` or `./evaluate`. A published name here would become a
8
+ * compatibility promise with no consumer, and a counter on the narrow entry would add cost to the
9
+ * door that exists to stay cheap.
10
+ *
11
+ * The names are pinned by `test/runtime-entry-split.test.ts` and
12
+ * `test/package-entry-surface.test.ts`, so a new rule moves one of these behind a deliberate
13
+ * edit rather than onto a host door.
14
+ */
15
+ export { evaluateAllNaive } from './eval/engine/naive.js';
16
+ export { deliveryIndexWalks } from './eval/engine/measurement.js';
17
+ export { sealsPerformed } from './eval/seal.js';
18
+ export { artifactStaticDerivations, availabilityConditionsEvaluated, availabilityMapCopies, blockerIdentityBuilds, rowTemplateMemberWalks, } from './eval/state/measurement.js';
19
+ export { artifactBehaviourDerivations } from './eval/rule/behaviour.js';
20
+ export { restrictedCanonicalizations } from './canonical/jcs.js';
21
+ export { wireValidations } from './model/wire.js';
22
+ export { overlayRowRuleComparisons } from './eval/access/overlay.js';
23
+ export { projectionWithheldComparisons } from './eval/submission.js';
24
+ export { evaluatorFor, readArtifactVersion } from './eval/version-dispatch.js';
25
+ export type { ArtifactEvaluator, EvaluatorTable } from './eval/version-dispatch.js';
26
+ export { BudgetExceededError } from './eval/budget.js';
27
+ export { createEvaluationState } from './eval/rule/create-state.js';
28
+ export { evaluateSuggestions } from './eval/suggestions.js';
29
+ export { evaluationInputOf, parsedAccessOf } from './model/input.js';
30
+ //# sourceMappingURL=testing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAIlD,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AAGrE,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC/E,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAKpF,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * `@azx-pbc/axiom-runtime/testing` — the repository's own measurement and parity surface.
3
+ *
4
+ * **Not a host API.** Nothing here carries a compatibility guarantee: the shape of a parity
5
+ * oracle follows the tests that compare against it, and a counter follows the budget a benchmark
6
+ * states. This repository's gates, benches and packed-surface suites are the only consumers, and
7
+ * none of these names is exported from `.` or `./evaluate`. A published name here would become a
8
+ * compatibility promise with no consumer, and a counter on the narrow entry would add cost to the
9
+ * door that exists to stay cheap.
10
+ *
11
+ * The names are pinned by `test/runtime-entry-split.test.ts` and
12
+ * `test/package-entry-surface.test.ts`, so a new rule moves one of these behind a deliberate
13
+ * edit rather than onto a host door.
14
+ */
15
+ // The separate whole-record assembler the parity and scale suites measure the session against. It
16
+ // shares the rule executor, so it proves cache and closure completeness only; the Python corpus
17
+ // remains the independent oracle for the language.
18
+ export { evaluateAllNaive } from './eval/engine/naive.js';
19
+ // The process-lifetime counters a benchmark and a counted budget test read.
20
+ export { deliveryIndexWalks } from './eval/engine/measurement.js';
21
+ export { sealsPerformed } from './eval/seal.js';
22
+ export { artifactStaticDerivations, availabilityConditionsEvaluated, availabilityMapCopies, blockerIdentityBuilds, rowTemplateMemberWalks, } from './eval/state/measurement.js';
23
+ export { artifactBehaviourDerivations } from './eval/rule/behaviour.js';
24
+ export { restrictedCanonicalizations } from './canonical/jcs.js';
25
+ export { wireValidations } from './model/wire.js';
26
+ // The two scale counters whose readers are counted budget tests, not hosts. They live here
27
+ // rather than on the source modules' deep paths so the suite reaches every counter through an
28
+ // `exports` entry.
29
+ export { overlayRowRuleComparisons } from './eval/access/overlay.js';
30
+ export { projectionWithheldComparisons } from './eval/submission.js';
31
+ // The Expr version seam: the keyed lookup and the evaluator shape, so a retention test can add a
32
+ // second arm and prove a v1 artifact is not routed to it. A host door exports no part of it.
33
+ export { evaluatorFor, readArtifactVersion } from './eval/version-dispatch.js';
34
+ // The one-evaluation seam a cost test needs to state an over-budget refusal as data rather than
35
+ // through a report: the refusal's own class, the state builder every pass uses, the checked
36
+ // input pair it accepts, and the alternatives reader that returns the refusal with its answer.
37
+ // None of these is a host API.
38
+ export { BudgetExceededError } from './eval/budget.js';
39
+ export { createEvaluationState } from './eval/rule/create-state.js';
40
+ export { evaluateSuggestions } from './eval/suggestions.js';
41
+ export { evaluationInputOf, parsedAccessOf } from './model/input.js';
42
+ //# sourceMappingURL=testing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,kGAAkG;AAClG,gGAAgG;AAChG,mDAAmD;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,4EAA4E;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EACL,yBAAyB,EACzB,+BAA+B,EAC/B,qBAAqB,EACrB,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AACxE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,2FAA2F;AAC3F,8FAA8F;AAC9F,mBAAmB;AACnB,OAAO,EAAE,yBAAyB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,6BAA6B,EAAE,MAAM,sBAAsB,CAAC;AACrE,iGAAiG;AACjG,6FAA6F;AAC7F,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAE/E,gGAAgG;AAChG,4FAA4F;AAC5F,+FAA+F;AAC/F,+BAA+B;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC","sourcesContent":["/**\n * `@azx-pbc/axiom-runtime/testing` — the repository's own measurement and parity surface.\n *\n * **Not a host API.** Nothing here carries a compatibility guarantee: the shape of a parity\n * oracle follows the tests that compare against it, and a counter follows the budget a benchmark\n * states. This repository's gates, benches and packed-surface suites are the only consumers, and\n * none of these names is exported from `.` or `./evaluate`. A published name here would become a\n * compatibility promise with no consumer, and a counter on the narrow entry would add cost to the\n * door that exists to stay cheap.\n *\n * The names are pinned by `test/runtime-entry-split.test.ts` and\n * `test/package-entry-surface.test.ts`, so a new rule moves one of these behind a deliberate\n * edit rather than onto a host door.\n */\n// The separate whole-record assembler the parity and scale suites measure the session against. It\n// shares the rule executor, so it proves cache and closure completeness only; the Python corpus\n// remains the independent oracle for the language.\nexport { evaluateAllNaive } from './eval/engine/naive.js';\n// The process-lifetime counters a benchmark and a counted budget test read.\nexport { deliveryIndexWalks } from './eval/engine/measurement.js';\nexport { sealsPerformed } from './eval/seal.js';\nexport {\n artifactStaticDerivations,\n availabilityConditionsEvaluated,\n availabilityMapCopies,\n blockerIdentityBuilds,\n rowTemplateMemberWalks,\n} from './eval/state/measurement.js';\nexport { artifactBehaviourDerivations } from './eval/rule/behaviour.js';\nexport { restrictedCanonicalizations } from './canonical/jcs.js';\nexport { wireValidations } from './model/wire.js';\n// The two scale counters whose readers are counted budget tests, not hosts. They live here\n// rather than on the source modules' deep paths so the suite reaches every counter through an\n// `exports` entry.\nexport { overlayRowRuleComparisons } from './eval/access/overlay.js';\nexport { projectionWithheldComparisons } from './eval/submission.js';\n// The Expr version seam: the keyed lookup and the evaluator shape, so a retention test can add a\n// second arm and prove a v1 artifact is not routed to it. A host door exports no part of it.\nexport { evaluatorFor, readArtifactVersion } from './eval/version-dispatch.js';\nexport type { ArtifactEvaluator, EvaluatorTable } from './eval/version-dispatch.js';\n// The one-evaluation seam a cost test needs to state an over-budget refusal as data rather than\n// through a report: the refusal's own class, the state builder every pass uses, the checked\n// input pair it accepts, and the alternatives reader that returns the refusal with its answer.\n// None of these is a host API.\nexport { BudgetExceededError } from './eval/budget.js';\nexport { createEvaluationState } from './eval/rule/create-state.js';\nexport { evaluateSuggestions } from './eval/suggestions.js';\nexport { evaluationInputOf, parsedAccessOf } from './model/input.js';\n"]}