@noy-db/hub 0.8.0 → 0.9.0-pre.0

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 (533) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +8 -8
  3. package/codemods/0.4.0-pre.json +1 -1
  4. package/codemods/0.8.0-pre.json +1 -1
  5. package/dist/api-MSJXVYQG.js +18 -0
  6. package/dist/as/index.js +33 -23
  7. package/dist/as/index.js.map +1 -1
  8. package/dist/at/index.js +8 -8
  9. package/dist/attestation/index.js +18 -18
  10. package/dist/{backup-YE2VQ26S.js → backup-7RKNZMQO.js} +11 -11
  11. package/dist/blobs/index.js +12 -12
  12. package/dist/broker/index.js +19 -11
  13. package/dist/broker/index.js.map +1 -1
  14. package/dist/by/index.js +2 -2
  15. package/dist/capsule/contract.d.ts +1 -1
  16. package/dist/capsule/contract.js +6 -6
  17. package/dist/capsule/enclave-aes/broker/proof.d.ts +12 -3
  18. package/dist/capsule/enclave-aes/index.d.ts +1 -1
  19. package/dist/capsule/enclave-aes/index.js +40 -14
  20. package/dist/capsule/enclave-aes/index.js.map +1 -1
  21. package/dist/capsule/index.d.ts +1 -1
  22. package/dist/capsule/plumbing/record-codec.d.ts +7 -0
  23. package/dist/{capsule-VOLX3QRQ.js → capsule-57BDK7LG.js} +8 -8
  24. package/dist/cargo/index.js +32 -32
  25. package/dist/{chunk-A4XMIZT3.js → chunk-226V6XXJ.js} +41 -6
  26. package/dist/chunk-226V6XXJ.js.map +1 -0
  27. package/dist/{chunk-LNSVGRHO.js → chunk-2A56DSRI.js} +2 -2
  28. package/dist/chunk-2DX4JCRI.js +1 -0
  29. package/dist/{chunk-SV2PM2OY.js → chunk-2ELOCEXE.js} +1 -1
  30. package/dist/chunk-2ELOCEXE.js.map +1 -0
  31. package/dist/{chunk-6QVKPHBF.js → chunk-2WJKJZSO.js} +2 -2
  32. package/dist/{chunk-TKVUE4JF.js → chunk-2ZFD2UJC.js} +9 -9
  33. package/dist/{chunk-2AFX33YA.js → chunk-3V6LZHUO.js} +3 -3
  34. package/dist/chunk-3V6LZHUO.js.map +1 -0
  35. package/dist/{chunk-4JPMZTJY.js → chunk-3Y5JLSXS.js} +2 -2
  36. package/dist/{chunk-XSPFDUDG.js → chunk-45VHWE4C.js} +51 -16
  37. package/dist/chunk-45VHWE4C.js.map +1 -0
  38. package/dist/{chunk-LGNDFRYC.js → chunk-4CFHL5RY.js} +1 -1
  39. package/dist/chunk-4CFHL5RY.js.map +1 -0
  40. package/dist/{chunk-EZGV6F47.js → chunk-4J3MNVVX.js} +1 -1
  41. package/dist/{chunk-EZGV6F47.js.map → chunk-4J3MNVVX.js.map} +1 -1
  42. package/dist/{chunk-O2IMQSNA.js → chunk-4UIP3QNW.js} +2 -2
  43. package/dist/{chunk-EJLV62NI.js → chunk-55P6OBB7.js} +2 -2
  44. package/dist/{chunk-Y3LPTBG7.js → chunk-5HNW4ZTA.js} +6 -9
  45. package/dist/chunk-5HNW4ZTA.js.map +1 -0
  46. package/dist/{chunk-TEHHROZL.js → chunk-5LMCVBMY.js} +5 -5
  47. package/dist/{chunk-4V3Q35WG.js → chunk-5UUJE4FP.js} +3 -3
  48. package/dist/{chunk-JWWYRR4Q.js → chunk-5XONHAFD.js} +2 -2
  49. package/dist/{chunk-PD64727P.js → chunk-6QLCS7ET.js} +2 -2
  50. package/dist/chunk-6QLCS7ET.js.map +1 -0
  51. package/dist/{chunk-QBLT6POL.js → chunk-6WS35E6X.js} +2 -2
  52. package/dist/{chunk-IUBMZPHM.js → chunk-6Y5E4SJU.js} +5 -6
  53. package/dist/chunk-6Y5E4SJU.js.map +1 -0
  54. package/dist/{chunk-GZT3NQRA.js → chunk-72XBVN4J.js} +8 -2
  55. package/dist/{chunk-GZT3NQRA.js.map → chunk-72XBVN4J.js.map} +1 -1
  56. package/dist/{chunk-EYG2CY2X.js → chunk-7BMOS4JQ.js} +11 -11
  57. package/dist/chunk-7BMOS4JQ.js.map +1 -0
  58. package/dist/{chunk-UA372JHH.js → chunk-7CT6SX4M.js} +3 -3
  59. package/dist/chunk-7CT6SX4M.js.map +1 -0
  60. package/dist/{chunk-EZOAKKTB.js → chunk-ABU6A4Z5.js} +2 -2
  61. package/dist/{chunk-VKI2EB3N.js → chunk-AJFPAHMW.js} +3 -3
  62. package/dist/{chunk-DQESF6RP.js → chunk-APFFJN5T.js} +29 -16
  63. package/dist/chunk-APFFJN5T.js.map +1 -0
  64. package/dist/{chunk-2ODVB6LZ.js → chunk-B65CC6Z6.js} +2 -2
  65. package/dist/{chunk-MBMTND6D.js → chunk-BJH77UY2.js} +2 -2
  66. package/dist/{chunk-VAORSCSU.js → chunk-BMHQHH7Q.js} +2 -2
  67. package/dist/chunk-BMHQHH7Q.js.map +1 -0
  68. package/dist/{chunk-FFJFE4T7.js → chunk-BNFNQNEP.js} +2 -2
  69. package/dist/chunk-BU2ABHFW.js +74 -0
  70. package/dist/chunk-BU2ABHFW.js.map +1 -0
  71. package/dist/{chunk-5WWDGFOS.js → chunk-BUE7R3B5.js} +2 -2
  72. package/dist/{chunk-5FE75J4S.js → chunk-BVF3SXD7.js} +5 -5
  73. package/dist/{chunk-VFHCKG5M.js → chunk-BYHCKX73.js} +3 -3
  74. package/dist/{chunk-BVCUTXE3.js → chunk-C53ER7AG.js} +2 -2
  75. package/dist/{chunk-MILI22XQ.js → chunk-CAD7N6HQ.js} +3 -3
  76. package/dist/{chunk-5KC7QYEC.js → chunk-CB4467G3.js} +5 -5
  77. package/dist/{chunk-JIBUPZHA.js → chunk-D4V5JJAK.js} +4 -4
  78. package/dist/{chunk-DLD5LGDS.js → chunk-D5A3GCZ4.js} +3 -3
  79. package/dist/{chunk-FOEDQATO.js → chunk-DHU2AQ6T.js} +2 -2
  80. package/dist/{chunk-VHBKYN2J.js → chunk-DL6BZKP3.js} +2 -2
  81. package/dist/{chunk-NBQ3KK6X.js → chunk-EA4VDI5D.js} +4 -4
  82. package/dist/chunk-EA4VDI5D.js.map +1 -0
  83. package/dist/{chunk-E2N2T5ZO.js → chunk-ECGXA4LT.js} +2 -2
  84. package/dist/{chunk-PP3K67AJ.js → chunk-EMAWOGVH.js} +3 -3
  85. package/dist/{chunk-WXE4W2U6.js → chunk-EUD3HQM4.js} +4 -4
  86. package/dist/{chunk-MXOQ5JCG.js → chunk-FSQNGPHH.js} +171 -124
  87. package/dist/chunk-FSQNGPHH.js.map +1 -0
  88. package/dist/{chunk-LIOVX5TJ.js → chunk-FZXRLNJO.js} +3 -3
  89. package/dist/{chunk-WPOYWFSE.js → chunk-G46JSSVX.js} +7 -7
  90. package/dist/{chunk-JSMTXZR3.js → chunk-G5EDYVSE.js} +8 -6
  91. package/dist/chunk-G5EDYVSE.js.map +1 -0
  92. package/dist/chunk-G66YXUTY.js +60 -0
  93. package/dist/chunk-G66YXUTY.js.map +1 -0
  94. package/dist/{chunk-FFWI7UH7.js → chunk-GAGT3YZN.js} +1 -1
  95. package/dist/chunk-GAGT3YZN.js.map +1 -0
  96. package/dist/{chunk-AEQGFRU4.js → chunk-GCUMOKTN.js} +3 -3
  97. package/dist/{chunk-244QBK7Z.js → chunk-GETUTTZU.js} +4 -4
  98. package/dist/{chunk-244QBK7Z.js.map → chunk-GETUTTZU.js.map} +1 -1
  99. package/dist/{chunk-V3RWOOSO.js → chunk-GOJQ5DZA.js} +4 -4
  100. package/dist/{chunk-UEFOQH74.js → chunk-GRS2HIV6.js} +2 -2
  101. package/dist/{chunk-3L2NBKDR.js → chunk-H3YM66EI.js} +2 -2
  102. package/dist/{chunk-3A5DUZ56.js → chunk-IVMFIKNA.js} +6 -6
  103. package/dist/{chunk-3A5DUZ56.js.map → chunk-IVMFIKNA.js.map} +1 -1
  104. package/dist/{chunk-747G6CT3.js → chunk-J4KAPKBJ.js} +2 -2
  105. package/dist/{chunk-H23XHRTT.js → chunk-JA25QG5M.js} +211 -6
  106. package/dist/chunk-JA25QG5M.js.map +1 -0
  107. package/dist/{chunk-T7IR4N2S.js → chunk-JBMMWYOH.js} +3 -1
  108. package/dist/{chunk-T7IR4N2S.js.map → chunk-JBMMWYOH.js.map} +1 -1
  109. package/dist/{chunk-MXKI4ABF.js → chunk-JPSL5GIZ.js} +3 -3
  110. package/dist/{chunk-2GHDLTPE.js → chunk-JSWKVZCR.js} +2 -2
  111. package/dist/{chunk-BNWA3WG5.js → chunk-JZ4EDEIP.js} +3 -3
  112. package/dist/{chunk-GUZET4SG.js → chunk-K673OO6B.js} +4 -4
  113. package/dist/chunk-K673OO6B.js.map +1 -0
  114. package/dist/{chunk-5UMK7GRI.js → chunk-K7RW7FI4.js} +5 -5
  115. package/dist/{chunk-N7EVQD5S.js → chunk-L2F3CFCH.js} +4 -4
  116. package/dist/{chunk-2PVXF5CS.js → chunk-L5A3KR7R.js} +3 -3
  117. package/dist/{chunk-O46CHQT7.js → chunk-LGGIFKJP.js} +4 -4
  118. package/dist/{chunk-Y2RKVFKR.js → chunk-MQ7YWBQ5.js} +2 -2
  119. package/dist/{chunk-4CIQDWRB.js → chunk-MRJDLXI3.js} +14 -8
  120. package/dist/{chunk-4CIQDWRB.js.map → chunk-MRJDLXI3.js.map} +1 -1
  121. package/dist/{chunk-YRXFFWG4.js → chunk-NIXRB5BP.js} +2 -2
  122. package/dist/{chunk-RHVMZSUU.js → chunk-NV4OESHC.js} +1 -1
  123. package/dist/chunk-NV4OESHC.js.map +1 -0
  124. package/dist/{chunk-V7ADQF5O.js → chunk-NYJBYVBG.js} +4 -4
  125. package/dist/{chunk-23D6M6VM.js → chunk-NZULV7LK.js} +4 -4
  126. package/dist/{chunk-HW7CMKUG.js → chunk-OFD2HD6F.js} +1 -1
  127. package/dist/{chunk-HW7CMKUG.js.map → chunk-OFD2HD6F.js.map} +1 -1
  128. package/dist/{chunk-BPWYQ25R.js → chunk-OJU67C23.js} +4 -4
  129. package/dist/{chunk-BPWYQ25R.js.map → chunk-OJU67C23.js.map} +1 -1
  130. package/dist/{chunk-AUKKUPVB.js → chunk-OK57EATL.js} +2 -2
  131. package/dist/{chunk-42ALPZ2B.js → chunk-OM3SEDI4.js} +4 -4
  132. package/dist/{chunk-42ALPZ2B.js.map → chunk-OM3SEDI4.js.map} +1 -1
  133. package/dist/{chunk-OYW3I5M4.js → chunk-PCYPXLEX.js} +6 -6
  134. package/dist/{chunk-2MG3SW7Q.js → chunk-PFCTSXHU.js} +2 -2
  135. package/dist/{chunk-FVH5QYY2.js → chunk-PGC35KXE.js} +2 -2
  136. package/dist/{chunk-NCO25JZO.js → chunk-PT2YCQVK.js} +4 -4
  137. package/dist/{chunk-SYNY3VB5.js → chunk-PTJY5R3O.js} +2 -2
  138. package/dist/{chunk-QMWY2FDS.js → chunk-PUBI455O.js} +2 -2
  139. package/dist/{chunk-VMV5SBE4.js → chunk-QDHHHI5Q.js} +5 -5
  140. package/dist/{chunk-JQYKPKG6.js → chunk-QGFEBNHO.js} +4 -4
  141. package/dist/{chunk-52MGURXO.js → chunk-QGSNJD3B.js} +2 -2
  142. package/dist/chunk-QJNAHPVT.js +91 -0
  143. package/dist/chunk-QJNAHPVT.js.map +1 -0
  144. package/dist/{chunk-VVOLDVIR.js → chunk-QSHATAXJ.js} +2 -2
  145. package/dist/{chunk-G2MVBDFP.js → chunk-QXJXG7DN.js} +39 -9
  146. package/dist/chunk-QXJXG7DN.js.map +1 -0
  147. package/dist/{chunk-KZXDLBY6.js → chunk-RDOEOPOI.js} +5 -5
  148. package/dist/{chunk-FLPCETP6.js → chunk-RIZTZJX6.js} +2 -2
  149. package/dist/{chunk-H427H63K.js → chunk-RNACRT5H.js} +2 -2
  150. package/dist/chunk-RWFQVNXR.js +24 -0
  151. package/dist/chunk-RWFQVNXR.js.map +1 -0
  152. package/dist/{chunk-JOSPH3E5.js → chunk-SFCD6OU7.js} +2 -2
  153. package/dist/{chunk-IMQKWR46.js → chunk-SNM7LSYG.js} +4 -5
  154. package/dist/chunk-SNM7LSYG.js.map +1 -0
  155. package/dist/{chunk-Q2XRFWOI.js → chunk-SPPOUJLN.js} +2 -2
  156. package/dist/{chunk-EGVJ7TM4.js → chunk-SWXLZ4HX.js} +8 -9
  157. package/dist/chunk-SWXLZ4HX.js.map +1 -0
  158. package/dist/{chunk-H7JBY4P7.js → chunk-TFWFPZRU.js} +13 -13
  159. package/dist/chunk-TFWFPZRU.js.map +1 -0
  160. package/dist/{chunk-VQDZYB2B.js → chunk-TMIJAR2X.js} +3 -3
  161. package/dist/{chunk-VQDZYB2B.js.map → chunk-TMIJAR2X.js.map} +1 -1
  162. package/dist/{chunk-RB4DOPGZ.js → chunk-TZYTMZZY.js} +10 -10
  163. package/dist/{chunk-Q4UHJ5SN.js → chunk-UAKY6E4N.js} +2 -2
  164. package/dist/chunk-UHFGK6YA.js +40 -0
  165. package/dist/chunk-UHFGK6YA.js.map +1 -0
  166. package/dist/{chunk-DIZLQVAA.js → chunk-UNSQZSZP.js} +2 -2
  167. package/dist/{chunk-4T3SE27M.js → chunk-UOZOWN73.js} +2 -2
  168. package/dist/{chunk-OKSTSITU.js → chunk-V55JASXO.js} +3 -3
  169. package/dist/{chunk-37EPTBBR.js → chunk-VSUQI5Q6.js} +32 -4
  170. package/dist/chunk-VSUQI5Q6.js.map +1 -0
  171. package/dist/{chunk-XQRFSKYM.js → chunk-WFWFXDNS.js} +2 -2
  172. package/dist/{chunk-N7UDP5VU.js → chunk-WHOKGHJ3.js} +7 -7
  173. package/dist/{chunk-7R2Q7CPL.js → chunk-X2RP4TO5.js} +7 -7
  174. package/dist/{chunk-U2FZNEWJ.js → chunk-XA34THLF.js} +8 -6
  175. package/dist/{chunk-U2FZNEWJ.js.map → chunk-XA34THLF.js.map} +1 -1
  176. package/dist/{chunk-UIYESRD6.js → chunk-XITHENBI.js} +9 -9
  177. package/dist/{chunk-UIYESRD6.js.map → chunk-XITHENBI.js.map} +1 -1
  178. package/dist/{chunk-3XJQBBZD.js → chunk-XKBTJGFP.js} +2 -2
  179. package/dist/{chunk-SMV2HRDU.js → chunk-XXNWU5QZ.js} +2 -2
  180. package/dist/{chunk-TZZBXPZK.js → chunk-XXQ5XIYY.js} +2 -2
  181. package/dist/{chunk-3EWS67C7.js → chunk-YFFMPZPY.js} +2 -2
  182. package/dist/{chunk-M5B2W6YY.js → chunk-YKGJ44Z7.js} +3 -3
  183. package/dist/{chunk-5A4345TG.js → chunk-YQFBH5ZJ.js} +3 -3
  184. package/dist/{chunk-DHHGL42E.js → chunk-Z3ZXVB2Y.js} +22 -6
  185. package/dist/chunk-Z3ZXVB2Y.js.map +1 -0
  186. package/dist/{chunk-OIEO4WDL.js → chunk-ZBUAX4EF.js} +2 -2
  187. package/dist/chunk-ZBUAX4EF.js.map +1 -0
  188. package/dist/{chunk-HS554XAF.js → chunk-ZHQJAV6D.js} +2 -2
  189. package/dist/{chunk-IUT3GWP3.js → chunk-ZMVSKYTJ.js} +17 -93
  190. package/dist/chunk-ZMVSKYTJ.js.map +1 -0
  191. package/dist/{chunk-AL6ML4LA.js → chunk-ZVSKSUGI.js} +5 -5
  192. package/dist/{chunk-JDEYF3PJ.js → chunk-ZWF3EWZA.js} +2 -2
  193. package/dist/chunk-ZWF3EWZA.js.map +1 -0
  194. package/dist/classified/index.js +5 -5
  195. package/dist/{classified-marker-SIYKUU5L.js → classified-marker-KHDOYIJB.js} +3 -3
  196. package/dist/collection-facade-LZIF7GWD.js +41 -0
  197. package/dist/{computed-FAD7SED4.js → computed-XMFTHAXV.js} +3 -3
  198. package/dist/consent/index.js +8 -8
  199. package/dist/cover/index.js +8 -8
  200. package/dist/coverage/index.js +1 -1
  201. package/dist/custody/index.js +12 -11
  202. package/dist/{dead-filter-4F3LWYKH.js → dead-filter-CXV5NS67.js} +10 -10
  203. package/dist/debug/index.js +7 -7
  204. package/dist/{delegation-NANZDG4N.js → delegation-ONLM4JFI.js} +49 -25
  205. package/dist/delegation-ONLM4JFI.js.map +1 -0
  206. package/dist/derivations/index.js +24 -23
  207. package/dist/derive-3YSIS36W.js +20 -0
  208. package/dist/directory/index.js +9 -9
  209. package/dist/{dispatch-JDZNGEB3.js → dispatch-2MQFMEGY.js} +20 -20
  210. package/dist/{dispatch-H4HV32AM.js → dispatch-OFDA4WQV.js} +5 -5
  211. package/dist/executor-E6YDJ7YA.js +8 -0
  212. package/dist/executor-NJX3YQQ4.js +35 -0
  213. package/dist/executor-WWM3DD4P.js +8 -0
  214. package/dist/export-accessible-RLHU5G4W.js +22 -0
  215. package/dist/extract-partition-QII2EDCS.js +35 -0
  216. package/dist/{fanout-sidecar-L7NHPIOC.js → fanout-sidecar-BO67PCPO.js} +8 -8
  217. package/dist/find-6M7GYDUZ.js +10 -0
  218. package/dist/forget/index.js +25 -8
  219. package/dist/forget/index.js.map +1 -1
  220. package/dist/guards/index.js +4 -4
  221. package/dist/history/index.js +12 -12
  222. package/dist/i18n/index.js +13 -13
  223. package/dist/index.d.ts +8 -6
  224. package/dist/index.js +122 -110
  225. package/dist/index.js.map +1 -1
  226. package/dist/indexing/index.js +6 -6
  227. package/dist/introspection/index.js +15 -11
  228. package/dist/issue-LPEEEMPP.js +19 -0
  229. package/dist/kernel/cache/index.d.ts +1 -1
  230. package/dist/kernel/collection.d.ts +1 -0
  231. package/dist/kernel/errors.d.ts +33 -4
  232. package/dist/kernel/export-scope.d.ts +40 -0
  233. package/dist/kernel/noydb.d.ts +3 -1
  234. package/dist/kernel/put-many-atomic.d.ts +1 -1
  235. package/dist/kernel/query/live/live.d.ts +2 -1
  236. package/dist/kernel/query/sort-key.d.ts +0 -2
  237. package/dist/kernel/tx-write-gate.d.ts +2 -4
  238. package/dist/kernel/types.d.ts +93 -6
  239. package/dist/kernel/validation.d.ts +0 -10
  240. package/dist/kernel/vault.d.ts +4 -0
  241. package/dist/kernel/via/reconcile.d.ts +1 -42
  242. package/dist/{ledger-5ZMGE44K.js → ledger-MSJGWKGW.js} +10 -10
  243. package/dist/liberate-LEKDYKTC.js +25 -0
  244. package/dist/{link-set-MFXC24VK.js → link-set-QXXSPPHL.js} +10 -10
  245. package/dist/{managed-secret-MFTFT22X.js → managed-secret-VSK7ANQI.js} +9 -9
  246. package/dist/materialized-views/index.js +26 -26
  247. package/dist/{migrate-cek-DZRFFOHW.js → migrate-cek-GEBFYBDC.js} +2 -2
  248. package/dist/money/index.js +5 -5
  249. package/dist/noydb-F2AUF6KL.js +98 -0
  250. package/dist/on/index.js +25 -0
  251. package/dist/overlay-views/index.js +4 -4
  252. package/dist/periods/index.js +11 -11
  253. package/dist/pod/index.js +69 -67
  254. package/dist/{pod-handle-A3LET7NO.js → pod-handle-YE7CT66T.js} +8 -8
  255. package/dist/policy/index.js +9 -9
  256. package/dist/port/as/active.d.ts +4 -0
  257. package/dist/port/as/index.d.ts +1 -0
  258. package/dist/port/by/index.d.ts +14 -5
  259. package/dist/port/on/index.d.ts +26 -0
  260. package/dist/port/to/index.d.ts +1 -1
  261. package/dist/port/with/broker-strategy.d.ts +14 -0
  262. package/dist/port/with/coverage-strategy.d.ts +17 -1
  263. package/dist/port/with/formats-strategy.d.ts +34 -1
  264. package/dist/port/with/lookup-strategy.d.ts +85 -4
  265. package/dist/port/with/service-bus.d.ts +2 -1
  266. package/dist/portability/index.js +8 -8
  267. package/dist/{post-register-7ND27CF2.js → post-register-QC5TEAW3.js} +6 -6
  268. package/dist/query/all/index.js +16 -16
  269. package/dist/query/index.js +8 -8
  270. package/dist/query/live/index.js +7 -7
  271. package/dist/query/reduce/index.js +10 -10
  272. package/dist/query/relate/index.js +10 -10
  273. package/dist/reduce/index.js +8 -8
  274. package/dist/register-SN72QALV.js +30 -0
  275. package/dist/registry-253FF7C6.js +35 -0
  276. package/dist/registry-3AZWQTDT.js +23 -0
  277. package/dist/registry-7UEBTHWG.js +8 -0
  278. package/dist/registry-IVJ67NFQ.js +8 -0
  279. package/dist/request-withdrawal-UKVJZKX2.js +28 -0
  280. package/dist/{reveal-B2TLP4JQ.js → reveal-YQTRNQFH.js} +7 -7
  281. package/dist/revoke-G2KXJQA5.js +24 -0
  282. package/dist/satellites/index.js +1 -1
  283. package/dist/schema-update/index.js +2 -2
  284. package/dist/sealed-record/index.js +11 -11
  285. package/dist/search/index.js +4 -4
  286. package/dist/{seed-XNSE4U3S.js → seed-JMQTRKRE.js} +121 -27
  287. package/dist/seed-JMQTRKRE.js.map +1 -0
  288. package/dist/sequence/index.js +8 -8
  289. package/dist/session/index.js +8 -8
  290. package/dist/shadow/index.js +2 -2
  291. package/dist/signer-IUIYR3CX.js +23 -0
  292. package/dist/snapshots/index.js +9 -9
  293. package/dist/{stale-6GCFMOOR.js → stale-SKV33PBU.js} +9 -9
  294. package/dist/storage-NPBYP2SM.js +21 -0
  295. package/dist/{store-coordination-provider-C4BPT5XF.js → store-coordination-provider-Z6HKPOGM.js} +9 -9
  296. package/dist/sync/index.js +17 -11
  297. package/dist/sync/index.js.map +1 -1
  298. package/dist/team/index.js +17 -15
  299. package/dist/tiers/index.js +10 -10
  300. package/dist/to/index.js +2 -2
  301. package/dist/transactions/index.js +3 -3
  302. package/dist/util/index.js +1 -1
  303. package/dist/vault-head/index.js +8 -8
  304. package/dist/{verify-UKALW7C2.js → verify-KWQIWLGH.js} +7 -7
  305. package/dist/via/classified/presets.d.ts +29 -0
  306. package/dist/via/classified/resolve.d.ts +7 -0
  307. package/dist/via/geo/binding.d.ts +0 -4
  308. package/dist/via/lookup/index.d.ts +32 -0
  309. package/dist/via/money/binding.d.ts +0 -9
  310. package/dist/walk-F4OLXI5H.js +20 -0
  311. package/dist/with-audit/attestation/strategy.d.ts +2 -1
  312. package/dist/with-audit/attestation/vault-facade.d.ts +7 -0
  313. package/dist/with-audit/forget/completeness.d.ts +66 -0
  314. package/dist/with-audit/forget/index.d.ts +2 -0
  315. package/dist/with-audit/forget/strategy.d.ts +65 -0
  316. package/dist/with-audit/periods/periods.d.ts +0 -9
  317. package/dist/with-audit/periods/reserved-collections.d.ts +7 -0
  318. package/dist/with-audit/portability/request-withdrawal.d.ts +0 -1
  319. package/dist/with-audit/portability/withdraw-accessible.d.ts +0 -1
  320. package/dist/with-audit/tiers/index.d.ts +1 -1
  321. package/dist/with-audit/tiers/strategy.d.ts +19 -0
  322. package/dist/with-cargo/extract-partition.d.ts +0 -46
  323. package/dist/with-commit/numbering/index.d.ts +0 -2
  324. package/dist/with-commit/tx/transaction.d.ts +2 -24
  325. package/dist/with-commit/vault-head/strategy.d.ts +7 -0
  326. package/dist/with-fork/snapshots/noydb-facade.d.ts +7 -0
  327. package/dist/with-formula/derivations/trigger-match.d.ts +8 -5
  328. package/dist/with-formula/materialized-views/emit-memo.d.ts +0 -2
  329. package/dist/with-lookup/embeddings/index.d.ts +1 -2
  330. package/dist/with-lookup/indexing/collection-facade.d.ts +1 -15
  331. package/dist/with-lookup/indexing/eager-indexes.d.ts +2 -1
  332. package/dist/with-lookup/search/collection-facade.d.ts +0 -12
  333. package/dist/with-party/broker/index.d.ts +2 -2
  334. package/dist/with-party/broker/seed.d.ts +25 -10
  335. package/dist/with-party/policy/noydb-facade.d.ts +1 -31
  336. package/dist/with-party/team/delegation.d.ts +58 -2
  337. package/dist/with-party/team/echo-secret.d.ts +0 -2
  338. package/dist/with-party/team/keyring.d.ts +1 -21
  339. package/dist/with-party/team/magic-link-grant.d.ts +11 -1
  340. package/dist/with-party/team/noydb-facade.d.ts +5 -0
  341. package/dist/with-party/team/reserved-secret-collections.d.ts +10 -8
  342. package/dist/with-party/team/roster-tag.d.ts +42 -1
  343. package/dist/with-party/team/tiers.d.ts +36 -5
  344. package/dist/with-shape/blobs/blob-set.d.ts +23 -0
  345. package/dist/with-shape/blobs/legacy-sweep.d.ts +16 -0
  346. package/dist/with-shape/introspection/describe.d.ts +1 -2
  347. package/dist/with-shape/introspection/index.d.ts +1 -0
  348. package/dist/with-shape/introspection/types.d.ts +2 -1
  349. package/dist/with-shape/schema-update/fence.d.ts +7 -0
  350. package/dist/with-sync/engine.d.ts +30 -1
  351. package/dist/with-sync/reserved-mirror.d.ts +89 -0
  352. package/dist/with-sync/strategy.d.ts +7 -0
  353. package/dist/with-sync/tab-write-relay.d.ts +0 -10
  354. package/dist/withdraw-accessible-ZKPLZ66E.js +25 -0
  355. package/package.json +3 -3
  356. package/dist/api-OS747DS4.js +0 -18
  357. package/dist/chunk-2AFX33YA.js.map +0 -1
  358. package/dist/chunk-2RH777HH.js +0 -126
  359. package/dist/chunk-2RH777HH.js.map +0 -1
  360. package/dist/chunk-37EPTBBR.js.map +0 -1
  361. package/dist/chunk-7XMHMVTS.js +0 -20
  362. package/dist/chunk-7XMHMVTS.js.map +0 -1
  363. package/dist/chunk-A4XMIZT3.js.map +0 -1
  364. package/dist/chunk-DHHGL42E.js.map +0 -1
  365. package/dist/chunk-DQESF6RP.js.map +0 -1
  366. package/dist/chunk-EGVJ7TM4.js.map +0 -1
  367. package/dist/chunk-EYG2CY2X.js.map +0 -1
  368. package/dist/chunk-FFWI7UH7.js.map +0 -1
  369. package/dist/chunk-G2MVBDFP.js.map +0 -1
  370. package/dist/chunk-GUZET4SG.js.map +0 -1
  371. package/dist/chunk-H23XHRTT.js.map +0 -1
  372. package/dist/chunk-H7JBY4P7.js.map +0 -1
  373. package/dist/chunk-IMQKWR46.js.map +0 -1
  374. package/dist/chunk-IUBMZPHM.js.map +0 -1
  375. package/dist/chunk-IUT3GWP3.js.map +0 -1
  376. package/dist/chunk-JDEYF3PJ.js.map +0 -1
  377. package/dist/chunk-JSMTXZR3.js.map +0 -1
  378. package/dist/chunk-LGNDFRYC.js.map +0 -1
  379. package/dist/chunk-MXOQ5JCG.js.map +0 -1
  380. package/dist/chunk-NBQ3KK6X.js.map +0 -1
  381. package/dist/chunk-OIEO4WDL.js.map +0 -1
  382. package/dist/chunk-PD64727P.js.map +0 -1
  383. package/dist/chunk-RHVMZSUU.js.map +0 -1
  384. package/dist/chunk-SV2PM2OY.js.map +0 -1
  385. package/dist/chunk-UA372JHH.js.map +0 -1
  386. package/dist/chunk-UBSFPGVJ.js +0 -1
  387. package/dist/chunk-VAORSCSU.js.map +0 -1
  388. package/dist/chunk-XSPFDUDG.js.map +0 -1
  389. package/dist/chunk-Y3LPTBG7.js.map +0 -1
  390. package/dist/collection-facade-CS7CA2XO.js +0 -47
  391. package/dist/delegation-NANZDG4N.js.map +0 -1
  392. package/dist/derive-XLOJVXPU.js +0 -20
  393. package/dist/executor-FMPVN6DT.js +0 -35
  394. package/dist/executor-LBBBRTN5.js +0 -8
  395. package/dist/executor-OSRZST2U.js +0 -8
  396. package/dist/export-accessible-RAOJAAU5.js +0 -22
  397. package/dist/extract-partition-JD5CUSTG.js +0 -37
  398. package/dist/find-JRN4RNQ5.js +0 -10
  399. package/dist/issue-YIVBZUTH.js +0 -19
  400. package/dist/liberate-WZSZM2W6.js +0 -24
  401. package/dist/noydb-ITIGNKUF.js +0 -96
  402. package/dist/register-DT5HZ2LZ.js +0 -30
  403. package/dist/registry-BHRZGZHF.js +0 -8
  404. package/dist/registry-ET6ZFFWA.js +0 -34
  405. package/dist/registry-HXFGLGTG.js +0 -8
  406. package/dist/registry-THCPDEOD.js +0 -23
  407. package/dist/request-withdrawal-AV2MJJKY.js +0 -30
  408. package/dist/revoke-6DWIEOCV.js +0 -24
  409. package/dist/seed-XNSE4U3S.js.map +0 -1
  410. package/dist/signer-MHGW3OIL.js +0 -23
  411. package/dist/storage-BYN5LO6Z.js +0 -21
  412. package/dist/walk-4VPK7AS4.js +0 -20
  413. package/dist/withdraw-accessible-HL7GACUE.js +0 -27
  414. /package/dist/{api-OS747DS4.js.map → api-MSJXVYQG.js.map} +0 -0
  415. /package/dist/{backup-YE2VQ26S.js.map → backup-7RKNZMQO.js.map} +0 -0
  416. /package/dist/{capsule-VOLX3QRQ.js.map → capsule-57BDK7LG.js.map} +0 -0
  417. /package/dist/{chunk-LNSVGRHO.js.map → chunk-2A56DSRI.js.map} +0 -0
  418. /package/dist/{chunk-UBSFPGVJ.js.map → chunk-2DX4JCRI.js.map} +0 -0
  419. /package/dist/{chunk-6QVKPHBF.js.map → chunk-2WJKJZSO.js.map} +0 -0
  420. /package/dist/{chunk-TKVUE4JF.js.map → chunk-2ZFD2UJC.js.map} +0 -0
  421. /package/dist/{chunk-4JPMZTJY.js.map → chunk-3Y5JLSXS.js.map} +0 -0
  422. /package/dist/{chunk-O2IMQSNA.js.map → chunk-4UIP3QNW.js.map} +0 -0
  423. /package/dist/{chunk-EJLV62NI.js.map → chunk-55P6OBB7.js.map} +0 -0
  424. /package/dist/{chunk-TEHHROZL.js.map → chunk-5LMCVBMY.js.map} +0 -0
  425. /package/dist/{chunk-4V3Q35WG.js.map → chunk-5UUJE4FP.js.map} +0 -0
  426. /package/dist/{chunk-JWWYRR4Q.js.map → chunk-5XONHAFD.js.map} +0 -0
  427. /package/dist/{chunk-QBLT6POL.js.map → chunk-6WS35E6X.js.map} +0 -0
  428. /package/dist/{chunk-EZOAKKTB.js.map → chunk-ABU6A4Z5.js.map} +0 -0
  429. /package/dist/{chunk-VKI2EB3N.js.map → chunk-AJFPAHMW.js.map} +0 -0
  430. /package/dist/{chunk-2ODVB6LZ.js.map → chunk-B65CC6Z6.js.map} +0 -0
  431. /package/dist/{chunk-MBMTND6D.js.map → chunk-BJH77UY2.js.map} +0 -0
  432. /package/dist/{chunk-FFJFE4T7.js.map → chunk-BNFNQNEP.js.map} +0 -0
  433. /package/dist/{chunk-5WWDGFOS.js.map → chunk-BUE7R3B5.js.map} +0 -0
  434. /package/dist/{chunk-5FE75J4S.js.map → chunk-BVF3SXD7.js.map} +0 -0
  435. /package/dist/{chunk-VFHCKG5M.js.map → chunk-BYHCKX73.js.map} +0 -0
  436. /package/dist/{chunk-BVCUTXE3.js.map → chunk-C53ER7AG.js.map} +0 -0
  437. /package/dist/{chunk-MILI22XQ.js.map → chunk-CAD7N6HQ.js.map} +0 -0
  438. /package/dist/{chunk-5KC7QYEC.js.map → chunk-CB4467G3.js.map} +0 -0
  439. /package/dist/{chunk-JIBUPZHA.js.map → chunk-D4V5JJAK.js.map} +0 -0
  440. /package/dist/{chunk-DLD5LGDS.js.map → chunk-D5A3GCZ4.js.map} +0 -0
  441. /package/dist/{chunk-FOEDQATO.js.map → chunk-DHU2AQ6T.js.map} +0 -0
  442. /package/dist/{chunk-VHBKYN2J.js.map → chunk-DL6BZKP3.js.map} +0 -0
  443. /package/dist/{chunk-E2N2T5ZO.js.map → chunk-ECGXA4LT.js.map} +0 -0
  444. /package/dist/{chunk-PP3K67AJ.js.map → chunk-EMAWOGVH.js.map} +0 -0
  445. /package/dist/{chunk-WXE4W2U6.js.map → chunk-EUD3HQM4.js.map} +0 -0
  446. /package/dist/{chunk-LIOVX5TJ.js.map → chunk-FZXRLNJO.js.map} +0 -0
  447. /package/dist/{chunk-WPOYWFSE.js.map → chunk-G46JSSVX.js.map} +0 -0
  448. /package/dist/{chunk-AEQGFRU4.js.map → chunk-GCUMOKTN.js.map} +0 -0
  449. /package/dist/{chunk-V3RWOOSO.js.map → chunk-GOJQ5DZA.js.map} +0 -0
  450. /package/dist/{chunk-UEFOQH74.js.map → chunk-GRS2HIV6.js.map} +0 -0
  451. /package/dist/{chunk-3L2NBKDR.js.map → chunk-H3YM66EI.js.map} +0 -0
  452. /package/dist/{chunk-747G6CT3.js.map → chunk-J4KAPKBJ.js.map} +0 -0
  453. /package/dist/{chunk-MXKI4ABF.js.map → chunk-JPSL5GIZ.js.map} +0 -0
  454. /package/dist/{chunk-2GHDLTPE.js.map → chunk-JSWKVZCR.js.map} +0 -0
  455. /package/dist/{chunk-BNWA3WG5.js.map → chunk-JZ4EDEIP.js.map} +0 -0
  456. /package/dist/{chunk-5UMK7GRI.js.map → chunk-K7RW7FI4.js.map} +0 -0
  457. /package/dist/{chunk-N7EVQD5S.js.map → chunk-L2F3CFCH.js.map} +0 -0
  458. /package/dist/{chunk-2PVXF5CS.js.map → chunk-L5A3KR7R.js.map} +0 -0
  459. /package/dist/{chunk-O46CHQT7.js.map → chunk-LGGIFKJP.js.map} +0 -0
  460. /package/dist/{chunk-Y2RKVFKR.js.map → chunk-MQ7YWBQ5.js.map} +0 -0
  461. /package/dist/{chunk-YRXFFWG4.js.map → chunk-NIXRB5BP.js.map} +0 -0
  462. /package/dist/{chunk-V7ADQF5O.js.map → chunk-NYJBYVBG.js.map} +0 -0
  463. /package/dist/{chunk-23D6M6VM.js.map → chunk-NZULV7LK.js.map} +0 -0
  464. /package/dist/{chunk-AUKKUPVB.js.map → chunk-OK57EATL.js.map} +0 -0
  465. /package/dist/{chunk-OYW3I5M4.js.map → chunk-PCYPXLEX.js.map} +0 -0
  466. /package/dist/{chunk-2MG3SW7Q.js.map → chunk-PFCTSXHU.js.map} +0 -0
  467. /package/dist/{chunk-FVH5QYY2.js.map → chunk-PGC35KXE.js.map} +0 -0
  468. /package/dist/{chunk-NCO25JZO.js.map → chunk-PT2YCQVK.js.map} +0 -0
  469. /package/dist/{chunk-SYNY3VB5.js.map → chunk-PTJY5R3O.js.map} +0 -0
  470. /package/dist/{chunk-QMWY2FDS.js.map → chunk-PUBI455O.js.map} +0 -0
  471. /package/dist/{chunk-VMV5SBE4.js.map → chunk-QDHHHI5Q.js.map} +0 -0
  472. /package/dist/{chunk-JQYKPKG6.js.map → chunk-QGFEBNHO.js.map} +0 -0
  473. /package/dist/{chunk-52MGURXO.js.map → chunk-QGSNJD3B.js.map} +0 -0
  474. /package/dist/{chunk-VVOLDVIR.js.map → chunk-QSHATAXJ.js.map} +0 -0
  475. /package/dist/{chunk-KZXDLBY6.js.map → chunk-RDOEOPOI.js.map} +0 -0
  476. /package/dist/{chunk-FLPCETP6.js.map → chunk-RIZTZJX6.js.map} +0 -0
  477. /package/dist/{chunk-H427H63K.js.map → chunk-RNACRT5H.js.map} +0 -0
  478. /package/dist/{chunk-JOSPH3E5.js.map → chunk-SFCD6OU7.js.map} +0 -0
  479. /package/dist/{chunk-Q2XRFWOI.js.map → chunk-SPPOUJLN.js.map} +0 -0
  480. /package/dist/{chunk-RB4DOPGZ.js.map → chunk-TZYTMZZY.js.map} +0 -0
  481. /package/dist/{chunk-Q4UHJ5SN.js.map → chunk-UAKY6E4N.js.map} +0 -0
  482. /package/dist/{chunk-DIZLQVAA.js.map → chunk-UNSQZSZP.js.map} +0 -0
  483. /package/dist/{chunk-4T3SE27M.js.map → chunk-UOZOWN73.js.map} +0 -0
  484. /package/dist/{chunk-OKSTSITU.js.map → chunk-V55JASXO.js.map} +0 -0
  485. /package/dist/{chunk-XQRFSKYM.js.map → chunk-WFWFXDNS.js.map} +0 -0
  486. /package/dist/{chunk-N7UDP5VU.js.map → chunk-WHOKGHJ3.js.map} +0 -0
  487. /package/dist/{chunk-7R2Q7CPL.js.map → chunk-X2RP4TO5.js.map} +0 -0
  488. /package/dist/{chunk-3XJQBBZD.js.map → chunk-XKBTJGFP.js.map} +0 -0
  489. /package/dist/{chunk-SMV2HRDU.js.map → chunk-XXNWU5QZ.js.map} +0 -0
  490. /package/dist/{chunk-TZZBXPZK.js.map → chunk-XXQ5XIYY.js.map} +0 -0
  491. /package/dist/{chunk-3EWS67C7.js.map → chunk-YFFMPZPY.js.map} +0 -0
  492. /package/dist/{chunk-M5B2W6YY.js.map → chunk-YKGJ44Z7.js.map} +0 -0
  493. /package/dist/{chunk-5A4345TG.js.map → chunk-YQFBH5ZJ.js.map} +0 -0
  494. /package/dist/{chunk-HS554XAF.js.map → chunk-ZHQJAV6D.js.map} +0 -0
  495. /package/dist/{chunk-AL6ML4LA.js.map → chunk-ZVSKSUGI.js.map} +0 -0
  496. /package/dist/{classified-marker-SIYKUU5L.js.map → classified-marker-KHDOYIJB.js.map} +0 -0
  497. /package/dist/{collection-facade-CS7CA2XO.js.map → collection-facade-LZIF7GWD.js.map} +0 -0
  498. /package/dist/{computed-FAD7SED4.js.map → computed-XMFTHAXV.js.map} +0 -0
  499. /package/dist/{dead-filter-4F3LWYKH.js.map → dead-filter-CXV5NS67.js.map} +0 -0
  500. /package/dist/{derive-XLOJVXPU.js.map → derive-3YSIS36W.js.map} +0 -0
  501. /package/dist/{dispatch-JDZNGEB3.js.map → dispatch-2MQFMEGY.js.map} +0 -0
  502. /package/dist/{dispatch-H4HV32AM.js.map → dispatch-OFDA4WQV.js.map} +0 -0
  503. /package/dist/{executor-FMPVN6DT.js.map → executor-E6YDJ7YA.js.map} +0 -0
  504. /package/dist/{executor-LBBBRTN5.js.map → executor-NJX3YQQ4.js.map} +0 -0
  505. /package/dist/{executor-OSRZST2U.js.map → executor-WWM3DD4P.js.map} +0 -0
  506. /package/dist/{export-accessible-RAOJAAU5.js.map → export-accessible-RLHU5G4W.js.map} +0 -0
  507. /package/dist/{extract-partition-JD5CUSTG.js.map → extract-partition-QII2EDCS.js.map} +0 -0
  508. /package/dist/{fanout-sidecar-L7NHPIOC.js.map → fanout-sidecar-BO67PCPO.js.map} +0 -0
  509. /package/dist/{find-JRN4RNQ5.js.map → find-6M7GYDUZ.js.map} +0 -0
  510. /package/dist/{issue-YIVBZUTH.js.map → issue-LPEEEMPP.js.map} +0 -0
  511. /package/dist/{ledger-5ZMGE44K.js.map → ledger-MSJGWKGW.js.map} +0 -0
  512. /package/dist/{liberate-WZSZM2W6.js.map → liberate-LEKDYKTC.js.map} +0 -0
  513. /package/dist/{link-set-MFXC24VK.js.map → link-set-QXXSPPHL.js.map} +0 -0
  514. /package/dist/{managed-secret-MFTFT22X.js.map → managed-secret-VSK7ANQI.js.map} +0 -0
  515. /package/dist/{migrate-cek-DZRFFOHW.js.map → migrate-cek-GEBFYBDC.js.map} +0 -0
  516. /package/dist/{noydb-ITIGNKUF.js.map → noydb-F2AUF6KL.js.map} +0 -0
  517. /package/dist/{pod-handle-A3LET7NO.js.map → pod-handle-YE7CT66T.js.map} +0 -0
  518. /package/dist/{post-register-7ND27CF2.js.map → post-register-QC5TEAW3.js.map} +0 -0
  519. /package/dist/{register-DT5HZ2LZ.js.map → register-SN72QALV.js.map} +0 -0
  520. /package/dist/{registry-BHRZGZHF.js.map → registry-253FF7C6.js.map} +0 -0
  521. /package/dist/{registry-ET6ZFFWA.js.map → registry-3AZWQTDT.js.map} +0 -0
  522. /package/dist/{registry-HXFGLGTG.js.map → registry-7UEBTHWG.js.map} +0 -0
  523. /package/dist/{registry-THCPDEOD.js.map → registry-IVJ67NFQ.js.map} +0 -0
  524. /package/dist/{request-withdrawal-AV2MJJKY.js.map → request-withdrawal-UKVJZKX2.js.map} +0 -0
  525. /package/dist/{reveal-B2TLP4JQ.js.map → reveal-YQTRNQFH.js.map} +0 -0
  526. /package/dist/{revoke-6DWIEOCV.js.map → revoke-G2KXJQA5.js.map} +0 -0
  527. /package/dist/{signer-MHGW3OIL.js.map → signer-IUIYR3CX.js.map} +0 -0
  528. /package/dist/{stale-6GCFMOOR.js.map → stale-SKV33PBU.js.map} +0 -0
  529. /package/dist/{storage-BYN5LO6Z.js.map → storage-NPBYP2SM.js.map} +0 -0
  530. /package/dist/{store-coordination-provider-C4BPT5XF.js.map → store-coordination-provider-Z6HKPOGM.js.map} +0 -0
  531. /package/dist/{verify-UKALW7C2.js.map → verify-KWQIWLGH.js.map} +0 -0
  532. /package/dist/{walk-4VPK7AS4.js.map → walk-F4OLXI5H.js.map} +0 -0
  533. /package/dist/{withdraw-accessible-HL7GACUE.js.map → withdraw-accessible-ZKPLZ66E.js.map} +0 -0
@@ -7,15 +7,15 @@ import {
7
7
  joinsDropLeftRows,
8
8
  orderReferencesJoinAlias,
9
9
  splitAroundJoins
10
- } from "./chunk-NCO25JZO.js";
10
+ } from "./chunk-PT2YCQVK.js";
11
11
  import {
12
12
  describeJoinOn,
13
13
  joinOnDispatch,
14
14
  normalizeJoinOn
15
- } from "./chunk-4V3Q35WG.js";
15
+ } from "./chunk-5UUJE4FP.js";
16
16
  import {
17
17
  ScanBuilder
18
- } from "./chunk-JQYKPKG6.js";
18
+ } from "./chunk-QGFEBNHO.js";
19
19
  import {
20
20
  installMethods
21
21
  } from "./chunk-F6NCB7KT.js";
@@ -27,22 +27,22 @@ import {
27
27
  pickCompound,
28
28
  pickCompoundOrder,
29
29
  viaOrdersField
30
- } from "./chunk-AL6ML4LA.js";
30
+ } from "./chunk-ZVSKSUGI.js";
31
31
  import {
32
32
  gateTerminal
33
- } from "./chunk-FOEDQATO.js";
33
+ } from "./chunk-DHU2AQ6T.js";
34
34
  import {
35
35
  readPath
36
- } from "./chunk-5WWDGFOS.js";
36
+ } from "./chunk-BUE7R3B5.js";
37
37
  import {
38
38
  isViaPrefixProbe
39
- } from "./chunk-SYNY3VB5.js";
39
+ } from "./chunk-PTJY5R3O.js";
40
40
  import {
41
41
  CrossJoinTooLargeError,
42
42
  DanglingReferenceError,
43
43
  RefNotDeclaredError,
44
44
  TraversalCycleError
45
- } from "./chunk-37EPTBBR.js";
45
+ } from "./chunk-VSUQI5Q6.js";
46
46
 
47
47
  // src/kernel/query/relate/explain.ts
48
48
  var WARN_FRACTION = 0.8;
@@ -1286,4 +1286,4 @@ export {
1286
1286
  runTraversal,
1287
1287
  installRelate
1288
1288
  };
1289
- //# sourceMappingURL=chunk-TKVUE4JF.js.map
1289
+ //# sourceMappingURL=chunk-2ZFD2UJC.js.map
@@ -6,10 +6,10 @@ import {
6
6
  KIND_STRING,
7
7
  compareKeys,
8
8
  toSortKey
9
- } from "./chunk-LGNDFRYC.js";
9
+ } from "./chunk-4CFHL5RY.js";
10
10
  import {
11
11
  readPath
12
- } from "./chunk-5WWDGFOS.js";
12
+ } from "./chunk-BUE7R3B5.js";
13
13
 
14
14
  // src/with-lookup/indexing/index-snapshot.ts
15
15
  var FIELD_INDEX_SNAPSHOT_VERSION = 1;
@@ -933,4 +933,4 @@ export {
933
933
  normalizeIndexDefs,
934
934
  CollectionIndexes
935
935
  };
936
- //# sourceMappingURL=chunk-2AFX33YA.js.map
936
+ //# sourceMappingURL=chunk-3V6LZHUO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/with-lookup/indexing/index-snapshot.ts","../src/with-lookup/indexing/sorted-indexes.ts","../src/with-lookup/indexing/compound-indexes.ts","../src/with-lookup/indexing/eager-indexes.ts"],"sourcesContent":["/**\n * The on-disk shape of a persisted field index (#1359) — the format both\n * `SortedIndex` (#1344) and `CompoundIndex` (#1345) round-trip through, plus\n * the structural validator every load must pass.\n *\n * ⭐ **Nothing is flattened into a delimited string.** A compound entry keeps\n * its tuple as an ARRAY of per-component keys, each carrying its runtime KIND\n * alongside its value — which is the whole point of #1345's in-memory shape\n * and would be destroyed by a `join()`. Two properties depend on it:\n *\n * - **Kind survives.** Entries rank by runtime kind FIRST (mirroring\n * `predicate.ts`'s `isComparable`), so a `string` probe must not reach\n * `number` entries. An encoding that wrote only the value would collapse\n * `1` and `'1'` into one key space on the way back in.\n * - **Per-component ordering survives.** A string component may contain any\n * byte, including whatever a separator would have been.\n *\n * The validator is deliberately paranoid and its failure mode is a REBUILD,\n * never a partial load: a blob that is truncated, from a future format, or\n * internally out of order is rejected whole. See\n * {@link parseFieldIndexSnapshot}.\n */\n\n/** Bump on ANY incompatible change to the shapes below. An older stamp is rejected, not migrated. */\nexport const FIELD_INDEX_SNAPSHOT_VERSION = 1\n\n/** One `SortKey`, wire form: `[kind, key]`. `kind` IS the sort rank. */\nexport type WireKey = readonly [kind: number, key: number | string]\n\n/** One `SortedIndex` entry: `[kind, key, seq, id]`. */\nexport type WireSortedEntry = readonly [kind: number, key: number | string, seq: number, id: string]\n\n/** One `CompoundIndex` entry: `[tupleKeys, seq, id]` — the tuple stays an ARRAY. */\nexport type WireCompoundEntry = readonly [keys: readonly WireKey[], seq: number, id: string]\n\nexport interface SortedIndexSnapshot {\n readonly v: number\n readonly t: 'sorted'\n readonly field: string\n readonly nextSeq: number\n readonly entries: readonly WireSortedEntry[]\n}\n\nexport interface CompoundIndexSnapshot {\n readonly v: number\n readonly t: 'compound'\n readonly fields: readonly string[]\n readonly nextSeq: number\n readonly entries: readonly WireCompoundEntry[]\n}\n\nexport type FieldIndexSnapshot = SortedIndexSnapshot | CompoundIndexSnapshot\n\n/**\n * Sidecar key for a single-field sorted index. Field paths are\n * percent-encoded so no field name can collide with the `,` the compound\n * form joins on, nor with the `s:` / `c:` discriminator.\n */\nexport function sortedIndexKey(field: string): string {\n return `s:${encodeURIComponent(field)}`\n}\n\n/** Sidecar key for a compound index over an ordered field tuple. */\nexport function compoundIndexKey(fields: readonly string[]): string {\n return `c:${fields.map(encodeURIComponent).join(',')}`\n}\n\n/** A key is well-formed only if its declared kind matches its value's runtime type. */\nfunction isWireKey(x: unknown): x is WireKey {\n if (!Array.isArray(x) || x.length !== 2) return false\n const [kind, key] = x as [unknown, unknown]\n // 0 = number, 1 = string, 2 = Date-as-epoch-millis. See `sorted-indexes.ts`.\n if (kind === 0 || kind === 2) return typeof key === 'number' && Number.isFinite(key)\n if (kind === 1) return typeof key === 'string'\n return false\n}\n\nfunction isSeq(x: unknown): x is number {\n return typeof x === 'number' && Number.isInteger(x) && x >= 0\n}\n\n/**\n * Decode + validate a persisted snapshot. Returns `null` — meaning \"rebuild\"\n * — for anything that is not exactly the current format: bad JSON (a torn\n * write), a version stamp from another release, a shape mismatch, a\n * malformed key, or entries out of the order the index's binary searches\n * require. A caller must never repair a snapshot; the source of truth is the\n * cache, and rebuilding from it is always available.\n */\nexport function parseFieldIndexSnapshot(json: string): FieldIndexSnapshot | null {\n let raw: unknown\n try {\n raw = JSON.parse(json)\n } catch {\n return null\n }\n if (typeof raw !== 'object' || raw === null) return null\n const o = raw as Record<string, unknown>\n if (o['v'] !== FIELD_INDEX_SNAPSHOT_VERSION) return null\n if (!isSeq(o['nextSeq']) || !Array.isArray(o['entries'])) return null\n const nextSeq = o['nextSeq']\n const entries = o['entries'] as unknown[]\n\n if (o['t'] === 'sorted') {\n if (typeof o['field'] !== 'string') return null\n const out: WireSortedEntry[] = []\n for (const e of entries) {\n if (!Array.isArray(e) || e.length !== 4) return null\n const [kind, key, seq, id] = e as [unknown, unknown, unknown, unknown]\n if (!isWireKey([kind, key])) return null\n if (!isSeq(seq) || seq >= nextSeq || typeof id !== 'string') return null\n out.push([kind as number, key as number | string, seq, id])\n }\n if (!isAscending(out.map(e => [[e[0], e[1]] as WireKey]), out.map(e => e[2]))) return null\n return { v: FIELD_INDEX_SNAPSHOT_VERSION, t: 'sorted', field: o['field'], nextSeq, entries: out }\n }\n\n if (o['t'] === 'compound') {\n const fields = o['fields']\n if (!Array.isArray(fields) || fields.length === 0 || !fields.every(f => typeof f === 'string')) return null\n const out: WireCompoundEntry[] = []\n for (const e of entries) {\n if (!Array.isArray(e) || e.length !== 3) return null\n const [keys, seq, id] = e as [unknown, unknown, unknown]\n if (!Array.isArray(keys) || keys.length !== fields.length || !keys.every(isWireKey)) return null\n if (!isSeq(seq) || seq >= nextSeq || typeof id !== 'string') return null\n out.push([keys as readonly WireKey[], seq, id])\n }\n if (!isAscending(out.map(e => e[0]), out.map(e => e[1]))) return null\n return { v: FIELD_INDEX_SNAPSHOT_VERSION, t: 'compound', fields, nextSeq, entries: out }\n }\n\n return null\n}\n\n/**\n * Every binary search in both index classes assumes `(keys…, seq)` ascending.\n * A blob that is not sorted would not merely be slow — it would answer\n * WRONGLY, so it is rejected rather than re-sorted (re-sorting would launder\n * a corrupt blob into a plausible-looking answer).\n */\nfunction isAscending(keys: ReadonlyArray<readonly WireKey[]>, seqs: readonly number[]): boolean {\n for (let i = 1; i < keys.length; i++) {\n const c = compareWireTuples(keys[i - 1]!, keys[i]!)\n if (c > 0) return false\n if (c === 0 && seqs[i - 1]! >= seqs[i]!) return false\n }\n return true\n}\n\nfunction compareWireTuples(a: readonly WireKey[], b: readonly WireKey[]): number {\n for (let i = 0; i < a.length; i++) {\n const x = a[i]!\n const y = b[i]!\n if (x[0] !== y[0]) return x[0] - y[0]\n if (typeof x[1] === 'number' && typeof y[1] === 'number') {\n if (x[1] !== y[1]) return x[1] - y[1]\n } else if (x[1] !== y[1]) {\n return x[1] < y[1] ? -1 : 1\n }\n }\n return 0\n}\n","/**\n * Sorted (range) secondary indexes — the ordered sibling of the hash\n * index in `eager-indexes.ts` (#1344).\n *\n * A sorted index is an array of `{ kind, key, seq, id }` entries kept in\n * ascending `(kindRank, key, seq)` order. Binary search then answers\n * `<`, `<=`, `>`, `>=`, `between` and `startsWith` as a contiguous slice,\n * and `orderedIds()` walks the array for `orderBy(field).limit(n)`.\n *\n * Three properties are load-bearing, each mirroring the linear scan this\n * replaces (`kernel/query/predicate.ts`):\n *\n * - **Kind-partitioned.** `evaluateFieldClause`'s `isComparable` refuses\n * to order two values of different runtime types, so entries are ranked\n * by kind FIRST. A `string` probe therefore cannot reach `number`\n * entries, exactly as the scan cannot. Values with no order-defined\n * type (booleans, objects, arrays) are not indexed at all.\n * - **Nullish is not indexed**, same as the hash index.\n * - **Ties keep insertion order** (`seq`), which after a `build()` is\n * snapshot order — so an index-served `orderBy(...).limit(n)` returns\n * the same rows the stable scan-and-sort would. An in-place UPDATE\n * reinstates the rank it held rather than appending (#1369): the record\n * cache does not move a re-`put` record, so neither may the index.\n *\n * Keys canonicalise through the SAME per-field closure the hash index\n * uses (`ViaPipeline.canonicalizeIndexKey`), so a Via-covered field's\n * entries live in one key space here too. Range DISPATCH for a\n * Via-covered clause is nevertheless declined by the query builder (a\n * money operand has no ordered stored-form probe) — see\n * `kernel/query/builder.ts`'s `candidateRecords`.\n *\n * PERSISTENCE (#1359) is OPT-IN, via `{ persist: true }` on the declaration.\n * {@link SortedIndex.toSnapshot} / {@link SortedIndex.loadSnapshot} are the\n * whole of this class's part in it — the encrypted sidecar, the freshness\n * stamp and the debounce live in `persisted-field-indexes.ts`. Without the\n * opt-in the index is in memory only and rebuilt on hydrate, as before.\n */\n\nimport { readPath } from '../../kernel/query/predicate.js'\nimport { KIND_STRING, compareKeys, toSortKey, type KeyKind, type SortKey } from '../../kernel/query/sort-key.js'\nimport {\n FIELD_INDEX_SNAPSHOT_VERSION,\n type FieldIndexSnapshot,\n type SortedIndexSnapshot,\n type WireSortedEntry,\n} from './index-snapshot.js'\n\n/** Range operators a sorted index can answer. */\nexport type RangeOperator = '<' | '<=' | '>' | '>=' | 'between' | 'startsWith'\n\n// The ordered-key encoding itself moved to `kernel/query/sort-key.ts` (#1339):\n// #1339's declared joins key on it too, and the kernel spine may not\n// statically import a `with-*` service (`check-architecture.mjs`'s\n// port-layering ratchet). Re-exported here so every existing importer of this\n// module is unchanged, and so there is still exactly ONE definition of what\n// makes two stored values comparable.\nexport { KIND_STRING, compareKeys, toSortKey, type KeyKind, type SortKey } from '../../kernel/query/sort-key.js'\n\ninterface Entry extends SortKey {\n readonly seq: number\n readonly id: string\n}\n\n/** A single field's sorted index. */\nexport class SortedIndex {\n private readonly entries: Entry[] = []\n private nextSeq = 0\n\n constructor(readonly field: string) {}\n\n get size(): number {\n return this.entries.length\n }\n\n clear(): void {\n this.entries.length = 0\n this.nextSeq = 0\n }\n\n /**\n * Insert one record. No-op when the value has no order-defined kind.\n *\n * `seq` REINSTATES a rank a previous entry for this id held — see\n * {@link remove}'s return value and `CollectionIndexes.upsert`. Omit it\n * for a fresh insert, which appends after every existing tie.\n */\n add(id: string, value: unknown, canonicalKey: string | undefined, seq?: number): void {\n const sk = toSortKey(value, canonicalKey)\n if (!sk) return\n const entry: Entry = { ...sk, seq: seq ?? this.nextSeq++, id }\n this.entries.splice(this.insertionPoint(entry), 0, entry)\n }\n\n /**\n * Remove one record, addressed by the value it was indexed under.\n * Returns the rank it held, so an UPDATE can reinstate it (#1369):\n * `sortRecords()` sorts a snapshot whose order does not change when a\n * record is written in place, so a tie-breaking rank that drifted to the\n * back on every `put` would make an index-served page disagree with the\n * scan it must match. Same contract as `CompoundIndex.remove`.\n */\n remove(id: string, value: unknown, canonicalKey: string | undefined): number | undefined {\n const sk = toSortKey(value, canonicalKey)\n if (!sk) return undefined\n // Every entry sharing this key is contiguous; walk that run for the id.\n for (let i = this.lowerBound(sk); i < this.entries.length; i++) {\n const e = this.entries[i]!\n if (compareKeys(e, sk) !== 0) break\n if (e.id === id) {\n this.entries.splice(i, 1)\n return e.seq\n }\n }\n return undefined\n }\n\n /**\n * Ids in ascending (or descending) key order. Ties keep INSERTION order\n * in both directions — `sortRecords()` negates its comparator over a\n * stable sort, which reverses the key order but not the order of equal\n * keys. A plain `.reverse()` here would disagree on ties.\n */\n orderedIds(direction: 'asc' | 'desc'): string[] {\n if (direction === 'asc') return this.entries.map(e => e.id)\n const out: string[] = []\n let end = this.entries.length\n while (end > 0) {\n let start = end - 1\n while (start > 0 && compareKeys(this.entries[start - 1]!, this.entries[end - 1]!) === 0) start--\n for (let i = start; i < end; i++) out.push(this.entries[i]!.id)\n end = start\n }\n return out\n }\n\n /**\n * Ids matching a range clause. Returns an empty set when the probe has\n * no comparable kind — which is what the linear scan would produce too.\n */\n lookup(op: RangeOperator, value: unknown): Set<string> {\n if (op === 'startsWith') return this.prefix(value)\n if (op === 'between') {\n if (!Array.isArray(value) || value.length !== 2) return new Set()\n const lo = toSortKey(value[0], undefined)\n const hi = toSortKey(value[1], undefined)\n if (!lo || !hi || lo.kind !== hi.kind) return new Set()\n return this.slice(this.lowerBound(lo), this.upperBound(hi))\n }\n const probe = toSortKey(value, undefined)\n if (!probe) return new Set()\n const lo = this.lowerBound(probe)\n const hi = this.upperBound(probe)\n // Kind-partitioned: `<`/`>` must stay inside the probe's own kind run.\n const [kindStart, kindEnd] = this.kindBounds(probe.kind)\n switch (op) {\n case '<':\n return this.slice(kindStart, lo)\n case '<=':\n return this.slice(kindStart, hi)\n case '>':\n return this.slice(hi, kindEnd)\n case '>=':\n return this.slice(lo, kindEnd)\n default: {\n const _exhaustive: never = op\n void _exhaustive\n return new Set()\n }\n }\n }\n\n private prefix(value: unknown): Set<string> {\n if (typeof value !== 'string') return new Set()\n const out = new Set<string>()\n const from = this.lowerBound({ kind: KIND_STRING, key: value })\n for (let i = from; i < this.entries.length; i++) {\n const e = this.entries[i]!\n if (e.kind !== KIND_STRING) break\n if (!(e.key as string).startsWith(value)) break\n out.add(e.id)\n }\n return out\n }\n\n private slice(from: number, to: number): Set<string> {\n const out = new Set<string>()\n for (let i = from; i < to; i++) out.add(this.entries[i]!.id)\n return out\n }\n\n /** [start, end) of the run of entries with the given kind — binary, not linear. */\n private kindBounds(kind: KeyKind): [number, number] {\n return [this.kindBoundary(k => k < kind), this.kindBoundary(k => k <= kind)]\n }\n\n private kindBoundary(before: (k: KeyKind) => boolean): number {\n let lo = 0\n let hi = this.entries.length\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (before(this.entries[mid]!.kind)) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /** First index whose key is >= `probe`. */\n private lowerBound(probe: SortKey): number {\n let lo = 0\n let hi = this.entries.length\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (compareKeys(this.entries[mid]!, probe) < 0) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /** First index whose key is > `probe`. */\n private upperBound(probe: SortKey): number {\n let lo = 0\n let hi = this.entries.length\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (compareKeys(this.entries[mid]!, probe) <= 0) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /**\n * The persistable form of this index (#1359). `kind` travels with every\n * key: entries rank by runtime kind first, so an encoding that dropped it\n * would let a `string` probe reach `number` entries on the way back in.\n */\n toSnapshot(): SortedIndexSnapshot {\n return {\n v: FIELD_INDEX_SNAPSHOT_VERSION,\n t: 'sorted',\n field: this.field,\n nextSeq: this.nextSeq,\n entries: this.entries.map(e => [e.kind, e.key, e.seq, e.id] as WireSortedEntry),\n }\n }\n\n /**\n * Adopt a validated snapshot, or refuse it. Refusal (`false`) means the\n * caller rebuilds — it NEVER means a partial index: the entries are staged\n * and only swapped in once every one of them is accepted.\n *\n * `isLive` is the caller's liveness predicate over the record cache. An\n * entry naming a record the cache does not hold means the blob and the\n * collection have diverged (a crash between the two writes, say), so the\n * whole blob is discarded. Crash residue must be a rebuild, never a wrong\n * answer.\n */\n loadSnapshot(snap: FieldIndexSnapshot, isLive: (id: string) => boolean): boolean {\n if (snap.t !== 'sorted' || snap.field !== this.field) return false\n const staged: Entry[] = []\n for (const [kind, key, seq, id] of snap.entries) {\n if (!isLive(id)) return false\n staged.push({ kind: kind as KeyKind, key, seq, id })\n }\n this.entries.length = 0\n for (const e of staged) this.entries.push(e)\n this.nextSeq = snap.nextSeq\n return true\n }\n\n /**\n * Insertion point that keeps ties in `seq` order. A fresh entry lands at\n * the end of its tie run; a REINSTATED one (see {@link add}) lands back at\n * its own rank inside it.\n */\n private insertionPoint(entry: Entry): number {\n let i = this.upperBound(entry)\n while (i > 0 && compareKeys(this.entries[i - 1]!, entry) === 0 && this.entries[i - 1]!.seq > entry.seq) {\n i--\n }\n return i\n }\n}\n\n/** Build the whole index from a snapshot. Entry seqs follow snapshot order. */\nexport function buildSortedIndex<T>(\n idx: SortedIndex,\n records: ReadonlyArray<{ id: string; record: T }>,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n idx.clear()\n for (const { id, record } of records) {\n const value = readPath(record, idx.field)\n if (value === null || value === undefined) continue\n idx.add(id, value, canonicalize?.(idx.field, value))\n }\n}\n\n","/**\n * Compound (multi-field) sorted indexes — the tuple-keyed sibling of\n * `sorted-indexes.ts` (#1345).\n *\n * A compound index is an array of `{ keys, seq, id }` entries kept in\n * ascending `(keys[0], keys[1], …, seq)` order, where each `keys[i]` is\n * the SAME `SortKey` the single-field sorted index builds — so the tuple\n * encoding is order-preserving per component BY CONSTRUCTION rather than\n * by a second, hand-rolled serialization. Nothing is flattened into a\n * delimited string: a string component can therefore contain any byte\n * without colliding with a separator, and a money field canonicalized to\n * a scaled-integer string (`ViaPipeline.canonicalizeIndexKey`) or a date\n * stored as ISO text sorts inside its own component exactly as it does in\n * the single-field index.\n *\n * The two load-bearing properties of #1344 hold PER COMPONENT:\n *\n * - **Kind-partitioned.** `compareKeys` ranks by runtime kind first, so\n * within any equality-prefix run a `string` probe on the next\n * component cannot reach `number` entries — mirroring `predicate.ts`'s\n * `isComparable`, exactly as the linear scan behaves.\n * - **Ties keep insertion order** in both directions. `orderedIds()`\n * walks equal-key runs forward even when emitting descending, because\n * `sortRecords()` negates its comparator over a STABLE sort.\n *\n * **A record is indexed only when EVERY component has an order-defined\n * value.** One nullish or non-orderable component and the record is\n * absent — which is why the query builder compares {@link\n * CompoundIndex.size} against the snapshot size before dispatching, and\n * falls back to the scan when the index does not cover the collection.\n *\n * PERSISTENCE (#1359) is OPT-IN, same as its single-field sibling. The wire\n * form keeps the tuple as an ARRAY of per-component keys — see\n * `index-snapshot.ts`: flattening it to a delimited string would destroy\n * exactly the per-component ordering and kind partition this class is built\n * to preserve.\n */\n\nimport { readPath } from '../../kernel/query/predicate.js'\nimport { KIND_STRING, compareKeys, toSortKey, type RangeOperator, type SortKey } from './sorted-indexes.js'\nimport {\n FIELD_INDEX_SNAPSHOT_VERSION,\n type CompoundIndexSnapshot,\n type FieldIndexSnapshot,\n type WireCompoundEntry,\n type WireKey,\n} from './index-snapshot.js'\n\n/** A range constraint on the component just past the equality prefix. */\nexport interface CompoundRangeProbe {\n readonly op: RangeOperator\n readonly value: unknown\n}\n\ninterface CompoundEntry {\n readonly keys: readonly SortKey[]\n readonly seq: number\n readonly id: string\n}\n\n/** One collection's index over an ordered field tuple. */\nexport class CompoundIndex {\n private readonly entries: CompoundEntry[] = []\n private nextSeq = 0\n\n constructor(readonly fields: readonly string[]) {}\n\n get size(): number {\n return this.entries.length\n }\n\n clear(): void {\n this.entries.length = 0\n this.nextSeq = 0\n }\n\n /**\n * Insert one record. No-op unless every component has an ordered key.\n *\n * `seq` REINSTATES a rank a previous entry for this id held — see\n * {@link remove}'s return value and `CollectionIndexes.upsert`. Omit it\n * for a fresh insert, which appends after every existing tie.\n */\n add(id: string, keys: readonly SortKey[] | undefined, seq?: number): void {\n if (!keys) return\n const entry: CompoundEntry = { keys, seq: seq ?? this.nextSeq++, id }\n this.entries.splice(this.insertionPoint(entry), 0, entry)\n }\n\n /**\n * Remove one record, addressed by the tuple it was indexed under.\n * Returns the rank it held, so an UPDATE can reinstate it: `sortRecords()`\n * sorts a snapshot whose order does not change when a record is written in\n * place, so a tie-breaking rank that drifted to the back on every `put`\n * would make an index-served page disagree with the scan it must match.\n */\n remove(id: string, keys: readonly SortKey[] | undefined): number | undefined {\n if (!keys) return undefined\n const [from, to] = this.run(keys, keys.length)\n for (let i = from; i < to; i++) {\n if (this.entries[i]!.id === id) {\n const [gone] = this.entries.splice(i, 1)\n return gone!.seq\n }\n }\n return undefined\n }\n\n /**\n * Ids matching an equality prefix, optionally narrowed by a range on\n * the next component. An empty set is authoritative: the index covers\n * these fields and nothing matches.\n */\n lookup(prefix: readonly SortKey[], range?: CompoundRangeProbe): Set<string> {\n const [from, to] = this.run(prefix, prefix.length)\n if (!range) return this.slice(from, to)\n const k = prefix.length\n if (k >= this.fields.length) return new Set()\n\n if (range.op === 'startsWith') {\n if (typeof range.value !== 'string') return new Set()\n const out = new Set<string>()\n const start = this.lowerBound([...prefix, { kind: KIND_STRING, key: range.value }], k + 1, from, to)\n for (let i = start; i < to; i++) {\n const key = this.entries[i]!.keys[k]!\n if (key.kind !== KIND_STRING) break\n if (!(key.key as string).startsWith(range.value)) break\n out.add(this.entries[i]!.id)\n }\n return out\n }\n\n if (range.op === 'between') {\n if (!Array.isArray(range.value) || range.value.length !== 2) return new Set()\n const lo = toSortKey(range.value[0], undefined)\n const hi = toSortKey(range.value[1], undefined)\n if (!lo || !hi || lo.kind !== hi.kind) return new Set()\n return this.slice(\n this.lowerBound([...prefix, lo], k + 1, from, to),\n this.upperBound([...prefix, hi], k + 1, from, to),\n )\n }\n\n const probe = toSortKey(range.value, undefined)\n if (!probe) return new Set()\n // Kind-partitioned per component: an open-ended bound stays inside the\n // probe's own kind run, so `< '5'` never sweeps up numeric entries.\n const [kindStart, kindEnd] = this.kindRun(from, to, k, probe.kind)\n const lo = this.lowerBound([...prefix, probe], k + 1, from, to)\n const hi = this.upperBound([...prefix, probe], k + 1, from, to)\n switch (range.op) {\n case '<':\n return this.slice(kindStart, lo)\n case '<=':\n return this.slice(kindStart, hi)\n case '>':\n return this.slice(hi, kindEnd)\n case '>=':\n return this.slice(lo, kindEnd)\n default: {\n const _exhaustive: never = range.op\n void _exhaustive\n return new Set()\n }\n }\n }\n\n /**\n * Ids matching an equality prefix, in the order of the remaining\n * components. Ties keep INSERTION order in both directions — a plain\n * `.reverse()` would disagree with `sortRecords()` on equal keys.\n */\n orderedIds(prefix: readonly SortKey[], direction: 'asc' | 'desc'): string[] {\n const [from, to] = this.run(prefix, prefix.length)\n const out: string[] = []\n if (direction === 'asc') {\n for (let i = from; i < to; i++) out.push(this.entries[i]!.id)\n return out\n }\n let end = to\n while (end > from) {\n let start = end - 1\n while (start > from && this.compare(this.entries[start - 1]!, this.entries[end - 1]!.keys, this.fields.length) === 0) {\n start--\n }\n for (let i = start; i < end; i++) out.push(this.entries[i]!.id)\n end = start\n }\n return out\n }\n\n private slice(from: number, to: number): Set<string> {\n const out = new Set<string>()\n for (let i = from; i < to; i++) out.add(this.entries[i]!.id)\n return out\n }\n\n /** [start, end) of the entries whose first `upto` components equal `probe`. */\n private run(probe: readonly SortKey[], upto: number): [number, number] {\n return [\n this.lowerBound(probe, upto, 0, this.entries.length),\n this.upperBound(probe, upto, 0, this.entries.length),\n ]\n }\n\n /** [start, end) of the entries in [from,to) whose component `k` has this kind. */\n private kindRun(from: number, to: number, k: number, kind: number): [number, number] {\n return [\n this.kindBoundary(from, to, k, x => x < kind),\n this.kindBoundary(from, to, k, x => x <= kind),\n ]\n }\n\n private kindBoundary(from: number, to: number, k: number, before: (kind: number) => boolean): number {\n let lo = from\n let hi = to\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (before(this.entries[mid]!.keys[k]!.kind)) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /** First index in [from,to) whose first `upto` components are >= `probe`. */\n private lowerBound(probe: readonly SortKey[], upto: number, from: number, to: number): number {\n let lo = from\n let hi = to\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (this.compare(this.entries[mid]!, probe, upto) < 0) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /** First index in [from,to) whose first `upto` components are > `probe`. */\n private upperBound(probe: readonly SortKey[], upto: number, from: number, to: number): number {\n let lo = from\n let hi = to\n while (lo < hi) {\n const mid = (lo + hi) >>> 1\n if (this.compare(this.entries[mid]!, probe, upto) <= 0) lo = mid + 1\n else hi = mid\n }\n return lo\n }\n\n /**\n * The persistable form of this index (#1359). Each entry's tuple stays an\n * ARRAY of `[kind, key]` pairs: nothing is joined into a string, so a\n * string component may hold any byte and the per-component kind partition\n * survives the round trip intact.\n */\n toSnapshot(): CompoundIndexSnapshot {\n return {\n v: FIELD_INDEX_SNAPSHOT_VERSION,\n t: 'compound',\n fields: [...this.fields],\n nextSeq: this.nextSeq,\n entries: this.entries.map(\n e => [e.keys.map(k => [k.kind, k.key] as WireKey), e.seq, e.id] as WireCompoundEntry,\n ),\n }\n }\n\n /**\n * Adopt a validated snapshot, or refuse it. Same contract as\n * `SortedIndex.loadSnapshot`: all-or-nothing, and an entry naming a record\n * the cache does not hold rejects the whole blob so crash residue becomes a\n * rebuild rather than a wrong answer. A snapshot whose field tuple is not\n * exactly this index's is refused — the declaration changed under it.\n */\n loadSnapshot(snap: FieldIndexSnapshot, isLive: (id: string) => boolean): boolean {\n if (snap.t !== 'compound') return false\n if (snap.fields.length !== this.fields.length) return false\n for (let i = 0; i < snap.fields.length; i++) if (snap.fields[i] !== this.fields[i]) return false\n const staged: CompoundEntry[] = []\n for (const [keys, seq, id] of snap.entries) {\n if (!isLive(id)) return false\n staged.push({ keys: keys.map(k => ({ kind: k[0] as SortKey['kind'], key: k[1] })), seq, id })\n }\n this.entries.length = 0\n for (const e of staged) this.entries.push(e)\n this.nextSeq = snap.nextSeq\n return true\n }\n\n /**\n * Insertion point that keeps ties in `seq` order. A fresh entry lands at\n * the end of its tie run; a REINSTATED one (see {@link add}) lands back at\n * its own rank inside it.\n */\n private insertionPoint(entry: CompoundEntry): number {\n const to = this.upperBound(entry.keys, this.fields.length, 0, this.entries.length)\n let i = to\n while (i > 0 && this.compare(this.entries[i - 1]!, entry.keys, this.fields.length) === 0\n && this.entries[i - 1]!.seq > entry.seq) {\n i--\n }\n return i\n }\n\n private compare(entry: CompoundEntry, probe: readonly SortKey[], upto: number): number {\n for (let i = 0; i < upto; i++) {\n const c = compareKeys(entry.keys[i]!, probe[i]!)\n if (c !== 0) return c\n }\n return 0\n }\n}\n\n/**\n * The tuple key for one record, or `undefined` when any component is\n * nullish or has no order-defined runtime type. Canonicalizes through the\n * same per-field closure the hash and sorted indexes use, so a Via-covered\n * component lives in one key space across all three.\n */\nexport function tupleKeyOf<T>(\n fields: readonly string[],\n record: T,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): SortKey[] | undefined {\n const keys: SortKey[] = []\n for (const field of fields) {\n const value = readPath(record, field)\n if (value === null || value === undefined) return undefined\n const key = toSortKey(value, canonicalize?.(field, value))\n if (!key) return undefined\n keys.push(key)\n }\n return keys\n}\n\n/** Probe keys for an equality prefix, or `undefined` if any operand is unorderable. */\nexport function probeKeysOf(values: readonly unknown[]): SortKey[] | undefined {\n const keys: SortKey[] = []\n for (const value of values) {\n const key = toSortKey(value, undefined)\n if (!key) return undefined\n keys.push(key)\n }\n return keys\n}\n\n/** Build the whole index from a snapshot. Entry seqs follow snapshot order. */\nexport function buildCompoundIndex<T>(\n idx: CompoundIndex,\n records: ReadonlyArray<{ id: string; record: T }>,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n idx.clear()\n for (const { id, record } of records) {\n idx.add(id, tupleKeyOf(idx.fields, record, canonicalize))\n }\n}\n\n/** Stable map key for a field tuple. `\\0` cannot appear in a field path. */\nexport function compoundKey(fields: readonly string[]): string {\n return fields.join('\\u0000')\n}\n","/**\n * Secondary indexes for the query DSL.\n *\n * ships **in-memory hash indexes**:\n * - Built during `Collection.ensureHydrated()` from the decrypted cache\n * - Maintained incrementally on `put` and `delete`\n * - Consulted by the query executor for `==` and `in` operators on\n * indexed fields, falling back to a linear scan otherwise\n * - Live entirely in memory — no adapter writes for the index itself\n *\n * Persistent encrypted index blobs (the spec's \"store as a separate\n * AES-256-GCM blob\" note) are deferred to a follow-up issue. The reasons\n * are documented in the PR body — short version: at the target\n * scale of 1K–50K records, building the index during hydrate is free,\n * so persistence buys nothing measurable.\n */\n\nimport { readPath } from '../../kernel/query/predicate.js'\nimport { stringifyBucketKey, isProbeableBucketKey } from '../../kernel/query/distinct-key.js'\nimport { SortedIndex, buildSortedIndex, type RangeOperator } from './sorted-indexes.js'\nimport {\n CompoundIndex,\n buildCompoundIndex,\n compoundKey,\n probeKeysOf,\n tupleKeyOf,\n type CompoundRangeProbe,\n} from './compound-indexes.js'\nimport {\n compoundIndexKey,\n sortedIndexKey,\n type FieldIndexSnapshot,\n} from './index-snapshot.js'\n\n/**\n * Index declaration accepted by `Collection`'s constructor.\n *\n * Accepts:\n * - `string` — a single-field hash index (`'clientId'`)\n * - `{ fields: [...] }` or `readonly string[]` — a composite index\n * over an ordered field tuple. Only lazy-mode\n * collections consume composite declarations today; eager mode\n * silently treats a composite as equivalent to declaring each\n * component field as its own single-field index.\n *\n * Additive variants (unique constraints, partial indexes) will land as\n * further union members without breaking existing declarations.\n */\nexport type IndexDef =\n | string\n | {\n readonly fields: readonly string[]\n /**\n * Enforce that no two records share this field tuple. A MULTI-field\n * tuple is a COMPOUND unique — uniqueness over the tuple, never over\n * each component on its own (`['workerId','employerId']` allows one\n * worker at many employers). Null-distinct: a record with `null` or\n * `undefined` in any constrained field is exempt.\n *\n * ⚠️ **What \"unique\" means depends on the collection's mode (#1358),\n * and one of the four cannot promise prevention at all:**\n *\n * - eager (default) — prevented, from the in-memory map.\n * - lazy (`prefetch: false`) — prevented, by a point lookup through the\n * persisted `_idx/` mirror. Requires `withIndexing()`.\n * - tiered (`tiers: [...]`) — prevented across every tier whose DEK the\n * writer holds. **A tier the writer cannot read is outside the\n * guarantee** — those records are unreadable, so no local check can\n * see them, and a duplicate against one is accepted.\n * - CRDT (`crdt: '...'`) — **NOT prevented.** Uniqueness cannot be\n * enforced across concurrent replicas: two replicas that are offline\n * from each other can both accept the same value, and no local check\n * can prevent that. The write always succeeds and both records are\n * kept; the collision is reported on the `unique:violation` event as\n * a `UniqueConstraintError`, both when it happens and when a later\n * session first sees the two records together. What you get is\n * uniqueness within what this writer could see at write time, plus\n * detection when the replicas meet.\n */\n readonly unique?: boolean\n readonly kind?: IndexKind\n /**\n * Persist this index as an encrypted sidecar so a restart reuses it\n * instead of rebuilding (#1359). Only meaningful with `kind: 'sorted'`\n * — the hash index is not persisted. OPT-IN until measured: at the\n * 1K–50K target scale rebuild-on-open is free, and a sidecar is a\n * write on every debounce window plus a blob at rest.\n */\n readonly persist?: boolean\n }\n | readonly string[]\n\n/**\n * The access structure an index declaration asks for (#1344).\n *\n * `'hash'` (the default, and what every pre-#1344 declaration means) is\n * the equality/`in` bucket map. `'sorted'` additionally maintains an\n * ordered array over the same canonicalized keys, which lights up\n * index-driven `<`, `<=`, `>`, `>=`, `between`, `startsWith` and\n * `orderBy(field).limit(n)`. A `'sorted'` declaration keeps the hash\n * index too — `==`/`in` stay O(1).\n */\ntype IndexKind = 'hash' | 'sorted'\n\n/**\n * Normalize a declared `IndexDef[]` into a uniform `{ fields, unique? }`\n * shape: `string` → `{fields:[s]}`, `string[]` → `{fields}`, object →\n * passthrough. Pure — used by `Collection`'s sensitive-field leak check\n * and by `getDeclaredIndexes()` (introspection).\n */\nexport function normalizeIndexDefs(\n defs: readonly IndexDef[],\n): ReadonlyArray<{ readonly fields: readonly string[]; readonly unique?: boolean }> {\n return defs.map((def) => {\n if (typeof def === 'string') return { fields: [def] }\n if (Array.isArray(def)) return { fields: def }\n return def as { readonly fields: readonly string[]; readonly unique?: boolean }\n })\n}\n\n/**\n * Internal representation of a built hash index.\n *\n * Maps stringified field values to the set of record ids whose value\n * for that field matches. Stringification keeps the index simple and\n * works uniformly for primitives (`'open'`, `'42'`, `'true'`).\n *\n * Records whose indexed field is `undefined` or `null` are NOT inserted\n * — `query().where('field', '==', undefined)` falls back to a linear\n * scan, which is the conservative behavior.\n */\nexport interface HashIndex {\n readonly field: string\n readonly buckets: Map<string, Set<string>>\n}\n\n/**\n * Container for all indexes on a single collection.\n *\n * Methods are pure with respect to the in-memory `buckets` Map — they\n * never touch the adapter or the keyring. The Collection class owns\n * lifecycle (build on hydrate, maintain on put/delete).\n */\nexport class CollectionIndexes {\n private readonly indexes = new Map<string, HashIndex>()\n\n /**\n * Sorted (range) indexes, keyed by field — the #1344 half. Parallel to\n * `indexes` above and maintained at the SAME mutation sites, through the\n * SAME `canonicalize` closure, so the two can never disagree about which\n * key space a field lives in.\n */\n private readonly sorted = new Map<string, SortedIndex>()\n\n /**\n * Compound (tuple-keyed) sorted indexes, keyed by the joined field\n * tuple — the #1345 half. Third parallel map, maintained at the SAME\n * mutation sites through the SAME `canonicalize` closure as the other\n * two, so no field can end up in disagreeing key spaces.\n */\n private readonly compound = new Map<string, CompoundIndex>()\n\n /**\n * The indexes declared `persist: true` (#1359), keyed by their SIDECAR key\n * (`s:<field>` / `c:<f1>,<f2>`). A separate map rather than a flag on the\n * index classes: persistence is a property of the DECLARATION, and the\n * index classes stay unaware of storage.\n */\n private readonly persistable = new Map<string, SortedIndex | CompoundIndex>()\n\n /**\n * Per-field bucket-key canonicalizer (#672 review C1), registered ONCE\n * via {@link setCanonicalizer} when the collection wires indexing up\n * (money-aware via `ViaPipeline.canonicalizeIndexKey`). Consulted by\n * EVERY bucket-mutation site — `build`/`upsert`/`remove` — so bucket\n * membership is symmetric by construction: a value can never be added\n * under a canonical key and later removed under the raw one (or vice\n * versa), which is what stranded ids on `put`/`delete` before this fix.\n */\n private canonicalize?: (field: string, value: unknown) => string | undefined\n\n /**\n * Register the bucket-key canonicalizer. Called once, where the\n * collection constructs its indexing state — safe to call again (the\n * closure is simply replaced) but there is normally only one caller.\n */\n setCanonicalizer(fn: (field: string, value: unknown) => string | undefined): void {\n this.canonicalize = fn\n }\n\n /**\n * Declare an index. Subsequent record additions are tracked under it.\n * Calling this twice for the same field is a no-op (idempotent).\n */\n declare(field: string): void {\n if (this.indexes.has(field)) return\n this.indexes.set(field, { field, buckets: new Map() })\n }\n\n /**\n * Declare a sorted (range) index on a field. Independent of\n * {@link declare} — callers that want both `==` speed and range speed\n * declare both (which is what `withIndexing()` does for a\n * `kind: 'sorted'` declaration). Idempotent.\n */\n declareSorted(field: string, opts?: { readonly persist?: boolean }): void {\n let idx = this.sorted.get(field)\n if (!idx) {\n idx = new SortedIndex(field)\n this.sorted.set(field, idx)\n }\n if (opts?.persist) this.persistable.set(sortedIndexKey(field), idx)\n }\n\n /** True if the given field has a declared SORTED index. */\n hasSorted(field: string): boolean {\n return this.sorted.has(field)\n }\n\n /** All sorted-index field names, in declaration order. */\n sortedFields(): string[] {\n return [...this.sorted.keys()]\n }\n\n /** Number of entries in a field's sorted index (0 when undeclared). */\n sortedSize(field: string): number {\n return this.sorted.get(field)?.size ?? 0\n }\n\n /**\n * Range lookup: ids whose `field` satisfies the operator. Returns\n * `null` when no SORTED index covers the field — the caller falls back\n * to a linear scan. An empty set means \"the index covers this field and\n * nothing matches\", which is authoritative.\n */\n lookupRange(field: string, op: RangeOperator, value: unknown): ReadonlySet<string> | null {\n return this.sorted.get(field)?.lookup(op, value) ?? null\n }\n\n /**\n * Ids of every indexed record in `field` order. `null` when no sorted\n * index covers the field. Records whose value is nullish or has no\n * order-defined type are absent — compare against {@link sortedSize}\n * before treating the result as the full collection.\n */\n orderedIds(field: string, direction: 'asc' | 'desc'): readonly string[] | null {\n return this.sorted.get(field)?.orderedIds(direction) ?? null\n }\n\n /**\n * Declare a compound (multi-field) sorted index over an ordered field\n * tuple. A tuple shorter than two fields is a single-field sorted index\n * and is ignored here. Idempotent.\n */\n declareCompound(fields: readonly string[], opts?: { readonly persist?: boolean }): void {\n if (fields.length < 2) return\n const key = compoundKey(fields)\n let idx = this.compound.get(key)\n if (!idx) {\n idx = new CompoundIndex([...fields])\n this.compound.set(key, idx)\n }\n if (opts?.persist) this.persistable.set(compoundIndexKey(fields), idx)\n }\n\n /** Every declared field tuple, in declaration order. */\n compoundTuples(): ReadonlyArray<readonly string[]> {\n return [...this.compound.values()].map(idx => idx.fields)\n }\n\n /**\n * Number of records the tuple's index holds (0 when undeclared). A\n * record with a nullish or non-orderable component is absent, so a\n * caller that removes clauses from the plan MUST compare this against\n * the snapshot size before trusting the result.\n */\n compoundSize(fields: readonly string[]): number {\n return this.compound.get(compoundKey(fields))?.size ?? 0\n }\n\n /**\n * Compound lookup: ids whose leading components equal `prefixValues`,\n * optionally narrowed by a range on the component just past them.\n * `null` when no compound index covers the tuple, or when an operand\n * has no order-defined type — the caller falls back to a linear scan.\n */\n lookupCompound(\n fields: readonly string[],\n prefixValues: readonly unknown[],\n range?: CompoundRangeProbe,\n ): ReadonlySet<string> | null {\n const idx = this.compound.get(compoundKey(fields))\n if (!idx) return null\n const prefix = probeKeysOf(prefixValues)\n if (!prefix) return null\n return idx.lookup(prefix, range)\n }\n\n /**\n * Ids matching an equality prefix, ordered by the remaining components.\n * `null` when no compound index covers the tuple or an operand has no\n * order-defined type. See {@link compoundSize} for the coverage caveat.\n */\n compoundOrderedIds(\n fields: readonly string[],\n prefixValues: readonly unknown[],\n direction: 'asc' | 'desc',\n ): readonly string[] | null {\n const idx = this.compound.get(compoundKey(fields))\n if (!idx) return null\n const prefix = probeKeysOf(prefixValues)\n if (!prefix) return null\n return idx.orderedIds(prefix, direction)\n }\n\n /** True if the given field has a declared index. */\n has(field: string): boolean {\n return this.indexes.has(field)\n }\n\n /** All declared field names, in declaration order. */\n fields(): string[] {\n return [...this.indexes.keys()]\n }\n\n /**\n * Build all declared indexes from a snapshot of records.\n * Called once per hydration. O(N × indexes.size). Buckets through the\n * registered {@link setCanonicalizer} closure, same as `upsert`/`remove`.\n */\n build<T>(records: ReadonlyArray<{ id: string; record: T }>, skip: ReadonlySet<string> = EMPTY_KEYS): void {\n for (const idx of this.indexes.values()) {\n idx.buckets.clear()\n for (const { id, record } of records) {\n addToIndex(idx, id, record, this.canonicalize)\n }\n }\n // `skip` names the sidecar keys a persisted snapshot already restored\n // (#1359) — rebuilding them would throw that work away AND renumber every\n // `seq`, which is what the whole ordered fast path rests on.\n for (const [field, idx] of this.sorted) {\n if (skip.has(sortedIndexKey(field))) continue\n buildSortedIndex(idx, records, this.canonicalize)\n }\n for (const idx of this.compound.values()) {\n if (skip.has(compoundIndexKey(idx.fields))) continue\n buildCompoundIndex(idx, records, this.canonicalize)\n }\n }\n\n /** Sidecar keys of every index declared `persist: true`, in declaration order. */\n persistableKeys(): readonly string[] {\n return [...this.persistable.keys()]\n }\n\n /** The persistable snapshot behind one sidecar key, or `undefined` if it is not declared. */\n snapshotIndex(key: string): FieldIndexSnapshot | undefined {\n return this.persistable.get(key)?.toSnapshot()\n }\n\n /**\n * Adopt a validated snapshot into the index behind `key`. `false` means the\n * caller must rebuild that index from the cache — the index is left\n * untouched, never half-loaded.\n */\n restoreIndex(key: string, snap: FieldIndexSnapshot, isLive: (id: string) => boolean): boolean {\n return this.persistable.get(key)?.loadSnapshot(snap, isLive) ?? false\n }\n\n /**\n * Insert or update a single record across all indexes.\n * Called by `Collection.put()` after the encrypted write succeeds.\n *\n * If `previousRecord` is provided, the record is removed from any old\n * buckets first — this is the update path. Pass `null` for fresh adds.\n */\n upsert<T>(id: string, newRecord: T, previousRecord: T | null): void {\n if (this.indexes.size === 0 && this.sorted.size === 0 && this.compound.size === 0) return\n // Detach the compound and sorted entries FIRST, holding the rank each one had. An\n // in-place `put` does not move a record within `snapshot()`, so it must\n // not move it within a tie run either — otherwise an index-served\n // `orderBy(...).limit(n)` page disagrees with the stable scan-and-sort\n // it is required to reproduce exactly (#1345, #1369). The `this.remove()`\n // below re-runs both removals, which are then no-ops.\n const ranks = new Map<string, number | undefined>()\n const sortedRanks = new Map<string, number | undefined>()\n if (previousRecord !== null) {\n for (const [key, idx] of this.compound) {\n ranks.set(key, idx.remove(id, tupleKeyOf(idx.fields, previousRecord, this.canonicalize)))\n }\n // Same for the single-field sorted indexes (#1369) — the defect and the\n // remedy are identical, and the two implementations must agree.\n for (const [key, idx] of this.sorted) {\n const value = readPath(previousRecord, idx.field)\n if (value === null || value === undefined) continue\n sortedRanks.set(key, idx.remove(id, value, this.canonicalize?.(idx.field, value)))\n }\n this.remove(id, previousRecord)\n }\n for (const idx of this.indexes.values()) {\n addToIndex(idx, id, newRecord, this.canonicalize)\n }\n for (const [key, idx] of this.sorted) {\n const value = readPath(newRecord, idx.field)\n if (value === null || value === undefined) continue\n idx.add(id, value, this.canonicalize?.(idx.field, value), sortedRanks.get(key))\n }\n for (const [key, idx] of this.compound) {\n idx.add(id, tupleKeyOf(idx.fields, newRecord, this.canonicalize), ranks.get(key))\n }\n }\n\n /**\n * Remove a record from all indexes. Called by `Collection.delete()`\n * (and as the first half of `upsert` for the update path).\n */\n remove<T>(id: string, record: T): void {\n if (this.indexes.size === 0 && this.sorted.size === 0 && this.compound.size === 0) return\n for (const idx of this.indexes.values()) {\n removeFromIndex(idx, id, record, this.canonicalize)\n }\n for (const idx of this.sorted.values()) {\n const value = readPath(record, idx.field)\n if (value === null || value === undefined) continue\n idx.remove(id, value, this.canonicalize?.(idx.field, value))\n }\n for (const idx of this.compound.values()) {\n idx.remove(id, tupleKeyOf(idx.fields, record, this.canonicalize))\n }\n }\n\n /** Drop all index data. Called when the collection is invalidated. */\n clear(): void {\n for (const idx of this.indexes.values()) {\n idx.buckets.clear()\n }\n for (const idx of this.sorted.values()) {\n idx.clear()\n }\n for (const idx of this.compound.values()) {\n idx.clear()\n }\n }\n\n /**\n * Equality lookup: return the set of record ids whose `field` matches\n * the given value. Returns `null` if no index covers the field — the\n * caller should fall back to a linear scan.\n *\n * ⛔ ALSO `null` when the OPERAND has no bucket ADDRESS (#1402) — a\n * nullish operand, or an object one, which every object-valued record in\n * the collection shares. Answering those from the buckets returns rows\n * the scan does not, silently, and only on the collections that happen to\n * have an index. See `isProbeableBucketKey` for the two measurements.\n *\n * The returned Set is a reference to the index's internal storage —\n * callers must NOT mutate it.\n */\n lookupEqual(field: string, value: unknown): ReadonlySet<string> | null {\n const idx = this.indexes.get(field)\n if (!idx) return null\n if (!isProbeableBucketKey(value)) return null\n const key = stringifyKey(value)\n return idx.buckets.get(key) ?? EMPTY_SET\n }\n\n /**\n * Set lookup: return the union of record ids whose `field` matches any\n * of the given values. Returns `null` if no index covers the field.\n *\n * ⛔ ALSO `null` when ANY member of `values` has no bucket address\n * (#1402) — one unaddressable member poisons the whole union, since the\n * result is a union and there is no partial answer to hand back. Same\n * measurement as {@link lookupEqual}.\n */\n lookupIn(field: string, values: readonly unknown[]): ReadonlySet<string> | null {\n const idx = this.indexes.get(field)\n if (!idx) return null\n if (!values.every(isProbeableBucketKey)) return null\n const out = new Set<string>()\n for (const value of values) {\n const key = stringifyKey(value)\n const bucket = idx.buckets.get(key)\n if (bucket) {\n for (const id of bucket) out.add(id)\n }\n }\n return out\n }\n\n /**\n * One record id per NON-EMPTY bucket of `field`'s hash index, in bucket\n * order — the index-backed spine of `Query.distinct()` (#1347). `null` when\n * no hash index covers the field, so the caller scans instead.\n *\n * The bucket set IS the distinct key set, so this costs O(buckets) rather\n * than O(records). It returns REPRESENTATIVE IDS rather than the keys\n * themselves on purpose: a bucket key is a canonical string (money's\n * BigInt-normalized scaled int, say), and `distinct()` owes its caller the\n * field's real value, which only the record carries.\n *\n * Bucket insertion order is first-seen record order — `build()` walks the\n * snapshot in order and `upsert()` appends — which is why an index-backed\n * `distinct()` and a scanned one agree on ORDER too, not merely on the set.\n * Empty buckets are skipped defensively; `removeFromIndex` already deletes\n * them, so this is belt-and-braces against a future partial removal path.\n */\n bucketRepresentatives(field: string): readonly string[] | null {\n const idx = this.indexes.get(field)\n if (!idx) return null\n const out: string[] = []\n for (const bucket of idx.buckets.values()) {\n for (const id of bucket) {\n out.push(id)\n break\n }\n }\n return out\n }\n}\n\nconst EMPTY_SET: ReadonlySet<string> = new Set()\nconst EMPTY_KEYS: ReadonlySet<string> = new Set()\n\n/**\n * Stringify a value into a stable bucket key.\n *\n * ⚠️ The DEFINITION moved to `kernel/query/distinct-key.ts` (#1347) and is\n * only aliased here. `distinct()` / `countDistinct()` recompute this key on\n * the scan path, and an index-backed `distinct()` reads the buckets it made —\n * one definition is what stops those two answers from drifting apart. Change\n * the shared function, not a copy.\n */\nconst stringifyKey = stringifyBucketKey\n\nfunction addToIndex<T>(\n idx: HashIndex,\n id: string,\n record: T,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n const value = readPath(record, idx.field)\n if (value === null || value === undefined) return\n const key = canonicalize?.(idx.field, value) ?? stringifyKey(value)\n let bucket = idx.buckets.get(key)\n if (!bucket) {\n bucket = new Set()\n idx.buckets.set(key, bucket)\n }\n bucket.add(id)\n}\n\nfunction removeFromIndex<T>(\n idx: HashIndex,\n id: string,\n record: T,\n canonicalize?: (field: string, value: unknown) => string | undefined,\n): void {\n const value = readPath(record, idx.field)\n if (value === null || value === undefined) return\n const key = canonicalize?.(idx.field, value) ?? stringifyKey(value)\n const bucket = idx.buckets.get(key)\n if (!bucket) return\n bucket.delete(id)\n // Clean up empty buckets so the Map doesn't accumulate dead keys.\n if (bucket.size === 0) idx.buckets.delete(key)\n}\n"],"mappings":";;;;;;;;;;;;;;AAwBO,IAAM,+BAA+B;AAkCrC,SAAS,eAAe,OAAuB;AACpD,SAAO,KAAK,mBAAmB,KAAK,CAAC;AACvC;AAGO,SAAS,iBAAiB,QAAmC;AAClE,SAAO,KAAK,OAAO,IAAI,kBAAkB,EAAE,KAAK,GAAG,CAAC;AACtD;AAGA,SAAS,UAAU,GAA0B;AAC3C,MAAI,CAAC,MAAM,QAAQ,CAAC,KAAK,EAAE,WAAW,EAAG,QAAO;AAChD,QAAM,CAAC,MAAM,GAAG,IAAI;AAEpB,MAAI,SAAS,KAAK,SAAS,EAAG,QAAO,OAAO,QAAQ,YAAY,OAAO,SAAS,GAAG;AACnF,MAAI,SAAS,EAAG,QAAO,OAAO,QAAQ;AACtC,SAAO;AACT;AAEA,SAAS,MAAM,GAAyB;AACtC,SAAO,OAAO,MAAM,YAAY,OAAO,UAAU,CAAC,KAAK,KAAK;AAC9D;AAUO,SAAS,wBAAwB,MAAyC;AAC/E,MAAI;A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,iBAAW,MAAM,QAAQ;AACvB,YAAI,KAAK,EAAE;AACX;AAAA,MACF;AAAA,IACF;AACA,WAAO;AAAA,EACT;AACF;AAEA,IAAM,YAAiC,oBAAI,IAAI;AAC/C,IAAM,aAAkC,oBAAI,IAAI;AAWhD,IAAM,eAAe;AAErB,SAAS,WACP,KACA,IACA,QACA,cACM;AACN,QAAM,QAAQ,SAAS,QAAQ,IAAI,KAAK;AACxC,MAAI,UAAU,QAAQ,UAAU,OAAW;AAC3C,QAAM,MAAM,eAAe,IAAI,OAAO,KAAK,KAAK,aAAa,KAAK;AAClE,MAAI,SAAS,IAAI,QAAQ,IAAI,GAAG;AAChC,MAAI,CAAC,QAAQ;AACX,aAAS,oBAAI,IAAI;AACjB,QAAI,QAAQ,IAAI,KAAK,MAAM;AAAA,EAC7B;AACA,SAAO,IAAI,EAAE;AACf;AAEA,SAAS,gBACP,KACA,IACA,QACA,cACM;AACN,QAAM,QAAQ,SAAS,QAAQ,IAAI,KAAK;AACxC,MAAI,UAAU,QAAQ,UAAU,OAAW;AAC3C,QAAM,MAAM,eAAe,IAAI,OAAO,KAAK,KAAK,aAAa,KAAK;AAClE,QAAM,SAAS,IAAI,QAAQ,IAAI,GAAG;AAClC,MAAI,CAAC,OAAQ;AACb,SAAO,OAAO,EAAE;AAEhB,MAAI,OAAO,SAAS,EAAG,KAAI,QAAQ,OAAO,GAAG;AAC/C;","names":["lo","hi","lo","hi"]}
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  NonAdditiveSchemaChangeError,
3
3
  SchemaLockedError
4
- } from "./chunk-37EPTBBR.js";
4
+ } from "./chunk-VSUQI5Q6.js";
5
5
 
6
6
  // src/with-shape/schema-update/strategies.ts
7
7
  function blindUpdate() {
@@ -62,4 +62,4 @@ export {
62
62
  lockSchema,
63
63
  coordinatedCutover
64
64
  };
65
- //# sourceMappingURL=chunk-4JPMZTJY.js.map
65
+ //# sourceMappingURL=chunk-3Y5JLSXS.js.map
@@ -5,10 +5,13 @@ import {
5
5
  readDirectoryConfig,
6
6
  readUserVisibility,
7
7
  saveUserEnvelope
8
- } from "./chunk-LIOVX5TJ.js";
8
+ } from "./chunk-FZXRLNJO.js";
9
+ import {
10
+ keyringClearance
11
+ } from "./chunk-UHFGK6YA.js";
9
12
  import {
10
13
  parseDekKey
11
- } from "./chunk-FLPCETP6.js";
14
+ } from "./chunk-RIZTZJX6.js";
12
15
  import {
13
16
  base64ToBuffer,
14
17
  bufferToBase64,
@@ -31,10 +34,10 @@ import {
31
34
  rekeyEnvelopeIfNeeded,
32
35
  unwrapKey,
33
36
  wrapKey
34
- } from "./chunk-EZGV6F47.js";
37
+ } from "./chunk-4J3MNVVX.js";
35
38
  import {
36
39
  NOYDB_KEYRING_VERSION
37
- } from "./chunk-SV2PM2OY.js";
40
+ } from "./chunk-2ELOCEXE.js";
38
41
  import {
39
42
  BLOB_ADDRESS_KEY_ID,
40
43
  DirectoryDisabledError,
@@ -52,7 +55,7 @@ import {
52
55
  USER_ENVELOPE_COLLECTION,
53
56
  ValidationError,
54
57
  WrongPromptError
55
- } from "./chunk-37EPTBBR.js";
58
+ } from "./chunk-VSUQI5Q6.js";
56
59
 
57
60
  // src/with-party/team/roster-epoch.ts
58
61
  function assertRosterEpochCurrent(found, expected, userId) {
@@ -121,7 +124,24 @@ function rosterCanonical(file) {
121
124
  // the tag stops verifying, so a store cannot downgrade a file to the
122
125
  // no-epoch shape. It can only replay a file that genuinely never had one,
123
126
  // which is why absence must read as UNKNOWN rather than as zero.
124
- ...file.roster_epoch !== void 0 ? { roster_epoch: file.roster_epoch } : {}
127
+ ...file.roster_epoch !== void 0 ? { roster_epoch: file.roster_epoch } : {},
128
+ // core#58 — the advisory clearance, bound ONLY WHEN PRESENT.
129
+ //
130
+ // ⛔ The conditional spread is mandatory here for the identical reason
131
+ // given for `roster_epoch` directly above: `file.clearance ?? null` would
132
+ // change the canonical string for every keyring written before this field
133
+ // existed, fail every one of their tags, and render every existing vault
134
+ // unopenable. Do not "tidy" it into the `?? null` shape the older optional
135
+ // fields use.
136
+ //
137
+ // ⚠️ Why bind it at all, when it is DERIVED from `dek_slots` which is
138
+ // already bound? Because "derived" is a property of how WE write it, not of
139
+ // what a store must send back. Binding it costs one conditional and makes a
140
+ // forged value fail the tag instead of merely disagreeing with the slots —
141
+ // which is the difference between a caught tamper and a silent one, for a
142
+ // reader who trusted the cheap number. It is defence in depth for a field
143
+ // whose whole risk is being read instead of the DEK map.
144
+ ...file.clearance !== void 0 ? { clearance: file.clearance } : {}
125
145
  });
126
146
  }
127
147
  async function mintRosterTag(file, rosterKey) {
@@ -161,6 +181,13 @@ function mismatchReason(file) {
161
181
  if (file._noydb_keyring !== NOYDB_KEYRING_VERSION) return "format-superseded";
162
182
  return "roster-tag-mismatch";
163
183
  }
184
+ function stampAuthority(authority, previousEpoch) {
185
+ return {
186
+ ...authority,
187
+ roster_epoch: nextRosterEpoch(previousEpoch),
188
+ clearance: keyringClearance(Object.keys(authority.deks ?? {}))
189
+ };
190
+ }
164
191
 
165
192
  // src/kernel/validation.ts
166
193
  var WeakSecretError = class extends NoydbError {
@@ -366,9 +393,11 @@ async function verifyTypedEcho(block, echo) {
366
393
  // src/with-party/team/reserved-secret-collections.ts
367
394
  var SYNC_CREDENTIALS_COLLECTION = "_sync_credentials";
368
395
  var BROKER_COLLECTION = "_broker";
396
+ var BROKER_MEMBER_COLLECTION = "_broker_member";
369
397
  var SECRET_BEARING_RESERVED_COLLECTIONS = /* @__PURE__ */ new Set([
370
398
  SYNC_CREDENTIALS_COLLECTION,
371
- BROKER_COLLECTION
399
+ BROKER_COLLECTION,
400
+ BROKER_MEMBER_COLLECTION
372
401
  ]);
373
402
  function isSecretBearingReservedCollection(name) {
374
403
  return SECRET_BEARING_RESERVED_COLLECTIONS.has(name);
@@ -553,7 +582,7 @@ async function createOwnerKeyring(store, vault, opts) {
553
582
  [BLOB_ADDRESS_KEY_ID]: wrappedBlobAddressKey
554
583
  }
555
584
  };
556
- const withEpoch = { ...authorityWithDeks, roster_epoch: nextRosterEpoch(void 0) };
585
+ const withEpoch = stampAuthority(authorityWithDeks, void 0);
557
586
  const keyringFile = {
558
587
  _noydb_keyring: NOYDB_KEYRING_VERSION,
559
588
  ...withEpoch,
@@ -649,6 +678,9 @@ async function grant(store, vault, callerKeyring, options) {
649
678
  throw new PrivilegeEscalationError(collName);
650
679
  }
651
680
  }
681
+ if (!granteeMayHoldSecrets) {
682
+ wrappedDeks[BROKER_MEMBER_COLLECTION] = await wrapKey(await generateDEK(), newKek);
683
+ }
652
684
  const canary = await mintKeyringCanary(newKek);
653
685
  const authority = {
654
686
  user_id: options.userId,
@@ -660,7 +692,7 @@ async function grant(store, vault, callerKeyring, options) {
660
692
  ...options.importCapability !== void 0 && { import_capability: options.importCapability }
661
693
  };
662
694
  const authorityWithDeks = { ...authority, deks: wrappedDeks };
663
- const withEpoch = { ...authorityWithDeks, roster_epoch: nextRosterEpoch(previousGrantFound?.file.roster_epoch) };
695
+ const withEpoch = stampAuthority(authorityWithDeks, previousGrantFound?.file.roster_epoch);
664
696
  const keyringFile = {
665
697
  _noydb_keyring: NOYDB_KEYRING_VERSION,
666
698
  ...withEpoch,
@@ -772,7 +804,7 @@ async function revoke(store, vault, callerKeyring, options) {
772
804
  });
773
805
  if (unverified.length > 0) {
774
806
  console.warn(
775
- `[noy-db] revoke(${options.userId}): ${unverified.length} member(s) were SKIPPED by the rotation because their keyring failed roster authentication: ${unverified.map((u) => `${u.userId} (${u.reason})`).join(", ")}. The revocation itself completed. Those members cannot open the vault and did not receive the rotated keys; their keyring files need repair or removal (noy-db#1114).`
807
+ `[noy-db] revoke(${options.userId}): ${unverified.length} member(s) were SKIPPED by the rotation because their keyring failed roster authentication: ${unverified.map((u) => `${u.userId} (${u.reason})`).join(", ")}. The revocation itself completed. Those members cannot open the vault and did not receive the rotated keys; their keyring files need repair or removal (vLannaAi/noy-db#1114).`
776
808
  );
777
809
  }
778
810
  }
@@ -897,7 +929,7 @@ async function updateKeyringIdentity(store, vault, callerKeyring, options) {
897
929
  },
898
930
  ...options.permissions !== void 0 && { permissions: options.permissions }
899
931
  };
900
- const withEpoch = { ...edited, roster_epoch: nextRosterEpoch(target.roster_epoch) };
932
+ const withEpoch = stampAuthority(edited, target.roster_epoch);
901
933
  const next = { ...withEpoch, roster_tag: await mintRosterTag(withEpoch, rosterKey) };
902
934
  await writeKeyringFile(store, vault, options.userId, next);
903
935
  }
@@ -1036,7 +1068,7 @@ async function rotateKeys(store, vault, callerKeyring, opts) {
1036
1068
  deks: updatedDeks,
1037
1069
  permissions: updatedPermissions
1038
1070
  };
1039
- const withEpoch = { ...edited, roster_epoch: nextRosterEpoch(userKeyringFile.roster_epoch) };
1071
+ const withEpoch = stampAuthority(edited, userKeyringFile.roster_epoch);
1040
1072
  const updatedKeyring = {
1041
1073
  ...withEpoch,
1042
1074
  roster_tag: await mintRosterTag(withEpoch, callerRosterKey)
@@ -1076,7 +1108,7 @@ async function changeSecret(store, vault, keyring, opts) {
1076
1108
  ...existingAuthority?.import_capability !== void 0 && { import_capability: existingAuthority.import_capability }
1077
1109
  };
1078
1110
  const authorityWithDeks = { ...authority, deks: wrappedDeks };
1079
- const withEpoch = { ...authorityWithDeks, roster_epoch: nextRosterEpoch(existingAuthority?.roster_epoch) };
1111
+ const withEpoch = stampAuthority(authorityWithDeks, existingAuthority?.roster_epoch);
1080
1112
  const keyringFile = {
1081
1113
  _noydb_keyring: NOYDB_KEYRING_VERSION,
1082
1114
  ...withEpoch,
@@ -1151,7 +1183,7 @@ async function buildRecipientKeyringFile(callerKeyring, recipient) {
1151
1183
  ...recipient.expiresAt !== void 0 ? { expires_at: recipient.expiresAt } : {}
1152
1184
  };
1153
1185
  const authorityWithDeks = { ...authority, deks: wrappedDeks };
1154
- const withEpoch = { ...authorityWithDeks, roster_epoch: nextRosterEpoch(void 0) };
1186
+ const withEpoch = stampAuthority(authorityWithDeks, void 0);
1155
1187
  return {
1156
1188
  _noydb_keyring: NOYDB_KEYRING_VERSION,
1157
1189
  ...withEpoch,
@@ -1333,7 +1365,7 @@ async function persistKeyring(store, vault, keyring) {
1333
1365
  deks: wrappedDeks,
1334
1366
  ...Object.keys(wrappedPending).length > 0 ? { pending_deks: wrappedPending } : {}
1335
1367
  };
1336
- const withEpoch = { ...authorityWithDeks, roster_epoch: nextRosterEpoch(existingFound?.file.roster_epoch) };
1368
+ const withEpoch = stampAuthority(authorityWithDeks, existingFound?.file.roster_epoch);
1337
1369
  const keyringFile = {
1338
1370
  _noydb_keyring: NOYDB_KEYRING_VERSION,
1339
1371
  ...withEpoch,
@@ -1403,6 +1435,7 @@ export {
1403
1435
  mintRosterTag,
1404
1436
  assertRosterAuthenticated,
1405
1437
  assertRosterTagValid,
1438
+ stampAuthority,
1406
1439
  WeakSecretError,
1407
1440
  validateSecret,
1408
1441
  assertStrongSecret,
@@ -1417,10 +1450,12 @@ export {
1417
1450
  verifyTypedEcho,
1418
1451
  SYNC_CREDENTIALS_COLLECTION,
1419
1452
  BROKER_COLLECTION,
1453
+ BROKER_MEMBER_COLLECTION,
1420
1454
  isSecretBearingReservedCollection,
1421
1455
  mintKeyringCanary,
1422
1456
  requireRosterKey,
1423
1457
  deriveKekForKeyring,
1458
+ parseKeyringEnvelope,
1424
1459
  readKeyringFile,
1425
1460
  assertKeyringNotExpired,
1426
1461
  loadKeyring,
@@ -1445,4 +1480,4 @@ export {
1445
1480
  hasImportCapability,
1446
1481
  evaluateImportCapability
1447
1482
  };
1448
- //# sourceMappingURL=chunk-XSPFDUDG.js.map
1483
+ //# sourceMappingURL=chunk-45VHWE4C.js.map