@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,131 @@
1
+ import type { CompiledField, WireValue } from '../model/types.js';
2
+ import type { CompiledSchema } from '../model/schema.js';
3
+ /**
4
+ * Row addressing: the rows a declared array addresses, the key that names each one and the
5
+ * element the record holds for it, `spec/semantics/identity-v1.md`.
6
+ *
7
+ * One authority for that fact, because every mechanic that names a row keeps it: the session
8
+ * identity that moves rows, the derived form state that reports them, the reader that matches a
9
+ * covered target and the submission projection that exports them. A natural key is the value of
10
+ * the key member, a value key is the item itself and an assigned key is the host's manifest, so
11
+ * all three are read here and nowhere else. An assigned id is never a number and never paired by
12
+ * position unless the manifest states one id per row; an array declared inside another array
13
+ * addresses nothing in v1 — the compiler refuses an item rule over it and the session refuses a
14
+ * structural operation on it — and it must never fall back to its parent's rows, which is exactly
15
+ * what reading the enclosing array's value would produce.
16
+ *
17
+ * Nothing here reads access. Identity is a fact of the record and the manifest, and a caller
18
+ * that must not spell a key the access answer withholds decides that separately.
19
+ */
20
+ /** How a declared array identifies its rows, `[IDENT-2.1.5]`. */
21
+ export type RowKeyMode = 'natural' | 'value' | 'assigned';
22
+ /** One declared array, where its items live in the record and how its rows are identified. */
23
+ export interface ArrayDeclaration {
24
+ readonly field: CompiledField;
25
+ readonly mode: RowKeyMode;
26
+ /** A v1 row key addresses a row outside any enclosing array; nested rows have no composite key. */
27
+ readonly topLevel: boolean;
28
+ /** The record-container path to this array, including its own field id. */
29
+ readonly path: readonly string[];
30
+ }
31
+ /** One addressed row: the key that names it and the element the record holds for it. */
32
+ export interface AddressableRow {
33
+ readonly rowKey: string | number;
34
+ /** The element the record holds, as the record holds it: canonicalising it is a read's question. */
35
+ readonly item: unknown;
36
+ }
37
+ /**
38
+ * What one array's identity answers.
39
+ *
40
+ * `duplicate` is its own outcome because it is the refusal a caller must be able to name: two
41
+ * rows with one key identify neither, and the offending key is the repair. Every other reason
42
+ * is `unsupported`, which states no row at all rather than a guessed one.
43
+ */
44
+ export type ArrayAddressing = {
45
+ readonly outcome: 'addressed';
46
+ readonly mode: RowKeyMode;
47
+ /** The declaration that supplies the key: the natural key member, or a value array itself. */
48
+ readonly identityFieldId: string | undefined;
49
+ readonly rows: readonly AddressableRow[];
50
+ } | {
51
+ readonly outcome: 'duplicate';
52
+ readonly rowKey: string | number;
53
+ } | {
54
+ readonly outcome: 'unsupported';
55
+ readonly reason: 'nested' | 'not-an-array' | 'not-a-list' | 'unreconciled' | 'unkeyed' | 'undetermined';
56
+ };
57
+ /**
58
+ * Every array a document declares with an identity, nested declarations included.
59
+ *
60
+ * An array with neither a declared key nor an item domain has no identity to keep: the
61
+ * compiler refuses it, so an artifact that carries one leaves its rows unaddressable rather
62
+ * than acquiring a guessed key. An array inside another array is kept in the list with
63
+ * `topLevel: false` so its nesting is decided once, here, rather than by each consumer.
64
+ */
65
+ export declare function arrayDeclarations(compiled: CompiledSchema): readonly ArrayDeclaration[];
66
+ /** The array declaration one field id names, at any nesting level. */
67
+ export declare function declarationOf(compiled: CompiledSchema, fieldId: string): ArrayDeclaration | undefined;
68
+ /**
69
+ * The id a host-assigned manifest may state for one row, `[IDENT-2.1.2]`.
70
+ *
71
+ * An assigned id is the string a host's `idFactory()` minted. The session refuses anything else
72
+ * when it validates a manifest, so the stateless derivation reads the same predicate: a numeric
73
+ * id it accepted here would name a row no session could address, the reserved spelling `current`
74
+ * would collide with the symbolic row (`RULES-6.1.2`), and a lone surrogate has no UTF-8 form, so
75
+ * a report carrying one would be refused by the profile's own reader.
76
+ */
77
+ export declare function assignedRowKeyOf(id: unknown): string | undefined;
78
+ /**
79
+ * The key the declaration names for the item at `index`, or `undefined` when it names none.
80
+ *
81
+ * The single per-row rule: what one key member holds, what a value-identified item is, and what
82
+ * an assigned manifest states once it names one id per row. A caller that projects or merges
83
+ * one row asks this rather than reading the key member or pairing a manifest itself.
84
+ */
85
+ export declare function rowKeyOfItem(field: CompiledField, items: readonly unknown[], index: number, manifest: readonly (string | number)[] | undefined): string | number | undefined;
86
+ /**
87
+ * The rows one declared array's items address.
88
+ *
89
+ * The list a caller supplies is the list it reads rows from: the committed record for the
90
+ * session, the access-resolved read for the reader, the writer's value for the derived state.
91
+ * `addressingOf` states the record's answer, and this states the answer for any list a caller
92
+ * already holds.
93
+ */
94
+ export declare function addressingOfItems(field: CompiledField, items: readonly unknown[], manifest: readonly (string | number)[] | undefined): ArrayAddressing;
95
+ /**
96
+ * The position of one row in an addressed array, by wire-typed key.
97
+ *
98
+ * A key `7` and a text `"7"` name different rows, so the position is looked up by the token the
99
+ * derivation already built for each row rather than by comparing keys one at a time. An answer
100
+ * that states no positions — one built outside this module — is searched and charged for its
101
+ * rows, so a caller that stops carrying the index is visible in the count instead of quietly
102
+ * paying the walk.
103
+ */
104
+ export declare function rowPositionOf(answer: Extract<ArrayAddressing, {
105
+ readonly outcome: 'addressed';
106
+ }>, rowKey: string | number): number | undefined;
107
+ /**
108
+ * The items a declared array currently holds, in a record the session already canonicalised; an
109
+ * absent or null container holds none. A caller reading an untrusted payload asks
110
+ * `addressingOf`, which reports the elements as the record holds them.
111
+ */
112
+ export declare function itemsOf(values: Readonly<Record<string, WireValue>>, declaration: ArrayDeclaration): readonly WireValue[];
113
+ /**
114
+ * The rows one array addresses, or the refusal its declaration and values state.
115
+ *
116
+ * The record reaching this point is either untrusted submitted JSON or a session record the
117
+ * session already canonicalised; both are read structurally here, and every key is narrowed by
118
+ * `rowKeyValue`, so a value the wire contract would refuse names no row.
119
+ */
120
+ export declare function addressingOf(compiled: CompiledSchema, fieldId: string, values: Readonly<Record<string, unknown>>, manifests: ReadonlyMap<string, readonly (string | number)[]> | undefined): ArrayAddressing;
121
+ /**
122
+ * The addressing of one array as a session operation reads it, `[IDENT-2.1.5]`.
123
+ *
124
+ * The same answer `addressingOf` states, charged to the measurement hook for the rows it had to
125
+ * derive: an operation reads the committed record's answer, which the pass that committed the
126
+ * record already stated, instead of rebuilding it on both sides of every write. A write that
127
+ * re-keys a row replaces the element list, and the replacement is a new key that derives its own
128
+ * answer, so the charge is the work this call caused and never a hit.
129
+ */
130
+ export declare function operationAddressingOf(compiled: CompiledSchema, fieldId: string, values: Readonly<Record<string, unknown>>, manifests: ReadonlyMap<string, readonly (string | number)[]> | undefined): ArrayAddressing;
131
+ //# sourceMappingURL=addressing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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,MAAM,EACf,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GACvE,eAAe,CAEjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,cAAc,EACxB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC,GAAG,SAAS,GACvE,eAAe,CAIjB"}
@@ -0,0 +1,270 @@
1
+ import { isRecord, isWireValueArray } from '../model/values.js';
2
+ import { rowKeyOfWire, rowKeyToken, rowKeyValue } from '../model/wire.js';
3
+ import { naturalKeyMember } from './reader/declarations.js';
4
+ import { noteRowKeyScan } from './state/measurement.js';
5
+ const DECLARATIONS = new WeakMap();
6
+ /**
7
+ * Every array a document declares with an identity, nested declarations included.
8
+ *
9
+ * An array with neither a declared key nor an item domain has no identity to keep: the
10
+ * compiler refuses it, so an artifact that carries one leaves its rows unaddressable rather
11
+ * than acquiring a guessed key. An array inside another array is kept in the list with
12
+ * `topLevel: false` so its nesting is decided once, here, rather than by each consumer.
13
+ */
14
+ export function arrayDeclarations(compiled) {
15
+ return declarationIndexOf(compiled).list;
16
+ }
17
+ /** The array declaration one field id names, at any nesting level. */
18
+ export function declarationOf(compiled, fieldId) {
19
+ return declarationIndexOf(compiled).byFieldId.get(fieldId);
20
+ }
21
+ /** One artifact's declarations, walked once: a derivation asks per array field. */
22
+ function declarationIndexOf(compiled) {
23
+ const cached = DECLARATIONS.get(compiled);
24
+ if (cached !== undefined)
25
+ return cached;
26
+ const declared = [];
27
+ const visit = (fields, recordPath, insideArray) => {
28
+ for (const field of fields) {
29
+ const path = [...recordPath, field.fieldId];
30
+ if (field.primitive === 'array') {
31
+ const mode = rowKeyModeOf(field);
32
+ if (mode !== undefined) {
33
+ declared.push({ field, mode, topLevel: !insideArray, path });
34
+ }
35
+ }
36
+ if (field.fields !== undefined) {
37
+ visit(field.fields, field.primitive === 'array' ? [] : path, insideArray || field.primitive === 'array');
38
+ }
39
+ }
40
+ };
41
+ visit(compiled.fields, [], false);
42
+ const byFieldId = new Map(declared.map((entry) => [entry.field.fieldId, entry]));
43
+ const index = { list: declared, byFieldId };
44
+ DECLARATIONS.set(compiled, index);
45
+ return index;
46
+ }
47
+ /**
48
+ * How a declaration names its rows, or `undefined` when it declares no identity at all.
49
+ *
50
+ * The one reading of `rowKey` and `items`, so the declaration index, the list answer and the
51
+ * per-row question cannot conclude differently about one artifact.
52
+ */
53
+ function rowKeyModeOf(field) {
54
+ const declared = field.rowKey?.mode;
55
+ if (declared !== undefined)
56
+ return declared;
57
+ return field.items === undefined ? undefined : 'value';
58
+ }
59
+ /**
60
+ * The id a host-assigned manifest may state for one row, `[IDENT-2.1.2]`.
61
+ *
62
+ * An assigned id is the string a host's `idFactory()` minted. The session refuses anything else
63
+ * when it validates a manifest, so the stateless derivation reads the same predicate: a numeric
64
+ * id it accepted here would name a row no session could address, the reserved spelling `current`
65
+ * would collide with the symbolic row (`RULES-6.1.2`), and a lone surrogate has no UTF-8 form, so
66
+ * a report carrying one would be refused by the profile's own reader.
67
+ */
68
+ export function assignedRowKeyOf(id) {
69
+ const key = rowKeyOfWire(id);
70
+ return typeof key === 'string' ? key : undefined;
71
+ }
72
+ /**
73
+ * The key the declaration names for the item at `index`, or `undefined` when it names none.
74
+ *
75
+ * The single per-row rule: what one key member holds, what a value-identified item is, and what
76
+ * an assigned manifest states once it names one id per row. A caller that projects or merges
77
+ * one row asks this rather than reading the key member or pairing a manifest itself.
78
+ */
79
+ export function rowKeyOfItem(field, items, index, manifest) {
80
+ switch (rowKeyModeOf(field)) {
81
+ case undefined:
82
+ return undefined;
83
+ case 'assigned': {
84
+ // A manifest that names a different number of rows does not reconcile with this list:
85
+ // pairing it by position would attach a stored id to the wrong element (`IDENT-3.1.2`).
86
+ if (manifest === undefined || manifest.length !== items.length)
87
+ return undefined;
88
+ return assignedRowKeyOf(manifest[index]);
89
+ }
90
+ case 'value':
91
+ return rowKeyValue(items[index]);
92
+ case 'natural': {
93
+ const keyMember = naturalKeyMember(field);
94
+ const item = items[index];
95
+ return keyMember === undefined || !isRecord(item) ? undefined : rowKeyValue(item[keyMember]);
96
+ }
97
+ }
98
+ }
99
+ /**
100
+ * One answer per declaration and element list, `[IDENT-2.1.5]`.
101
+ *
102
+ * Which rows an array addresses is a fact of one list and one manifest, so a list that has been
103
+ * addressed answers again rather than being walked again: the derived form state asks it for the
104
+ * container and for every member of it, the reader asks it per covered target, and a session asks
105
+ * it on both sides of every write. The map under one list is keyed by declaration, so two arrays
106
+ * over the same list never answer for each other.
107
+ *
108
+ * Identity is a sound key. A committed record is *replaced*, never edited — `withArray` and
109
+ * `withMember` build the next record from the last, and the session hands a host a copy rather
110
+ * than the record itself — so the list object a caller holds names the same elements in the same
111
+ * order for as long as it can be reached. A hit is verified against the declaration and the
112
+ * manifest it was derived from, the only other inputs, so nothing can make it stale: a replaced
113
+ * list is a different key that derives its own answer, and the reader's covered targets already
114
+ * key their derived row keys by the element list the same way.
115
+ */
116
+ const ADDRESSES = new WeakMap();
117
+ /** The positions one derived answer states, so a row lookup does not re-walk the keys. */
118
+ const POSITIONS = new WeakMap();
119
+ /** The rows one declared array's items address, derived fresh. */
120
+ function deriveAddressing(field, items, manifest) {
121
+ const positions = new Map();
122
+ const index = (answer) => {
123
+ POSITIONS.set(answer, positions);
124
+ return { manifest, answer, positions };
125
+ };
126
+ const mode = rowKeyModeOf(field);
127
+ if (mode === undefined)
128
+ return index({ outcome: 'unsupported', reason: 'unkeyed' });
129
+ const identityFieldId = mode === 'natural' ? naturalKeyMember(field) : mode === 'value' ? field.fieldId : undefined;
130
+ // A natural array whose declaration names no key member identifies no row, exactly as a row
131
+ // whose key member is missing does.
132
+ if (mode === 'natural' && identityFieldId === undefined) {
133
+ return index({ outcome: 'unsupported', reason: 'unkeyed' });
134
+ }
135
+ if (mode === 'assigned' && (manifest === undefined || manifest.length !== items.length)) {
136
+ return index({ outcome: 'unsupported', reason: 'unreconciled' });
137
+ }
138
+ const rows = [];
139
+ const seen = new Set();
140
+ for (const [position, item] of items.entries()) {
141
+ const rowKey = rowKeyOfItem(field, items, position, manifest);
142
+ if (rowKey === undefined) {
143
+ return index({
144
+ outcome: 'unsupported',
145
+ reason: mode === 'assigned' ? 'unreconciled' : 'unkeyed',
146
+ });
147
+ }
148
+ const token = rowKeyToken(rowKey);
149
+ if (seen.has(token))
150
+ return index({ outcome: 'duplicate', rowKey });
151
+ seen.add(token);
152
+ positions.set(token, position);
153
+ rows.push({ rowKey, item });
154
+ }
155
+ return index({ outcome: 'addressed', mode, identityFieldId, rows });
156
+ }
157
+ /**
158
+ * The memoised answer for one element list, and whether this call had to derive it.
159
+ *
160
+ * The flag is what lets the operation path charge the measurement hook for work it caused
161
+ * rather than for an answer another caller already stated.
162
+ */
163
+ function addressIndexOf(field, items, manifest) {
164
+ const byField = ADDRESSES.get(items);
165
+ const cached = byField?.get(field);
166
+ if (cached !== undefined && cached.manifest === manifest) {
167
+ return { entry: cached, derived: false };
168
+ }
169
+ const entry = deriveAddressing(field, items, manifest);
170
+ // One entry per element list and declaration. A second manifest over the same list replaces
171
+ // it: the answer is a function of the three inputs, so a later call with the earlier manifest
172
+ // is a miss that derives its own answer rather than a stale hit.
173
+ if (byField === undefined)
174
+ ADDRESSES.set(items, new Map([[field, entry]]));
175
+ else
176
+ byField.set(field, entry);
177
+ return { entry, derived: true };
178
+ }
179
+ /**
180
+ * The rows one declared array's items address.
181
+ *
182
+ * The list a caller supplies is the list it reads rows from: the committed record for the
183
+ * session, the access-resolved read for the reader, the writer's value for the derived state.
184
+ * `addressingOf` states the record's answer, and this states the answer for any list a caller
185
+ * already holds.
186
+ */
187
+ export function addressingOfItems(field, items, manifest) {
188
+ return addressIndexOf(field, items, manifest).entry.answer;
189
+ }
190
+ /**
191
+ * The position of one row in an addressed array, by wire-typed key.
192
+ *
193
+ * A key `7` and a text `"7"` name different rows, so the position is looked up by the token the
194
+ * derivation already built for each row rather than by comparing keys one at a time. An answer
195
+ * that states no positions — one built outside this module — is searched and charged for its
196
+ * rows, so a caller that stops carrying the index is visible in the count instead of quietly
197
+ * paying the walk.
198
+ */
199
+ export function rowPositionOf(answer, rowKey) {
200
+ const token = rowKeyToken(rowKey);
201
+ const positions = POSITIONS.get(answer);
202
+ if (positions !== undefined)
203
+ return positions.get(token);
204
+ noteRowKeyScan(answer.rows.length);
205
+ const position = answer.rows.findIndex((row) => rowKeyToken(row.rowKey) === token);
206
+ return position < 0 ? undefined : position;
207
+ }
208
+ /** The value the record holds at a declaration's path, as the record holds it. */
209
+ function heldValueOf(values, declaration) {
210
+ let current = values;
211
+ for (const segment of declaration.path) {
212
+ if (!isRecord(current))
213
+ return undefined;
214
+ current = current[segment];
215
+ }
216
+ return current;
217
+ }
218
+ /**
219
+ * The items a declared array currently holds, in a record the session already canonicalised; an
220
+ * absent or null container holds none. A caller reading an untrusted payload asks
221
+ * `addressingOf`, which reports the elements as the record holds them.
222
+ */
223
+ export function itemsOf(values, declaration) {
224
+ const held = heldValueOf(values, declaration);
225
+ return isWireValueArray(held) ? held : [];
226
+ }
227
+ /**
228
+ * The rows one array addresses, or the refusal its declaration and values state.
229
+ *
230
+ * The record reaching this point is either untrusted submitted JSON or a session record the
231
+ * session already canonicalised; both are read structurally here, and every key is narrowed by
232
+ * `rowKeyValue`, so a value the wire contract would refuse names no row.
233
+ */
234
+ export function addressingOf(compiled, fieldId, values, manifests) {
235
+ return resolvedAddressing(compiled, fieldId, values, manifests).answer;
236
+ }
237
+ /**
238
+ * The addressing of one array as a session operation reads it, `[IDENT-2.1.5]`.
239
+ *
240
+ * The same answer `addressingOf` states, charged to the measurement hook for the rows it had to
241
+ * derive: an operation reads the committed record's answer, which the pass that committed the
242
+ * record already stated, instead of rebuilding it on both sides of every write. A write that
243
+ * re-keys a row replaces the element list, and the replacement is a new key that derives its own
244
+ * answer, so the charge is the work this call caused and never a hit.
245
+ */
246
+ export function operationAddressingOf(compiled, fieldId, values, manifests) {
247
+ const { answer, derived } = resolvedAddressing(compiled, fieldId, values, manifests);
248
+ if (derived && answer.outcome === 'addressed')
249
+ noteRowKeyScan(answer.rows.length);
250
+ return answer;
251
+ }
252
+ /** One array's answer for one record, and whether this call had to derive it. */
253
+ function resolvedAddressing(compiled, fieldId, values, manifests) {
254
+ const declaration = declarationOf(compiled, fieldId);
255
+ if (declaration === undefined) {
256
+ return { answer: { outcome: 'unsupported', reason: 'not-an-array' }, derived: false };
257
+ }
258
+ if (!declaration.topLevel) {
259
+ return { answer: { outcome: 'unsupported', reason: 'nested' }, derived: false };
260
+ }
261
+ const held = heldValueOf(values, declaration);
262
+ // A value the array declaration refuses is not an empty list: claiming its declared mode would
263
+ // report rows the record never held. An absent or `null` container is the authored empty list.
264
+ if (held !== undefined && held !== null && !Array.isArray(held)) {
265
+ return { answer: { outcome: 'unsupported', reason: 'not-a-list' }, derived: false };
266
+ }
267
+ const { entry, derived } = addressIndexOf(declaration.field, Array.isArray(held) ? held : [], manifests?.get(fieldId));
268
+ return { answer: entry.answer, derived };
269
+ }
270
+ //# sourceMappingURL=addressing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addressing.js","sourceRoot":"","sources":["../../src/eval/addressing.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AA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AI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAChE,OAAO,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IACtF,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,cAAc,CACvC,WAAW,CAAC,KAAK,EACjB,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAC/B,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CACxB,CAAC;IACF,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import type { CompiledField, WireValue } from '../model/types.js';\nimport type { CompiledSchema } from '../model/schema.js';\nimport { isRecord, isWireValueArray } from '../model/values.js';\nimport { rowKeyOfWire, rowKeyToken, rowKeyValue } from '../model/wire.js';\nimport { naturalKeyMember } from './reader/declarations.js';\nimport { noteRowKeyScan } from './state/measurement.js';\n\n/**\n * Row addressing: the rows a declared array addresses, the key that names each one and the\n * element the record holds for it, `spec/semantics/identity-v1.md`.\n *\n * One authority for that fact, because every mechanic that names a row keeps it: the session\n * identity that moves rows, the derived form state that reports them, the reader that matches a\n * covered target and the submission projection that exports them. A natural key is the value of\n * the key member, a value key is the item itself and an assigned key is the host's manifest, so\n * all three are read here and nowhere else. An assigned id is never a number and never paired by\n * position unless the manifest states one id per row; an array declared inside another array\n * addresses nothing in v1 — the compiler refuses an item rule over it and the session refuses a\n * structural operation on it — and it must never fall back to its parent's rows, which is exactly\n * what reading the enclosing array's value would produce.\n *\n * Nothing here reads access. Identity is a fact of the record and the manifest, and a caller\n * that must not spell a key the access answer withholds decides that separately.\n */\n\n/** How a declared array identifies its rows, `[IDENT-2.1.5]`. */\nexport type RowKeyMode = 'natural' | 'value' | 'assigned';\n\n/** One declared array, where its items live in the record and how its rows are identified. */\nexport interface ArrayDeclaration {\n readonly field: CompiledField;\n readonly mode: RowKeyMode;\n /** A v1 row key addresses a row outside any enclosing array; nested rows have no composite key. */\n readonly topLevel: boolean;\n /** The record-container path to this array, including its own field id. */\n readonly path: readonly string[];\n}\n\n/** One addressed row: the key that names it and the element the record holds for it. */\nexport interface AddressableRow {\n readonly rowKey: string | number;\n /** The element the record holds, as the record holds it: canonicalising it is a read's question. */\n readonly item: unknown;\n}\n\n/**\n * What one array's identity answers.\n *\n * `duplicate` is its own outcome because it is the refusal a caller must be able to name: two\n * rows with one key identify neither, and the offending key is the repair. Every other reason\n * is `unsupported`, which states no row at all rather than a guessed one.\n */\nexport type ArrayAddressing =\n | {\n readonly outcome: 'addressed';\n readonly mode: RowKeyMode;\n /** The declaration that supplies the key: the natural key member, or a value array itself. */\n readonly identityFieldId: string | undefined;\n readonly rows: readonly AddressableRow[];\n }\n | { readonly outcome: 'duplicate'; readonly rowKey: string | number }\n | {\n readonly outcome: 'unsupported';\n readonly reason:\n | 'nested'\n | 'not-an-array'\n | 'not-a-list'\n | 'unreconciled'\n | 'unkeyed'\n // The effective value is a writer's undecided answer, so it states no row: a mode over\n // zero rows would contradict the row keys a report may still carry.\n | 'undetermined';\n };\n\n/** The declarations of one artifact, in declaration order and by the field id each names. */\ninterface DeclarationIndex {\n readonly list: readonly ArrayDeclaration[];\n readonly byFieldId: ReadonlyMap<string, ArrayDeclaration>;\n}\n\nconst DECLARATIONS: WeakMap<CompiledSchema, DeclarationIndex> = new WeakMap();\n\n/**\n * Every array a document declares with an identity, nested declarations included.\n *\n * An array with neither a declared key nor an item domain has no identity to keep: the\n * compiler refuses it, so an artifact that carries one leaves its rows unaddressable rather\n * than acquiring a guessed key. An array inside another array is kept in the list with\n * `topLevel: false` so its nesting is decided once, here, rather than by each consumer.\n */\nexport function arrayDeclarations(compiled: CompiledSchema): readonly ArrayDeclaration[] {\n return declarationIndexOf(compiled).list;\n}\n\n/** The array declaration one field id names, at any nesting level. */\nexport function declarationOf(\n compiled: CompiledSchema,\n fieldId: string,\n): ArrayDeclaration | undefined {\n return declarationIndexOf(compiled).byFieldId.get(fieldId);\n}\n\n/** One artifact's declarations, walked once: a derivation asks per array field. */\nfunction declarationIndexOf(compiled: CompiledSchema): DeclarationIndex {\n const cached = DECLARATIONS.get(compiled);\n if (cached !== undefined) return cached;\n const declared: ArrayDeclaration[] = [];\n const visit = (\n fields: readonly CompiledField[],\n recordPath: readonly string[],\n insideArray: boolean,\n ): void => {\n for (const field of fields) {\n const path = [...recordPath, field.fieldId];\n if (field.primitive === 'array') {\n const mode = rowKeyModeOf(field);\n if (mode !== undefined) {\n declared.push({ field, mode, topLevel: !insideArray, path });\n }\n }\n if (field.fields !== undefined) {\n visit(\n field.fields,\n field.primitive === 'array' ? [] : path,\n insideArray || field.primitive === 'array',\n );\n }\n }\n };\n visit(compiled.fields, [], false);\n const byFieldId = new Map(declared.map((entry) => [entry.field.fieldId, entry] as const));\n const index: DeclarationIndex = { list: declared, byFieldId };\n DECLARATIONS.set(compiled, index);\n return index;\n}\n\n/**\n * How a declaration names its rows, or `undefined` when it declares no identity at all.\n *\n * The one reading of `rowKey` and `items`, so the declaration index, the list answer and the\n * per-row question cannot conclude differently about one artifact.\n */\nfunction rowKeyModeOf(field: CompiledField): RowKeyMode | undefined {\n const declared = field.rowKey?.mode;\n if (declared !== undefined) return declared;\n return field.items === undefined ? undefined : 'value';\n}\n\n/**\n * The id a host-assigned manifest may state for one row, `[IDENT-2.1.2]`.\n *\n * An assigned id is the string a host's `idFactory()` minted. The session refuses anything else\n * when it validates a manifest, so the stateless derivation reads the same predicate: a numeric\n * id it accepted here would name a row no session could address, the reserved spelling `current`\n * would collide with the symbolic row (`RULES-6.1.2`), and a lone surrogate has no UTF-8 form, so\n * a report carrying one would be refused by the profile's own reader.\n */\nexport function assignedRowKeyOf(id: unknown): string | undefined {\n const key = rowKeyOfWire(id);\n return typeof key === 'string' ? key : undefined;\n}\n\n/**\n * The key the declaration names for the item at `index`, or `undefined` when it names none.\n *\n * The single per-row rule: what one key member holds, what a value-identified item is, and what\n * an assigned manifest states once it names one id per row. A caller that projects or merges\n * one row asks this rather than reading the key member or pairing a manifest itself.\n */\nexport function rowKeyOfItem(\n field: CompiledField,\n items: readonly unknown[],\n index: number,\n manifest: readonly (string | number)[] | undefined,\n): string | number | undefined {\n switch (rowKeyModeOf(field)) {\n case undefined:\n return undefined;\n case 'assigned': {\n // A manifest that names a different number of rows does not reconcile with this list:\n // pairing it by position would attach a stored id to the wrong element (`IDENT-3.1.2`).\n if (manifest === undefined || manifest.length !== items.length) return undefined;\n return assignedRowKeyOf(manifest[index]);\n }\n case 'value':\n return rowKeyValue(items[index]);\n case 'natural': {\n const keyMember = naturalKeyMember(field);\n const item = items[index];\n return keyMember === undefined || !isRecord(item) ? undefined : rowKeyValue(item[keyMember]);\n }\n }\n}\n\n/** One array's answer and the positions its rows sit at, derived together. */\ninterface AddressIndex {\n /** The manifest the answer was derived from; a different one is a different answer. */\n readonly manifest: readonly (string | number)[] | undefined;\n readonly answer: ArrayAddressing;\n /** The position of the row one wire-typed key token names. */\n readonly positions: ReadonlyMap<string, number>;\n}\n\n/**\n * One answer per declaration and element list, `[IDENT-2.1.5]`.\n *\n * Which rows an array addresses is a fact of one list and one manifest, so a list that has been\n * addressed answers again rather than being walked again: the derived form state asks it for the\n * container and for every member of it, the reader asks it per covered target, and a session asks\n * it on both sides of every write. The map under one list is keyed by declaration, so two arrays\n * over the same list never answer for each other.\n *\n * Identity is a sound key. A committed record is *replaced*, never edited — `withArray` and\n * `withMember` build the next record from the last, and the session hands a host a copy rather\n * than the record itself — so the list object a caller holds names the same elements in the same\n * order for as long as it can be reached. A hit is verified against the declaration and the\n * manifest it was derived from, the only other inputs, so nothing can make it stale: a replaced\n * list is a different key that derives its own answer, and the reader's covered targets already\n * key their derived row keys by the element list the same way.\n */\nconst ADDRESSES: WeakMap<readonly unknown[], Map<CompiledField, AddressIndex>> = new WeakMap();\n\n/** The positions one derived answer states, so a row lookup does not re-walk the keys. */\nconst POSITIONS: WeakMap<ArrayAddressing, ReadonlyMap<string, number>> = new WeakMap();\n\n/** The rows one declared array's items address, derived fresh. */\nfunction deriveAddressing(\n field: CompiledField,\n items: readonly unknown[],\n manifest: readonly (string | number)[] | undefined,\n): AddressIndex {\n const positions = new Map<string, number>();\n const index = (answer: ArrayAddressing): AddressIndex => {\n POSITIONS.set(answer, positions);\n return { manifest, answer, positions };\n };\n const mode = rowKeyModeOf(field);\n if (mode === undefined) return index({ outcome: 'unsupported', reason: 'unkeyed' });\n const identityFieldId =\n mode === 'natural' ? naturalKeyMember(field) : mode === 'value' ? field.fieldId : undefined;\n // A natural array whose declaration names no key member identifies no row, exactly as a row\n // whose key member is missing does.\n if (mode === 'natural' && identityFieldId === undefined) {\n return index({ outcome: 'unsupported', reason: 'unkeyed' });\n }\n if (mode === 'assigned' && (manifest === undefined || manifest.length !== items.length)) {\n return index({ outcome: 'unsupported', reason: 'unreconciled' });\n }\n const rows: AddressableRow[] = [];\n const seen = new Set<string>();\n for (const [position, item] of items.entries()) {\n const rowKey = rowKeyOfItem(field, items, position, manifest);\n if (rowKey === undefined) {\n return index({\n outcome: 'unsupported',\n reason: mode === 'assigned' ? 'unreconciled' : 'unkeyed',\n });\n }\n const token = rowKeyToken(rowKey);\n if (seen.has(token)) return index({ outcome: 'duplicate', rowKey });\n seen.add(token);\n positions.set(token, position);\n rows.push({ rowKey, item });\n }\n return index({ outcome: 'addressed', mode, identityFieldId, rows });\n}\n\n/**\n * The memoised answer for one element list, and whether this call had to derive it.\n *\n * The flag is what lets the operation path charge the measurement hook for work it caused\n * rather than for an answer another caller already stated.\n */\nfunction addressIndexOf(\n field: CompiledField,\n items: readonly unknown[],\n manifest: readonly (string | number)[] | undefined,\n): { readonly entry: AddressIndex; readonly derived: boolean } {\n const byField = ADDRESSES.get(items);\n const cached = byField?.get(field);\n if (cached !== undefined && cached.manifest === manifest) {\n return { entry: cached, derived: false };\n }\n const entry = deriveAddressing(field, items, manifest);\n // One entry per element list and declaration. A second manifest over the same list replaces\n // it: the answer is a function of the three inputs, so a later call with the earlier manifest\n // is a miss that derives its own answer rather than a stale hit.\n if (byField === undefined) ADDRESSES.set(items, new Map([[field, entry]]));\n else byField.set(field, entry);\n return { entry, derived: true };\n}\n\n/**\n * The rows one declared array's items address.\n *\n * The list a caller supplies is the list it reads rows from: the committed record for the\n * session, the access-resolved read for the reader, the writer's value for the derived state.\n * `addressingOf` states the record's answer, and this states the answer for any list a caller\n * already holds.\n */\nexport function addressingOfItems(\n field: CompiledField,\n items: readonly unknown[],\n manifest: readonly (string | number)[] | undefined,\n): ArrayAddressing {\n return addressIndexOf(field, items, manifest).entry.answer;\n}\n\n/**\n * The position of one row in an addressed array, by wire-typed key.\n *\n * A key `7` and a text `\"7\"` name different rows, so the position is looked up by the token the\n * derivation already built for each row rather than by comparing keys one at a time. An answer\n * that states no positions — one built outside this module — is searched and charged for its\n * rows, so a caller that stops carrying the index is visible in the count instead of quietly\n * paying the walk.\n */\nexport function rowPositionOf(\n answer: Extract<ArrayAddressing, { readonly outcome: 'addressed' }>,\n rowKey: string | number,\n): number | undefined {\n const token = rowKeyToken(rowKey);\n const positions = POSITIONS.get(answer);\n if (positions !== undefined) return positions.get(token);\n noteRowKeyScan(answer.rows.length);\n const position = answer.rows.findIndex((row) => rowKeyToken(row.rowKey) === token);\n return position < 0 ? undefined : position;\n}\n\n/** The value the record holds at a declaration's path, as the record holds it. */\nfunction heldValueOf(\n values: Readonly<Record<string, unknown>>,\n declaration: ArrayDeclaration,\n): unknown {\n let current: unknown = values;\n for (const segment of declaration.path) {\n if (!isRecord(current)) return undefined;\n current = current[segment];\n }\n return current;\n}\n\n/**\n * The items a declared array currently holds, in a record the session already canonicalised; an\n * absent or null container holds none. A caller reading an untrusted payload asks\n * `addressingOf`, which reports the elements as the record holds them.\n */\nexport function itemsOf(\n values: Readonly<Record<string, WireValue>>,\n declaration: ArrayDeclaration,\n): readonly WireValue[] {\n const held = heldValueOf(values, declaration);\n return isWireValueArray(held) ? held : [];\n}\n\n/**\n * The rows one array addresses, or the refusal its declaration and values state.\n *\n * The record reaching this point is either untrusted submitted JSON or a session record the\n * session already canonicalised; both are read structurally here, and every key is narrowed by\n * `rowKeyValue`, so a value the wire contract would refuse names no row.\n */\nexport function addressingOf(\n compiled: CompiledSchema,\n fieldId: string,\n values: Readonly<Record<string, unknown>>,\n manifests: ReadonlyMap<string, readonly (string | number)[]> | undefined,\n): ArrayAddressing {\n return resolvedAddressing(compiled, fieldId, values, manifests).answer;\n}\n\n/**\n * The addressing of one array as a session operation reads it, `[IDENT-2.1.5]`.\n *\n * The same answer `addressingOf` states, charged to the measurement hook for the rows it had to\n * derive: an operation reads the committed record's answer, which the pass that committed the\n * record already stated, instead of rebuilding it on both sides of every write. A write that\n * re-keys a row replaces the element list, and the replacement is a new key that derives its own\n * answer, so the charge is the work this call caused and never a hit.\n */\nexport function operationAddressingOf(\n compiled: CompiledSchema,\n fieldId: string,\n values: Readonly<Record<string, unknown>>,\n manifests: ReadonlyMap<string, readonly (string | number)[]> | undefined,\n): ArrayAddressing {\n const { answer, derived } = resolvedAddressing(compiled, fieldId, values, manifests);\n if (derived && answer.outcome === 'addressed') noteRowKeyScan(answer.rows.length);\n return answer;\n}\n\n/** One array's answer for one record, and whether this call had to derive it. */\nfunction resolvedAddressing(\n compiled: CompiledSchema,\n fieldId: string,\n values: Readonly<Record<string, unknown>>,\n manifests: ReadonlyMap<string, readonly (string | number)[]> | undefined,\n): { readonly answer: ArrayAddressing; readonly derived: boolean } {\n const declaration = declarationOf(compiled, fieldId);\n if (declaration === undefined) {\n return { answer: { outcome: 'unsupported', reason: 'not-an-array' }, derived: false };\n }\n if (!declaration.topLevel) {\n return { answer: { outcome: 'unsupported', reason: 'nested' }, derived: false };\n }\n const held = heldValueOf(values, declaration);\n // A value the array declaration refuses is not an empty list: claiming its declared mode would\n // report rows the record never held. An absent or `null` container is the authored empty list.\n if (held !== undefined && held !== null && !Array.isArray(held)) {\n return { answer: { outcome: 'unsupported', reason: 'not-a-list' }, derived: false };\n }\n const { entry, derived } = addressIndexOf(\n declaration.field,\n Array.isArray(held) ? held : [],\n manifests?.get(fieldId),\n );\n return { answer: entry.answer, derived };\n}\n"]}
@@ -0,0 +1,143 @@
1
+ import { AxiomError } from '../model/errors.js';
2
+ import type { CompiledField, ContextRoot, WireValue } from '../model/types.js';
3
+ import type { EvaluationInput } from '../model/access.js';
4
+ import type { CompiledSchema } from '../model/schema.js';
5
+ /** The budget one pass runs under. */
6
+ export interface EvaluationBudget {
7
+ /** Nodes one rule may visit. */
8
+ readonly perRule: number;
9
+ /** Nodes the whole pass may visit. */
10
+ readonly total: number;
11
+ /** Elements one comprehension source may carry before its first binding. */
12
+ readonly elements: number;
13
+ /**
14
+ * Elements one rule may materialise across every nested comprehension it evaluates.
15
+ *
16
+ * This is the ceiling `EXPR-17.1.1` states, not the per-source allowance in `elements`: one
17
+ * source at the ceiling is legal, and the cumulative charge exists to stop a nesting from
18
+ * multiplying past it. 900 rows of 900 marks is 810,000 and admitted; 1,200 rows of 1,200
19
+ * marks is 1,440,000 and refused.
20
+ */
21
+ readonly nestedElements: number;
22
+ /**
23
+ * Report entries one pass may produce, `rules × rows`.
24
+ *
25
+ * This is its own dimension because the report is the allocation nobody watches: the node
26
+ * budget bounds the work an expression does, and this bounds the evidence the report retains
27
+ * after every rule has run.
28
+ */
29
+ readonly decisions: number;
30
+ }
31
+ /**
32
+ * The rows the record declares: the summed length of every declared array.
33
+ *
34
+ * This is what the budget scales with. It is read from the raw submission rather than through
35
+ * the record reader, so measuring the budget does not validate, copy or mark considered the
36
+ * values the evaluation is about to read.
37
+ */
38
+ export declare function declaredRowCount(fields: readonly CompiledField[] | undefined, values: Readonly<Record<string, unknown>>): number;
39
+ /** The rows a declared context array contributes, read from the raw context values. */
40
+ export declare function contextRowCount(roots: readonly ContextRoot[] | undefined, context: Readonly<Record<string, unknown>> | undefined): number;
41
+ /**
42
+ * The budget an artifact's declared shape earns: one rule's allowance scales with the rows
43
+ * it addresses, and the pass ceiling is the sum of those allowances, bounded.
44
+ */
45
+ export declare function evaluationBudget(rows: number, ruleCount: number): EvaluationBudget;
46
+ /** The budget a caller that declares no work runs under: one standalone expression. */
47
+ export declare const STANDALONE_BUDGET: EvaluationBudget;
48
+ /** The budget a compiled artifact earns against one record. */
49
+ export declare function budgetForSchema(compiled: CompiledSchema, input: EvaluationInput): EvaluationBudget;
50
+ /** The budget dimension a refusal names, so a report can state which limit was crossed. */
51
+ export type BudgetDimension = 'rule_nodes' | 'pass_nodes' | 'comprehension_elements' | 'decisions';
52
+ /**
53
+ * A refusal that crossed a declared budget.
54
+ *
55
+ * It extends the runtime's own refusal so the evaluator's single error path still carries it,
56
+ * and it keeps the limit and the dimension, which the report states as parameters. Mapping a
57
+ * cost overrun to a bare `ENGINE_ERROR` hid which budget was crossed and by how much.
58
+ */
59
+ export declare class BudgetExceededError extends AxiomError {
60
+ readonly limit: number;
61
+ readonly dimension: BudgetDimension;
62
+ /**
63
+ * The operation that crossed the budget, when the caller can name one.
64
+ *
65
+ * A decision refusal is produced by an item rule or by the report fold, and naming which
66
+ * lets an operator size the right thing — one rule's row count rather than the whole pass —
67
+ * without reading the evaluator.
68
+ */
69
+ readonly operation: string | undefined;
70
+ constructor(dimension: BudgetDimension, limit: number, detail: string, operation?: string);
71
+ }
72
+ /**
73
+ * The work one pass has spent, and the allowance of the rule currently running.
74
+ *
75
+ * A nested rule — `rule_ok` evaluating another rule mid-expression — begins its own
76
+ * allowances and restores the interrupted ones, so one rule's spend never shortens another's.
77
+ * The element charge and the comprehension depth are part of that same boundary: a nested rule
78
+ * starts at depth zero, so a comprehension it evaluates is charged to the nested rule and not to
79
+ * the rule whose body asked about it.
80
+ */
81
+ export declare class NodeLedger {
82
+ private readonly budget;
83
+ private ruleVisited;
84
+ private passVisited;
85
+ private chargedElements;
86
+ private comprehensionDepth;
87
+ private producedDecisions;
88
+ constructor(budget: EvaluationBudget);
89
+ /** Starts one rule's allowances, returning the interrupted counters to restore later. */
90
+ beginRule(): RuleAllowance;
91
+ /** Restores the allowances of the rule that asked about this one. */
92
+ endRule(previous: RuleAllowance): void;
93
+ /** Counts one visited node against both allowances. */
94
+ spend(): void;
95
+ /** Enters one comprehension, returning the depth it interrupted. */
96
+ beginComprehension(): number;
97
+ /** Leaves one comprehension, restoring the depth it interrupted. */
98
+ endComprehension(previous: number): void;
99
+ /**
100
+ * Refuses a comprehension source before the first element is bound.
101
+ *
102
+ * This is the per-source cap: one source no listing may exceed, and a list literal is held
103
+ * to the historical 10,000 floor through `elements`.
104
+ */
105
+ refuseElements(count: number): void;
106
+ /**
107
+ * Counts the elements one nested comprehension materialised, against the rule's cumulative
108
+ * charge.
109
+ *
110
+ * The caller charges only a comprehension that is itself inside another: the outermost one
111
+ * reads the declared source once, which is the work the rule's rows already bought, so two
112
+ * aggregates over one admissible array are not refused. The cumulative ceiling is the source
113
+ * ceiling `EXPR-17.1.1` states, not the per-source allowance, so the 900×900 shape is
114
+ * admitted and a nesting that multiplies past 1,000,000 elements is refused.
115
+ */
116
+ chargeElements(count: number): void;
117
+ /**
118
+ * Refuses a block of report entries before any of them is allocated.
119
+ *
120
+ * An item rule knows its row count before it evaluates the first row, so checking here keeps
121
+ * an over-ceiling shape from allocating a result per row only to throw on the last one. The
122
+ * check does not commit the count; `spendDecisions` records the entries actually produced.
123
+ */
124
+ ensureDecisionRoom(count: number, operation: string): void;
125
+ /** Counts the report entries one rule produced against the pass-wide decision ceiling. */
126
+ spendDecisions(count: number, operation: string): void;
127
+ }
128
+ /** The counters one rule's allowances interrupted, restored when the rule returns. */
129
+ export interface RuleAllowance {
130
+ /** Nodes the interrupted rule had visited. */
131
+ readonly visited: number;
132
+ /** Nested elements the interrupted rule had materialised. */
133
+ readonly charged: number;
134
+ /** Comprehension depth the interrupted rule was evaluating at. */
135
+ readonly depth: number;
136
+ }
137
+ /**
138
+ * The parameters a report states for a budget refusal, or `undefined` when the error is not
139
+ * one. The report names the limit and the dimension so a reader can size the record or split
140
+ * the expression without reading the evaluator.
141
+ */
142
+ export declare function budgetRefusalParams(error: AxiomError): Readonly<Record<string, WireValue>> | undefined;
143
+ //# sourceMappingURL=budget.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"budget.d.ts","sourceRoot":"","sources":["../../src/eval/budget.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAe,MAAM,oBAAoB,CAAC;AAE7D,OAAO,KAAK,EACV,aAAa,EAEb,WAAW,EAEX,SAAS,EACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAqFzD,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAC/B,gCAAgC;IAChC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,sCAAsC;IACtC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;;;OAOG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAiBD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS,aAAa,EAAE,GAAG,SAAS,EAC5C,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,CAiBR;AAED,uFAAuF;AACvF,wBAAgB,eAAe,CAC7B,KAAK,EAAE,SAAS,WAAW,EAAE,GAAG,SAAS,EACzC,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,GAC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