@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,277 @@
1
+ import { canonicalizeRestricted } from '../../canonical/jcs.js';
2
+ import { compareCodePoints } from '../../expr/strings.js';
3
+ import { ProvenanceLedger } from '../../lookup/pass.js';
4
+ import { inspectDeps } from '../../graph/index.js';
5
+ import { prepareComputed } from '../rule/compute.js';
6
+ import { evaluateRuleOnce } from '../rule/execution.js';
7
+ import { freezeTree, reportStatus, sealReport } from '../seal.js';
8
+ /** A keyed record in code-point order, or `undefined` when it holds nothing. */
9
+ function sortedRecord(entries) {
10
+ if (entries.size === 0)
11
+ return undefined;
12
+ const sorted = {};
13
+ for (const key of [...entries.keys()].sort(compareCodePoints)) {
14
+ const value = entries.get(key);
15
+ if (value !== undefined)
16
+ sorted[key] = value;
17
+ }
18
+ return sorted;
19
+ }
20
+ /**
21
+ * The rank of one diagnostic: `(code, ruleId, fieldId, itemId)`, the identifiers its identity is
22
+ * made of. Two diagnostics with a non-zero rank comparison cannot state the same fact, because
23
+ * the canonical text begins with those same members.
24
+ *
25
+ * Ranking by the whole text instead let the *set* of optional members a diagnostic happens to
26
+ * carry dominate its identity: a field-scope `DEFERRED_SERVER_CHECK` carries `fieldId`, which
27
+ * sorts before a record-scope diagnostic's `messageKey`, so it preceded a record-scope
28
+ * diagnostic with the same code and an earlier `ruleId`. Adding an optional member later would
29
+ * reorder diagnostics that did not change. An absent member sorts before every present one
30
+ * because an identifier starts with a letter, so `''` sorts first.
31
+ */
32
+ function compareDiagnosticRank(left, right) {
33
+ return (compareCodePoints(left.code, right.code) ||
34
+ compareCodePoints(left.ruleId ?? '', right.ruleId ?? '') ||
35
+ compareCodePoints(left.fieldId ?? '', right.fieldId ?? '') ||
36
+ compareCodePoints(left.itemId ?? '', right.itemId ?? ''));
37
+ }
38
+ /**
39
+ * The canonical order: the rank above, with the diagnostic's own canonical text as the final
40
+ * tiebreak.
41
+ *
42
+ * The text is read through `tokenOf` rather than carried on the entry, so a comparison the rank
43
+ * already decides never canonicalises anything. Two diagnostics can share a token only by
44
+ * stating the same code and the same rule, field and item, so a report whose diagnostics all
45
+ * rank distinctly — the ordinary shape, one per rule or per row — pays no canonicalisation at
46
+ * all.
47
+ */
48
+ function compareDiagnostics(left, right, tokenOf) {
49
+ return compareDiagnosticRank(left, right) || compareCodePoints(tokenOf(left), tokenOf(right));
50
+ }
51
+ /**
52
+ * A canonical token per diagnostic object, computed at most once per assembly.
53
+ *
54
+ * The memo is per assembly rather than per process: a diagnostic is the engine's own value but
55
+ * it is not frozen until the body that carries it is (`freezeTree`), and a token cached across
56
+ * assemblies would outlive the value it describes. Within one assembly the same object can
57
+ * arrive through several contributions when a session replays a cached rule, and then its text
58
+ * is walked once. `WeakMap` keeps the memo from retaining a diagnostic a report dropped.
59
+ */
60
+ function diagnosticTokens() {
61
+ const tokens = new WeakMap();
62
+ return (diagnostic) => {
63
+ let token = tokens.get(diagnostic);
64
+ if (token === undefined) {
65
+ token = canonicalizeRestricted(diagnostic);
66
+ tokens.set(diagnostic, token);
67
+ }
68
+ return token;
69
+ };
70
+ }
71
+ /** The access answer this evaluation resolved, in the report's canonical order. */
72
+ function accessProjection(state, contributions) {
73
+ return state.accessWindow.reportEntries(contributions.flatMap((entry) => entry.considered));
74
+ }
75
+ /** The contribution one rule made to the evaluation in progress. */
76
+ function contributionOf(state, rule) {
77
+ return {
78
+ ruleId: rule.ruleId,
79
+ evaluation: evaluateRuleOnce(state, rule),
80
+ considered: state.reader.consideredFor(rule.ruleId),
81
+ diagnostics: state.ruleDiagnostics.get(rule.ruleId) ?? [],
82
+ lookups: state.provenance.forRule(rule.ruleId),
83
+ };
84
+ }
85
+ /**
86
+ * Evaluates the selected rules and returns one contribution per rule that ran.
87
+ *
88
+ * Two `visible` rules may ask `is_relevant` about each other. There is no consistent answer to
89
+ * that pair, so the documented fail-open rule decides one of them; which one must not depend on
90
+ * where the author wrote the declarations (`RULES-2.1.12`). Entering the visible rules first, in
91
+ * `ruleId` code-point order, fixes the answer before any other rule can ask.
92
+ *
93
+ * A rule pulled in by `rule_ok` or `is_relevant` runs under its own identity, so the returned
94
+ * list covers every rule the call actually evaluated, not only the ones it was handed.
95
+ */
96
+ export function evaluateContributions(state, rules) {
97
+ const visibilityRules = rules
98
+ .filter((rule) => rule.kind === 'visible')
99
+ .sort((left, right) => compareCodePoints(left.ruleId, right.ruleId));
100
+ for (const rule of visibilityRules)
101
+ evaluateRuleOnce(state, rule);
102
+ for (const rule of rules)
103
+ evaluateRuleOnce(state, rule);
104
+ return [...state.ruleOutcomes.keys()].map((rule) => contributionOf(state, rule));
105
+ }
106
+ /**
107
+ * Assembles the canonical report from contributions, and nothing else.
108
+ *
109
+ * Every emitted list is in a canonical order, so a report states the same thing however its
110
+ * contributions were produced or ordered: two documents that differ only in declaration order
111
+ * decide identically and hash identically.
112
+ */
113
+ export function assembleBody(state, contributions, unattributedDiagnostics = []) {
114
+ const results = [];
115
+ const gates = new Map();
116
+ const screens = new Map();
117
+ for (const contribution of contributions) {
118
+ const evaluated = contribution.evaluation;
119
+ // An item rule answers once per row, and a legal record can hold a million of them. A
120
+ // spread here would call `push` with that many arguments and overflow the stack after
121
+ // every rule had already run, turning a legal form into a bare `RangeError` instead of a
122
+ // report. Append one at a time; the array is the only thing that grows.
123
+ for (const result of evaluated.results)
124
+ results.push(result);
125
+ // Every declared gate and screen is keyed by its rule's `ruleId`. The compiler refuses a
126
+ // document that declares one without designating it, so the section and the root scalar
127
+ // always agree about which entry a caller that names none gets.
128
+ if (evaluated.gate !== undefined)
129
+ gates.set(evaluated.gate.gateId, evaluated.gate.report);
130
+ if (evaluated.screen !== undefined) {
131
+ screens.set(evaluated.screen.screenId, evaluated.screen.report);
132
+ }
133
+ }
134
+ const keyedGates = sortedRecord(gates);
135
+ const keyedScreens = sortedRecord(screens);
136
+ // A rule's verdict is a fact about the record, not about where its author wrote it: two
137
+ // documents that differ only in declaration order decide identically, so their reports must
138
+ // hash identically. `RULES-1.1.4` already imposes this on a target list, and gate/screen
139
+ // sections are keyed for the same reason.
140
+ results.sort((left, right) => compareCodePoints(left.ruleId, right.ruleId));
141
+ // Diagnostics are raised while rules run, so their insertion order follows production order,
142
+ // and production order is topological: two unrelated declarations may swap it. A diagnostic's
143
+ // identity is what it says, not when it was raised, so the report ranks them by
144
+ // `(code, ruleId, fieldId, itemId)` and falls back to their canonical text only to break a
145
+ // tie. `compareDiagnostics` is the one authority for that order.
146
+ // A diagnostic raised outside any rule has no contribution to ride in, so it is appended from
147
+ // the evaluation's own stream rather than dropped from the report that must carry it.
148
+ const unattributed = [
149
+ ...state.diagnostics.filter((diagnostic) => !state.diagnosticOwners.has(diagnostic)),
150
+ ...unattributedDiagnostics,
151
+ ];
152
+ // A diagnostic's identity is the fact it states, not the rule that happened to record it
153
+ // first: a refused read of a hidden container is one fact, and a session replaying per-rule
154
+ // contributions could otherwise state it once per rule that observed it. The report is a set
155
+ // of facts in canonical order, so the identical ones collapse to the first. Two diagnostics
156
+ // can hold the same token only when their ranks are equal, so the token is read for an
157
+ // adjacent pair only when that happens. Because the order is the rank and then the text, the
158
+ // duplicates are adjacent once ranked, and one pass over the sorted list removes them all.
159
+ const tokenOf = diagnosticTokens();
160
+ const ranked = [...contributions.flatMap((entry) => entry.diagnostics), ...unattributed];
161
+ ranked.sort((left, right) => compareDiagnostics(left, right, tokenOf));
162
+ const orderedDiagnostics = [];
163
+ let previous;
164
+ for (const diagnostic of ranked) {
165
+ if (previous !== undefined &&
166
+ compareDiagnosticRank(previous, diagnostic) === 0 &&
167
+ tokenOf(previous) === tokenOf(diagnostic)) {
168
+ continue;
169
+ }
170
+ orderedDiagnostics.push(diagnostic);
171
+ previous = diagnostic;
172
+ }
173
+ const ledger = new ProvenanceLedger();
174
+ for (const contribution of contributions) {
175
+ for (const entry of contribution.lookups)
176
+ ledger.record(entry, undefined);
177
+ }
178
+ // The artifact's designation is the one authority for the primary. Deriving it from the
179
+ // section's key count reported no primary for a schema that declared two gates, and choosing
180
+ // one by declaration order would make a presentation decision out of an accident of authoring.
181
+ const primaryGateId = state.compiled.primaryGateId;
182
+ const primaryScreenId = state.compiled.primaryScreenId;
183
+ const composition = state.compiled.composition;
184
+ const body = {
185
+ schemaId: state.compiled.schemaId,
186
+ schemaVersion: state.compiled.schemaVersion,
187
+ exprVersion: state.compiled.exprVersion,
188
+ behaviorHash: state.prepared.behaviorHash,
189
+ status: reportStatus(results, orderedDiagnostics),
190
+ accessVersion: state.accessWindow.version,
191
+ access: accessProjection(state, contributions),
192
+ rules: results,
193
+ ...(keyedGates === undefined ? {} : { gates: keyedGates }),
194
+ ...(keyedScreens === undefined ? {} : { screens: keyedScreens }),
195
+ ...(primaryGateId === undefined ? {} : { primaryGateId }),
196
+ ...(primaryScreenId === undefined ? {} : { primaryScreenId }),
197
+ ...(composition === undefined ? {} : { composition }),
198
+ diagnostics: orderedDiagnostics,
199
+ lookups: ledger.all(),
200
+ };
201
+ // A body is evidence the moment it is stated, so it is frozen like a sealed report. Freezing
202
+ // walks the tree once and allocates nothing; the digest a seal adds is what a keystroke skips.
203
+ return freezeTree(body);
204
+ }
205
+ /**
206
+ * Assembles the canonical report and seals it once, `[ENGINE-7.1.2]`.
207
+ *
208
+ * A stateless evaluation returns a decision, so it states the digest. A session that derives a
209
+ * form on every keystroke assembles the body instead and seals only when a caller asks for the
210
+ * report, because canonicalising and hashing is the cost of proving a decision, not of
211
+ * describing one.
212
+ */
213
+ export function assembleReport(state, contributions, unattributedDiagnostics = []) {
214
+ return sealReport(assembleBody(state, contributions, unattributedDiagnostics));
215
+ }
216
+ /**
217
+ * Evaluates and assembles one report, once per evaluation.
218
+ *
219
+ * Every writer produces its value before any ordinary rule reads one, in the one order the
220
+ * derived graph states.
221
+ */
222
+ export function runBody(state) {
223
+ const cached = state.body;
224
+ if (cached !== undefined)
225
+ return cached;
226
+ prepareComputed(state, (rule) => evaluateRuleOnce(state, rule));
227
+ const contributions = evaluateContributions(state, state.compiled.rules ?? []);
228
+ const body = assembleBody(state, contributions);
229
+ // The report carries a copy of this stream, so a diagnostic recorded after the seal would be
230
+ // dropped while `reportStatus` had already folded the stream into the verdict. No path can
231
+ // legitimately record one here — every writer and rule has run above, and the post-report
232
+ // readers only project what the evaluation resolved — so freezing the stream makes a future
233
+ // one fail instead of leaving a report that disagrees with itself.
234
+ Object.freeze(state.diagnostics);
235
+ state.body = body;
236
+ return body;
237
+ }
238
+ /** Evaluates and assembles one report body, sealed once for a caller that wants the digest. */
239
+ export function runReport(state) {
240
+ return (state.report ??= sealReport(runBody(state)));
241
+ }
242
+ /**
243
+ * The audit trail of this evaluation's explain(): what each rule read and resolved.
244
+ */
245
+ export function explanationOf(state) {
246
+ const report = runReport(state);
247
+ const dependencies = inspectDeps(state.compiled);
248
+ // Indexed once: a report holds one result per rule per row, and a linear scan per result
249
+ // turned an explanation of a large form into a quadratic walk.
250
+ const dependencyById = dependencies.ok
251
+ ? new Map(dependencies.report.rules.map((entry) => [entry.ruleId, entry]))
252
+ : undefined;
253
+ const rules = report.rules.map((result) => {
254
+ const dependency = dependencyById?.get(result.ruleId);
255
+ return {
256
+ ruleId: result.ruleId,
257
+ ruleHash: result.ruleHash,
258
+ kind: result.kind,
259
+ scope: result.scope,
260
+ status: result.status,
261
+ ...(result.rowKey === undefined ? {} : { rowKey: result.rowKey }),
262
+ reads: result.fields ?? [],
263
+ dependsOnRules: dependency?.dependsOnRules ?? [],
264
+ lookups: state.provenance.forRule(result.ruleId),
265
+ diagnostics: state.ruleDiagnostics.get(result.ruleId) ?? [],
266
+ };
267
+ });
268
+ return {
269
+ schemaId: report.schemaId,
270
+ schemaVersion: report.schemaVersion,
271
+ behaviorHash: report.behaviorHash,
272
+ reportHash: report.reportHash,
273
+ rules,
274
+ lookups: report.lookups,
275
+ };
276
+ }
277
+ //# sourceMappingURL=assemble.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assemble.js","sourceRoot":"","sources":["../../../src/eval/report/assemble.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAanD,OAAO,EAAE,eAAe,EAAE,MAAM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YACjB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,GAAG,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC;YACjE,KAAK,EAAE,MAAM,CAAC,MAAM,IAAI,EAAE;YAC1B,cAAc,EAAE,UAAU,EAAE,cAAc,IAAI,EAAE;YAChD,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;YAChD,WAAW,EAAE,KAAK,CAAC,eAAe,CAAC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE;SAC5D,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO;QACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,YAAY,EAAE,MAAM,CAAC,YAAY;QACjC,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,KAAK;QACL,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import { canonicalizeRestricted } from '../../canonical/jcs.js';\nimport { compareCodePoints } from '../../expr/strings.js';\nimport { ProvenanceLedger } from '../../lookup/pass.js';\nimport { inspectDeps } from '../../graph/index.js';\nimport type {\n CompiledRule,\n Diagnostic,\n EvaluationReport,\n FieldRef,\n GateReport,\n LookupProvenance,\n RuleKind,\n RuleResult,\n ScreenReport,\n} from '../../model/types.js';\nimport type { ReportAccessEntry, ReportFacts } from '../../model/types.js';\nimport { prepareComputed } from '../rule/compute.js';\nimport { evaluateRuleOnce } from '../rule/execution.js';\nimport type { EvaluationState, RuleEvaluation } from '../rule/state.js';\nimport { freezeTree, reportStatus, sealReport } from '../seal.js';\n\n/** A keyed record in code-point order, or `undefined` when it holds nothing. */\nfunction sortedRecord<T>(entries: ReadonlyMap<string, T>): Readonly<Record<string, T>> | undefined {\n if (entries.size === 0) return undefined;\n const sorted: Record<string, T> = {};\n for (const key of [...entries.keys()].sort(compareCodePoints)) {\n const value = entries.get(key);\n if (value !== undefined) sorted[key] = value;\n }\n return sorted;\n}\n\n/**\n * The rank of one diagnostic: `(code, ruleId, fieldId, itemId)`, the identifiers its identity is\n * made of. Two diagnostics with a non-zero rank comparison cannot state the same fact, because\n * the canonical text begins with those same members.\n *\n * Ranking by the whole text instead let the *set* of optional members a diagnostic happens to\n * carry dominate its identity: a field-scope `DEFERRED_SERVER_CHECK` carries `fieldId`, which\n * sorts before a record-scope diagnostic's `messageKey`, so it preceded a record-scope\n * diagnostic with the same code and an earlier `ruleId`. Adding an optional member later would\n * reorder diagnostics that did not change. An absent member sorts before every present one\n * because an identifier starts with a letter, so `''` sorts first.\n */\nfunction compareDiagnosticRank(left: Diagnostic, right: Diagnostic): number {\n return (\n compareCodePoints(left.code, right.code) ||\n compareCodePoints(left.ruleId ?? '', right.ruleId ?? '') ||\n compareCodePoints(left.fieldId ?? '', right.fieldId ?? '') ||\n compareCodePoints(left.itemId ?? '', right.itemId ?? '')\n );\n}\n\n/**\n * The canonical order: the rank above, with the diagnostic's own canonical text as the final\n * tiebreak.\n *\n * The text is read through `tokenOf` rather than carried on the entry, so a comparison the rank\n * already decides never canonicalises anything. Two diagnostics can share a token only by\n * stating the same code and the same rule, field and item, so a report whose diagnostics all\n * rank distinctly — the ordinary shape, one per rule or per row — pays no canonicalisation at\n * all.\n */\nfunction compareDiagnostics(\n left: Diagnostic,\n right: Diagnostic,\n tokenOf: (diagnostic: Diagnostic) => string,\n): number {\n return compareDiagnosticRank(left, right) || compareCodePoints(tokenOf(left), tokenOf(right));\n}\n\n/**\n * A canonical token per diagnostic object, computed at most once per assembly.\n *\n * The memo is per assembly rather than per process: a diagnostic is the engine's own value but\n * it is not frozen until the body that carries it is (`freezeTree`), and a token cached across\n * assemblies would outlive the value it describes. Within one assembly the same object can\n * arrive through several contributions when a session replays a cached rule, and then its text\n * is walked once. `WeakMap` keeps the memo from retaining a diagnostic a report dropped.\n */\nfunction diagnosticTokens(): (diagnostic: Diagnostic) => string {\n const tokens = new WeakMap<Diagnostic, string>();\n return (diagnostic) => {\n let token = tokens.get(diagnostic);\n if (token === undefined) {\n token = canonicalizeRestricted(diagnostic);\n tokens.set(diagnostic, token);\n }\n return token;\n };\n}\n\n/** The access answer this evaluation resolved, in the report's canonical order. */\nfunction accessProjection(\n state: EvaluationState,\n contributions: readonly RuleContribution[],\n): readonly ReportAccessEntry[] {\n return state.accessWindow.reportEntries(contributions.flatMap((entry) => entry.considered));\n}\n\n/**\n * One rule's whole contribution to a report: its result, the access entries it considered, the\n * diagnostics it raised and the lookups it resolved.\n *\n * A report is a fold of these, and nothing else. Keeping the record explicit is what lets a\n * stateful session re-evaluate only the rules a change reaches and still state the same report\n * as a caller that evaluated every rule: the cached contributions of the untouched rules are\n * replayed beside the new ones, in the same canonical order.\n */\nexport interface RuleContribution {\n readonly ruleId: string;\n readonly evaluation: RuleEvaluation;\n readonly considered: readonly FieldRef[];\n readonly diagnostics: readonly Diagnostic[];\n readonly lookups: readonly LookupProvenance[];\n}\n\n/** The contribution one rule made to the evaluation in progress. */\nfunction contributionOf(state: EvaluationState, rule: CompiledRule): RuleContribution {\n return {\n ruleId: rule.ruleId,\n evaluation: evaluateRuleOnce(state, rule),\n considered: state.reader.consideredFor(rule.ruleId),\n diagnostics: state.ruleDiagnostics.get(rule.ruleId) ?? [],\n lookups: state.provenance.forRule(rule.ruleId),\n };\n}\n\n/**\n * Evaluates the selected rules and returns one contribution per rule that ran.\n *\n * Two `visible` rules may ask `is_relevant` about each other. There is no consistent answer to\n * that pair, so the documented fail-open rule decides one of them; which one must not depend on\n * where the author wrote the declarations (`RULES-2.1.12`). Entering the visible rules first, in\n * `ruleId` code-point order, fixes the answer before any other rule can ask.\n *\n * A rule pulled in by `rule_ok` or `is_relevant` runs under its own identity, so the returned\n * list covers every rule the call actually evaluated, not only the ones it was handed.\n */\nexport function evaluateContributions(\n state: EvaluationState,\n rules: readonly CompiledRule[],\n): readonly RuleContribution[] {\n const visibilityRules = rules\n .filter((rule) => rule.kind === 'visible')\n .sort((left, right) => compareCodePoints(left.ruleId, right.ruleId));\n for (const rule of visibilityRules) evaluateRuleOnce(state, rule);\n for (const rule of rules) evaluateRuleOnce(state, rule);\n return [...state.ruleOutcomes.keys()].map((rule) => contributionOf(state, rule));\n}\n\n/**\n * Assembles the canonical report from contributions, and nothing else.\n *\n * Every emitted list is in a canonical order, so a report states the same thing however its\n * contributions were produced or ordered: two documents that differ only in declaration order\n * decide identically and hash identically.\n */\nexport function assembleBody(\n state: EvaluationState,\n contributions: readonly RuleContribution[],\n unattributedDiagnostics: readonly Diagnostic[] = [],\n): ReportFacts {\n const results: RuleResult[] = [];\n const gates = new Map<string, GateReport>();\n const screens = new Map<string, ScreenReport>();\n for (const contribution of contributions) {\n const evaluated = contribution.evaluation;\n // An item rule answers once per row, and a legal record can hold a million of them. A\n // spread here would call `push` with that many arguments and overflow the stack after\n // every rule had already run, turning a legal form into a bare `RangeError` instead of a\n // report. Append one at a time; the array is the only thing that grows.\n for (const result of evaluated.results) results.push(result);\n // Every declared gate and screen is keyed by its rule's `ruleId`. The compiler refuses a\n // document that declares one without designating it, so the section and the root scalar\n // always agree about which entry a caller that names none gets.\n if (evaluated.gate !== undefined) gates.set(evaluated.gate.gateId, evaluated.gate.report);\n if (evaluated.screen !== undefined) {\n screens.set(evaluated.screen.screenId, evaluated.screen.report);\n }\n }\n const keyedGates = sortedRecord(gates);\n const keyedScreens = sortedRecord(screens);\n // A rule's verdict is a fact about the record, not about where its author wrote it: two\n // documents that differ only in declaration order decide identically, so their reports must\n // hash identically. `RULES-1.1.4` already imposes this on a target list, and gate/screen\n // sections are keyed for the same reason.\n results.sort((left, right) => compareCodePoints(left.ruleId, right.ruleId));\n // Diagnostics are raised while rules run, so their insertion order follows production order,\n // and production order is topological: two unrelated declarations may swap it. A diagnostic's\n // identity is what it says, not when it was raised, so the report ranks them by\n // `(code, ruleId, fieldId, itemId)` and falls back to their canonical text only to break a\n // tie. `compareDiagnostics` is the one authority for that order.\n // A diagnostic raised outside any rule has no contribution to ride in, so it is appended from\n // the evaluation's own stream rather than dropped from the report that must carry it.\n const unattributed = [\n ...state.diagnostics.filter((diagnostic) => !state.diagnosticOwners.has(diagnostic)),\n ...unattributedDiagnostics,\n ];\n // A diagnostic's identity is the fact it states, not the rule that happened to record it\n // first: a refused read of a hidden container is one fact, and a session replaying per-rule\n // contributions could otherwise state it once per rule that observed it. The report is a set\n // of facts in canonical order, so the identical ones collapse to the first. Two diagnostics\n // can hold the same token only when their ranks are equal, so the token is read for an\n // adjacent pair only when that happens. Because the order is the rank and then the text, the\n // duplicates are adjacent once ranked, and one pass over the sorted list removes them all.\n const tokenOf = diagnosticTokens();\n const ranked = [...contributions.flatMap((entry) => entry.diagnostics), ...unattributed];\n ranked.sort((left, right) => compareDiagnostics(left, right, tokenOf));\n const orderedDiagnostics: Diagnostic[] = [];\n let previous: Diagnostic | undefined;\n for (const diagnostic of ranked) {\n if (\n previous !== undefined &&\n compareDiagnosticRank(previous, diagnostic) === 0 &&\n tokenOf(previous) === tokenOf(diagnostic)\n ) {\n continue;\n }\n orderedDiagnostics.push(diagnostic);\n previous = diagnostic;\n }\n const ledger = new ProvenanceLedger();\n for (const contribution of contributions) {\n for (const entry of contribution.lookups) ledger.record(entry, undefined);\n }\n // The artifact's designation is the one authority for the primary. Deriving it from the\n // section's key count reported no primary for a schema that declared two gates, and choosing\n // one by declaration order would make a presentation decision out of an accident of authoring.\n const primaryGateId = state.compiled.primaryGateId;\n const primaryScreenId = state.compiled.primaryScreenId;\n const composition = state.compiled.composition;\n const body = {\n schemaId: state.compiled.schemaId,\n schemaVersion: state.compiled.schemaVersion,\n exprVersion: state.compiled.exprVersion,\n behaviorHash: state.prepared.behaviorHash,\n status: reportStatus(results, orderedDiagnostics),\n accessVersion: state.accessWindow.version,\n access: accessProjection(state, contributions),\n rules: results,\n ...(keyedGates === undefined ? {} : { gates: keyedGates }),\n ...(keyedScreens === undefined ? {} : { screens: keyedScreens }),\n ...(primaryGateId === undefined ? {} : { primaryGateId }),\n ...(primaryScreenId === undefined ? {} : { primaryScreenId }),\n ...(composition === undefined ? {} : { composition }),\n diagnostics: orderedDiagnostics,\n lookups: ledger.all(),\n } satisfies ReportFacts;\n // A body is evidence the moment it is stated, so it is frozen like a sealed report. Freezing\n // walks the tree once and allocates nothing; the digest a seal adds is what a keystroke skips.\n return freezeTree(body);\n}\n\n/**\n * Assembles the canonical report and seals it once, `[ENGINE-7.1.2]`.\n *\n * A stateless evaluation returns a decision, so it states the digest. A session that derives a\n * form on every keystroke assembles the body instead and seals only when a caller asks for the\n * report, because canonicalising and hashing is the cost of proving a decision, not of\n * describing one.\n */\nexport function assembleReport(\n state: EvaluationState,\n contributions: readonly RuleContribution[],\n unattributedDiagnostics: readonly Diagnostic[] = [],\n): EvaluationReport {\n return sealReport(assembleBody(state, contributions, unattributedDiagnostics));\n}\n\n/**\n * Evaluates and assembles one report, once per evaluation.\n *\n * Every writer produces its value before any ordinary rule reads one, in the one order the\n * derived graph states.\n */\nexport function runBody(state: EvaluationState): ReportFacts {\n const cached = state.body;\n if (cached !== undefined) return cached;\n prepareComputed(state, (rule) => evaluateRuleOnce(state, rule));\n const contributions = evaluateContributions(state, state.compiled.rules ?? []);\n const body = assembleBody(state, contributions);\n // The report carries a copy of this stream, so a diagnostic recorded after the seal would be\n // dropped while `reportStatus` had already folded the stream into the verdict. No path can\n // legitimately record one here — every writer and rule has run above, and the post-report\n // readers only project what the evaluation resolved — so freezing the stream makes a future\n // one fail instead of leaving a report that disagrees with itself.\n Object.freeze(state.diagnostics);\n state.body = body;\n return body;\n}\n\n/** Evaluates and assembles one report body, sealed once for a caller that wants the digest. */\nexport function runReport(state: EvaluationState): EvaluationReport {\n return (state.report ??= sealReport(runBody(state)));\n}\n\n/** One rule's audit trail: what it read, what it depended on and where it resolved a lookup. */\nexport interface RuleExplanation {\n readonly ruleId: string;\n readonly ruleHash: string;\n readonly kind: RuleKind;\n readonly scope: RuleResult['scope'];\n readonly status: RuleResult['status'];\n readonly rowKey?: string | number;\n readonly reads: readonly FieldRef[];\n readonly dependsOnRules: readonly string[];\n readonly lookups: readonly LookupProvenance[];\n readonly diagnostics: readonly Diagnostic[];\n}\n\n/** The audit trail of one stateless evaluation, `explain()`. */\nexport interface EvaluationExplanation {\n readonly schemaId: string;\n readonly schemaVersion: number;\n readonly behaviorHash: string;\n readonly reportHash: string;\n readonly rules: readonly RuleExplanation[];\n readonly lookups: readonly LookupProvenance[];\n}\n\n/**\n * The audit trail of this evaluation's explain(): what each rule read and resolved.\n */\nexport function explanationOf(state: EvaluationState): EvaluationExplanation {\n const report = runReport(state);\n const dependencies = inspectDeps(state.compiled);\n // Indexed once: a report holds one result per rule per row, and a linear scan per result\n // turned an explanation of a large form into a quadratic walk.\n const dependencyById = dependencies.ok\n ? new Map(dependencies.report.rules.map((entry) => [entry.ruleId, entry]))\n : undefined;\n const rules: RuleExplanation[] = report.rules.map((result) => {\n const dependency = dependencyById?.get(result.ruleId);\n return {\n ruleId: result.ruleId,\n ruleHash: result.ruleHash,\n kind: result.kind,\n scope: result.scope,\n status: result.status,\n ...(result.rowKey === undefined ? {} : { rowKey: result.rowKey }),\n reads: result.fields ?? [],\n dependsOnRules: dependency?.dependsOnRules ?? [],\n lookups: state.provenance.forRule(result.ruleId),\n diagnostics: state.ruleDiagnostics.get(result.ruleId) ?? [],\n };\n });\n return {\n schemaId: report.schemaId,\n schemaVersion: report.schemaVersion,\n behaviorHash: report.behaviorHash,\n reportHash: report.reportHash,\n rules,\n lookups: report.lookups,\n };\n}\n"]}
@@ -0,0 +1,18 @@
1
+ import type { Outcome, ScreenOutcome } from '../../model/types.js';
2
+ /**
3
+ * A screen's five-state outcome from its base expression and its `referWhen` condition.
4
+ *
5
+ * `referWhen` is a condition, not a decision: it either holds (`PASS`, producing
6
+ * `SCREEN_REFER`), is undecided (`UNKNOWN`/`DEFERRED`, contributing that state), or does not
7
+ * hold (`FAIL`, contributing nothing). The winner is the highest-ranked state, so a base
8
+ * failure stays `SCREEN_FAIL` even when the record also needs review, and an undecided screen
9
+ * is never promoted to a pass.
10
+ */
11
+ export declare function foldScreen(base: Outcome, refer: Outcome): ScreenOutcome;
12
+ /**
13
+ * The rule status a screen outcome reports. `SCREEN_REFER` is a decision that the record needs a
14
+ * human, so it is not `PASS`; both non-pass decided outcomes report `FAIL`, and the two
15
+ * undecided states keep their own outcome.
16
+ */
17
+ export declare function screenStatus(outcome: ScreenOutcome): Outcome;
18
+ //# sourceMappingURL=fold.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fold.d.ts","sourceRoot":"","sources":["../../../src/eval/report/fold.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AA4BnE;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,aAAa,CAKvE;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAW5D"}
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The five screen states in their precedence, highest first: `UNKNOWN` > `DEFERRED` >
3
+ * `SCREEN_FAIL` > `SCREEN_REFER` > `SCREEN_PASS`. The undecided states outrank every decided
4
+ * one, and a failure always beats a referral.
5
+ */
6
+ const SCREEN_RANK = {
7
+ UNKNOWN: 4,
8
+ DEFERRED: 3,
9
+ SCREEN_FAIL: 2,
10
+ SCREEN_REFER: 1,
11
+ SCREEN_PASS: 0,
12
+ };
13
+ /** A base outcome as the screen state it decides. */
14
+ function screenState(outcome) {
15
+ switch (outcome) {
16
+ case 'PASS':
17
+ return 'SCREEN_PASS';
18
+ case 'FAIL':
19
+ return 'SCREEN_FAIL';
20
+ case 'UNKNOWN':
21
+ case 'DEFERRED':
22
+ return outcome;
23
+ }
24
+ }
25
+ /**
26
+ * A screen's five-state outcome from its base expression and its `referWhen` condition.
27
+ *
28
+ * `referWhen` is a condition, not a decision: it either holds (`PASS`, producing
29
+ * `SCREEN_REFER`), is undecided (`UNKNOWN`/`DEFERRED`, contributing that state), or does not
30
+ * hold (`FAIL`, contributing nothing). The winner is the highest-ranked state, so a base
31
+ * failure stays `SCREEN_FAIL` even when the record also needs review, and an undecided screen
32
+ * is never promoted to a pass.
33
+ */
34
+ export function foldScreen(base, refer) {
35
+ const baseState = screenState(base);
36
+ if (refer === 'FAIL')
37
+ return baseState;
38
+ const referState = refer === 'PASS' ? 'SCREEN_REFER' : refer;
39
+ return SCREEN_RANK[referState] > SCREEN_RANK[baseState] ? referState : baseState;
40
+ }
41
+ /**
42
+ * The rule status a screen outcome reports. `SCREEN_REFER` is a decision that the record needs a
43
+ * human, so it is not `PASS`; both non-pass decided outcomes report `FAIL`, and the two
44
+ * undecided states keep their own outcome.
45
+ */
46
+ export function screenStatus(outcome) {
47
+ switch (outcome) {
48
+ case 'SCREEN_PASS':
49
+ return 'PASS';
50
+ case 'SCREEN_FAIL':
51
+ case 'SCREEN_REFER':
52
+ return 'FAIL';
53
+ case 'UNKNOWN':
54
+ case 'DEFERRED':
55
+ return outcome;
56
+ }
57
+ }
58
+ //# sourceMappingURL=fold.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fold.js","sourceRoot":"","sources":["../../../src/eval/report/fold.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,GAA4C;IAC3D,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,CAAC;IACX,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,CAAC;IACf,WAAW,EAAE,CAAC;CACf,CAAC;AAEF,qDAAqD;AACrD,SAAS,WAAW,CAAC,OAAgB;IACnC,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,MAAM;YACT,OAAO,aAAa,CAAC;QACvB,KAAK,MAAM;YACT,OAAO,aAAa,CAAC;QACvB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU;YACb,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CAAC,IAAa,EAAE,KAAc;IACtD,MAAM,SAAS,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACpC,IAAI,KAAK,KAAK,MAAM;QAAE,OAAO,SAAS,CAAC;IACvC,MAAM,UAAU,GAAkB,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5E,OAAO,WAAW,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;AACnF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,OAAsB;IACjD,QAAQ,OAAO,EAAE,CAAC;QAChB,KAAK,aAAa;YAChB,OAAO,MAAM,CAAC;QAChB,KAAK,aAAa,CAAC;QACnB,KAAK,cAAc;YACjB,OAAO,MAAM,CAAC;QAChB,KAAK,SAAS,CAAC;QACf,KAAK,UAAU;YACb,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC","sourcesContent":["import type { Outcome, ScreenOutcome } from '../../model/types.js';\n\n/**\n * The five screen states in their precedence, highest first: `UNKNOWN` > `DEFERRED` >\n * `SCREEN_FAIL` > `SCREEN_REFER` > `SCREEN_PASS`. The undecided states outrank every decided\n * one, and a failure always beats a referral.\n */\nconst SCREEN_RANK: Readonly<Record<ScreenOutcome, number>> = {\n UNKNOWN: 4,\n DEFERRED: 3,\n SCREEN_FAIL: 2,\n SCREEN_REFER: 1,\n SCREEN_PASS: 0,\n};\n\n/** A base outcome as the screen state it decides. */\nfunction screenState(outcome: Outcome): ScreenOutcome {\n switch (outcome) {\n case 'PASS':\n return 'SCREEN_PASS';\n case 'FAIL':\n return 'SCREEN_FAIL';\n case 'UNKNOWN':\n case 'DEFERRED':\n return outcome;\n }\n}\n\n/**\n * A screen's five-state outcome from its base expression and its `referWhen` condition.\n *\n * `referWhen` is a condition, not a decision: it either holds (`PASS`, producing\n * `SCREEN_REFER`), is undecided (`UNKNOWN`/`DEFERRED`, contributing that state), or does not\n * hold (`FAIL`, contributing nothing). The winner is the highest-ranked state, so a base\n * failure stays `SCREEN_FAIL` even when the record also needs review, and an undecided screen\n * is never promoted to a pass.\n */\nexport function foldScreen(base: Outcome, refer: Outcome): ScreenOutcome {\n const baseState = screenState(base);\n if (refer === 'FAIL') return baseState;\n const referState: ScreenOutcome = refer === 'PASS' ? 'SCREEN_REFER' : refer;\n return SCREEN_RANK[referState] > SCREEN_RANK[baseState] ? referState : baseState;\n}\n\n/**\n * The rule status a screen outcome reports. `SCREEN_REFER` is a decision that the record needs a\n * human, so it is not `PASS`; both non-pass decided outcomes report `FAIL`, and the two\n * undecided states keep their own outcome.\n */\nexport function screenStatus(outcome: ScreenOutcome): Outcome {\n switch (outcome) {\n case 'SCREEN_PASS':\n return 'PASS';\n case 'SCREEN_FAIL':\n case 'SCREEN_REFER':\n return 'FAIL';\n case 'UNKNOWN':\n case 'DEFERRED':\n return outcome;\n }\n}\n"]}
@@ -0,0 +1,23 @@
1
+ import type { CompiledRule } from '../../model/types.js';
2
+ import type { EvaluatedAlternatives } from '../suggestions.js';
3
+ import type { EvaluationState } from './state.js';
4
+ /**
5
+ * The alternatives one `validate` rule offers for the verdict it just reached, `RULES-6.1.3`.
6
+ *
7
+ * Only a `FAIL` has alternatives to offer, so this is called for that status and no other: a rule
8
+ * that passed, could not decide, or defers to the server states none, and an artifact is never
9
+ * charged for evaluating an expression nobody can act on.
10
+ *
11
+ * The alternatives are read on a dedicated evaluation of this pass's inputs, access answer and
12
+ * writer overlay, exactly as an option's availability condition is (`RULES-7.1.2`): an expression
13
+ * that reads a value the report must withhold is how the filter learns to omit that alternative,
14
+ * and a report may not carry the read, the refusal or the lookup it took to find out. The row in
15
+ * force travels with them, so an `item`-scoped rule's `$it` and its `current` row still name the
16
+ * row that failed.
17
+ *
18
+ * A cost refusal from an alternative is returned with the answer rather than parked on the
19
+ * artifact, so the rule's result builder records it exactly once and no second evaluation of the
20
+ * same rule can inherit it.
21
+ */
22
+ export declare function ruleAlternatives(state: EvaluationState, rule: CompiledRule): EvaluatedAlternatives;
23
+ //# sourceMappingURL=alternatives.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alternatives.d.ts","sourceRoot":"","sources":["../../../src/eval/rule/alternatives.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAmBlD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,eAAe,EACtB,IAAI,EAAE,YAAY,GACjB,qBAAqB,CAUvB"}
@@ -0,0 +1,46 @@
1
+ import { evaluateSuggestions } from '../suggestions.js';
2
+ /**
3
+ * The evaluation alternatives are read on, built once per pass.
4
+ *
5
+ * One rule may fail on every row of a large list, and each of those verdicts offers the same
6
+ * alternatives. The state is built on first use and shared, because it is a reader rather than an
7
+ * answer: the rows it reads for one verdict do not change what it reads for the next.
8
+ */
9
+ const ALTERNATIVES = new WeakMap();
10
+ function alternativesStateOf(state) {
11
+ const cached = ALTERNATIVES.get(state);
12
+ if (cached !== undefined)
13
+ return cached;
14
+ const created = state.isolate();
15
+ ALTERNATIVES.set(state, created);
16
+ return created;
17
+ }
18
+ /**
19
+ * The alternatives one `validate` rule offers for the verdict it just reached, `RULES-6.1.3`.
20
+ *
21
+ * Only a `FAIL` has alternatives to offer, so this is called for that status and no other: a rule
22
+ * that passed, could not decide, or defers to the server states none, and an artifact is never
23
+ * charged for evaluating an expression nobody can act on.
24
+ *
25
+ * The alternatives are read on a dedicated evaluation of this pass's inputs, access answer and
26
+ * writer overlay, exactly as an option's availability condition is (`RULES-7.1.2`): an expression
27
+ * that reads a value the report must withhold is how the filter learns to omit that alternative,
28
+ * and a report may not carry the read, the refusal or the lookup it took to find out. The row in
29
+ * force travels with them, so an `item`-scoped rule's `$it` and its `current` row still name the
30
+ * row that failed.
31
+ *
32
+ * A cost refusal from an alternative is returned with the answer rather than parked on the
33
+ * artifact, so the rule's result builder records it exactly once and no second evaluation of the
34
+ * same rule can inherit it.
35
+ */
36
+ export function ruleAlternatives(state, rule) {
37
+ const suggestions = rule.suggests;
38
+ if (suggestions === undefined || suggestions.length === 0)
39
+ return { suggestions: [] };
40
+ const isolated = alternativesStateOf(state);
41
+ // The row is an argument of this call, not a field of the shared isolate: the isolate is
42
+ // cached for the pass, and writing the row into it would let one verdict's row survive into
43
+ // the next reader of a state nobody re-derived.
44
+ return isolated.evaluator.withBinderScopes(state.evaluator.scopes, () => evaluateSuggestions(isolated, suggestions, state.currentRowKey));
45
+ }
46
+ //# sourceMappingURL=alternatives.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alternatives.js","sourceRoot":"","sources":["../../../src/eval/rule/alternatives.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAIxD;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,IAAI,OAAO,EAAoC,CAAC;AAErE,SAAS,mBAAmB,CAAC,KAAsB;IACjD,MAAM,MAAM,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACvC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;IAChC,YAAY,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;IACjC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,gBAAgB,CAC9B,KAAsB,EACtB,IAAkB;IAElB,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC;IAClC,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACtF,MAAM,QAAQ,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC5C,yFAAyF;IACzF,4FAA4F;IAC5F,gDAAgD;IAChD,OAAO,QAAQ,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,EAAE,GAAG,EAAE,CACtE,mBAAmB,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,CAChE,CAAC;AACJ,CAAC","sourcesContent":["import type { CompiledRule } from '../../model/types.js';\nimport { evaluateSuggestions } from '../suggestions.js';\nimport type { EvaluatedAlternatives } from '../suggestions.js';\nimport type { EvaluationState } from './state.js';\n\n/**\n * The evaluation alternatives are read on, built once per pass.\n *\n * One rule may fail on every row of a large list, and each of those verdicts offers the same\n * alternatives. The state is built on first use and shared, because it is a reader rather than an\n * answer: the rows it reads for one verdict do not change what it reads for the next.\n */\nconst ALTERNATIVES = new WeakMap<EvaluationState, EvaluationState>();\n\nfunction alternativesStateOf(state: EvaluationState): EvaluationState {\n const cached = ALTERNATIVES.get(state);\n if (cached !== undefined) return cached;\n const created = state.isolate();\n ALTERNATIVES.set(state, created);\n return created;\n}\n\n/**\n * The alternatives one `validate` rule offers for the verdict it just reached, `RULES-6.1.3`.\n *\n * Only a `FAIL` has alternatives to offer, so this is called for that status and no other: a rule\n * that passed, could not decide, or defers to the server states none, and an artifact is never\n * charged for evaluating an expression nobody can act on.\n *\n * The alternatives are read on a dedicated evaluation of this pass's inputs, access answer and\n * writer overlay, exactly as an option's availability condition is (`RULES-7.1.2`): an expression\n * that reads a value the report must withhold is how the filter learns to omit that alternative,\n * and a report may not carry the read, the refusal or the lookup it took to find out. The row in\n * force travels with them, so an `item`-scoped rule's `$it` and its `current` row still name the\n * row that failed.\n *\n * A cost refusal from an alternative is returned with the answer rather than parked on the\n * artifact, so the rule's result builder records it exactly once and no second evaluation of the\n * same rule can inherit it.\n */\nexport function ruleAlternatives(\n state: EvaluationState,\n rule: CompiledRule,\n): EvaluatedAlternatives {\n const suggestions = rule.suggests;\n if (suggestions === undefined || suggestions.length === 0) return { suggestions: [] };\n const isolated = alternativesStateOf(state);\n // The row is an argument of this call, not a field of the shared isolate: the isolate is\n // cached for the pass, and writing the row into it would let one verdict's row survive into\n // the next reader of a state nobody re-derived.\n return isolated.evaluator.withBinderScopes(state.evaluator.scopes, () =>\n evaluateSuggestions(isolated, suggestions, state.currentRowKey),\n );\n}\n"]}
@@ -0,0 +1,47 @@
1
+ import type { CompiledRule } from '../../model/types.js';
2
+ import type { CompiledSchema } from '../../model/schema.js';
3
+ /** One rule's behaviour identity. */
4
+ export interface RuleBehaviour {
5
+ readonly ruleId: string;
6
+ readonly ruleHash: string;
7
+ }
8
+ /** A compiled artifact's behaviour identity. */
9
+ export interface ArtifactBehaviour {
10
+ /** What the artifact does, independent of how it presents itself. */
11
+ readonly behaviorHash: string;
12
+ /** Every rule's hash in declaration order, so a caller names the rules that differ. */
13
+ readonly rules: readonly RuleBehaviour[];
14
+ }
15
+ /** Every rule's rule hash, keyed by the rule object the caller holds. */
16
+ export declare function ruleHashesOf(compiled: CompiledSchema): Map<CompiledRule, string>;
17
+ /**
18
+ * The behaviour identity built from hashes a caller already derived. Hashing a rule is a
19
+ * defensive walk plus SHA-256, so a caller that needs both the per-rule hashes and the
20
+ * artifact's own passes its map in rather than deriving the same hashes a second time.
21
+ *
22
+ * The payload is the artifact's non-presentation members plus the sorted `(ruleId, ruleHash)`
23
+ * pairs. Keeping the pairs means a revision diff names the rules that moved instead of
24
+ * reporting one opaque digest, and every other member — fields, their options and row keys,
25
+ * context roots, datasets, money domains, hiding policy, signature coverage, a rule's message
26
+ * bindings — participates because it is not presentation, not because a list here remembered to
27
+ * say so.
28
+ */
29
+ export declare function behaviourOf(compiled: CompiledSchema, ruleHashes: ReadonlyMap<CompiledRule, string>): ArtifactBehaviour;
30
+ /** Whether `behaviour` is the immutable identity `artifactBehaviour` derived for `compiled`. */
31
+ export declare function isArtifactBehaviourOf(compiled: CompiledSchema, behaviour: ArtifactBehaviour): boolean;
32
+ /** The number of artifact behaviour identities derived since the process started. */
33
+ export declare function artifactBehaviourDerivations(): number;
34
+ /**
35
+ * The behaviour identity of a compiled artifact.
36
+ *
37
+ * Evaluation binds these hashes into every report and gate override, and an operator comparing
38
+ * two versions of a schema needs the same answer the report would carry, so the definition lives
39
+ * here instead of in either caller: a second derivation would let the two disagree about whether
40
+ * a schema's behaviour changed.
41
+ *
42
+ * A caller that needs the identity beside other work on the same artifact derives it once and
43
+ * threads the value — `readinessGaps`, `embeddedEvidence`, `runScenarioSuite` and
44
+ * `classifyArtifactDiff` all accept one — because each derivation re-hashes every rule.
45
+ */
46
+ export declare function artifactBehaviour(compiled: CompiledSchema): ArtifactBehaviour;
47
+ //# sourceMappingURL=behaviour.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"behaviour.d.ts","sourceRoot":"","sources":["../../../src/eval/rule/behaviour.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAEV,YAAY,EAMb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AA+K5D,qCAAqC;AACrC,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;CAC3B;AAED,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,uFAAuF;IACvF,QAAQ,CAAC,KAAK,EAAE,SAAS,aAAa,EAAE,CAAC;CAC1C;AAED,yEAAyE;AACzE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,cAAc,GAAG,GAAG,CAAC,YAAY,EAAE,MAAM,CAAC,CAMhF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACzB,QAAQ,EAAE,cAAc,EACxB,UAAU,EAAE,WAAW,CAAC,YAAY,EAAE,MAAM,CAAC,GAC5C,iBAAiB,CAiBnB;AAKD,gGAAgG;AAChG,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,cAAc,EACxB,SAAS,EAAE,iBAAiB,GAC3B,OAAO,CAET;AAaD,qFAAqF;AACrF,wBAAgB,4BAA4B,IAAI,MAAM,CAErD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,cAAc,GAAG,iBAAiB,CAW7E"}