@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,66 @@
1
+ import type { EvaluationEnv, SubmissionAuthority } from '../model/access.js';
2
+ import type { CompiledSchema } from '../model/schema.js';
3
+ import type { ReportFacts } from '../model/types.js';
4
+ import type { FormStateOptions } from './state/options.js';
5
+ import type { FormState } from './state/derive.js';
6
+ import type { SubmissionRefusal, SubmissionTrust } from './submission/index.js';
7
+ /**
8
+ * The one answer a host gates a submission on, from one evaluation.
9
+ *
10
+ * The three answers a host used to combine — the report's `status`, a gate's `OPEN` badge and
11
+ * local readiness — are folded here exactly once. `SUBMIT` means this device found nothing
12
+ * blocking and nothing undecided; it never authorises a write, and `deferred` says the server
13
+ * still has a check to settle. `BLOCKED` names every decided cause through `form.blockers`.
14
+ * `UNDETERMINED` means nothing decided is wrong, but at least one block-severity check could
15
+ * not be decided: the form is undecided, not wrong, and `form.undeterminedChecks` names every
16
+ * open question. `REFUSED` is the one failure surface for a bad wire value or an unauthorised
17
+ * write: it is the same `{ code, path, detail, cause? }` refusal `evaluateSubmission` states, so
18
+ * a host branches on `outcome` rather than catching one surface and reading another.
19
+ *
20
+ * `report` is the report *body* — `Omit<EvaluationReport, 'reportHash'>` — the same one
21
+ * `describeFormState` derives from. The digest is a seal a host takes from `evaluateSubmission`
22
+ * or `evaluate`; this door does not state one, so there is no second digest to disagree with it.
23
+ */
24
+ export type SubmissionDecision = {
25
+ readonly outcome: 'SUBMIT';
26
+ readonly report: ReportFacts;
27
+ readonly form: FormState;
28
+ /** The `onHide: "exclude"` projection, the record this verdict describes. */
29
+ readonly values: Readonly<Record<string, unknown>>;
30
+ /** Whether a server-tier decision remains; a handoff, never a block. */
31
+ readonly deferred: boolean;
32
+ } | {
33
+ readonly outcome: 'BLOCKED';
34
+ readonly report: ReportFacts;
35
+ readonly form: FormState;
36
+ } | {
37
+ readonly outcome: 'UNDETERMINED';
38
+ readonly report: ReportFacts;
39
+ readonly form: FormState;
40
+ } | {
41
+ readonly outcome: 'REFUSED';
42
+ readonly refusal: SubmissionRefusal;
43
+ };
44
+ /**
45
+ * Decides one submission's verdict for the record an untrusted body states.
46
+ *
47
+ * This door takes exactly the same arguments and the same stance as `evaluateSubmission` — the
48
+ * body, the environment, the host's `authority`, the `trust` it states and the same
49
+ * `FormStateOptions` — and runs the same admission, so a body cannot be admissible here and
50
+ * refused there. The body is the principal's answers: a body that states `context`, `overlay`,
51
+ * `access`, `redacted` or `sessionWrites` is refused at `$.<member>` unless the stance is
52
+ * `trusted-host`, which states that the caller constructed the document (a stored record, a
53
+ * vector, a test) rather than forwarding a request. The safe default is `unstated`: it admits
54
+ * no body-supplied host fact and claims no write check, and the answer says so.
55
+ *
56
+ * A stated `kind: 'access'` stance judges every value the body carries with `checkWrite` before
57
+ * the evaluation, so a forged `read_only` value is `REFUSED` rather than folded into `SUBMIT`.
58
+ * `authority.heldValues` supplies the server's record for the bindings the principal may not
59
+ * write; a rule that reads one binds the server's value, and the body cannot override it.
60
+ *
61
+ * A writer's output whose domain does not satisfy its target is a *publish-time* defect and
62
+ * belongs to the compiler, not to this boundary: an artifact that reaches here has already
63
+ * passed the compiler's declaration checks.
64
+ */
65
+ export declare function submissionVerdict(compiled: CompiledSchema, body: unknown, env?: EvaluationEnv, authority?: SubmissionAuthority, trust?: SubmissionTrust, options?: FormStateOptions): SubmissionDecision;
66
+ //# sourceMappingURL=verdict.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdict.d.ts","sourceRoot":"","sources":["../../src/eval/verdict.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AASnD,OAAO,KAAK,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAGhF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,kBAAkB,GAC1B;IACE,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACnD,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B,GACD;IACE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B,GACD;IACE,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;CAC1B,GACD;IAAE,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAA;CAAE,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAE,OAAO,EACb,GAAG,GAAE,aAAkB,EACvB,SAAS,GAAE,mBAAwB,EACnC,KAAK,GAAE,eAAgC,EACvC,OAAO,GAAE,gBAAwC,GAChD,kBAAkB,CA8EpB"}
@@ -0,0 +1,106 @@
1
+ import { AxiomError } from '../model/errors.js';
2
+ import { refusalOf } from '../model/wire.js';
3
+ import { assertArtifactReceipt } from './receipt.js';
4
+ import { Evaluation } from './rule/runner.js';
5
+ import { NO_FORM_STATE_OPTIONS } from './state/options.js';
6
+ import { deriveFormState } from './state/derive.js';
7
+ import { admitSubmission } from './submission/admission.js';
8
+ import { auditSignatures, auditWrites, datasetRefusal, UNSTATED_TRUST, undeclaredDataset, } from './submission/index.js';
9
+ import { projectSubmission } from './submission.js';
10
+ /**
11
+ * Decides one submission's verdict for the record an untrusted body states.
12
+ *
13
+ * This door takes exactly the same arguments and the same stance as `evaluateSubmission` — the
14
+ * body, the environment, the host's `authority`, the `trust` it states and the same
15
+ * `FormStateOptions` — and runs the same admission, so a body cannot be admissible here and
16
+ * refused there. The body is the principal's answers: a body that states `context`, `overlay`,
17
+ * `access`, `redacted` or `sessionWrites` is refused at `$.<member>` unless the stance is
18
+ * `trusted-host`, which states that the caller constructed the document (a stored record, a
19
+ * vector, a test) rather than forwarding a request. The safe default is `unstated`: it admits
20
+ * no body-supplied host fact and claims no write check, and the answer says so.
21
+ *
22
+ * A stated `kind: 'access'` stance judges every value the body carries with `checkWrite` before
23
+ * the evaluation, so a forged `read_only` value is `REFUSED` rather than folded into `SUBMIT`.
24
+ * `authority.heldValues` supplies the server's record for the bindings the principal may not
25
+ * write; a rule that reads one binds the server's value, and the body cannot override it.
26
+ *
27
+ * A writer's output whose domain does not satisfy its target is a *publish-time* defect and
28
+ * belongs to the compiler, not to this boundary: an artifact that reaches here has already
29
+ * passed the compiler's declaration checks.
30
+ */
31
+ export function submissionVerdict(compiled, body, env = {}, authority = {}, trust = UNSTATED_TRUST, options = NO_FORM_STATE_OPTIONS) {
32
+ assertArtifactReceipt(compiled);
33
+ // `bodyAuthorsHostFacts` is true: a `trusted-host` document is a record the caller built, and
34
+ // its host-only members are its own. Every other stance reads the body through
35
+ // `toSubmissionInput`, which refuses them by name.
36
+ const admission = admitSubmission(compiled, body, env, authority, trust, options, true);
37
+ if (!admission.ok)
38
+ return { outcome: 'REFUSED', refusal: admission.refusal };
39
+ const { input, env: parsedEnv, trust: stated, writeAuthority, accessWindow } = admission.value;
40
+ // The two artifact-scope questions `evaluateSubmission` answers before any rule or table:
41
+ // the artifact's dataset allow-list, and the signature captures the stance covers. They are
42
+ // asked here too, so a body refused at one door is refused at this one for the same reason.
43
+ const undeclared = undeclaredDataset(compiled);
44
+ if (undeclared !== undefined)
45
+ return { outcome: 'REFUSED', refusal: datasetRefusal(undeclared) };
46
+ const signatureRefusal = auditSignatures(compiled, input, stated);
47
+ if (signatureRefusal !== undefined)
48
+ return { outcome: 'REFUSED', refusal: signatureRefusal };
49
+ const identity = options.identity;
50
+ const assignedRowKeys = identity === undefined ? undefined : (fieldId) => identity.get(fieldId);
51
+ const evaluation = new Evaluation(compiled, input, parsedEnv, {
52
+ accessWindow,
53
+ ...(assignedRowKeys === undefined ? {} : { assignedRowKeys }),
54
+ });
55
+ const reportBody = evaluation.runBody();
56
+ // The `enabled` half of the write audit needs the report; the access half already ran in the
57
+ // admission, so a forged value never reaches a rule.
58
+ if (writeAuthority !== undefined) {
59
+ const refusal = auditWrites(compiled, admission.value.bodyValues, reportBody, writeAuthority, identity);
60
+ if (refusal !== undefined)
61
+ return { outcome: 'REFUSED', refusal };
62
+ }
63
+ // The derivation reads the *body*: `describeFormState` derives the same facts from the same
64
+ // body, and the decision states that body rather than sealing it. `submissionVerdict` is the
65
+ // readiness door — a host that needs the `reportHash` takes it from `evaluateSubmission` or
66
+ // `evaluate`, whose seal over this same body is the digest of `form.report`.
67
+ const form = deriveFormState(compiled, {
68
+ report: reportBody,
69
+ access: accessWindow,
70
+ computed: evaluation.computedValues(),
71
+ input,
72
+ rowCounts: evaluation.rowCounts(),
73
+ optionAvailability: evaluation.optionAvailability(),
74
+ undecided: evaluation.undecidedCauses(),
75
+ layoutHidden: evaluation.layoutHidden(),
76
+ }, options);
77
+ if (form.verdict === 'BLOCKED')
78
+ return { outcome: 'BLOCKED', report: reportBody, form };
79
+ // An undecided record is not a submission either, and it projects no values: a host that
80
+ // wants to send the draft anyway does so through `exportSubmission`, deliberately.
81
+ if (form.verdict === 'UNDETERMINED') {
82
+ return { outcome: 'UNDETERMINED', report: reportBody, form };
83
+ }
84
+ try {
85
+ const values = projectSubmission(compiled, input, {
86
+ report: reportBody,
87
+ access: evaluation.snapshotAccess(),
88
+ ...(assignedRowKeys === undefined ? {} : { assignedRowKeys }),
89
+ });
90
+ return {
91
+ outcome: 'SUBMIT',
92
+ report: reportBody,
93
+ form,
94
+ values,
95
+ deferred: form.hasDeferredChecks,
96
+ };
97
+ }
98
+ catch (error) {
99
+ // A projection refusal is a bad value or an authoring defect. It is still the one failure
100
+ // this door returns, rather than a second surface a host must catch.
101
+ if (error instanceof AxiomError)
102
+ return { outcome: 'REFUSED', refusal: refusalOf(error) };
103
+ throw error;
104
+ }
105
+ }
106
+ //# sourceMappingURL=verdict.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verdict.js","sourceRoot":"","sources":["../../src/eval/verdict.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,WAAW,EACX,cAAc,EACd,cAAc,EACd,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAyCpD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,QAAwB,EACxB,IAAa,EACb,GAAG,GAAkB,EAAE,EACvB,SAAS,GAAwB,EAAE,EACnC,KAAK,GAAoB,cAAc,EACvC,OAAO,GAAqB,qBAAqB;IAEjD,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IAChC,8FAA8F;IAC9F,+EAA+E;IAC/E,mDAAmD;IACnD,MAAM,SAAS,GAAG,eAAe,CAAC,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,O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,OAAO;YACL,OAAO,EAAE,QAAQ;YACjB,MAAM,EAAE,UAAU;YAClB,IAAI;YACJ,MAAM;YACN,QAAQ,EAAE,IAAI,CAAC,iBAAiB;SACjC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,0FAA0F;QAC1F,qEAAqE;QACrE,IAAI,KAAK,YAAY,UAAU;YAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1F,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC","sourcesContent":["import { AxiomError } from '../model/errors.js';\nimport type { EvaluationEnv, SubmissionAuthority } from '../model/access.js';\nimport type { CompiledSchema } from '../model/schema.js';\nimport type { ReportFacts } from '../model/types.js';\nimport { refusalOf } from '../model/wire.js';\nimport { assertArtifactReceipt } from './receipt.js';\nimport { Evaluation } from './rule/runner.js';\nimport { NO_FORM_STATE_OPTIONS } from './state/options.js';\nimport type { FormStateOptions } from './state/options.js';\nimport { deriveFormState } from './state/derive.js';\nimport type { FormState } from './state/derive.js';\nimport { admitSubmission } from './submission/admission.js';\nimport {\n auditSignatures,\n auditWrites,\n datasetRefusal,\n UNSTATED_TRUST,\n undeclaredDataset,\n} from './submission/index.js';\nimport type { SubmissionRefusal, SubmissionTrust } from './submission/index.js';\nimport { projectSubmission } from './submission.js';\n\n/**\n * The one answer a host gates a submission on, from one evaluation.\n *\n * The three answers a host used to combine — the report's `status`, a gate's `OPEN` badge and\n * local readiness — are folded here exactly once. `SUBMIT` means this device found nothing\n * blocking and nothing undecided; it never authorises a write, and `deferred` says the server\n * still has a check to settle. `BLOCKED` names every decided cause through `form.blockers`.\n * `UNDETERMINED` means nothing decided is wrong, but at least one block-severity check could\n * not be decided: the form is undecided, not wrong, and `form.undeterminedChecks` names every\n * open question. `REFUSED` is the one failure surface for a bad wire value or an unauthorised\n * write: it is the same `{ code, path, detail, cause? }` refusal `evaluateSubmission` states, so\n * a host branches on `outcome` rather than catching one surface and reading another.\n *\n * `report` is the report *body* — `Omit<EvaluationReport, 'reportHash'>` — the same one\n * `describeFormState` derives from. The digest is a seal a host takes from `evaluateSubmission`\n * or `evaluate`; this door does not state one, so there is no second digest to disagree with it.\n */\nexport type SubmissionDecision =\n | {\n readonly outcome: 'SUBMIT';\n readonly report: ReportFacts;\n readonly form: FormState;\n /** The `onHide: \"exclude\"` projection, the record this verdict describes. */\n readonly values: Readonly<Record<string, unknown>>;\n /** Whether a server-tier decision remains; a handoff, never a block. */\n readonly deferred: boolean;\n }\n | {\n readonly outcome: 'BLOCKED';\n readonly report: ReportFacts;\n readonly form: FormState;\n }\n | {\n readonly outcome: 'UNDETERMINED';\n readonly report: ReportFacts;\n readonly form: FormState;\n }\n | { readonly outcome: 'REFUSED'; readonly refusal: SubmissionRefusal };\n\n/**\n * Decides one submission's verdict for the record an untrusted body states.\n *\n * This door takes exactly the same arguments and the same stance as `evaluateSubmission` — the\n * body, the environment, the host's `authority`, the `trust` it states and the same\n * `FormStateOptions` — and runs the same admission, so a body cannot be admissible here and\n * refused there. The body is the principal's answers: a body that states `context`, `overlay`,\n * `access`, `redacted` or `sessionWrites` is refused at `$.<member>` unless the stance is\n * `trusted-host`, which states that the caller constructed the document (a stored record, a\n * vector, a test) rather than forwarding a request. The safe default is `unstated`: it admits\n * no body-supplied host fact and claims no write check, and the answer says so.\n *\n * A stated `kind: 'access'` stance judges every value the body carries with `checkWrite` before\n * the evaluation, so a forged `read_only` value is `REFUSED` rather than folded into `SUBMIT`.\n * `authority.heldValues` supplies the server's record for the bindings the principal may not\n * write; a rule that reads one binds the server's value, and the body cannot override it.\n *\n * A writer's output whose domain does not satisfy its target is a *publish-time* defect and\n * belongs to the compiler, not to this boundary: an artifact that reaches here has already\n * passed the compiler's declaration checks.\n */\nexport function submissionVerdict(\n compiled: CompiledSchema,\n body: unknown,\n env: EvaluationEnv = {},\n authority: SubmissionAuthority = {},\n trust: SubmissionTrust = UNSTATED_TRUST,\n options: FormStateOptions = NO_FORM_STATE_OPTIONS,\n): SubmissionDecision {\n assertArtifactReceipt(compiled);\n // `bodyAuthorsHostFacts` is true: a `trusted-host` document is a record the caller built, and\n // its host-only members are its own. Every other stance reads the body through\n // `toSubmissionInput`, which refuses them by name.\n const admission = admitSubmission(compiled, body, env, authority, trust, options, true);\n if (!admission.ok) return { outcome: 'REFUSED', refusal: admission.refusal };\n const { input, env: parsedEnv, trust: stated, writeAuthority, accessWindow } = admission.value;\n // The two artifact-scope questions `evaluateSubmission` answers before any rule or table:\n // the artifact's dataset allow-list, and the signature captures the stance covers. They are\n // asked here too, so a body refused at one door is refused at this one for the same reason.\n const undeclared = undeclaredDataset(compiled);\n if (undeclared !== undefined) return { outcome: 'REFUSED', refusal: datasetRefusal(undeclared) };\n const signatureRefusal = auditSignatures(compiled, input, stated);\n if (signatureRefusal !== undefined) return { outcome: 'REFUSED', refusal: signatureRefusal };\n const identity = options.identity;\n const assignedRowKeys =\n identity === undefined ? undefined : (fieldId: string) => identity.get(fieldId);\n const evaluation = new Evaluation(compiled, input, parsedEnv, {\n accessWindow,\n ...(assignedRowKeys === undefined ? {} : { assignedRowKeys }),\n });\n const reportBody = evaluation.runBody();\n // The `enabled` half of the write audit needs the report; the access half already ran in the\n // admission, so a forged value never reaches a rule.\n if (writeAuthority !== undefined) {\n const refusal = auditWrites(\n compiled,\n admission.value.bodyValues,\n reportBody,\n writeAuthority,\n identity,\n );\n if (refusal !== undefined) return { outcome: 'REFUSED', refusal };\n }\n // The derivation reads the *body*: `describeFormState` derives the same facts from the same\n // body, and the decision states that body rather than sealing it. `submissionVerdict` is the\n // readiness door — a host that needs the `reportHash` takes it from `evaluateSubmission` or\n // `evaluate`, whose seal over this same body is the digest of `form.report`.\n const form = deriveFormState(\n compiled,\n {\n report: reportBody,\n access: accessWindow,\n computed: evaluation.computedValues(),\n input,\n rowCounts: evaluation.rowCounts(),\n optionAvailability: evaluation.optionAvailability(),\n undecided: evaluation.undecidedCauses(),\n layoutHidden: evaluation.layoutHidden(),\n },\n options,\n );\n if (form.verdict === 'BLOCKED') return { outcome: 'BLOCKED', report: reportBody, form };\n // An undecided record is not a submission either, and it projects no values: a host that\n // wants to send the draft anyway does so through `exportSubmission`, deliberately.\n if (form.verdict === 'UNDETERMINED') {\n return { outcome: 'UNDETERMINED', report: reportBody, form };\n }\n try {\n const values = projectSubmission(compiled, input, {\n report: reportBody,\n access: evaluation.snapshotAccess(),\n ...(assignedRowKeys === undefined ? {} : { assignedRowKeys }),\n });\n return {\n outcome: 'SUBMIT',\n report: reportBody,\n form,\n values,\n deferred: form.hasDeferredChecks,\n };\n } catch (error) {\n // A projection refusal is a bad value or an authoring defect. It is still the one failure\n // this door returns, rather than a second surface a host must catch.\n if (error instanceof AxiomError) return { outcome: 'REFUSED', refusal: refusalOf(error) };\n throw error;\n }\n}\n"]}
@@ -0,0 +1,78 @@
1
+ import type { SchemaCatalogue, StoredSignature } from '../model/evolution.js';
2
+ import type { Diagnostic } from '../model/types.js';
3
+ import type { EvaluationInput } from '../model/access.js';
4
+ /**
5
+ * Signature verification, `spec/semantics/canonical-v1.md`.
6
+ *
7
+ * A stored `signature_ref` carries the binding digest it was signed over. Verifying is
8
+ * recomputing that digest from the values the record holds *now* and comparing the two; a
9
+ * covered value that changed makes the recomputation differ, which invalidates the
10
+ * signature. The same digest is what `digest(coveredTargets, schemaVersion)` returns, so a
11
+ * rule that recomputes a signature's binding and this function agree on every record.
12
+ * The comparison reads every digit so its duration says nothing about how much of a forged
13
+ * digest was right.
14
+ *
15
+ * The digest binds the covered values, their target list and the schema version — nothing
16
+ * else. `status`, `signerRole`, `signedAt`, `id` and `mediaRefId` are the blob's and the
17
+ * record's claims about the signer, not bytes the signature covers, so a `verified` outcome
18
+ * answers "do the covered values still match this digest" and never "may this signature be
19
+ * relied on". A host that requires a live, unrevoked or role-appropriate signature applies
20
+ * that policy to those members itself; reading them here would make one answer stand for two
21
+ * different questions.
22
+ *
23
+ * Verification resolves the signature's *recorded* version through the catalogue and reads the
24
+ * values through that version's declarations (`[CANON-4.1.3]`). The bytes a seven-year-old
25
+ * signature signed are the bytes that version admitted, so upcasting the record first and
26
+ * verifying the upcast values would report a faithful signature as tampered. A version the
27
+ * catalogue does not retain is `unverifiable`, never `tampered`: the verifier cannot tell
28
+ * whether the values changed when it cannot read the declarations they were recorded under.
29
+ */
30
+ /**
31
+ * A tagged outcome rather than a boolean: a signature that is `unverifiable` or `uncovered`
32
+ * is not a valid signature, and a caller that only tested truthiness would
33
+ * treat a withheld value or a partial coverage as a pass.
34
+ */
35
+ /** The row identity a verification payload cannot derive from assigned rows' values. */
36
+ export interface SignatureVerificationOptions {
37
+ /** The session's committed manifest for one assigned array, in array order. */
38
+ readonly assignedRowKeys?: (fieldId: string) => readonly (string | number)[] | undefined;
39
+ }
40
+ export type SignatureVerification = {
41
+ readonly kind: 'verified';
42
+ readonly dataHash: string;
43
+ } | {
44
+ readonly kind: 'tampered';
45
+ readonly expectedDataHash: string;
46
+ readonly actualDataHash: string;
47
+ } | {
48
+ /** The stored targets are not the coverage the artifact declares. */
49
+ readonly kind: 'uncovered';
50
+ readonly declaredTargets: readonly string[];
51
+ readonly actualTargets: readonly string[];
52
+ } | {
53
+ readonly kind: 'unverifiable';
54
+ readonly diagnostic: Diagnostic;
55
+ };
56
+ /**
57
+ * Whether a stored signature still binds the values the record holds, verified against the
58
+ * `signature_capture` field at the version the signature names.
59
+ *
60
+ * `catalogue` is the host's retained published artifacts. The signature's recorded version is
61
+ * resolved through it before anything is read, so a stored signature is compared against the
62
+ * values its own version admitted. Reads go through the record reader of that version, so a
63
+ * covered target this device may not read is `unverifiable` rather than compared against a
64
+ * guess. An assigned row also needs `options.assignedRowKeys` from its session manifest; without
65
+ * it the target is unverifiable, never matched by position. `input.values` is the current value
66
+ * tree — the stored values, plus any computed value the host has applied from a previous report —
67
+ * so a computed covered target is verified once the host made it current.
68
+ *
69
+ * Only the covered values, their declaration order and the recorded schema version take part;
70
+ * the signature's own metadata does not, as the module comment states.
71
+ *
72
+ * Verification proves integrity of the covered values against the digest the blob carries: the
73
+ * digest is recomputed from the record's own declarations and compared. It proves nothing about
74
+ * who signed, and grants no permission. Issuer authenticity, key custody, signer role and
75
+ * revocation are the host's, with its own trust material (`[ACCESS-7.1.5]`).
76
+ */
77
+ export declare function verifySignature(catalogue: SchemaCatalogue, input: EvaluationInput, signatureFieldId: string, signature: StoredSignature, options?: SignatureVerificationOptions): SignatureVerification;
78
+ //# sourceMappingURL=verify-signature.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-signature.d.ts","sourceRoot":"","sources":["../../src/eval/verify-signature.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE9E,OAAO,KAAK,EAAiB,UAAU,EAAuB,MAAM,mBAAmB,CAAC;AACxF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAW1D;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;GAIG;AACH,wFAAwF;AACxF,MAAM,WAAW,4BAA4B;IAC3C,+EAA+E;IAC/E,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC;CAC1F;AAED,MAAM,MAAM,qBAAqB,GAC7B;IAAE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,GACxD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAC1B,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC,GACD;IACE,qEAAqE;IACrE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IAC5C,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3C,GACD;IAAE,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAA;CAAE,CAAC;AAkFvE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,eAAe,EAC1B,KAAK,EAAE,eAAe,EACtB,gBAAgB,EAAE,MAAM,EACxB,SAAS,EAAE,eAAe,EAC1B,OAAO,GAAE,4BAAiC,GACzC,qBAAqB,CA2FvB"}
@@ -0,0 +1,185 @@
1
+ import { digestsMatch, signatureBinding } from '../canonical/signature.js';
2
+ import { diagnosticDoc } from '../expr/diagnostics.js';
3
+ import { AxiomError } from '../model/errors.js';
4
+ import { SHA256_HEX_PATTERN, isUndetermined } from '../model/types.js';
5
+ import { isSafeInteger } from '../model/values.js';
6
+ import { toFieldRef } from '../model/wire.js';
7
+ import { fieldKey, stillRedacted } from './access/projection.js';
8
+ import { createAccessWindow } from './access/window.js';
9
+ import { indexContextRoots, indexFields, NO_VISIBLE_RULES, RecordReader } from './reader.js';
10
+ import { matchesCoverage } from './signature-coverage.js';
11
+ /**
12
+ * One refusal's diagnostic, carrying the occurrence it refused at.
13
+ *
14
+ * `ENGINE_ERROR` is the one code every way a stored signature can fail to parse or resolve
15
+ * reports, so `params` is what distinguishes them: a host that did not retain a published version,
16
+ * a blob whose members do not parse, and an artifact that stopped declaring the signature field are
17
+ * three different failures with three different owners. The code's own catalogue entry promises the
18
+ * report names the place the engine refused, and the key spells it the way the evaluator's refusals
19
+ * already do.
20
+ */
21
+ function diagnostic(code, fieldRef, params) {
22
+ const doc = diagnosticDoc(code);
23
+ return {
24
+ code,
25
+ severity: doc.severity,
26
+ messageKey: doc.messageKey,
27
+ ...(params === undefined ? {} : { params }),
28
+ ...(fieldRef === undefined
29
+ ? {}
30
+ : {
31
+ fieldId: fieldRef.fieldId,
32
+ ...(fieldRef.rowKey === undefined ? {} : { rowKey: fieldRef.rowKey }),
33
+ }),
34
+ };
35
+ }
36
+ /**
37
+ * Reads the stored signature through its contract. A signature that does not parse is not a
38
+ * valid one, so it fails closed here rather than reaching the comparison with a value no
39
+ * `signature_ref` shape admits. Each refusal names the member that failed to parse.
40
+ */
41
+ function readSignature(signature) {
42
+ if (!SHA256_HEX_PATTERN.test(signature.dataHash)) {
43
+ return diagnostic('ENGINE_ERROR', undefined, { path: '$.signature.dataHash' });
44
+ }
45
+ if (!isSafeInteger(signature.schemaVersion) || signature.schemaVersion < 1) {
46
+ return diagnostic('ENGINE_ERROR', undefined, { path: '$.signature.schemaVersion' });
47
+ }
48
+ if (!Array.isArray(signature.coveredTargets) || signature.coveredTargets.length === 0) {
49
+ return diagnostic('ENGINE_ERROR', undefined, { path: '$.signature.coveredTargets' });
50
+ }
51
+ const coveredTargets = [];
52
+ try {
53
+ signature.coveredTargets.forEach((target, index) => {
54
+ coveredTargets.push(toFieldRef(target, `$.signature.coveredTargets[${String(index)}]`));
55
+ });
56
+ }
57
+ catch (error) {
58
+ if (!(error instanceof AxiomError))
59
+ throw error;
60
+ return diagnostic('ENGINE_ERROR', undefined, error.path === '' ? undefined : { path: error.path });
61
+ }
62
+ return {
63
+ coveredTargets,
64
+ schemaVersion: signature.schemaVersion,
65
+ dataHash: signature.dataHash,
66
+ };
67
+ }
68
+ /**
69
+ * The declaration a `fieldId` names. `fieldId`s are unique across nesting, so
70
+ * one identifier names one declaration; the reader's index is keyed by path, and its values
71
+ * are every declaration in the document.
72
+ */
73
+ function declarationOf(fieldsByPath, fieldId) {
74
+ for (const field of fieldsByPath.values()) {
75
+ if (field.fieldId === fieldId)
76
+ return field;
77
+ }
78
+ return undefined;
79
+ }
80
+ /**
81
+ * Whether a stored signature still binds the values the record holds, verified against the
82
+ * `signature_capture` field at the version the signature names.
83
+ *
84
+ * `catalogue` is the host's retained published artifacts. The signature's recorded version is
85
+ * resolved through it before anything is read, so a stored signature is compared against the
86
+ * values its own version admitted. Reads go through the record reader of that version, so a
87
+ * covered target this device may not read is `unverifiable` rather than compared against a
88
+ * guess. An assigned row also needs `options.assignedRowKeys` from its session manifest; without
89
+ * it the target is unverifiable, never matched by position. `input.values` is the current value
90
+ * tree — the stored values, plus any computed value the host has applied from a previous report —
91
+ * so a computed covered target is verified once the host made it current.
92
+ *
93
+ * Only the covered values, their declaration order and the recorded schema version take part;
94
+ * the signature's own metadata does not, as the module comment states.
95
+ *
96
+ * Verification proves integrity of the covered values against the digest the blob carries: the
97
+ * digest is recomputed from the record's own declarations and compared. It proves nothing about
98
+ * who signed, and grants no permission. Issuer authenticity, key custody, signer role and
99
+ * revocation are the host's, with its own trust material (`[ACCESS-7.1.5]`).
100
+ */
101
+ export function verifySignature(catalogue, input, signatureFieldId, signature, options = {}) {
102
+ const read = readSignature(signature);
103
+ if ('code' in read)
104
+ return { kind: 'unverifiable', diagnostic: read };
105
+ // The binding hashes the schema version, so the declarations that locate the covered values
106
+ // are the recorded version's, not whatever artifact the host evaluates today.
107
+ const compiled = catalogue.get(read.schemaVersion);
108
+ if (compiled === undefined) {
109
+ // The version is the occurrence: a host that did not retain a published artifact
110
+ // (`[EVOL-1.1.3]`) has a different failure, and a different fix, than a corrupt blob.
111
+ return {
112
+ kind: 'unverifiable',
113
+ diagnostic: diagnostic('ENGINE_ERROR', undefined, { schemaVersion: read.schemaVersion }),
114
+ };
115
+ }
116
+ const fieldsByPath = indexFields(compiled.fields);
117
+ const declaration = declarationOf(fieldsByPath, signatureFieldId);
118
+ if (declaration === undefined || declaration.primitive !== 'signature_ref') {
119
+ return {
120
+ kind: 'unverifiable',
121
+ diagnostic: diagnostic('ENGINE_ERROR', { fieldId: signatureFieldId }),
122
+ };
123
+ }
124
+ // A coverage declaration is what the artifact says the signature binds, so a stored
125
+ // signature that binds anything else is not the signature this record declares.
126
+ if (declaration.covers !== undefined &&
127
+ !matchesCoverage(declaration.covers, read.coveredTargets)) {
128
+ return {
129
+ kind: 'uncovered',
130
+ declaredTargets: declaration.covers,
131
+ // `fieldKey` is the only reference serialiser: the integer row `1` and the text row `"1"`
132
+ // are two rows, and a refusal that spelled both `f_qty@1` could not name the one it
133
+ // refused, nor be compared against a reference the host keyed the same way.
134
+ actualTargets: read.coveredTargets.map((target) => fieldKey(target)),
135
+ };
136
+ }
137
+ const denied = [];
138
+ // Verification reads the same session value evaluation and projection do: a covered reference
139
+ // this session wrote is no longer redacted, while every sibling and container stays withheld.
140
+ const resolvedInput = {
141
+ ...input,
142
+ ...(input.redacted === undefined
143
+ ? {}
144
+ : { redacted: stillRedacted(compiled.fields, input.redacted, input.sessionWrites) }),
145
+ };
146
+ const reader = new RecordReader({
147
+ fieldsByPath,
148
+ contextRoots: indexContextRoots(compiled.context?.roots),
149
+ ...(options.assignedRowKeys === undefined
150
+ ? {}
151
+ : { assignedRowKeys: options.assignedRowKeys }),
152
+ }, resolvedInput, createAccessWindow(compiled.fields, resolvedInput, {}), new Set(), (code, fieldId) => {
153
+ denied.push(diagnostic(code, { fieldId }));
154
+ },
155
+ // Verification answers what the covered targets hold, never whether a rule hides them.
156
+ NO_VISIBLE_RULES);
157
+ const covered = [];
158
+ for (const target of read.coveredTargets) {
159
+ let value;
160
+ try {
161
+ value = reader.readCoveredTarget(target);
162
+ }
163
+ catch (error) {
164
+ if (!(error instanceof AxiomError))
165
+ throw error;
166
+ return { kind: 'unverifiable', diagnostic: diagnostic(error.code, target) };
167
+ }
168
+ if (value.kind === 'absent' || isUndetermined(value.value)) {
169
+ return {
170
+ kind: 'unverifiable',
171
+ diagnostic: denied[0] ?? diagnostic('ENGINE_ERROR', target),
172
+ };
173
+ }
174
+ covered.push({ target, value: value.value });
175
+ }
176
+ const digest = signatureBinding(covered, read.schemaVersion);
177
+ return digestsMatch(read.dataHash, digest)
178
+ ? { kind: 'verified', dataHash: digest }
179
+ : {
180
+ kind: 'tampered',
181
+ expectedDataHash: read.dataHash,
182
+ actualDataHash: digest,
183
+ };
184
+ }
185
+ //# sourceMappingURL=verify-signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-signature.js","sourceRoot":"","sources":["../../src/eval/verify-signature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAIhD,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAuD1D;;;;;;;;;GASG;AACH,SAAS,UAAU,CACjB,IAAwB,EACxB,QAAmB,EACnB,MAA4C;IAE5C,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO;QACL,IAAI;QACJ,QAAQ,EAAE,GAAG,CAAC,QAAQ;QACtB,UAAU,EAAE,GAAG,CAAC,UAAU;QAC1B,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC;QAC3C,GAAG,CAAC,QAAQ,KAAK,SAAS;YACxB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC;gBACE,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,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,QAAQ,EAAE,MAAM,CAAC;QACxC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE;QACxC,CAAC,CAAC;YACE,IAAI,EAAE,UAAU;YAChB,gBAAgB,EAAE,IAAI,CAAC,QAAQ;YAC/B,cAAc,EAAE,MAAM;SACvB,CAAC;AACR,CAAC","sourcesContent":["import { digestsMatch, signatureBinding } from '../canonical/signature.js';\nimport { diagnosticDoc } from '../expr/diagnostics.js';\nimport type { SchemaCatalogue, StoredSignature } from '../model/evolution.js';\nimport { AxiomError } from '../model/errors.js';\nimport type { CompiledField, Diagnostic, FieldRef, WireValue } from '../model/types.js';\nimport type { EvaluationInput } from '../model/access.js';\nimport type { CompiledSchema } from '../model/schema.js';\nimport { SHA256_HEX_PATTERN, isUndetermined } from '../model/types.js';\nimport { isSafeInteger } from '../model/values.js';\nimport { toFieldRef } from '../model/wire.js';\nimport { fieldKey, stillRedacted } from './access/projection.js';\nimport { createAccessWindow } from './access/window.js';\nimport type { Evaluated } from './expression.js';\nimport { indexContextRoots, indexFields, NO_VISIBLE_RULES, RecordReader } from './reader.js';\nimport { matchesCoverage } from './signature-coverage.js';\n\n/**\n * Signature verification, `spec/semantics/canonical-v1.md`.\n *\n * A stored `signature_ref` carries the binding digest it was signed over. Verifying is\n * recomputing that digest from the values the record holds *now* and comparing the two; a\n * covered value that changed makes the recomputation differ, which invalidates the\n * signature. The same digest is what `digest(coveredTargets, schemaVersion)` returns, so a\n * rule that recomputes a signature's binding and this function agree on every record.\n * The comparison reads every digit so its duration says nothing about how much of a forged\n * digest was right.\n *\n * The digest binds the covered values, their target list and the schema version — nothing\n * else. `status`, `signerRole`, `signedAt`, `id` and `mediaRefId` are the blob's and the\n * record's claims about the signer, not bytes the signature covers, so a `verified` outcome\n * answers \"do the covered values still match this digest\" and never \"may this signature be\n * relied on\". A host that requires a live, unrevoked or role-appropriate signature applies\n * that policy to those members itself; reading them here would make one answer stand for two\n * different questions.\n *\n * Verification resolves the signature's *recorded* version through the catalogue and reads the\n * values through that version's declarations (`[CANON-4.1.3]`). The bytes a seven-year-old\n * signature signed are the bytes that version admitted, so upcasting the record first and\n * verifying the upcast values would report a faithful signature as tampered. A version the\n * catalogue does not retain is `unverifiable`, never `tampered`: the verifier cannot tell\n * whether the values changed when it cannot read the declarations they were recorded under.\n */\n\n/**\n * A tagged outcome rather than a boolean: a signature that is `unverifiable` or `uncovered`\n * is not a valid signature, and a caller that only tested truthiness would\n * treat a withheld value or a partial coverage as a pass.\n */\n/** The row identity a verification payload cannot derive from assigned rows' values. */\nexport interface SignatureVerificationOptions {\n /** The session's committed manifest for one assigned array, in array order. */\n readonly assignedRowKeys?: (fieldId: string) => readonly (string | number)[] | undefined;\n}\n\nexport type SignatureVerification =\n | { readonly kind: 'verified'; readonly dataHash: string }\n | {\n readonly kind: 'tampered';\n readonly expectedDataHash: string;\n readonly actualDataHash: string;\n }\n | {\n /** The stored targets are not the coverage the artifact declares. */\n readonly kind: 'uncovered';\n readonly declaredTargets: readonly string[];\n readonly actualTargets: readonly string[];\n }\n | { readonly kind: 'unverifiable'; readonly diagnostic: Diagnostic };\n\n/**\n * One refusal's diagnostic, carrying the occurrence it refused at.\n *\n * `ENGINE_ERROR` is the one code every way a stored signature can fail to parse or resolve\n * reports, so `params` is what distinguishes them: a host that did not retain a published version,\n * a blob whose members do not parse, and an artifact that stopped declaring the signature field are\n * three different failures with three different owners. The code's own catalogue entry promises the\n * report names the place the engine refused, and the key spells it the way the evaluator's refusals\n * already do.\n */\nfunction diagnostic(\n code: Diagnostic['code'],\n fieldRef?: FieldRef,\n params?: Readonly<Record<string, WireValue>>,\n): Diagnostic {\n const doc = diagnosticDoc(code);\n return {\n code,\n severity: doc.severity,\n messageKey: doc.messageKey,\n ...(params === undefined ? {} : { params }),\n ...(fieldRef === undefined\n ? {}\n : {\n fieldId: fieldRef.fieldId,\n ...(fieldRef.rowKey === undefined ? {} : { rowKey: fieldRef.rowKey }),\n }),\n };\n}\n\n/**\n * Reads the stored signature through its contract. A signature that does not parse is not a\n * valid one, so it fails closed here rather than reaching the comparison with a value no\n * `signature_ref` shape admits. Each refusal names the member that failed to parse.\n */\nfunction readSignature(signature: StoredSignature): StoredSignature | Diagnostic {\n if (!SHA256_HEX_PATTERN.test(signature.dataHash)) {\n return diagnostic('ENGINE_ERROR', undefined, { path: '$.signature.dataHash' });\n }\n if (!isSafeInteger(signature.schemaVersion) || signature.schemaVersion < 1) {\n return diagnostic('ENGINE_ERROR', undefined, { path: '$.signature.schemaVersion' });\n }\n if (!Array.isArray(signature.coveredTargets) || signature.coveredTargets.length === 0) {\n return diagnostic('ENGINE_ERROR', undefined, { path: '$.signature.coveredTargets' });\n }\n const coveredTargets: FieldRef[] = [];\n try {\n signature.coveredTargets.forEach((target, index) => {\n coveredTargets.push(toFieldRef(target, `$.signature.coveredTargets[${String(index)}]`));\n });\n } catch (error) {\n if (!(error instanceof AxiomError)) throw error;\n return diagnostic(\n 'ENGINE_ERROR',\n undefined,\n error.path === '' ? undefined : { path: error.path },\n );\n }\n return {\n coveredTargets,\n schemaVersion: signature.schemaVersion,\n dataHash: signature.dataHash,\n };\n}\n\n/**\n * The declaration a `fieldId` names. `fieldId`s are unique across nesting, so\n * one identifier names one declaration; the reader's index is keyed by path, and its values\n * are every declaration in the document.\n */\nfunction declarationOf(\n fieldsByPath: ReadonlyMap<string, CompiledField>,\n fieldId: string,\n): CompiledField | undefined {\n for (const field of fieldsByPath.values()) {\n if (field.fieldId === fieldId) return field;\n }\n return undefined;\n}\n\n/**\n * Whether a stored signature still binds the values the record holds, verified against the\n * `signature_capture` field at the version the signature names.\n *\n * `catalogue` is the host's retained published artifacts. The signature's recorded version is\n * resolved through it before anything is read, so a stored signature is compared against the\n * values its own version admitted. Reads go through the record reader of that version, so a\n * covered target this device may not read is `unverifiable` rather than compared against a\n * guess. An assigned row also needs `options.assignedRowKeys` from its session manifest; without\n * it the target is unverifiable, never matched by position. `input.values` is the current value\n * tree — the stored values, plus any computed value the host has applied from a previous report —\n * so a computed covered target is verified once the host made it current.\n *\n * Only the covered values, their declaration order and the recorded schema version take part;\n * the signature's own metadata does not, as the module comment states.\n *\n * Verification proves integrity of the covered values against the digest the blob carries: the\n * digest is recomputed from the record's own declarations and compared. It proves nothing about\n * who signed, and grants no permission. Issuer authenticity, key custody, signer role and\n * revocation are the host's, with its own trust material (`[ACCESS-7.1.5]`).\n */\nexport function verifySignature(\n catalogue: SchemaCatalogue,\n input: EvaluationInput,\n signatureFieldId: string,\n signature: StoredSignature,\n options: SignatureVerificationOptions = {},\n): SignatureVerification {\n const read = readSignature(signature);\n if ('code' in read) return { kind: 'unverifiable', diagnostic: read };\n // The binding hashes the schema version, so the declarations that locate the covered values\n // are the recorded version's, not whatever artifact the host evaluates today.\n const compiled: CompiledSchema | undefined = catalogue.get(read.schemaVersion);\n if (compiled === undefined) {\n // The version is the occurrence: a host that did not retain a published artifact\n // (`[EVOL-1.1.3]`) has a different failure, and a different fix, than a corrupt blob.\n return {\n kind: 'unverifiable',\n diagnostic: diagnostic('ENGINE_ERROR', undefined, { schemaVersion: read.schemaVersion }),\n };\n }\n\n const fieldsByPath = indexFields(compiled.fields);\n const declaration = declarationOf(fieldsByPath, signatureFieldId);\n if (declaration === undefined || declaration.primitive !== 'signature_ref') {\n return {\n kind: 'unverifiable',\n diagnostic: diagnostic('ENGINE_ERROR', { fieldId: signatureFieldId }),\n };\n }\n // A coverage declaration is what the artifact says the signature binds, so a stored\n // signature that binds anything else is not the signature this record declares.\n if (\n declaration.covers !== undefined &&\n !matchesCoverage(declaration.covers, read.coveredTargets)\n ) {\n return {\n kind: 'uncovered',\n declaredTargets: declaration.covers,\n // `fieldKey` is the only reference serialiser: the integer row `1` and the text row `\"1\"`\n // are two rows, and a refusal that spelled both `f_qty@1` could not name the one it\n // refused, nor be compared against a reference the host keyed the same way.\n actualTargets: read.coveredTargets.map((target) => fieldKey(target)),\n };\n }\n\n const denied: Diagnostic[] = [];\n // Verification reads the same session value evaluation and projection do: a covered reference\n // this session wrote is no longer redacted, while every sibling and container stays withheld.\n const resolvedInput: EvaluationInput = {\n ...input,\n ...(input.redacted === undefined\n ? {}\n : { redacted: stillRedacted(compiled.fields, input.redacted, input.sessionWrites) }),\n };\n const reader = new RecordReader(\n {\n fieldsByPath,\n contextRoots: indexContextRoots(compiled.context?.roots),\n ...(options.assignedRowKeys === undefined\n ? {}\n : { assignedRowKeys: options.assignedRowKeys }),\n },\n resolvedInput,\n createAccessWindow(compiled.fields, resolvedInput, {}),\n new Set(),\n (code, fieldId) => {\n denied.push(diagnostic(code, { fieldId }));\n },\n // Verification answers what the covered targets hold, never whether a rule hides them.\n NO_VISIBLE_RULES,\n );\n const covered: { readonly target: FieldRef; readonly value: WireValue }[] = [];\n for (const target of read.coveredTargets) {\n let value: Evaluated;\n try {\n value = reader.readCoveredTarget(target);\n } catch (error) {\n if (!(error instanceof AxiomError)) throw error;\n return { kind: 'unverifiable', diagnostic: diagnostic(error.code, target) };\n }\n if (value.kind === 'absent' || isUndetermined(value.value)) {\n return {\n kind: 'unverifiable',\n diagnostic: denied[0] ?? diagnostic('ENGINE_ERROR', target),\n };\n }\n covered.push({ target, value: value.value });\n }\n\n const digest = signatureBinding(covered, read.schemaVersion);\n return digestsMatch(read.dataHash, digest)\n ? { kind: 'verified', dataHash: digest }\n : {\n kind: 'tampered',\n expectedDataHash: read.dataHash,\n actualDataHash: digest,\n };\n}\n"]}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The Expr version seam: which evaluator a stored artifact is answered by.
3
+ *
4
+ * `EXPR-1.1.4` requires a v1 evaluator while a v1 artifact remains in any retention window. That
5
+ * obligation is only a guarantee if the entry *reads* the version and chooses by it, rather than
6
+ * reading the members it recognises and assuming v1. This module holds that choice: one table
7
+ * keyed by the `exprVersion` an artifact states, a refusal for a version no arm implements, and
8
+ * nothing else. It is pure and takes the table as an argument so the seam is provable with a
9
+ * second arm in a test — a v2 arm added to a table must not be reachable from a v1 artifact.
10
+ *
11
+ * The table is keyed, never "the latest": `{ 1: v1, 2: v2 }` answers a version-1 artifact with
12
+ * `v1`, so landing a v2 evaluator cannot silently change what a retained v1 artifact means.
13
+ */
14
+ import type { EvaluationEnv, EvaluationInput } from '../model/access.js';
15
+ import type { CompiledSchema } from '../model/schema.js';
16
+ import type { EvaluationReport } from '../model/types.js';
17
+ import type { FormStateOptions } from './state/options.js';
18
+ /** One language version's evaluator: the whole v1 path behind the seam. */
19
+ export type ArtifactEvaluator = (compiled: CompiledSchema, input: EvaluationInput, env: EvaluationEnv, options?: FormStateOptions) => EvaluationReport;
20
+ /** The evaluators this build implements, keyed by the `expressionVersion` they answer. */
21
+ export type EvaluatorTable = Readonly<Record<number, ArtifactEvaluator>>;
22
+ /**
23
+ * Reads the version member an artifact states, without trusting the artifact's type.
24
+ *
25
+ * A host that rehydrated storage may hand this entry anything; the dispatch must refuse a value
26
+ * that is not an object with the same message it refuses an unknown version with, rather than
27
+ * reading a member off a primitive.
28
+ */
29
+ export declare function readArtifactVersion(compiled: unknown): unknown;
30
+ /**
31
+ * The evaluator for one stated version, or the refusal naming the version and this build's.
32
+ *
33
+ * A version the table does not key is refused here, before any rule runs. That is the security
34
+ * shape the receipt exists for: a v2 `validate` expression whose meaning changed must not be
35
+ * decided by v1 and reported as a verdict.
36
+ */
37
+ export declare function evaluatorFor(table: EvaluatorTable, version: unknown): ArtifactEvaluator;
38
+ //# sourceMappingURL=version-dispatch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-dispatch.d.ts","sourceRoot":"","sources":["../../src/eval/version-dispatch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,2EAA2E;AAC3E,MAAM,MAAM,iBAAiB,GAAG,CAC9B,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,aAAa,EAClB,OAAO,CAAC,EAAE,gBAAgB,KACvB,gBAAgB,CAAC;AAEtB,0FAA0F;AAC1F,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;AAoCzE;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAK9D;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,iBAAiB,CAQvF"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * How a refusal spells the version value it read.
3
+ *
4
+ * The receipt's spelling rules apply here for the same reason: `JSON.stringify` on a string keeps
5
+ * `"2"` distinct from `2`, and every other non-number is named by class rather than printed, so a
6
+ * refusal cannot echo a structure it read from untrusted storage.
7
+ */
8
+ function spellVersion(value) {
9
+ switch (typeof value) {
10
+ case 'string':
11
+ return JSON.stringify(value);
12
+ case 'number':
13
+ case 'boolean':
14
+ case 'bigint':
15
+ return String(value);
16
+ case 'function':
17
+ case 'symbol':
18
+ return `a ${typeof value}`;
19
+ case 'object':
20
+ return value === null ? 'null' : Array.isArray(value) ? 'a list' : 'an object';
21
+ case 'undefined':
22
+ return 'no exprVersion';
23
+ }
24
+ }
25
+ /** The versions a table answers, in ascending order, for a refusal that names them. */
26
+ function implementedVersions(table) {
27
+ return Object.keys(table)
28
+ .map((key) => Number(key))
29
+ .filter((version) => Number.isSafeInteger(version) && version >= 0)
30
+ .sort((left, right) => left - right)
31
+ .join(', ');
32
+ }
33
+ /**
34
+ * Reads the version member an artifact states, without trusting the artifact's type.
35
+ *
36
+ * A host that rehydrated storage may hand this entry anything; the dispatch must refuse a value
37
+ * that is not an object with the same message it refuses an unknown version with, rather than
38
+ * reading a member off a primitive.
39
+ */
40
+ export function readArtifactVersion(compiled) {
41
+ if (typeof compiled !== 'object' || compiled === null || Array.isArray(compiled)) {
42
+ return undefined;
43
+ }
44
+ return Reflect.get(compiled, 'exprVersion');
45
+ }
46
+ /**
47
+ * The evaluator for one stated version, or the refusal naming the version and this build's.
48
+ *
49
+ * A version the table does not key is refused here, before any rule runs. That is the security
50
+ * shape the receipt exists for: a v2 `validate` expression whose meaning changed must not be
51
+ * decided by v1 and reported as a verdict.
52
+ */
53
+ export function evaluatorFor(table, version) {
54
+ if (typeof version === 'number' && Number.isSafeInteger(version)) {
55
+ const evaluator = table[version];
56
+ if (evaluator !== undefined)
57
+ return evaluator;
58
+ }
59
+ throw new TypeError(`Axiom: the artifact states exprVersion ${spellVersion(version)}; this runtime implements ${implementedVersions(table)}`);
60
+ }
61
+ //# sourceMappingURL=version-dispatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-dispatch.js","sourceRoot":"","sources":["../../src/eval/version-dispatch.ts"],"names":[],"mappings":"AA6BA;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,KAAc;IAClC,QAAQ,OAAO,KAAK,EAAE,CAAC;QACrB,KAAK,QAAQ;YACX,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC/B,KAAK,QAAQ,CAAC;QACd,KAAK,SAAS,CAAC;QACf,KAAK,QAAQ;YACX,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;QACvB,KAAK,UAAU,CAAC;QAChB,KAAK,QAAQ;YACX,OAAO,KAAK,OAAO,KAAK,EAAE,CAAC;QAC7B,KAAK,QAAQ;YACX,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,WAAW,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\n *\n * `EXPR-1.1.4` requires a v1 evaluator while a v1 artifact remains in any retention window. That\n * obligation is only a guarantee if the entry *reads* the version and chooses by it, rather than\n * reading the members it recognises and assuming v1. This module holds that choice: one table\n * keyed by the `exprVersion` an artifact states, a refusal for a version no arm implements, and\n * nothing else. It is pure and takes the table as an argument so the seam is provable with a\n * second arm in a test — a v2 arm added to a table must not be reachable from a v1 artifact.\n *\n * The table is keyed, never \"the latest\": `{ 1: v1, 2: v2 }` answers a version-1 artifact with\n * `v1`, so landing a v2 evaluator cannot silently change what a retained v1 artifact means.\n */\nimport type { EvaluationEnv, EvaluationInput } from '../model/access.js';\nimport type { CompiledSchema } from '../model/schema.js';\nimport type { EvaluationReport } from '../model/types.js';\nimport type { FormStateOptions } from './state/options.js';\n\n/** One language version's evaluator: the whole v1 path behind the seam. */\nexport type ArtifactEvaluator = (\n compiled: CompiledSchema,\n input: EvaluationInput,\n env: EvaluationEnv,\n options?: FormStateOptions,\n) => EvaluationReport;\n\n/** The evaluators this build implements, keyed by the `expressionVersion` they answer. */\nexport type EvaluatorTable = Readonly<Record<number, ArtifactEvaluator>>;\n\n/**\n * How a refusal spells the version value it read.\n *\n * The receipt's spelling rules apply here for the same reason: `JSON.stringify` on a string keeps\n * `\"2\"` distinct from `2`, and every other non-number is named by class rather than printed, so a\n * refusal cannot echo a structure it read from untrusted storage.\n */\nfunction spellVersion(value: unknown): string {\n switch (typeof value) {\n case 'string':\n return JSON.stringify(value);\n case 'number':\n case 'boolean':\n case 'bigint':\n return String(value);\n case 'function':\n case 'symbol':\n return `a ${typeof value}`;\n case 'object':\n return value === null ? 'null' : Array.isArray(value) ? 'a list' : 'an object';\n case 'undefined':\n return 'no exprVersion';\n }\n}\n\n/** The versions a table answers, in ascending order, for a refusal that names them. */\nfunction implementedVersions(table: EvaluatorTable): string {\n return Object.keys(table)\n .map((key) => Number(key))\n .filter((version) => Number.isSafeInteger(version) && version >= 0)\n .sort((left, right) => left - right)\n .join(', ');\n}\n\n/**\n * Reads the version member an artifact states, without trusting the artifact's type.\n *\n * A host that rehydrated storage may hand this entry anything; the dispatch must refuse a value\n * that is not an object with the same message it refuses an unknown version with, rather than\n * reading a member off a primitive.\n */\nexport function readArtifactVersion(compiled: unknown): unknown {\n if (typeof compiled !== 'object' || compiled === null || Array.isArray(compiled)) {\n return undefined;\n }\n return Reflect.get(compiled, 'exprVersion');\n}\n\n/**\n * The evaluator for one stated version, or the refusal naming the version and this build's.\n *\n * A version the table does not key is refused here, before any rule runs. That is the security\n * shape the receipt exists for: a v2 `validate` expression whose meaning changed must not be\n * decided by v1 and reported as a verdict.\n */\nexport function evaluatorFor(table: EvaluatorTable, version: unknown): ArtifactEvaluator {\n if (typeof version === 'number' && Number.isSafeInteger(version)) {\n const evaluator = table[version];\n if (evaluator !== undefined) return evaluator;\n }\n throw new TypeError(\n `Axiom: the artifact states exprVersion ${spellVersion(version)}; this runtime implements ${implementedVersions(table)}`,\n );\n}\n"]}