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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (755) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +714 -2
  3. package/dist/cache/index.d.ts +191 -0
  4. package/dist/cache/index.d.ts.map +1 -0
  5. package/dist/cache/index.js +361 -0
  6. package/dist/cache/index.js.map +1 -0
  7. package/dist/canonical/jcs.d.ts +78 -0
  8. package/dist/canonical/jcs.d.ts.map +1 -0
  9. package/dist/canonical/jcs.js +500 -0
  10. package/dist/canonical/jcs.js.map +1 -0
  11. package/dist/canonical/restricted-json.d.ts +7 -0
  12. package/dist/canonical/restricted-json.d.ts.map +1 -0
  13. package/dist/canonical/restricted-json.js +318 -0
  14. package/dist/canonical/restricted-json.js.map +1 -0
  15. package/dist/canonical/restricted-value.d.ts +59 -0
  16. package/dist/canonical/restricted-value.d.ts.map +1 -0
  17. package/dist/canonical/restricted-value.js +156 -0
  18. package/dist/canonical/restricted-value.js.map +1 -0
  19. package/dist/canonical/restricted.d.ts +85 -0
  20. package/dist/canonical/restricted.d.ts.map +1 -0
  21. package/dist/canonical/restricted.js +163 -0
  22. package/dist/canonical/restricted.js.map +1 -0
  23. package/dist/canonical/signature.d.ts +38 -0
  24. package/dist/canonical/signature.d.ts.map +1 -0
  25. package/dist/canonical/signature.js +47 -0
  26. package/dist/canonical/signature.js.map +1 -0
  27. package/dist/eval/access/delivery.d.ts +63 -0
  28. package/dist/eval/access/delivery.d.ts.map +1 -0
  29. package/dist/eval/access/delivery.js +98 -0
  30. package/dist/eval/access/delivery.js.map +1 -0
  31. package/dist/eval/access/overlay.d.ts +72 -0
  32. package/dist/eval/access/overlay.d.ts.map +1 -0
  33. package/dist/eval/access/overlay.js +402 -0
  34. package/dist/eval/access/overlay.js.map +1 -0
  35. package/dist/eval/access/projection.d.ts +159 -0
  36. package/dist/eval/access/projection.d.ts.map +1 -0
  37. package/dist/eval/access/projection.js +211 -0
  38. package/dist/eval/access/projection.js.map +1 -0
  39. package/dist/eval/access/window.d.ts +128 -0
  40. package/dist/eval/access/window.d.ts.map +1 -0
  41. package/dist/eval/access/window.js +254 -0
  42. package/dist/eval/access/window.js.map +1 -0
  43. package/dist/eval/access/write.d.ts +113 -0
  44. package/dist/eval/access/write.d.ts.map +1 -0
  45. package/dist/eval/access/write.js +119 -0
  46. package/dist/eval/access/write.js.map +1 -0
  47. package/dist/eval/addressing.d.ts +131 -0
  48. package/dist/eval/addressing.d.ts.map +1 -0
  49. package/dist/eval/addressing.js +270 -0
  50. package/dist/eval/addressing.js.map +1 -0
  51. package/dist/eval/budget.d.ts +143 -0
  52. package/dist/eval/budget.d.ts.map +1 -0
  53. package/dist/eval/budget.js +387 -0
  54. package/dist/eval/budget.js.map +1 -0
  55. package/dist/eval/computed.d.ts +46 -0
  56. package/dist/eval/computed.d.ts.map +1 -0
  57. package/dist/eval/computed.js +89 -0
  58. package/dist/eval/computed.js.map +1 -0
  59. package/dist/eval/denials.d.ts +64 -0
  60. package/dist/eval/denials.d.ts.map +1 -0
  61. package/dist/eval/denials.js +87 -0
  62. package/dist/eval/denials.js.map +1 -0
  63. package/dist/eval/engine/cancellation.d.ts +12 -0
  64. package/dist/eval/engine/cancellation.d.ts.map +1 -0
  65. package/dist/eval/engine/cancellation.js +56 -0
  66. package/dist/eval/engine/cancellation.js.map +1 -0
  67. package/dist/eval/engine/delta.d.ts +104 -0
  68. package/dist/eval/engine/delta.d.ts.map +1 -0
  69. package/dist/eval/engine/delta.js +466 -0
  70. package/dist/eval/engine/delta.js.map +1 -0
  71. package/dist/eval/engine/deps.d.ts +136 -0
  72. package/dist/eval/engine/deps.d.ts.map +1 -0
  73. package/dist/eval/engine/deps.js +345 -0
  74. package/dist/eval/engine/deps.js.map +1 -0
  75. package/dist/eval/engine/identity.d.ts +128 -0
  76. package/dist/eval/engine/identity.d.ts.map +1 -0
  77. package/dist/eval/engine/identity.js +398 -0
  78. package/dist/eval/engine/identity.js.map +1 -0
  79. package/dist/eval/engine/index.d.ts +200 -0
  80. package/dist/eval/engine/index.d.ts.map +1 -0
  81. package/dist/eval/engine/index.js +1242 -0
  82. package/dist/eval/engine/index.js.map +1 -0
  83. package/dist/eval/engine/measurement.d.ts +23 -0
  84. package/dist/eval/engine/measurement.d.ts.map +1 -0
  85. package/dist/eval/engine/measurement.js +42 -0
  86. package/dist/eval/engine/measurement.js.map +1 -0
  87. package/dist/eval/engine/naive.d.ts +19 -0
  88. package/dist/eval/engine/naive.d.ts.map +1 -0
  89. package/dist/eval/engine/naive.js +59 -0
  90. package/dist/eval/engine/naive.js.map +1 -0
  91. package/dist/eval/engine/ops.d.ts +214 -0
  92. package/dist/eval/engine/ops.d.ts.map +1 -0
  93. package/dist/eval/engine/ops.js +1422 -0
  94. package/dist/eval/engine/ops.js.map +1 -0
  95. package/dist/eval/engine/patches.d.ts +40 -0
  96. package/dist/eval/engine/patches.d.ts.map +1 -0
  97. package/dist/eval/engine/patches.js +125 -0
  98. package/dist/eval/engine/patches.js.map +1 -0
  99. package/dist/eval/engine/ports.d.ts +71 -0
  100. package/dist/eval/engine/ports.d.ts.map +1 -0
  101. package/dist/eval/engine/ports.js +2 -0
  102. package/dist/eval/engine/ports.js.map +1 -0
  103. package/dist/eval/engine/session.d.ts +116 -0
  104. package/dist/eval/engine/session.d.ts.map +1 -0
  105. package/dist/eval/engine/session.js +653 -0
  106. package/dist/eval/engine/session.js.map +1 -0
  107. package/dist/eval/engine/snapshot.d.ts +97 -0
  108. package/dist/eval/engine/snapshot.d.ts.map +1 -0
  109. package/dist/eval/engine/snapshot.js +221 -0
  110. package/dist/eval/engine/snapshot.js.map +1 -0
  111. package/dist/eval/engine/subscriptions.d.ts +47 -0
  112. package/dist/eval/engine/subscriptions.d.ts.map +1 -0
  113. package/dist/eval/engine/subscriptions.js +103 -0
  114. package/dist/eval/engine/subscriptions.js.map +1 -0
  115. package/dist/eval/engine/trace.d.ts +77 -0
  116. package/dist/eval/engine/trace.d.ts.map +1 -0
  117. package/dist/eval/engine/trace.js +140 -0
  118. package/dist/eval/engine/trace.js.map +1 -0
  119. package/dist/eval/error-diagnostic.d.ts +26 -0
  120. package/dist/eval/error-diagnostic.d.ts.map +1 -0
  121. package/dist/eval/error-diagnostic.js +63 -0
  122. package/dist/eval/error-diagnostic.js.map +1 -0
  123. package/dist/eval/evaluate-expr.d.ts +44 -0
  124. package/dist/eval/evaluate-expr.d.ts.map +1 -0
  125. package/dist/eval/evaluate-expr.js +149 -0
  126. package/dist/eval/evaluate-expr.js.map +1 -0
  127. package/dist/eval/evaluate.d.ts +282 -0
  128. package/dist/eval/evaluate.d.ts.map +1 -0
  129. package/dist/eval/evaluate.js +391 -0
  130. package/dist/eval/evaluate.js.map +1 -0
  131. package/dist/eval/evolution/relocate.d.ts +72 -0
  132. package/dist/eval/evolution/relocate.d.ts.map +1 -0
  133. package/dist/eval/evolution/relocate.js +427 -0
  134. package/dist/eval/evolution/relocate.js.map +1 -0
  135. package/dist/eval/evolution/select.d.ts +11 -0
  136. package/dist/eval/evolution/select.d.ts.map +1 -0
  137. package/dist/eval/evolution/select.js +53 -0
  138. package/dist/eval/evolution/select.js.map +1 -0
  139. package/dist/eval/evolution/upcast.d.ts +13 -0
  140. package/dist/eval/evolution/upcast.d.ts.map +1 -0
  141. package/dist/eval/evolution/upcast.js +88 -0
  142. package/dist/eval/evolution/upcast.js.map +1 -0
  143. package/dist/eval/expr/aggregates.d.ts +75 -0
  144. package/dist/eval/expr/aggregates.d.ts.map +1 -0
  145. package/dist/eval/expr/aggregates.js +991 -0
  146. package/dist/eval/expr/aggregates.js.map +1 -0
  147. package/dist/eval/expr/arithmetic.d.ts +26 -0
  148. package/dist/eval/expr/arithmetic.d.ts.map +1 -0
  149. package/dist/eval/expr/arithmetic.js +387 -0
  150. package/dist/eval/expr/arithmetic.js.map +1 -0
  151. package/dist/eval/expr/between.d.ts +17 -0
  152. package/dist/eval/expr/between.d.ts.map +1 -0
  153. package/dist/eval/expr/between.js +46 -0
  154. package/dist/eval/expr/between.js.map +1 -0
  155. package/dist/eval/expr/binder.d.ts +96 -0
  156. package/dist/eval/expr/binder.d.ts.map +1 -0
  157. package/dist/eval/expr/binder.js +253 -0
  158. package/dist/eval/expr/binder.js.map +1 -0
  159. package/dist/eval/expr/call-dispatch.d.ts +28 -0
  160. package/dist/eval/expr/call-dispatch.d.ts.map +1 -0
  161. package/dist/eval/expr/call-dispatch.js +114 -0
  162. package/dist/eval/expr/call-dispatch.js.map +1 -0
  163. package/dist/eval/expr/collections.d.ts +20 -0
  164. package/dist/eval/expr/collections.d.ts.map +1 -0
  165. package/dist/eval/expr/collections.js +66 -0
  166. package/dist/eval/expr/collections.js.map +1 -0
  167. package/dist/eval/expr/compare.d.ts +36 -0
  168. package/dist/eval/expr/compare.d.ts.map +1 -0
  169. package/dist/eval/expr/compare.js +115 -0
  170. package/dist/eval/expr/compare.js.map +1 -0
  171. package/dist/eval/expr/datasets.d.ts +28 -0
  172. package/dist/eval/expr/datasets.d.ts.map +1 -0
  173. package/dist/eval/expr/datasets.js +304 -0
  174. package/dist/eval/expr/datasets.js.map +1 -0
  175. package/dist/eval/expr/digest.d.ts +23 -0
  176. package/dist/eval/expr/digest.d.ts.map +1 -0
  177. package/dist/eval/expr/digest.js +89 -0
  178. package/dist/eval/expr/digest.js.map +1 -0
  179. package/dist/eval/expr/domains.d.ts +19 -0
  180. package/dist/eval/expr/domains.d.ts.map +1 -0
  181. package/dist/eval/expr/domains.js +18 -0
  182. package/dist/eval/expr/domains.js.map +1 -0
  183. package/dist/eval/expr/host.d.ts +152 -0
  184. package/dist/eval/expr/host.d.ts.map +1 -0
  185. package/dist/eval/expr/host.js +36 -0
  186. package/dist/eval/expr/host.js.map +1 -0
  187. package/dist/eval/expr/lists.d.ts +24 -0
  188. package/dist/eval/expr/lists.d.ts.map +1 -0
  189. package/dist/eval/expr/lists.js +155 -0
  190. package/dist/eval/expr/lists.js.map +1 -0
  191. package/dist/eval/expr/member.d.ts +15 -0
  192. package/dist/eval/expr/member.d.ts.map +1 -0
  193. package/dist/eval/expr/member.js +32 -0
  194. package/dist/eval/expr/member.js.map +1 -0
  195. package/dist/eval/expr/money-ops.d.ts +10 -0
  196. package/dist/eval/expr/money-ops.d.ts.map +1 -0
  197. package/dist/eval/expr/money-ops.js +17 -0
  198. package/dist/eval/expr/money-ops.js.map +1 -0
  199. package/dist/eval/expr/operands.d.ts +27 -0
  200. package/dist/eval/expr/operands.d.ts.map +1 -0
  201. package/dist/eval/expr/operands.js +167 -0
  202. package/dist/eval/expr/operands.js.map +1 -0
  203. package/dist/eval/expr/presence.d.ts +27 -0
  204. package/dist/eval/expr/presence.d.ts.map +1 -0
  205. package/dist/eval/expr/presence.js +140 -0
  206. package/dist/eval/expr/presence.js.map +1 -0
  207. package/dist/eval/expr/records.d.ts +22 -0
  208. package/dist/eval/expr/records.d.ts.map +1 -0
  209. package/dist/eval/expr/records.js +101 -0
  210. package/dist/eval/expr/records.js.map +1 -0
  211. package/dist/eval/expr/rule-refs.d.ts +25 -0
  212. package/dist/eval/expr/rule-refs.d.ts.map +1 -0
  213. package/dist/eval/expr/rule-refs.js +60 -0
  214. package/dist/eval/expr/rule-refs.js.map +1 -0
  215. package/dist/eval/expr/sequences.d.ts +26 -0
  216. package/dist/eval/expr/sequences.d.ts.map +1 -0
  217. package/dist/eval/expr/sequences.js +151 -0
  218. package/dist/eval/expr/sequences.js.map +1 -0
  219. package/dist/eval/expr/value.d.ts +99 -0
  220. package/dist/eval/expr/value.d.ts.map +1 -0
  221. package/dist/eval/expr/value.js +14 -0
  222. package/dist/eval/expr/value.js.map +1 -0
  223. package/dist/eval/expression.d.ts +142 -0
  224. package/dist/eval/expression.d.ts.map +1 -0
  225. package/dist/eval/expression.js +446 -0
  226. package/dist/eval/expression.js.map +1 -0
  227. package/dist/eval/firing.d.ts +68 -0
  228. package/dist/eval/firing.d.ts.map +1 -0
  229. package/dist/eval/firing.js +222 -0
  230. package/dist/eval/firing.js.map +1 -0
  231. package/dist/eval/gate.d.ts +110 -0
  232. package/dist/eval/gate.d.ts.map +1 -0
  233. package/dist/eval/gate.js +278 -0
  234. package/dist/eval/gate.js.map +1 -0
  235. package/dist/eval/layout-visibility.d.ts +18 -0
  236. package/dist/eval/layout-visibility.d.ts.map +1 -0
  237. package/dist/eval/layout-visibility.js +61 -0
  238. package/dist/eval/layout-visibility.js.map +1 -0
  239. package/dist/eval/option-availability.d.ts +26 -0
  240. package/dist/eval/option-availability.d.ts.map +1 -0
  241. package/dist/eval/option-availability.js +580 -0
  242. package/dist/eval/option-availability.js.map +1 -0
  243. package/dist/eval/options-boundary.d.ts +15 -0
  244. package/dist/eval/options-boundary.d.ts.map +1 -0
  245. package/dist/eval/options-boundary.js +40 -0
  246. package/dist/eval/options-boundary.js.map +1 -0
  247. package/dist/eval/options.d.ts +99 -0
  248. package/dist/eval/options.d.ts.map +1 -0
  249. package/dist/eval/options.js +96 -0
  250. package/dist/eval/options.js.map +1 -0
  251. package/dist/eval/overrides.d.ts +116 -0
  252. package/dist/eval/overrides.d.ts.map +1 -0
  253. package/dist/eval/overrides.js +176 -0
  254. package/dist/eval/overrides.js.map +1 -0
  255. package/dist/eval/paths.d.ts +25 -0
  256. package/dist/eval/paths.d.ts.map +1 -0
  257. package/dist/eval/paths.js +47 -0
  258. package/dist/eval/paths.js.map +1 -0
  259. package/dist/eval/presentation-reads.d.ts +20 -0
  260. package/dist/eval/presentation-reads.d.ts.map +1 -0
  261. package/dist/eval/presentation-reads.js +2 -0
  262. package/dist/eval/presentation-reads.js.map +1 -0
  263. package/dist/eval/presentation.d.ts +122 -0
  264. package/dist/eval/presentation.d.ts.map +1 -0
  265. package/dist/eval/presentation.js +255 -0
  266. package/dist/eval/presentation.js.map +1 -0
  267. package/dist/eval/reader/context-value.d.ts +41 -0
  268. package/dist/eval/reader/context-value.d.ts.map +1 -0
  269. package/dist/eval/reader/context-value.js +129 -0
  270. package/dist/eval/reader/context-value.js.map +1 -0
  271. package/dist/eval/reader/covered.d.ts +53 -0
  272. package/dist/eval/reader/covered.d.ts.map +1 -0
  273. package/dist/eval/reader/covered.js +139 -0
  274. package/dist/eval/reader/covered.js.map +1 -0
  275. package/dist/eval/reader/declarations.d.ts +182 -0
  276. package/dist/eval/reader/declarations.d.ts.map +1 -0
  277. package/dist/eval/reader/declarations.js +153 -0
  278. package/dist/eval/reader/declarations.js.map +1 -0
  279. package/dist/eval/reader/member-access.d.ts +87 -0
  280. package/dist/eval/reader/member-access.d.ts.map +1 -0
  281. package/dist/eval/reader/member-access.js +212 -0
  282. package/dist/eval/reader/member-access.js.map +1 -0
  283. package/dist/eval/reader/memo.d.ts +34 -0
  284. package/dist/eval/reader/memo.d.ts.map +1 -0
  285. package/dist/eval/reader/memo.js +67 -0
  286. package/dist/eval/reader/memo.js.map +1 -0
  287. package/dist/eval/reader/overlay.d.ts +74 -0
  288. package/dist/eval/reader/overlay.d.ts.map +1 -0
  289. package/dist/eval/reader/overlay.js +365 -0
  290. package/dist/eval/reader/overlay.js.map +1 -0
  291. package/dist/eval/reader/questions.d.ts +37 -0
  292. package/dist/eval/reader/questions.d.ts.map +1 -0
  293. package/dist/eval/reader/questions.js +78 -0
  294. package/dist/eval/reader/questions.js.map +1 -0
  295. package/dist/eval/reader/resolve.d.ts +84 -0
  296. package/dist/eval/reader/resolve.d.ts.map +1 -0
  297. package/dist/eval/reader/resolve.js +310 -0
  298. package/dist/eval/reader/resolve.js.map +1 -0
  299. package/dist/eval/reader/value-read.d.ts +50 -0
  300. package/dist/eval/reader/value-read.d.ts.map +1 -0
  301. package/dist/eval/reader/value-read.js +133 -0
  302. package/dist/eval/reader/value-read.js.map +1 -0
  303. package/dist/eval/reader/withheld.d.ts +48 -0
  304. package/dist/eval/reader/withheld.d.ts.map +1 -0
  305. package/dist/eval/reader/withheld.js +108 -0
  306. package/dist/eval/reader/withheld.js.map +1 -0
  307. package/dist/eval/reader-paths.d.ts +24 -0
  308. package/dist/eval/reader-paths.d.ts.map +1 -0
  309. package/dist/eval/reader-paths.js +23 -0
  310. package/dist/eval/reader-paths.js.map +1 -0
  311. package/dist/eval/reader.d.ts +281 -0
  312. package/dist/eval/reader.d.ts.map +1 -0
  313. package/dist/eval/reader.js +560 -0
  314. package/dist/eval/reader.js.map +1 -0
  315. package/dist/eval/receipt.d.ts +37 -0
  316. package/dist/eval/receipt.d.ts.map +1 -0
  317. package/dist/eval/receipt.js +222 -0
  318. package/dist/eval/receipt.js.map +1 -0
  319. package/dist/eval/report/assemble.d.ts +84 -0
  320. package/dist/eval/report/assemble.d.ts.map +1 -0
  321. package/dist/eval/report/assemble.js +277 -0
  322. package/dist/eval/report/assemble.js.map +1 -0
  323. package/dist/eval/report/fold.d.ts +18 -0
  324. package/dist/eval/report/fold.d.ts.map +1 -0
  325. package/dist/eval/report/fold.js +58 -0
  326. package/dist/eval/report/fold.js.map +1 -0
  327. package/dist/eval/rule/alternatives.d.ts +23 -0
  328. package/dist/eval/rule/alternatives.d.ts.map +1 -0
  329. package/dist/eval/rule/alternatives.js +46 -0
  330. package/dist/eval/rule/alternatives.js.map +1 -0
  331. package/dist/eval/rule/behaviour.d.ts +47 -0
  332. package/dist/eval/rule/behaviour.d.ts.map +1 -0
  333. package/dist/eval/rule/behaviour.js +249 -0
  334. package/dist/eval/rule/behaviour.js.map +1 -0
  335. package/dist/eval/rule/compute.d.ts +46 -0
  336. package/dist/eval/rule/compute.d.ts.map +1 -0
  337. package/dist/eval/rule/compute.js +158 -0
  338. package/dist/eval/rule/compute.js.map +1 -0
  339. package/dist/eval/rule/create-state.d.ts +42 -0
  340. package/dist/eval/rule/create-state.d.ts.map +1 -0
  341. package/dist/eval/rule/create-state.js +134 -0
  342. package/dist/eval/rule/create-state.js.map +1 -0
  343. package/dist/eval/rule/diagnostics.d.ts +24 -0
  344. package/dist/eval/rule/diagnostics.d.ts.map +1 -0
  345. package/dist/eval/rule/diagnostics.js +45 -0
  346. package/dist/eval/rule/diagnostics.js.map +1 -0
  347. package/dist/eval/rule/execution.d.ts +24 -0
  348. package/dist/eval/rule/execution.d.ts.map +1 -0
  349. package/dist/eval/rule/execution.js +495 -0
  350. package/dist/eval/rule/execution.js.map +1 -0
  351. package/dist/eval/rule/gate.d.ts +12 -0
  352. package/dist/eval/rule/gate.d.ts.map +1 -0
  353. package/dist/eval/rule/gate.js +34 -0
  354. package/dist/eval/rule/gate.js.map +1 -0
  355. package/dist/eval/rule/item.d.ts +11 -0
  356. package/dist/eval/rule/item.d.ts.map +1 -0
  357. package/dist/eval/rule/item.js +265 -0
  358. package/dist/eval/rule/item.js.map +1 -0
  359. package/dist/eval/rule/prepare.d.ts +64 -0
  360. package/dist/eval/rule/prepare.d.ts.map +1 -0
  361. package/dist/eval/rule/prepare.js +131 -0
  362. package/dist/eval/rule/prepare.js.map +1 -0
  363. package/dist/eval/rule/result.d.ts +97 -0
  364. package/dist/eval/rule/result.d.ts.map +1 -0
  365. package/dist/eval/rule/result.js +347 -0
  366. package/dist/eval/rule/result.js.map +1 -0
  367. package/dist/eval/rule/runner.d.ts +128 -0
  368. package/dist/eval/rule/runner.d.ts.map +1 -0
  369. package/dist/eval/rule/runner.js +296 -0
  370. package/dist/eval/rule/runner.js.map +1 -0
  371. package/dist/eval/rule/screen.d.ts +32 -0
  372. package/dist/eval/rule/screen.d.ts.map +1 -0
  373. package/dist/eval/rule/screen.js +73 -0
  374. package/dist/eval/rule/screen.js.map +1 -0
  375. package/dist/eval/rule/state.d.ts +137 -0
  376. package/dist/eval/rule/state.d.ts.map +1 -0
  377. package/dist/eval/rule/state.js +2 -0
  378. package/dist/eval/rule/state.js.map +1 -0
  379. package/dist/eval/rule/steps.d.ts +44 -0
  380. package/dist/eval/rule/steps.d.ts.map +1 -0
  381. package/dist/eval/rule/steps.js +367 -0
  382. package/dist/eval/rule/steps.js.map +1 -0
  383. package/dist/eval/rule/visibility.d.ts +18 -0
  384. package/dist/eval/rule/visibility.d.ts.map +1 -0
  385. package/dist/eval/rule/visibility.js +79 -0
  386. package/dist/eval/rule/visibility.js.map +1 -0
  387. package/dist/eval/seal.d.ts +74 -0
  388. package/dist/eval/seal.d.ts.map +1 -0
  389. package/dist/eval/seal.js +154 -0
  390. package/dist/eval/seal.js.map +1 -0
  391. package/dist/eval/signature-coverage.d.ts +19 -0
  392. package/dist/eval/signature-coverage.d.ts.map +1 -0
  393. package/dist/eval/signature-coverage.js +160 -0
  394. package/dist/eval/signature-coverage.js.map +1 -0
  395. package/dist/eval/state/derive.d.ts +72 -0
  396. package/dist/eval/state/derive.d.ts.map +1 -0
  397. package/dist/eval/state/derive.js +61 -0
  398. package/dist/eval/state/derive.js.map +1 -0
  399. package/dist/eval/state/describe.d.ts +18 -0
  400. package/dist/eval/state/describe.d.ts.map +1 -0
  401. package/dist/eval/state/describe.js +19 -0
  402. package/dist/eval/state/describe.js.map +1 -0
  403. package/dist/eval/state/field-state.d.ts +471 -0
  404. package/dist/eval/state/field-state.d.ts.map +1 -0
  405. package/dist/eval/state/field-state.js +1604 -0
  406. package/dist/eval/state/field-state.js.map +1 -0
  407. package/dist/eval/state/measurement.d.ts +136 -0
  408. package/dist/eval/state/measurement.d.ts.map +1 -0
  409. package/dist/eval/state/measurement.js +209 -0
  410. package/dist/eval/state/measurement.js.map +1 -0
  411. package/dist/eval/state/options.d.ts +21 -0
  412. package/dist/eval/state/options.d.ts.map +1 -0
  413. package/dist/eval/state/options.js +3 -0
  414. package/dist/eval/state/options.js.map +1 -0
  415. package/dist/eval/state/readiness.d.ts +400 -0
  416. package/dist/eval/state/readiness.d.ts.map +1 -0
  417. package/dist/eval/state/readiness.js +1067 -0
  418. package/dist/eval/state/readiness.js.map +1 -0
  419. package/dist/eval/state/snapshot.d.ts +130 -0
  420. package/dist/eval/state/snapshot.d.ts.map +1 -0
  421. package/dist/eval/state/snapshot.js +35 -0
  422. package/dist/eval/state/snapshot.js.map +1 -0
  423. package/dist/eval/state/unavailable-options.d.ts +54 -0
  424. package/dist/eval/state/unavailable-options.d.ts.map +1 -0
  425. package/dist/eval/state/unavailable-options.js +82 -0
  426. package/dist/eval/state/unavailable-options.js.map +1 -0
  427. package/dist/eval/state/value-state.d.ts +38 -0
  428. package/dist/eval/state/value-state.d.ts.map +1 -0
  429. package/dist/eval/state/value-state.js +52 -0
  430. package/dist/eval/state/value-state.js.map +1 -0
  431. package/dist/eval/submission/admission.d.ts +50 -0
  432. package/dist/eval/submission/admission.d.ts.map +1 -0
  433. package/dist/eval/submission/admission.js +174 -0
  434. package/dist/eval/submission/admission.js.map +1 -0
  435. package/dist/eval/submission/authority.d.ts +71 -0
  436. package/dist/eval/submission/authority.d.ts.map +1 -0
  437. package/dist/eval/submission/authority.js +118 -0
  438. package/dist/eval/submission/authority.js.map +1 -0
  439. package/dist/eval/submission/datasets.d.ts +28 -0
  440. package/dist/eval/submission/datasets.d.ts.map +1 -0
  441. package/dist/eval/submission/datasets.js +109 -0
  442. package/dist/eval/submission/datasets.js.map +1 -0
  443. package/dist/eval/submission/index.d.ts +15 -0
  444. package/dist/eval/submission/index.d.ts.map +1 -0
  445. package/dist/eval/submission/index.js +13 -0
  446. package/dist/eval/submission/index.js.map +1 -0
  447. package/dist/eval/submission/refusals.d.ts +103 -0
  448. package/dist/eval/submission/refusals.d.ts.map +1 -0
  449. package/dist/eval/submission/refusals.js +15 -0
  450. package/dist/eval/submission/refusals.js.map +1 -0
  451. package/dist/eval/submission/signatures.d.ts +7 -0
  452. package/dist/eval/submission/signatures.d.ts.map +1 -0
  453. package/dist/eval/submission/signatures.js +215 -0
  454. package/dist/eval/submission/signatures.js.map +1 -0
  455. package/dist/eval/submission/writes.d.ts +51 -0
  456. package/dist/eval/submission/writes.d.ts.map +1 -0
  457. package/dist/eval/submission/writes.js +203 -0
  458. package/dist/eval/submission/writes.js.map +1 -0
  459. package/dist/eval/submission.d.ts +53 -0
  460. package/dist/eval/submission.d.ts.map +1 -0
  461. package/dist/eval/submission.js +521 -0
  462. package/dist/eval/submission.js.map +1 -0
  463. package/dist/eval/suggestions-to-engine.d.ts +18 -0
  464. package/dist/eval/suggestions-to-engine.d.ts.map +1 -0
  465. package/dist/eval/suggestions-to-engine.js +40 -0
  466. package/dist/eval/suggestions-to-engine.js.map +1 -0
  467. package/dist/eval/suggestions.d.ts +17 -0
  468. package/dist/eval/suggestions.d.ts.map +1 -0
  469. package/dist/eval/suggestions.js +314 -0
  470. package/dist/eval/suggestions.js.map +1 -0
  471. package/dist/eval/undecided.d.ts +64 -0
  472. package/dist/eval/undecided.d.ts.map +1 -0
  473. package/dist/eval/undecided.js +101 -0
  474. package/dist/eval/undecided.js.map +1 -0
  475. package/dist/eval/verdict.d.ts +66 -0
  476. package/dist/eval/verdict.d.ts.map +1 -0
  477. package/dist/eval/verdict.js +106 -0
  478. package/dist/eval/verdict.js.map +1 -0
  479. package/dist/eval/verify-signature.d.ts +78 -0
  480. package/dist/eval/verify-signature.d.ts.map +1 -0
  481. package/dist/eval/verify-signature.js +185 -0
  482. package/dist/eval/verify-signature.js.map +1 -0
  483. package/dist/eval/version-dispatch.d.ts +38 -0
  484. package/dist/eval/version-dispatch.d.ts.map +1 -0
  485. package/dist/eval/version-dispatch.js +61 -0
  486. package/dist/eval/version-dispatch.js.map +1 -0
  487. package/dist/eval/visibility.d.ts +33 -0
  488. package/dist/eval/visibility.d.ts.map +1 -0
  489. package/dist/eval/visibility.js +83 -0
  490. package/dist/eval/visibility.js.map +1 -0
  491. package/dist/evaluate.d.ts +24 -0
  492. package/dist/evaluate.d.ts.map +1 -0
  493. package/dist/evaluate.js +18 -0
  494. package/dist/evaluate.js.map +1 -0
  495. package/dist/expr/builtin-docs.d.ts +51 -0
  496. package/dist/expr/builtin-docs.d.ts.map +1 -0
  497. package/dist/expr/builtin-docs.js +874 -0
  498. package/dist/expr/builtin-docs.js.map +1 -0
  499. package/dist/expr/builtins.d.ts +50 -0
  500. package/dist/expr/builtins.d.ts.map +1 -0
  501. package/dist/expr/builtins.js +966 -0
  502. package/dist/expr/builtins.js.map +1 -0
  503. package/dist/expr/decimal-precision.d.ts +39 -0
  504. package/dist/expr/decimal-precision.d.ts.map +1 -0
  505. package/dist/expr/decimal-precision.js +62 -0
  506. package/dist/expr/decimal-precision.js.map +1 -0
  507. package/dist/expr/decimal.d.ts +172 -0
  508. package/dist/expr/decimal.d.ts.map +1 -0
  509. package/dist/expr/decimal.js +782 -0
  510. package/dist/expr/decimal.js.map +1 -0
  511. package/dist/expr/deprecations.d.ts +34 -0
  512. package/dist/expr/deprecations.d.ts.map +1 -0
  513. package/dist/expr/deprecations.js +17 -0
  514. package/dist/expr/deprecations.js.map +1 -0
  515. package/dist/expr/diagnostics.d.ts +21 -0
  516. package/dist/expr/diagnostics.d.ts.map +1 -0
  517. package/dist/expr/diagnostics.js +231 -0
  518. package/dist/expr/diagnostics.js.map +1 -0
  519. package/dist/expr/direction.d.ts +30 -0
  520. package/dist/expr/direction.d.ts.map +1 -0
  521. package/dist/expr/direction.js +77 -0
  522. package/dist/expr/direction.js.map +1 -0
  523. package/dist/expr/example-expression.d.ts +62 -0
  524. package/dist/expr/example-expression.d.ts.map +1 -0
  525. package/dist/expr/example-expression.js +670 -0
  526. package/dist/expr/example-expression.js.map +1 -0
  527. package/dist/expr/instant.d.ts +49 -0
  528. package/dist/expr/instant.d.ts.map +1 -0
  529. package/dist/expr/instant.js +111 -0
  530. package/dist/expr/instant.js.map +1 -0
  531. package/dist/expr/logic.d.ts +17 -0
  532. package/dist/expr/logic.d.ts.map +1 -0
  533. package/dist/expr/logic.js +65 -0
  534. package/dist/expr/logic.js.map +1 -0
  535. package/dist/expr/messages.d.ts +45 -0
  536. package/dist/expr/messages.d.ts.map +1 -0
  537. package/dist/expr/messages.js +280 -0
  538. package/dist/expr/messages.js.map +1 -0
  539. package/dist/expr/money.d.ts +38 -0
  540. package/dist/expr/money.d.ts.map +1 -0
  541. package/dist/expr/money.js +127 -0
  542. package/dist/expr/money.js.map +1 -0
  543. package/dist/expr/ordering.d.ts +56 -0
  544. package/dist/expr/ordering.d.ts.map +1 -0
  545. package/dist/expr/ordering.js +167 -0
  546. package/dist/expr/ordering.js.map +1 -0
  547. package/dist/expr/pattern.d.ts +44 -0
  548. package/dist/expr/pattern.d.ts.map +1 -0
  549. package/dist/expr/pattern.js +458 -0
  550. package/dist/expr/pattern.js.map +1 -0
  551. package/dist/expr/plain-date.d.ts +90 -0
  552. package/dist/expr/plain-date.d.ts.map +1 -0
  553. package/dist/expr/plain-date.js +230 -0
  554. package/dist/expr/plain-date.js.map +1 -0
  555. package/dist/expr/plural-categories.d.ts +8 -0
  556. package/dist/expr/plural-categories.d.ts.map +1 -0
  557. package/dist/expr/plural-categories.js +15 -0
  558. package/dist/expr/plural-categories.js.map +1 -0
  559. package/dist/expr/plural-keys.d.ts +39 -0
  560. package/dist/expr/plural-keys.d.ts.map +1 -0
  561. package/dist/expr/plural-keys.js +46 -0
  562. package/dist/expr/plural-keys.js.map +1 -0
  563. package/dist/expr/plural.d.ts +33 -0
  564. package/dist/expr/plural.d.ts.map +1 -0
  565. package/dist/expr/plural.js +50 -0
  566. package/dist/expr/plural.js.map +1 -0
  567. package/dist/expr/quantity.d.ts +31 -0
  568. package/dist/expr/quantity.d.ts.map +1 -0
  569. package/dist/expr/quantity.js +83 -0
  570. package/dist/expr/quantity.js.map +1 -0
  571. package/dist/expr/reduce.d.ts +50 -0
  572. package/dist/expr/reduce.d.ts.map +1 -0
  573. package/dist/expr/reduce.js +236 -0
  574. package/dist/expr/reduce.js.map +1 -0
  575. package/dist/expr/regex.d.ts +108 -0
  576. package/dist/expr/regex.d.ts.map +1 -0
  577. package/dist/expr/regex.js +1207 -0
  578. package/dist/expr/regex.js.map +1 -0
  579. package/dist/expr/select-locale.d.ts +67 -0
  580. package/dist/expr/select-locale.d.ts.map +1 -0
  581. package/dist/expr/select-locale.js +219 -0
  582. package/dist/expr/select-locale.js.map +1 -0
  583. package/dist/expr/sequences.d.ts +123 -0
  584. package/dist/expr/sequences.d.ts.map +1 -0
  585. package/dist/expr/sequences.js +234 -0
  586. package/dist/expr/sequences.js.map +1 -0
  587. package/dist/expr/strings.d.ts +50 -0
  588. package/dist/expr/strings.d.ts.map +1 -0
  589. package/dist/expr/strings.js +184 -0
  590. package/dist/expr/strings.js.map +1 -0
  591. package/dist/expr/validation.d.ts +32 -0
  592. package/dist/expr/validation.d.ts.map +1 -0
  593. package/dist/expr/validation.js +182 -0
  594. package/dist/expr/validation.js.map +1 -0
  595. package/dist/graph/freeze.d.ts +4 -0
  596. package/dist/graph/freeze.d.ts.map +1 -0
  597. package/dist/graph/freeze.js +52 -0
  598. package/dist/graph/freeze.js.map +1 -0
  599. package/dist/graph/index.d.ts +15 -0
  600. package/dist/graph/index.d.ts.map +1 -0
  601. package/dist/graph/index.js +13 -0
  602. package/dist/graph/index.js.map +1 -0
  603. package/dist/graph/inspect.d.ts +76 -0
  604. package/dist/graph/inspect.d.ts.map +1 -0
  605. package/dist/graph/inspect.js +263 -0
  606. package/dist/graph/inspect.js.map +1 -0
  607. package/dist/graph/read-walk.d.ts +101 -0
  608. package/dist/graph/read-walk.d.ts.map +1 -0
  609. package/dist/graph/read-walk.js +358 -0
  610. package/dist/graph/read-walk.js.map +1 -0
  611. package/dist/graph/record-index.d.ts +24 -0
  612. package/dist/graph/record-index.d.ts.map +1 -0
  613. package/dist/graph/record-index.js +35 -0
  614. package/dist/graph/record-index.js.map +1 -0
  615. package/dist/index.d.ts +104 -0
  616. package/dist/index.d.ts.map +1 -0
  617. package/dist/index.js +139 -0
  618. package/dist/index.js.map +1 -0
  619. package/dist/lookup/digest.d.ts +51 -0
  620. package/dist/lookup/digest.d.ts.map +1 -0
  621. package/dist/lookup/digest.js +46 -0
  622. package/dist/lookup/digest.js.map +1 -0
  623. package/dist/lookup/index.d.ts +28 -0
  624. package/dist/lookup/index.d.ts.map +1 -0
  625. package/dist/lookup/index.js +27 -0
  626. package/dist/lookup/index.js.map +1 -0
  627. package/dist/lookup/install.d.ts +48 -0
  628. package/dist/lookup/install.d.ts.map +1 -0
  629. package/dist/lookup/install.js +315 -0
  630. package/dist/lookup/install.js.map +1 -0
  631. package/dist/lookup/pass.d.ts +55 -0
  632. package/dist/lookup/pass.d.ts.map +1 -0
  633. package/dist/lookup/pass.js +212 -0
  634. package/dist/lookup/pass.js.map +1 -0
  635. package/dist/lookup/pins.d.ts +34 -0
  636. package/dist/lookup/pins.d.ts.map +1 -0
  637. package/dist/lookup/pins.js +39 -0
  638. package/dist/lookup/pins.js.map +1 -0
  639. package/dist/lookup/provenance.d.ts +23 -0
  640. package/dist/lookup/provenance.d.ts.map +1 -0
  641. package/dist/lookup/provenance.js +78 -0
  642. package/dist/lookup/provenance.js.map +1 -0
  643. package/dist/lookup/readiness.d.ts +13 -0
  644. package/dist/lookup/readiness.d.ts.map +1 -0
  645. package/dist/lookup/readiness.js +57 -0
  646. package/dist/lookup/readiness.js.map +1 -0
  647. package/dist/lookup/resolve.d.ts +24 -0
  648. package/dist/lookup/resolve.d.ts.map +1 -0
  649. package/dist/lookup/resolve.js +201 -0
  650. package/dist/lookup/resolve.js.map +1 -0
  651. package/dist/lookup/store.d.ts +41 -0
  652. package/dist/lookup/store.d.ts.map +1 -0
  653. package/dist/lookup/store.js +74 -0
  654. package/dist/lookup/store.js.map +1 -0
  655. package/dist/model/access.d.ts +200 -0
  656. package/dist/model/access.d.ts.map +1 -0
  657. package/dist/model/access.js +125 -0
  658. package/dist/model/access.js.map +1 -0
  659. package/dist/model/artifact-members.d.ts +3 -0
  660. package/dist/model/artifact-members.d.ts.map +1 -0
  661. package/dist/model/artifact-members.js +38 -0
  662. package/dist/model/artifact-members.js.map +1 -0
  663. package/dist/model/composition.d.ts +47 -0
  664. package/dist/model/composition.d.ts.map +1 -0
  665. package/dist/model/composition.js +66 -0
  666. package/dist/model/composition.js.map +1 -0
  667. package/dist/model/domain.d.ts +51 -0
  668. package/dist/model/domain.d.ts.map +1 -0
  669. package/dist/model/domain.js +75 -0
  670. package/dist/model/domain.js.map +1 -0
  671. package/dist/model/duration.d.ts +31 -0
  672. package/dist/model/duration.d.ts.map +1 -0
  673. package/dist/model/duration.js +136 -0
  674. package/dist/model/duration.js.map +1 -0
  675. package/dist/model/errors.d.ts +58 -0
  676. package/dist/model/errors.d.ts.map +1 -0
  677. package/dist/model/errors.js +81 -0
  678. package/dist/model/errors.js.map +1 -0
  679. package/dist/model/evolution.d.ts +177 -0
  680. package/dist/model/evolution.d.ts.map +1 -0
  681. package/dist/model/evolution.js +5 -0
  682. package/dist/model/evolution.js.map +1 -0
  683. package/dist/model/expr-children.d.ts +15 -0
  684. package/dist/model/expr-children.d.ts.map +1 -0
  685. package/dist/model/expr-children.js +45 -0
  686. package/dist/model/expr-children.js.map +1 -0
  687. package/dist/model/guards.d.ts +9 -0
  688. package/dist/model/guards.d.ts.map +1 -0
  689. package/dist/model/guards.js +11 -0
  690. package/dist/model/guards.js.map +1 -0
  691. package/dist/model/input.d.ts +42 -0
  692. package/dist/model/input.d.ts.map +1 -0
  693. package/dist/model/input.js +26 -0
  694. package/dist/model/input.js.map +1 -0
  695. package/dist/model/integer.d.ts +14 -0
  696. package/dist/model/integer.d.ts.map +1 -0
  697. package/dist/model/integer.js +16 -0
  698. package/dist/model/integer.js.map +1 -0
  699. package/dist/model/intrinsic.d.ts +18 -0
  700. package/dist/model/intrinsic.d.ts.map +1 -0
  701. package/dist/model/intrinsic.js +21 -0
  702. package/dist/model/intrinsic.js.map +1 -0
  703. package/dist/model/layout.d.ts +129 -0
  704. package/dist/model/layout.d.ts.map +1 -0
  705. package/dist/model/layout.js +2 -0
  706. package/dist/model/layout.js.map +1 -0
  707. package/dist/model/media.d.ts +33 -0
  708. package/dist/model/media.d.ts.map +1 -0
  709. package/dist/model/media.js +86 -0
  710. package/dist/model/media.js.map +1 -0
  711. package/dist/model/members.generated.d.ts +11 -0
  712. package/dist/model/members.generated.d.ts.map +1 -0
  713. package/dist/model/members.generated.js +71 -0
  714. package/dist/model/members.generated.js.map +1 -0
  715. package/dist/model/row-address.d.ts +27 -0
  716. package/dist/model/row-address.d.ts.map +1 -0
  717. package/dist/model/row-address.js +146 -0
  718. package/dist/model/row-address.js.map +1 -0
  719. package/dist/model/schema.d.ts +108 -0
  720. package/dist/model/schema.d.ts.map +1 -0
  721. package/dist/model/schema.js +2 -0
  722. package/dist/model/schema.js.map +1 -0
  723. package/dist/model/shape.d.ts +193 -0
  724. package/dist/model/shape.d.ts.map +1 -0
  725. package/dist/model/shape.js +2 -0
  726. package/dist/model/shape.js.map +1 -0
  727. package/dist/model/time.d.ts +61 -0
  728. package/dist/model/time.d.ts.map +1 -0
  729. package/dist/model/time.js +110 -0
  730. package/dist/model/time.js.map +1 -0
  731. package/dist/model/types.d.ts +1329 -0
  732. package/dist/model/types.d.ts.map +1 -0
  733. package/dist/model/types.js +424 -0
  734. package/dist/model/types.js.map +1 -0
  735. package/dist/model/values.d.ts +91 -0
  736. package/dist/model/values.d.ts.map +1 -0
  737. package/dist/model/values.js +195 -0
  738. package/dist/model/values.js.map +1 -0
  739. package/dist/model/wire.d.ts +356 -0
  740. package/dist/model/wire.d.ts.map +1 -0
  741. package/dist/model/wire.js +1504 -0
  742. package/dist/model/wire.js.map +1 -0
  743. package/dist/offline/index.d.ts +374 -0
  744. package/dist/offline/index.d.ts.map +1 -0
  745. package/dist/offline/index.js +422 -0
  746. package/dist/offline/index.js.map +1 -0
  747. package/dist/testing.d.ts +30 -0
  748. package/dist/testing.d.ts.map +1 -0
  749. package/dist/testing.js +42 -0
  750. package/dist/testing.js.map +1 -0
  751. package/dist/version.d.ts +30 -0
  752. package/dist/version.d.ts.map +1 -0
  753. package/dist/version.js +116 -0
  754. package/dist/version.js.map +1 -0
  755. package/package.json +98 -3
@@ -0,0 +1,249 @@
1
+ import { canonicalHash } from '../../canonical/jcs.js';
2
+ import { compareCodePoints } from '../../expr/strings.js';
3
+ import { AxiomError } from '../../model/errors.js';
4
+ /**
5
+ * The members each declaration site states as presentation, never what it decides.
6
+ *
7
+ * The projection is by inclusion: every member of a compiled artifact is behaviour unless its
8
+ * own declaration site names it here. That direction is deliberate — forgetting to exclude a
9
+ * presentation member is visible and caught by the totality test, while forgetting to include a
10
+ * behavioural one would silently weaken the pin, and a revision taken last year has to stay
11
+ * reproducible next year.
12
+ *
13
+ * A list belongs to a *site*, not to a name. The same spelling is presentation at one
14
+ * declaration and data at another: `titleKey` names a message a document shows, but it is also a
15
+ * legal message argument name, and a record value may carry any member at all. Matching by name
16
+ * at every depth dropped those, so two artifacts that interpolated different fields into one
17
+ * message shared a `behaviorHash` — the invisible weakening this projection exists to prevent
18
+ * (`CANON-3.1.2`).
19
+ */
20
+ const SCHEMA_PRESENTATION = [
21
+ 'layout',
22
+ 'messages',
23
+ 'locales',
24
+ 'defaultLocale',
25
+ 'titleKey',
26
+ // The root designation says which section a caller acts on when it names none, and the rule
27
+ // clauses call that a presentation decision: re-designating the primary changes the report
28
+ // and leaves every recorded approval valid (`RULES-2.1.13`, `RULES-5.1.2`).
29
+ 'primaryGateId',
30
+ 'primaryScreenId',
31
+ ];
32
+ /**
33
+ * A rule's embedded vectors are authoring evidence and its `note` is author-facing
34
+ * documentation; neither is a decision the artifact makes. Excluding the note here is what lets
35
+ * an author annotate a rule without moving a decision, a report or a seal.
36
+ */
37
+ const RULE_PRESENTATION = ['testCases', 'note'];
38
+ const FIELD_PRESENTATION = [
39
+ 'labelKey',
40
+ 'descriptionKey',
41
+ 'placeholderKey',
42
+ // The authored `rowsFrom` text names the expression in a blocker; the AST decides the count.
43
+ 'rowsFromSource',
44
+ // A bound reaches the renderer as a hint; the decision is the generated `validate` rule, so
45
+ // carrying the number on the field must not move `behaviorHash` (`MODEL-2.1.16`).
46
+ 'minimum',
47
+ 'maximum',
48
+ 'step',
49
+ ];
50
+ /** An option's label is presentation; its code and deprecation are not. */
51
+ const OPTION_PRESENTATION = ['labelKey'];
52
+ /**
53
+ * An alternative's label names it for a reader; the operations are what applying it does.
54
+ *
55
+ * The label is presentation at both sites that state an alternative, so rewriting a
56
+ * suggestion's sentence moves neither `behaviorHash` nor `ruleHash`, exactly as relabelling an
57
+ * option does not move the domain it offers.
58
+ */
59
+ const SUGGESTION_PRESENTATION = [
60
+ 'labelKey',
61
+ ];
62
+ /** The members no declaration site states as presentation. */
63
+ const NO_PRESENTATION = new Set();
64
+ const RULE_PRESENTATION_SET = new Set(RULE_PRESENTATION);
65
+ const FIELD_PRESENTATION_SET = new Set(FIELD_PRESENTATION);
66
+ const OPTION_PRESENTATION_SET = new Set(OPTION_PRESENTATION);
67
+ const SUGGESTION_PRESENTATION_SET = new Set(SUGGESTION_PRESENTATION);
68
+ /** The artifact members the payload states separately or not at all. */
69
+ const ARTIFACT_EXCLUSIONS = new Set([
70
+ ...SCHEMA_PRESENTATION,
71
+ // The rules are stated by the sorted `(ruleId, ruleHash)` pairs, not twice.
72
+ 'rules',
73
+ // The target names the tier the artifact was packaged for, not a decision it makes. Two
74
+ // artifacts that decide the same record the same way share a `behaviorHash` whether they run
75
+ // on a device or a server; where a target changes what the artifact carries (a stub in place
76
+ // of a server rule, a stripped case payload), the rules themselves already hash differently.
77
+ 'target',
78
+ // The producer stamp names the release that wrote the bytes, not what they decide. Hashing it
79
+ // would move every artifact's behaviour identity on a patch release that changed no rule, and
80
+ // a seven-year-old report could no longer be reproduced from the artifact it names.
81
+ 'producerVersion',
82
+ ]);
83
+ /**
84
+ * One declaration's own members, with the members its site states as presentation left out.
85
+ *
86
+ * Nested declarations are copied as they are; a caller whose member is itself a declaration
87
+ * replaces it with that declaration's own projection. Everything not named is behaviour by
88
+ * default, and `ownMember` reads a member without an index signature so no cast carries the
89
+ * tree into the projection.
90
+ */
91
+ function declaration(value, presentation) {
92
+ const projected = {};
93
+ for (const key of Object.keys(value)) {
94
+ if (presentation.has(key))
95
+ continue;
96
+ projected[key] = ownMember(value, key);
97
+ }
98
+ return projected;
99
+ }
100
+ /** One own member of a declaration, read by descriptor so the type needs no index signature. */
101
+ function ownMember(value, key) {
102
+ const descriptor = Object.getOwnPropertyDescriptor(value, key);
103
+ return descriptor === undefined ? undefined : descriptor.value;
104
+ }
105
+ /** A declaration list of fields, in `fieldId` order, so where a declaration sits is not behaviour. */
106
+ function projectFieldList(fields) {
107
+ return [...fields]
108
+ .sort((left, right) => compareCodePoints(left.fieldId, right.fieldId))
109
+ .map(projectField);
110
+ }
111
+ function projectField(field) {
112
+ const projected = declaration(field, FIELD_PRESENTATION_SET);
113
+ if (field.fields !== undefined)
114
+ projected['fields'] = projectFieldList(field.fields);
115
+ if (field.options !== undefined)
116
+ projected['options'] = field.options.map(projectOption);
117
+ return projected;
118
+ }
119
+ function projectOption(option) {
120
+ const projected = declaration(option, OPTION_PRESENTATION_SET);
121
+ // An alternative's operations are behaviour and its label is presentation, so the list is
122
+ // projected at its own site rather than carried as opaque data.
123
+ if (option.suggests !== undefined)
124
+ projected['suggests'] = option.suggests.map(projectSuggestion);
125
+ return projected;
126
+ }
127
+ function projectSuggestion(suggestion) {
128
+ return declaration(suggestion, SUGGESTION_PRESENTATION_SET);
129
+ }
130
+ function projectRule(rule) {
131
+ const projected = declaration(rule, RULE_PRESENTATION_SET);
132
+ if (rule.gate !== undefined)
133
+ projected['gate'] = projectGate(rule.gate);
134
+ if (rule.kind === 'screen' && rule.reasons !== undefined) {
135
+ projected['reasons'] = rule.reasons.map(projectReason);
136
+ }
137
+ if (rule.suggests !== undefined)
138
+ projected['suggests'] = rule.suggests.map(projectSuggestion);
139
+ // `params` is a message's argument binding: its member names are the message's argument
140
+ // names, so it stays opaque data and is never read as a member of a declaration.
141
+ return projected;
142
+ }
143
+ function projectGate(gate) {
144
+ const projected = declaration(gate, NO_PRESENTATION);
145
+ // A hand-built artifact may state no item list; the member is then absent rather than an
146
+ // empty list hashed in its place, which is what the projection of a missing member means.
147
+ if (Array.isArray(gate.items))
148
+ projected['items'] = gate.items.map(projectGateItem);
149
+ return projected;
150
+ }
151
+ function projectGateItem(item) {
152
+ return declaration(item, NO_PRESENTATION);
153
+ }
154
+ function projectReason(reason) {
155
+ return declaration(reason, NO_PRESENTATION);
156
+ }
157
+ /** The artifact's behaviour members, with `rules` left to the hashed pairs beside them. */
158
+ function projectArtifact(compiled) {
159
+ const projected = declaration(compiled, ARTIFACT_EXCLUSIONS);
160
+ // A record's member list is projected at its own site. An artifact that states none keeps the
161
+ // member absent rather than hashing an empty list in its place.
162
+ if (Array.isArray(compiled.fields))
163
+ projected['fields'] = projectFieldList(compiled.fields);
164
+ return projected;
165
+ }
166
+ /** Every rule's rule hash, keyed by the rule object the caller holds. */
167
+ export function ruleHashesOf(compiled) {
168
+ const hashes = new Map();
169
+ for (const rule of compiled.rules ?? []) {
170
+ hashes.set(rule, canonicalHash(projectRule(rule)));
171
+ }
172
+ return hashes;
173
+ }
174
+ /**
175
+ * The behaviour identity built from hashes a caller already derived. Hashing a rule is a
176
+ * defensive walk plus SHA-256, so a caller that needs both the per-rule hashes and the
177
+ * artifact's own passes its map in rather than deriving the same hashes a second time.
178
+ *
179
+ * The payload is the artifact's non-presentation members plus the sorted `(ruleId, ruleHash)`
180
+ * pairs. Keeping the pairs means a revision diff names the rules that moved instead of
181
+ * reporting one opaque digest, and every other member — fields, their options and row keys,
182
+ * context roots, datasets, money domains, hiding policy, signature coverage, a rule's message
183
+ * bindings — participates because it is not presentation, not because a list here remembered to
184
+ * say so.
185
+ */
186
+ export function behaviourOf(compiled, ruleHashes) {
187
+ const rules = compiled.rules ?? [];
188
+ const hashOf = (rule) => {
189
+ const hash = ruleHashes.get(rule);
190
+ if (hash === undefined) {
191
+ throw new AxiomError('ENGINE_ERROR', `rule ${rule.ruleId} has no recorded hash`, rule.ruleId);
192
+ }
193
+ return hash;
194
+ };
195
+ const artifact = projectArtifact(compiled);
196
+ const hashedRules = rules
197
+ .map((rule) => ({ ruleId: rule.ruleId, ruleHash: hashOf(rule) }))
198
+ .sort((a, b) => compareCodePoints(a.ruleId, b.ruleId));
199
+ return {
200
+ behaviorHash: canonicalHash({ artifact, rules: hashedRules }),
201
+ rules: rules.map((rule) => ({ ruleId: rule.ruleId, ruleHash: hashOf(rule) })),
202
+ };
203
+ }
204
+ /** The artifact each public identity was derived from, for callers that thread it back. */
205
+ const ARTIFACTS_BY_BEHAVIOUR = new WeakMap();
206
+ /** Whether `behaviour` is the immutable identity `artifactBehaviour` derived for `compiled`. */
207
+ export function isArtifactBehaviourOf(compiled, behaviour) {
208
+ return ARTIFACTS_BY_BEHAVIOUR.get(behaviour) === compiled;
209
+ }
210
+ /**
211
+ * The behaviour identities this process has derived.
212
+ *
213
+ * A measurement hook, never an input: no decision reads it. A derivation hashes every rule and
214
+ * the artifact around them, so a compile that derives it twice pays that walk twice; a counted
215
+ * test states the one-derivation budget instead of asserting a wall-clock duration, in the
216
+ * spelling `wireValidations` uses. Its reader is published on
217
+ * `@azx-pbc/axiom-runtime/testing`, not on a host door.
218
+ */
219
+ let derivationCount = 0;
220
+ /** The number of artifact behaviour identities derived since the process started. */
221
+ export function artifactBehaviourDerivations() {
222
+ return derivationCount;
223
+ }
224
+ /**
225
+ * The behaviour identity of a compiled artifact.
226
+ *
227
+ * Evaluation binds these hashes into every report and gate override, and an operator comparing
228
+ * two versions of a schema needs the same answer the report would carry, so the definition lives
229
+ * here instead of in either caller: a second derivation would let the two disagree about whether
230
+ * a schema's behaviour changed.
231
+ *
232
+ * A caller that needs the identity beside other work on the same artifact derives it once and
233
+ * threads the value — `readinessGaps`, `embeddedEvidence`, `runScenarioSuite` and
234
+ * `classifyArtifactDiff` all accept one — because each derivation re-hashes every rule.
235
+ */
236
+ export function artifactBehaviour(compiled) {
237
+ derivationCount += 1;
238
+ const behaviour = behaviourOf(compiled, ruleHashesOf(compiled));
239
+ // A caller threads this value into reports and revision diffs. Freezing the hash and every rule
240
+ // pair keeps that binding from being edited after derivation; the weak provenance check then
241
+ // rejects the same identity paired with another artifact without hashing the artifact again.
242
+ for (const rule of behaviour.rules)
243
+ Object.freeze(rule);
244
+ Object.freeze(behaviour.rules);
245
+ Object.freeze(behaviour);
246
+ ARTIFACTS_BY_BEHAVIOUR.set(behaviour, compiled);
247
+ return behaviour;
248
+ }
249
+ //# sourceMappingURL=behaviour.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behaviour.js","sourceRoot":"","sources":["../../../src/eval/rule/behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAYnD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,mBAAmB,GAAG;IAC1B,QAAQ;IACR,UAAU;IACV,SAAS;IACT,eAAe;IACf,UAAU;IACV,4FAA4F;IAC5F,2FAA2F;IAC3F,4EAA4E;IAC5E,eAAe;IACf,iBAAiB;CACmC,CAAC;AAEvD;;;;GAIG;AACH,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,MAAM,CAAoD,CAAC;AAEnG,MAAM,kBAAkB,GAAG;IACzB,UAAU;IACV,gBAAgB;IAChB,gBAAgB;IAChB,6FAA6F;IAC7F,gBAAgB;IAChB,4FAA4F;IAC5F,kFAAkF;IAClF,SAAS;IACT,SAAS;IACT,MAAM;CAC6C,CAAC;AAEtD,2EAA2E;AAC3E,MAAM,mBAAmB,GAAG,CAAC,UAAU,CAAmD,CAAC;AAE3F;;;;;;GAMG;AACH,MAAM,uBAAuB,GAAG;IAC9B,UAAU;CAC8C,CAAC;AAE3D,8DAA8D;AAC9D,MAAM,eAAe,GAAwB,IAAI,GAAG,EAAU,CAAC;AAE/D,MAAM,qBAAqB,GAAwB,IAAI,GAAG,CAAS,iBAAiB,CAAC,CAAC;AACtF,MAAM,sBAAsB,GAAwB,IAAI,GAAG,CAAS,kBAAkB,CAAC,CAAC;AACxF,MAAM,uBAAuB,GAAwB,IAAI,GAAG,CAAS,mBAAmB,CAAC,CAAC;AAC1F,MAAM,2BAA2B,GAAwB,IAAI,GAAG,CAAS,uBAAu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,UAAU,qBAAqB,CACnC,QAAwB,EACxB,SAA4B;IAE5B,OAAO,sBAAsB,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,QAAQ,CAAC;AAC5D,CAAC;AAED;;;;;;;;GAQG;AACH,IAAI,eAAe,GAAG,CAAC,CAAC;AAExB,qFAAqF;AACrF,MAAM,UAAU,4BAA4B;IAC1C,OAAO,eAAe,CAAC;AACzB,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAwB;IACxD,eAAe,IAAI,CAAC,CAAC;IACrB,MAAM,SAAS,GAAG,WAAW,CAAC,QAAQ,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC;IAChE,gGAAgG;IAChG,6FAA6F;IAC7F,6FAA6F;IAC7F,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,KAAK;QAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IACxD,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACzB,sBAAsB,CAAC,GAAG,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAChD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import { canonicalHash } from '../../canonical/jcs.js';\nimport { compareCodePoints } from '../../expr/strings.js';\nimport { AxiomError } from '../../model/errors.js';\nimport type {\n CompiledField,\n CompiledRule,\n CompiledSuggestion,\n FieldOption,\n GateItemDeclaration,\n RuleGate,\n ScreenReasonDeclaration,\n} from '../../model/types.js';\nimport type { CompiledSchema } from '../../model/schema.js';\n\n/**\n * The members each declaration site states as presentation, never what it decides.\n *\n * The projection is by inclusion: every member of a compiled artifact is behaviour unless its\n * own declaration site names it here. That direction is deliberate — forgetting to exclude a\n * presentation member is visible and caught by the totality test, while forgetting to include a\n * behavioural one would silently weaken the pin, and a revision taken last year has to stay\n * reproducible next year.\n *\n * A list belongs to a *site*, not to a name. The same spelling is presentation at one\n * declaration and data at another: `titleKey` names a message a document shows, but it is also a\n * legal message argument name, and a record value may carry any member at all. Matching by name\n * at every depth dropped those, so two artifacts that interpolated different fields into one\n * message shared a `behaviorHash` — the invisible weakening this projection exists to prevent\n * (`CANON-3.1.2`).\n */\nconst SCHEMA_PRESENTATION = [\n 'layout',\n 'messages',\n 'locales',\n 'defaultLocale',\n 'titleKey',\n // The root designation says which section a caller acts on when it names none, and the rule\n // clauses call that a presentation decision: re-designating the primary changes the report\n // and leaves every recorded approval valid (`RULES-2.1.13`, `RULES-5.1.2`).\n 'primaryGateId',\n 'primaryScreenId',\n] as const satisfies readonly (keyof CompiledSchema)[];\n\n/**\n * A rule's embedded vectors are authoring evidence and its `note` is author-facing\n * documentation; neither is a decision the artifact makes. Excluding the note here is what lets\n * an author annotate a rule without moving a decision, a report or a seal.\n */\nconst RULE_PRESENTATION = ['testCases', 'note'] as const satisfies readonly (keyof CompiledRule)[];\n\nconst FIELD_PRESENTATION = [\n 'labelKey',\n 'descriptionKey',\n 'placeholderKey',\n // The authored `rowsFrom` text names the expression in a blocker; the AST decides the count.\n 'rowsFromSource',\n // A bound reaches the renderer as a hint; the decision is the generated `validate` rule, so\n // carrying the number on the field must not move `behaviorHash` (`MODEL-2.1.16`).\n 'minimum',\n 'maximum',\n 'step',\n] as const satisfies readonly (keyof CompiledField)[];\n\n/** An option's label is presentation; its code and deprecation are not. */\nconst OPTION_PRESENTATION = ['labelKey'] as const satisfies readonly (keyof FieldOption)[];\n\n/**\n * An alternative's label names it for a reader; the operations are what applying it does.\n *\n * The label is presentation at both sites that state an alternative, so rewriting a\n * suggestion's sentence moves neither `behaviorHash` nor `ruleHash`, exactly as relabelling an\n * option does not move the domain it offers.\n */\nconst SUGGESTION_PRESENTATION = [\n 'labelKey',\n] as const satisfies readonly (keyof CompiledSuggestion)[];\n\n/** The members no declaration site states as presentation. */\nconst NO_PRESENTATION: ReadonlySet<string> = new Set<string>();\n\nconst RULE_PRESENTATION_SET: ReadonlySet<string> = new Set<string>(RULE_PRESENTATION);\nconst FIELD_PRESENTATION_SET: ReadonlySet<string> = new Set<string>(FIELD_PRESENTATION);\nconst OPTION_PRESENTATION_SET: ReadonlySet<string> = new Set<string>(OPTION_PRESENTATION);\nconst SUGGESTION_PRESENTATION_SET: ReadonlySet<string> = new Set<string>(SUGGESTION_PRESENTATION);\n\n/** The artifact members the payload states separately or not at all. */\nconst ARTIFACT_EXCLUSIONS: ReadonlySet<string> = new Set<string>([\n ...SCHEMA_PRESENTATION,\n // The rules are stated by the sorted `(ruleId, ruleHash)` pairs, not twice.\n 'rules',\n // The target names the tier the artifact was packaged for, not a decision it makes. Two\n // artifacts that decide the same record the same way share a `behaviorHash` whether they run\n // on a device or a server; where a target changes what the artifact carries (a stub in place\n // of a server rule, a stripped case payload), the rules themselves already hash differently.\n 'target',\n // The producer stamp names the release that wrote the bytes, not what they decide. Hashing it\n // would move every artifact's behaviour identity on a patch release that changed no rule, and\n // a seven-year-old report could no longer be reproduced from the artifact it names.\n 'producerVersion',\n]);\n\n/**\n * One declaration's own members, with the members its site states as presentation left out.\n *\n * Nested declarations are copied as they are; a caller whose member is itself a declaration\n * replaces it with that declaration's own projection. Everything not named is behaviour by\n * default, and `ownMember` reads a member without an index signature so no cast carries the\n * tree into the projection.\n */\nfunction declaration(value: object, presentation: ReadonlySet<string>): Record<string, unknown> {\n const projected: Record<string, unknown> = {};\n for (const key of Object.keys(value)) {\n if (presentation.has(key)) continue;\n projected[key] = ownMember(value, key);\n }\n return projected;\n}\n\n/** One own member of a declaration, read by descriptor so the type needs no index signature. */\nfunction ownMember(value: object, key: string): unknown {\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n return descriptor === undefined ? undefined : descriptor.value;\n}\n\n/** A declaration list of fields, in `fieldId` order, so where a declaration sits is not behaviour. */\nfunction projectFieldList(fields: readonly CompiledField[]): readonly Record<string, unknown>[] {\n return [...fields]\n .sort((left, right) => compareCodePoints(left.fieldId, right.fieldId))\n .map(projectField);\n}\n\nfunction projectField(field: CompiledField): Record<string, unknown> {\n const projected = declaration(field, FIELD_PRESENTATION_SET);\n if (field.fields !== undefined) projected['fields'] = projectFieldList(field.fields);\n if (field.options !== undefined) projected['options'] = field.options.map(projectOption);\n return projected;\n}\n\nfunction projectOption(option: FieldOption): Record<string, unknown> {\n const projected = declaration(option, OPTION_PRESENTATION_SET);\n // An alternative's operations are behaviour and its label is presentation, so the list is\n // projected at its own site rather than carried as opaque data.\n if (option.suggests !== undefined) projected['suggests'] = option.suggests.map(projectSuggestion);\n return projected;\n}\n\nfunction projectSuggestion(suggestion: CompiledSuggestion): Record<string, unknown> {\n return declaration(suggestion, SUGGESTION_PRESENTATION_SET);\n}\n\nfunction projectRule(rule: CompiledRule): Record<string, unknown> {\n const projected = declaration(rule, RULE_PRESENTATION_SET);\n if (rule.gate !== undefined) projected['gate'] = projectGate(rule.gate);\n if (rule.kind === 'screen' && rule.reasons !== undefined) {\n projected['reasons'] = rule.reasons.map(projectReason);\n }\n if (rule.suggests !== undefined) projected['suggests'] = rule.suggests.map(projectSuggestion);\n // `params` is a message's argument binding: its member names are the message's argument\n // names, so it stays opaque data and is never read as a member of a declaration.\n return projected;\n}\n\nfunction projectGate(gate: RuleGate): Record<string, unknown> {\n const projected = declaration(gate, NO_PRESENTATION);\n // A hand-built artifact may state no item list; the member is then absent rather than an\n // empty list hashed in its place, which is what the projection of a missing member means.\n if (Array.isArray(gate.items)) projected['items'] = gate.items.map(projectGateItem);\n return projected;\n}\n\nfunction projectGateItem(item: GateItemDeclaration): Record<string, unknown> {\n return declaration(item, NO_PRESENTATION);\n}\n\nfunction projectReason(reason: ScreenReasonDeclaration): Record<string, unknown> {\n return declaration(reason, NO_PRESENTATION);\n}\n\n/** The artifact's behaviour members, with `rules` left to the hashed pairs beside them. */\nfunction projectArtifact(compiled: CompiledSchema): Record<string, unknown> {\n const projected = declaration(compiled, ARTIFACT_EXCLUSIONS);\n // A record's member list is projected at its own site. An artifact that states none keeps the\n // member absent rather than hashing an empty list in its place.\n if (Array.isArray(compiled.fields)) projected['fields'] = projectFieldList(compiled.fields);\n return projected;\n}\n\n/** One rule's behaviour identity. */\nexport interface RuleBehaviour {\n readonly ruleId: string;\n readonly ruleHash: string;\n}\n\n/** A compiled artifact's behaviour identity. */\nexport interface ArtifactBehaviour {\n /** What the artifact does, independent of how it presents itself. */\n readonly behaviorHash: string;\n /** Every rule's hash in declaration order, so a caller names the rules that differ. */\n readonly rules: readonly RuleBehaviour[];\n}\n\n/** Every rule's rule hash, keyed by the rule object the caller holds. */\nexport function ruleHashesOf(compiled: CompiledSchema): Map<CompiledRule, string> {\n const hashes = new Map<CompiledRule, string>();\n for (const rule of compiled.rules ?? []) {\n hashes.set(rule, canonicalHash(projectRule(rule)));\n }\n return hashes;\n}\n\n/**\n * The behaviour identity built from hashes a caller already derived. Hashing a rule is a\n * defensive walk plus SHA-256, so a caller that needs both the per-rule hashes and the\n * artifact's own passes its map in rather than deriving the same hashes a second time.\n *\n * The payload is the artifact's non-presentation members plus the sorted `(ruleId, ruleHash)`\n * pairs. Keeping the pairs means a revision diff names the rules that moved instead of\n * reporting one opaque digest, and every other member — fields, their options and row keys,\n * context roots, datasets, money domains, hiding policy, signature coverage, a rule's message\n * bindings — participates because it is not presentation, not because a list here remembered to\n * say so.\n */\nexport function behaviourOf(\n compiled: CompiledSchema,\n ruleHashes: ReadonlyMap<CompiledRule, string>,\n): ArtifactBehaviour {\n const rules = compiled.rules ?? [];\n const hashOf = (rule: CompiledRule): string => {\n const hash = ruleHashes.get(rule);\n if (hash === undefined) {\n throw new AxiomError('ENGINE_ERROR', `rule ${rule.ruleId} has no recorded hash`, rule.ruleId);\n }\n return hash;\n };\n const artifact = projectArtifact(compiled);\n const hashedRules = rules\n .map((rule) => ({ ruleId: rule.ruleId, ruleHash: hashOf(rule) }))\n .sort((a, b) => compareCodePoints(a.ruleId, b.ruleId));\n return {\n behaviorHash: canonicalHash({ artifact, rules: hashedRules }),\n rules: rules.map((rule) => ({ ruleId: rule.ruleId, ruleHash: hashOf(rule) })),\n };\n}\n\n/** The artifact each public identity was derived from, for callers that thread it back. */\nconst ARTIFACTS_BY_BEHAVIOUR = new WeakMap<ArtifactBehaviour, CompiledSchema>();\n\n/** Whether `behaviour` is the immutable identity `artifactBehaviour` derived for `compiled`. */\nexport function isArtifactBehaviourOf(\n compiled: CompiledSchema,\n behaviour: ArtifactBehaviour,\n): boolean {\n return ARTIFACTS_BY_BEHAVIOUR.get(behaviour) === compiled;\n}\n\n/**\n * The behaviour identities this process has derived.\n *\n * A measurement hook, never an input: no decision reads it. A derivation hashes every rule and\n * the artifact around them, so a compile that derives it twice pays that walk twice; a counted\n * test states the one-derivation budget instead of asserting a wall-clock duration, in the\n * spelling `wireValidations` uses. Its reader is published on\n * `@azx-pbc/axiom-runtime/testing`, not on a host door.\n */\nlet derivationCount = 0;\n\n/** The number of artifact behaviour identities derived since the process started. */\nexport function artifactBehaviourDerivations(): number {\n return derivationCount;\n}\n\n/**\n * The behaviour identity of a compiled artifact.\n *\n * Evaluation binds these hashes into every report and gate override, and an operator comparing\n * two versions of a schema needs the same answer the report would carry, so the definition lives\n * here instead of in either caller: a second derivation would let the two disagree about whether\n * a schema's behaviour changed.\n *\n * A caller that needs the identity beside other work on the same artifact derives it once and\n * threads the value — `readinessGaps`, `embeddedEvidence`, `runScenarioSuite` and\n * `classifyArtifactDiff` all accept one — because each derivation re-hashes every rule.\n */\nexport function artifactBehaviour(compiled: CompiledSchema): ArtifactBehaviour {\n derivationCount += 1;\n const behaviour = behaviourOf(compiled, ruleHashesOf(compiled));\n // A caller threads this value into reports and revision diffs. Freezing the hash and every rule\n // pair keeps that binding from being edited after derivation; the weak provenance check then\n // rejects the same identity paired with another artifact without hashing the artifact again.\n for (const rule of behaviour.rules) Object.freeze(rule);\n Object.freeze(behaviour.rules);\n Object.freeze(behaviour);\n ARTIFACTS_BY_BEHAVIOUR.set(behaviour, compiled);\n return behaviour;\n}\n"]}
@@ -0,0 +1,46 @@
1
+ import type { CompiledRule, ComputedValue, Undetermined } from '../../model/types.js';
2
+ import type { EvaluationState, RuleEvaluation } from './state.js';
3
+ /** What one writer produced: its semantic result, and whether that result shadows the field. */
4
+ export interface WriterResolution {
5
+ readonly value: ComputedValue;
6
+ /** `true` when the writer owns the target and its result replaces the submitted value. */
7
+ readonly overlay: boolean;
8
+ }
9
+ /**
10
+ * Produces every writer's value once, in the graph's order, before the ordinary rules run.
11
+ *
12
+ * Evaluation is memoised by rule, so the declaration-order pass below reuses these results
13
+ * and reports them where they were declared. An item-scoped writer is evaluated once per row
14
+ * through the same item path as any other row-scoped rule, writing each decided value to
15
+ * `(targetFieldId, rowKey)`.
16
+ */
17
+ export declare function prepareComputed(state: EvaluationState, evaluateOnce: (rule: CompiledRule) => RuleEvaluation): void;
18
+ /**
19
+ * Produces the values of the writers a caller selected, in the graph's order.
20
+ *
21
+ * A session that retains the computed overlay between passes re-runs only the writers in the
22
+ * change set's closure; every other writer's entry is still the value its own last evaluation
23
+ * produced, so a read of an untouched computed field does not fall back to the submission.
24
+ */
25
+ export declare function prepareWriters(state: EvaluationState, order: readonly CompiledRule[], evaluateOnce: (rule: CompiledRule) => RuleEvaluation): void;
26
+ /**
27
+ * Records the sentinel a writer could not resolve, so a read of its target propagates the
28
+ * undetermined state instead of falling back to a submitted value the writer never approved.
29
+ * A `defaultCompute` is only overlaid when its default applies; its callers decide that.
30
+ *
31
+ * An item-scoped writer records the entry for the row in force: a row's failed write is that
32
+ * row's answer, not a verdict about its siblings.
33
+ */
34
+ export declare function markComputedUndetermined(state: EvaluationState, rule: CompiledRule, sentinel: Undetermined): void;
35
+ /**
36
+ * One writer's semantic result.
37
+ *
38
+ * `compute` is the sole authority for its target: the expression's value, or the sentinel
39
+ * that says it could not be produced, always shadows the submitted value.
40
+ * `defaultCompute` states the exception the language defines: while an override record is
41
+ * active the field keeps the value it already holds, so no overlay entry is recorded. An
42
+ * override record this device cannot read leaves the default unapplied — the engine cannot
43
+ * tell whether one is active — and records nothing rather than overwriting a stored value.
44
+ */
45
+ export declare function resolveWriter(state: EvaluationState, rule: CompiledRule): WriterResolution;
46
+ //# sourceMappingURL=compute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compute.d.ts","sourceRoot":"","sources":["../../../src/eval/rule/compute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKtF,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAElE,gGAAgG;AAChG,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,0FAA0F;IAC1F,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,eAAe,EACtB,YAAY,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,cAAc,GACnD,IAAI,CASN;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,SAAS,YAAY,EAAE,EAC9B,YAAY,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,cAAc,GACnD,IAAI,CA6BN;AAED;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,YAAY,EAClB,QAAQ,EAAE,YAAY,GACrB,IAAI,CAkBN;AAmBD;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,IAAI,EAAE,YAAY,GAAG,gBAAgB,CAkD1F"}
@@ -0,0 +1,158 @@
1
+ import { AxiomError } from '../../model/errors.js';
2
+ import { isUndetermined, UNKNOWN } from '../../model/types.js';
3
+ import { toWireValue, wireDeclarationOf } from '../../model/wire.js';
4
+ import { renderComputedValue, undeterminedValue } from '../computed.js';
5
+ /**
6
+ * Produces every writer's value once, in the graph's order, before the ordinary rules run.
7
+ *
8
+ * Evaluation is memoised by rule, so the declaration-order pass below reuses these results
9
+ * and reports them where they were declared. An item-scoped writer is evaluated once per row
10
+ * through the same item path as any other row-scoped rule, writing each decided value to
11
+ * `(targetFieldId, rowKey)`.
12
+ */
13
+ export function prepareComputed(state, evaluateOnce) {
14
+ if (state.computedPrepared)
15
+ return;
16
+ state.computedPrepared = true;
17
+ const order = state.prepared.computedOrder;
18
+ if (order === undefined) {
19
+ state.computedUnorderable = true;
20
+ return;
21
+ }
22
+ prepareWriters(state, order, evaluateOnce);
23
+ }
24
+ /**
25
+ * Produces the values of the writers a caller selected, in the graph's order.
26
+ *
27
+ * A session that retains the computed overlay between passes re-runs only the writers in the
28
+ * change set's closure; every other writer's entry is still the value its own last evaluation
29
+ * produced, so a read of an untouched computed field does not fall back to the submission.
30
+ */
31
+ export function prepareWriters(state, order, evaluateOnce) {
32
+ state.resolvingWriters = true;
33
+ try {
34
+ for (const rule of order) {
35
+ // The writer is the authority for its target in this pass. Clearing first is what makes a
36
+ // writer that now produces nothing (a `defaultCompute` whose override became active)
37
+ // stop shadowing the submitted value with the entry its last evaluation left.
38
+ const written = rule.scope === 'item' ? rule.targetFieldId : rule.fieldId;
39
+ if (written !== undefined)
40
+ state.computed.clear(written);
41
+ try {
42
+ evaluateOnce(rule);
43
+ }
44
+ finally {
45
+ // A `compute` that produced no entry did not write its field: a re-entered rule or a
46
+ // refusal outside the compute branch leaves the result undetermined, and a read must
47
+ // not fall back to the submitted value. A `defaultCompute` with no entry is the
48
+ // override case the language defines, so only `compute` is enforced here.
49
+ if (rule.kind === 'compute' &&
50
+ rule.scope !== 'item' &&
51
+ rule.fieldId !== undefined &&
52
+ state.computed.get(rule.fieldId) === undefined) {
53
+ markComputedUndetermined(state, rule, UNKNOWN);
54
+ }
55
+ }
56
+ }
57
+ }
58
+ finally {
59
+ state.resolvingWriters = false;
60
+ }
61
+ }
62
+ /**
63
+ * Records the sentinel a writer could not resolve, so a read of its target propagates the
64
+ * undetermined state instead of falling back to a submitted value the writer never approved.
65
+ * A `defaultCompute` is only overlaid when its default applies; its callers decide that.
66
+ *
67
+ * An item-scoped writer records the entry for the row in force: a row's failed write is that
68
+ * row's answer, not a verdict about its siblings.
69
+ */
70
+ export function markComputedUndetermined(state, rule, sentinel) {
71
+ if (rule.fieldId === undefined)
72
+ return;
73
+ if (rule.scope === 'item') {
74
+ const target = rule.targetFieldId;
75
+ const rowKey = state.currentRowKey;
76
+ if (target === undefined || !state.prepared.writerIds.has(target))
77
+ return;
78
+ // A refusal before the rows are read — notably a server-tier writer on a client — has
79
+ // no row to key. The declaration-wide entry makes every row's target undetermined
80
+ // without reading those rows; a row entry, when one exists, remains more specific.
81
+ if (rowKey === undefined) {
82
+ state.computed.set(target, undeterminedValue(sentinel));
83
+ return;
84
+ }
85
+ state.computed.setRow(target, rowKey, undeterminedValue(sentinel));
86
+ return;
87
+ }
88
+ if (!state.prepared.writerIds.has(rule.fieldId))
89
+ return;
90
+ state.computed.set(rule.fieldId, undeterminedValue(sentinel));
91
+ }
92
+ /** The field one writer writes: the row member for an item writer, the field otherwise. */
93
+ function writerTargetId(rule) {
94
+ return rule.scope === 'item' ? rule.targetFieldId : rule.fieldId;
95
+ }
96
+ /**
97
+ * One field a writer reads by identifier. A row-scoped writer reads the member through its
98
+ * item binder, because the declaration path of an array member is not a path a record holds;
99
+ * every other writer reads the declaration as usual.
100
+ */
101
+ function readWriterField(state, rule, fieldId) {
102
+ if (rule.scope === 'item') {
103
+ return state.evaluator.evaluate({ kind: 'path', path: `$it.${fieldId}` });
104
+ }
105
+ return state.reader.read(state.reader.declarationPathOf(fieldId));
106
+ }
107
+ /**
108
+ * One writer's semantic result.
109
+ *
110
+ * `compute` is the sole authority for its target: the expression's value, or the sentinel
111
+ * that says it could not be produced, always shadows the submitted value.
112
+ * `defaultCompute` states the exception the language defines: while an override record is
113
+ * active the field keeps the value it already holds, so no overlay entry is recorded. An
114
+ * override record this device cannot read leaves the default unapplied — the engine cannot
115
+ * tell whether one is active — and records nothing rather than overwriting a stored value.
116
+ */
117
+ export function resolveWriter(state, rule) {
118
+ if (state.computedUnorderable) {
119
+ throw new AxiomError('ENGINE_ERROR', `computed field ${rule.fieldId ?? rule.ruleId} has no recalculation order, so its value cannot be produced`, rule.ruleId);
120
+ }
121
+ if (rule.scope === 'item' && rule.targetFieldId === undefined) {
122
+ throw new AxiomError('ENGINE_ERROR', 'an item-scoped computed rule declares the row member it writes', rule.ruleId);
123
+ }
124
+ const targetId = writerTargetId(rule);
125
+ const target = targetId === undefined ? undefined : state.prepared.fieldById.get(targetId);
126
+ const path = targetId === undefined ? `$.rules.${rule.ruleId}` : state.reader.declarationPathOf(targetId);
127
+ if (rule.kind === 'defaultCompute' && rule.overrideFieldId !== undefined) {
128
+ // The companion is named by its immutable `fieldId`, which is not always the path it is
129
+ // declared at, so it is resolved like any other field a rule names rather than read as one.
130
+ const override = readWriterField(state, rule, rule.overrideFieldId);
131
+ if (override.kind === 'value' && isUndetermined(override.value)) {
132
+ return { value: undeterminedValue(override.value), overlay: false };
133
+ }
134
+ if (override.kind === 'value' && override.value !== null) {
135
+ // An active override: the stored value is the field's value, and the report records it
136
+ // for the same reason a read delivers it.
137
+ if (targetId === undefined) {
138
+ return { value: { kind: 'decided', value: null }, overlay: false };
139
+ }
140
+ const current = readWriterField(state, rule, targetId);
141
+ if (current.kind === 'absent') {
142
+ return { value: { kind: 'decided', value: null }, overlay: false };
143
+ }
144
+ if (isUndetermined(current.value)) {
145
+ return { value: undeterminedValue(current.value), overlay: false };
146
+ }
147
+ const value = target === undefined
148
+ ? current.value
149
+ : toWireValue(current.value, path, wireDeclarationOf(target));
150
+ return { value: { kind: 'decided', value }, overlay: false };
151
+ }
152
+ }
153
+ return {
154
+ value: renderComputedValue(target, state.evaluator.evaluate(rule.expr), path),
155
+ overlay: true,
156
+ };
157
+ }
158
+ //# sourceMappingURL=compute.js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OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YACrE,CAAC;YACD,IAAI,cAAc,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBAClC,OAAO,EAAE,KAAK,EAAE,iBAAiB,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;YACrE,CAAC;YACD,MAAM,KAAK,GACT,MAAM,KAAK,SAAS;gBAClB,CAAC,CAAC,OAAO,CAAC,KAAK;gBACf,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC;YAClE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC/D,CAAC;IACH,CAAC;IACD,OAAO;QACL,KAAK,EAAE,mBAAmB,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;QAC7E,OAAO,EAAE,IAAI;KACd,CAAC;AACJ,CAAC","sourcesContent":["import { AxiomError } from '../../model/errors.js';\nimport type { CompiledRule, ComputedValue, Undetermined } from '../../model/types.js';\nimport { isUndetermined, UNKNOWN } from '../../model/types.js';\nimport { toWireValue, wireDeclarationOf } from '../../model/wire.js';\nimport { renderComputedValue, undeterminedValue } from '../computed.js';\nimport type { Evaluated } from '../expression.js';\nimport type { EvaluationState, RuleEvaluation } from './state.js';\n\n/** What one writer produced: its semantic result, and whether that result shadows the field. */\nexport interface WriterResolution {\n readonly value: ComputedValue;\n /** `true` when the writer owns the target and its result replaces the submitted value. */\n readonly overlay: boolean;\n}\n\n/**\n * Produces every writer's value once, in the graph's order, before the ordinary rules run.\n *\n * Evaluation is memoised by rule, so the declaration-order pass below reuses these results\n * and reports them where they were declared. An item-scoped writer is evaluated once per row\n * through the same item path as any other row-scoped rule, writing each decided value to\n * `(targetFieldId, rowKey)`.\n */\nexport function prepareComputed(\n state: EvaluationState,\n evaluateOnce: (rule: CompiledRule) => RuleEvaluation,\n): void {\n if (state.computedPrepared) return;\n state.computedPrepared = true;\n const order = state.prepared.computedOrder;\n if (order === undefined) {\n state.computedUnorderable = true;\n return;\n }\n prepareWriters(state, order, evaluateOnce);\n}\n\n/**\n * Produces the values of the writers a caller selected, in the graph's order.\n *\n * A session that retains the computed overlay between passes re-runs only the writers in the\n * change set's closure; every other writer's entry is still the value its own last evaluation\n * produced, so a read of an untouched computed field does not fall back to the submission.\n */\nexport function prepareWriters(\n state: EvaluationState,\n order: readonly CompiledRule[],\n evaluateOnce: (rule: CompiledRule) => RuleEvaluation,\n): void {\n state.resolvingWriters = true;\n try {\n for (const rule of order) {\n // The writer is the authority for its target in this pass. Clearing first is what makes a\n // writer that now produces nothing (a `defaultCompute` whose override became active)\n // stop shadowing the submitted value with the entry its last evaluation left.\n const written = rule.scope === 'item' ? rule.targetFieldId : rule.fieldId;\n if (written !== undefined) state.computed.clear(written);\n try {\n evaluateOnce(rule);\n } finally {\n // A `compute` that produced no entry did not write its field: a re-entered rule or a\n // refusal outside the compute branch leaves the result undetermined, and a read must\n // not fall back to the submitted value. A `defaultCompute` with no entry is the\n // override case the language defines, so only `compute` is enforced here.\n if (\n rule.kind === 'compute' &&\n rule.scope !== 'item' &&\n rule.fieldId !== undefined &&\n state.computed.get(rule.fieldId) === undefined\n ) {\n markComputedUndetermined(state, rule, UNKNOWN);\n }\n }\n }\n } finally {\n state.resolvingWriters = false;\n }\n}\n\n/**\n * Records the sentinel a writer could not resolve, so a read of its target propagates the\n * undetermined state instead of falling back to a submitted value the writer never approved.\n * A `defaultCompute` is only overlaid when its default applies; its callers decide that.\n *\n * An item-scoped writer records the entry for the row in force: a row's failed write is that\n * row's answer, not a verdict about its siblings.\n */\nexport function markComputedUndetermined(\n state: EvaluationState,\n rule: CompiledRule,\n sentinel: Undetermined,\n): void {\n if (rule.fieldId === undefined) return;\n if (rule.scope === 'item') {\n const target = rule.targetFieldId;\n const rowKey = state.currentRowKey;\n if (target === undefined || !state.prepared.writerIds.has(target)) return;\n // A refusal before the rows are read — notably a server-tier writer on a client — has\n // no row to key. The declaration-wide entry makes every row's target undetermined\n // without reading those rows; a row entry, when one exists, remains more specific.\n if (rowKey === undefined) {\n state.computed.set(target, undeterminedValue(sentinel));\n return;\n }\n state.computed.setRow(target, rowKey, undeterminedValue(sentinel));\n return;\n }\n if (!state.prepared.writerIds.has(rule.fieldId)) return;\n state.computed.set(rule.fieldId, undeterminedValue(sentinel));\n}\n\n/** The field one writer writes: the row member for an item writer, the field otherwise. */\nfunction writerTargetId(rule: CompiledRule): string | undefined {\n return rule.scope === 'item' ? rule.targetFieldId : rule.fieldId;\n}\n\n/**\n * One field a writer reads by identifier. A row-scoped writer reads the member through its\n * item binder, because the declaration path of an array member is not a path a record holds;\n * every other writer reads the declaration as usual.\n */\nfunction readWriterField(state: EvaluationState, rule: CompiledRule, fieldId: string): Evaluated {\n if (rule.scope === 'item') {\n return state.evaluator.evaluate({ kind: 'path', path: `$it.${fieldId}` });\n }\n return state.reader.read(state.reader.declarationPathOf(fieldId));\n}\n\n/**\n * One writer's semantic result.\n *\n * `compute` is the sole authority for its target: the expression's value, or the sentinel\n * that says it could not be produced, always shadows the submitted value.\n * `defaultCompute` states the exception the language defines: while an override record is\n * active the field keeps the value it already holds, so no overlay entry is recorded. An\n * override record this device cannot read leaves the default unapplied — the engine cannot\n * tell whether one is active — and records nothing rather than overwriting a stored value.\n */\nexport function resolveWriter(state: EvaluationState, rule: CompiledRule): WriterResolution {\n if (state.computedUnorderable) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n `computed field ${rule.fieldId ?? rule.ruleId} has no recalculation order, so its value cannot be produced`,\n rule.ruleId,\n );\n }\n if (rule.scope === 'item' && rule.targetFieldId === undefined) {\n throw new AxiomError(\n 'ENGINE_ERROR',\n 'an item-scoped computed rule declares the row member it writes',\n rule.ruleId,\n );\n }\n const targetId = writerTargetId(rule);\n const target = targetId === undefined ? undefined : state.prepared.fieldById.get(targetId);\n const path =\n targetId === undefined ? `$.rules.${rule.ruleId}` : state.reader.declarationPathOf(targetId);\n if (rule.kind === 'defaultCompute' && rule.overrideFieldId !== undefined) {\n // The companion is named by its immutable `fieldId`, which is not always the path it is\n // declared at, so it is resolved like any other field a rule names rather than read as one.\n const override = readWriterField(state, rule, rule.overrideFieldId);\n if (override.kind === 'value' && isUndetermined(override.value)) {\n return { value: undeterminedValue(override.value), overlay: false };\n }\n if (override.kind === 'value' && override.value !== null) {\n // An active override: the stored value is the field's value, and the report records it\n // for the same reason a read delivers it.\n if (targetId === undefined) {\n return { value: { kind: 'decided', value: null }, overlay: false };\n }\n const current = readWriterField(state, rule, targetId);\n if (current.kind === 'absent') {\n return { value: { kind: 'decided', value: null }, overlay: false };\n }\n if (isUndetermined(current.value)) {\n return { value: undeterminedValue(current.value), overlay: false };\n }\n const value =\n target === undefined\n ? current.value\n : toWireValue(current.value, path, wireDeclarationOf(target));\n return { value: { kind: 'decided', value }, overlay: false };\n }\n }\n return {\n value: renderComputedValue(target, state.evaluator.evaluate(rule.expr), path),\n overlay: true,\n };\n}\n"]}
@@ -0,0 +1,42 @@
1
+ import type { EvaluationEnv, EvaluationInput } from '../../model/access.js';
2
+ import type { CompiledSchema } from '../../model/schema.js';
3
+ import type { ComputedOverlay } from '../computed.js';
4
+ import type { AccessWindow } from '../access/window.js';
5
+ import type { EvaluationState } from './state.js';
6
+ /**
7
+ * What a caller may hand one evaluation beyond its inputs.
8
+ *
9
+ * A session that owns several passes supplies the computed overlay it retains between them,
10
+ * so a writer outside one pass's closure keeps the value its own last evaluation produced
11
+ * instead of falling back to the submission. The observer is how a counted pass trace sees
12
+ * rule evaluations without a private counter.
13
+ */
14
+ export interface EvaluationOptions {
15
+ readonly computed?: ComputedOverlay;
16
+ readonly onRuleEvaluated?: (ruleId: string) => void;
17
+ /**
18
+ * The committed ids of a host-assigned array, so an item rule or a row-addressed read names
19
+ * the row the session minted rather than a position, `[IDENT-2.1.4]`.
20
+ */
21
+ readonly assignedRowKeys?: (fieldId: string) => readonly (string | number)[] | undefined;
22
+ /**
23
+ * The access answer a boundary already resolved for this input and environment.
24
+ *
25
+ * `evaluateSubmission` resolves it inside its own catch so a body that supplies both an
26
+ * overlay and a projection — or an `accessVersion` its overlay never had — is answered as a
27
+ * refusal rather than thrown after the boundary; handing that window in keeps the check and
28
+ * the evaluation reading one answer instead of resolving the overlay twice.
29
+ */
30
+ readonly accessWindow?: AccessWindow;
31
+ }
32
+ /**
33
+ * One evaluation's state: its reader, its evaluator and the streams they record into.
34
+ *
35
+ * Building the state is separated from `Evaluation` so a pass can open a second one over the
36
+ * same inputs, access answer and writer overlay when it needs reads that must not enter the
37
+ * report — an option's availability condition, a rule's alternatives. Those readers answer the
38
+ * same questions as the report's, and their diagnostics, provenance and considered reads are
39
+ * discarded with them (`RULES-7.1.2`).
40
+ */
41
+ export declare function createEvaluationState(compiled: CompiledSchema, input: EvaluationInput, env: EvaluationEnv, options?: EvaluationOptions): EvaluationState;
42
+ //# sourceMappingURL=create-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-state.d.ts","sourceRoot":"","sources":["../../../src/eval/rule/create-state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC5E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAI5D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAKtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAMxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGlD;;;;;;;GAOG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,QAAQ,CAAC,EAAE,eAAe,CAAC;IACpC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpD;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GAAG,SAAS,CAAC;IACzF;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,YAAY,CAAC;CACtC;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,cAAc,EACxB,KAAK,EAAE,eAAe,EACtB,GAAG,EAAE,aAAa,EAClB,OAAO,GAAE,iBAAsB,GAC9B,eAAe,CA6HjB"}