@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,28 @@
1
+ import type { CompiledSchema } from '../../model/schema.js';
2
+ import type { SubmissionRefusal } from './refusals.js';
3
+ /**
4
+ * The artifact's `datasets` declaration is the allow-list for every table an expression reads.
5
+ *
6
+ * `pinLookup` answers a *pinned* table at the version and digest the artifact states, but a
7
+ * `tableId` the artifact never names passes through to the host's `LookupPort` unresolved: the
8
+ * rule reads rows it was never admitted with, and the report records the provenance only after
9
+ * the read. A rehydrated artifact has no compiler in front of it (`readArtifact` checks the root
10
+ * shape, not the contents), so the door is the last place that can refuse the name.
11
+ *
12
+ * The check walks the compiled expressions rather than the store: a table name is a literal path
13
+ * in a dataset built-in, so the artifact states every table it can reach and nothing at run time
14
+ * is dynamic. The walk is iterative so a deeply nested hand-built tree costs heap, not stack.
15
+ */
16
+ /** One table an expression names without the artifact declaring it. */
17
+ export interface UndeclaredDataset {
18
+ readonly tableId: string;
19
+ /** The rule or declaration whose expression names the table. */
20
+ readonly expression: string;
21
+ /** The path inside the artifact the expression lives at. */
22
+ readonly path: string;
23
+ }
24
+ /** The first table an artifact reads without declaring, in rule order, or `undefined`. */
25
+ export declare function undeclaredDataset(compiled: CompiledSchema): UndeclaredDataset | undefined;
26
+ /** The one refusal the door states for an undeclared table. */
27
+ export declare function datasetRefusal(use: UndeclaredDataset): SubmissionRefusal;
28
+ //# sourceMappingURL=datasets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datasets.d.ts","sourceRoot":"","sources":["../../../src/eval/submission/datasets.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;;;;;GAYG;AAEH,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,0FAA0F;AAC1F,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,iBAAiB,GAAG,SAAS,CAwBzF;AAOD,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,GAAG,EAAE,iBAAiB,GAAG,iBAAiB,CAOxE"}
@@ -0,0 +1,109 @@
1
+ import { DATASET_BUILTINS } from '../../model/types.js';
2
+ import { declaredFieldExpressions, ruleExpressionSlots } from '../../graph/read-walk.js';
3
+ /** The first table an artifact reads without declaring, in rule order, or `undefined`. */
4
+ export function undeclaredDataset(compiled) {
5
+ const declared = declaredTables(compiled);
6
+ for (const rule of compiled.rules ?? []) {
7
+ // The one slot walk the rest of the engine uses: a gate item's expression and a screen
8
+ // reason's condition are reads this rule performs, so a table they name is as undeclared as
9
+ // one in `rule.expr`. A hand-written list of slots is how those two escaped this check.
10
+ for (const slot of ruleExpressionSlots(rule)) {
11
+ const tableId = firstUndeclaredTable(slot.node, declared);
12
+ if (tableId !== undefined) {
13
+ return { tableId, expression: rule.ruleId, path: slot.path };
14
+ }
15
+ }
16
+ }
17
+ // A field's own expressions are reads the artifact performs too: an array's `rowsFrom` count, a
18
+ // declared option's availability condition and reason arguments, and the expressions its
19
+ // alternatives carry. The same walk enumerates them, so a table one of them names is as
20
+ // undeclared as one a rule names.
21
+ for (const slot of declaredFieldExpressions(compiled.fields)) {
22
+ const tableId = firstUndeclaredTable(slot.node, declared);
23
+ if (tableId !== undefined) {
24
+ return { tableId, expression: slot.fieldId, path: slot.path };
25
+ }
26
+ }
27
+ return undefined;
28
+ }
29
+ /** Pushes every child without a spread: an argument list has a length the engine does not own. */
30
+ function pushAll(stack, nodes) {
31
+ for (const nod of nodes)
32
+ stack.push(nod);
33
+ }
34
+ /** The one refusal the door states for an undeclared table. */
35
+ export function datasetRefusal(use) {
36
+ return {
37
+ code: 'TABLE_NOT_DECLARED',
38
+ path: use.path,
39
+ detail: `expression ${use.expression} reads table ${use.tableId}, which the artifact does not declare in datasets`,
40
+ cause: { kind: 'dataset', tableId: use.tableId, expression: use.expression },
41
+ };
42
+ }
43
+ /** The table ids the artifact pins, read defensively: `readArtifact` does not validate a pin. */
44
+ function declaredTables(compiled) {
45
+ const declared = new Set();
46
+ for (const pin of compiled.datasets ?? []) {
47
+ const tableId = pin.tableId;
48
+ if (typeof tableId === 'string' && tableId !== '')
49
+ declared.add(tableId);
50
+ }
51
+ return declared;
52
+ }
53
+ /**
54
+ * The first table an expression reads without a declaration, or `undefined`.
55
+ *
56
+ * A dataset built-in names its table as a literal path in its first operand, and the table name
57
+ * is not a record read: the walk starts at the second operand so a table called `f_code` is not
58
+ * mistaken for a field, and continues through every other child.
59
+ */
60
+ function firstUndeclaredTable(root, declared) {
61
+ const stack = [root];
62
+ while (stack.length > 0) {
63
+ const node = stack.pop();
64
+ if (node === undefined)
65
+ break;
66
+ switch (node.kind) {
67
+ case 'literal':
68
+ break;
69
+ case 'path':
70
+ break;
71
+ case 'list':
72
+ pushAll(stack, node.items);
73
+ break;
74
+ case 'and':
75
+ case 'or':
76
+ case 'coalesce':
77
+ pushAll(stack, node.args);
78
+ break;
79
+ case 'not':
80
+ stack.push(node.args[0]);
81
+ break;
82
+ case 'compare':
83
+ case 'if':
84
+ pushAll(stack, node.args);
85
+ break;
86
+ case 'call': {
87
+ const table = node.args[0];
88
+ if (!DATASET_BUILTINS.has(node.op)) {
89
+ pushAll(stack, node.args);
90
+ break;
91
+ }
92
+ if (table !== undefined && table.kind === 'path' && !declared.has(table.path)) {
93
+ return table.path;
94
+ }
95
+ pushAll(stack, node.args.slice(1));
96
+ break;
97
+ }
98
+ case 'comprehension':
99
+ stack.push(node.source);
100
+ if (node.valueExpr !== undefined)
101
+ stack.push(node.valueExpr);
102
+ if (node.predicate !== undefined)
103
+ stack.push(node.predicate);
104
+ break;
105
+ }
106
+ }
107
+ return undefined;
108
+ }
109
+ //# sourceMappingURL=datasets.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"datasets.js","sourceRoot":"","sources":["../../../src/eval/submission/datasets.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,EAAE,wBAAwB,EAA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TINS } from '../../model/types.js';\nimport type { ExprNode } from '../../model/types.js';\nimport type { CompiledSchema } from '../../model/schema.js';\nimport { declaredFieldExpressions, ruleExpressionSlots } from '../../graph/read-walk.js';\nimport type { SubmissionRefusal } from './refusals.js';\n\n/**\n * The artifact's `datasets` declaration is the allow-list for every table an expression reads.\n *\n * `pinLookup` answers a *pinned* table at the version and digest the artifact states, but a\n * `tableId` the artifact never names passes through to the host's `LookupPort` unresolved: the\n * rule reads rows it was never admitted with, and the report records the provenance only after\n * the read. A rehydrated artifact has no compiler in front of it (`readArtifact` checks the root\n * shape, not the contents), so the door is the last place that can refuse the name.\n *\n * The check walks the compiled expressions rather than the store: a table name is a literal path\n * in a dataset built-in, so the artifact states every table it can reach and nothing at run time\n * is dynamic. The walk is iterative so a deeply nested hand-built tree costs heap, not stack.\n */\n\n/** One table an expression names without the artifact declaring it. */\nexport interface UndeclaredDataset {\n readonly tableId: string;\n /** The rule or declaration whose expression names the table. */\n readonly expression: string;\n /** The path inside the artifact the expression lives at. */\n readonly path: string;\n}\n\n/** The first table an artifact reads without declaring, in rule order, or `undefined`. */\nexport function undeclaredDataset(compiled: CompiledSchema): UndeclaredDataset | undefined {\n const declared = declaredTables(compiled);\n for (const rule of compiled.rules ?? []) {\n // The one slot walk the rest of the engine uses: a gate item's expression and a screen\n // reason's condition are reads this rule performs, so a table they name is as undeclared as\n // one in `rule.expr`. A hand-written list of slots is how those two escaped this check.\n for (const slot of ruleExpressionSlots(rule)) {\n const tableId = firstUndeclaredTable(slot.node, declared);\n if (tableId !== undefined) {\n return { tableId, expression: rule.ruleId, path: slot.path };\n }\n }\n }\n // A field's own expressions are reads the artifact performs too: an array's `rowsFrom` count, a\n // declared option's availability condition and reason arguments, and the expressions its\n // alternatives carry. The same walk enumerates them, so a table one of them names is as\n // undeclared as one a rule names.\n for (const slot of declaredFieldExpressions(compiled.fields)) {\n const tableId = firstUndeclaredTable(slot.node, declared);\n if (tableId !== undefined) {\n return { tableId, expression: slot.fieldId, path: slot.path };\n }\n }\n return undefined;\n}\n\n/** Pushes every child without a spread: an argument list has a length the engine does not own. */\nfunction pushAll(stack: ExprNode[], nodes: readonly ExprNode[]): void {\n for (const nod of nodes) stack.push(nod);\n}\n\n/** The one refusal the door states for an undeclared table. */\nexport function datasetRefusal(use: UndeclaredDataset): SubmissionRefusal {\n return {\n code: 'TABLE_NOT_DECLARED',\n path: use.path,\n detail: `expression ${use.expression} reads table ${use.tableId}, which the artifact does not declare in datasets`,\n cause: { kind: 'dataset', tableId: use.tableId, expression: use.expression },\n };\n}\n\n/** The table ids the artifact pins, read defensively: `readArtifact` does not validate a pin. */\nfunction declaredTables(compiled: CompiledSchema): ReadonlySet<string> {\n const declared = new Set<string>();\n for (const pin of compiled.datasets ?? []) {\n const tableId: unknown = pin.tableId;\n if (typeof tableId === 'string' && tableId !== '') declared.add(tableId);\n }\n return declared;\n}\n\n/**\n * The first table an expression reads without a declaration, or `undefined`.\n *\n * A dataset built-in names its table as a literal path in its first operand, and the table name\n * is not a record read: the walk starts at the second operand so a table called `f_code` is not\n * mistaken for a field, and continues through every other child.\n */\nfunction firstUndeclaredTable(root: ExprNode, declared: ReadonlySet<string>): string | undefined {\n const stack: ExprNode[] = [root];\n while (stack.length > 0) {\n const node = stack.pop();\n if (node === undefined) break;\n switch (node.kind) {\n case 'literal':\n break;\n case 'path':\n break;\n case 'list':\n pushAll(stack, node.items);\n break;\n case 'and':\n case 'or':\n case 'coalesce':\n pushAll(stack, node.args);\n break;\n case 'not':\n stack.push(node.args[0]);\n break;\n case 'compare':\n case 'if':\n pushAll(stack, node.args);\n break;\n case 'call': {\n const table = node.args[0];\n if (!DATASET_BUILTINS.has(node.op)) {\n pushAll(stack, node.args);\n break;\n }\n if (table !== undefined && table.kind === 'path' && !declared.has(table.path)) {\n return table.path;\n }\n pushAll(stack, node.args.slice(1));\n break;\n }\n case 'comprehension':\n stack.push(node.source);\n if (node.valueExpr !== undefined) stack.push(node.valueExpr);\n if (node.predicate !== undefined) stack.push(node.predicate);\n break;\n }\n }\n return undefined;\n}\n"]}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * The three answers the wire boundary cannot give, and the stance that enables them.
3
+ *
4
+ * `evaluateSubmission` closes the *shape* of an untrusted body. This module is the door's second
5
+ * half: it judges what the body claims against what the host says it trusts — write authority,
6
+ * a server-captured signature, and the artifact's declared tables — and returns a tagged refusal
7
+ * for each rather than a report.
8
+ */
9
+ export { UNSTATED_TRUST } from './authority.js';
10
+ export type { CapturedSignature, SubmissionTrust, SubmissionTrustKind, } from './authority.js';
11
+ export type { SignatureRefusal, SubmissionRefusal, SubmissionRefusalCause, SubmissionRefusalCode, } from './refusals.js';
12
+ export { datasetRefusal, undeclaredDataset } from './datasets.js';
13
+ export { auditSignatures } from './signatures.js';
14
+ export { auditWrites } from './writes.js';
15
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/eval/submission/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,gBAAgB,EAChB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The three answers the wire boundary cannot give, and the stance that enables them.
3
+ *
4
+ * `evaluateSubmission` closes the *shape* of an untrusted body. This module is the door's second
5
+ * half: it judges what the body claims against what the host says it trusts — write authority,
6
+ * a server-captured signature, and the artifact's declared tables — and returns a tagged refusal
7
+ * for each rather than a report.
8
+ */
9
+ export { UNSTATED_TRUST } from './authority.js';
10
+ export { datasetRefusal, undeclaredDataset } from './datasets.js';
11
+ export { auditSignatures } from './signatures.js';
12
+ export { auditWrites } from './writes.js';
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/eval/submission/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAYhD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC","sourcesContent":["/**\n * The three answers the wire boundary cannot give, and the stance that enables them.\n *\n * `evaluateSubmission` closes the *shape* of an untrusted body. This module is the door's second\n * half: it judges what the body claims against what the host says it trusts — write authority,\n * a server-captured signature, and the artifact's declared tables — and returns a tagged refusal\n * for each rather than a report.\n */\nexport { UNSTATED_TRUST } from './authority.js';\nexport type {\n CapturedSignature,\n SubmissionTrust,\n SubmissionTrustKind,\n} from './authority.js';\nexport type {\n SignatureRefusal,\n SubmissionRefusal,\n SubmissionRefusalCause,\n SubmissionRefusalCode,\n} from './refusals.js';\nexport { datasetRefusal, undeclaredDataset } from './datasets.js';\nexport { auditSignatures } from './signatures.js';\nexport { auditWrites } from './writes.js';\n"]}
@@ -0,0 +1,103 @@
1
+ import type { FieldAccess, FieldRef } from '../../model/types.js';
2
+ import type { DiagnosticCode } from '../../model/types.js';
3
+ import type { BoundaryRefusal } from '../../model/wire.js';
4
+ import type { SignatureVerification } from '../verify-signature.js';
5
+ import type { WriteRefusal, WriteRefusalCode } from '../access/write.js';
6
+ /**
7
+ * The refusals the submission door states for the three checks the wire boundary cannot make.
8
+ *
9
+ * Everything here is data: no check throws, and no check reports "not verified" as `ok`. The
10
+ * envelope is the door's existing `{ code, path, detail }` shape — a host keeps one branch for a
11
+ * bad body and a bad authority — and `cause` carries the structured facts the free-text `detail`
12
+ * can only quote, so a log line and the host's own branch read the same answer.
13
+ */
14
+ /**
15
+ * A refusal's code.
16
+ *
17
+ * The wire boundary's code is a diagnostic; a refused write's code is the one `checkWrite`
18
+ * states (`ACCESS_DENIED`, `DISABLED`, `ROW_UNADDRESSABLE`, `INVALID_VALUE`). Both vocabularies
19
+ * are already public, and the door adds one code of its own: a `write_only` value the session
20
+ * did not record is not a write the predicate refuses (access permits it) and not a body shape
21
+ * the wire refuses, so `WRITE_UNRECORDED` names the missing host fact a host repairs by listing
22
+ * the reference in `sessionWrites`.
23
+ */
24
+ export type SubmissionRefusalCode = DiagnosticCode | WriteRefusalCode | 'WRITE_UNRECORDED';
25
+ /** Why a signature the body carries is not a signature this process can rely on. */
26
+ export type SignatureRefusal =
27
+ /** No capture was stated and only a system-origin capture may write a `signature_ref`. */
28
+ {
29
+ readonly kind: 'not-captured';
30
+ }
31
+ /** The host captured a signature for this binding, but not this blob. */
32
+ | {
33
+ readonly kind: 'capture-mismatch';
34
+ }
35
+ /** The blob names a schema version other than the record's. */
36
+ | {
37
+ readonly kind: 'schema-version';
38
+ readonly declared: number;
39
+ readonly record: number;
40
+ }
41
+ /** A hand-built artifact declares the field without the coverage it signs. */
42
+ | {
43
+ readonly kind: 'no-declared-covers';
44
+ }
45
+ /** `verifySignature` recomputed the binding and the covered values no longer match. */
46
+ | {
47
+ readonly kind: 'verification';
48
+ };
49
+ /** The structured cause of one refusal, tagged by the check that produced it. */
50
+ export type SubmissionRefusalCause = {
51
+ readonly kind: 'write';
52
+ /** The predicate's own refusal: code, origin, binding and row key. */
53
+ readonly write: WriteRefusal;
54
+ readonly access: FieldAccess;
55
+ readonly enabled: boolean;
56
+ readonly repair: string;
57
+ } | {
58
+ readonly kind: 'signature';
59
+ readonly fieldId: string;
60
+ readonly rowKey?: string | number;
61
+ readonly refusal: SignatureRefusal;
62
+ /** The verifier's own tagged outcome, when one was produced. */
63
+ readonly verification?: SignatureVerification;
64
+ } | {
65
+ readonly kind: 'dataset';
66
+ readonly tableId: string;
67
+ /** The rule or declaration whose expression names the table. */
68
+ readonly expression: string;
69
+ } | {
70
+ /**
71
+ * A `write_only` value the body carries and the session did not record.
72
+ *
73
+ * Access permits a user write to `write_only`, so this is not the predicate's refusal: it
74
+ * is the door answering that it cannot tell this session's write from a client's claim,
75
+ * and would otherwise drop the value from the projection without saying so.
76
+ */
77
+ readonly kind: 'session-write';
78
+ readonly ref: FieldRef;
79
+ readonly access: 'write_only';
80
+ };
81
+ /**
82
+ * One refusal from the submission door.
83
+ *
84
+ * It is the wire boundary's envelope plus the check that refused, so a refusal of a *body* and a
85
+ * refusal of the *authority that judged it* are one value a backend logs and branches on.
86
+ */
87
+ export interface SubmissionRefusal extends Omit<BoundaryRefusal, 'code'> {
88
+ readonly code: SubmissionRefusalCode;
89
+ readonly cause?: SubmissionRefusalCause;
90
+ }
91
+ /** One write refusal as the door states it, naming the binding and the access it resolved. */
92
+ export declare function writeCause(input: {
93
+ readonly write: WriteRefusal;
94
+ readonly access: FieldAccess;
95
+ readonly enabled: boolean;
96
+ readonly repair: string;
97
+ }): SubmissionRefusalCause;
98
+ /** The reference one refusal names, as text a log can quote without quoting a value. */
99
+ export declare function bindingOf(ref: {
100
+ readonly fieldId: string;
101
+ readonly rowKey?: string | number | undefined;
102
+ }): string;
103
+ //# sourceMappingURL=refusals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusals.d.ts","sourceRoot":"","sources":["../../../src/eval/submission/refusals.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,qBAAqB,EAAE,M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AAE,qBAAqB,CAAC;CAC/C,GACD;IACE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,gEAAgE;IAChE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B,GACD;IACE;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B,CAAC;AAEN;;;;;GAKG;AACH,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,eAAe,EAAE,MAAM,CAAC;IACtE,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,KAAK,CAAC,EAAE,sBAAsB,CAAC;CACzC;AAED,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAChC,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB,GAAG,sBAAsB,CAQzB;AAED,wFAAwF;AACxF,wBAAgB,SAAS,CAAC,GAAG,EAAE;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;CAC/C,GAAG,MAAM,CAET"}
@@ -0,0 +1,15 @@
1
+ /** One write refusal as the door states it, naming the binding and the access it resolved. */
2
+ export function writeCause(input) {
3
+ return {
4
+ kind: 'write',
5
+ write: input.write,
6
+ access: input.access,
7
+ enabled: input.enabled,
8
+ repair: input.repair,
9
+ };
10
+ }
11
+ /** The reference one refusal names, as text a log can quote without quoting a value. */
12
+ export function bindingOf(ref) {
13
+ return ref.rowKey === undefined ? ref.fieldId : `${ref.fieldId}@${String(ref.rowKey)}`;
14
+ }
15
+ //# sourceMappingURL=refusals.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refusals.js","sourceRoot":"","sources":["../../../src/eval/submission/refusals.ts"],"names":[],"mappings":"AA4FA,8FAA8F;AAC9F,MAAM,UAAU,UAAU,CAAC,KAK1B;IACC,OAAO;QACL,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,MAAM,EAAE,KAAK,CAAC,MAAM;KACrB,CAAC;AACJ,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,SAAS,CAAC,GAGzB;IACC,OAAO,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;AACzF,CAAC","sourcesContent":["import type { FieldAccess, FieldRef } from '../../model/types.js';\nimport type { DiagnosticCode } from '../../model/types.js';\nimport type { BoundaryRefusal } from '../../model/wire.js';\nimport type { SignatureVerification } from '../verify-signature.js';\nimport type { WriteRefusal, WriteRefusalCode } from '../access/write.js';\n\n/**\n * The refusals the submission door states for the three checks the wire boundary cannot make.\n *\n * Everything here is data: no check throws, and no check reports \"not verified\" as `ok`. The\n * envelope is the door's existing `{ code, path, detail }` shape — a host keeps one branch for a\n * bad body and a bad authority — and `cause` carries the structured facts the free-text `detail`\n * can only quote, so a log line and the host's own branch read the same answer.\n */\n\n/**\n * A refusal's code.\n *\n * The wire boundary's code is a diagnostic; a refused write's code is the one `checkWrite`\n * states (`ACCESS_DENIED`, `DISABLED`, `ROW_UNADDRESSABLE`, `INVALID_VALUE`). Both vocabularies\n * are already public, and the door adds one code of its own: a `write_only` value the session\n * did not record is not a write the predicate refuses (access permits it) and not a body shape\n * the wire refuses, so `WRITE_UNRECORDED` names the missing host fact a host repairs by listing\n * the reference in `sessionWrites`.\n */\nexport type SubmissionRefusalCode = DiagnosticCode | WriteRefusalCode | 'WRITE_UNRECORDED';\n\n/** Why a signature the body carries is not a signature this process can rely on. */\nexport type SignatureRefusal =\n /** No capture was stated and only a system-origin capture may write a `signature_ref`. */\n | { readonly kind: 'not-captured' }\n /** The host captured a signature for this binding, but not this blob. */\n | { readonly kind: 'capture-mismatch' }\n /** The blob names a schema version other than the record's. */\n | {\n readonly kind: 'schema-version';\n readonly declared: number;\n readonly record: number;\n }\n /** A hand-built artifact declares the field without the coverage it signs. */\n | { readonly kind: 'no-declared-covers' }\n /** `verifySignature` recomputed the binding and the covered values no longer match. */\n | { readonly kind: 'verification' };\n\n/** The structured cause of one refusal, tagged by the check that produced it. */\nexport type SubmissionRefusalCause =\n | {\n readonly kind: 'write';\n /** The predicate's own refusal: code, origin, binding and row key. */\n readonly write: WriteRefusal;\n readonly access: FieldAccess;\n readonly enabled: boolean;\n readonly repair: string;\n }\n | {\n readonly kind: 'signature';\n readonly fieldId: string;\n readonly rowKey?: string | number;\n readonly refusal: SignatureRefusal;\n /** The verifier's own tagged outcome, when one was produced. */\n readonly verification?: SignatureVerification;\n }\n | {\n readonly kind: 'dataset';\n readonly tableId: string;\n /** The rule or declaration whose expression names the table. */\n readonly expression: string;\n }\n | {\n /**\n * A `write_only` value the body carries and the session did not record.\n *\n * Access permits a user write to `write_only`, so this is not the predicate's refusal: it\n * is the door answering that it cannot tell this session's write from a client's claim,\n * and would otherwise drop the value from the projection without saying so.\n */\n readonly kind: 'session-write';\n readonly ref: FieldRef;\n readonly access: 'write_only';\n };\n\n/**\n * One refusal from the submission door.\n *\n * It is the wire boundary's envelope plus the check that refused, so a refusal of a *body* and a\n * refusal of the *authority that judged it* are one value a backend logs and branches on.\n */\nexport interface SubmissionRefusal extends Omit<BoundaryRefusal, 'code'> {\n readonly code: SubmissionRefusalCode;\n readonly cause?: SubmissionRefusalCause;\n}\n\n/** One write refusal as the door states it, naming the binding and the access it resolved. */\nexport function writeCause(input: {\n readonly write: WriteRefusal;\n readonly access: FieldAccess;\n readonly enabled: boolean;\n readonly repair: string;\n}): SubmissionRefusalCause {\n return {\n kind: 'write',\n write: input.write,\n access: input.access,\n enabled: input.enabled,\n repair: input.repair,\n };\n}\n\n/** The reference one refusal names, as text a log can quote without quoting a value. */\nexport function bindingOf(ref: {\n readonly fieldId: string;\n readonly rowKey?: string | number | undefined;\n}): string {\n return ref.rowKey === undefined ? ref.fieldId : `${ref.fieldId}@${String(ref.rowKey)}`;\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import type { EvaluationInput } from '../../model/access.js';
2
+ import type { CompiledSchema } from '../../model/schema.js';
3
+ import type { SubmissionTrust } from './authority.js';
4
+ import type { SubmissionRefusal } from './refusals.js';
5
+ /** Refuses any signature the body carries that this process cannot tie to a capture. */
6
+ export declare function auditSignatures(compiled: CompiledSchema, input: EvaluationInput, trust: SubmissionTrust): SubmissionRefusal | undefined;
7
+ //# sourceMappingURL=signatures.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signatures.d.ts","sourceRoot":"","sources":["../../../src/eval/submission/signatures.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,KAAK,EAAqB,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACzE,OAAO,KAAK,EAAoB,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA+CzE,wFAAwF;AACxF,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,eAAe,GACrB,iBAAiB,GAAG,SAAS,CAS/B"}
@@ -0,0 +1,215 @@
1
+ import { fieldKey } from '../access/projection.js';
2
+ import { verifySignature } from '../verify-signature.js';
3
+ import { isRecord } from '../../model/guards.js';
4
+ import { isSafeInteger } from '../../model/integer.js';
5
+ import { SHA256_HEX_PATTERN } from '../../model/types.js';
6
+ /** The captures a stance states, or `undefined` when the stance skips the audit. */
7
+ function capturesOf(trust) {
8
+ switch (trust.kind) {
9
+ case 'trusted-host':
10
+ return undefined;
11
+ case 'unstated':
12
+ // No capture was stated, and a `signature_ref` is never a user write: the empty capture
13
+ // list is what refuses a body signature below.
14
+ return [];
15
+ case 'access':
16
+ return trust.signatures ?? [];
17
+ case 'verified':
18
+ return trust.signatures;
19
+ }
20
+ }
21
+ /** Refuses any signature the body carries that this process cannot tie to a capture. */
22
+ export function auditSignatures(compiled, input, trust) {
23
+ const captures = capturesOf(trust);
24
+ if (captures === undefined)
25
+ return undefined;
26
+ const declarations = declarationsById(compiled.fields);
27
+ for (const located of collectSignatures(compiled.fields, input.values)) {
28
+ const refusal = auditOne(compiled, input, located, declarations, captures, trust);
29
+ if (refusal !== undefined)
30
+ return refusal;
31
+ }
32
+ return undefined;
33
+ }
34
+ /** One located signature, judged against its declaration, its capture and the record. */
35
+ function auditOne(compiled, input, located, declarations, captures, trust) {
36
+ const stored = storedSignatureOf(located.value);
37
+ if (stored === undefined) {
38
+ return signatureRefusal(located, 'ENGINE_ERROR', { kind: 'not-captured' }, `signature ${located.ref.fieldId} is not a stored signature`);
39
+ }
40
+ const declaration = declarations.get(located.ref.fieldId);
41
+ if (declaration?.covers === undefined || declaration.covers.length === 0) {
42
+ // A compiled artifact always declares coverage; a rehydrated one may omit it, and then the
43
+ // verifier would trust whatever target list the blob carries.
44
+ return signatureRefusal(located, 'ENGINE_ERROR', { kind: 'no-declared-covers' }, `signature ${located.ref.fieldId} declares no \`covers\`, so the record cannot say what it binds`);
45
+ }
46
+ const key = fieldKey(located.ref);
47
+ const capture = captures.find((candidate) => fieldKey(candidate.ref) === key);
48
+ if (capture === undefined) {
49
+ // Under `verified` the host claims it captured every signature, so a body blob with no
50
+ // capture is an unverifiable reference. With no capture stated at all — the default and an
51
+ // access-only stance — this is the user write `checkWrite` refuses for a `signature_ref`.
52
+ const code = trust.kind === 'verified' ? 'ENGINE_ERROR' : 'ACCESS_DENIED';
53
+ return signatureRefusal(located, code, { kind: 'not-captured' }, code === 'ACCESS_DENIED'
54
+ ? `a user write to ${key} was refused with ACCESS_DENIED; only the host's system-origin capture may record a signature`
55
+ : `signature ${key} is not a signature this host captured`);
56
+ }
57
+ if (!sameSignature(capture.signature, stored)) {
58
+ return signatureRefusal(located, 'ENGINE_ERROR', { kind: 'capture-mismatch' }, `signature ${key} is not the blob this host captured for that binding`);
59
+ }
60
+ if (stored.schemaVersion !== compiled.schemaVersion) {
61
+ return signatureRefusal(located, 'ENGINE_ERROR', { kind: 'schema-version', declared: stored.schemaVersion, record: compiled.schemaVersion }, `signature ${key} names schema version ${String(stored.schemaVersion)}; this record is version ${String(compiled.schemaVersion)}`);
62
+ }
63
+ const verification = verifySignature(new Map([[compiled.schemaVersion, compiled]]), input, located.ref.fieldId, stored);
64
+ if (verification.kind === 'verified')
65
+ return undefined;
66
+ return signatureRefusal(located, 'ENGINE_ERROR', { kind: 'verification' }, describeVerification(key, verification), verification);
67
+ }
68
+ /** The sentence a verification refusal states, naming targets and digests but never a value. */
69
+ function describeVerification(binding, verification) {
70
+ switch (verification.kind) {
71
+ case 'tampered':
72
+ // Both members are digests: the blob's claim and the recomputation, no covered value.
73
+ return `signature ${binding} does not bind the record: declared ${verification.expectedDataHash}, recomputed ${verification.actualDataHash}`;
74
+ case 'uncovered':
75
+ return `signature ${binding} covers [${verification.actualTargets.join(', ')}], not the declared [${verification.declaredTargets.join(', ')}]`;
76
+ case 'unverifiable':
77
+ return `signature ${binding} cannot be verified: ${verification.diagnostic.messageKey}`;
78
+ }
79
+ }
80
+ /** Builds one signature refusal, keeping the optional row key and verification off the shape. */
81
+ function signatureRefusal(located, code, refusal, detail, verification) {
82
+ return {
83
+ code,
84
+ path: located.path,
85
+ detail,
86
+ cause: {
87
+ kind: 'signature',
88
+ fieldId: located.ref.fieldId,
89
+ ...(located.ref.rowKey === undefined ? {} : { rowKey: located.ref.rowKey }),
90
+ refusal,
91
+ ...(verification === undefined ? {} : { verification }),
92
+ },
93
+ };
94
+ }
95
+ /** Whether two stored signatures bind the same bytes at the same version. */
96
+ function sameSignature(left, right) {
97
+ if (left.dataHash !== right.dataHash || left.schemaVersion !== right.schemaVersion)
98
+ return false;
99
+ if (left.coveredTargets.length !== right.coveredTargets.length)
100
+ return false;
101
+ return left.coveredTargets.every((target, index) => {
102
+ const other = right.coveredTargets[index];
103
+ return other !== undefined && fieldKey(target) === fieldKey(other);
104
+ });
105
+ }
106
+ /**
107
+ * The members of the blob verification reads, or `undefined` when the value is not one.
108
+ *
109
+ * The wire reader has already validated every body value against its declaration, so a value
110
+ * that fails here is an artifact/value disagreement the door refuses rather than asserts away.
111
+ */
112
+ function storedSignatureOf(value) {
113
+ if (!isRecord(value))
114
+ return undefined;
115
+ const covered = value['coveredTargets'];
116
+ if (!Array.isArray(covered) || covered.length === 0)
117
+ return undefined;
118
+ const coveredTargets = [];
119
+ for (const target of covered) {
120
+ if (!isRecord(target))
121
+ return undefined;
122
+ const fieldId = target['fieldId'];
123
+ if (typeof fieldId !== 'string')
124
+ return undefined;
125
+ const rowKey = target['rowKey'];
126
+ if (rowKey === undefined) {
127
+ coveredTargets.push({ fieldId });
128
+ }
129
+ else if (typeof rowKey === 'string' || typeof rowKey === 'number') {
130
+ coveredTargets.push({ fieldId, rowKey });
131
+ }
132
+ else {
133
+ return undefined;
134
+ }
135
+ }
136
+ const schemaVersion = value['schemaVersion'];
137
+ if (typeof schemaVersion !== 'number' ||
138
+ !Number.isSafeInteger(schemaVersion) ||
139
+ schemaVersion < 1) {
140
+ return undefined;
141
+ }
142
+ const dataHash = value['dataHash'];
143
+ if (typeof dataHash !== 'string' || !SHA256_HEX_PATTERN.test(dataHash))
144
+ return undefined;
145
+ return { coveredTargets, schemaVersion, dataHash };
146
+ }
147
+ /** Every declaration in the artifact, keyed by the unique `fieldId`. */
148
+ function declarationsById(fields) {
149
+ const byId = new Map();
150
+ const walk = (members) => {
151
+ for (const field of members) {
152
+ byId.set(field.fieldId, field);
153
+ if (field.fields !== undefined && field.fields.length > 0)
154
+ walk(field.fields);
155
+ }
156
+ };
157
+ walk(fields);
158
+ return byId;
159
+ }
160
+ /**
161
+ * Every signature the record carries, at any nesting level.
162
+ *
163
+ * A natural-key array supplies the row key from the row's own key field; an assigned-key array
164
+ * has no key in the values, so its signature is located without one and the capture must match
165
+ * by field alone. A signature inside a record is located without a row key.
166
+ */
167
+ function collectSignatures(fields, values) {
168
+ const located = [];
169
+ const visit = (members, record, path, rowKey) => {
170
+ for (const field of members) {
171
+ // Only a member the record itself carries is a signature. An omitted field named like an
172
+ // `Object.prototype` member is not the prototype's function.
173
+ const value = Object.hasOwn(record, field.fieldId) ? record[field.fieldId] : undefined;
174
+ if (value === undefined)
175
+ continue;
176
+ if (field.primitive === 'signature_ref') {
177
+ located.push({
178
+ ref: rowKey === undefined ? { fieldId: field.fieldId } : { fieldId: field.fieldId, rowKey },
179
+ path: `${path}.${field.fieldId}`,
180
+ value,
181
+ });
182
+ continue;
183
+ }
184
+ if (field.primitive === 'record' && isRecord(value)) {
185
+ visit(field.fields ?? [], value, `${path}.${field.fieldId}`, rowKey);
186
+ continue;
187
+ }
188
+ if (field.primitive === 'array' && Array.isArray(value) && field.fields !== undefined) {
189
+ value.forEach((row, index) => {
190
+ if (!isRecord(row))
191
+ return;
192
+ const key = naturalRowKey(field, row);
193
+ visit(field.fields ?? [], row, `${path}.${field.fieldId}[${String(index)}]`, key);
194
+ });
195
+ }
196
+ }
197
+ };
198
+ visit(fields, values, '$.values', undefined);
199
+ return located;
200
+ }
201
+ /** The row key a natural-key array states in the row itself; absent for an assigned row. */
202
+ function naturalRowKey(field, row) {
203
+ const declaration = field.rowKey;
204
+ if (declaration === undefined || declaration.mode !== 'natural')
205
+ return undefined;
206
+ if (declaration.fieldId === undefined)
207
+ return undefined;
208
+ const key = row[declaration.fieldId];
209
+ if (typeof key === 'string')
210
+ return key;
211
+ if (typeof key === 'number' && isSafeInteger(key))
212
+ return key;
213
+ return undefined;
214
+ }
215
+ //# sourceMappingURL=signatures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signatures.js","sourceRoot":"","sources":["../../../src/eval/submission/signatures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAqC1D,oFAAoF;AACpF,SAAS,UAAU,CAAC,KAAsB;IACxC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,cAAc;YACjB,OAAO,SAAS,CAAC;QACnB,KAAK,UAAU;YACb,wFAAwF;YACxF,+CAA+C;YAC/C,OAAO,EAAE,CAAC;QACZ,KAAK,QAAQ;YACX,OAAO,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;QAChC,KAAK,UAAU;YACb,OAAO,KAAK,CAAC,UAAU,CAAC;IAC5B,CAAC;AACH,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,eAAe,CAC7B,QAAwB,EACxB,KAAsB,EACtB,KAAsB;IAEtB,MAAM,QAAQ,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC;IACnC,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC7C,MAAM,YAAY,GAAG,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACvD,KAAK,MAAM,OAAO,IAAI,iBAAiB,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;Q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Y,EAAE,KAAa,EAAE,EAAE;oBAC5C,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;wBAAE,OAAO;oBAC3B,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;oBACtC,KAAK,CAAC,KAAK,CAAC,MAAM,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,IAAI,IAAI,KAAK,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;gBACpF,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC,CAAC;IACF,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;IAC7C,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,4FAA4F;AAC5F,SAAS,aAAa,CACpB,KAAoB,EACpB,GAAsC;IAEtC,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC;IACjC,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,CAAC,IAAI,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAClF,IAAI,WAAW,CAAC,OAAO,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IACxD,MAAM,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IACrC,IAAI,OAAO,GAAG,KAAK,QAAQ;QAAE,OAAO,GAAG,CAAC;IACxC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,aAAa,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IAC9D,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { fieldKey } from '../access/projection.js';\nimport { verifySignature } from '../verify-signature.js';\nimport type { SignatureVerification } from '../verify-signature.js';\nimport { isRecord } from '../../model/guards.js';\nimport { isSafeInteger } from '../../model/integer.js';\nimport { SHA256_HEX_PATTERN } from '../../model/types.js';\nimport type { CompiledField, FieldRef } from '../../model/types.js';\nimport type { StoredSignature } from '../../model/evolution.js';\nimport type { EvaluationInput } from '../../model/access.js';\nimport type { CompiledSchema } from '../../model/schema.js';\nimport type { CapturedSignature, SubmissionTrust } from './authority.js';\nimport type { SignatureRefusal, SubmissionRefusal } from './refusals.js';\n\n/**\n * Signature verification at the submission door.\n *\n * `verifySignature` answers one question — \"do the covered values still match this digest\" — and\n * a client can compute that digest itself, because it is public and deterministic. So a\n * self-consistent blob from the body proves nothing about who produced it: the door needs the\n * host's capture to answer that. What this module adds is the binding between the two:\n *\n * 1. every `signature_ref` the body carries is located, at any nesting depth;\n * 2. its `coveredTargets` must equal the coverage the field declares (a blob that binds less, or\n * something else, is not the signature this record declares);\n * 3. its `schemaVersion` must be the record's, so the declarations that read the covered values\n * cannot be chosen by the blob;\n * 4. it must be the signature this process captured — same digest, version and target list — or\n * the caller stated no capture at all, in which case no body signature is accepted;\n * 5. `verifySignature` must recompute the same digest from the record the body carries.\n *\n * A `trusted-host` stance skips the audit: the caller has stated, at its own call site, that it\n * authorised the body before this call. Every other stance runs it.\n */\n\n/** One signature the body carries, located in the record's declarations. */\ninterface LocatedSignature {\n readonly ref: FieldRef;\n /** The value path the refusal names, `$.values.<field>…`. */\n readonly path: string;\n readonly value: unknown;\n}\n\n/** The captures a stance states, or `undefined` when the stance skips the audit. */\nfunction capturesOf(trust: SubmissionTrust): readonly CapturedSignature[] | undefined {\n switch (trust.kind) {\n case 'trusted-host':\n return undefined;\n case 'unstated':\n // No capture was stated, and a `signature_ref` is never a user write: the empty capture\n // list is what refuses a body signature below.\n return [];\n case 'access':\n return trust.signatures ?? [];\n case 'verified':\n return trust.signatures;\n }\n}\n\n/** Refuses any signature the body carries that this process cannot tie to a capture. */\nexport function auditSignatures(\n compiled: CompiledSchema,\n input: EvaluationInput,\n trust: SubmissionTrust,\n): SubmissionRefusal | undefined {\n const captures = capturesOf(trust);\n if (captures === undefined) return undefined;\n const declarations = declarationsById(compiled.fields);\n for (const located of collectSignatures(compiled.fields, input.values)) {\n const refusal = auditOne(compiled, input, located, declarations, captures, trust);\n if (refusal !== undefined) return refusal;\n }\n return undefined;\n}\n\n/** One located signature, judged against its declaration, its capture and the record. */\nfunction auditOne(\n compiled: CompiledSchema,\n input: EvaluationInput,\n located: LocatedSignature,\n declarations: ReadonlyMap<string, CompiledField>,\n captures: readonly CapturedSignature[],\n trust: SubmissionTrust,\n): SubmissionRefusal | undefined {\n const stored = storedSignatureOf(located.value);\n if (stored === undefined) {\n return signatureRefusal(\n located,\n 'ENGINE_ERROR',\n { kind: 'not-captured' },\n `signature ${located.ref.fieldId} is not a stored signature`,\n );\n }\n const declaration = declarations.get(located.ref.fieldId);\n if (declaration?.covers === undefined || declaration.covers.length === 0) {\n // A compiled artifact always declares coverage; a rehydrated one may omit it, and then the\n // verifier would trust whatever target list the blob carries.\n return signatureRefusal(\n located,\n 'ENGINE_ERROR',\n { kind: 'no-declared-covers' },\n `signature ${located.ref.fieldId} declares no \\`covers\\`, so the record cannot say what it binds`,\n );\n }\n const key = fieldKey(located.ref);\n const capture = captures.find((candidate) => fieldKey(candidate.ref) === key);\n if (capture === undefined) {\n // Under `verified` the host claims it captured every signature, so a body blob with no\n // capture is an unverifiable reference. With no capture stated at all — the default and an\n // access-only stance — this is the user write `checkWrite` refuses for a `signature_ref`.\n const code = trust.kind === 'verified' ? 'ENGINE_ERROR' : 'ACCESS_DENIED';\n return signatureRefusal(\n located,\n code,\n { kind: 'not-captured' },\n code === 'ACCESS_DENIED'\n ? `a user write to ${key} was refused with ACCESS_DENIED; only the host's system-origin capture may record a signature`\n : `signature ${key} is not a signature this host captured`,\n );\n }\n if (!sameSignature(capture.signature, stored)) {\n return signatureRefusal(\n located,\n 'ENGINE_ERROR',\n { kind: 'capture-mismatch' },\n `signature ${key} is not the blob this host captured for that binding`,\n );\n }\n if (stored.schemaVersion !== compiled.schemaVersion) {\n return signatureRefusal(\n located,\n 'ENGINE_ERROR',\n { kind: 'schema-version', declared: stored.schemaVersion, record: compiled.schemaVersion },\n `signature ${key} names schema version ${String(stored.schemaVersion)}; this record is version ${String(compiled.schemaVersion)}`,\n );\n }\n const verification = verifySignature(\n new Map([[compiled.schemaVersion, compiled]]),\n input,\n located.ref.fieldId,\n stored,\n );\n if (verification.kind === 'verified') return undefined;\n return signatureRefusal(\n located,\n 'ENGINE_ERROR',\n { kind: 'verification' },\n describeVerification(key, verification),\n verification,\n );\n}\n\n/** The sentence a verification refusal states, naming targets and digests but never a value. */\nfunction describeVerification(\n binding: string,\n verification: Exclude<SignatureVerification, { readonly kind: 'verified' }>,\n): string {\n switch (verification.kind) {\n case 'tampered':\n // Both members are digests: the blob's claim and the recomputation, no covered value.\n return `signature ${binding} does not bind the record: declared ${verification.expectedDataHash}, recomputed ${verification.actualDataHash}`;\n case 'uncovered':\n return `signature ${binding} covers [${verification.actualTargets.join(', ')}], not the declared [${verification.declaredTargets.join(', ')}]`;\n case 'unverifiable':\n return `signature ${binding} cannot be verified: ${verification.diagnostic.messageKey}`;\n }\n}\n\n/** Builds one signature refusal, keeping the optional row key and verification off the shape. */\nfunction signatureRefusal(\n located: LocatedSignature,\n code: SubmissionRefusal['code'],\n refusal: SignatureRefusal,\n detail: string,\n verification?: SignatureVerification,\n): SubmissionRefusal {\n return {\n code,\n path: located.path,\n detail,\n cause: {\n kind: 'signature',\n fieldId: located.ref.fieldId,\n ...(located.ref.rowKey === undefined ? {} : { rowKey: located.ref.rowKey }),\n refusal,\n ...(verification === undefined ? {} : { verification }),\n },\n };\n}\n\n/** Whether two stored signatures bind the same bytes at the same version. */\nfunction sameSignature(left: StoredSignature, right: StoredSignature): boolean {\n if (left.dataHash !== right.dataHash || left.schemaVersion !== right.schemaVersion) return false;\n if (left.coveredTargets.length !== right.coveredTargets.length) return false;\n return left.coveredTargets.every((target, index) => {\n const other = right.coveredTargets[index];\n return other !== undefined && fieldKey(target) === fieldKey(other);\n });\n}\n\n/**\n * The members of the blob verification reads, or `undefined` when the value is not one.\n *\n * The wire reader has already validated every body value against its declaration, so a value\n * that fails here is an artifact/value disagreement the door refuses rather than asserts away.\n */\nfunction storedSignatureOf(value: unknown): StoredSignature | undefined {\n if (!isRecord(value)) return undefined;\n const covered = value['coveredTargets'];\n if (!Array.isArray(covered) || covered.length === 0) return undefined;\n const coveredTargets: FieldRef[] = [];\n for (const target of covered) {\n if (!isRecord(target)) return undefined;\n const fieldId = target['fieldId'];\n if (typeof fieldId !== 'string') return undefined;\n const rowKey = target['rowKey'];\n if (rowKey === undefined) {\n coveredTargets.push({ fieldId });\n } else if (typeof rowKey === 'string' || typeof rowKey === 'number') {\n coveredTargets.push({ fieldId, rowKey });\n } else {\n return undefined;\n }\n }\n const schemaVersion = value['schemaVersion'];\n if (\n typeof schemaVersion !== 'number' ||\n !Number.isSafeInteger(schemaVersion) ||\n schemaVersion < 1\n ) {\n return undefined;\n }\n const dataHash = value['dataHash'];\n if (typeof dataHash !== 'string' || !SHA256_HEX_PATTERN.test(dataHash)) return undefined;\n return { coveredTargets, schemaVersion, dataHash };\n}\n\n/** Every declaration in the artifact, keyed by the unique `fieldId`. */\nfunction declarationsById(fields: readonly CompiledField[]): ReadonlyMap<string, CompiledField> {\n const byId = new Map<string, CompiledField>();\n const walk = (members: readonly CompiledField[]): void => {\n for (const field of members) {\n byId.set(field.fieldId, field);\n if (field.fields !== undefined && field.fields.length > 0) walk(field.fields);\n }\n };\n walk(fields);\n return byId;\n}\n\n/**\n * Every signature the record carries, at any nesting level.\n *\n * A natural-key array supplies the row key from the row's own key field; an assigned-key array\n * has no key in the values, so its signature is located without one and the capture must match\n * by field alone. A signature inside a record is located without a row key.\n */\nfunction collectSignatures(\n fields: readonly CompiledField[],\n values: Readonly<Record<string, unknown>>,\n): readonly LocatedSignature[] {\n const located: LocatedSignature[] = [];\n const visit = (\n members: readonly CompiledField[],\n record: Readonly<Record<string, unknown>>,\n path: string,\n rowKey: string | number | undefined,\n ): void => {\n for (const field of members) {\n // Only a member the record itself carries is a signature. An omitted field named like an\n // `Object.prototype` member is not the prototype's function.\n const value = Object.hasOwn(record, field.fieldId) ? record[field.fieldId] : undefined;\n if (value === undefined) continue;\n if (field.primitive === 'signature_ref') {\n located.push({\n ref:\n rowKey === undefined ? { fieldId: field.fieldId } : { fieldId: field.fieldId, rowKey },\n path: `${path}.${field.fieldId}`,\n value,\n });\n continue;\n }\n if (field.primitive === 'record' && isRecord(value)) {\n visit(field.fields ?? [], value, `${path}.${field.fieldId}`, rowKey);\n continue;\n }\n if (field.primitive === 'array' && Array.isArray(value) && field.fields !== undefined) {\n value.forEach((row: unknown, index: number) => {\n if (!isRecord(row)) return;\n const key = naturalRowKey(field, row);\n visit(field.fields ?? [], row, `${path}.${field.fieldId}[${String(index)}]`, key);\n });\n }\n }\n };\n visit(fields, values, '$.values', undefined);\n return located;\n}\n\n/** The row key a natural-key array states in the row itself; absent for an assigned row. */\nfunction naturalRowKey(\n field: CompiledField,\n row: Readonly<Record<string, unknown>>,\n): string | number | undefined {\n const declaration = field.rowKey;\n if (declaration === undefined || declaration.mode !== 'natural') return undefined;\n if (declaration.fieldId === undefined) return undefined;\n const key = row[declaration.fieldId];\n if (typeof key === 'string') return key;\n if (typeof key === 'number' && isSafeInteger(key)) return key;\n return undefined;\n}\n"]}