@noy-db/hub 0.7.0 → 0.8.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 (616) hide show
  1. package/CHANGELOG.md +105 -14
  2. package/LICENSE +202 -21
  3. package/NOTICE +1 -0
  4. package/README.md +27 -10
  5. package/codemods/0.8.0-pre.json +61 -0
  6. package/dist/api-GVYEKSJE.js +19 -0
  7. package/dist/as/index.js +11 -11
  8. package/dist/at/index.js +9 -9
  9. package/dist/attestation/index.js +20 -20
  10. package/dist/{backup-IJTB4S4M.js → backup-7TFRVFLH.js} +21 -15
  11. package/dist/backup-7TFRVFLH.js.map +1 -0
  12. package/dist/blobs/index.js +13 -13
  13. package/dist/broker/index.js +12 -12
  14. package/dist/by/index.js +2 -2
  15. package/dist/cargo/index.js +39 -36
  16. package/dist/{chunk-7O3Y4PPD.js → chunk-244VXYPG.js} +140 -16
  17. package/dist/chunk-244VXYPG.js.map +1 -0
  18. package/dist/{chunk-BUE2D7PX.js → chunk-32YV3TJT.js} +2 -2
  19. package/dist/{chunk-3RCJJBNR.js → chunk-3ELRMVJK.js} +12 -12
  20. package/dist/{chunk-6GMZ7HEE.js → chunk-3F7GLNAE.js} +6 -6
  21. package/dist/{chunk-2Y4IMKA6.js → chunk-3H5KLDZN.js} +4 -4
  22. package/dist/{chunk-VTFVLCUH.js → chunk-3JWHAR6E.js} +2 -2
  23. package/dist/{chunk-YMUFFJCO.js → chunk-3TDUWVWB.js} +5 -2
  24. package/dist/chunk-3TDUWVWB.js.map +1 -0
  25. package/dist/{chunk-JBDFMYKQ.js → chunk-4AF3TUMP.js} +2 -2
  26. package/dist/{chunk-ZORTV6NH.js → chunk-4I522ERM.js} +88 -4
  27. package/dist/chunk-4I522ERM.js.map +1 -0
  28. package/dist/{chunk-MUM7IANK.js → chunk-4MXI3ODD.js} +4 -4
  29. package/dist/chunk-4MXI3ODD.js.map +1 -0
  30. package/dist/{chunk-BLN54W3L.js → chunk-5FDLC6G7.js} +56 -3
  31. package/dist/chunk-5FDLC6G7.js.map +1 -0
  32. package/dist/chunk-5O7D6ZTW.js +53 -0
  33. package/dist/chunk-5O7D6ZTW.js.map +1 -0
  34. package/dist/{chunk-J6FXAEUG.js → chunk-6B3VNR4P.js} +12 -12
  35. package/dist/{chunk-TUFM4UZP.js → chunk-6K7DPM7D.js} +2 -2
  36. package/dist/{chunk-K6LHRFBL.js → chunk-6LMQ5R26.js} +7 -7
  37. package/dist/{chunk-SPXXX5E4.js → chunk-6LNL42F5.js} +94 -32
  38. package/dist/chunk-6LNL42F5.js.map +1 -0
  39. package/dist/{chunk-XLMEZIAJ.js → chunk-6OWXYZK2.js} +2 -2
  40. package/dist/{chunk-BOWNCWZT.js → chunk-6QSQQLSE.js} +3 -3
  41. package/dist/chunk-7JE7BDYJ.js +1558 -0
  42. package/dist/chunk-7JE7BDYJ.js.map +1 -0
  43. package/dist/{chunk-KG7TZKZG.js → chunk-7VCXZDA4.js} +5 -5
  44. package/dist/chunk-7VCXZDA4.js.map +1 -0
  45. package/dist/{chunk-NQKIUNW5.js → chunk-A6IJU4TK.js} +2 -2
  46. package/dist/{chunk-BM5TWITZ.js → chunk-ANWPSTZU.js} +38 -9
  47. package/dist/chunk-ANWPSTZU.js.map +1 -0
  48. package/dist/{chunk-QIZPZMUI.js → chunk-AOWGXU6D.js} +2 -2
  49. package/dist/{chunk-CUZLNGD5.js → chunk-B2YY6WDD.js} +1 -1
  50. package/dist/chunk-B2YY6WDD.js.map +1 -0
  51. package/dist/{chunk-SFAWCTEM.js → chunk-B57AFBY2.js} +2 -2
  52. package/dist/{chunk-GPEQUXHL.js → chunk-B6SJIBQK.js} +4 -4
  53. package/dist/chunk-BJ2IXQ5Q.js +100 -0
  54. package/dist/chunk-BJ2IXQ5Q.js.map +1 -0
  55. package/dist/{chunk-Q2PU57HC.js → chunk-BK2HHQGN.js} +2 -2
  56. package/dist/chunk-BKT776R5.js +1 -0
  57. package/dist/{chunk-KUX3OB6D.js → chunk-BP6DARYA.js} +33 -5
  58. package/dist/chunk-BP6DARYA.js.map +1 -0
  59. package/dist/{chunk-FXBIP2WD.js → chunk-BUDAGWL5.js} +6 -6
  60. package/dist/chunk-CF5UU4S7.js +757 -0
  61. package/dist/chunk-CF5UU4S7.js.map +1 -0
  62. package/dist/{chunk-BOET4NA4.js → chunk-CKNGS5MH.js} +3 -3
  63. package/dist/chunk-CY2CYVWZ.js +41 -0
  64. package/dist/chunk-CY2CYVWZ.js.map +1 -0
  65. package/dist/{chunk-2577DKXB.js → chunk-DC5QVPV7.js} +2 -2
  66. package/dist/chunk-DC5QVPV7.js.map +1 -0
  67. package/dist/{chunk-YSRUYAVU.js → chunk-DE4DH2RZ.js} +2 -2
  68. package/dist/{chunk-6I2RQCET.js → chunk-DF73H4UN.js} +4 -4
  69. package/dist/{chunk-4GVM6QZA.js → chunk-ENAG3IY7.js} +2 -2
  70. package/dist/chunk-ENAG3IY7.js.map +1 -0
  71. package/dist/{chunk-K7NTTA6P.js → chunk-EOVMT6TB.js} +2 -2
  72. package/dist/chunk-F24ZZTHQ.js +193 -0
  73. package/dist/chunk-F24ZZTHQ.js.map +1 -0
  74. package/dist/chunk-F2TDU7MQ.js +456 -0
  75. package/dist/chunk-F2TDU7MQ.js.map +1 -0
  76. package/dist/chunk-F6NCB7KT.js +13 -0
  77. package/dist/chunk-F6NCB7KT.js.map +1 -0
  78. package/dist/{chunk-SPYWXKJN.js → chunk-F7XGHL5O.js} +3 -3
  79. package/dist/chunk-F7XGHL5O.js.map +1 -0
  80. package/dist/{chunk-XTXOCYOJ.js → chunk-FCKWQE2H.js} +5 -5
  81. package/dist/{chunk-U4FOQDY4.js → chunk-FH2L2E34.js} +4 -4
  82. package/dist/chunk-FH2L2E34.js.map +1 -0
  83. package/dist/{chunk-4OZNXTO4.js → chunk-FN5EBVTQ.js} +2 -2
  84. package/dist/chunk-FQ54DWUQ.js +270 -0
  85. package/dist/chunk-FQ54DWUQ.js.map +1 -0
  86. package/dist/{chunk-NKHRDYOR.js → chunk-FQ5VRHIB.js} +4 -4
  87. package/dist/{chunk-FAHMLERK.js → chunk-FW22ZCXT.js} +2 -2
  88. package/dist/chunk-FXQBGFOX.js +524 -0
  89. package/dist/chunk-FXQBGFOX.js.map +1 -0
  90. package/dist/{chunk-AO42KJO6.js → chunk-GF5BZ7D4.js} +45 -9
  91. package/dist/chunk-GF5BZ7D4.js.map +1 -0
  92. package/dist/{chunk-TRGTKX5E.js → chunk-GHLTDZRS.js} +5 -3
  93. package/dist/{chunk-TRGTKX5E.js.map → chunk-GHLTDZRS.js.map} +1 -1
  94. package/dist/{chunk-5WDXHNSW.js → chunk-HBPPGWUM.js} +5 -5
  95. package/dist/chunk-HBPPGWUM.js.map +1 -0
  96. package/dist/{chunk-KTFRCC5C.js → chunk-HBRLNOHL.js} +82 -8
  97. package/dist/chunk-HBRLNOHL.js.map +1 -0
  98. package/dist/chunk-HLEK5VAN.js +275 -0
  99. package/dist/chunk-HLEK5VAN.js.map +1 -0
  100. package/dist/{chunk-RMS3NEA3.js → chunk-HT2AHGQI.js} +2 -2
  101. package/dist/{chunk-CHJBLCOG.js → chunk-HVSCEIYL.js} +7 -7
  102. package/dist/{chunk-UXWB3FPF.js → chunk-I3JDRCMW.js} +150 -22
  103. package/dist/chunk-I3JDRCMW.js.map +1 -0
  104. package/dist/{chunk-GY4WYNNG.js → chunk-ID6Z6E66.js} +2 -2
  105. package/dist/{chunk-EYBQEIUY.js → chunk-IEX7NK2K.js} +3 -3
  106. package/dist/{chunk-KUJDV5QH.js → chunk-ISZQJBML.js} +5 -5
  107. package/dist/{chunk-LWBCUYZW.js → chunk-IT22PWKV.js} +2 -2
  108. package/dist/{chunk-EQEYOJBM.js → chunk-IUWCVHQ7.js} +3 -3
  109. package/dist/chunk-IUWCVHQ7.js.map +1 -0
  110. package/dist/{chunk-7V4TP3AF.js → chunk-J6UOHJY5.js} +4 -4
  111. package/dist/{chunk-JMGDHKQF.js → chunk-JCN44NCY.js} +2 -2
  112. package/dist/{chunk-CARABLSQ.js → chunk-K6W7BVZ6.js} +3 -3
  113. package/dist/{chunk-77K4PG6P.js → chunk-KJFW62P4.js} +29 -11
  114. package/dist/chunk-KJFW62P4.js.map +1 -0
  115. package/dist/{chunk-453F654R.js → chunk-L7DOS3TE.js} +2 -2
  116. package/dist/chunk-LGNDFRYC.js +23 -0
  117. package/dist/chunk-LGNDFRYC.js.map +1 -0
  118. package/dist/{chunk-WEQEYLCS.js → chunk-LGRLME4M.js} +7 -7
  119. package/dist/{chunk-RMF67KCG.js → chunk-LQ4ZHOKP.js} +2 -2
  120. package/dist/{chunk-ZVO4QVPD.js → chunk-M522UYZ2.js} +5 -5
  121. package/dist/{chunk-G56KBWFY.js → chunk-M7NI3IWE.js} +45 -12
  122. package/dist/chunk-M7NI3IWE.js.map +1 -0
  123. package/dist/chunk-MDWKM2XC.js +293 -0
  124. package/dist/chunk-MDWKM2XC.js.map +1 -0
  125. package/dist/chunk-MKXXMNJH.js +204 -0
  126. package/dist/chunk-MKXXMNJH.js.map +1 -0
  127. package/dist/{chunk-SKGMN35F.js → chunk-MLPHLJIQ.js} +3 -3
  128. package/dist/chunk-MLPHLJIQ.js.map +1 -0
  129. package/dist/{chunk-2N4GY74U.js → chunk-MTL7MXGR.js} +6 -6
  130. package/dist/{chunk-TFR7DSOV.js → chunk-MVZ2TPVP.js} +2 -2
  131. package/dist/{chunk-CPWQB3N5.js → chunk-N5DNADLQ.js} +7 -7
  132. package/dist/{chunk-ELNXJMGB.js → chunk-NNARWO72.js} +6 -6
  133. package/dist/{chunk-PT43Y56J.js → chunk-NRT6QZQB.js} +102 -16
  134. package/dist/chunk-NRT6QZQB.js.map +1 -0
  135. package/dist/{chunk-QIBVIOXO.js → chunk-NWHBJQAL.js} +99 -8
  136. package/dist/chunk-NWHBJQAL.js.map +1 -0
  137. package/dist/chunk-NYMLINRP.js +28 -0
  138. package/dist/chunk-NYMLINRP.js.map +1 -0
  139. package/dist/{chunk-7MG7SJT7.js → chunk-ODVPTDPK.js} +1 -1
  140. package/dist/chunk-ODVPTDPK.js.map +1 -0
  141. package/dist/chunk-ORDURZBU.js +461 -0
  142. package/dist/chunk-ORDURZBU.js.map +1 -0
  143. package/dist/{chunk-6YXCPL4T.js → chunk-PDCG6PR5.js} +2 -2
  144. package/dist/{chunk-REDOOY2Q.js → chunk-PSIV7CJV.js} +2 -2
  145. package/dist/{chunk-NA2NIJZI.js → chunk-QBBUZ3I3.js} +126 -19
  146. package/dist/chunk-QBBUZ3I3.js.map +1 -0
  147. package/dist/{chunk-5VCRVKOZ.js → chunk-QOOUUR4A.js} +6 -4
  148. package/dist/{chunk-5VCRVKOZ.js.map → chunk-QOOUUR4A.js.map} +1 -1
  149. package/dist/{chunk-ANATMFIO.js → chunk-QWFHIOD2.js} +5 -5
  150. package/dist/{chunk-X2DLENDQ.js → chunk-QWGU66MP.js} +3 -3
  151. package/dist/chunk-RHVMZSUU.js +7 -0
  152. package/dist/chunk-RHVMZSUU.js.map +1 -0
  153. package/dist/{chunk-BSFNRLK2.js → chunk-S57HTZ6X.js} +5 -5
  154. package/dist/{chunk-SZJ3DLZA.js → chunk-SEE332EV.js} +2 -2
  155. package/dist/{chunk-YYP7WSEB.js → chunk-SI3V7D4G.js} +2 -2
  156. package/dist/{chunk-UGTBXF5U.js → chunk-SOIQ4MM4.js} +3 -3
  157. package/dist/chunk-SUZKW6UR.js +25 -0
  158. package/dist/chunk-SUZKW6UR.js.map +1 -0
  159. package/dist/{chunk-VXGSWL6L.js → chunk-SYVZW77S.js} +6 -6
  160. package/dist/{chunk-6GOE5PGN.js → chunk-T2LBQ5DV.js} +883 -227
  161. package/dist/chunk-T2LBQ5DV.js.map +1 -0
  162. package/dist/chunk-T52GX4SA.js +215 -0
  163. package/dist/chunk-T52GX4SA.js.map +1 -0
  164. package/dist/{chunk-MVMXZYXT.js → chunk-TKUOEU2F.js} +2 -2
  165. package/dist/chunk-TOPYQ6GA.js +31 -0
  166. package/dist/chunk-TOPYQ6GA.js.map +1 -0
  167. package/dist/{chunk-SMH6SRX7.js → chunk-TROR3ALR.js} +2 -2
  168. package/dist/{chunk-2C3AQB46.js → chunk-UD5EVGZ7.js} +42 -389
  169. package/dist/chunk-UD5EVGZ7.js.map +1 -0
  170. package/dist/{chunk-KJIMGIWO.js → chunk-UPD5NWI5.js} +65 -17
  171. package/dist/chunk-UPD5NWI5.js.map +1 -0
  172. package/dist/{chunk-SL3JAAKN.js → chunk-UYB234ZR.js} +30 -2
  173. package/dist/chunk-UYB234ZR.js.map +1 -0
  174. package/dist/chunk-VHM7HCKB.js +220 -0
  175. package/dist/chunk-VHM7HCKB.js.map +1 -0
  176. package/dist/{chunk-DGOZ4UZD.js → chunk-VNNRUGMM.js} +2 -2
  177. package/dist/{chunk-HDOU6I2Y.js → chunk-VNPEWFPD.js} +4 -4
  178. package/dist/{chunk-L7CIOOBW.js → chunk-WNJ4AVGE.js} +2 -2
  179. package/dist/{chunk-FMZY5Q6L.js → chunk-WX5ADGTZ.js} +3 -3
  180. package/dist/{chunk-VXANTWBJ.js → chunk-WY2XXTET.js} +92 -6
  181. package/dist/{chunk-VXANTWBJ.js.map → chunk-WY2XXTET.js.map} +1 -1
  182. package/dist/{chunk-6X6SEMEE.js → chunk-X25NWUZB.js} +33 -8
  183. package/dist/chunk-X25NWUZB.js.map +1 -0
  184. package/dist/{chunk-Q7HZX3IF.js → chunk-X4773RBR.js} +2 -2
  185. package/dist/chunk-XBKH4FOC.js +195 -0
  186. package/dist/chunk-XBKH4FOC.js.map +1 -0
  187. package/dist/{chunk-ANSIZYEG.js → chunk-YNIUIERI.js} +3 -3
  188. package/dist/chunk-YSK2CU2Q.js +936 -0
  189. package/dist/chunk-YSK2CU2Q.js.map +1 -0
  190. package/dist/{chunk-UXVWEX5L.js → chunk-Z5HTYMMQ.js} +6 -2
  191. package/dist/chunk-Z5HTYMMQ.js.map +1 -0
  192. package/dist/{chunk-RRNRNANG.js → chunk-ZE4CHIED.js} +66 -75
  193. package/dist/chunk-ZE4CHIED.js.map +1 -0
  194. package/dist/chunk-ZSX4S5XB.js +1289 -0
  195. package/dist/chunk-ZSX4S5XB.js.map +1 -0
  196. package/dist/{chunk-BZ3534YM.js → chunk-ZUVBC32X.js} +2 -2
  197. package/dist/{chunk-L742JPKZ.js → chunk-ZXABPVM6.js} +6 -6
  198. package/dist/classified/index.js +5 -5
  199. package/dist/{classified-marker-LI2SF2E4.js → classified-marker-W3USLL5M.js} +3 -3
  200. package/dist/collection-facade-QU6IJBN3.js +48 -0
  201. package/dist/{computed-VPOKQK4N.js → computed-TPFBX7U4.js} +3 -3
  202. package/dist/consent/index.js +9 -9
  203. package/dist/cover/index.js +10 -10
  204. package/dist/coverage/index.js +306 -0
  205. package/dist/coverage/index.js.map +1 -0
  206. package/dist/custody/index.js +12 -12
  207. package/dist/{dead-filter-TSWZQRR5.js → dead-filter-U2UYKSZL.js} +2 -2
  208. package/dist/debug/index.js +1 -1
  209. package/dist/{delegation-OVIFFPG4.js → delegation-S3AEPW2T.js} +11 -11
  210. package/dist/derivations/index.js +25 -22
  211. package/dist/derive-OX7F6TGG.js +21 -0
  212. package/dist/directory/index.js +10 -10
  213. package/dist/{dispatch-WC6X2M6C.js → dispatch-3CQDJV5Q.js} +5 -5
  214. package/dist/{dispatch-S73TK3IY.js → dispatch-RH4LHKBH.js} +21 -21
  215. package/dist/{enclave-KJOTOH7X.js → enclave-27SMF6GF.js} +15 -9
  216. package/dist/executor-B6SRO2QS.js +36 -0
  217. package/dist/executor-BI5CHWRY.js +8 -0
  218. package/dist/executor-RBKM5W5K.js +8 -0
  219. package/dist/export-accessible-VMA3YM5V.js +22 -0
  220. package/dist/extract-partition-NF7PXGPP.js +37 -0
  221. package/dist/{fanout-sidecar-WUFXNYP4.js → fanout-sidecar-OT6RYLOL.js} +9 -9
  222. package/dist/find-LZMP26KF.js +10 -0
  223. package/dist/forget/index.js +9 -9
  224. package/dist/guards/index.js +4 -4
  225. package/dist/history/index.js +13 -13
  226. package/dist/i18n/index.js +14 -14
  227. package/dist/index.d.ts +29 -6
  228. package/dist/index.js +999 -191
  229. package/dist/index.js.map +1 -1
  230. package/dist/indexing/index.js +13 -5
  231. package/dist/indexing/index.js.map +1 -1
  232. package/dist/introspection/index.js +11 -11
  233. package/dist/issue-IHARXWW5.js +18 -0
  234. package/dist/ivf-flat-UZ6DQDLS.js +314 -0
  235. package/dist/ivf-flat-UZ6DQDLS.js.map +1 -0
  236. package/dist/{json-schema-V3M5MUCM.js → json-schema-3SHX72CC.js} +2 -1
  237. package/dist/json-schema-3SHX72CC.js.map +1 -0
  238. package/dist/kernel/collection-config.d.ts +4 -20
  239. package/dist/kernel/collection.d.ts +29 -8
  240. package/dist/kernel/enclave/crypto.d.ts +16 -0
  241. package/dist/kernel/enclave/index.d.ts +1 -1
  242. package/dist/kernel/enclave/record-keys/record-codec.d.ts +25 -0
  243. package/dist/kernel/errors.d.ts +227 -36
  244. package/dist/kernel/generation-map.d.ts +48 -0
  245. package/dist/kernel/memory-store.d.ts +35 -7
  246. package/dist/kernel/noydb.d.ts +6 -1
  247. package/dist/kernel/present-cache.d.ts +58 -0
  248. package/dist/kernel/query/all.d.ts +7 -0
  249. package/dist/kernel/query/builder.d.ts +601 -270
  250. package/dist/kernel/query/civil-date.d.ts +64 -0
  251. package/dist/kernel/query/cursor.d.ts +40 -0
  252. package/dist/kernel/query/distinct-key.d.ts +98 -0
  253. package/dist/kernel/query/hydration.d.ts +76 -0
  254. package/dist/kernel/query/index.d.ts +31 -15
  255. package/dist/kernel/query/internal/core.d.ts +30 -0
  256. package/dist/kernel/query/internal/hooks.d.ts +22 -0
  257. package/dist/kernel/query/internal/maintenance.d.ts +43 -0
  258. package/dist/kernel/query/live/incremental.d.ts +314 -0
  259. package/dist/kernel/query/live/index.d.ts +22 -0
  260. package/dist/kernel/query/live/install.d.ts +2 -0
  261. package/dist/kernel/query/{live.d.ts → live/live.d.ts} +39 -9
  262. package/dist/kernel/query/live/methods.d.ts +107 -0
  263. package/dist/kernel/query/predicate.d.ts +119 -1
  264. package/dist/kernel/query/reduce/date-trunc.d.ts +75 -0
  265. package/dist/kernel/query/reduce/index.d.ts +36 -0
  266. package/dist/kernel/query/reduce/install.d.ts +2 -0
  267. package/dist/kernel/query/reduce/methods.d.ts +259 -0
  268. package/dist/kernel/query/reduce/scan-methods.d.ts +121 -0
  269. package/dist/kernel/query/relate/explain.d.ts +199 -0
  270. package/dist/kernel/query/relate/index.d.ts +48 -0
  271. package/dist/kernel/query/relate/install.d.ts +2 -0
  272. package/dist/kernel/query/relate/join-on.d.ts +126 -0
  273. package/dist/kernel/query/relate/join-reduce.d.ts +16 -0
  274. package/dist/kernel/query/relate/join.d.ts +452 -0
  275. package/dist/kernel/query/relate/methods.d.ts +426 -0
  276. package/dist/kernel/query/relate/partition.d.ts +87 -0
  277. package/dist/kernel/query/relate/scan-methods.d.ts +163 -0
  278. package/dist/kernel/query/relate/traverse.d.ts +109 -0
  279. package/dist/kernel/query/scan-builder.d.ts +79 -176
  280. package/dist/kernel/query/sort-key.d.ts +52 -0
  281. package/dist/kernel/tx-write-gate.d.ts +77 -0
  282. package/dist/kernel/types.d.ts +71 -3
  283. package/dist/kernel/validation.d.ts +27 -10
  284. package/dist/kernel/vault.d.ts +9 -4
  285. package/dist/kernel/via/compose.d.ts +3 -0
  286. package/dist/kernel/via/index.d.ts +56 -0
  287. package/dist/kernel/via/pipeline.d.ts +48 -0
  288. package/dist/{ledger-F33ZVMTK.js → ledger-KZPCMVZY.js} +11 -11
  289. package/dist/liberate-GRLCZMW4.js +24 -0
  290. package/dist/link-set-JCMJ7ULP.js +30 -0
  291. package/dist/{managed-secret-PQYKSR6T.js → managed-secret-S3MQ6SH6.js} +10 -10
  292. package/dist/materialized-views/index.js +30 -23
  293. package/dist/{migrate-cek-5ENH64AA.js → migrate-cek-V7GKJZ7O.js} +2 -2
  294. package/dist/money/index.js +5 -5
  295. package/dist/noydb-SWQJ3MZS.js +97 -0
  296. package/dist/overlay-views/index.js +4 -4
  297. package/dist/periods/index.js +12 -12
  298. package/dist/pod/index.js +75 -68
  299. package/dist/{pod-handle-Q736KYON.js → pod-handle-WGDFB4C2.js} +9 -9
  300. package/dist/policy/index.js +10 -10
  301. package/dist/port/with/blob-strategy.d.ts +9 -0
  302. package/dist/port/with/collection-options.d.ts +5 -0
  303. package/dist/port/with/coverage-strategy.d.ts +83 -0
  304. package/dist/port/with/service-bus.d.ts +46 -0
  305. package/dist/port/with/strategies.d.ts +2 -0
  306. package/dist/portability/index.js +8 -8
  307. package/dist/{post-register-LNE2FE2A.js → post-register-SLSXIPBV.js} +6 -6
  308. package/dist/query/all/index.js +31 -0
  309. package/dist/query/index.js +20 -32
  310. package/dist/query/live/index.js +21 -0
  311. package/dist/query/live/index.js.map +1 -0
  312. package/dist/query/reduce/index.js +33 -0
  313. package/dist/query/reduce/index.js.map +1 -0
  314. package/dist/query/relate/index.js +56 -0
  315. package/dist/query/relate/index.js.map +1 -0
  316. package/dist/reduce/index.js +72 -18
  317. package/dist/reduce/index.js.map +1 -1
  318. package/dist/register-F3OYE7MJ.js +31 -0
  319. package/dist/registry-CILQFXFK.js +8 -0
  320. package/dist/registry-XNNYQVKV.js +8 -0
  321. package/dist/registry-YCDZV3VW.js +35 -0
  322. package/dist/registry-ZGYS33TE.js +24 -0
  323. package/dist/request-withdrawal-Z5NC6TXT.js +30 -0
  324. package/dist/{reveal-67RDQRIN.js → reveal-4BCKPEC2.js} +6 -6
  325. package/dist/revoke-ZL62WC2D.js +23 -0
  326. package/dist/satellites/index.js +1 -1
  327. package/dist/schema-update/index.js +2 -2
  328. package/dist/sealed-record/index.js +12 -12
  329. package/dist/search/index.js +11 -5
  330. package/dist/{seed-G42JYN56.js → seed-4JS2RJ4A.js} +12 -12
  331. package/dist/sequence/index.js +9 -9
  332. package/dist/session/index.js +9 -9
  333. package/dist/shadow/index.js +2 -2
  334. package/dist/signer-MBZZMXTC.js +24 -0
  335. package/dist/snapshots/index.js +10 -10
  336. package/dist/{stale-DDL7WQEZ.js → stale-TJ3DYZMQ.js} +10 -10
  337. package/dist/storage-SVMKRGCW.js +22 -0
  338. package/dist/{store-coordination-provider-MEQ2MJQG.js → store-coordination-provider-2O2VUHKW.js} +10 -10
  339. package/dist/sync/index.js +10 -10
  340. package/dist/team/index.js +17 -15
  341. package/dist/tiers/index.js +13 -11
  342. package/dist/to/index.js +2 -2
  343. package/dist/transactions/index.js +3 -3
  344. package/dist/util/index.js +1 -1
  345. package/dist/vault-head/index.js +8 -8
  346. package/dist/{verify-KOV2G5D6.js → verify-RVT67IMH.js} +5 -5
  347. package/dist/via/blob/index.d.ts +1 -0
  348. package/dist/via/geo/binding.d.ts +31 -0
  349. package/dist/via/geo/descriptor.d.ts +54 -0
  350. package/dist/via/geo/geohash.d.ts +95 -0
  351. package/dist/via/geo/index.d.ts +13 -0
  352. package/dist/via/geo/where.d.ts +50 -0
  353. package/dist/via/i18n/core.d.ts +1 -1
  354. package/dist/via/lookup/registry.d.ts +1 -1
  355. package/dist/via/lookup/snapshot.d.ts +3 -3
  356. package/dist/walk-HJ42EISE.js +21 -0
  357. package/dist/walk-HJ42EISE.js.map +1 -0
  358. package/dist/with-audit/coverage/accounting.d.ts +112 -0
  359. package/dist/with-audit/coverage/active.d.ts +29 -0
  360. package/dist/with-audit/coverage/index.d.ts +61 -0
  361. package/dist/with-audit/coverage/sketch.d.ts +75 -0
  362. package/dist/with-audit/periods/periods.d.ts +55 -7
  363. package/dist/with-audit/periods/reserved-collections.d.ts +3 -0
  364. package/dist/with-audit/periods/vault-facade.d.ts +17 -0
  365. package/dist/with-audit/tiers/index.d.ts +51 -0
  366. package/dist/with-audit/tiers/strategy.d.ts +8 -0
  367. package/dist/with-cargo/floor.d.ts +2 -2
  368. package/dist/with-commit/tx/invariants.d.ts +1 -1
  369. package/dist/with-commit/tx/transaction.d.ts +13 -3
  370. package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +4 -3
  371. package/dist/with-formula/materialized-views/emit-memo.d.ts +40 -0
  372. package/dist/with-formula/materialized-views/executor.d.ts +8 -0
  373. package/dist/with-formula/materialized-views/index.d.ts +1 -1
  374. package/dist/with-formula/materialized-views/registry.d.ts +15 -0
  375. package/dist/with-formula/materialized-views/types.d.ts +106 -14
  376. package/dist/with-formula/materialized-views/window-stage.d.ts +11 -0
  377. package/dist/with-formula/overlay-views/types.d.ts +1 -1
  378. package/dist/with-formula/overlay-views/virtual-collection.d.ts +13 -4
  379. package/dist/with-lookup/embeddings/chunks.d.ts +79 -0
  380. package/dist/with-lookup/embeddings/descriptor.d.ts +21 -0
  381. package/dist/with-lookup/embeddings/index.d.ts +3 -0
  382. package/dist/with-lookup/embeddings/ivf-flat.d.ts +93 -0
  383. package/dist/with-lookup/embeddings/vector-index.d.ts +73 -0
  384. package/dist/with-lookup/embeddings/vector-set.d.ts +94 -1
  385. package/dist/with-lookup/embeddings/with-vector-index.d.ts +67 -0
  386. package/dist/with-lookup/indexing/collection-facade.d.ts +85 -2
  387. package/dist/with-lookup/indexing/compound-indexes.d.ts +129 -0
  388. package/dist/with-lookup/indexing/eager-indexes.d.ts +170 -1
  389. package/dist/with-lookup/indexing/index-snapshot.d.ts +62 -0
  390. package/dist/with-lookup/indexing/lazy-builder.d.ts +33 -0
  391. package/dist/with-lookup/indexing/persisted-field-indexes.d.ts +104 -0
  392. package/dist/with-lookup/indexing/persisted-indexes.d.ts +12 -0
  393. package/dist/with-lookup/indexing/sorted-indexes.d.ts +117 -0
  394. package/dist/with-lookup/indexing/unique-constraints.d.ts +106 -23
  395. package/dist/with-lookup/reduce/active.d.ts +2 -24
  396. package/dist/with-lookup/reduce/group-core.d.ts +43 -0
  397. package/dist/with-lookup/reduce/groupby.d.ts +195 -36
  398. package/dist/with-lookup/reduce/incremental-group.d.ts +153 -0
  399. package/dist/with-lookup/reduce/index.d.ts +26 -5
  400. package/dist/with-lookup/reduce/reducers.d.ts +255 -1
  401. package/dist/with-lookup/reduce/reduction.d.ts +44 -13
  402. package/dist/with-lookup/reduce/strategy.d.ts +43 -3
  403. package/dist/with-lookup/reduce/window.d.ts +262 -0
  404. package/dist/with-lookup/search/collection-facade.d.ts +44 -8
  405. package/dist/with-lookup/search/index-store.d.ts +5 -3
  406. package/dist/with-lookup/search/index.d.ts +4 -2
  407. package/dist/with-lookup/search/inverted-index.d.ts +38 -2
  408. package/dist/with-lookup/search/persisted-index-store.d.ts +5 -2
  409. package/dist/with-lookup/search/phrase.d.ts +28 -0
  410. package/dist/with-lookup/search/retrieve-types.d.ts +57 -1
  411. package/dist/with-lookup/search/serialize.d.ts +29 -3
  412. package/dist/with-lookup/search/strategy.d.ts +2 -6
  413. package/dist/with-party/directory/cover/index.d.ts +1 -1
  414. package/dist/with-party/directory/cover/storage.d.ts +1 -1
  415. package/dist/with-party/directory/cover/types.d.ts +1 -1
  416. package/dist/with-party/directory/index.d.ts +1 -1
  417. package/dist/with-party/directory/types.d.ts +1 -1
  418. package/dist/with-party/directory/user-envelope/api.d.ts +1 -1
  419. package/dist/with-party/policy/engine.d.ts +1 -1
  420. package/dist/with-party/policy/index.d.ts +1 -1
  421. package/dist/with-party/policy/presets.d.ts +1 -1
  422. package/dist/with-party/team/authenticators.d.ts +91 -1
  423. package/dist/with-party/team/index.d.ts +3 -2
  424. package/dist/with-party/team/keyring.d.ts +13 -6
  425. package/dist/with-party/team/managed-secret.d.ts +1 -1
  426. package/dist/with-party/team/noydb-facade.d.ts +12 -3
  427. package/dist/with-party/team/wrapped-deks.d.ts +4 -4
  428. package/dist/with-pod/format.d.ts +1 -1
  429. package/dist/with-pod/pod.d.ts +5 -5
  430. package/dist/with-shape/blobs/blob-compaction.d.ts +16 -0
  431. package/dist/with-shape/blobs/blob-set.d.ts +21 -2
  432. package/dist/with-shape/blobs/legacy-sweep.d.ts +35 -0
  433. package/dist/with-shape/introspection/describe.d.ts +6 -0
  434. package/dist/with-shape/introspection/field-meta.d.ts +18 -0
  435. package/dist/with-shape/introspection/types.d.ts +57 -1
  436. package/dist/with-shape/links/vault-facade.d.ts +1 -1
  437. package/dist/with-store/partitioned/index.d.ts +337 -0
  438. package/dist/with-sync/change-broadcast.d.ts +153 -0
  439. package/dist/withdraw-accessible-5NZUPAVA.js +27 -0
  440. package/dist/withdraw-accessible-5NZUPAVA.js.map +1 -0
  441. package/package.json +37 -10
  442. package/dist/api-TXFOVOXX.js +0 -19
  443. package/dist/backup-IJTB4S4M.js.map +0 -1
  444. package/dist/chunk-2577DKXB.js.map +0 -1
  445. package/dist/chunk-2C3AQB46.js.map +0 -1
  446. package/dist/chunk-4GVM6QZA.js.map +0 -1
  447. package/dist/chunk-5WDXHNSW.js.map +0 -1
  448. package/dist/chunk-6GOE5PGN.js.map +0 -1
  449. package/dist/chunk-6X6SEMEE.js.map +0 -1
  450. package/dist/chunk-77K4PG6P.js.map +0 -1
  451. package/dist/chunk-7MG2LHO5.js +0 -1616
  452. package/dist/chunk-7MG2LHO5.js.map +0 -1
  453. package/dist/chunk-7MG7SJT7.js.map +0 -1
  454. package/dist/chunk-7O3Y4PPD.js.map +0 -1
  455. package/dist/chunk-AO42KJO6.js.map +0 -1
  456. package/dist/chunk-ATL3ZVXT.js +0 -151
  457. package/dist/chunk-ATL3ZVXT.js.map +0 -1
  458. package/dist/chunk-BLN54W3L.js.map +0 -1
  459. package/dist/chunk-BM5TWITZ.js.map +0 -1
  460. package/dist/chunk-CUZLNGD5.js.map +0 -1
  461. package/dist/chunk-EQEYOJBM.js.map +0 -1
  462. package/dist/chunk-G56KBWFY.js.map +0 -1
  463. package/dist/chunk-I3ISCYT7.js +0 -159
  464. package/dist/chunk-I3ISCYT7.js.map +0 -1
  465. package/dist/chunk-KG7TZKZG.js.map +0 -1
  466. package/dist/chunk-KJIMGIWO.js.map +0 -1
  467. package/dist/chunk-KTFRCC5C.js.map +0 -1
  468. package/dist/chunk-KUX3OB6D.js.map +0 -1
  469. package/dist/chunk-MUM7IANK.js.map +0 -1
  470. package/dist/chunk-NA2NIJZI.js.map +0 -1
  471. package/dist/chunk-NSITFOCJ.js +0 -99
  472. package/dist/chunk-NSITFOCJ.js.map +0 -1
  473. package/dist/chunk-PT43Y56J.js.map +0 -1
  474. package/dist/chunk-QIBVIOXO.js.map +0 -1
  475. package/dist/chunk-RRNRNANG.js.map +0 -1
  476. package/dist/chunk-RTBJ5IOO.js +0 -87
  477. package/dist/chunk-RTBJ5IOO.js.map +0 -1
  478. package/dist/chunk-SKGMN35F.js.map +0 -1
  479. package/dist/chunk-SL3JAAKN.js.map +0 -1
  480. package/dist/chunk-SPXXX5E4.js.map +0 -1
  481. package/dist/chunk-SPYWXKJN.js.map +0 -1
  482. package/dist/chunk-U4FOQDY4.js.map +0 -1
  483. package/dist/chunk-UXVWEX5L.js.map +0 -1
  484. package/dist/chunk-UXWB3FPF.js.map +0 -1
  485. package/dist/chunk-YMUFFJCO.js.map +0 -1
  486. package/dist/chunk-ZN4FD4PE.js +0 -364
  487. package/dist/chunk-ZN4FD4PE.js.map +0 -1
  488. package/dist/chunk-ZORTV6NH.js.map +0 -1
  489. package/dist/collection-facade-4GRREZ6C.js +0 -45
  490. package/dist/derive-6O5SWQKN.js +0 -21
  491. package/dist/executor-5NIMLSKZ.js +0 -8
  492. package/dist/executor-AQVXV5GZ.js +0 -8
  493. package/dist/executor-PUAO6AKJ.js +0 -29
  494. package/dist/export-accessible-72EQNBMR.js +0 -22
  495. package/dist/extract-partition-PUYNU3UF.js +0 -37
  496. package/dist/find-2ABFCZX4.js +0 -10
  497. package/dist/issue-SIDORTSZ.js +0 -18
  498. package/dist/json-schema-V3M5MUCM.js.map +0 -1
  499. package/dist/kernel/query/join.d.ts +0 -232
  500. package/dist/liberate-LCDPNAG2.js +0 -24
  501. package/dist/link-set-FKNWAYKS.js +0 -30
  502. package/dist/noydb-DUXZPKSN.js +0 -90
  503. package/dist/register-I2DZXGAR.js +0 -31
  504. package/dist/registry-23WF3TGH.js +0 -8
  505. package/dist/registry-4AYVUNXK.js +0 -8
  506. package/dist/registry-VSSQPIGF.js +0 -18
  507. package/dist/registry-YLEWMGAC.js +0 -32
  508. package/dist/request-withdrawal-KFQHEZ25.js +0 -30
  509. package/dist/revoke-DQDZAZZM.js +0 -23
  510. package/dist/signer-WAMDZHEN.js +0 -24
  511. package/dist/storage-FLR73HHF.js +0 -22
  512. package/dist/walk-3UQBRMDV.js +0 -21
  513. package/dist/withdraw-accessible-EL5GXZBS.js +0 -27
  514. /package/dist/{api-TXFOVOXX.js.map → api-GVYEKSJE.js.map} +0 -0
  515. /package/dist/{chunk-BUE2D7PX.js.map → chunk-32YV3TJT.js.map} +0 -0
  516. /package/dist/{chunk-3RCJJBNR.js.map → chunk-3ELRMVJK.js.map} +0 -0
  517. /package/dist/{chunk-6GMZ7HEE.js.map → chunk-3F7GLNAE.js.map} +0 -0
  518. /package/dist/{chunk-2Y4IMKA6.js.map → chunk-3H5KLDZN.js.map} +0 -0
  519. /package/dist/{chunk-VTFVLCUH.js.map → chunk-3JWHAR6E.js.map} +0 -0
  520. /package/dist/{chunk-JBDFMYKQ.js.map → chunk-4AF3TUMP.js.map} +0 -0
  521. /package/dist/{chunk-J6FXAEUG.js.map → chunk-6B3VNR4P.js.map} +0 -0
  522. /package/dist/{chunk-TUFM4UZP.js.map → chunk-6K7DPM7D.js.map} +0 -0
  523. /package/dist/{chunk-K6LHRFBL.js.map → chunk-6LMQ5R26.js.map} +0 -0
  524. /package/dist/{chunk-XLMEZIAJ.js.map → chunk-6OWXYZK2.js.map} +0 -0
  525. /package/dist/{chunk-BOWNCWZT.js.map → chunk-6QSQQLSE.js.map} +0 -0
  526. /package/dist/{chunk-NQKIUNW5.js.map → chunk-A6IJU4TK.js.map} +0 -0
  527. /package/dist/{chunk-QIZPZMUI.js.map → chunk-AOWGXU6D.js.map} +0 -0
  528. /package/dist/{chunk-SFAWCTEM.js.map → chunk-B57AFBY2.js.map} +0 -0
  529. /package/dist/{chunk-GPEQUXHL.js.map → chunk-B6SJIBQK.js.map} +0 -0
  530. /package/dist/{chunk-Q2PU57HC.js.map → chunk-BK2HHQGN.js.map} +0 -0
  531. /package/dist/{collection-facade-4GRREZ6C.js.map → chunk-BKT776R5.js.map} +0 -0
  532. /package/dist/{chunk-FXBIP2WD.js.map → chunk-BUDAGWL5.js.map} +0 -0
  533. /package/dist/{chunk-BOET4NA4.js.map → chunk-CKNGS5MH.js.map} +0 -0
  534. /package/dist/{chunk-YSRUYAVU.js.map → chunk-DE4DH2RZ.js.map} +0 -0
  535. /package/dist/{chunk-6I2RQCET.js.map → chunk-DF73H4UN.js.map} +0 -0
  536. /package/dist/{chunk-K7NTTA6P.js.map → chunk-EOVMT6TB.js.map} +0 -0
  537. /package/dist/{chunk-XTXOCYOJ.js.map → chunk-FCKWQE2H.js.map} +0 -0
  538. /package/dist/{chunk-4OZNXTO4.js.map → chunk-FN5EBVTQ.js.map} +0 -0
  539. /package/dist/{chunk-NKHRDYOR.js.map → chunk-FQ5VRHIB.js.map} +0 -0
  540. /package/dist/{chunk-FAHMLERK.js.map → chunk-FW22ZCXT.js.map} +0 -0
  541. /package/dist/{chunk-RMS3NEA3.js.map → chunk-HT2AHGQI.js.map} +0 -0
  542. /package/dist/{chunk-CHJBLCOG.js.map → chunk-HVSCEIYL.js.map} +0 -0
  543. /package/dist/{chunk-GY4WYNNG.js.map → chunk-ID6Z6E66.js.map} +0 -0
  544. /package/dist/{chunk-EYBQEIUY.js.map → chunk-IEX7NK2K.js.map} +0 -0
  545. /package/dist/{chunk-KUJDV5QH.js.map → chunk-ISZQJBML.js.map} +0 -0
  546. /package/dist/{chunk-LWBCUYZW.js.map → chunk-IT22PWKV.js.map} +0 -0
  547. /package/dist/{chunk-7V4TP3AF.js.map → chunk-J6UOHJY5.js.map} +0 -0
  548. /package/dist/{chunk-JMGDHKQF.js.map → chunk-JCN44NCY.js.map} +0 -0
  549. /package/dist/{chunk-CARABLSQ.js.map → chunk-K6W7BVZ6.js.map} +0 -0
  550. /package/dist/{chunk-453F654R.js.map → chunk-L7DOS3TE.js.map} +0 -0
  551. /package/dist/{chunk-WEQEYLCS.js.map → chunk-LGRLME4M.js.map} +0 -0
  552. /package/dist/{chunk-RMF67KCG.js.map → chunk-LQ4ZHOKP.js.map} +0 -0
  553. /package/dist/{chunk-ZVO4QVPD.js.map → chunk-M522UYZ2.js.map} +0 -0
  554. /package/dist/{chunk-2N4GY74U.js.map → chunk-MTL7MXGR.js.map} +0 -0
  555. /package/dist/{chunk-TFR7DSOV.js.map → chunk-MVZ2TPVP.js.map} +0 -0
  556. /package/dist/{chunk-CPWQB3N5.js.map → chunk-N5DNADLQ.js.map} +0 -0
  557. /package/dist/{chunk-ELNXJMGB.js.map → chunk-NNARWO72.js.map} +0 -0
  558. /package/dist/{chunk-6YXCPL4T.js.map → chunk-PDCG6PR5.js.map} +0 -0
  559. /package/dist/{chunk-REDOOY2Q.js.map → chunk-PSIV7CJV.js.map} +0 -0
  560. /package/dist/{chunk-ANATMFIO.js.map → chunk-QWFHIOD2.js.map} +0 -0
  561. /package/dist/{chunk-X2DLENDQ.js.map → chunk-QWGU66MP.js.map} +0 -0
  562. /package/dist/{chunk-BSFNRLK2.js.map → chunk-S57HTZ6X.js.map} +0 -0
  563. /package/dist/{chunk-SZJ3DLZA.js.map → chunk-SEE332EV.js.map} +0 -0
  564. /package/dist/{chunk-YYP7WSEB.js.map → chunk-SI3V7D4G.js.map} +0 -0
  565. /package/dist/{chunk-UGTBXF5U.js.map → chunk-SOIQ4MM4.js.map} +0 -0
  566. /package/dist/{chunk-VXGSWL6L.js.map → chunk-SYVZW77S.js.map} +0 -0
  567. /package/dist/{chunk-MVMXZYXT.js.map → chunk-TKUOEU2F.js.map} +0 -0
  568. /package/dist/{chunk-SMH6SRX7.js.map → chunk-TROR3ALR.js.map} +0 -0
  569. /package/dist/{chunk-DGOZ4UZD.js.map → chunk-VNNRUGMM.js.map} +0 -0
  570. /package/dist/{chunk-HDOU6I2Y.js.map → chunk-VNPEWFPD.js.map} +0 -0
  571. /package/dist/{chunk-L7CIOOBW.js.map → chunk-WNJ4AVGE.js.map} +0 -0
  572. /package/dist/{chunk-FMZY5Q6L.js.map → chunk-WX5ADGTZ.js.map} +0 -0
  573. /package/dist/{chunk-Q7HZX3IF.js.map → chunk-X4773RBR.js.map} +0 -0
  574. /package/dist/{chunk-ANSIZYEG.js.map → chunk-YNIUIERI.js.map} +0 -0
  575. /package/dist/{chunk-BZ3534YM.js.map → chunk-ZUVBC32X.js.map} +0 -0
  576. /package/dist/{chunk-L742JPKZ.js.map → chunk-ZXABPVM6.js.map} +0 -0
  577. /package/dist/{classified-marker-LI2SF2E4.js.map → classified-marker-W3USLL5M.js.map} +0 -0
  578. /package/dist/{computed-VPOKQK4N.js.map → collection-facade-QU6IJBN3.js.map} +0 -0
  579. /package/dist/{derive-6O5SWQKN.js.map → computed-TPFBX7U4.js.map} +0 -0
  580. /package/dist/{dead-filter-TSWZQRR5.js.map → dead-filter-U2UYKSZL.js.map} +0 -0
  581. /package/dist/{delegation-OVIFFPG4.js.map → delegation-S3AEPW2T.js.map} +0 -0
  582. /package/dist/{enclave-KJOTOH7X.js.map → derive-OX7F6TGG.js.map} +0 -0
  583. /package/dist/{dispatch-WC6X2M6C.js.map → dispatch-3CQDJV5Q.js.map} +0 -0
  584. /package/dist/{dispatch-S73TK3IY.js.map → dispatch-RH4LHKBH.js.map} +0 -0
  585. /package/dist/{executor-5NIMLSKZ.js.map → enclave-27SMF6GF.js.map} +0 -0
  586. /package/dist/{executor-AQVXV5GZ.js.map → executor-B6SRO2QS.js.map} +0 -0
  587. /package/dist/{executor-PUAO6AKJ.js.map → executor-BI5CHWRY.js.map} +0 -0
  588. /package/dist/{export-accessible-72EQNBMR.js.map → executor-RBKM5W5K.js.map} +0 -0
  589. /package/dist/{extract-partition-PUYNU3UF.js.map → export-accessible-VMA3YM5V.js.map} +0 -0
  590. /package/dist/{find-2ABFCZX4.js.map → extract-partition-NF7PXGPP.js.map} +0 -0
  591. /package/dist/{fanout-sidecar-WUFXNYP4.js.map → fanout-sidecar-OT6RYLOL.js.map} +0 -0
  592. /package/dist/{issue-SIDORTSZ.js.map → find-LZMP26KF.js.map} +0 -0
  593. /package/dist/{ledger-F33ZVMTK.js.map → issue-IHARXWW5.js.map} +0 -0
  594. /package/dist/{liberate-LCDPNAG2.js.map → ledger-KZPCMVZY.js.map} +0 -0
  595. /package/dist/{link-set-FKNWAYKS.js.map → liberate-GRLCZMW4.js.map} +0 -0
  596. /package/dist/{managed-secret-PQYKSR6T.js.map → link-set-JCMJ7ULP.js.map} +0 -0
  597. /package/dist/{noydb-DUXZPKSN.js.map → managed-secret-S3MQ6SH6.js.map} +0 -0
  598. /package/dist/{migrate-cek-5ENH64AA.js.map → migrate-cek-V7GKJZ7O.js.map} +0 -0
  599. /package/dist/{register-I2DZXGAR.js.map → noydb-SWQJ3MZS.js.map} +0 -0
  600. /package/dist/{pod-handle-Q736KYON.js.map → pod-handle-WGDFB4C2.js.map} +0 -0
  601. /package/dist/{post-register-LNE2FE2A.js.map → post-register-SLSXIPBV.js.map} +0 -0
  602. /package/dist/{registry-23WF3TGH.js.map → query/all/index.js.map} +0 -0
  603. /package/dist/{registry-4AYVUNXK.js.map → register-F3OYE7MJ.js.map} +0 -0
  604. /package/dist/{registry-VSSQPIGF.js.map → registry-CILQFXFK.js.map} +0 -0
  605. /package/dist/{registry-YLEWMGAC.js.map → registry-XNNYQVKV.js.map} +0 -0
  606. /package/dist/{request-withdrawal-KFQHEZ25.js.map → registry-YCDZV3VW.js.map} +0 -0
  607. /package/dist/{revoke-DQDZAZZM.js.map → registry-ZGYS33TE.js.map} +0 -0
  608. /package/dist/{signer-WAMDZHEN.js.map → request-withdrawal-Z5NC6TXT.js.map} +0 -0
  609. /package/dist/{reveal-67RDQRIN.js.map → reveal-4BCKPEC2.js.map} +0 -0
  610. /package/dist/{stale-DDL7WQEZ.js.map → revoke-ZL62WC2D.js.map} +0 -0
  611. /package/dist/{seed-G42JYN56.js.map → seed-4JS2RJ4A.js.map} +0 -0
  612. /package/dist/{storage-FLR73HHF.js.map → signer-MBZZMXTC.js.map} +0 -0
  613. /package/dist/{walk-3UQBRMDV.js.map → stale-TJ3DYZMQ.js.map} +0 -0
  614. /package/dist/{withdraw-accessible-EL5GXZBS.js.map → storage-SVMKRGCW.js.map} +0 -0
  615. /package/dist/{store-coordination-provider-MEQ2MJQG.js.map → store-coordination-provider-2O2VUHKW.js.map} +0 -0
  616. /package/dist/{verify-KOV2G5D6.js.map → verify-RVT67IMH.js.map} +0 -0
@@ -1,27 +1,27 @@
1
- import {
2
- isManifestReservedCollection
3
- } from "./chunk-EPFF7LOX.js";
4
1
  import {
5
2
  LinkIntegrityError,
6
3
  declareLink,
7
4
  isLinkCollectionName,
8
5
  linkCollectionName,
9
6
  linkRowKey
10
- } from "./chunk-QIZPZMUI.js";
7
+ } from "./chunk-AOWGXU6D.js";
11
8
  import {
12
9
  hashFields,
13
10
  validateSatelliteDeclaration
14
- } from "./chunk-TUFM4UZP.js";
11
+ } from "./chunk-6K7DPM7D.js";
15
12
  import {
16
13
  resolveStaleOnRead
17
- } from "./chunk-SMH6SRX7.js";
14
+ } from "./chunk-TROR3ALR.js";
15
+ import {
16
+ isManifestReservedCollection
17
+ } from "./chunk-EPFF7LOX.js";
18
18
  import {
19
19
  loadFence
20
- } from "./chunk-453F654R.js";
20
+ } from "./chunk-L7DOS3TE.js";
21
21
  import {
22
22
  buildPersistedIndexCallbacks,
23
23
  syncTierSearch
24
- } from "./chunk-SPXXX5E4.js";
24
+ } from "./chunk-6LNL42F5.js";
25
25
  import {
26
26
  isBaseLive,
27
27
  liveBaseIdSet
@@ -29,80 +29,99 @@ import {
29
29
  import {
30
30
  SchemaUpdateGate
31
31
  } from "./chunk-6LJY7X5A.js";
32
- import {
33
- NO_ATTESTATION
34
- } from "./chunk-Q7HZX3IF.js";
35
32
  import {
36
33
  NO_TIERS,
37
34
  classifySealedShred,
38
35
  syncDerivedOutputs
39
- } from "./chunk-KJIMGIWO.js";
36
+ } from "./chunk-UPD5NWI5.js";
40
37
  import {
41
38
  NO_PORTABILITY
42
- } from "./chunk-BZ3534YM.js";
39
+ } from "./chunk-ZUVBC32X.js";
43
40
  import {
44
41
  NO_CARGO
45
- } from "./chunk-NQKIUNW5.js";
42
+ } from "./chunk-A6IJU4TK.js";
43
+ import {
44
+ fallbackDerivationName
45
+ } from "./chunk-RXLYKVTF.js";
46
46
  import {
47
47
  saveSealedSecret
48
- } from "./chunk-4GVM6QZA.js";
48
+ } from "./chunk-ENAG3IY7.js";
49
49
  import {
50
50
  runDrainBarrier
51
- } from "./chunk-VTFVLCUH.js";
51
+ } from "./chunk-3JWHAR6E.js";
52
52
  import {
53
- fallbackDerivationName
54
- } from "./chunk-RXLYKVTF.js";
53
+ findRollupSpecForIntent,
54
+ forgetDerivedFanout,
55
+ ledgerAuditHook,
56
+ putDerivedOutput,
57
+ resolveRollupDeleteIntents,
58
+ runGraphDispatchWave,
59
+ selfWriteFieldEqual,
60
+ touchFor
61
+ } from "./chunk-K6W7BVZ6.js";
62
+ import {
63
+ OverlayedCollection
64
+ } from "./chunk-MLPHLJIQ.js";
65
+ import {
66
+ INDEXED_STORE_POLICY,
67
+ NO_SYNC
68
+ } from "./chunk-T7IR4N2S.js";
69
+ import {
70
+ NO_ATTESTATION
71
+ } from "./chunk-X4773RBR.js";
72
+ import {
73
+ NO_SHADOW
74
+ } from "./chunk-SMY5X46Z.js";
75
+ import {
76
+ NO_SNAPSHOTS
77
+ } from "./chunk-DZFQVICS.js";
78
+ import {
79
+ TxContext,
80
+ bestEffortRevert,
81
+ trackKeyedWrite
82
+ } from "./chunk-5FDLC6G7.js";
83
+ import {
84
+ lazy
85
+ } from "./chunk-5D2ALSM5.js";
86
+ import {
87
+ INDEX_SNAPSHOT_VERSION,
88
+ InvertedIndex,
89
+ MemoryIndexStore,
90
+ NO_SEARCH
91
+ } from "./chunk-I3JDRCMW.js";
55
92
  import {
56
93
  NO_SEQUENCE,
57
94
  SEQUENCE_COLLECTION,
58
95
  compileSequenceFormat,
59
96
  resolveSequenceKey
60
- } from "./chunk-ZVO4QVPD.js";
97
+ } from "./chunk-M522UYZ2.js";
61
98
  import {
62
99
  CustodyApi,
63
100
  NO_CUSTODY
64
- } from "./chunk-GPEQUXHL.js";
101
+ } from "./chunk-B6SJIBQK.js";
65
102
  import {
66
103
  DEFAULT_POSTURE,
67
- EXPORT_REDACTION_MARKER,
68
104
  ViaGraph,
69
- ViaPipeline,
70
105
  buildDescription,
71
106
  collectKnownFieldNames,
72
107
  computedEntryParts,
73
108
  deriveZodFields,
74
- exportRedact,
75
109
  guardReconcileCollisions,
76
110
  mergeViaFields,
77
111
  resolveCollectionConfig,
78
112
  resolveComputedEdges,
79
113
  resolveDescribeFieldIds,
80
114
  resolveVirtualMoneyFields
81
- } from "./chunk-2C3AQB46.js";
115
+ } from "./chunk-UD5EVGZ7.js";
82
116
  import {
83
117
  findMatchingIdsByPairs
84
118
  } from "./chunk-TFMM5DBB.js";
85
119
  import {
86
120
  encodeVecId
87
- } from "./chunk-RTBJ5IOO.js";
88
- import {
89
- NO_CLASSIFIED,
90
- guardClassifiedCompat,
91
- resolveClassifiedFields
92
- } from "./chunk-5VCRVKOZ.js";
121
+ } from "./chunk-MDWKM2XC.js";
93
122
  import {
94
123
  derivePersistedSchema
95
- } from "./chunk-REDOOY2Q.js";
96
- import {
97
- findRollupSpecForIntent,
98
- forgetDerivedFanout,
99
- ledgerAuditHook,
100
- putDerivedOutput,
101
- resolveRollupDeleteIntents,
102
- runGraphDispatchWave,
103
- selfWriteFieldEqual,
104
- touchFor
105
- } from "./chunk-CARABLSQ.js";
124
+ } from "./chunk-PSIV7CJV.js";
106
125
  import {
107
126
  buildLookupAltIndex,
108
127
  buildLookupSnapshotRows,
@@ -117,25 +136,47 @@ import {
117
136
  resolveDictSource,
118
137
  resolveLabelFromMap,
119
138
  updateReferencingRecords
120
- } from "./chunk-U4FOQDY4.js";
139
+ } from "./chunk-FH2L2E34.js";
121
140
  import {
122
- OverlayedCollection
123
- } from "./chunk-SKGMN35F.js";
141
+ NO_CLASSIFIED,
142
+ guardClassifiedCompat,
143
+ resolveClassifiedFields
144
+ } from "./chunk-QOOUUR4A.js";
124
145
  import {
125
- INDEXED_STORE_POLICY,
126
- NO_SYNC
127
- } from "./chunk-T7IR4N2S.js";
146
+ LazyQuery,
147
+ NO_INDEXING,
148
+ compositeKey,
149
+ decodeIdxId,
150
+ encodeIdxId
151
+ } from "./chunk-HBRLNOHL.js";
152
+ import {
153
+ IMPLICIT_LAZY
154
+ } from "./chunk-66TQOPFM.js";
155
+ import {
156
+ estimateRecordBytes
157
+ } from "./chunk-V4PXLYWM.js";
158
+ import {
159
+ canonicalGroupKey
160
+ } from "./chunk-XZHEOSQ2.js";
161
+ import {
162
+ NO_CRDT
163
+ } from "./chunk-PVEWA2DU.js";
128
164
  import {
129
165
  NO_CONSENT
130
166
  } from "./chunk-PEOZ34EM.js";
167
+ import {
168
+ NO_COVERAGE
169
+ } from "./chunk-RHVMZSUU.js";
131
170
  import {
132
171
  NO_PERIODS,
133
172
  isEffectivelyReopened,
173
+ isOrderableBusinessDate,
174
+ malformedBusinessDate,
134
175
  purgeMarkersOn,
135
176
  resolvePeriodKey,
136
177
  resolveReopenState,
137
178
  samePartition
138
- } from "./chunk-PT43Y56J.js";
179
+ } from "./chunk-NRT6QZQB.js";
139
180
  import {
140
181
  PERIODS_COLLECTION,
141
182
  PERIOD_ARCHIVES_COLLECTION,
@@ -143,78 +184,50 @@ import {
143
184
  PERIOD_REOPENS_COLLECTION,
144
185
  PERIOD_TARGET_PURGES_COLLECTION,
145
186
  periodExclusiveUpperBound
146
- } from "./chunk-FAHMLERK.js";
187
+ } from "./chunk-FW22ZCXT.js";
147
188
  import {
148
- NO_SHADOW
149
- } from "./chunk-SMY5X46Z.js";
189
+ NO_SEALED_RECORD
190
+ } from "./chunk-PDCG6PR5.js";
150
191
  import {
151
- NO_SNAPSHOTS
152
- } from "./chunk-DZFQVICS.js";
192
+ normalizeIndexDefs,
193
+ parseFieldIndexSnapshot
194
+ } from "./chunk-YSK2CU2Q.js";
153
195
  import {
154
- TxContext,
155
- bestEffortRevert
156
- } from "./chunk-BLN54W3L.js";
196
+ EXPORT_REDACTION_MARKER,
197
+ ViaPipeline,
198
+ exportRedact
199
+ } from "./chunk-ORDURZBU.js";
157
200
  import {
158
- lazy
159
- } from "./chunk-5D2ALSM5.js";
201
+ ScanBuilder
202
+ } from "./chunk-F24ZZTHQ.js";
160
203
  import {
161
- InvertedIndex,
162
- MemoryIndexStore,
163
- NO_SEARCH
164
- } from "./chunk-UXWB3FPF.js";
204
+ Query
205
+ } from "./chunk-7JE7BDYJ.js";
165
206
  import {
166
- NO_SEALED_RECORD
167
- } from "./chunk-6YXCPL4T.js";
207
+ NO_REDUCE
208
+ } from "./chunk-3TDUWVWB.js";
168
209
  import {
169
- Query,
170
- ScanBuilder
171
- } from "./chunk-7MG2LHO5.js";
210
+ readPath
211
+ } from "./chunk-HLEK5VAN.js";
172
212
  import {
173
213
  EXPORT_AUDIT_COLLECTION,
174
214
  NO_BLOBS,
175
215
  createExportBlobsHandle,
176
216
  runCompaction
177
- } from "./chunk-AO42KJO6.js";
178
- import {
179
- LazyQuery,
180
- NO_INDEXING,
181
- decodeIdxId,
182
- encodeIdxId
183
- } from "./chunk-KTFRCC5C.js";
184
- import {
185
- normalizeIndexDefs
186
- } from "./chunk-I3ISCYT7.js";
187
- import {
188
- IMPLICIT_LAZY
189
- } from "./chunk-66TQOPFM.js";
190
- import {
191
- estimateRecordBytes
192
- } from "./chunk-V4PXLYWM.js";
193
- import {
194
- canonicalGroupKey
195
- } from "./chunk-XZHEOSQ2.js";
196
- import {
197
- NO_REDUCE
198
- } from "./chunk-YMUFFJCO.js";
199
- import {
200
- readPath
201
- } from "./chunk-NSITFOCJ.js";
202
- import {
203
- NO_CRDT
204
- } from "./chunk-PVEWA2DU.js";
217
+ } from "./chunk-GF5BZ7D4.js";
205
218
  import {
206
219
  dictCollectionName
207
- } from "./chunk-6I2RQCET.js";
220
+ } from "./chunk-DF73H4UN.js";
208
221
  import {
209
222
  NO_I18N,
210
223
  getAtPath,
211
224
  isDictCollectionName,
212
225
  isStaticDictDescriptor
213
- } from "./chunk-TRGTKX5E.js";
226
+ } from "./chunk-GHLTDZRS.js";
214
227
  import {
215
228
  isViaInstalled,
216
229
  viaBinder
217
- } from "./chunk-UXVWEX5L.js";
230
+ } from "./chunk-Z5HTYMMQ.js";
218
231
  import {
219
232
  NO_TEAM,
220
233
  describeAllUsersAuth,
@@ -237,7 +250,7 @@ import {
237
250
  saveShamirRecoveryEntries,
238
251
  updateAuthenticator,
239
252
  writeMagicLinkGrant
240
- } from "./chunk-RRNRNANG.js";
253
+ } from "./chunk-ZE4CHIED.js";
241
254
  import {
242
255
  assertKeyringOpenAllowed,
243
256
  buildRecipientKeyringFile,
@@ -252,15 +265,15 @@ import {
252
265
  listUsers,
253
266
  loadKeyring,
254
267
  updateKeyringIdentity
255
- } from "./chunk-G56KBWFY.js";
268
+ } from "./chunk-M7NI3IWE.js";
256
269
  import {
257
270
  persistDirectoryConfig,
258
271
  readDirectoryConfig
259
- } from "./chunk-KG7TZKZG.js";
272
+ } from "./chunk-7VCXZDA4.js";
260
273
  import {
261
274
  NO_BROKER,
262
275
  buildCredentialBrokerHandle
263
- } from "./chunk-JBDFMYKQ.js";
276
+ } from "./chunk-4AF3TUMP.js";
264
277
  import {
265
278
  NO_SESSION
266
279
  } from "./chunk-VKQCVU2Z.js";
@@ -269,16 +282,16 @@ import {
269
282
  } from "./chunk-4AOERLTV.js";
270
283
  import {
271
284
  NO_HISTORY
272
- } from "./chunk-X2DLENDQ.js";
285
+ } from "./chunk-QWGU66MP.js";
273
286
  import {
274
287
  sha256Hex
275
- } from "./chunk-BOET4NA4.js";
288
+ } from "./chunk-CKNGS5MH.js";
276
289
  import {
277
290
  assertCutoverTierSafe,
278
291
  assertTierWritable,
279
292
  dekKey,
280
293
  liveRecordIsElevated
281
- } from "./chunk-JMGDHKQF.js";
294
+ } from "./chunk-JCN44NCY.js";
282
295
  import {
283
296
  NO_VAULT_HEAD
284
297
  } from "./chunk-HK67PX4J.js";
@@ -290,7 +303,7 @@ import {
290
303
  readDottedPath,
291
304
  rebuildSubjectIndex,
292
305
  removeSubjectRef
293
- } from "./chunk-7V4TP3AF.js";
306
+ } from "./chunk-J6UOHJY5.js";
294
307
  import {
295
308
  RecordCodec,
296
309
  SEALED_CEK_NS,
@@ -306,20 +319,20 @@ import {
306
319
  rewrapBodyToDek,
307
320
  validateSchemaInput,
308
321
  verifyRecordIdentity
309
- } from "./chunk-77K4PG6P.js";
322
+ } from "./chunk-KJFW62P4.js";
310
323
  import {
311
324
  buildDeleteMarker,
312
325
  buildRecordEnvelope,
313
326
  buildTombstone,
314
327
  isDeleteMarker,
315
328
  isTombstone
316
- } from "./chunk-SZJ3DLZA.js";
329
+ } from "./chunk-SEE332EV.js";
317
330
  import {
318
331
  encrypt
319
- } from "./chunk-SL3JAAKN.js";
332
+ } from "./chunk-UYB234ZR.js";
320
333
  import {
321
334
  SealedHandle
322
- } from "./chunk-7MG7SJT7.js";
335
+ } from "./chunk-ODVPTDPK.js";
323
336
  import {
324
337
  AlreadyElevatedError,
325
338
  AttestationError,
@@ -357,10 +370,9 @@ import {
357
370
  TierNotGrantedError,
358
371
  USER_ENVELOPE_COLLECTION,
359
372
  UniqueConstraintError,
360
- UnsupportedIndexOptionError,
361
373
  ValidationError,
362
374
  isConflictError
363
- } from "./chunk-7O3Y4PPD.js";
375
+ } from "./chunk-244VXYPG.js";
364
376
 
365
377
  // src/kernel/merge-authority.ts
366
378
  function buildMergeAuthority(keyring) {
@@ -442,6 +454,7 @@ var STRATEGY_DEFAULTS = {
442
454
  cargo: NO_CARGO,
443
455
  classified: NO_CLASSIFIED,
444
456
  consent: NO_CONSENT,
457
+ coverage: NO_COVERAGE,
445
458
  crdt: NO_CRDT,
446
459
  custody: NO_CUSTODY,
447
460
  forget: NO_FORGET,
@@ -540,7 +553,7 @@ function validateSecretModeOptions(options) {
540
553
  }
541
554
  async function resolveEffectiveSecret(options, store, vault) {
542
555
  if (options.secretMode === "managed") {
543
- const { resolveManagedSecret } = await import("./managed-secret-PQYKSR6T.js");
556
+ const { resolveManagedSecret } = await import("./managed-secret-S3MQ6SH6.js");
544
557
  return resolveManagedSecret(store, vault, options.sealingKey);
545
558
  }
546
559
  return options.secret;
@@ -558,7 +571,7 @@ function ownerKeyringOptions(options, secret) {
558
571
 
559
572
  // src/port/by/default-provider.ts
560
573
  async function createDefaultMesh(store) {
561
- const { StoreMesh } = await import("./store-coordination-provider-MEQ2MJQG.js");
574
+ const { StoreMesh } = await import("./store-coordination-provider-2O2VUHKW.js");
562
575
  return new StoreMesh(store);
563
576
  }
564
577
 
@@ -613,6 +626,60 @@ function populateCollectionRegistries(r, collectionName, options, effectiveViaFi
613
626
  }
614
627
  }
615
628
 
629
+ // src/kernel/generation-map.ts
630
+ var tick = 0;
631
+ var GenerationMap = class extends Map {
632
+ /**
633
+ * ⚠️ NOT a `#private` field, and not readonly-initialised, deliberately.
634
+ * `Map`'s constructor calls `this.set()` for each entry of an iterable
635
+ * argument — which runs BEFORE this class's fields are installed. A
636
+ * `#private` field throws `TypeError` on touch at that point; a declared
637
+ * property is merely `undefined`, and assigning to it is safe. The
638
+ * initializer below then runs and resets it to 0, which is the correct
639
+ * resting state for a freshly built map.
640
+ */
641
+ gen = 0;
642
+ /** Mutation stamp. Equal across two reads means nothing changed between them. */
643
+ get generation() {
644
+ return this.gen;
645
+ }
646
+ set(key, value) {
647
+ this.gen = ++tick;
648
+ return super.set(key, value);
649
+ }
650
+ delete(key) {
651
+ this.gen = ++tick;
652
+ return super.delete(key);
653
+ }
654
+ clear() {
655
+ this.gen = ++tick;
656
+ super.clear();
657
+ }
658
+ };
659
+
660
+ // src/kernel/present-cache.ts
661
+ var memo = /* @__PURE__ */ new WeakMap();
662
+ function presentVariantKey(locale, layer, fallback) {
663
+ const chain = fallback === void 0 ? "" : Array.isArray(fallback) ? fallback.join(",") : String(fallback);
664
+ return `${locale ?? ""} ${layer} ${chain}`;
665
+ }
666
+ function memoizePresent(record, variant, compute) {
667
+ let variants = memo.get(record);
668
+ if (!variants) {
669
+ variants = /* @__PURE__ */ new Map();
670
+ memo.set(record, variants);
671
+ }
672
+ const hit = variants.get(variant);
673
+ if (hit !== void 0) return hit;
674
+ const scope = variants;
675
+ const pending = compute().catch((err) => {
676
+ scope.delete(variant);
677
+ throw err;
678
+ });
679
+ scope.set(variant, pending);
680
+ return pending;
681
+ }
682
+
616
683
  // src/kernel/lazy-count.ts
617
684
  var COUNT_PAGE_SIZE = 1e3;
618
685
  function isLive(env, storeCiphertext) {
@@ -675,6 +742,121 @@ async function applyCutoverTransform(ctx) {
675
742
  return count;
676
743
  }
677
744
 
745
+ // src/with-lookup/indexing/persisted-field-indexes.ts
746
+ function fieldIndexFingerprint(cache) {
747
+ let sum = 0;
748
+ let xor = 0;
749
+ let maxVersion = 0;
750
+ for (const [id, entry] of cache) {
751
+ const h = fnv1a(`${id} ${entry.version}`);
752
+ sum = sum + h >>> 0;
753
+ xor = (xor ^ h) >>> 0;
754
+ if (entry.version > maxVersion) maxVersion = entry.version;
755
+ }
756
+ return { count: cache.size, maxVersion, digest: `${sum.toString(36)}.${xor.toString(36)}` };
757
+ }
758
+ function fnv1a(s) {
759
+ let h = 2166136261;
760
+ for (let i = 0; i < s.length; i++) {
761
+ h ^= s.charCodeAt(i);
762
+ h = Math.imul(h, 16777619) >>> 0;
763
+ }
764
+ return h >>> 0;
765
+ }
766
+ function fpEqual(a, b) {
767
+ return a.count === b.count && a.maxVersion === b.maxVersion && a.digest === b.digest;
768
+ }
769
+ var PersistedFieldIndexes = class {
770
+ constructor(cb) {
771
+ this.cb = cb;
772
+ this.debounceMs = cb.debounceMs ?? 1e3;
773
+ }
774
+ cb;
775
+ timer = null;
776
+ debounceMs;
777
+ /** True when at least one index on this collection asked to be persisted. */
778
+ get enabled() {
779
+ return this.cb.keys().length > 0;
780
+ }
781
+ /**
782
+ * Restore whatever is fresh. Returns the sidecar keys that were adopted —
783
+ * the caller rebuilds every other declared index from the cache. Never
784
+ * throws for a bad blob: an unreadable sidecar is indistinguishable from an
785
+ * absent one, and both mean "rebuild".
786
+ */
787
+ async restore(isLive2) {
788
+ const keys = this.cb.keys();
789
+ if (keys.length === 0) return EMPTY;
790
+ const live = this.cb.currentFingerprint();
791
+ const restored = /* @__PURE__ */ new Set();
792
+ for (const key of keys) {
793
+ let loaded = null;
794
+ try {
795
+ loaded = await this.cb.load(key);
796
+ } catch {
797
+ continue;
798
+ }
799
+ if (loaded === null || !fpEqual(loaded.fingerprint, live)) continue;
800
+ const snap = parseFieldIndexSnapshot(loaded.json);
801
+ if (snap === null) continue;
802
+ if (this.cb.restore(key, snap, isLive2)) restored.add(key);
803
+ }
804
+ return restored;
805
+ }
806
+ /** Schedule a debounced write of every opted-in sidecar. */
807
+ markDirty() {
808
+ if (this.cb.keys().length === 0) return;
809
+ if (this.timer) clearTimeout(this.timer);
810
+ this.timer = setTimeout(() => {
811
+ this.timer = null;
812
+ void this.persist().catch(() => {
813
+ });
814
+ }, this.debounceMs);
815
+ }
816
+ /** Force an immediate write (cancels any pending debounce). */
817
+ async flush() {
818
+ if (this.timer) {
819
+ clearTimeout(this.timer);
820
+ this.timer = null;
821
+ }
822
+ await this.persist();
823
+ }
824
+ /** Delete every sidecar — erasure, and any point the blobs must not survive. */
825
+ async removeAll() {
826
+ if (this.timer) {
827
+ clearTimeout(this.timer);
828
+ this.timer = null;
829
+ }
830
+ let purged = 0;
831
+ const residue = [];
832
+ for (const key of this.cb.keys()) {
833
+ try {
834
+ await this.cb.remove(key);
835
+ purged++;
836
+ } catch {
837
+ residue.push(key);
838
+ }
839
+ }
840
+ return { purged, residue };
841
+ }
842
+ /** Drop a pending debounce without writing (collection teardown). */
843
+ dispose() {
844
+ if (this.timer) {
845
+ clearTimeout(this.timer);
846
+ this.timer = null;
847
+ }
848
+ }
849
+ async persist() {
850
+ const fp = this.cb.currentFingerprint();
851
+ for (const key of this.cb.keys()) {
852
+ const snap = this.cb.snapshot(key);
853
+ if (!snap) continue;
854
+ await this.cb.save(key, JSON.stringify(snap), fp);
855
+ }
856
+ }
857
+ };
858
+ var EMPTY = /* @__PURE__ */ new Set();
859
+
678
860
  // src/with-lookup/indexing/collection-facade.ts
679
861
  function readPersistedValue(record, field) {
680
862
  if (!field.includes(".")) return record[field];
@@ -713,14 +895,98 @@ function valuesMatch(stored, live) {
713
895
  return false;
714
896
  }
715
897
  }
716
- function rebuildEagerIndexesFromCache(ctx) {
898
+ function rebuildEagerIndexesFromCache(ctx, skip) {
717
899
  const eager = ctx.indexes;
718
900
  if (!eager || eager.fields().length === 0) return;
719
901
  const snapshot = [];
720
902
  for (const [id, entry] of ctx.cache) {
721
903
  snapshot.push({ id, record: entry.record });
722
904
  }
723
- eager.build(snapshot);
905
+ eager.build(snapshot, skip);
906
+ }
907
+ var FIELD_IDX = "_fieldidx";
908
+ function buildFieldIndexCallbacks(provideCtx, debounceMs) {
909
+ const sidecarId = (name, key) => `${name}/${key}`;
910
+ return {
911
+ keys: () => provideCtx().indexes?.persistableKeys() ?? [],
912
+ snapshot: (key) => provideCtx().indexes?.snapshotIndex(key),
913
+ restore: (key, snap, isLive2) => provideCtx().indexes?.restoreIndex(key, snap, isLive2) ?? false,
914
+ load: async (key) => {
915
+ const ctx = provideCtx();
916
+ const id = sidecarId(ctx.name, key);
917
+ const env = await ctx.adapter.get(ctx.vault, FIELD_IDX, id);
918
+ if (!env) return null;
919
+ const body = await ctx.codec.decryptJsonString({ collection: FIELD_IDX, id }, env);
920
+ if (body === null) return null;
921
+ try {
922
+ const wrapped = JSON.parse(body);
923
+ if (typeof wrapped?.idx !== "string" || typeof wrapped?.fp?.digest !== "string") return null;
924
+ return { json: wrapped.idx, fingerprint: wrapped.fp };
925
+ } catch {
926
+ return null;
927
+ }
928
+ },
929
+ save: async (key, json, fp) => {
930
+ const ctx = provideCtx();
931
+ const id = sidecarId(ctx.name, key);
932
+ const body = JSON.stringify({ fp, idx: json });
933
+ const env = await ctx.codec.encryptJsonString({ collection: FIELD_IDX, id }, body, fp.count);
934
+ await ctx.adapter.put(ctx.vault, FIELD_IDX, id, env);
935
+ },
936
+ remove: async (key) => {
937
+ const ctx = provideCtx();
938
+ await ctx.adapter.delete(ctx.vault, FIELD_IDX, sidecarId(ctx.name, key));
939
+ },
940
+ currentFingerprint: () => fieldIndexFingerprint(provideCtx().cache),
941
+ ...debounceMs !== void 0 ? { debounceMs } : {}
942
+ };
943
+ }
944
+ function createPersistedFieldIndexes(provideCtx, indexes) {
945
+ if ((indexes?.persistableKeys().length ?? 0) === 0) return null;
946
+ return new PersistedFieldIndexes(buildFieldIndexCallbacks(provideCtx));
947
+ }
948
+ async function hydrateEagerIndexes(ctx) {
949
+ const store = ctx.fieldIndexes;
950
+ if (!store || !store.enabled || !ctx.indexes) {
951
+ rebuildEagerIndexesFromCache(ctx);
952
+ return;
953
+ }
954
+ const restored = await store.restore((id) => ctx.cache.has(id));
955
+ rebuildEagerIndexesFromCache(ctx, restored);
956
+ if (restored.size < ctx.indexes.persistableKeys().length) store.markDirty();
957
+ }
958
+ async function checkUniqueOnPut(ctx, id, record) {
959
+ const set = ctx.uniqueConstraints;
960
+ if (!set || set.enforcement === "detect") return;
961
+ if (!ctx.lazy) {
962
+ set.check(id, record);
963
+ return;
964
+ }
965
+ const persisted = ctx.persistedIndexes;
966
+ if (!persisted) {
967
+ throw new Error(
968
+ `Collection "${ctx.name}": a unique index in lazy mode (prefetch: false) needs the indexing service. Pass \`withIndexing()\` from "@noy-db/hub/indexing" to \`createNoydb({ indexingStrategy })\`.`
969
+ );
970
+ }
971
+ await ctx.ensurePersistedIndexesLoaded();
972
+ const rec = record;
973
+ for (const fields of set.fieldTuples()) {
974
+ const values = [];
975
+ for (const f of fields) {
976
+ const v = readPersistedValue(rec, f);
977
+ if (v === null || v === void 0) {
978
+ values.length = 0;
979
+ break;
980
+ }
981
+ values.push(v);
982
+ }
983
+ if (values.length === 0) continue;
984
+ const holders = persisted.probeEqual(compositeKey(fields), fields.length === 1 ? values[0] : values);
985
+ if (!holders) continue;
986
+ for (const holder of holders) {
987
+ if (holder !== id) throw new UniqueConstraintError(ctx.name, id, fields, holder);
988
+ }
989
+ }
724
990
  }
725
991
  function rebuildUniqueConstraintsFromCache(ctx) {
726
992
  if (!ctx.uniqueConstraints) return;
@@ -916,10 +1182,11 @@ async function maintainPersistedIndexesOnDelete(ctx, id, previousRecord) {
916
1182
  }
917
1183
  }
918
1184
  async function purgePersistedIndexes(ctx, id) {
1185
+ const field = ctx.fieldIndexes ? await ctx.fieldIndexes.removeAll() : { purged: 0, residue: [] };
919
1186
  const persisted = ctx.persistedIndexes;
920
- if (!persisted) return { purged: 0, residue: [] };
921
- let purged = 0;
922
- const residue = [];
1187
+ if (!persisted) return field;
1188
+ let purged = field.purged;
1189
+ const residue = [...field.residue];
923
1190
  for (const def of persisted.definitions()) {
924
1191
  try {
925
1192
  await ctx.adapter.delete(ctx.vault, ctx.name, encodeIdxId(def.key, id));
@@ -947,19 +1214,108 @@ async function resolveTierSyncPrior(ctx, id, priorEnvelope) {
947
1214
  if (!ctx.lazy || !priorEnvelope || (priorEnvelope._tier ?? 0) > 0) return null;
948
1215
  return await ctx.codec.decryptRecord({ collection: ctx.name, id }, priorEnvelope, { skipValidation: true });
949
1216
  }
1217
+ function resolveDeclaredIndexes(defs, collectionName, indexingEnabled) {
1218
+ const declared = normalizeIndexDefs(defs);
1219
+ if (indexingEnabled || declared.length === 0) return declared;
1220
+ const fields = [...new Set(declared.flatMap((d) => [...d.fields]))];
1221
+ console.warn(
1222
+ `[noy-db] collection "${collectionName}" declares indexes ${JSON.stringify(fields)} but no indexingStrategy was passed to createNoydb() \u2014 every query on it will scan. Pass \`indexingStrategy: withIndexing()\` from "@noy-db/hub/indexing", or drop the \`indexes:\` declaration if a scan is intended.`
1223
+ );
1224
+ return declared;
1225
+ }
950
1226
 
951
1227
  // src/with-lookup/search/serialize.ts
952
1228
  function serializeIndex(idx) {
953
1229
  return JSON.stringify(idx.toSnapshot());
954
1230
  }
955
1231
  function deserializeIndex(json) {
956
- return InvertedIndex.fromSnapshot(JSON.parse(json));
1232
+ const snap = parseIndexSnapshot(json);
1233
+ return snap === null ? null : InvertedIndex.fromSnapshot(snap);
1234
+ }
1235
+ function parseIndexSnapshot(json) {
1236
+ let raw;
1237
+ try {
1238
+ raw = JSON.parse(json);
1239
+ } catch {
1240
+ return null;
1241
+ }
1242
+ if (typeof raw !== "object" || raw === null) return null;
1243
+ const o = raw;
1244
+ if (o["v"] !== INDEX_SNAPSHOT_VERSION) return null;
1245
+ if (!isStringArray(o["posFields"])) return null;
1246
+ if (!Array.isArray(o["fieldStats"]) || !Array.isArray(o["docs"])) return null;
1247
+ const posFields = new Set(o["posFields"]);
1248
+ const fieldStats = [];
1249
+ for (const e of o["fieldStats"]) {
1250
+ if (!Array.isArray(e) || e.length !== 2 || typeof e[0] !== "string") return null;
1251
+ const s = e[1];
1252
+ if (typeof s !== "object" || s === null) return null;
1253
+ if (!isCountPairs(s["df"]) || !isNonNegInt(s["n"]) || !isNonNegInt(s["totalLen"])) return null;
1254
+ fieldStats.push([e[0], { df: s["df"], n: s["n"], totalLen: s["totalLen"] }]);
1255
+ }
1256
+ const docs = [];
1257
+ for (const e of o["docs"]) {
1258
+ if (typeof e !== "object" || e === null) return null;
1259
+ const d = e;
1260
+ if (typeof d["id"] !== "string" || typeof d["field"] !== "string" || typeof d["text"] !== "string") return null;
1261
+ if (!isNonNegInt(d["len"])) return null;
1262
+ if (d["locale"] !== void 0 && typeof d["locale"] !== "string") return null;
1263
+ if (!isCountPairs(d["tf"]) || !isCountPairs(d["firstOffset"])) return null;
1264
+ const wantsPos = posFields.has(d["field"]);
1265
+ if (wantsPos !== (d["pos"] !== void 0)) return null;
1266
+ let pos;
1267
+ if (d["pos"] !== void 0) {
1268
+ if (!isPositionPairs(d["pos"], d["len"])) return null;
1269
+ pos = d["pos"];
1270
+ }
1271
+ docs.push({
1272
+ id: d["id"],
1273
+ field: d["field"],
1274
+ text: d["text"],
1275
+ len: d["len"],
1276
+ tf: d["tf"],
1277
+ firstOffset: d["firstOffset"],
1278
+ ...d["locale"] !== void 0 ? { locale: d["locale"] } : {},
1279
+ ...pos !== void 0 ? { pos } : {}
1280
+ });
1281
+ }
1282
+ return { v: INDEX_SNAPSHOT_VERSION, posFields: o["posFields"], fieldStats, docs };
1283
+ }
1284
+ function isNonNegInt(x) {
1285
+ return typeof x === "number" && Number.isInteger(x) && x >= 0;
1286
+ }
1287
+ function isStringArray(x) {
1288
+ return Array.isArray(x) && x.every((s) => typeof s === "string");
1289
+ }
1290
+ function isCountPairs(x) {
1291
+ return Array.isArray(x) && x.every((p) => Array.isArray(p) && p.length === 2 && typeof p[0] === "string" && isNonNegInt(p[1]));
1292
+ }
1293
+ function isPositionPairs(x, len) {
1294
+ if (!Array.isArray(x)) return false;
1295
+ for (const p of x) {
1296
+ if (!Array.isArray(p) || p.length !== 2 || typeof p[0] !== "string") return false;
1297
+ const list = p[1];
1298
+ if (!Array.isArray(list) || list.length === 0) return false;
1299
+ let prev = -1;
1300
+ for (const n of list) {
1301
+ if (!isNonNegInt(n) || n <= prev || n >= len) return false;
1302
+ prev = n;
1303
+ }
1304
+ }
1305
+ return true;
957
1306
  }
958
1307
 
959
1308
  // src/with-lookup/search/persisted-index-store.ts
960
- function fpEqual(a, b) {
1309
+ function fpEqual2(a, b) {
961
1310
  return a.count === b.count && a.maxVersion === b.maxVersion;
962
1311
  }
1312
+ function positionsMatch(idx, opts) {
1313
+ const want = new Set(opts?.positions ?? []);
1314
+ const have = idx.positionFields;
1315
+ if (want.size !== have.size) return false;
1316
+ for (const f of want) if (!have.has(f)) return false;
1317
+ return true;
1318
+ }
963
1319
  var PersistedIndexStore = class {
964
1320
  constructor(cb) {
965
1321
  this.cb = cb;
@@ -969,6 +1325,9 @@ var PersistedIndexStore = class {
969
1325
  index;
970
1326
  timer = null;
971
1327
  lastBuild;
1328
+ /** The positional-postings opt-in the last caller asked for (#1354). A loaded
1329
+ * sidecar that does not carry exactly these fields is discarded, not adapted. */
1330
+ lastOpts;
972
1331
  debounceMs;
973
1332
  /**
974
1333
  * Bumped by every purge (removePersisted). A save() captured under a since-stale
@@ -1015,16 +1374,20 @@ var PersistedIndexStore = class {
1015
1374
  get built() {
1016
1375
  return this.index !== void 0;
1017
1376
  }
1018
- async ensureBuilt(build) {
1377
+ async ensureBuilt(build, opts) {
1019
1378
  await this.retryPendingCompensation();
1020
1379
  this.lastBuild = build;
1380
+ this.lastOpts = opts;
1021
1381
  if (this.index !== void 0) return this.index;
1022
1382
  const loaded = await this.cb.load();
1023
- if (loaded !== null && fpEqual(loaded.fingerprint, this.cb.currentFingerprint())) {
1024
- this.index = deserializeIndex(loaded.json);
1025
- return this.index;
1383
+ if (loaded !== null && fpEqual2(loaded.fingerprint, this.cb.currentFingerprint())) {
1384
+ const restored = deserializeIndex(loaded.json);
1385
+ if (restored !== null && positionsMatch(restored, opts)) {
1386
+ this.index = restored;
1387
+ return this.index;
1388
+ }
1026
1389
  }
1027
- this.index = InvertedIndex.build(build());
1390
+ this.index = InvertedIndex.build(build(), opts);
1028
1391
  await this.persist();
1029
1392
  return this.index;
1030
1393
  }
@@ -1071,7 +1434,7 @@ var PersistedIndexStore = class {
1071
1434
  await this.retryPendingCompensation();
1072
1435
  if (this.lastBuild === void 0) return;
1073
1436
  if (this.index === void 0) {
1074
- this.index = InvertedIndex.build(this.lastBuild());
1437
+ this.index = InvertedIndex.build(this.lastBuild(), this.lastOpts);
1075
1438
  }
1076
1439
  await this.persist();
1077
1440
  }
@@ -1114,21 +1477,34 @@ var PersistedIndexStore = class {
1114
1477
 
1115
1478
  // src/with-lookup/indexing/unique-constraints.ts
1116
1479
  var UniqueConstraintSet = class {
1117
- constructor(collectionName, uniqueDefs) {
1480
+ constructor(collectionName, uniqueDefs, enforcement = "prevent", report = () => {
1481
+ }) {
1118
1482
  this.collectionName = collectionName;
1483
+ this.enforcement = enforcement;
1484
+ this.report = report;
1119
1485
  this.constraints = uniqueDefs.map((fields) => ({ fields, map: /* @__PURE__ */ new Map() }));
1120
1486
  }
1121
1487
  collectionName;
1488
+ enforcement;
1489
+ report;
1122
1490
  constraints;
1123
1491
  get size() {
1124
1492
  return this.constraints.length;
1125
1493
  }
1494
+ /** The declared field tuples, in declaration order. */
1495
+ fieldTuples() {
1496
+ return this.constraints.map((c) => c.fields);
1497
+ }
1126
1498
  /**
1127
1499
  * Compute the canonical key for a record under a given constraint.
1128
1500
  * Returns `null` if any constrained field is `null` or `undefined`
1129
1501
  * (the record is exempt — no constraint is checked).
1502
+ *
1503
+ * Public because the tier scan (`with-audit/tiers/index.ts`) has to compute
1504
+ * the same key for a record it decrypted under a tier DEK, which this class
1505
+ * cannot reach — one key function, so the two paths cannot drift.
1130
1506
  */
1131
- keyFor(fields, record) {
1507
+ keyOf(fields, record) {
1132
1508
  const row = {};
1133
1509
  for (const f of fields) {
1134
1510
  const v = readPath(record, f);
@@ -1137,29 +1513,66 @@ var UniqueConstraintSet = class {
1137
1513
  }
1138
1514
  return canonicalGroupKey(fields, row);
1139
1515
  }
1516
+ /**
1517
+ * Every constraint key `record` would occupy — the probe a checker outside
1518
+ * this class (tiers, lazy) compares against its own candidates. Exempt
1519
+ * (null-distinct) constraints are omitted, so an empty result means "this
1520
+ * record is unconstrained" and the caller can skip its scan entirely.
1521
+ */
1522
+ probe(record) {
1523
+ const out = [];
1524
+ for (const c of this.constraints) {
1525
+ const key = this.keyOf(c.fields, record);
1526
+ if (key !== null) out.push({ fields: c.fields, key });
1527
+ }
1528
+ return out;
1529
+ }
1140
1530
  /**
1141
1531
  * Throw `UniqueConstraintError` if writing `id` with `record` would
1142
1532
  * collide with a DIFFERENT existing record. Call BEFORE the store write.
1533
+ *
1534
+ * In `'detect'` mode this is a deliberate NO-OP: a CRDT collection must
1535
+ * not refuse a write it has no authority to refuse (module doc). The
1536
+ * collision is reported from {@link upsert} / {@link build} instead.
1143
1537
  */
1144
1538
  check(id, record) {
1539
+ if (this.enforcement === "detect") return;
1540
+ const clash = this.collision(id, record);
1541
+ if (clash) throw clash;
1542
+ }
1543
+ /**
1544
+ * The `UniqueConstraintError` a write of `id`/`record` would produce, or
1545
+ * `null`. Never throws — the shared core of {@link check} (which throws it)
1546
+ * and the detect path (which reports it).
1547
+ */
1548
+ collision(id, record) {
1145
1549
  for (const c of this.constraints) {
1146
- const key = this.keyFor(c.fields, record);
1550
+ const key = this.keyOf(c.fields, record);
1147
1551
  if (key === null) continue;
1148
1552
  const holder = c.map.get(key);
1149
1553
  if (holder !== void 0 && holder !== id) {
1150
- throw new UniqueConstraintError(this.collectionName, id, c.fields, holder);
1554
+ return new UniqueConstraintError(this.collectionName, id, c.fields, holder);
1151
1555
  }
1152
1556
  }
1557
+ return null;
1153
1558
  }
1154
1559
  /**
1155
1560
  * Update the constraint maps after a successful write.
1156
1561
  * Pass `previous` when updating an existing record (so the old key
1157
1562
  * is removed first). Pass `null` or `undefined` for a fresh insert.
1563
+ *
1564
+ * In `'detect'` mode a collision observed here is REPORTED and the write
1565
+ * still stands (both records are kept — see the module doc). In
1566
+ * `'prevent'` mode `check()` already ran, so there is nothing to report.
1158
1567
  */
1159
1568
  upsert(id, record, previous) {
1160
1569
  if (previous != null) this.remove(id, previous);
1570
+ if (this.enforcement === "detect") {
1571
+ const clash = this.collision(id, record);
1572
+ if (clash) this.report(clash);
1573
+ }
1161
1574
  for (const c of this.constraints) {
1162
- const key = this.keyFor(c.fields, record);
1575
+ const key = this.keyOf(c.fields, record);
1163
1576
  if (key !== null) c.map.set(key, id);
1164
1577
  }
1165
1578
  }
@@ -1169,7 +1582,7 @@ var UniqueConstraintSet = class {
1169
1582
  */
1170
1583
  remove(id, record) {
1171
1584
  for (const c of this.constraints) {
1172
- const key = this.keyFor(c.fields, record);
1585
+ const key = this.keyOf(c.fields, record);
1173
1586
  if (key !== null && c.map.get(key) === id) c.map.delete(key);
1174
1587
  }
1175
1588
  }
@@ -1177,13 +1590,18 @@ var UniqueConstraintSet = class {
1177
1590
  * Rebuild all constraint maps from a full snapshot.
1178
1591
  * Called after hydration (ensureHydrated / hydrateFromSnapshot).
1179
1592
  *
1180
- * **Last-writer-wins**: this method does NOT validate pre-existing data
1181
- * for duplicates. If the store already contains two records sharing a
1182
- * constrained value (written before the unique index was declared), the
1183
- * last one processed wins the map slot and the duplicate is silently
1184
- * displaced — no error is thrown, and the earlier holder is evicted from
1185
- * the map. Callers retrofitting a unique index onto populated data should
1186
- * run a one-time uniqueness scan before relying on enforcement.
1593
+ * **In `'prevent'` mode this is last-writer-wins**: it does NOT validate
1594
+ * pre-existing data for duplicates. If the store already contains two
1595
+ * records sharing a constrained value (written before the unique index was
1596
+ * declared), the last one processed wins the map slot and the duplicate is
1597
+ * silently displaced — no error is thrown, and the earlier holder is
1598
+ * evicted from the map. Callers retrofitting a unique index onto populated
1599
+ * data should run a one-time uniqueness scan before relying on enforcement.
1600
+ *
1601
+ * **In `'detect'` mode this is the MERGE POINT** — the moment a session
1602
+ * that wrote neither record first sees them together (a CRDT replica
1603
+ * opening a store its peer has written to). Every displaced holder is
1604
+ * reported on `unique:violation` instead of being dropped in silence.
1187
1605
  */
1188
1606
  build(entries) {
1189
1607
  for (const c of this.constraints) c.map.clear();
@@ -1192,7 +1610,7 @@ var UniqueConstraintSet = class {
1192
1610
  }
1193
1611
  }
1194
1612
  };
1195
- function buildUniqueConstraintSet(collectionName, indexes, mode) {
1613
+ function buildUniqueConstraintSet(collectionName, indexes, mode, report) {
1196
1614
  const uniqueDefs = [];
1197
1615
  for (const def of indexes ?? []) {
1198
1616
  if (def !== null && typeof def === "object" && !Array.isArray(def) && def.unique === true) {
@@ -1200,25 +1618,7 @@ function buildUniqueConstraintSet(collectionName, indexes, mode) {
1200
1618
  }
1201
1619
  }
1202
1620
  if (uniqueDefs.length === 0) return null;
1203
- if (mode.lazy) {
1204
- throw new UnsupportedIndexOptionError(
1205
- "unique",
1206
- `unique indexes are not yet supported in lazy mode (prefetch:false) \u2014 use the default eager mode. Collection "${collectionName}".`
1207
- );
1208
- }
1209
- if (mode.crdt) {
1210
- throw new UnsupportedIndexOptionError(
1211
- "unique",
1212
- `unique indexes are not supported on CRDT collections (crdt mode is incompatible with eager unique enforcement). Collection "${collectionName}".`
1213
- );
1214
- }
1215
- if (mode.tiered) {
1216
- throw new UnsupportedIndexOptionError(
1217
- "unique",
1218
- `unique indexes are not supported on tiered collections (tier writes use a separate path that bypasses unique enforcement). Collection "${collectionName}".`
1219
- );
1220
- }
1221
- return new UniqueConstraintSet(collectionName, uniqueDefs);
1621
+ return new UniqueConstraintSet(collectionName, uniqueDefs, mode.crdt ? "detect" : "prevent", report);
1222
1622
  }
1223
1623
 
1224
1624
  // src/kernel/put-many-atomic.ts
@@ -1325,7 +1725,7 @@ async function commitSequentially(ctx, entries, priors) {
1325
1725
  }
1326
1726
 
1327
1727
  // src/with-formula/computed/lazy.ts
1328
- var loadComputed = lazy(() => import("./computed-VPOKQK4N.js"));
1728
+ var loadComputed = lazy(() => import("./computed-TPFBX7U4.js"));
1329
1729
  async function loadEvalComputedFields() {
1330
1730
  return (await loadComputed()).evalComputedFields;
1331
1731
  }
@@ -1379,7 +1779,18 @@ var Collection = class {
1379
1779
  // In-memory cache of decrypted records (eager mode only). Lazy mode
1380
1780
  // uses `lru` instead. Both fields exist so a single Collection instance
1381
1781
  // doesn't need a runtime branch on every cache access.
1382
- cache = /* @__PURE__ */ new Map();
1782
+ cache = new GenerationMap();
1783
+ /** #1418 — mutation stamp for a derived-output memo, or `null` when one must NOT be used because a redundant re-write would still be observable (gate handler, history, sync, search) or there is no eager cache to stamp. The rules and their measured rationale live with the consumer, `with-formula/materialized-views/emit-memo.ts`. `_`-prefixed deliberately: `kernel-api-surface-golden` freezes the PUBLIC surface and this is an executor seam. @internal */
1784
+ get _cacheStamp() {
1785
+ if (this.lazy) return null;
1786
+ if (this.historyConfigExplicit && this.historyConfig.enabled !== false) return null;
1787
+ if (this.onDirty !== void 0 || this.searchIndexStore !== void 0) return null;
1788
+ return this.cache.generation;
1789
+ }
1790
+ /** #1439 — could a `beforePut` gate fire for THIS row? Asks each handler's declared scope, not merely whether any is registered — the bus is vault-wide, the gates are not. @internal */
1791
+ _derivedWriteGated(record) {
1792
+ return this.subsystemBus?.gateAppliesTo("beforePut", { vault: this.vault, collection: this.name, record }) === true;
1793
+ }
1383
1794
  hydrated = false;
1384
1795
  /**
1385
1796
  * #606: ids known to carry a delete marker in the store — lets the #589
@@ -1494,8 +1905,12 @@ var Collection = class {
1494
1905
  i18nFields;
1495
1906
  /** The configured string fields exposed to `retrieve()`; `undefined` for ordinary collections (zero-cost). */
1496
1907
  textIndexes;
1908
+ /** #1354 — the subset of `textIndexes` carrying positional postings (phrase / proximity). */
1909
+ textIndexPositions;
1497
1910
  /** Session-scoped lexical index store; `undefined` (zero-cost) unless `textIndexes` is non-empty. */
1498
1911
  searchIndexStore;
1912
+ /** Encrypted field-index sidecars (#1359); `null` (zero-cost) unless an index declared `persist: true`. */
1913
+ fieldIndexStore;
1499
1914
  /** Embedding config for write-time vector derivation; `undefined` (zero-cost) for ordinary
1500
1915
  * collections. When set, `put()` encodes the source field(s) and stores an encrypted `_vec` sidecar. */
1501
1916
  embeddings;
@@ -1712,6 +2127,7 @@ var Collection = class {
1712
2127
  this.joinResolver = cfg.joinResolver;
1713
2128
  this.i18nFields = cfg.i18nFields;
1714
2129
  this.textIndexes = cfg.textIndexes;
2130
+ this.textIndexPositions = cfg.textIndexPositions;
1715
2131
  this.searchIndexStore = opts.textIndexes && opts.textIndexes.length > 0 ? opts.textIndexPersist ? new PersistedIndexStore(buildPersistedIndexCallbacks(() => this.searchContext())) : new MemoryIndexStore() : void 0;
1716
2132
  this.embeddings = cfg.embeddings;
1717
2133
  this.vectorSet = cfg.vectorSet;
@@ -1773,6 +2189,8 @@ var Collection = class {
1773
2189
  getDEK: (collection) => this.getDEK(collection ?? this.name),
1774
2190
  cekCache: this.cekCache,
1775
2191
  classifiedMarkerDigestOnly: () => this._classifiedMarkerDigestOnly(),
2192
+ onDecrypt: this.strategies.coverage.observer(this.vault, this.name, this.keyring.userId, () => this.fieldMeta, this.emitter, opts.prefetch !== false),
2193
+ // #1363 read-coverage sensor; NO_COVERAGE returns undefined
1776
2194
  via: this.via
1777
2195
  });
1778
2196
  if (cfg.classifiedEraseCfg) cfg.classifiedEraseCfg.classifySealedShred = (live) => this.codec.classifySealedShred(live);
@@ -1854,14 +2272,15 @@ var Collection = class {
1854
2272
  defs: opts.indexes ?? [],
1855
2273
  lazy: this.lazy
1856
2274
  });
1857
- this.declaredIndexes = normalizeIndexDefs(opts.indexes ?? []);
2275
+ this.declaredIndexes = resolveDeclaredIndexes(opts.indexes ?? [], this.name, this.indexState.isEnabled);
2276
+ this.fieldIndexStore = createPersistedFieldIndexes(() => this.indexingContext(), this.indexes);
1858
2277
  this.indexes?.setCanonicalizer((f, v) => this.via?.canonicalizeIndexKey(f, v));
1859
2278
  this.persistedIndexes?.setCanonicalizer((f, v) => this.via?.canonicalizeIndexKey(f, v));
1860
2279
  this.uniqueConstraints = buildUniqueConstraintSet(this.name, opts.indexes, {
1861
2280
  lazy: this.lazy,
1862
2281
  crdt: this.crdtMode != null,
1863
2282
  tiered: this.tiers != null
1864
- });
2283
+ }, (err) => this.emitter.emit("unique:violation", { vault: this.vault, collection: this.name, id: err.recordId, fields: err.fields, conflictingId: err.conflictingId, error: err }));
1865
2284
  }
1866
2285
  /**
1867
2286
  * Return the Standard Schema validator attached to this collection,
@@ -1889,6 +2308,11 @@ var Collection = class {
1889
2308
  return this.declaredIndexes;
1890
2309
  }
1891
2310
  // declared index defs, normalized; consumed by walk.ts
2311
+ /** #1447 — `field -> via brands covering it`, for `dumpSchema()`. Brand and field only, never a binding's config; see `via/pipeline.ts#fieldCoverage`. Consumed by walk.ts. */
2312
+ getViaCoverage() {
2313
+ const c = this.via?.fieldCoverage();
2314
+ return c && Object.keys(c).length > 0 ? c : void 0;
2315
+ }
1892
2316
  /**
1893
2317
  * Aggregate all collection-level configuration options that are actively set
1894
2318
  * into a {@link CollectionConfig} snapshot. Returns `undefined` when no options
@@ -1994,7 +2418,7 @@ var Collection = class {
1994
2418
  }
1995
2419
  /** JSON Schema for this collection with describe() metadata as x- extensions. */
1996
2420
  async toJSONSchema() {
1997
- const { buildJsonSchema } = await import("./json-schema-V3M5MUCM.js");
2421
+ const { buildJsonSchema } = await import("./json-schema-3SHX72CC.js");
1998
2422
  const desc = await this.describe({});
1999
2423
  let base = null;
2000
2424
  if (this.schema !== void 0) {
@@ -2110,7 +2534,7 @@ var Collection = class {
2110
2534
  }
2111
2535
  await this.onAccess?.("find", "*");
2112
2536
  if (hits.length === 0) return [];
2113
- const { verifyDigestField } = await import("./verify-KOV2G5D6.js");
2537
+ const { verifyDigestField } = await import("./verify-RVT67IMH.js");
2114
2538
  const policy = {
2115
2539
  normalize: spec.verifyNormalize ?? "password",
2116
2540
  notLastN: spec.notLastN ?? 0,
@@ -2322,7 +2746,7 @@ var Collection = class {
2322
2746
  }
2323
2747
  }
2324
2748
  if (this.materializedViewSource !== void 0) {
2325
- const { resolveStaleMVOnRead } = await import("./stale-DDL7WQEZ.js");
2749
+ const { resolveStaleMVOnRead } = await import("./stale-TJ3DYZMQ.js");
2326
2750
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
2327
2751
  }
2328
2752
  let record;
@@ -2439,6 +2863,10 @@ var Collection = class {
2439
2863
  * ORIGIN refresh time across vaults. (FR-4)
2440
2864
  */
2441
2865
  async put(id, record, options) {
2866
+ return trackKeyedWrite(this.adapter, this.vault, this.name, id, () => this.#putGated(id, record, options));
2867
+ }
2868
+ /** @internal The body of {@link put}; see the #1420 note there for why it is split. */
2869
+ async #putGated(id, record, options) {
2442
2870
  await this.schemaUpdateGate?.assertWritable();
2443
2871
  await this.schemaFence?.assertWritable(this.name);
2444
2872
  const hooksActive = this.#hooksActive();
@@ -2805,7 +3233,8 @@ var Collection = class {
2805
3233
  }
2806
3234
  if (priorRaw && isDeleteMarker(priorRaw)) version = priorRaw._v + 1;
2807
3235
  }
2808
- this.uniqueConstraints?.check(id, record);
3236
+ await checkUniqueOnPut(this.indexingContext(), id, record);
3237
+ if (this.tiers !== null && this.uniqueConstraints !== null) await this.strategies.tiers.checkUnique(this.tiersContext(), id, record);
2809
3238
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
2810
3239
  const vdigCtx = this.vdigFields !== null ? { id, prev: await this.adapter.get(this.vault, this.name, id) } : void 0;
2811
3240
  const envelope = await this.codec.encryptRecord({ collection: this.name, id }, record, version, cek, options?.source, options?.sourceTs, vdigCtx);
@@ -2854,7 +3283,7 @@ var Collection = class {
2854
3283
  */
2855
3284
  async dispatchMaterializedViews(id, record, wave) {
2856
3285
  if (this.materializedViewSource === void 0) return;
2857
- const { dispatchMaterializedViews } = await import("./dispatch-WC6X2M6C.js");
3286
+ const { dispatchMaterializedViews } = await import("./dispatch-3CQDJV5Q.js");
2858
3287
  return dispatchMaterializedViews(this.#mvDispatchCtx(this.materializedViewSource), id, record, wave);
2859
3288
  }
2860
3289
  /**
@@ -3020,13 +3449,13 @@ var Collection = class {
3020
3449
  * dispatch wave's per-target dedup; `undefined` on the local-write path (byte-identical). */
3021
3450
  async dispatchDerivations(id, record, version, wave, prior) {
3022
3451
  if (this.derivationSource === void 0) return;
3023
- const { dispatchDerivations } = await import("./dispatch-S73TK3IY.js");
3452
+ const { dispatchDerivations } = await import("./dispatch-RH4LHKBH.js");
3024
3453
  return dispatchDerivations(this.#derivationDispatchCtx(), id, record, version, wave, prior);
3025
3454
  }
3026
3455
  /** @internal — trigger fan-out for a deleted parent (#1249); see dispatch.ts. */
3027
3456
  async dispatchTriggerDerivationsOnDelete(id, deleted) {
3028
3457
  if (this.derivationSource === void 0) return;
3029
- const { dispatchTriggerDerivationsOnDelete } = await import("./dispatch-S73TK3IY.js");
3458
+ const { dispatchTriggerDerivationsOnDelete } = await import("./dispatch-RH4LHKBH.js");
3030
3459
  return dispatchTriggerDerivationsOnDelete(this.#derivationDispatchCtx(), id, deleted);
3031
3460
  }
3032
3461
  /**
@@ -3034,6 +3463,10 @@ var Collection = class {
3034
3463
  * so `hub.writeQueue.pending` reflects this write.
3035
3464
  */
3036
3465
  async delete(id) {
3466
+ return trackKeyedWrite(this.adapter, this.vault, this.name, id, () => this.#deleteGated(id));
3467
+ }
3468
+ /** @internal The body of {@link delete}; see the #1420 note on {@link put}. */
3469
+ async #deleteGated(id) {
3037
3470
  await this.schemaUpdateGate?.assertWritable();
3038
3471
  await this.schemaFence?.assertWritable(this.name);
3039
3472
  const hooksActive = this.#hooksActive();
@@ -3246,6 +3679,7 @@ var Collection = class {
3246
3679
  if (persist) await this.adapter.put(this.vault, this.name, id, marker);
3247
3680
  this.markerIds.add(id);
3248
3681
  } else if (persist) await this.adapter.delete(this.vault, this.name, id);
3682
+ if (this.strategies.blobs !== NO_BLOBS) await this.blob(id).releaseAll();
3249
3683
  if (this.ledger) {
3250
3684
  await this.ledger.append({ op: "delete", collection: this.name, id, version: existing?.version ?? 0, actor: this.keyring.userId, payloadHash: previousPayloadHash });
3251
3685
  }
@@ -3338,7 +3772,7 @@ var Collection = class {
3338
3772
  */
3339
3773
  async dispatchArrayDerivationsOnDelete(id, eraseRecordShapeToo = false) {
3340
3774
  if (this.derivationSource === void 0) return 0;
3341
- const { dispatchArrayDerivationsOnDelete } = await import("./dispatch-S73TK3IY.js");
3775
+ const { dispatchArrayDerivationsOnDelete } = await import("./dispatch-RH4LHKBH.js");
3342
3776
  return dispatchArrayDerivationsOnDelete(this.#derivationDeleteCtx(this.derivationSource), id, eraseRecordShapeToo);
3343
3777
  }
3344
3778
  /**
@@ -3352,7 +3786,7 @@ var Collection = class {
3352
3786
  */
3353
3787
  async dispatchMaterializedViewsOnDelete(id) {
3354
3788
  if (this.materializedViewSource === void 0) return { deleted: 0, residueUndecodable: [], residueDeclined: [] };
3355
- const { dispatchMaterializedViewsOnDelete } = await import("./dispatch-WC6X2M6C.js");
3789
+ const { dispatchMaterializedViewsOnDelete } = await import("./dispatch-3CQDJV5Q.js");
3356
3790
  return dispatchMaterializedViewsOnDelete(this.#mvDispatchCtx(this.materializedViewSource), id);
3357
3791
  }
3358
3792
  /**
@@ -3372,7 +3806,7 @@ var Collection = class {
3372
3806
  );
3373
3807
  }
3374
3808
  if (this.materializedViewSource !== void 0) {
3375
- const { resolveStaleMVOnRead } = await import("./stale-DDL7WQEZ.js");
3809
+ const { resolveStaleMVOnRead } = await import("./stale-TJ3DYZMQ.js");
3376
3810
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
3377
3811
  }
3378
3812
  await this.ensureHydrated();
@@ -3430,6 +3864,7 @@ var Collection = class {
3430
3864
  cache: this.cache,
3431
3865
  lazy: this.lazy,
3432
3866
  textIndexes: this.textIndexes,
3867
+ textIndexPositions: this.textIndexPositions,
3433
3868
  i18nFields: this.i18nFields,
3434
3869
  dictKeyFields: this.dictKeyFields,
3435
3870
  blobFields: this.blobFields,
@@ -3555,7 +3990,7 @@ var Collection = class {
3555
3990
  subscribe: (cb) => {
3556
3991
  const handler = (event) => {
3557
3992
  if (event.vault === this.vault && event.collection === this.name) {
3558
- cb();
3993
+ cb(event.remote === true ? void 0 : { id: event.id, action: event.action });
3559
3994
  }
3560
3995
  };
3561
3996
  this.emitter.on("change", handler);
@@ -3567,6 +4002,11 @@ var Collection = class {
3567
4002
  getIndexes: () => this.getIndexes(),
3568
4003
  lookupById: (id) => this.cache.get(id)?.record,
3569
4004
  snapshotEntries: () => [...this.cache.entries()].map(([id, e]) => ({ id, record: e.record })),
4005
+ // Binds a keyset cursor to this collection (#1346).
4006
+ identity: `${this.vault}/${this.name}`,
4007
+ snapshotVersion: () => this.cache.generation,
4008
+ hydration: { label: `${this.vault}/${this.name}`, collection: this.name, isHydrated: () => this.hydrated, hydrate: () => this.ensureHydrated() },
4009
+ // #1414 — a never-read eager collection answers by ABSENCE; the gate makes every terminal await-able and refuse a synchronous read (query/hydration.ts)
3570
4010
  ...this.via ? { via: this.via } : {}
3571
4011
  };
3572
4012
  const resolver = this.joinResolver;
@@ -3658,6 +4098,8 @@ var Collection = class {
3658
4098
  return {
3659
4099
  snapshot: () => [...this.cache.values()].map((e) => e.record),
3660
4100
  lookupById: (id) => this.cache.get(id)?.record,
4101
+ snapshotEntries: () => [...this.cache.entries()].map(([id, e]) => ({ id, record: e.record })),
4102
+ // #1289 right/full outer join — the id is the cache KEY, not a field on the record; same `this.cache` closure as snapshot(), so the two views cannot disagree
3661
4103
  subscribe: (cb) => {
3662
4104
  const handler = (event) => {
3663
4105
  if (event.vault === this.vault && event.collection === this.name) {
@@ -3668,7 +4110,10 @@ var Collection = class {
3668
4110
  return () => this.emitter.off("change", handler);
3669
4111
  },
3670
4112
  // Sync join dressing (#650 Task 6, #626 retirement) — i18n-text + lookup-label, from this collection's own bindings.
3671
- ...this.presentForJoin !== void 0 ? { presentForJoin: this.presentForJoin } : {}
4113
+ ...this.presentForJoin !== void 0 ? { presentForJoin: this.presentForJoin } : {},
4114
+ decodeResults: (record) => this.via && this.via.hasResultDecode ? this.via.decodeResults(record) : record,
4115
+ via: () => this.via
4116
+ // #1289 Via result decode for a record served under an ALIAS, and #1337/#1338's `via()` — the pipeline ITSELF, for a record ORDERED (compareForOrder) or REDUCED (wrapReducers) under one. Contract + rationale on JoinableSource in query/join.ts. Both read `this.via` per call, never a captured value: _applyMoneyFields rebuilds the pipeline after this source is handed out — which is also why `via` is a thunk and not a property
3672
4117
  };
3673
4118
  }
3674
4119
  /**
@@ -4006,6 +4451,15 @@ var Collection = class {
4006
4451
  async _applyRemoteChange(id, action) {
4007
4452
  await this._onRecordMutated(id, action, "tab-mirror");
4008
4453
  }
4454
+ /** @internal #1362 — same as {@link _applyRemoteChange}, for a frame that carries NO verb.
4455
+ * A peer's claim about the verb is not evidence; the re-read decides it, exactly as
4456
+ * `_compensateRevertedWrite` does. Untrusted ingress is why the frame omits it. */
4457
+ async _applyRemoteSignal(id) {
4458
+ await this._invalidateCacheEntry(id);
4459
+ const action = await this.get(id) !== null ? "put" : "delete";
4460
+ this.emitter.emit("change", { vault: this.vault, collection: this.name, id, action, remote: true });
4461
+ this.searchIndexStore?.markDirty();
4462
+ }
4009
4463
  /**
4010
4464
  * Origin-tagged mutation choke point (#623 task 10) — the single dispatch
4011
4465
  * point every put/delete path funnels through, AFTER its own store write,
@@ -4035,6 +4489,7 @@ var Collection = class {
4035
4489
  await this.onDirty?.(this.name, id, "put", version);
4036
4490
  this.emitter.emit("change", { vault: this.vault, collection: this.name, id, action: "put" });
4037
4491
  this.searchIndexStore?.markDirty();
4492
+ this.fieldIndexStore?.markDirty();
4038
4493
  await this.onAccess?.("put", id);
4039
4494
  await this.dispatchDerivations(id, record, version, void 0, ctx.prior);
4040
4495
  await this.dispatchMaterializedViews(id, record);
@@ -4044,13 +4499,15 @@ var Collection = class {
4044
4499
  await this.onDirty?.(this.name, id, "put", ctx.version);
4045
4500
  this.emitter.emit("change", { vault: this.vault, collection: this.name, id, action: "delete" });
4046
4501
  this.searchIndexStore?.markDirty();
4502
+ this.fieldIndexStore?.markDirty();
4047
4503
  await this.onAccess?.("delete", id);
4048
4504
  return;
4049
4505
  }
4050
4506
  case "tab-mirror":
4051
4507
  await this._invalidateCacheEntry(id);
4052
- this.emitter.emit("change", { vault: this.vault, collection: this.name, id, action });
4508
+ this.emitter.emit("change", { vault: this.vault, collection: this.name, id, action, remote: true });
4053
4509
  this.searchIndexStore?.markDirty();
4510
+ this.fieldIndexStore?.markDirty();
4054
4511
  return;
4055
4512
  case "sync-apply": {
4056
4513
  this._invalidateCekCacheEntry(id);
@@ -4088,7 +4545,7 @@ var Collection = class {
4088
4545
  }
4089
4546
  }
4090
4547
  this.hydrated = true;
4091
- this.rebuildEagerIndexesFromCache();
4548
+ await hydrateEagerIndexes(this.indexingContext());
4092
4549
  this.rebuildUniqueConstraintsFromCache();
4093
4550
  }
4094
4551
  /** Hydrate from a pre-loaded snapshot (used by Vault). */
@@ -4104,7 +4561,7 @@ var Collection = class {
4104
4561
  this.cache.set(id, { record, version: envelope._v });
4105
4562
  }
4106
4563
  this.hydrated = true;
4107
- this.rebuildEagerIndexesFromCache();
4564
+ await hydrateEagerIndexes(this.indexingContext());
4108
4565
  this.rebuildUniqueConstraintsFromCache();
4109
4566
  }
4110
4567
  /**
@@ -4222,10 +4679,39 @@ var Collection = class {
4222
4679
  tiersActive: this.tiers !== null,
4223
4680
  keyring: this.keyring,
4224
4681
  debugPlaintext: this.keyring.debugPlaintext === true,
4682
+ assertOwnerWritable: () => this._assertRecordMutable(id),
4683
+ // #1452
4225
4684
  ...this.objectStore !== void 0 ? { objectStore: this.objectStore } : {},
4226
4685
  ...this.blobFields !== void 0 ? { blobFields: this.blobFields } : {}
4227
4686
  });
4228
4687
  }
4688
+ /**
4689
+ * #1452 — would an update of record `id` pass the `beforePut` gate bus right
4690
+ * now? Runs the bus with `incoming = existing`, so closed periods and record
4691
+ * guards refuse an attachment change exactly as they would refuse the
4692
+ * record's own update. A record with no stored body (never written, marker,
4693
+ * elevated tier) is not gated — attaching before the first `put()` was
4694
+ * always allowed. @internal
4695
+ */
4696
+ async _assertRecordMutable(id) {
4697
+ if (!this.subsystemBus?.hasGateHandlers("beforePut")) return;
4698
+ const { env, record } = await this.resolveGatePrior("beforePut", id);
4699
+ if (!env || record === null || record === void 0) return;
4700
+ const existing = this.via ? this.via.canonicalizeStored(record) : record;
4701
+ await this.subsystemBus.dispatchGate("beforePut", {
4702
+ op: "update",
4703
+ vault: this.vault,
4704
+ collection: this.name,
4705
+ docId: id,
4706
+ incoming: existing,
4707
+ existing,
4708
+ existingVersion: env._v,
4709
+ existingTs: env._ts,
4710
+ userId: this.keyring.userId,
4711
+ role: this.keyring.role,
4712
+ ...this.computed !== void 0 ? { computedFieldNames: new Set(Object.keys(this.computed)) } : {}
4713
+ });
4714
+ }
4229
4715
  /** Get all records as encrypted envelopes (for dump). */
4230
4716
  async dumpEnvelopes() {
4231
4717
  await this.ensureHydrated();
@@ -4258,9 +4744,8 @@ var Collection = class {
4258
4744
  if (!this.via) return record;
4259
4745
  const locale = localeOpts?.locale ?? this.defaultLocale;
4260
4746
  const layer = localeOpts?._layer ?? "read";
4261
- let result = record;
4262
- result = await this.via.present(result, { locale, ...localeOpts?.fallback !== void 0 ? { fallback: localeOpts.fallback } : {}, layer });
4263
- return result;
4747
+ const via = this.via;
4748
+ return memoizePresent(record, presentVariantKey(locale, layer, localeOpts?.fallback), async () => await via.present(record, { locale, ...localeOpts?.fallback !== void 0 ? { fallback: localeOpts.fallback } : {}, layer }));
4264
4749
  }
4265
4750
  /**
4266
4751
  * Low-level: encrypt a pre-serialised JSON string into an EncryptedEnvelope.
@@ -4314,7 +4799,11 @@ var Collection = class {
4314
4799
  * Called by vault.ts forget() inside a resilient try/catch; residue is reported in ForgetResult. */
4315
4800
  async _purgeVector(id) {
4316
4801
  await this.adapter.delete(this.vault, "_vec", encodeVecId(this.name, id));
4317
- this.vectorSet?.markDirty();
4802
+ this.vectorSet?.removeRecord(id);
4803
+ }
4804
+ /** @internal #1359 — force an immediate sidecar write, cancelling the debounce. No-op when none opted in. */
4805
+ async _flushFieldIndexes() {
4806
+ await this.fieldIndexStore?.flush();
4318
4807
  }
4319
4808
  /** Drop the persisted lexical-index blob (forget/erasure): an opaque
4320
4809
  * all-records index must not survive crypto-shred. Idempotent; no-op without persist. */
@@ -4482,14 +4971,14 @@ var Collection = class {
4482
4971
  /** C-A/R10: persist the classified marker once per classified handle (store I/O in config-drift.ts). */
4483
4972
  async _ensureClassifiedMarker() {
4484
4973
  if (this._markerPersisted || this.vdigFields === null) return;
4485
- const { persistClassifiedMarkerForFields } = await import("./classified-marker-LI2SF2E4.js");
4974
+ const { persistClassifiedMarkerForFields } = await import("./classified-marker-W3USLL5M.js");
4486
4975
  await persistClassifiedMarkerForFields(this.adapter, this.vault, this.name, this.vdigFields, await this.getDEK(this.name));
4487
4976
  this._markerPersisted = true;
4488
4977
  }
4489
4978
  /** C-A/R10 drift signal — the marker's declared digest-only set, memoized to one store read per handle (see config-drift.ts). */
4490
4979
  async _classifiedMarkerDigestOnly() {
4491
4980
  if (this._markerDigestOnlyCache !== void 0) return this._markerDigestOnlyCache;
4492
- const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-LI2SF2E4.js");
4981
+ const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-W3USLL5M.js");
4493
4982
  this._markerDigestOnlyCache = await readClassifiedMarkerDigestOnly(this.adapter, this.vault, this.name, await this.getDEK(this.name));
4494
4983
  return this._markerDigestOnlyCache;
4495
4984
  }
@@ -4663,7 +5152,10 @@ var Collection = class {
4663
5152
  tierMode: this.tierMode,
4664
5153
  getDEK: (key) => this.getDEK(key),
4665
5154
  emitCrossTierEvent: (event) => this.emitCrossTierEvent(event),
4666
- addSubjectRef: (id, record) => this.addSubjectRef?.(id, record) ?? Promise.resolve()
5155
+ addSubjectRef: (id, record) => this.addSubjectRef?.(id, record) ?? Promise.resolve(),
5156
+ // #1358 — undefined on a collection with no `unique` index, which is what keeps the tier scan free everywhere else.
5157
+ uniqueKeys: this.uniqueConstraints ? (record) => this.uniqueConstraints.probe(record) : void 0,
5158
+ checkUniqueLocal: this.uniqueConstraints ? (id, record) => checkUniqueOnPut(this.indexingContext(), id, record) : void 0
4667
5159
  };
4668
5160
  }
4669
5161
  /**
@@ -4684,6 +5176,7 @@ var Collection = class {
4684
5176
  indexes: this.indexes,
4685
5177
  uniqueConstraints: this.uniqueConstraints,
4686
5178
  persistedIndexes: this.persistedIndexes,
5179
+ fieldIndexes: this.fieldIndexStore,
4687
5180
  ensureHydrated: () => this.ensureHydrated(),
4688
5181
  ensurePersistedIndexesLoaded: () => this.ensurePersistedIndexesLoaded(),
4689
5182
  setPersistedIndexesLoaded: (value) => {
@@ -4693,6 +5186,18 @@ var Collection = class {
4693
5186
  }
4694
5187
  };
4695
5188
 
5189
+ // src/with-audit/periods/reserved-collections.ts
5190
+ var PERIODS_RESERVED_COLLECTIONS = /* @__PURE__ */ new Set([
5191
+ PERIODS_COLLECTION,
5192
+ PERIOD_FREEZES_COLLECTION,
5193
+ PERIOD_ARCHIVES_COLLECTION,
5194
+ PERIOD_TARGET_PURGES_COLLECTION,
5195
+ PERIOD_REOPENS_COLLECTION
5196
+ ]);
5197
+ function isPeriodsReservedCollection(name) {
5198
+ return PERIODS_RESERVED_COLLECTIONS.has(name);
5199
+ }
5200
+
4696
5201
  // src/port/with/capabilities.ts
4697
5202
  function assertCanExport(keyring, tier, format) {
4698
5203
  if (tier === "plaintext") {
@@ -5065,8 +5570,8 @@ var VaultPeriods = class {
5065
5570
  async closePeriod(options) {
5066
5571
  const existing = await this.loadPeriodsCache();
5067
5572
  this.deps.strategy.validatePeriodName(options.name, existing, options.partition);
5068
- if (typeof options.endDate !== "string" || options.endDate.length === 0) {
5069
- throw new ValidationError("closePeriod: endDate must be a non-empty ISO string.");
5573
+ if (typeof options.endDate !== "string" || !isOrderableBusinessDate(options.endDate)) {
5574
+ throw typeof options.endDate === "string" ? malformedBusinessDate("closePeriod: endDate", options.endDate) : new ValidationError("closePeriod: endDate must be a non-empty ISO string.");
5070
5575
  }
5071
5576
  const anchor = await this.deps.strategy.chainAnchor(existing, options.partition);
5072
5577
  const record = {
@@ -5481,6 +5986,32 @@ var VaultPeriods = class {
5481
5986
  findPeriod(all, name, options) {
5482
5987
  return all.find((p) => p.name === name && samePartition(p.partition, options?.partition));
5483
5988
  }
5989
+ /**
5990
+ * #1439 — could a closed period govern this record? Synchronous, and
5991
+ * deliberately a SUPERSET of what {@link assertTsWritable} would refuse.
5992
+ *
5993
+ * Exists so a caller can tell "the period gate is registered" from "the
5994
+ * period gate can fire for this row". Those were conflated, and the cost was
5995
+ * that installing `withPeriods()` disabled an unrelated optimisation for
5996
+ * every collection in the vault — with no period closed and no collection
5997
+ * registered as a subject (#1439, measured: 0 → 250 redundant MV writes per
5998
+ * source write).
5999
+ *
6000
+ * ⛔ Answers `true` whenever it cannot rule the gate out: the cache is not
6001
+ * loaded yet, a closed period has no `dateField` to test against, or no row
6002
+ * was supplied. A predicate that exists to permit an optimisation must fail
6003
+ * towards "the gate applies", never away from it.
6004
+ */
6005
+ couldGovern(record) {
6006
+ if (this.periodCache === null) return true;
6007
+ const now = (/* @__PURE__ */ new Date()).toISOString();
6008
+ for (const p of this.periodCache) {
6009
+ if (p.kind !== "closed" || isEffectivelyReopened(p, now)) continue;
6010
+ if (!p.dateField || record === void 0) return true;
6011
+ if (record[p.dateField] !== void 0 && record[p.dateField] !== null) return true;
6012
+ }
6013
+ return false;
6014
+ }
5484
6015
  /** Called by the gate bus before put/delete. `collection` selects the subject mapping (#1005). */
5485
6016
  async assertTsWritable(existing, incoming, collection) {
5486
6017
  if (existing === null && incoming === null) return;
@@ -6115,7 +6646,7 @@ var VaultLinks = class {
6115
6646
  // src/with-shape/links/lazy-handle.ts
6116
6647
  function makeLazyLinkSetHandle(d) {
6117
6648
  let engine = null;
6118
- const load = () => engine ??= import("./link-set-FKNWAYKS.js").then(
6649
+ const load = () => engine ??= import("./link-set-JCMJ7ULP.js").then(
6119
6650
  ({ LinkSet }) => new LinkSet(d.adapter, d.vault, d.name, d.spec, d.encrypted, d.getDEK, d.actor, d.emitter, d.endpointExists)
6120
6651
  );
6121
6652
  return {
@@ -6766,7 +7297,7 @@ function declareSatellite(ctx, collectionName, options, existingRegistry) {
6766
7297
  ctx.forEachSyncEngine((e) => e.remirrorPairResolvers([spec.base, spec.satellite]));
6767
7298
  const registry = reg;
6768
7299
  const baseSchema = ctx.getBaseSchema(spec.base);
6769
- void import("./post-register-LNE2FE2A.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
7300
+ void import("./post-register-SLSXIPBV.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
6770
7301
  });
6771
7302
  return reg;
6772
7303
  }
@@ -7305,6 +7836,7 @@ var COLLECTION_PASSTHROUGH_KEYS = [
7305
7836
  "i18nFields",
7306
7837
  "embeddings",
7307
7838
  "textIndexes",
7839
+ "textIndexPositions",
7308
7840
  "warmIndexOnOpen",
7309
7841
  "textIndexPersist",
7310
7842
  "moneyFields",
@@ -7696,6 +8228,7 @@ var Vault = class {
7696
8228
  if (collectionName === SEQUENCE_COLLECTION) throw new ReservedCollectionNameError(collectionName);
7697
8229
  if (isLinkCollectionName(collectionName)) throw new ReservedCollectionNameError(collectionName);
7698
8230
  if (isSecretBearingReservedCollection(collectionName) || isManifestReservedCollection(collectionName)) throw new ReservedCollectionNameError(collectionName);
8231
+ if (isPeriodsReservedCollection(collectionName)) throw new ReservedCollectionNameError(collectionName);
7699
8232
  if (this.satelliteRegistry?.byJoined(collectionName)) {
7700
8233
  throw new SatelliteConfigError(`"${collectionName}" is a joined handle \u2014 use vault.joined('${collectionName}'), not vault.collection().`);
7701
8234
  }
@@ -7741,7 +8274,7 @@ var Vault = class {
7741
8274
  const strategies = options.schemaUpdate ?? [];
7742
8275
  const work = (async () => {
7743
8276
  const dek = await this.getDEK(collectionName);
7744
- const { persistSchemaIfNeeded } = await import("./register-I2DZXGAR.js");
8277
+ const { persistSchemaIfNeeded } = await import("./register-F3OYE7MJ.js");
7745
8278
  const result = await persistSchemaIfNeeded({
7746
8279
  store: this.adapter,
7747
8280
  vault: this.name,
@@ -7891,7 +8424,7 @@ var Vault = class {
7891
8424
  const work = (async () => {
7892
8425
  try {
7893
8426
  const dek = await this.getDEK(collectionName);
7894
- await (await import("./register-I2DZXGAR.js")).persistSchemaIfNeeded({
8427
+ await (await import("./register-F3OYE7MJ.js")).persistSchemaIfNeeded({
7895
8428
  store: this.adapter,
7896
8429
  vault: this.name,
7897
8430
  collectionName,
@@ -7937,7 +8470,7 @@ var Vault = class {
7937
8470
  * writes (unfenced walk — see `with-shape/satellites/migrate-cek.ts`); resumable.
7938
8471
  */
7939
8472
  async migrateSatellitePerRecordKeys(satelliteName) {
7940
- const { migrateSatelliteCek } = await import("./migrate-cek-5ENH64AA.js");
8473
+ const { migrateSatelliteCek } = await import("./migrate-cek-V7GKJZ7O.js");
7941
8474
  return migrateSatelliteCek(satelliteName, this.collection(satelliteName, { perRecordKeys: true }));
7942
8475
  }
7943
8476
  /**
@@ -7980,6 +8513,10 @@ var Vault = class {
7980
8513
  if (!coll) return;
7981
8514
  await coll._applyRemoteChange(docId, action);
7982
8515
  }
8516
+ /** @internal #1362 — verb-less variant; no-op for a collection this instance never opened. */
8517
+ async _applyRemoteSignal(collectionName, docId) {
8518
+ await this.collectionCache.get(collectionName)?._applyRemoteSignal(docId);
8519
+ }
7983
8520
  /** @internal #598: refresh cache entries a sync-applied write rewrote underneath us. No-op if not loaded this session.
7984
8521
  * #650 Task 4 (#647): a reserved-lookup collection has no `Collection` instance — instead, refresh
7985
8522
  * its already-warmed `LookupHandle._syncCache` (membership/altIndex/snapshot reads never see a
@@ -8568,7 +9105,7 @@ var Vault = class {
8568
9105
  */
8569
9106
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
8570
9107
  async _loadPodSigner() {
8571
- const { loadSigner } = await import("./signer-WAMDZHEN.js");
9108
+ const { loadSigner } = await import("./signer-MBZZMXTC.js");
8572
9109
  return loadSigner(this.adapter, this.name, this.getDEK);
8573
9110
  }
8574
9111
  async writeExportAudit(entry) {
@@ -9058,7 +9595,7 @@ var Vault = class {
9058
9595
  async _initGuards(handles) {
9059
9596
  if (handles.length === 0) return;
9060
9597
  const [{ GuardRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
9061
- import("./registry-4AYVUNXK.js"),
9598
+ import("./registry-CILQFXFK.js"),
9062
9599
  import("./read-only-facade-BIGO37U3.js")
9063
9600
  ]);
9064
9601
  const registry = new GuardRegistry();
@@ -9086,7 +9623,7 @@ var Vault = class {
9086
9623
  async _initDerivations(handles) {
9087
9624
  if (handles.length === 0) return;
9088
9625
  const [{ DerivationRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
9089
- import("./registry-YLEWMGAC.js"),
9626
+ import("./registry-YCDZV3VW.js"),
9090
9627
  import("./read-only-facade-BIGO37U3.js")
9091
9628
  ]);
9092
9629
  const registry = new DerivationRegistry();
@@ -9118,7 +9655,7 @@ var Vault = class {
9118
9655
  */
9119
9656
  async _initMaterializedViews(handles) {
9120
9657
  if (handles.length === 0) return;
9121
- const { MaterializedViewRegistry } = await import("./registry-VSSQPIGF.js");
9658
+ const { MaterializedViewRegistry } = await import("./registry-ZGYS33TE.js");
9122
9659
  const registry = new MaterializedViewRegistry();
9123
9660
  this.materializedViewRegistry = registry;
9124
9661
  const db = this;
@@ -9143,7 +9680,7 @@ var Vault = class {
9143
9680
  */
9144
9681
  async _initOverlayedViews(handles) {
9145
9682
  if (handles.length === 0) return;
9146
- const { OverlayedViewRegistry } = await import("./registry-23WF3TGH.js");
9683
+ const { OverlayedViewRegistry } = await import("./registry-XNNYQVKV.js");
9147
9684
  const registry = new OverlayedViewRegistry();
9148
9685
  const mvRegistry = this.materializedViewRegistry;
9149
9686
  const overlayNames = /* @__PURE__ */ new Set();
@@ -9193,27 +9730,27 @@ var Vault = class {
9193
9730
  /**
9194
9731
  * Manual re-materialize for a single registered MV (`refresh: 'manual'` consumers,
9195
9732
  * stale-bit recovery on vault reopen, bulk-recompute escape hatch after a strategy
9196
- * change). Returns `{ written, deleted, failed, residueUndecodable, residueDeclined }` (`deleted`
9197
- * always 0 without tombstoning; #785 splits the #782 leftovers — undecodable vs #718-declined). Throws if not registered.
9733
+ * change). Returns `{ written, skipped, deleted, failed, residueUndecodable, residueDeclined }` (`skipped` counts rows whose
9734
+ * content was unchanged since the last refresh, #1418; `deleted` always 0 without tombstoning; #785 splits the #782 leftovers — undecodable vs #718-declined). Throws if not registered.
9198
9735
  */
9199
9736
  async refreshView(name) {
9200
9737
  const registry = this.materializedViewRegistry;
9201
9738
  if (registry === null) {
9202
- return { written: 0, deleted: 0, failed: 0, residueUndecodable: [], residueDeclined: [] };
9739
+ return { written: 0, skipped: 0, deleted: 0, failed: 0, residueUndecodable: [], residueDeclined: [] };
9203
9740
  }
9204
9741
  await registry.resolvePendingPlans();
9205
9742
  const reg = registry.byName(name);
9206
9743
  if (!reg) {
9207
9744
  throw new Error(`refreshView: no MV registered with name "${name}"`);
9208
9745
  }
9209
- const { MaterializedViewExecutor } = await import("./executor-PUAO6AKJ.js");
9746
+ const { MaterializedViewExecutor } = await import("./executor-B6SRO2QS.js");
9210
9747
  const result = await MaterializedViewExecutor.refresh(reg, {
9211
9748
  getCollection: (n) => this.collection(n),
9212
9749
  getActiveTxContext: () => this.noydb._activeTxContextOrNull,
9213
9750
  getQueryContext: () => this,
9214
9751
  dispatchCtx: this._dispatchCtx({ collection: name, id: "refreshView" })
9215
9752
  });
9216
- const { clearMVStaleFully } = await import("./stale-DDL7WQEZ.js");
9753
+ const { clearMVStaleFully } = await import("./stale-TJ3DYZMQ.js");
9217
9754
  await clearMVStaleFully(this.adapter, this.name, registry, name);
9218
9755
  return result;
9219
9756
  }
@@ -9226,7 +9763,7 @@ var Vault = class {
9226
9763
  if (registry === null) return { derived: 0, failed: 0, skippedFrozen: 0 };
9227
9764
  const strategies = registry.strategiesForSource(sourceCollection);
9228
9765
  if (strategies.length === 0) return { derived: 0, failed: 0, skippedFrozen: 0 };
9229
- const { DerivationExecutor } = await import("./executor-5NIMLSKZ.js");
9766
+ const { DerivationExecutor } = await import("./executor-RBKM5W5K.js");
9230
9767
  const sourceColl = this.collection(sourceCollection);
9231
9768
  const records = await sourceColl.list();
9232
9769
  const ctx = { vault: this.derivationFacade ?? new (await import("./read-only-facade-BIGO37U3.js")).ReadOnlyVaultFacade(this, "derivation") };
@@ -9253,7 +9790,7 @@ var Vault = class {
9253
9790
  if (!outSpec) continue;
9254
9791
  const outputColl = this.collection(outSpec.collection);
9255
9792
  if (out.kind === "array") {
9256
- const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-WUFXNYP4.js");
9793
+ const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-OT6RYLOL.js");
9257
9794
  const prior = await loadFanoutSidecar(this.adapter, this.name, spec.source, id, key, this.getDEK, this.encrypted);
9258
9795
  const prevKeys = new Set(prior?.keys ?? []);
9259
9796
  const newKeysList = out.entries.map((e) => e.key);
@@ -9480,7 +10017,7 @@ var Vault = class {
9480
10017
  * collection.
9481
10018
  */
9482
10019
  async delegate(opts) {
9483
- const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-OVIFFPG4.js");
10020
+ const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-S3AEPW2T.js");
9484
10021
  if (!this.keyring.kek) {
9485
10022
  throw new ValidationError(
9486
10023
  "issueDelegation: keyring.kek is null \u2014 issuing a delegation requires a tier-1 unlock. Re-authenticate at tier 1 (secret) first."
@@ -9502,7 +10039,7 @@ var Vault = class {
9502
10039
  * if the id does not exist.
9503
10040
  */
9504
10041
  async revokeDelegation(id) {
9505
- const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-OVIFFPG4.js");
10042
+ const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-S3AEPW2T.js");
9506
10043
  await revokeDelegation(this.adapter, this.name, id);
9507
10044
  void DELEGATIONS_COLLECTION;
9508
10045
  }
@@ -9730,6 +10267,10 @@ var Vault = class {
9730
10267
  async _assertTsWritable(existing, incoming, collection) {
9731
10268
  return this.periods.assertTsWritable(existing, incoming, collection);
9732
10269
  }
10270
+ /** #1439 — sync superset test: could a closed period govern this row? See `periods/vault-facade.ts#couldGovern`. @internal */
10271
+ _periodCouldGovern(record) {
10272
+ return this.periods.couldGovern(record);
10273
+ }
9733
10274
  /** List all collection names in this vault. */
9734
10275
  async collections() {
9735
10276
  const snapshot = await this.adapter.loadAll(this.name);
@@ -9755,7 +10296,7 @@ var Vault = class {
9755
10296
  * @see design-history/2026-05-22-schema-dump-design.md
9756
10297
  */
9757
10298
  async dumpSchema(opts = {}) {
9758
- const { dumpVaultSchema } = await import("./walk-3UQBRMDV.js");
10299
+ const { dumpVaultSchema } = await import("./walk-HJ42EISE.js");
9759
10300
  return dumpVaultSchema(this, opts);
9760
10301
  }
9761
10302
  /**
@@ -9851,7 +10392,7 @@ var Vault = class {
9851
10392
  * separate vault instances now.
9852
10393
  */
9853
10394
  async getPodHandle() {
9854
- const { buildPodHandle } = await import("./pod-handle-Q736KYON.js");
10395
+ const { buildPodHandle } = await import("./pod-handle-WGDFB4C2.js");
9855
10396
  return buildPodHandle(this.adapter, this.name);
9856
10397
  }
9857
10398
  /**
@@ -9865,7 +10406,7 @@ var Vault = class {
9865
10406
  * single, already-opened `Vault` instance so the
9866
10407
  * bundle writer can snapshot it without holding a `Noydb` reference.
9867
10408
  *
9868
- * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/public-envelope.md
10409
+ * @see https://github.com/noy-db/docs/blob/main/content/docs/services/public-envelope.md
9869
10410
  */
9870
10411
  async getCover(opts = {}) {
9871
10412
  const { readCover } = await import("./cover/index.js");
@@ -9883,7 +10424,7 @@ var Vault = class {
9883
10424
  * both modes round-trip cleanly.
9884
10425
  */
9885
10426
  async dump() {
9886
- const { dumpVault } = await import("./backup-IJTB4S4M.js");
10427
+ const { dumpVault } = await import("./backup-7TFRVFLH.js");
9887
10428
  return dumpVault(this.backupContext());
9888
10429
  }
9889
10430
  /**
@@ -9935,7 +10476,7 @@ var Vault = class {
9935
10476
  * — there's no chain to verify against.
9936
10477
  */
9937
10478
  async load(backupJson) {
9938
- const { loadVault } = await import("./backup-IJTB4S4M.js");
10479
+ const { loadVault } = await import("./backup-7TFRVFLH.js");
9939
10480
  return loadVault(this.backupContext(), backupJson);
9940
10481
  }
9941
10482
  /**
@@ -9967,7 +10508,7 @@ var Vault = class {
9967
10508
  * way to detect tampering of an in-place vault.
9968
10509
  */
9969
10510
  async verifyBackupIntegrity() {
9970
- const { verifyBackupIntegrity } = await import("./backup-IJTB4S4M.js");
10511
+ const { verifyBackupIntegrity } = await import("./backup-7TFRVFLH.js");
9971
10512
  return verifyBackupIntegrity(this.backupContext());
9972
10513
  }
9973
10514
  /**
@@ -10197,7 +10738,7 @@ var Vault = class {
10197
10738
  * is the live validator object, not a serialization of it).
10198
10739
  */
10199
10740
  async exportJSON(opts = {}) {
10200
- const { exportVaultJSON } = await import("./backup-IJTB4S4M.js");
10741
+ const { exportVaultJSON } = await import("./backup-7TFRVFLH.js");
10201
10742
  return exportVaultJSON(this.backupContext(), opts);
10202
10743
  }
10203
10744
  };
@@ -10439,7 +10980,7 @@ var ServiceBus = class {
10439
10980
  arr = [];
10440
10981
  this.#gateHandlers.set(point, arr);
10441
10982
  }
10442
- const entry = { fn: handler, needsPrior: opts?.needsPrior !== false };
10983
+ const entry = { fn: handler, needsPrior: opts?.needsPrior !== false, scope: opts?.scope };
10443
10984
  arr.push(entry);
10444
10985
  return () => {
10445
10986
  const a = this.#gateHandlers.get(point);
@@ -10453,6 +10994,30 @@ var ServiceBus = class {
10453
10994
  const a = this.#gateHandlers.get(point);
10454
10995
  return a !== void 0 && a.length > 0;
10455
10996
  }
10997
+ /**
10998
+ * #1439 — could a gate at `point` fire for THIS target?
10999
+ *
11000
+ * ⚠️ This is the question callers almost always mean, and
11001
+ * {@link hasGateHandlers} is not it. That one is about the bus, which is
11002
+ * shared by the whole vault; this one consults each handler's declared
11003
+ * {@link GateScope}. A handler that declares none counts as "may fire", so a
11004
+ * registrant which has not thought about scope keeps today's behaviour.
11005
+ *
11006
+ * ⛔ A scope that throws is treated as "may fire". A predicate whose job is
11007
+ * to permit an optimisation must never be able to disable a gate by failing.
11008
+ */
11009
+ gateAppliesTo(point, target) {
11010
+ const a = this.#gateHandlers.get(point);
11011
+ if (a === void 0 || a.length === 0) return false;
11012
+ return a.some((e) => {
11013
+ if (e.scope === void 0) return true;
11014
+ try {
11015
+ return e.scope(target);
11016
+ } catch {
11017
+ return true;
11018
+ }
11019
+ });
11020
+ }
10456
11021
  /**
10457
11022
  * True when at least one gate handler at `point` needs the prior record
10458
11023
  * (the default). False when the point has no handlers or every handler
@@ -10981,10 +11546,24 @@ var NoydbSnapshots = class {
10981
11546
  };
10982
11547
 
10983
11548
  // src/kernel/memory-store.ts
10984
- function memoryStore() {
11549
+ var MEMORY_STORE_OPTION_KEYS = ["full", "clockUncertaintyMs"];
11550
+ function memoryStore(options = {}) {
11551
+ for (const k of Object.keys(options)) {
11552
+ if (!MEMORY_STORE_OPTION_KEYS.includes(k)) {
11553
+ throw new Error(
11554
+ `memoryStore: unknown option \`${k}\`. Known options: ${MEMORY_STORE_OPTION_KEYS.join(", ")}.`
11555
+ );
11556
+ }
11557
+ }
11558
+ const full = options.full === true;
11559
+ if (options.clockUncertaintyMs !== void 0 && !full) {
11560
+ throw new Error(
11561
+ "memoryStore: `clockUncertaintyMs` requires `full: true` \u2014 the default store clock is a counter, not milliseconds, so an ms epsilon around it would be meaningless."
11562
+ );
11563
+ }
11564
+ const epsilon = options.clockUncertaintyMs ?? 0;
10985
11565
  const store = /* @__PURE__ */ new Map();
10986
11566
  let clock = 0;
10987
- const epsilon = 0;
10988
11567
  const coll = (vault, collection) => {
10989
11568
  let comp = store.get(vault);
10990
11569
  if (!comp) {
@@ -10998,11 +11577,16 @@ function memoryStore() {
10998
11577
  }
10999
11578
  return c;
11000
11579
  };
11001
- return {
11580
+ const core = {
11002
11581
  name: "memory",
11003
- capabilities: { casAtomic: true, serverWriteTime: true, auth: { kind: "none", required: false, flow: "static" } },
11582
+ capabilities: {
11583
+ casAtomic: true,
11584
+ serverWriteTime: true,
11585
+ ...full ? { txAtomic: true } : {},
11586
+ auth: { kind: "none", required: false, flow: "static" }
11587
+ },
11004
11588
  async getStoreTime() {
11005
- const now = ++clock;
11589
+ const now = full ? clock = Math.max(clock + 1, Date.now()) : ++clock;
11006
11590
  return { earliest: now - epsilon, latest: now + epsilon };
11007
11591
  },
11008
11592
  async get(vault, collection, id) {
@@ -11061,6 +11645,50 @@ function memoryStore() {
11061
11645
  return { items, nextCursor: end < ids.length ? String(end) : null };
11062
11646
  }
11063
11647
  };
11648
+ if (!full) return core;
11649
+ return {
11650
+ ...core,
11651
+ async ping() {
11652
+ return true;
11653
+ },
11654
+ /**
11655
+ * Enumerate every top-level vault held by this store — the outer Map's
11656
+ * keys, O(vaults). Intentionally unsorted; sort at the call site if you
11657
+ * need a stable order.
11658
+ */
11659
+ async listVaults() {
11660
+ return [...store.keys()];
11661
+ },
11662
+ /**
11663
+ * Multi-record atomic transaction. Validates every op's
11664
+ * `expectedVersion` against current state first and throws on the first
11665
+ * mismatch with nothing written, then applies every op in one
11666
+ * synchronous burst — the Map mutations cannot interleave in the JS
11667
+ * event loop, so this is truly atomic.
11668
+ */
11669
+ async tx(ops) {
11670
+ for (const op of ops) {
11671
+ if (op.type === "put" && !op.envelope) {
11672
+ throw new Error(`tx: put op for ${op.id} is missing envelope`);
11673
+ }
11674
+ if (op.expectedVersion === void 0) continue;
11675
+ const actual = store.get(op.vault)?.get(op.collection)?.get(op.id)?._v ?? 0;
11676
+ if (actual !== op.expectedVersion) {
11677
+ throw new ConflictError(
11678
+ actual,
11679
+ `tx: ${op.vault}/${op.collection}/${op.id} expected v${op.expectedVersion}, found v${actual}`
11680
+ );
11681
+ }
11682
+ }
11683
+ for (const op of ops) {
11684
+ if (op.type === "put") {
11685
+ coll(op.vault, op.collection).set(op.id, op.envelope);
11686
+ } else {
11687
+ store.get(op.vault)?.get(op.collection)?.delete(op.id);
11688
+ }
11689
+ }
11690
+ }
11691
+ };
11064
11692
  }
11065
11693
 
11066
11694
  // src/with-party/team/noydb-facade.ts
@@ -11091,6 +11719,9 @@ var TeamFacade = class {
11091
11719
  this.deps.checkPolicyOperation(vault, "grant");
11092
11720
  await this.deps.checkGate(vault, "enroll-user", factors);
11093
11721
  const keyring = await this.deps.getKeyringInternal(vault);
11722
+ if (this.deps.options.periodsStrategy !== void 0) {
11723
+ await (await ensureCollectionDEK(this.deps.options.store, vault, keyring))(PERIODS_COLLECTION);
11724
+ }
11094
11725
  await engine(this.deps.options.store, vault, keyring, options);
11095
11726
  }
11096
11727
  /** Gate + run a `revoke` engine. See `Noydb.revoke` for the public contract. */
@@ -11142,9 +11773,18 @@ var TeamFacade = class {
11142
11773
  this.deps.keyringCache.set(vault, next);
11143
11774
  }
11144
11775
  /**
11145
- * Remove a tier-2 authenticator slot. Idempotent — removing a
11146
- * non-existent slot is a successful no-op. Gated by
11776
+ * Remove a tier-2 authenticator slot. Idempotent — removing a slot
11777
+ * that is not in the keyring is a successful no-op. Gated by
11147
11778
  * `remove-authenticator`.
11779
+ *
11780
+ * ⚠️ Idempotency needs the slot list to be VISIBLE, and a tier-3
11781
+ * PIN-resumed / session-restored keyring carries an empty one
11782
+ * (#1426). Such a session throws `ValidationError` rather than
11783
+ * reporting a removal it did not perform — re-authenticate at tier 1
11784
+ * first.
11785
+ *
11786
+ * @throws `ValidationError` when the active keyring cannot see its
11787
+ * slot list (`kek === null`).
11148
11788
  */
11149
11789
  async removeAuthenticator(vault, slotId, factors) {
11150
11790
  await this.deps.checkGate(vault, "remove-authenticator", factors);
@@ -12125,10 +12765,14 @@ var Noydb = class {
12125
12765
  if (!facade) return;
12126
12766
  const ctx = { existing, vault: facade, userId: e.userId, role: e.role };
12127
12767
  await registry.runChecks(e.collection, incoming, ctx);
12128
- const { GuardExecutor } = await import("./executor-AQVXV5GZ.js");
12768
+ const { GuardExecutor } = await import("./executor-BI5CHWRY.js");
12129
12769
  for (const g of guards) {
12130
12770
  await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming, e.computedFieldNames);
12131
12771
  }
12772
+ }, {
12773
+ // #1439 — this handler's own first two early-returns, hoisted so a caller can ask
12774
+ // "could a guard fire HERE" without writing. See `ServiceBus.gateAppliesTo`.
12775
+ scope: ({ vault, collection }) => (this.vaultCache.get(vault)?._getGuardRegistry()?.guardsFor(collection).length ?? 0) > 0
12132
12776
  });
12133
12777
  this.subsystemBus.registerGate("beforeDelete", async (e) => {
12134
12778
  const v = this.vaultCache.get(e.vault);
@@ -12172,6 +12816,9 @@ var Noydb = class {
12172
12816
  if (!v) return;
12173
12817
  const existing = e.op === "create" ? null : { ts: e.existingTs ?? null, record: e.existing ?? null };
12174
12818
  await v._assertTsWritable(existing, e.incoming, e.collection);
12819
+ }, {
12820
+ // #1439 — a period governs a row only through its `dateField`; see `couldGovern`.
12821
+ scope: ({ vault, record }) => this.vaultCache.get(vault)?._periodCouldGovern(record) ?? true
12175
12822
  });
12176
12823
  this.subsystemBus.registerGate("beforeDelete", async (e) => {
12177
12824
  if (e.internal) return;
@@ -13061,6 +13708,15 @@ var Noydb = class {
13061
13708
  }
13062
13709
  return { dispose: () => this.disableTabCoordination() };
13063
13710
  }
13711
+ /** @internal #1362 — `ChangeBroadcastHost`: re-read one broadcast address through THIS
13712
+ * instance's own keyring. No-op for a vault this instance has not opened. */
13713
+ _applyRemoteSignal(vaultName, collectionName, id) {
13714
+ return this.vaultCache.get(vaultName)?._applyRemoteSignal(collectionName, id) ?? Promise.resolve();
13715
+ }
13716
+ /** @internal #1362 — `ChangeBroadcastHost`: store backend name, for the default channel name. */
13717
+ get _storeName() {
13718
+ return this.options.store.name;
13719
+ }
13064
13720
  #applyRemoteWrite(vaultName, collectionName, docId, action) {
13065
13721
  const v = this.vaultCache.get(vaultName);
13066
13722
  if (!v) return Promise.resolve();
@@ -13284,7 +13940,7 @@ var Noydb = class {
13284
13940
  * keyring file at `_keyring/<userId>` and the envelope ciphertext at
13285
13941
  * `_users/<keyringId>` remain observable to anyone with direct store
13286
13942
  * read access — only the hub-level enumeration is gated. See
13287
- * `https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/user-envelope.md` → "Directory visibility".
13943
+ * `https://github.com/noy-db/docs/blob/main/content/docs/services/user-envelope.md` → "Directory visibility".
13288
13944
  */
13289
13945
  async setDirectoryEnabled(vault, enabled) {
13290
13946
  if (this.closed) throw new ValidationError("Instance is closed");
@@ -13368,7 +14024,7 @@ var Noydb = class {
13368
14024
  this.activeTier.set(vault, tier);
13369
14025
  }
13370
14026
  // ─── Tier-2 enroll / remove ─────────────────────────────────────
13371
- // ─── Cover (https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/public-envelope.md) ──────
14027
+ // ─── Cover (https://github.com/noy-db/docs/blob/main/content/docs/services/public-envelope.md) ──────
13372
14028
  /**
13373
14029
  * Set the owner-curated cover for a vault. Throws
13374
14030
  * `ValidationError` if the developer did not opt the hub into
@@ -13497,7 +14153,7 @@ async function createNoydb(options) {
13497
14153
  if (!options.store) options = { ...options, store: memoryStore() };
13498
14154
  validateSecretModeOptions(options);
13499
14155
  if (!options.mesh) options = { ...options, mesh: await createDefaultMesh(options.store) };
13500
- if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-TXFOVOXX.js")).createUserApi };
14156
+ if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-GVYEKSJE.js")).createUserApi };
13501
14157
  if (!options.policyFactory) {
13502
14158
  const policyModule = await import("./policy/index.js");
13503
14159
  options = { ...options, policyFactory: policyModule.createNoydbPolicy, policyCheckGateFn: policyModule.checkGate };
@@ -13530,4 +14186,4 @@ export {
13530
14186
  Noydb,
13531
14187
  createNoydb
13532
14188
  };
13533
- //# sourceMappingURL=chunk-6GOE5PGN.js.map
14189
+ //# sourceMappingURL=chunk-T2LBQ5DV.js.map