@noy-db/hub 0.3.0-pre.12 → 0.3.0-pre.13

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 (373) hide show
  1. package/dist/aggregate/index.js +4 -4
  2. package/dist/api-ZGS6LCOF.js +20 -0
  3. package/dist/as/index.js +11 -11
  4. package/dist/attestation/index.js +18 -18
  5. package/dist/{backup-2WVBIVXW.js → backup-BJ57IKAO.js} +28 -11
  6. package/dist/backup-BJ57IKAO.js.map +1 -0
  7. package/dist/blobs/index.js +12 -10
  8. package/dist/blobs/index.js.map +1 -1
  9. package/dist/broker/index.js +12 -12
  10. package/dist/bundle/index.js +25 -22
  11. package/dist/bundle/index.js.map +1 -1
  12. package/dist/by/index.js +2 -2
  13. package/dist/cargo/index.js +22 -22
  14. package/dist/{chunk-ZL6PRULX.js → chunk-2NVOWNI3.js} +4 -4
  15. package/dist/{chunk-WEHIQYQH.js → chunk-3B5VVCNY.js} +2 -2
  16. package/dist/{chunk-FF7S3XDW.js → chunk-3LQ2YKO4.js} +2 -2
  17. package/dist/{chunk-NAR6IDKH.js → chunk-3QCRBHCY.js} +2 -2
  18. package/dist/{chunk-SXPCZ6LL.js → chunk-454JXE57.js} +3 -3
  19. package/dist/{chunk-R3NHNVS5.js → chunk-4CTHCN4J.js} +12 -10
  20. package/dist/{chunk-R3NHNVS5.js.map → chunk-4CTHCN4J.js.map} +1 -1
  21. package/dist/{chunk-JGUZMC3I.js → chunk-4JBYV75E.js} +5 -5
  22. package/dist/{chunk-RXTMLYJS.js → chunk-4NXKCLLQ.js} +2 -2
  23. package/dist/{chunk-GXLZXD2W.js → chunk-4VNQOLML.js} +2 -2
  24. package/dist/{chunk-45QPICLE.js → chunk-5M5DVGV7.js} +2 -2
  25. package/dist/{chunk-EHW5KTTA.js → chunk-5O3XF4DV.js} +4 -4
  26. package/dist/chunk-5O3XF4DV.js.map +1 -0
  27. package/dist/{chunk-S2OWPVSO.js → chunk-5YOLBEQ6.js} +2 -2
  28. package/dist/{chunk-BDEMZD4F.js → chunk-6CRIV7DE.js} +2 -2
  29. package/dist/{chunk-VCUQR6ZL.js → chunk-6JTIAGHD.js} +3 -3
  30. package/dist/{chunk-K2DLLK34.js → chunk-6QTNZJBS.js} +3 -3
  31. package/dist/{chunk-UMC5QZTX.js → chunk-6T2SCQRU.js} +4 -4
  32. package/dist/{chunk-J3JIYFYL.js → chunk-7DSTRQIJ.js} +2 -2
  33. package/dist/{chunk-3QSOFZQB.js → chunk-AUSTCW2X.js} +10 -10
  34. package/dist/{chunk-PN5332SU.js → chunk-B3HJYUOF.js} +2 -2
  35. package/dist/{chunk-DIB2BOIH.js → chunk-BDVFPG6Y.js} +5 -5
  36. package/dist/{chunk-FZCGIJEJ.js → chunk-BIOUI4HL.js} +50 -1
  37. package/dist/chunk-BIOUI4HL.js.map +1 -0
  38. package/dist/{chunk-FYNE4WLC.js → chunk-CAF6WOK7.js} +2 -2
  39. package/dist/{chunk-AKEOHKMT.js → chunk-CDUQTA3Z.js} +110 -11
  40. package/dist/chunk-CDUQTA3Z.js.map +1 -0
  41. package/dist/{chunk-37WOJQWY.js → chunk-CIE2BASH.js} +2 -2
  42. package/dist/{chunk-BLUT46UP.js → chunk-CRI4OUV4.js} +2 -2
  43. package/dist/{chunk-Y5TWPBNW.js → chunk-DLG74CNB.js} +4 -4
  44. package/dist/{chunk-HIOLCOK3.js → chunk-E5ZQT5KX.js} +2 -2
  45. package/dist/{chunk-IQIVD7TP.js → chunk-EQO2UVP4.js} +6 -6
  46. package/dist/{chunk-US34HTOI.js → chunk-ERJ7FU55.js} +3 -3
  47. package/dist/{chunk-S7TAPIRS.js → chunk-EVVGJDRQ.js} +3 -3
  48. package/dist/{chunk-EXGDL2UQ.js → chunk-EVX47VBM.js} +2 -2
  49. package/dist/{chunk-NT2ZO4KI.js → chunk-EXK7QRWF.js} +5 -5
  50. package/dist/{chunk-7QLY64AD.js → chunk-EYZ6IQ6X.js} +5 -5
  51. package/dist/{chunk-QF5LGMSV.js → chunk-F64IRYG3.js} +2 -2
  52. package/dist/{chunk-PH7G7ZI7.js → chunk-FHS2HQSH.js} +5 -5
  53. package/dist/{chunk-HG76BZ6G.js → chunk-FM3G3NOY.js} +27 -9
  54. package/dist/chunk-FM3G3NOY.js.map +1 -0
  55. package/dist/{chunk-ZHOJOT6S.js → chunk-FUG4SFN3.js} +2 -2
  56. package/dist/{chunk-JRKE5MAZ.js → chunk-GKEWXIV5.js} +2 -2
  57. package/dist/{chunk-6MA575R5.js → chunk-GTGPO5KW.js} +5 -5
  58. package/dist/{chunk-XS6DLN67.js → chunk-HB3RFQSC.js} +3 -3
  59. package/dist/{chunk-VXZNSPJM.js → chunk-HDMEGAQE.js} +5 -5
  60. package/dist/chunk-HDQIIUPH.js +135 -0
  61. package/dist/chunk-HDQIIUPH.js.map +1 -0
  62. package/dist/{chunk-DJ7MRXNA.js → chunk-HTJQYHZP.js} +2 -2
  63. package/dist/{chunk-NRYNRSGV.js → chunk-I6GALP6E.js} +6 -6
  64. package/dist/{chunk-GL3JV5EV.js → chunk-IL6POWCW.js} +6 -6
  65. package/dist/{chunk-NEYKOESM.js → chunk-IU6SNYX6.js} +5 -5
  66. package/dist/{chunk-CCIR2OJH.js → chunk-J2ZX2XUV.js} +5 -5
  67. package/dist/{chunk-F3LGBRSV.js → chunk-JIF24JPM.js} +57 -15
  68. package/dist/chunk-JIF24JPM.js.map +1 -0
  69. package/dist/{chunk-NM3IFKBL.js → chunk-JKJOGPZN.js} +2 -2
  70. package/dist/{chunk-JC75UBMT.js → chunk-JNAI2HN2.js} +1 -1
  71. package/dist/{chunk-JC75UBMT.js.map → chunk-JNAI2HN2.js.map} +1 -1
  72. package/dist/{chunk-TVS6BUUR.js → chunk-JZUV47FZ.js} +2 -2
  73. package/dist/{chunk-5HNX4OD4.js → chunk-K5IMOGHB.js} +2 -2
  74. package/dist/{chunk-XJ47GS53.js → chunk-KSKBRKGJ.js} +3 -3
  75. package/dist/{chunk-INBQ43DI.js → chunk-LASZKVMO.js} +3 -3
  76. package/dist/{chunk-EVHBK7BN.js → chunk-LXEXBTKL.js} +4 -4
  77. package/dist/{chunk-6S7ENMRE.js → chunk-M4CV6BRT.js} +2 -2
  78. package/dist/{chunk-AAIIDAUC.js → chunk-MEFJPTZ4.js} +3 -3
  79. package/dist/{chunk-WHQHTNT7.js → chunk-MV43JSJF.js} +4 -4
  80. package/dist/{chunk-F44XWXOA.js → chunk-NJ4EOKMB.js} +4 -4
  81. package/dist/{chunk-ILF5GARW.js → chunk-NR5LT5RY.js} +7 -7
  82. package/dist/{chunk-TBNF5DV5.js → chunk-NWSGI5C7.js} +3 -3
  83. package/dist/{chunk-BDPAVYGJ.js → chunk-OSDB5WW3.js} +92 -15
  84. package/dist/chunk-OSDB5WW3.js.map +1 -0
  85. package/dist/chunk-PN2XMATY.js +37 -0
  86. package/dist/chunk-PN2XMATY.js.map +1 -0
  87. package/dist/{chunk-EIZ4YOG2.js → chunk-Q5VNKNE5.js} +3 -3
  88. package/dist/{chunk-TVOHSPVK.js → chunk-QLWMEXCT.js} +2 -2
  89. package/dist/{chunk-7GAXFU2O.js → chunk-QRB7NAOJ.js} +2 -2
  90. package/dist/{chunk-X6Y5MXTH.js → chunk-R4ROFEYC.js} +2 -2
  91. package/dist/{chunk-4BQXMCE5.js → chunk-RCVJZMFE.js} +4 -4
  92. package/dist/{chunk-QG5RQQBO.js → chunk-RIX4V2TB.js} +3 -3
  93. package/dist/{chunk-SAL5X5OK.js → chunk-RYCTDFUX.js} +2 -2
  94. package/dist/{chunk-CXC3JLAQ.js → chunk-RZ5SVOYR.js} +2 -2
  95. package/dist/{chunk-44IL5G3W.js → chunk-SLFHQTTW.js} +5 -5
  96. package/dist/chunk-SNZ6URZZ.js +2782 -0
  97. package/dist/chunk-SNZ6URZZ.js.map +1 -0
  98. package/dist/{chunk-2MTRJCBI.js → chunk-T2FFWNPK.js} +3 -3
  99. package/dist/{chunk-QYPDYN23.js → chunk-UNFPPVNI.js} +2 -2
  100. package/dist/{chunk-RNXJ2VO6.js → chunk-VFUPHI2Z.js} +63 -10
  101. package/dist/chunk-VFUPHI2Z.js.map +1 -0
  102. package/dist/{chunk-7ZOSHEVS.js → chunk-VLFCJYTL.js} +9 -9
  103. package/dist/{chunk-APHLCXVC.js → chunk-VN3DBQAU.js} +2 -2
  104. package/dist/{chunk-HK4XTXO4.js → chunk-VZRODIM3.js} +4 -4
  105. package/dist/{chunk-P2LJI6JE.js → chunk-W22IKJE2.js} +2 -2
  106. package/dist/{chunk-FJTWLQV3.js → chunk-X3YYQWOQ.js} +3 -3
  107. package/dist/{chunk-YCXKFB7J.js → chunk-X7QBD67R.js} +498 -274
  108. package/dist/chunk-X7QBD67R.js.map +1 -0
  109. package/dist/{chunk-HA6ZQWA2.js → chunk-XDYREZWE.js} +82 -10
  110. package/dist/chunk-XDYREZWE.js.map +1 -0
  111. package/dist/{chunk-HBBZWEC5.js → chunk-XWZVFISC.js} +40 -6
  112. package/dist/{chunk-HBBZWEC5.js.map → chunk-XWZVFISC.js.map} +1 -1
  113. package/dist/{chunk-SGJGWBSC.js → chunk-YFXZEAYK.js} +6 -6
  114. package/dist/{chunk-SIAIYP6G.js → chunk-ZAJAVEXY.js} +2 -2
  115. package/dist/{chunk-KKYEZCQG.js → chunk-ZICD77GM.js} +2 -2
  116. package/dist/{chunk-HGAB325C.js → chunk-ZJ2AK4V7.js} +2 -2
  117. package/dist/{chunk-HYG32HCM.js → chunk-ZUODRVHY.js} +2 -2
  118. package/dist/classified/index.js +5 -5
  119. package/dist/{classified-marker-M7K3OJPM.js → classified-marker-CZKA6ITE.js} +3 -3
  120. package/dist/collection-facade-TLWIPI76.js +44 -0
  121. package/dist/{computed-ORCGM5JE.js → computed-ZIQTYTDI.js} +3 -3
  122. package/dist/consent/index.js +9 -9
  123. package/dist/{dead-filter-OV5FGKOG.js → dead-filter-ESOBZZP5.js} +2 -2
  124. package/dist/delegation-W7ZV2322.js +25 -0
  125. package/dist/derivations/index.js +12 -12
  126. package/dist/derive-H2BJTLUI.js +21 -0
  127. package/dist/{enclave-XXFUKJC6.js → enclave-AP3I5W7O.js} +15 -9
  128. package/dist/executor-KGWTNEQD.js +9 -0
  129. package/dist/executor-OVEXR6RT.js +9 -0
  130. package/dist/executor-UNEH5ZYH.js +25 -0
  131. package/dist/export-accessible-PCMXSUZS.js +23 -0
  132. package/dist/extract-partition-SWHFSYJO.js +38 -0
  133. package/dist/{fanout-sidecar-IO2KDUWV.js → fanout-sidecar-A765THMX.js} +9 -9
  134. package/dist/find-N6345CNT.js +11 -0
  135. package/dist/forget/index.js +9 -9
  136. package/dist/guards/index.js +3 -3
  137. package/dist/history/index.js +14 -11
  138. package/dist/history/index.js.map +1 -1
  139. package/dist/i18n/index.js +14 -14
  140. package/dist/index.d.ts +5 -1
  141. package/dist/index.js +108 -89
  142. package/dist/index.js.map +1 -1
  143. package/dist/indexing/index.js +2 -2
  144. package/dist/issue-5OKB6I2R.js +19 -0
  145. package/dist/kernel/collection-config.d.ts +20 -0
  146. package/dist/kernel/collection.d.ts +31 -28
  147. package/dist/kernel/enclave/classify/verify.d.ts +3 -0
  148. package/dist/kernel/enclave/index.d.ts +2 -1
  149. package/dist/kernel/enclave/record-keys/deterministic.d.ts +1 -0
  150. package/dist/kernel/enclave/record-keys/lifecycle.d.ts +50 -0
  151. package/dist/kernel/enclave/record-keys/record-codec.d.ts +27 -0
  152. package/dist/kernel/errors.d.ts +74 -0
  153. package/dist/kernel/lazy-count.d.ts +13 -0
  154. package/dist/kernel/tier-visibility.d.ts +54 -0
  155. package/dist/kernel/types.d.ts +73 -0
  156. package/dist/kernel/vault.d.ts +8 -5
  157. package/dist/kernel/via/dispatch.d.ts +10 -0
  158. package/dist/{ledger-UAQKPWNM.js → ledger-GFBKVPV4.js} +11 -11
  159. package/dist/legacy/bundle.d.ts +1 -1
  160. package/dist/liberate-3VDOT4KO.js +24 -0
  161. package/dist/{link-set-DGYUOFVD.js → link-set-Z7Q2ASFX.js} +11 -11
  162. package/dist/materialized-views/index.js +18 -18
  163. package/dist/noydb-ZCJOYBDI.js +68 -0
  164. package/dist/on/index.js +9 -9
  165. package/dist/overlay-views/index.js +4 -4
  166. package/dist/periods/index.js +12 -12
  167. package/dist/pod/index.js +11 -11
  168. package/dist/{policy-5POYLI26.js → policy-Z3RUAIY2.js} +5 -5
  169. package/dist/port/with/blob-strategy.d.ts +17 -0
  170. package/dist/portability/index.js +8 -8
  171. package/dist/{post-register-LB3P4XQU.js → post-register-JTH76BLY.js} +6 -6
  172. package/dist/{public-envelope-GOG4LUM7.js → public-envelope-B4KNWVUA.js} +4 -4
  173. package/dist/query/index.js +5 -5
  174. package/dist/register-VAHONCID.js +23 -0
  175. package/dist/registry-7MLVD3VO.js +19 -0
  176. package/dist/registry-EPKPD5SM.js +18 -0
  177. package/dist/registry-P5T7PS2U.js +9 -0
  178. package/dist/request-withdrawal-TI3A5WPS.js +31 -0
  179. package/dist/{reveal-NPVROV4D.js → reveal-DIBHLUZX.js} +7 -7
  180. package/dist/reveal-DIBHLUZX.js.map +1 -0
  181. package/dist/revoke-FDRD6GRW.js +24 -0
  182. package/dist/satellites/index.js +1 -1
  183. package/dist/sealed-record/index.js +12 -12
  184. package/dist/{seed-VI4FU7UH.js → seed-Q6M2IZFL.js} +11 -11
  185. package/dist/session/index.js +9 -9
  186. package/dist/shadow/index.js +2 -2
  187. package/dist/signer-MUWEIUI6.js +25 -0
  188. package/dist/snapshots/index.js +10 -10
  189. package/dist/stale-OSQ7J3AA.js +29 -0
  190. package/dist/storage-MVFCGEQE.js +23 -0
  191. package/dist/{store-coordination-provider-5KDS2RRP.js → store-coordination-provider-64OEZFGS.js} +3 -3
  192. package/dist/sync/index.js +9 -9
  193. package/dist/team/index.js +15 -15
  194. package/dist/tiers/index.js +14 -10
  195. package/dist/to/index.js +1 -1
  196. package/dist/tx/index.js +3 -3
  197. package/dist/util/index.js +1 -1
  198. package/dist/{verify-QK76NJ4G.js → verify-ZASTRNPR.js} +9 -8
  199. package/dist/verify-ZASTRNPR.js.map +1 -0
  200. package/dist/{walk-XQCBKSBW.js → walk-SVNDIZ62.js} +11 -11
  201. package/dist/with/index.js +11 -11
  202. package/dist/with-audit/forget/strategy.d.ts +22 -0
  203. package/dist/with-audit/tiers/index.d.ts +275 -3
  204. package/dist/with-audit/tiers/strategy.d.ts +5 -4
  205. package/dist/with-cargo/describe-extraction.d.ts +9 -1
  206. package/dist/with-cargo/extract-partition.d.ts +9 -1
  207. package/dist/with-cargo/walk-closure.d.ts +32 -3
  208. package/dist/with-commit/history/history.d.ts +46 -0
  209. package/dist/with-commit/history/ledger/store.d.ts +21 -0
  210. package/dist/with-commit/history/strategy.d.ts +10 -0
  211. package/dist/with-commit/history/time-machine.d.ts +23 -0
  212. package/dist/with-commit/tx/elevated-handle.d.ts +2 -1
  213. package/dist/with-formula/materialized-views/executor.d.ts +9 -0
  214. package/dist/with-formula/materialized-views/stale.d.ts +52 -1
  215. package/dist/with-lookup/embeddings/index.d.ts +1 -0
  216. package/dist/with-lookup/embeddings/vec-id.d.ts +47 -0
  217. package/dist/with-lookup/indexing/collection-facade.d.ts +38 -1
  218. package/dist/with-lookup/search/collection-facade.d.ts +40 -0
  219. package/dist/with-lookup/search/persisted-index-store.d.ts +82 -2
  220. package/dist/with-lookup/search/strategy.d.ts +4 -0
  221. package/dist/with-shape/blobs/blob-intent.d.ts +153 -0
  222. package/dist/with-shape/blobs/blob-set.d.ts +949 -5
  223. package/dist/withdraw-accessible-WZIEVWSR.js +28 -0
  224. package/package.json +3 -3
  225. package/dist/api-3TH2GOFQ.js +0 -20
  226. package/dist/backup-2WVBIVXW.js.map +0 -1
  227. package/dist/chunk-65VLRG3I.js +0 -54
  228. package/dist/chunk-65VLRG3I.js.map +0 -1
  229. package/dist/chunk-AKEOHKMT.js.map +0 -1
  230. package/dist/chunk-BDPAVYGJ.js.map +0 -1
  231. package/dist/chunk-CZMCOFEA.js +0 -1221
  232. package/dist/chunk-CZMCOFEA.js.map +0 -1
  233. package/dist/chunk-EHW5KTTA.js.map +0 -1
  234. package/dist/chunk-F3LGBRSV.js.map +0 -1
  235. package/dist/chunk-FZCGIJEJ.js.map +0 -1
  236. package/dist/chunk-HA6ZQWA2.js.map +0 -1
  237. package/dist/chunk-HG76BZ6G.js.map +0 -1
  238. package/dist/chunk-RNXJ2VO6.js.map +0 -1
  239. package/dist/chunk-YCXKFB7J.js.map +0 -1
  240. package/dist/collection-facade-DWA735G2.js +0 -39
  241. package/dist/delegation-YVSHMIZZ.js +0 -25
  242. package/dist/derive-BUO555L5.js +0 -21
  243. package/dist/executor-6OCCE5VM.js +0 -25
  244. package/dist/executor-JFVAJY42.js +0 -9
  245. package/dist/executor-UPSH5O3F.js +0 -9
  246. package/dist/export-accessible-L4A2QZA5.js +0 -23
  247. package/dist/extract-partition-ZHQ4RGGM.js +0 -36
  248. package/dist/find-ZFZDZQ2U.js +0 -11
  249. package/dist/issue-OG4V23SQ.js +0 -19
  250. package/dist/liberate-GFUQJRK5.js +0 -24
  251. package/dist/noydb-AKH4AMCR.js +0 -67
  252. package/dist/register-ZI7YI7US.js +0 -23
  253. package/dist/registry-DZ2T4LL7.js +0 -9
  254. package/dist/registry-NVWEQ2GU.js +0 -18
  255. package/dist/registry-SEKL74ET.js +0 -19
  256. package/dist/request-withdrawal-ZP3JIRVS.js +0 -31
  257. package/dist/reveal-NPVROV4D.js.map +0 -1
  258. package/dist/revoke-VF6TAJK2.js +0 -24
  259. package/dist/signer-DRDDCCHW.js +0 -25
  260. package/dist/stale-TJXFQKOJ.js +0 -14
  261. package/dist/storage-GR7KZRH4.js +0 -23
  262. package/dist/verify-QK76NJ4G.js.map +0 -1
  263. package/dist/withdraw-accessible-FMN4LPJZ.js +0 -28
  264. /package/dist/{api-3TH2GOFQ.js.map → api-ZGS6LCOF.js.map} +0 -0
  265. /package/dist/{chunk-ZL6PRULX.js.map → chunk-2NVOWNI3.js.map} +0 -0
  266. /package/dist/{chunk-WEHIQYQH.js.map → chunk-3B5VVCNY.js.map} +0 -0
  267. /package/dist/{chunk-FF7S3XDW.js.map → chunk-3LQ2YKO4.js.map} +0 -0
  268. /package/dist/{chunk-NAR6IDKH.js.map → chunk-3QCRBHCY.js.map} +0 -0
  269. /package/dist/{chunk-SXPCZ6LL.js.map → chunk-454JXE57.js.map} +0 -0
  270. /package/dist/{chunk-JGUZMC3I.js.map → chunk-4JBYV75E.js.map} +0 -0
  271. /package/dist/{chunk-RXTMLYJS.js.map → chunk-4NXKCLLQ.js.map} +0 -0
  272. /package/dist/{chunk-GXLZXD2W.js.map → chunk-4VNQOLML.js.map} +0 -0
  273. /package/dist/{chunk-45QPICLE.js.map → chunk-5M5DVGV7.js.map} +0 -0
  274. /package/dist/{chunk-S2OWPVSO.js.map → chunk-5YOLBEQ6.js.map} +0 -0
  275. /package/dist/{chunk-BDEMZD4F.js.map → chunk-6CRIV7DE.js.map} +0 -0
  276. /package/dist/{chunk-VCUQR6ZL.js.map → chunk-6JTIAGHD.js.map} +0 -0
  277. /package/dist/{chunk-K2DLLK34.js.map → chunk-6QTNZJBS.js.map} +0 -0
  278. /package/dist/{chunk-UMC5QZTX.js.map → chunk-6T2SCQRU.js.map} +0 -0
  279. /package/dist/{chunk-J3JIYFYL.js.map → chunk-7DSTRQIJ.js.map} +0 -0
  280. /package/dist/{chunk-3QSOFZQB.js.map → chunk-AUSTCW2X.js.map} +0 -0
  281. /package/dist/{chunk-PN5332SU.js.map → chunk-B3HJYUOF.js.map} +0 -0
  282. /package/dist/{chunk-DIB2BOIH.js.map → chunk-BDVFPG6Y.js.map} +0 -0
  283. /package/dist/{chunk-FYNE4WLC.js.map → chunk-CAF6WOK7.js.map} +0 -0
  284. /package/dist/{chunk-37WOJQWY.js.map → chunk-CIE2BASH.js.map} +0 -0
  285. /package/dist/{chunk-BLUT46UP.js.map → chunk-CRI4OUV4.js.map} +0 -0
  286. /package/dist/{chunk-Y5TWPBNW.js.map → chunk-DLG74CNB.js.map} +0 -0
  287. /package/dist/{chunk-HIOLCOK3.js.map → chunk-E5ZQT5KX.js.map} +0 -0
  288. /package/dist/{chunk-IQIVD7TP.js.map → chunk-EQO2UVP4.js.map} +0 -0
  289. /package/dist/{chunk-US34HTOI.js.map → chunk-ERJ7FU55.js.map} +0 -0
  290. /package/dist/{chunk-S7TAPIRS.js.map → chunk-EVVGJDRQ.js.map} +0 -0
  291. /package/dist/{chunk-EXGDL2UQ.js.map → chunk-EVX47VBM.js.map} +0 -0
  292. /package/dist/{chunk-NT2ZO4KI.js.map → chunk-EXK7QRWF.js.map} +0 -0
  293. /package/dist/{chunk-7QLY64AD.js.map → chunk-EYZ6IQ6X.js.map} +0 -0
  294. /package/dist/{chunk-QF5LGMSV.js.map → chunk-F64IRYG3.js.map} +0 -0
  295. /package/dist/{chunk-PH7G7ZI7.js.map → chunk-FHS2HQSH.js.map} +0 -0
  296. /package/dist/{chunk-ZHOJOT6S.js.map → chunk-FUG4SFN3.js.map} +0 -0
  297. /package/dist/{chunk-JRKE5MAZ.js.map → chunk-GKEWXIV5.js.map} +0 -0
  298. /package/dist/{chunk-6MA575R5.js.map → chunk-GTGPO5KW.js.map} +0 -0
  299. /package/dist/{chunk-XS6DLN67.js.map → chunk-HB3RFQSC.js.map} +0 -0
  300. /package/dist/{chunk-VXZNSPJM.js.map → chunk-HDMEGAQE.js.map} +0 -0
  301. /package/dist/{chunk-DJ7MRXNA.js.map → chunk-HTJQYHZP.js.map} +0 -0
  302. /package/dist/{chunk-NRYNRSGV.js.map → chunk-I6GALP6E.js.map} +0 -0
  303. /package/dist/{chunk-GL3JV5EV.js.map → chunk-IL6POWCW.js.map} +0 -0
  304. /package/dist/{chunk-NEYKOESM.js.map → chunk-IU6SNYX6.js.map} +0 -0
  305. /package/dist/{chunk-CCIR2OJH.js.map → chunk-J2ZX2XUV.js.map} +0 -0
  306. /package/dist/{chunk-NM3IFKBL.js.map → chunk-JKJOGPZN.js.map} +0 -0
  307. /package/dist/{chunk-TVS6BUUR.js.map → chunk-JZUV47FZ.js.map} +0 -0
  308. /package/dist/{chunk-5HNX4OD4.js.map → chunk-K5IMOGHB.js.map} +0 -0
  309. /package/dist/{chunk-XJ47GS53.js.map → chunk-KSKBRKGJ.js.map} +0 -0
  310. /package/dist/{chunk-INBQ43DI.js.map → chunk-LASZKVMO.js.map} +0 -0
  311. /package/dist/{chunk-EVHBK7BN.js.map → chunk-LXEXBTKL.js.map} +0 -0
  312. /package/dist/{chunk-6S7ENMRE.js.map → chunk-M4CV6BRT.js.map} +0 -0
  313. /package/dist/{chunk-AAIIDAUC.js.map → chunk-MEFJPTZ4.js.map} +0 -0
  314. /package/dist/{chunk-WHQHTNT7.js.map → chunk-MV43JSJF.js.map} +0 -0
  315. /package/dist/{chunk-F44XWXOA.js.map → chunk-NJ4EOKMB.js.map} +0 -0
  316. /package/dist/{chunk-ILF5GARW.js.map → chunk-NR5LT5RY.js.map} +0 -0
  317. /package/dist/{chunk-TBNF5DV5.js.map → chunk-NWSGI5C7.js.map} +0 -0
  318. /package/dist/{chunk-EIZ4YOG2.js.map → chunk-Q5VNKNE5.js.map} +0 -0
  319. /package/dist/{chunk-TVOHSPVK.js.map → chunk-QLWMEXCT.js.map} +0 -0
  320. /package/dist/{chunk-7GAXFU2O.js.map → chunk-QRB7NAOJ.js.map} +0 -0
  321. /package/dist/{chunk-X6Y5MXTH.js.map → chunk-R4ROFEYC.js.map} +0 -0
  322. /package/dist/{chunk-4BQXMCE5.js.map → chunk-RCVJZMFE.js.map} +0 -0
  323. /package/dist/{chunk-QG5RQQBO.js.map → chunk-RIX4V2TB.js.map} +0 -0
  324. /package/dist/{chunk-SAL5X5OK.js.map → chunk-RYCTDFUX.js.map} +0 -0
  325. /package/dist/{chunk-CXC3JLAQ.js.map → chunk-RZ5SVOYR.js.map} +0 -0
  326. /package/dist/{chunk-44IL5G3W.js.map → chunk-SLFHQTTW.js.map} +0 -0
  327. /package/dist/{chunk-2MTRJCBI.js.map → chunk-T2FFWNPK.js.map} +0 -0
  328. /package/dist/{chunk-QYPDYN23.js.map → chunk-UNFPPVNI.js.map} +0 -0
  329. /package/dist/{chunk-7ZOSHEVS.js.map → chunk-VLFCJYTL.js.map} +0 -0
  330. /package/dist/{chunk-APHLCXVC.js.map → chunk-VN3DBQAU.js.map} +0 -0
  331. /package/dist/{chunk-HK4XTXO4.js.map → chunk-VZRODIM3.js.map} +0 -0
  332. /package/dist/{chunk-P2LJI6JE.js.map → chunk-W22IKJE2.js.map} +0 -0
  333. /package/dist/{chunk-FJTWLQV3.js.map → chunk-X3YYQWOQ.js.map} +0 -0
  334. /package/dist/{chunk-SGJGWBSC.js.map → chunk-YFXZEAYK.js.map} +0 -0
  335. /package/dist/{chunk-SIAIYP6G.js.map → chunk-ZAJAVEXY.js.map} +0 -0
  336. /package/dist/{chunk-KKYEZCQG.js.map → chunk-ZICD77GM.js.map} +0 -0
  337. /package/dist/{chunk-HGAB325C.js.map → chunk-ZJ2AK4V7.js.map} +0 -0
  338. /package/dist/{chunk-HYG32HCM.js.map → chunk-ZUODRVHY.js.map} +0 -0
  339. /package/dist/{classified-marker-M7K3OJPM.js.map → classified-marker-CZKA6ITE.js.map} +0 -0
  340. /package/dist/{collection-facade-DWA735G2.js.map → collection-facade-TLWIPI76.js.map} +0 -0
  341. /package/dist/{computed-ORCGM5JE.js.map → computed-ZIQTYTDI.js.map} +0 -0
  342. /package/dist/{dead-filter-OV5FGKOG.js.map → dead-filter-ESOBZZP5.js.map} +0 -0
  343. /package/dist/{delegation-YVSHMIZZ.js.map → delegation-W7ZV2322.js.map} +0 -0
  344. /package/dist/{derive-BUO555L5.js.map → derive-H2BJTLUI.js.map} +0 -0
  345. /package/dist/{enclave-XXFUKJC6.js.map → enclave-AP3I5W7O.js.map} +0 -0
  346. /package/dist/{executor-6OCCE5VM.js.map → executor-KGWTNEQD.js.map} +0 -0
  347. /package/dist/{executor-JFVAJY42.js.map → executor-OVEXR6RT.js.map} +0 -0
  348. /package/dist/{executor-UPSH5O3F.js.map → executor-UNEH5ZYH.js.map} +0 -0
  349. /package/dist/{export-accessible-L4A2QZA5.js.map → export-accessible-PCMXSUZS.js.map} +0 -0
  350. /package/dist/{extract-partition-ZHQ4RGGM.js.map → extract-partition-SWHFSYJO.js.map} +0 -0
  351. /package/dist/{fanout-sidecar-IO2KDUWV.js.map → fanout-sidecar-A765THMX.js.map} +0 -0
  352. /package/dist/{find-ZFZDZQ2U.js.map → find-N6345CNT.js.map} +0 -0
  353. /package/dist/{issue-OG4V23SQ.js.map → issue-5OKB6I2R.js.map} +0 -0
  354. /package/dist/{ledger-UAQKPWNM.js.map → ledger-GFBKVPV4.js.map} +0 -0
  355. /package/dist/{liberate-GFUQJRK5.js.map → liberate-3VDOT4KO.js.map} +0 -0
  356. /package/dist/{link-set-DGYUOFVD.js.map → link-set-Z7Q2ASFX.js.map} +0 -0
  357. /package/dist/{noydb-AKH4AMCR.js.map → noydb-ZCJOYBDI.js.map} +0 -0
  358. /package/dist/{policy-5POYLI26.js.map → policy-Z3RUAIY2.js.map} +0 -0
  359. /package/dist/{post-register-LB3P4XQU.js.map → post-register-JTH76BLY.js.map} +0 -0
  360. /package/dist/{public-envelope-GOG4LUM7.js.map → public-envelope-B4KNWVUA.js.map} +0 -0
  361. /package/dist/{register-ZI7YI7US.js.map → register-VAHONCID.js.map} +0 -0
  362. /package/dist/{registry-DZ2T4LL7.js.map → registry-7MLVD3VO.js.map} +0 -0
  363. /package/dist/{registry-NVWEQ2GU.js.map → registry-EPKPD5SM.js.map} +0 -0
  364. /package/dist/{registry-SEKL74ET.js.map → registry-P5T7PS2U.js.map} +0 -0
  365. /package/dist/{request-withdrawal-ZP3JIRVS.js.map → request-withdrawal-TI3A5WPS.js.map} +0 -0
  366. /package/dist/{revoke-VF6TAJK2.js.map → revoke-FDRD6GRW.js.map} +0 -0
  367. /package/dist/{seed-VI4FU7UH.js.map → seed-Q6M2IZFL.js.map} +0 -0
  368. /package/dist/{signer-DRDDCCHW.js.map → signer-MUWEIUI6.js.map} +0 -0
  369. /package/dist/{stale-TJXFQKOJ.js.map → stale-OSQ7J3AA.js.map} +0 -0
  370. /package/dist/{storage-GR7KZRH4.js.map → storage-MVFCGEQE.js.map} +0 -0
  371. /package/dist/{store-coordination-provider-5KDS2RRP.js.map → store-coordination-provider-64OEZFGS.js.map} +0 -0
  372. /package/dist/{walk-XQCBKSBW.js.map → walk-SVNDIZ62.js.map} +0 -0
  373. /package/dist/{withdraw-accessible-FMN4LPJZ.js.map → withdraw-accessible-WZIEVWSR.js.map} +0 -0
@@ -6,34 +6,36 @@ import {
6
6
  SEQUENCE_COLLECTION,
7
7
  compileSequenceFormat,
8
8
  resolveSequenceKey
9
- } from "./chunk-7QLY64AD.js";
9
+ } from "./chunk-EYZ6IQ6X.js";
10
10
  import {
11
11
  loadVaultPolicy
12
- } from "./chunk-BLUT46UP.js";
12
+ } from "./chunk-CRI4OUV4.js";
13
13
  import {
14
14
  LinkIntegrityError,
15
15
  isLinkCollectionName,
16
16
  linkCollectionName,
17
17
  linkRowKey
18
- } from "./chunk-TVS6BUUR.js";
18
+ } from "./chunk-JZUV47FZ.js";
19
19
  import {
20
20
  hashFields,
21
21
  validateSatelliteDeclaration
22
- } from "./chunk-SIAIYP6G.js";
22
+ } from "./chunk-ZAJAVEXY.js";
23
23
  import {
24
24
  loadFence
25
- } from "./chunk-SAL5X5OK.js";
25
+ } from "./chunk-RYCTDFUX.js";
26
26
  import {
27
27
  InvertedIndex,
28
28
  MemoryIndexStore,
29
29
  NO_SEARCH,
30
30
  VectorSet,
31
- buildPersistedIndexCallbacks
32
- } from "./chunk-BDPAVYGJ.js";
31
+ buildPersistedIndexCallbacks,
32
+ encodeVecId,
33
+ syncTierSearch
34
+ } from "./chunk-OSDB5WW3.js";
33
35
  import {
34
36
  derivePersistedSchema,
35
37
  isZod4Schema
36
- } from "./chunk-P2LJI6JE.js";
38
+ } from "./chunk-W22IKJE2.js";
37
39
  import {
38
40
  isBaseLive,
39
41
  liveBaseIdSet
@@ -42,7 +44,7 @@ import {
42
44
  CustodyApi,
43
45
  NO_CARGO,
44
46
  NO_CUSTODY
45
- } from "./chunk-UMC5QZTX.js";
47
+ } from "./chunk-6T2SCQRU.js";
46
48
  import {
47
49
  ServiceBus,
48
50
  WriteHookRegistry,
@@ -50,44 +52,45 @@ import {
50
52
  assertCanImport,
51
53
  canExport,
52
54
  canImport
53
- } from "./chunk-K2DLLK34.js";
55
+ } from "./chunk-6QTNZJBS.js";
54
56
  import {
55
57
  runDrainBarrier
56
- } from "./chunk-NAR6IDKH.js";
58
+ } from "./chunk-3QCRBHCY.js";
57
59
  import {
58
60
  OverlayedCollection
59
- } from "./chunk-PN5332SU.js";
61
+ } from "./chunk-B3HJYUOF.js";
60
62
  import {
61
63
  NO_ATTESTATION
62
- } from "./chunk-S2OWPVSO.js";
64
+ } from "./chunk-5YOLBEQ6.js";
63
65
  import {
64
66
  NO_CLASSIFIED,
65
67
  guardClassifiedCompat,
66
68
  resolveClassifiedFields
67
- } from "./chunk-WHQHTNT7.js";
69
+ } from "./chunk-MV43JSJF.js";
68
70
  import {
69
71
  NO_TIERS,
70
- classifySealedShred
71
- } from "./chunk-AKEOHKMT.js";
72
+ classifySealedShred,
73
+ syncDerivedOutputs
74
+ } from "./chunk-CDUQTA3Z.js";
72
75
  import {
73
76
  NO_PORTABILITY
74
- } from "./chunk-5HNX4OD4.js";
77
+ } from "./chunk-K5IMOGHB.js";
75
78
  import {
76
79
  PERIODS_COLLECTION,
77
80
  PERIOD_ARCHIVES_COLLECTION,
78
81
  PERIOD_FREEZES_COLLECTION,
79
82
  PERIOD_TARGET_PURGES_COLLECTION,
80
83
  periodExclusiveUpperBound
81
- } from "./chunk-Y5TWPBNW.js";
84
+ } from "./chunk-DLG74CNB.js";
82
85
  import {
83
86
  TxContext,
84
87
  bestEffortRevert,
85
88
  revertExecuted
86
- } from "./chunk-AAIIDAUC.js";
89
+ } from "./chunk-MEFJPTZ4.js";
87
90
  import {
88
91
  DEFAULT_POSTURE,
89
92
  ViaGraph
90
- } from "./chunk-DJ7MRXNA.js";
93
+ } from "./chunk-HTJQYHZP.js";
91
94
  import {
92
95
  buildLookupAltIndex,
93
96
  buildLookupSnapshotRows,
@@ -110,22 +113,22 @@ import {
110
113
  runGraphDispatchWave,
111
114
  touchFor,
112
115
  updateReferencingRecords
113
- } from "./chunk-R3NHNVS5.js";
116
+ } from "./chunk-4CTHCN4J.js";
114
117
  import {
115
118
  NO_AGGREGATE,
116
119
  Query,
117
120
  ScanBuilder
118
- } from "./chunk-SXPCZ6LL.js";
121
+ } from "./chunk-454JXE57.js";
119
122
  import {
120
123
  EXPORT_AUDIT_COLLECTION,
121
124
  createExportBlobsHandle,
122
125
  runCompaction
123
- } from "./chunk-TBNF5DV5.js";
126
+ } from "./chunk-NWSGI5C7.js";
124
127
  import {
125
128
  LazyQuery,
126
129
  decodeIdxId,
127
130
  encodeIdxId
128
- } from "./chunk-6S7ENMRE.js";
131
+ } from "./chunk-M4CV6BRT.js";
129
132
  import {
130
133
  IMPLICIT_LAZY,
131
134
  Lru,
@@ -133,17 +136,17 @@ import {
133
136
  } from "./chunk-NO272T7Q.js";
134
137
  import {
135
138
  canonicalGroupKey
136
- } from "./chunk-EVHBK7BN.js";
139
+ } from "./chunk-LXEXBTKL.js";
137
140
  import {
138
141
  readPath
139
142
  } from "./chunk-IGJCYUT5.js";
140
143
  import {
141
144
  resolveManagedSecret,
142
145
  saveSealedPassphrase
143
- } from "./chunk-FF7S3XDW.js";
146
+ } from "./chunk-3LQ2YKO4.js";
144
147
  import {
145
148
  dictCollectionName
146
- } from "./chunk-F44XWXOA.js";
149
+ } from "./chunk-NJ4EOKMB.js";
147
150
  import {
148
151
  NO_I18N,
149
152
  getAtPath,
@@ -151,12 +154,12 @@ import {
151
154
  isDictKeyDescriptor,
152
155
  isI18nTextDescriptor,
153
156
  isStaticDictDescriptor
154
- } from "./chunk-VCUQR6ZL.js";
157
+ } from "./chunk-6JTIAGHD.js";
155
158
  import {
156
159
  installViaBinder,
157
160
  isViaInstalled,
158
161
  viaBinder
159
- } from "./chunk-GXLZXD2W.js";
162
+ } from "./chunk-4VNQOLML.js";
160
163
  import {
161
164
  NO_TEAM,
162
165
  enrollAuthenticator,
@@ -167,7 +170,7 @@ import {
167
170
  rotatePassphrase,
168
171
  updateAuthenticator,
169
172
  writeMagicLinkGrant
170
- } from "./chunk-3QSOFZQB.js";
173
+ } from "./chunk-AUSTCW2X.js";
171
174
  import {
172
175
  hasRecoveryEnrolled,
173
176
  hasStrongRecoveryEnrolled,
@@ -177,7 +180,7 @@ import {
177
180
  mintShamirRecoveryEntry,
178
181
  savePaperRecoveryEntries,
179
182
  saveShamirRecoveryEntries
180
- } from "./chunk-S7TAPIRS.js";
183
+ } from "./chunk-EVVGJDRQ.js";
181
184
  import {
182
185
  INDEXED_STORE_POLICY
183
186
  } from "./chunk-VQNJ7UZL.js";
@@ -193,21 +196,26 @@ import {
193
196
  listUsers,
194
197
  loadKeyring,
195
198
  updateKeyringIdentity
196
- } from "./chunk-CCIR2OJH.js";
199
+ } from "./chunk-J2ZX2XUV.js";
197
200
  import {
198
201
  persistDirectoryConfig,
199
202
  readDirectoryConfig
200
- } from "./chunk-JGUZMC3I.js";
203
+ } from "./chunk-4JBYV75E.js";
201
204
  import {
202
205
  NO_BROKER,
203
206
  buildCredentialBrokerHandle
204
- } from "./chunk-HIOLCOK3.js";
207
+ } from "./chunk-E5ZQT5KX.js";
205
208
  import {
206
209
  generateULID
207
210
  } from "./chunk-ZJADGNYF.js";
211
+ import {
212
+ assertCutoverTierSafe,
213
+ assertTierWritable,
214
+ liveRecordIsElevated
215
+ } from "./chunk-PN2XMATY.js";
208
216
  import {
209
217
  sha256Hex
210
- } from "./chunk-EIZ4YOG2.js";
218
+ } from "./chunk-Q5VNKNE5.js";
211
219
  import {
212
220
  NO_FORGET,
213
221
  addSubjectRef,
@@ -216,10 +224,10 @@ import {
216
224
  readDottedPath,
217
225
  rebuildSubjectIndex,
218
226
  removeSubjectRef
219
- } from "./chunk-EHW5KTTA.js";
227
+ } from "./chunk-5O3XF4DV.js";
220
228
  import {
221
229
  NO_SEALED_RECORD
222
- } from "./chunk-TVOHSPVK.js";
230
+ } from "./chunk-QLWMEXCT.js";
223
231
  import {
224
232
  RecordCodec,
225
233
  SEALED_CEK_NS,
@@ -230,20 +238,20 @@ import {
230
238
  queryByDet,
231
239
  resolveStableCek,
232
240
  validateSchemaInput
233
- } from "./chunk-HA6ZQWA2.js";
241
+ } from "./chunk-XDYREZWE.js";
234
242
  import {
235
243
  buildDeleteMarker,
236
244
  buildTombstone,
237
245
  isDeleteMarker,
238
246
  isTombstone
239
- } from "./chunk-J3JIYFYL.js";
247
+ } from "./chunk-7DSTRQIJ.js";
240
248
  import {
241
249
  encrypt
242
- } from "./chunk-37WOJQWY.js";
250
+ } from "./chunk-CIE2BASH.js";
243
251
  import {
244
252
  NOYDB_FORMAT_VERSION,
245
253
  SealedHandle
246
- } from "./chunk-JC75UBMT.js";
254
+ } from "./chunk-JNAI2HN2.js";
247
255
  import {
248
256
  AlreadyElevatedError,
249
257
  AttestationError,
@@ -266,6 +274,7 @@ import {
266
274
  NoydbError,
267
275
  NumberingUncertaintyError,
268
276
  PermissionDeniedError,
277
+ PersistedIndexCompensationError,
269
278
  PolicyDeniedError,
270
279
  ReadOnlyError,
271
280
  RecoveryNotEnrolledError,
@@ -280,12 +289,13 @@ import {
280
289
  USER_ENVELOPE_COLLECTION,
281
290
  UniqueConstraintError,
282
291
  UnsupportedIndexOptionError,
292
+ UnsupportedTierCompositionError,
283
293
  ValidationError
284
- } from "./chunk-FZCGIJEJ.js";
294
+ } from "./chunk-BIOUI4HL.js";
285
295
 
286
296
  // src/port/by/default-provider.ts
287
297
  async function createDefaultCoordinationProvider(store) {
288
- const { StoreCoordinationProvider } = await import("./store-coordination-provider-5KDS2RRP.js");
298
+ const { StoreCoordinationProvider } = await import("./store-coordination-provider-64OEZFGS.js");
289
299
  return new StoreCoordinationProvider(store);
290
300
  }
291
301
 
@@ -653,6 +663,34 @@ function exportRedact(coll, record) {
653
663
  return via2 ? via2.redactForExport(record) : record;
654
664
  }
655
665
 
666
+ // src/kernel/lazy-count.ts
667
+ var COUNT_PAGE_SIZE = 1e3;
668
+ function isLive(env, storeCiphertext) {
669
+ return !!env && !isTombstone(env, storeCiphertext) && !isDeleteMarker(env) && (env._tier ?? 0) === 0;
670
+ }
671
+ async function countLiveEnvelopes(adapter, vault, name, storeCiphertext) {
672
+ let n = 0;
673
+ if (adapter.listPage) {
674
+ let cursor;
675
+ let page = await adapter.listPage(vault, name, cursor, COUNT_PAGE_SIZE);
676
+ while (true) {
677
+ for (const { envelope } of page.items) {
678
+ if (isLive(envelope, storeCiphertext)) n++;
679
+ }
680
+ if (page.nextCursor === null) break;
681
+ cursor = page.nextCursor;
682
+ page = await adapter.listPage(vault, name, cursor, COUNT_PAGE_SIZE);
683
+ }
684
+ return n;
685
+ }
686
+ const ids = await adapter.list(vault, name);
687
+ for (const id of ids) {
688
+ const env = await adapter.get(vault, name, id);
689
+ if (isLive(env, storeCiphertext)) n++;
690
+ }
691
+ return n;
692
+ }
693
+
656
694
  // src/with-lookup/indexing/collection-facade.ts
657
695
  function readPersistedValue(record, field) {
658
696
  if (!field.includes(".")) return record[field];
@@ -738,6 +776,7 @@ async function rebuildIndexes(ctx) {
738
776
  for (const recordId of canonicalIds) {
739
777
  const envelope = await ctx.adapter.get(ctx.vault, ctx.name, recordId);
740
778
  if (!envelope) continue;
779
+ if ((envelope._tier ?? 0) > 0) continue;
741
780
  const record = await ctx.codec.decryptRecord(envelope, { skipValidation: true, id: recordId });
742
781
  if (record === null) continue;
743
782
  await maintainPersistedIndexesOnPut(ctx, recordId, record, null, envelope._v);
@@ -791,6 +830,7 @@ async function reconcileIndex(ctx, field, opts = {}) {
791
830
  if (id.startsWith("_")) continue;
792
831
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
793
832
  if (!env) continue;
833
+ if ((env._tier ?? 0) > 0) continue;
794
834
  const record = await ctx.codec.decryptRecord(env, { skipValidation: true, id });
795
835
  if (record === null) continue;
796
836
  const live = readPersistedValue(record, field);
@@ -906,6 +946,66 @@ async function purgePersistedIndexes(ctx, id) {
906
946
  }
907
947
  return { purged, residue };
908
948
  }
949
+ async function syncTierIndexes(ctx, id, record, version, priorEnvelope) {
950
+ if (!ctx.indexes && !ctx.persistedIndexes) return;
951
+ const prior = await resolveTierSyncPrior(ctx, id, priorEnvelope);
952
+ if (record === null) {
953
+ await purgePersistedIndexes(ctx, id);
954
+ if (prior) ctx.indexes?.remove(id, prior);
955
+ } else {
956
+ await maintainPersistedIndexesOnPut(ctx, id, record, prior, version);
957
+ ctx.indexes?.upsert(id, record, prior);
958
+ }
959
+ }
960
+ async function resolveTierSyncPrior(ctx, id, priorEnvelope) {
961
+ const cached = ctx.cache.get(id)?.record;
962
+ if (cached !== void 0) return cached;
963
+ if (!ctx.lazy || !priorEnvelope || (priorEnvelope._tier ?? 0) > 0) return null;
964
+ return await ctx.codec.decryptRecord(priorEnvelope, { skipValidation: true, id });
965
+ }
966
+
967
+ // src/with-commit/history/strategy.ts
968
+ function notEnabled(op) {
969
+ return new Error(
970
+ `${op} requires the history strategy. Import \`{ withHistory }\` from "@noy-db/hub/history" and pass it to \`createNoydb({ historyStrategy: withHistory() })\`.`
971
+ );
972
+ }
973
+ var NO_HISTORY = {
974
+ async saveHistory() {
975
+ },
976
+ async getHistoryEntries() {
977
+ throw notEnabled("collection.history()");
978
+ },
979
+ async getVersionEnvelope() {
980
+ throw notEnabled("collection.getVersion()");
981
+ },
982
+ async pruneHistory() {
983
+ return 0;
984
+ },
985
+ async clearHistory() {
986
+ return 0;
987
+ },
988
+ async tombstoneHistory() {
989
+ return 0;
990
+ },
991
+ async rewrapHistory() {
992
+ },
993
+ async envelopePayloadHash() {
994
+ return "";
995
+ },
996
+ computePatch() {
997
+ return [];
998
+ },
999
+ diff() {
1000
+ throw notEnabled("collection.diff()");
1001
+ },
1002
+ buildLedger() {
1003
+ return null;
1004
+ },
1005
+ buildVaultInstant() {
1006
+ throw notEnabled("vault.at() / vault.timeMachine()");
1007
+ }
1008
+ };
909
1009
 
910
1010
  // src/with-lookup/indexing/strategy.ts
911
1011
  var NO_INDEXING = {
@@ -941,10 +1041,53 @@ var PersistedIndexStore = class {
941
1041
  timer = null;
942
1042
  lastBuild;
943
1043
  debounceMs;
1044
+ /**
1045
+ * Bumped by every purge (removePersisted). A save() captured under a since-stale
1046
+ * epoch undoes its own effect once it settles, however it interleaves with the
1047
+ * purge's own delete — a delete can never be overtaken by a save that was
1048
+ * scheduled before it (#725).
1049
+ *
1050
+ * Subsumes the issue's variant (b) (a stale, pre-purge in-memory index getting
1051
+ * paired with a live, post-purge fingerprint and TRUSTED by a cold load, defeating
1052
+ * the fingerprint backstop) for free — no separate handling needed: removePersisted()
1053
+ * always resets `index` to undefined in the SAME synchronous step that bumps the
1054
+ * epoch (below), and the only two paths that can repopulate `index` (ensureBuilt's
1055
+ * cold rebuild, rebuildAndPersist's rebuild) do so strictly from `lastBuild()`, which
1056
+ * the collection wires to read its LIVE cache at call time — not a frozen snapshot.
1057
+ * Cache eviction (the collection dropping the purged/forgotten record) always
1058
+ * precedes removePersisted() in both the elevate and forget call paths (#721's
1059
+ * syncCache eviction / forget's tombstone write both land before syncSearch /
1060
+ * _purgeSearchIndex runs). So any rebuild that executes strictly after
1061
+ * removePersisted() — the only way `index` becomes defined again post-purge —
1062
+ * necessarily observes the post-purge cache, and any rebuild that predates
1063
+ * removePersisted() has its `index` wiped by it. There is no ordering in which a
1064
+ * stale (pre-purge) index survives to be skip-rebuilt and persisted under a
1065
+ * matching live fingerprint. Regression-pinned in
1066
+ * `search-persisted-index-store.test.ts` ("variant (b) is subsumed...").
1067
+ */
1068
+ epoch = 0;
1069
+ /**
1070
+ * Set when a compensating/purging remove() (`compensate()` undoing a stale
1071
+ * save, or `removePersisted()`'s own purge, #764) fails. Unlike the routine
1072
+ * best-effort swallow on the debounced flush path (markDirty's timer
1073
+ * .catch(), below — safe there because the fingerprint backstop forces a
1074
+ * rebuild on the next cold load), a failed removal leaves a resurrected or
1075
+ * un-purged blob at rest whose fingerprint can still match the live cache —
1076
+ * a cold load would TRUST it, not rebuild past it. So this is never silently
1077
+ * dropped: every subsequent store entrypoint (ensureBuilt, rebuildAndPersist,
1078
+ * removePersisted) retries the remove first and refuses to proceed past it
1079
+ * until it succeeds (#725 review), and the raw adapter error is wrapped in
1080
+ * {@link PersistedIndexCompensationError} (#764) so a caller can catch a
1081
+ * stuck removal deliberately instead of an indistinguishable adapter error.
1082
+ * A crash between a landed put and its compensating remove (before this
1083
+ * flag or a retry can run) is a residual gap — see the class doc.
1084
+ */
1085
+ pendingCompensation = false;
944
1086
  get built() {
945
1087
  return this.index !== void 0;
946
1088
  }
947
1089
  async ensureBuilt(build) {
1090
+ await this.retryPendingCompensation();
948
1091
  this.lastBuild = build;
949
1092
  if (this.index !== void 0) return this.index;
950
1093
  const loaded = await this.cb.load();
@@ -973,26 +1116,70 @@ var PersistedIndexStore = class {
973
1116
  }
974
1117
  await this.rebuildAndPersist();
975
1118
  }
976
- /** Delete the persisted blob and drop the in-memory index (forget/erasure). */
1119
+ /** Delete the persisted blob and drop the in-memory index (forget/erasure/tier
1120
+ * move). A failed purge is wrapped in {@link PersistedIndexCompensationError}
1121
+ * (#764) and left sticky (`pendingCompensation`) so the next store entrypoint
1122
+ * retries it — never silently dropped, same posture #725 established for a
1123
+ * stale save's own compensating remove. */
977
1124
  async removePersisted() {
978
1125
  if (this.timer) {
979
1126
  clearTimeout(this.timer);
980
1127
  this.timer = null;
981
1128
  }
1129
+ await this.retryPendingCompensation();
1130
+ this.epoch++;
982
1131
  this.index = void 0;
983
- await this.cb.remove();
1132
+ try {
1133
+ await this.cb.remove();
1134
+ this.pendingCompensation = false;
1135
+ } catch (e) {
1136
+ this.pendingCompensation = true;
1137
+ throw new PersistedIndexCompensationError(e);
1138
+ }
984
1139
  }
985
1140
  /** Rebuild using the last known build thunk, then persist. */
986
1141
  async rebuildAndPersist() {
1142
+ await this.retryPendingCompensation();
987
1143
  if (this.lastBuild === void 0) return;
988
1144
  if (this.index === void 0) {
989
1145
  this.index = InvertedIndex.build(this.lastBuild());
990
1146
  }
991
1147
  await this.persist();
992
1148
  }
1149
+ /** Persist the current index, then undo it if a purge (removePersisted) landed
1150
+ * while the save was in flight — a delete can never be overtaken by a save
1151
+ * that was scheduled before it (#725). A failed undo does not silently vanish:
1152
+ * see `pendingCompensation`. */
993
1153
  async persist() {
994
1154
  if (this.index === void 0) return;
995
- await this.cb.save(serializeIndex(this.index), this.cb.currentFingerprint());
1155
+ const epoch = this.epoch;
1156
+ await this.cb.save(serializeIndex(this.index), this.cb.currentFingerprint(), () => this.epoch !== epoch);
1157
+ if (this.epoch !== epoch) await this.compensate();
1158
+ }
1159
+ /** Undo a stale save. Failure is sticky, not swallowed: see `pendingCompensation`.
1160
+ * Wraps the raw adapter error in {@link PersistedIndexCompensationError} (#764) so
1161
+ * a caller (e.g. the tier ops' `syncTierSearch`) can catch a stuck compensation
1162
+ * deliberately instead of treating it as an indistinguishable adapter failure. */
1163
+ async compensate() {
1164
+ try {
1165
+ await this.cb.remove();
1166
+ this.pendingCompensation = false;
1167
+ } catch (e) {
1168
+ this.pendingCompensation = true;
1169
+ throw new PersistedIndexCompensationError(e);
1170
+ }
1171
+ }
1172
+ /** Retries a sticky compensation before any store entrypoint proceeds. Failure
1173
+ * re-wraps the raw adapter error the same way `compensate()` does (#764) — the
1174
+ * flag stays set (untouched here) so the NEXT entrypoint retries again. */
1175
+ async retryPendingCompensation() {
1176
+ if (!this.pendingCompensation) return;
1177
+ try {
1178
+ await this.cb.remove();
1179
+ this.pendingCompensation = false;
1180
+ } catch (e) {
1181
+ throw new PersistedIndexCompensationError(e);
1182
+ }
996
1183
  }
997
1184
  };
998
1185
 
@@ -1434,6 +1621,54 @@ function buildDescription(input) {
1434
1621
  };
1435
1622
  }
1436
1623
 
1624
+ // src/via/blob/binding.ts
1625
+ async function eraseBlobs(ctx, cfg) {
1626
+ if (cfg.purgeBlobsForRecord) return cfg.purgeBlobsForRecord(ctx.id);
1627
+ return { shredded: 0, residue: [] };
1628
+ }
1629
+ function buildBlobDescribeFragment(fields) {
1630
+ return {
1631
+ blobFields: Object.fromEntries(
1632
+ Object.entries(fields).map(([field, p]) => [field, {
1633
+ ...p.retainDays !== void 0 ? { retainDays: p.retainDays } : {},
1634
+ ...p.evictWhen !== void 0 ? { evictWhen: true } : {},
1635
+ ...p.legalHold !== void 0 ? { legalHold: true } : {},
1636
+ ...p.retainUntil !== void 0 ? { retainUntil: true } : {},
1637
+ ...p.external === true ? { external: true } : {},
1638
+ ...p.public === true ? { public: true } : {},
1639
+ ...p.backlink !== void 0 ? { backlink: p.backlink } : {}
1640
+ }])
1641
+ )
1642
+ };
1643
+ }
1644
+ function blobBinding(cfg) {
1645
+ return {
1646
+ brand: "blob",
1647
+ // encryptedAtRest: 'envelope' — blob chunks are AEAD-encrypted envelopes
1648
+ // in `_blob_chunks` (service-side), not sealed record fields; queryable:
1649
+ // 'none' — nothing indexes blob content; exportable — vault.exportBlobs()
1650
+ // is a first-class door; forgettable — shredAllForRecord participates in
1651
+ // vault.forget().
1652
+ posture: { encryptedAtRest: "envelope", queryable: "none", exportable: true, forgettable: true },
1653
+ covers: (field) => field in cfg.fields,
1654
+ erase: (ctx) => eraseBlobs(ctx, cfg),
1655
+ describeFragment: () => buildBlobDescribeFragment(cfg.fields)
1656
+ };
1657
+ }
1658
+ function linkBlobVia() {
1659
+ installViaBinder("blob", (c) => blobBinding(c));
1660
+ }
1661
+
1662
+ // src/port/with/blob-strategy.ts
1663
+ linkBlobVia();
1664
+ var NO_BLOBS = {
1665
+ openSlot() {
1666
+ throw new Error(
1667
+ 'Blob storage is not enabled on this Noydb instance. Import `{ withBlobs }` from "@noy-db/hub/blobs" and pass `withBlobs()` to `createNoydb({ blobStrategy: withBlobs() })`.'
1668
+ );
1669
+ }
1670
+ };
1671
+
1437
1672
  // src/with-formula/derivations/stale.ts
1438
1673
  var _staleByRegistry = /* @__PURE__ */ new WeakMap();
1439
1674
  var keyFor = (source, sourceId) => `${source}/${sourceId}`;
@@ -1470,7 +1705,7 @@ async function resolveStaleOnRead(accessor, outputCollection, id) {
1470
1705
  }
1471
1706
  const sourceWithId = { ...source, id };
1472
1707
  if (DerivationExecutor === null) {
1473
- ({ DerivationExecutor } = await import("./executor-JFVAJY42.js"));
1708
+ ({ DerivationExecutor } = await import("./executor-OVEXR6RT.js"));
1474
1709
  }
1475
1710
  const ctx = { vault: accessor.getReadOnlyFacade() };
1476
1711
  const result = await DerivationExecutor.run(spec, sourceWithId, 0, strategyHash, ctx);
@@ -1526,47 +1761,6 @@ var NO_CRDT = {
1526
1761
  }
1527
1762
  };
1528
1763
 
1529
- // src/with-commit/history/strategy.ts
1530
- function notEnabled(op) {
1531
- return new Error(
1532
- `${op} requires the history strategy. Import \`{ withHistory }\` from "@noy-db/hub/history" and pass it to \`createNoydb({ historyStrategy: withHistory() })\`.`
1533
- );
1534
- }
1535
- var NO_HISTORY = {
1536
- async saveHistory() {
1537
- },
1538
- async getHistoryEntries() {
1539
- throw notEnabled("collection.history()");
1540
- },
1541
- async getVersionEnvelope() {
1542
- throw notEnabled("collection.getVersion()");
1543
- },
1544
- async pruneHistory() {
1545
- return 0;
1546
- },
1547
- async clearHistory() {
1548
- return 0;
1549
- },
1550
- async tombstoneHistory() {
1551
- return 0;
1552
- },
1553
- async envelopePayloadHash() {
1554
- return "";
1555
- },
1556
- computePatch() {
1557
- return [];
1558
- },
1559
- diff() {
1560
- throw notEnabled("collection.diff()");
1561
- },
1562
- buildLedger() {
1563
- return null;
1564
- },
1565
- buildVaultInstant() {
1566
- throw notEnabled("vault.at() / vault.timeMachine()");
1567
- }
1568
- };
1569
-
1570
1764
  // src/with-party/team/sync-strategy.ts
1571
1765
  function notEnabled2(op) {
1572
1766
  return new Error(
@@ -1585,54 +1779,6 @@ var NO_SYNC = {
1585
1779
  }
1586
1780
  };
1587
1781
 
1588
- // src/via/blob/binding.ts
1589
- async function eraseBlobs(ctx, cfg) {
1590
- if (cfg.purgeBlobsForRecord) return cfg.purgeBlobsForRecord(ctx.id);
1591
- return { shredded: 0, residue: [] };
1592
- }
1593
- function buildBlobDescribeFragment(fields) {
1594
- return {
1595
- blobFields: Object.fromEntries(
1596
- Object.entries(fields).map(([field, p]) => [field, {
1597
- ...p.retainDays !== void 0 ? { retainDays: p.retainDays } : {},
1598
- ...p.evictWhen !== void 0 ? { evictWhen: true } : {},
1599
- ...p.legalHold !== void 0 ? { legalHold: true } : {},
1600
- ...p.retainUntil !== void 0 ? { retainUntil: true } : {},
1601
- ...p.external === true ? { external: true } : {},
1602
- ...p.public === true ? { public: true } : {},
1603
- ...p.backlink !== void 0 ? { backlink: p.backlink } : {}
1604
- }])
1605
- )
1606
- };
1607
- }
1608
- function blobBinding(cfg) {
1609
- return {
1610
- brand: "blob",
1611
- // encryptedAtRest: 'envelope' — blob chunks are AEAD-encrypted envelopes
1612
- // in `_blob_chunks` (service-side), not sealed record fields; queryable:
1613
- // 'none' — nothing indexes blob content; exportable — vault.exportBlobs()
1614
- // is a first-class door; forgettable — shredAllForRecord participates in
1615
- // vault.forget().
1616
- posture: { encryptedAtRest: "envelope", queryable: "none", exportable: true, forgettable: true },
1617
- covers: (field) => field in cfg.fields,
1618
- erase: (ctx) => eraseBlobs(ctx, cfg),
1619
- describeFragment: () => buildBlobDescribeFragment(cfg.fields)
1620
- };
1621
- }
1622
- function linkBlobVia() {
1623
- installViaBinder("blob", (c) => blobBinding(c));
1624
- }
1625
-
1626
- // src/port/with/blob-strategy.ts
1627
- linkBlobVia();
1628
- var NO_BLOBS = {
1629
- openSlot() {
1630
- throw new Error(
1631
- 'Blob storage is not enabled on this Noydb instance. Import `{ withBlobs }` from "@noy-db/hub/blobs" and pass `withBlobs()` to `createNoydb({ blobStrategy: withBlobs() })`.'
1632
- );
1633
- }
1634
- };
1635
-
1636
1782
  // src/kernel/via/compose.ts
1637
1783
  function via(...descriptors) {
1638
1784
  if (descriptors.length === 0) {
@@ -1910,6 +2056,34 @@ function resolveCollectionConfig(opts) {
1910
2056
  `Collection "${opts.name}": embeddings are not supported on CRDT collections (L2). Use a non-CRDT collection for semantic search.`
1911
2057
  );
1912
2058
  }
2059
+ if (opts.tiers && opts.tiers.length > 0 && opts.blobFields !== void 0 && Object.keys(opts.blobFields).length > 0 && opts.perRecordKeys !== true) {
2060
+ throw new UnsupportedTierCompositionError(
2061
+ "blobs",
2062
+ `Collection "${opts.name}": tiered collections that declare blobFields require \`perRecordKeys: true\` \u2014 legacy (non-perRecordKeys) blobs have no per-blob content CEK and cannot be tier-isolated on elevate/demote.`
2063
+ );
2064
+ }
2065
+ if (opts.tiers && opts.tiers.length > 0 && opts.blobFields !== void 0) {
2066
+ for (const [field, policy] of Object.entries(opts.blobFields)) {
2067
+ if (policy?.external && policy.public === true) {
2068
+ throw new UnsupportedTierCompositionError(
2069
+ "blobs",
2070
+ `Collection "${opts.name}": blob field "${field}" cannot be both \`external: true, public: true\` and declared on a tiered collection \u2014 the object key is deterministic and its bytes are world-readable by design, so tier-invisibility can never be enforced for it once elevated. Use a private/presigned external field (\`public\` omitted or \`false\`) or move this field to a non-tiered collection.`
2071
+ );
2072
+ }
2073
+ }
2074
+ }
2075
+ if (opts.tiers && opts.tiers.length > 0 && opts.encrypted === false) {
2076
+ throw new UnsupportedTierCompositionError(
2077
+ "plaintext",
2078
+ `Collection "${opts.name}": tiers are per-tier ENCRYPTION keys \u2014 a plaintext collection (\`encrypted: false\`) has nothing to re-key, so \`putAtTier\`/\`elevate\` would encrypt/decrypt incoherently. Use an encrypted collection.`
2079
+ );
2080
+ }
2081
+ if (opts.tiers && opts.tiers.length > 0 && opts.crdt !== void 0 && ((opts.derivationSource?.registry().strategiesForSource(opts.name).length ?? 0) > 0 || (opts.materializedViewSource?.registry().mvsForSource(opts.name).length ?? 0) > 0)) {
2082
+ throw new UnsupportedTierCompositionError(
2083
+ "crdt-derivation",
2084
+ `Collection "${opts.name}": tiers + crdt cannot be combined with this collection acting as a derivation/rollup source (#739) \u2014 the tier-aware pre-move decode \`syncDerived\` uses on elevate()/demote() does not resolve CRDT state, so a registered derivation/rollup reads raw CrdtState instead of the record and silently no-ops. Use a non-CRDT collection for a tiered derivation/rollup source, or move the derivation off this collection.`
2085
+ );
2086
+ }
1913
2087
  const effectiveViaFields = mergeViaFields(opts);
1914
2088
  const resolvedClassified = opts.classifiedFields !== void 0 ? resolveClassifiedFields(opts.name, opts.classifiedFields) : void 0;
1915
2089
  const allComputed = unifyComputedFields(opts, effectiveViaFields.computedFields);
@@ -2059,7 +2233,9 @@ function resolveCollectionConfig(opts) {
2059
2233
  tiersStrategy: opts.tiersStrategy ?? NO_TIERS,
2060
2234
  searchStrategy: opts.searchStrategy ?? NO_SEARCH,
2061
2235
  tierMode: opts.tierMode ?? "invisibility",
2236
+ blobTierPolicy: opts.blobTierPolicy ?? "isolate",
2062
2237
  onCrossTierAccess: opts.onCrossTierAccess,
2238
+ addSubjectRef: opts.addSubjectRef,
2063
2239
  deterministicFields,
2064
2240
  sensitiveFields,
2065
2241
  vdigFields,
@@ -2072,7 +2248,7 @@ function resolveCollectionConfig(opts) {
2072
2248
  // src/with-formula/computed/lazy.ts
2073
2249
  var fn = null;
2074
2250
  async function loadEvalComputedFields() {
2075
- fn ??= (await import("./computed-ORCGM5JE.js")).evalComputedFields;
2251
+ fn ??= (await import("./computed-ZIQTYTDI.js")).evalComputedFields;
2076
2252
  return fn;
2077
2253
  }
2078
2254
 
@@ -2128,6 +2304,8 @@ var Collection = class {
2128
2304
  blobStrategy;
2129
2305
  objectStore;
2130
2306
  blobFields;
2307
+ blobTierPolicy;
2308
+ // #724 T2/T3
2131
2309
  aggregateStrategy;
2132
2310
  crdtStrategy;
2133
2311
  tiersStrategy;
@@ -2365,11 +2543,10 @@ var Collection = class {
2365
2543
  tiers;
2366
2544
  tierMode;
2367
2545
  onCrossTierAccess;
2546
+ addSubjectRef;
2547
+ // #766: putAtTier's first-write subject-index registration (wired by the Vault; undefined ⇒ no forget-subject field declared)
2368
2548
  /**
2369
- * Optional reference to the vault-level hash-chained audit
2370
- * log. When present, every successful `put()` and `delete()` appends
2371
- * an entry to the ledger AFTER the adapter write succeeds (so a
2372
- * failed adapter write never produces an orphan ledger entry).
2549
+ * Optional reference to the vault-level hash-chained audit log. When present, every successful `put()` and `delete()` appends an entry to the ledger AFTER the adapter write succeeds (so a failed adapter write never produces an orphan ledger entry).
2373
2550
  *
2374
2551
  * The ledger is always a vault-wide singleton — all
2375
2552
  * collections in the same vault share the same LedgerStore.
@@ -2461,6 +2638,7 @@ var Collection = class {
2461
2638
  this.blobStrategy = cfg.blobStrategy;
2462
2639
  this.objectStore = cfg.objectStore;
2463
2640
  this.blobFields = cfg.blobFields;
2641
+ this.blobTierPolicy = cfg.blobTierPolicy ?? "isolate";
2464
2642
  this.aggregateStrategy = cfg.aggregateStrategy;
2465
2643
  this.crdtStrategy = cfg.crdtStrategy;
2466
2644
  this.tiersStrategy = cfg.tiersStrategy;
@@ -2506,6 +2684,7 @@ var Collection = class {
2506
2684
  this.tiers = cfg.tiers;
2507
2685
  this.tierMode = cfg.tierMode;
2508
2686
  this.onCrossTierAccess = cfg.onCrossTierAccess;
2687
+ this.addSubjectRef = cfg.addSubjectRef;
2509
2688
  this.deterministicFields = cfg.deterministicFields;
2510
2689
  this.sensitiveFields = cfg.sensitiveFields;
2511
2690
  this.perRecordCek = cfg.perRecordCek;
@@ -2558,9 +2737,7 @@ var Collection = class {
2558
2737
  const remoteJson = await this.codec.decryptJsonString(remote, id);
2559
2738
  if (localJson === null) return local;
2560
2739
  if (remoteJson === null) return remote;
2561
- const localState = JSON.parse(localJson);
2562
- const remoteState = JSON.parse(remoteJson);
2563
- const merged = this.crdtStrategy.mergeCrdtStates(localState, remoteState);
2740
+ const merged = this.crdtStrategy.mergeCrdtStates(JSON.parse(localJson), JSON.parse(remoteJson));
2564
2741
  const mergedVersion = Math.max(local._v, remote._v) + 1;
2565
2742
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
2566
2743
  return this.codec.encryptJsonString(JSON.stringify(merged), mergedVersion, cek);
@@ -2875,7 +3052,7 @@ var Collection = class {
2875
3052
  }
2876
3053
  await this.onAccess?.("find", "*");
2877
3054
  if (hits.length === 0) return [];
2878
- const { verifyDigestField } = await import("./verify-QK76NJ4G.js");
3055
+ const { verifyDigestField } = await import("./verify-ZASTRNPR.js");
2879
3056
  const policy = {
2880
3057
  normalize: spec.verifyNormalize ?? "password",
2881
3058
  notLastN: spec.notLastN ?? 0,
@@ -3081,7 +3258,7 @@ var Collection = class {
3081
3258
  }
3082
3259
  }
3083
3260
  if (this.materializedViewSource !== void 0) {
3084
- const { resolveStaleMVOnRead } = await import("./stale-TJXFQKOJ.js");
3261
+ const { resolveStaleMVOnRead } = await import("./stale-OSQ7J3AA.js");
3085
3262
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
3086
3263
  }
3087
3264
  let record;
@@ -3092,7 +3269,7 @@ var Collection = class {
3092
3269
  } else {
3093
3270
  const envelope = await this.adapter.get(this.vault, this.name, id);
3094
3271
  if (!envelope) return null;
3095
- if (isTombstone(envelope, this.storeCiphertext) || isDeleteMarker(envelope)) return null;
3272
+ if (isTombstone(envelope, this.storeCiphertext) || isDeleteMarker(envelope) || (envelope._tier ?? 0) > 0) return null;
3096
3273
  record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
3097
3274
  if (record === null) return null;
3098
3275
  this.lru.set(id, { record, version: envelope._v }, estimateRecordBytes(record));
@@ -3119,7 +3296,7 @@ var Collection = class {
3119
3296
  );
3120
3297
  }
3121
3298
  const envelope = await this.adapter.get(this.vault, this.name, id);
3122
- if (!envelope) return null;
3299
+ if (!envelope || (envelope._tier ?? 0) > 0) return null;
3123
3300
  const json = await this.codec.decryptJsonString(envelope);
3124
3301
  if (json === null) return null;
3125
3302
  return JSON.parse(json);
@@ -3236,7 +3413,7 @@ var Collection = class {
3236
3413
  const cached = this.lru.get(id);
3237
3414
  if (cached) return cached.record;
3238
3415
  const env = await this.adapter.get(this.vault, this.name, id);
3239
- if (!env) return void 0;
3416
+ if (!env || (env._tier ?? 0) > 0) return void 0;
3240
3417
  const rec = await this.codec.decryptRecord(env, { id });
3241
3418
  return rec === null ? void 0 : rec;
3242
3419
  }
@@ -3284,7 +3461,7 @@ var Collection = class {
3284
3461
  const cached2 = this.lru.get(id);
3285
3462
  if (cached2) return { record: cached2.record, version: cached2.version };
3286
3463
  const env = await this.adapter.get(this.vault, this.name, id);
3287
- if (!env) return { record: null, version: 0 };
3464
+ if (!env || (env._tier ?? 0) > 0) return { record: null, version: 0 };
3288
3465
  return { record: await this.codec.decryptRecord(env, { skipValidation: true, id }) ?? null, version: env._v };
3289
3466
  }
3290
3467
  await this.ensureHydrated();
@@ -3306,7 +3483,7 @@ var Collection = class {
3306
3483
  async resolvePriorValues(id) {
3307
3484
  if (this.sensitiveFields.size > 0 || this.via?.hasAtRestHooks === true) {
3308
3485
  const env = await this.adapter.get(this.vault, this.name, id);
3309
- if (!env || isTombstone(env, this.storeCiphertext)) return void 0;
3486
+ if (!env || isTombstone(env, this.storeCiphertext) || (env._tier ?? 0) > 0) return void 0;
3310
3487
  const rec = await this.codec.decryptRecord(env, { skipValidation: true, id });
3311
3488
  return rec === null ? void 0 : { record: rec, version: env._v };
3312
3489
  }
@@ -3318,11 +3495,8 @@ var Collection = class {
3318
3495
  if (!this.subsystemBus.gateNeedsPrior(point)) return { env: null, record: null, elided: true };
3319
3496
  const env = await this.adapter.get(this.vault, this.name, id);
3320
3497
  if (!env) return { env: null, record: null, elided: false };
3321
- try {
3322
- return { env, record: await this.codec.decryptRecord(env, { skipValidation: true, id }), elided: false };
3323
- } catch {
3324
- return { env, record: null, elided: false };
3325
- }
3498
+ if ((env._tier ?? 0) > 0) return { env, record: null, elided: false };
3499
+ return { env, record: await this.codec.decryptRecord(env, { skipValidation: true, id }), elided: false };
3326
3500
  }
3327
3501
  /**
3328
3502
  * Wraps {@link RecordCodec.toCacheRecord} with an additional strip for
@@ -3344,6 +3518,7 @@ var Collection = class {
3344
3518
  if (!hasWritePermission(this.keyring, this.name)) {
3345
3519
  throw new ReadOnlyError();
3346
3520
  }
3521
+ await assertTierWritable(this.adapter, this.vault, this.name, id, this.tiers !== null);
3347
3522
  if (this.via) record = this.via.ingest(record);
3348
3523
  if (this.subsystemBus?.hasGateHandlers("beforePut")) {
3349
3524
  const { env: existingEnv, record: existingRecord } = await this.resolveGatePrior("beforePut", id);
@@ -3409,8 +3584,7 @@ var Collection = class {
3409
3584
  }
3410
3585
  }
3411
3586
  }
3412
- const arr = Array.isArray(record) ? record : [record];
3413
- crdtState = this.crdtStrategy.buildRgaState(arr, existingState, generateULID);
3587
+ crdtState = this.crdtStrategy.buildRgaState(Array.isArray(record) ? record : [record], existingState, generateULID);
3414
3588
  } else {
3415
3589
  crdtState = { _crdt: "yjs", update: record };
3416
3590
  }
@@ -3422,9 +3596,7 @@ var Collection = class {
3422
3596
  const existingResolvedRecord = existingEnvelope ? await this.codec.decryptRecord(existingEnvelope, { skipValidation: true }) : null;
3423
3597
  const existingResolved = existingResolvedRecord !== null ? { record: existingResolvedRecord, version: existingVersion } : void 0;
3424
3598
  if (existingResolved && this.historyConfig.enabled !== false) {
3425
- const vdigCtx2 = this.vdigFields !== null ? { id, prev: existingEnvelope } : void 0;
3426
- const histEnvelope = await this.codec.encryptRecord(existingResolved.record, existingResolved.version, cek2, void 0, void 0, vdigCtx2, id);
3427
- await this.historyStrategy.saveHistory(this.adapter, this.vault, this.name, id, histEnvelope);
3599
+ await this.historyStrategy.saveHistory(this.adapter, this.vault, this.name, id, await this.codec.encryptRecord(existingResolved.record, existingResolved.version, cek2, void 0, void 0, this.vdigFields !== null ? { id, prev: existingEnvelope } : void 0, id));
3428
3600
  this.emitter.emit("history:save", { vault: this.vault, collection: this.name, id, version: existingResolved.version });
3429
3601
  if (this.historyConfig.maxVersions) {
3430
3602
  await this.historyStrategy.pruneHistory(this.adapter, this.vault, this.name, id, { keepVersions: this.historyConfig.maxVersions });
@@ -3486,19 +3658,14 @@ var Collection = class {
3486
3658
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
3487
3659
  const vdigCtx = this.vdigFields !== null ? { id, prev: await this.adapter.get(this.vault, this.name, id) } : void 0;
3488
3660
  if (existing && this.historyConfig.enabled !== false) {
3489
- const historyEnvelope = await this.codec.encryptRecord(existing.record, existing.version, cek, void 0, void 0, vdigCtx, id);
3490
- await this.historyStrategy.saveHistory(this.adapter, this.vault, this.name, id, historyEnvelope);
3661
+ await this.historyStrategy.saveHistory(this.adapter, this.vault, this.name, id, await this.codec.encryptRecord(existing.record, existing.version, cek, void 0, void 0, vdigCtx, id));
3491
3662
  this.emitter.emit("history:save", {
3492
3663
  vault: this.vault,
3493
3664
  collection: this.name,
3494
3665
  id,
3495
3666
  version: existing.version
3496
3667
  });
3497
- if (this.historyConfig.maxVersions) {
3498
- await this.historyStrategy.pruneHistory(this.adapter, this.vault, this.name, id, {
3499
- keepVersions: this.historyConfig.maxVersions
3500
- });
3501
- }
3668
+ if (this.historyConfig.maxVersions) await this.historyStrategy.pruneHistory(this.adapter, this.vault, this.name, id, { keepVersions: this.historyConfig.maxVersions });
3502
3669
  }
3503
3670
  const envelope = await this.codec.encryptRecord(record, version, cek, options?.source, options?.sourceTs, vdigCtx, id);
3504
3671
  await this.adapter.put(this.vault, this.name, id, envelope);
@@ -3560,7 +3727,7 @@ var Collection = class {
3560
3727
  if (wave?.seen(`mv\0${reg.spec.name}`)) continue;
3561
3728
  if (executor === null) {
3562
3729
  ;
3563
- ({ MaterializedViewExecutor: executor } = await import("./executor-6OCCE5VM.js"));
3730
+ ({ MaterializedViewExecutor: executor } = await import("./executor-UNEH5ZYH.js"));
3564
3731
  }
3565
3732
  await executor.refresh(reg, {
3566
3733
  getCollection: (name) => this.materializedViewSource.getCollection(name),
@@ -3570,7 +3737,7 @@ var Collection = class {
3570
3737
  });
3571
3738
  } else if (mode === "lazy") {
3572
3739
  if (staleHelpers === null) {
3573
- staleHelpers = await import("./stale-TJXFQKOJ.js");
3740
+ staleHelpers = await import("./stale-OSQ7J3AA.js");
3574
3741
  }
3575
3742
  staleHelpers.markMVStale(registry, reg.spec.name);
3576
3743
  }
@@ -3774,7 +3941,7 @@ var Collection = class {
3774
3941
  continue;
3775
3942
  }
3776
3943
  if (DerivationExecutor === null) {
3777
- ({ DerivationExecutor } = await import("./executor-JFVAJY42.js"));
3944
+ ({ DerivationExecutor } = await import("./executor-OVEXR6RT.js"));
3778
3945
  }
3779
3946
  for (const run of runs) {
3780
3947
  const ctx = { vault: this.derivationSource.getReadOnlyFacade() };
@@ -3794,7 +3961,7 @@ var Collection = class {
3794
3961
  const outputCollection = this.derivationSource.getCollection(outSpec.collection);
3795
3962
  const txCtx = this.derivationSource.getActiveTxContext();
3796
3963
  if (out.kind === "array") {
3797
- const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-IO2KDUWV.js");
3964
+ const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-A765THMX.js");
3798
3965
  const prior = await loadFanoutSidecar(this.adapter, this.vault, spec.source, run.runId, key, this.getDEK, this.storeCiphertext);
3799
3966
  const prevKeys = new Set(prior?.keys ?? []);
3800
3967
  const newKeysList = out.entries.map((e) => e.key);
@@ -3904,13 +4071,11 @@ var Collection = class {
3904
4071
  }
3905
4072
  }
3906
4073
  /**
3907
- * @internal — bulk-rewrite every record through a cutover transform.
3908
- * Raw adapter path (bypasses the write gate + guards — the transform is
3909
- * trusted and runs only during the `migrating` phase). Bumps each
3910
- * record's `_v` and appends a ledger `op:'migration'` entry.
4074
+ * @internal — bulk-rewrite every record through a cutover transform. Raw adapter path (bypasses the write gate + guards — the transform is trusted and runs only during the `migrating` phase). Bumps each record's `_v` and appends a ledger `op:'migration'` entry. #708: refuses BEFORE any rewrite if a live record is elevated (assertCutoverTierSafe) — demote it first.
3911
4075
  */
3912
4076
  async _applyCutoverTransform(transform) {
3913
4077
  const ids = await this.adapter.list(this.vault, this.name);
4078
+ await assertCutoverTierSafe(this.adapter, this.vault, this.name, this.tiers !== null);
3914
4079
  let count = 0;
3915
4080
  for (const id of ids) {
3916
4081
  const env = await this.adapter.get(this.vault, this.name, id);
@@ -3921,8 +4086,7 @@ var Collection = class {
3921
4086
  const next = transform(record);
3922
4087
  const nextVersion = (env._v ?? 0) + 1;
3923
4088
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
3924
- const newEnv = await this.codec.encryptRecord(next, nextVersion, cek, void 0, void 0, this.vdigFields !== null ? { id, prev: env } : void 0, id);
3925
- await this.adapter.put(this.vault, this.name, id, newEnv);
4089
+ await this.adapter.put(this.vault, this.name, id, await this.codec.encryptRecord(next, nextVersion, cek, void 0, void 0, this.vdigFields !== null ? { id, prev: env } : void 0, id));
3926
4090
  await this._onRecordMutated(id, "put", "cutover");
3927
4091
  if (this.ledger) {
3928
4092
  await this.ledger.append({
@@ -3994,13 +4158,14 @@ var Collection = class {
3994
4158
  priorEnvelope: prior
3995
4159
  });
3996
4160
  }
3997
- await this._doDelete(id, true);
3998
- return true;
4161
+ return await this._doDelete(id, true);
3999
4162
  }
4000
4163
  async _doDelete(id, internal) {
4001
4164
  if (!hasWritePermission(this.keyring, this.name)) {
4002
4165
  throw new ReadOnlyError();
4003
4166
  }
4167
+ await assertTierWritable(this.adapter, this.vault, this.name, id, !internal && this.tiers !== null);
4168
+ if (internal && this.tiers !== null && await liveRecordIsElevated(this.adapter, this.vault, this.name, id)) return false;
4004
4169
  if (this.subsystemBus?.hasGateHandlers("beforeDelete")) {
4005
4170
  const { env: existingEnv, record: existingRecord, elided } = await this.resolveGatePrior("beforeDelete", id);
4006
4171
  if (existingEnv || elided) {
@@ -4038,15 +4203,14 @@ var Collection = class {
4038
4203
  if (existing && this.historyConfig.enabled !== false) {
4039
4204
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
4040
4205
  const prevForVdig = this.vdigFields !== null ? await this.adapter.get(this.vault, this.name, id) : null;
4041
- const historyEnvelope = await this.codec.encryptRecord(existing.record, existing.version, cek, void 0, void 0, this.vdigFields !== null ? { id, prev: prevForVdig } : void 0, id);
4042
- await this.historyStrategy.saveHistory(this.adapter, this.vault, this.name, id, historyEnvelope);
4206
+ await this.historyStrategy.saveHistory(this.adapter, this.vault, this.name, id, await this.codec.encryptRecord(existing.record, existing.version, cek, void 0, void 0, this.vdigFields !== null ? { id, prev: prevForVdig } : void 0, id));
4043
4207
  }
4044
4208
  const previousEnvelope = await this.adapter.get(this.vault, this.name, id);
4045
4209
  const previousPayloadHash = await this.historyStrategy.envelopePayloadHash(previousEnvelope);
4046
4210
  let markerVersion;
4047
4211
  if (this.onDirty) {
4048
4212
  const live = previousEnvelope;
4049
- if (!live || isTombstone(live, this.storeCiphertext) || isDeleteMarker(live)) return;
4213
+ if (!live || isTombstone(live, this.storeCiphertext) || isDeleteMarker(live)) return false;
4050
4214
  markerVersion = live._v + 1;
4051
4215
  await this.adapter.put(this.vault, this.name, id, buildDeleteMarker(markerVersion, this.keyring.userId));
4052
4216
  this.markerIds.add(id);
@@ -4081,6 +4245,7 @@ var Collection = class {
4081
4245
  await this.dispatchArrayDerivationsOnDelete(id);
4082
4246
  if (existing) await this.dispatchRollupsOnDelete(id, existing.record);
4083
4247
  }
4248
+ return true;
4084
4249
  }
4085
4250
  /**
4086
4251
  * @internal — GDPR crypto-shred a LIVE record to a tombstone.
@@ -4154,7 +4319,7 @@ var Collection = class {
4154
4319
  continue;
4155
4320
  }
4156
4321
  if (helpers === null) {
4157
- helpers = await import("./fanout-sidecar-IO2KDUWV.js");
4322
+ helpers = await import("./fanout-sidecar-A765THMX.js");
4158
4323
  }
4159
4324
  const sidecar = await helpers.loadFanoutSidecar(this.adapter, this.vault, spec.source, id, outputKey, this.getDEK, this.storeCiphertext);
4160
4325
  if (!sidecar) continue;
@@ -4170,39 +4335,49 @@ var Collection = class {
4170
4335
  /**
4171
4336
  * Mirror of {@link dispatchMaterializedViews} for the delete/forget path — no `_materializedFrom`
4172
4337
  * skip (record's gone); the `internal` gate at `_doDelete` is the recursion guard. Returns the
4173
- * row count TOMBSTONED across every eager MV sourced here (#638 T6 — `forgetDerivedFanout`'s
4174
- * `derivedRecordsErased`); a lazy MV only flips its stale bit (0 contribution — resolved on read).
4338
+ * row count TOMBSTONED across EVERY MV sourced here (#638 T6 — `forgetDerivedFanout`'s
4339
+ * `derivedRecordsErased`) eager AND lazy/manual `invalidateMVAtRest` purges both contribute now
4340
+ * (#761 item 1, previously eager-only); lazy persists a stale mark for cold-session recompute;
4341
+ * manual serves empty until `refreshView()`. `residueUndecodable`/`residueDeclined` (#776/#785) carry `outputCollection:id` entries whose ownership stamp `invalidateMVAtRest` could not decode, resp. decoded+stamp-matched but declined erasure — surfaced, not erased.
4175
4342
  * @internal
4176
4343
  */
4177
4344
  async dispatchMaterializedViewsOnDelete(id) {
4178
- if (this.materializedViewSource === void 0) return 0;
4345
+ if (this.materializedViewSource === void 0) return { deleted: 0, residueUndecodable: [], residueDeclined: [] };
4179
4346
  const registry = this.materializedViewSource.registry();
4180
4347
  const mvs = registry.mvsForSource(this.name);
4181
- if (mvs.length === 0) return 0;
4348
+ if (mvs.length === 0) return { deleted: 0, residueUndecodable: [], residueDeclined: [] };
4182
4349
  let executor = null;
4183
4350
  let staleHelpers = null;
4184
4351
  let deleted = 0;
4352
+ const residueUndecodable = [];
4353
+ const residueDeclined = [];
4185
4354
  for (const reg of mvs) {
4186
4355
  const mode = reg.spec.refresh;
4187
4356
  if (mode === "eager") {
4188
4357
  if (executor === null) {
4189
4358
  ;
4190
- ({ MaterializedViewExecutor: executor } = await import("./executor-6OCCE5VM.js"));
4359
+ ({ MaterializedViewExecutor: executor } = await import("./executor-UNEH5ZYH.js"));
4191
4360
  }
4192
- deleted += (await executor.refresh(reg, {
4361
+ const rr = await executor.refresh(reg, {
4193
4362
  getCollection: (name) => this.materializedViewSource.getCollection(name),
4194
4363
  getActiveTxContext: () => this.materializedViewSource.getActiveTxContext(),
4195
4364
  getQueryContext: () => this.materializedViewSource.getQueryContext(),
4196
4365
  dispatchCtx: this.#dispatchCtx({ collection: this.name, id })
4197
- })).deleted;
4198
- } else if (mode === "lazy") {
4366
+ });
4367
+ deleted += rr.deleted;
4368
+ residueUndecodable.push(...rr.residueUndecodable);
4369
+ residueDeclined.push(...rr.residueDeclined);
4370
+ } else {
4199
4371
  if (staleHelpers === null) {
4200
- staleHelpers = await import("./stale-TJXFQKOJ.js");
4372
+ staleHelpers = await import("./stale-OSQ7J3AA.js");
4201
4373
  }
4202
- staleHelpers.markMVStale(registry, reg.spec.name);
4374
+ const inv = await staleHelpers.invalidateMVAtRest(this.materializedViewSource, reg, mode);
4375
+ deleted += inv.deleted;
4376
+ residueUndecodable.push(...inv.residueUndecodable.map((rid) => `${reg.outputCollection}:${rid}`));
4377
+ residueDeclined.push(...inv.residueDeclined.map((rid) => `${reg.outputCollection}:${rid}`));
4203
4378
  }
4204
4379
  }
4205
- return deleted;
4380
+ return { deleted, residueUndecodable, residueDeclined };
4206
4381
  }
4207
4382
  /**
4208
4383
  * List all records in the collection.
@@ -4221,7 +4396,7 @@ var Collection = class {
4221
4396
  );
4222
4397
  }
4223
4398
  if (this.materializedViewSource !== void 0) {
4224
- const { resolveStaleMVOnRead } = await import("./stale-TJXFQKOJ.js");
4399
+ const { resolveStaleMVOnRead } = await import("./stale-OSQ7J3AA.js");
4225
4400
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
4226
4401
  }
4227
4402
  await this.ensureHydrated();
@@ -4260,6 +4435,11 @@ var Collection = class {
4260
4435
  similarTo(vector, opts = {}) {
4261
4436
  return this.searchStrategy.similarTo(this.searchContext(), vector, opts);
4262
4437
  }
4438
+ /** Opt-in bulk `_vec` re-derive (#788) — a plain collection has nothing to rebuild; gated behind `searchStrategy: withSearch()` otherwise. */
4439
+ rebuildEmbeddings() {
4440
+ if (!this.embeddings) return Promise.resolve({ rebuilt: 0, skipped: 0 });
4441
+ return this.searchStrategy.rebuildEmbeddings(this.searchContext());
4442
+ }
4263
4443
  /**
4264
4444
  * Bind the {@link SearchContext} the search/retrieval surface needs. The
4265
4445
  * `cache` is the SAME `Map` reference the eager read/write path owns (passed
@@ -4379,8 +4559,7 @@ var Collection = class {
4379
4559
  if (op.collectionName === this.name) {
4380
4560
  await this._invalidateCacheEntry(op.id);
4381
4561
  } else if (this.derivationSource) {
4382
- const sibling = this.derivationSource.getCollection(op.collectionName);
4383
- await sibling._invalidateCacheEntry(op.id);
4562
+ await this.derivationSource.getCollection(op.collectionName)._invalidateCacheEntry(op.id);
4384
4563
  }
4385
4564
  } catch {
4386
4565
  }
@@ -4590,8 +4769,10 @@ var Collection = class {
4590
4769
  id,
4591
4770
  options
4592
4771
  );
4772
+ if (await liveRecordIsElevated(this.adapter, this.vault, this.name, id)) return [];
4593
4773
  const entries = [];
4594
4774
  for (const env of envelopes) {
4775
+ if ((env._tier ?? 0) > 0) continue;
4595
4776
  const record = await this.codec.decryptRecord(env, { skipValidation: true, id });
4596
4777
  if (record === null) continue;
4597
4778
  entries.push({
@@ -4620,7 +4801,7 @@ var Collection = class {
4620
4801
  id,
4621
4802
  version
4622
4803
  );
4623
- if (!envelope) return null;
4804
+ if (!envelope || (envelope._tier ?? 0) > 0 || await liveRecordIsElevated(this.adapter, this.vault, this.name, id)) return null;
4624
4805
  return this.codec.decryptRecord(envelope, { skipValidation: true, id });
4625
4806
  }
4626
4807
  /** Revert a record to a past version. Creates a new version with the old content. */
@@ -4638,8 +4819,7 @@ var Collection = class {
4638
4819
  */
4639
4820
  async diff(id, versionA, versionB) {
4640
4821
  const recordA = versionA === 0 ? null : await this.resolveVersion(id, versionA);
4641
- const recordB = versionB === void 0 || versionB === 0 ? versionB === 0 ? null : await this.resolveCurrentOrVersion(id) : await this.resolveVersion(id, versionB);
4642
- return this.historyStrategy.diff(recordA, recordB);
4822
+ return this.historyStrategy.diff(recordA, versionB === void 0 || versionB === 0 ? versionB === 0 ? null : await this.resolveCurrentOrVersion(id) : await this.resolveVersion(id, versionB));
4643
4823
  }
4644
4824
  /** Resolve a version: try history first, then check if it's the current version. */
4645
4825
  async resolveVersion(id, version) {
@@ -4681,14 +4861,13 @@ var Collection = class {
4681
4861
  /**
4682
4862
  * Count records in the collection.
4683
4863
  *
4684
- * In eager mode this returns the in-memory cache size (instant). In
4685
- * lazy mode it asks the adapter via `list()` to enumerate idsslower
4686
- * but still correct, and avoids loading any record bodies into memory.
4864
+ * In eager mode this returns the in-memory cache size (instant). In lazy
4865
+ * mode it counts only LIVE tier-0 envelopes via envelope inspectionno
4866
+ * record bodies loaded matching eager's tombstone/tier exclusion (#706).
4687
4867
  */
4688
4868
  async count() {
4689
4869
  if (this.lazy) {
4690
- const ids = await this.adapter.list(this.vault, this.name);
4691
- return ids.length;
4870
+ return countLiveEnvelopes(this.adapter, this.vault, this.name, this.storeCiphertext);
4692
4871
  }
4693
4872
  await this.ensureHydrated();
4694
4873
  return this.cache.size;
@@ -4728,7 +4907,7 @@ var Collection = class {
4728
4907
  for (let i = start; i < end; i++) {
4729
4908
  const id = ids[i];
4730
4909
  const envelope = await this.adapter.get(this.vault, this.name, id);
4731
- if (envelope) {
4910
+ if (envelope && (envelope._tier ?? 0) === 0) {
4732
4911
  const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
4733
4912
  if (record === null) continue;
4734
4913
  items.push(record);
@@ -4810,6 +4989,7 @@ var Collection = class {
4810
4989
  async decryptPage(items) {
4811
4990
  const out = [];
4812
4991
  for (const { id, envelope } of items) {
4992
+ if ((envelope._tier ?? 0) > 0) continue;
4813
4993
  const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
4814
4994
  if (record === null) continue;
4815
4995
  out.push({ id, record, version: envelope._v });
@@ -4851,8 +5031,7 @@ var Collection = class {
4851
5031
  async _compensateRevertedWrite(id) {
4852
5032
  await this._invalidateCacheEntry(id);
4853
5033
  await this.onDirty?.(this.name, id, "revert", 0);
4854
- const restored = await this.get(id);
4855
- this.emitter.emit("change", { vault: this.vault, collection: this.name, id, action: restored !== null ? "put" : "delete" });
5034
+ this.emitter.emit("change", { vault: this.vault, collection: this.name, id, action: await this.get(id) !== null ? "put" : "delete" });
4856
5035
  }
4857
5036
  async _invalidateCacheEntry(id) {
4858
5037
  if (this.lazy && this.lru) {
@@ -4967,7 +5146,7 @@ var Collection = class {
4967
5146
  const ids = await this.adapter.list(this.vault, this.name);
4968
5147
  for (const id of ids) {
4969
5148
  const envelope = await this.adapter.get(this.vault, this.name, id);
4970
- if (envelope && !isTombstone(envelope, this.storeCiphertext) && !isDeleteMarker(envelope)) {
5149
+ if (envelope && !isTombstone(envelope, this.storeCiphertext) && !isDeleteMarker(envelope) && (envelope._tier ?? 0) === 0) {
4971
5150
  const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
4972
5151
  if (record === null) continue;
4973
5152
  this.cache.set(id, { record, version: envelope._v });
@@ -4986,7 +5165,7 @@ var Collection = class {
4986
5165
  this.markerIds.add(id);
4987
5166
  continue;
4988
5167
  }
4989
- if (isTombstone(envelope, this.storeCiphertext)) continue;
5168
+ if (isTombstone(envelope, this.storeCiphertext) || (envelope._tier ?? 0) > 0) continue;
4990
5169
  const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
4991
5170
  if (record === null) continue;
4992
5171
  this.cache.set(id, { record, version: envelope._v });
@@ -5107,6 +5286,8 @@ var Collection = class {
5107
5286
  encrypted: this.storeCiphertext,
5108
5287
  userId: this.keyring.userId,
5109
5288
  erasableBlobs: this.perRecordCek,
5289
+ tiersActive: this.tiers !== null,
5290
+ keyring: this.keyring,
5110
5291
  debugPlaintext: this.keyring.debugPlaintext === true,
5111
5292
  ...this.objectStore !== void 0 ? { objectStore: this.objectStore } : {},
5112
5293
  ...this.blobFields !== void 0 ? { blobFields: this.blobFields } : {}
@@ -5199,7 +5380,7 @@ var Collection = class {
5199
5380
  /** Drop a record's encrypted _vec sidecar on erasure (a vector is text-invertible).
5200
5381
  * Called by vault.ts forget() inside a resilient try/catch; residue is reported in ForgetResult. */
5201
5382
  async _purgeVector(id) {
5202
- await this.adapter.delete(this.vault, "_vec", id);
5383
+ await this.adapter.delete(this.vault, "_vec", encodeVecId(this.name, id));
5203
5384
  this.vectorSet?.markDirty();
5204
5385
  }
5205
5386
  /** Drop the persisted lexical-index blob (forget/erasure): an opaque
@@ -5368,14 +5549,14 @@ var Collection = class {
5368
5549
  /** C-A/R10: persist the classified marker once per classified handle (store I/O in config-drift.ts). */
5369
5550
  async _ensureClassifiedMarker() {
5370
5551
  if (this._markerPersisted || this.vdigFields === null) return;
5371
- const { persistClassifiedMarkerForFields } = await import("./classified-marker-M7K3OJPM.js");
5552
+ const { persistClassifiedMarkerForFields } = await import("./classified-marker-CZKA6ITE.js");
5372
5553
  await persistClassifiedMarkerForFields(this.adapter, this.vault, this.name, this.vdigFields, await this.getDEK(this.name));
5373
5554
  this._markerPersisted = true;
5374
5555
  }
5375
5556
  /** C-A/R10 drift signal — the marker's declared digest-only set, memoized to one store read per handle (see config-drift.ts). */
5376
5557
  async _classifiedMarkerDigestOnly() {
5377
5558
  if (this._markerDigestOnlyCache !== void 0) return this._markerDigestOnlyCache;
5378
- const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-M7K3OJPM.js");
5559
+ const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-CZKA6ITE.js");
5379
5560
  this._markerDigestOnlyCache = await readClassifiedMarkerDigestOnly(this.adapter, this.vault, this.name, await this.getDEK(this.name));
5380
5561
  return this._markerDigestOnlyCache;
5381
5562
  }
@@ -5415,7 +5596,7 @@ var Collection = class {
5415
5596
  };
5416
5597
  }
5417
5598
  // ─── Hierarchical Access ──────────────────────────
5418
- /** tier-aware put — gated behind `tiersStrategy: withTiers()`. */
5599
+ /** tier-aware put — gated behind `tiersStrategy: withTiers()`. `searchResidue: true` = stuck search compensation (#774, mirroring #764's elevate/demote posture); the write itself always completes. */
5419
5600
  putAtTier(id, record, tier, opts) {
5420
5601
  return this.tiersStrategy.putAtTier(this.tiersContext(), id, record, tier, opts);
5421
5602
  }
@@ -5427,18 +5608,16 @@ var Collection = class {
5427
5608
  listAtTier() {
5428
5609
  return this.tiersStrategy.listAtTier(this.tiersContext());
5429
5610
  }
5430
- /** elevate a record to a higher tier — gated behind `withTiers()`. */
5611
+ /** elevate a record to a higher tier — gated behind `withTiers()`. `searchResidue: true` = stuck search compensation (#764); the move itself always completes. */
5431
5612
  elevate(id, toTier) {
5432
5613
  return this.tiersStrategy.elevate(this.tiersContext(), id, toTier);
5433
5614
  }
5434
- /** demote a record to a lower tier — gated behind `withTiers()`. */
5615
+ /** demote a record to a lower tier — gated behind `withTiers()`. Same `searchResidue` posture as {@link elevate} (#764). */
5435
5616
  demote(id, toTier) {
5436
5617
  return this.tiersStrategy.demote(this.tiersContext(), id, toTier);
5437
5618
  }
5438
5619
  /**
5439
- * Emit a cross-tier access event. The subscriber sink stays collection-
5440
- * resident (it captures `onCrossTierAccess`); the tiers module reaches it
5441
- * via the {@link TiersContext.emitCrossTierEvent} callback.
5620
+ * Emit a cross-tier access event. The subscriber sink stays collection-resident (it captures `onCrossTierAccess`); the tiers module reaches it via the {@link TiersContext.emitCrossTierEvent} callback.
5442
5621
  */
5443
5622
  emitCrossTierEvent(event) {
5444
5623
  try {
@@ -5479,9 +5658,7 @@ var Collection = class {
5479
5658
  if (patch.presentForJoin) this.presentForJoin = patch.presentForJoin;
5480
5659
  }
5481
5660
  /**
5482
- * Bind the {@link TiersContext} the tier ops need. The `cekCache` is passed
5483
- * by reference (the SAME `Lru` the kernel's read/write path owns) so an
5484
- * elevate/demote CEK re-wrap stays synchronous with cache eviction.
5661
+ * Bind the {@link TiersContext} the tier ops need `cekCache` by reference (same `Lru` the read/write path owns) for a synchronous re-wrap; `syncDerived` closes over `this` for {@link syncDerivedOutputs} (#722).
5485
5662
  */
5486
5663
  tiersContext() {
5487
5664
  return {
@@ -5491,19 +5668,43 @@ var Collection = class {
5491
5668
  keyring: this.keyring,
5492
5669
  codec: this.codec,
5493
5670
  cekCache: this.cekCache,
5671
+ syncCache: (id, e) => {
5672
+ if (e) this.cache.set(id, e);
5673
+ else this.cache.delete(id);
5674
+ this.lru?.remove(id);
5675
+ },
5676
+ syncIndexes: (id, rec, version, priorEnvelope) => syncTierIndexes(this.indexingContext(), id, rec, version, priorEnvelope),
5677
+ syncSearch: (id, rec, version) => syncTierSearch(this.searchContext(), id, rec, version),
5678
+ syncHistory: async (id, fromDek, toDek) => this.historyStrategy.rewrapHistory(this.adapter, this.vault, this.name, id, fromDek, toDek, await this.getDEK(this.name)),
5679
+ saveHistorySnapshot: async (id, envelope) => {
5680
+ if (this.historyConfig.enabled === false) return;
5681
+ await this.historyStrategy.saveHistory(this.adapter, this.vault, this.name, id, envelope);
5682
+ this.emitter.emit("history:save", { vault: this.vault, collection: this.name, id, version: envelope._v });
5683
+ if (this.historyConfig.maxVersions) await this.historyStrategy.pruneHistory(this.adapter, this.vault, this.name, id, { keepVersions: this.historyConfig.maxVersions });
5684
+ },
5685
+ historyEnabled: this.historyConfig.enabled !== false && this.historyStrategy !== NO_HISTORY,
5686
+ // #728/#737: lets putAtTier skip decrypting `existing` when no real history strategy is wired
5687
+ syncBlobs: (id, fromTier, toTier) => this.blobStrategy !== NO_BLOBS ? this.blob(id).syncTierMove(fromTier, toTier, this.blobTierPolicy) : Promise.resolve(),
5688
+ // #724 I1: gate on blob storage enabled (not on declared blobFields) so undeclared-field blobs still rehome; #746: syncTierMove mints/resumes the rehome journal marker; self-no-ops on an empty slot map
5689
+ syncLedger: async (id) => {
5690
+ await this.ledger?.purgeRecordDeltas(this.name, id);
5691
+ },
5692
+ syncDerived: (id, record, elevated, version) => syncDerivedOutputs(this, id, record, elevated, version),
5693
+ hasDerivedOutputs: this.materializedViewSource !== void 0 && this.materializedViewSource.registry().mvsForSource(this.name).length > 0 || this.derivationSource !== void 0 && this.derivationSource.registry().strategiesForSource(this.name).length > 0,
5694
+ // #737: source-grained (was vault-grained) — a derivation-free tiered collection skips the pre-move decode even when other collections in the vault have derivations
5494
5695
  provenance: this.provenance,
5495
5696
  tiers: this.tiers,
5496
5697
  tierMode: this.tierMode,
5497
5698
  getDEK: (key) => this.getDEK(key),
5498
- emitCrossTierEvent: (event) => this.emitCrossTierEvent(event)
5699
+ emitCrossTierEvent: (event) => this.emitCrossTierEvent(event),
5700
+ addSubjectRef: (id, record) => this.addSubjectRef?.(id, record) ?? Promise.resolve()
5499
5701
  };
5500
5702
  }
5501
5703
  /**
5502
5704
  * Bind the {@link IndexingContext} the index-maintenance surface needs. The
5503
5705
  * eager `cache` Map and the index / unique-constraint / persisted mirrors are
5504
5706
  * passed by reference (the SAME instances the query path reads, never
5505
- * copied); the `persistedIndexesLoaded` flag and `ensure*` hydration stay
5506
- * collection-resident, reached via callbacks.
5707
+ * copied); the `persistedIndexesLoaded` flag and `ensure*` hydration stay collection-resident, reached via callbacks.
5507
5708
  */
5508
5709
  indexingContext() {
5509
5710
  return {
@@ -5554,9 +5755,12 @@ var ElevatedHandle = class {
5554
5755
  */
5555
5756
  collection(name) {
5556
5757
  return {
5758
+ // #779 — surface `_elevatedPut`'s `TierMoveResult` (searchResidue) instead of
5759
+ // discarding it, so a stuck search compensation on this convenience path is
5760
+ // observable by the caller, mirroring `putAtTier`'s direct-call parity (#774).
5557
5761
  put: async (id, record) => {
5558
5762
  this.assertActive();
5559
- await this.vault._elevatedPut(name, id, record, this.tier, this.reason);
5763
+ return await this.vault._elevatedPut(name, id, record, this.tier, this.reason);
5560
5764
  }
5561
5765
  };
5562
5766
  }
@@ -6773,7 +6977,7 @@ var VaultLinks = class {
6773
6977
  // src/with-shape/links/lazy-handle.ts
6774
6978
  function makeLazyLinkSetHandle(d) {
6775
6979
  let engine = null;
6776
- const load = () => engine ??= import("./link-set-DGYUOFVD.js").then(
6980
+ const load = () => engine ??= import("./link-set-Z7Q2ASFX.js").then(
6777
6981
  ({ LinkSet }) => new LinkSet(d.adapter, d.vault, d.name, d.spec, d.encrypted, d.getDEK, d.actor, d.emitter, d.endpointExists)
6778
6982
  );
6779
6983
  return {
@@ -7311,7 +7515,7 @@ function declareSatellite(ctx, collectionName, options, existingRegistry) {
7311
7515
  ctx.forEachSyncEngine((e) => e.remirrorPairResolvers([spec.base, spec.satellite]));
7312
7516
  const registry = reg;
7313
7517
  const baseSchema = ctx.getBaseSchema(spec.base);
7314
- void import("./post-register-LB3P4XQU.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
7518
+ void import("./post-register-JTH76BLY.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
7315
7519
  });
7316
7520
  return reg;
7317
7521
  }
@@ -8305,7 +8509,7 @@ var Vault = class {
8305
8509
  const strategies = options.schemaUpdate ?? [];
8306
8510
  const work = (async () => {
8307
8511
  const dek = await this.getDEK(collectionName);
8308
- const { persistSchemaIfNeeded } = await import("./register-ZI7YI7US.js");
8512
+ const { persistSchemaIfNeeded } = await import("./register-VAHONCID.js");
8309
8513
  const result = await persistSchemaIfNeeded({
8310
8514
  store: this.adapter,
8311
8515
  vault: this.name,
@@ -8418,9 +8622,7 @@ var Vault = class {
8418
8622
  if (options?.sensitive !== void 0) {
8419
8623
  collOpts.sensitive = options.sensitive;
8420
8624
  }
8421
- if (options?.perRecordKeys !== void 0) {
8422
- collOpts.perRecordKeys = options.perRecordKeys;
8423
- }
8625
+ if (options?.perRecordKeys !== void 0) collOpts.perRecordKeys = options.perRecordKeys;
8424
8626
  const subjectKey = this.forgetStrategy.subjects[collectionName];
8425
8627
  if (subjectKey !== void 0) {
8426
8628
  if (options?.perRecordKeys === false) {
@@ -8430,11 +8632,16 @@ var Vault = class {
8430
8632
  }
8431
8633
  collOpts.perRecordKeys = true;
8432
8634
  collOpts.subjectKeyField = subjectKey;
8635
+ collOpts.addSubjectRef = async (id, record) => {
8636
+ const value = readDottedPath(record, subjectKey);
8637
+ if (value !== void 0 && value !== null) await this._addSubjectRef(coerceSubjectId(value), { collection: collectionName, id });
8638
+ };
8433
8639
  }
8434
8640
  if (options?.provenance !== void 0) collOpts.provenance = options.provenance;
8435
8641
  if (options?.ramCiphertext !== void 0) collOpts.ramCiphertext = options.ramCiphertext;
8436
8642
  if (options?.tiers !== void 0) collOpts.tiers = options.tiers;
8437
8643
  if (options?.tierMode !== void 0) collOpts.tierMode = options.tierMode;
8644
+ if (options?.blobTierPolicy !== void 0) collOpts.blobTierPolicy = options.blobTierPolicy;
8438
8645
  collOpts.onCrossTierAccess = (event) => this.emitCrossTier(event);
8439
8646
  if (this.syncAdapter !== void 0) collOpts.syncAdapter = this.syncAdapter;
8440
8647
  if (options?.i18nFields !== void 0) collOpts.i18nFields = options.i18nFields;
@@ -8501,7 +8708,7 @@ var Vault = class {
8501
8708
  const work = (async () => {
8502
8709
  try {
8503
8710
  const dek = await this.getDEK(collectionName);
8504
- await (await import("./register-ZI7YI7US.js")).persistSchemaIfNeeded({
8711
+ await (await import("./register-VAHONCID.js")).persistSchemaIfNeeded({
8505
8712
  store: this.adapter,
8506
8713
  vault: this.name,
8507
8714
  collectionName,
@@ -9375,6 +9582,8 @@ var Vault = class {
9375
9582
  if (Object.keys(this.forgetStrategy.subjects).length === 0) {
9376
9583
  throw new ForgetStrategyNotConfiguredError();
9377
9584
  }
9585
+ const ledger = this.getLedgerOrNull();
9586
+ if (!ledger) throw new Error('vault.forget() requires the history strategy for the erasure-proof ledger entry. Pass `historyStrategy: withHistory()` from "@noy-db/hub/history" to createNoydb().');
9378
9587
  const refs = await lookupSubject(this.adapter, this.name, this.getDEK, this.encrypted, subjectId);
9379
9588
  const allRefs = expandRefsWithSatellites(refs, this.satelliteRegistry);
9380
9589
  let recordsShredded = 0;
@@ -9387,12 +9596,14 @@ var Vault = class {
9387
9596
  let indexPostingsPurged = 0;
9388
9597
  let sealedFieldsShredded = 0;
9389
9598
  let sealedCekEnvelopesPurged = 0;
9599
+ let ledgerDeltasPurged = 0;
9390
9600
  const sealedCekResidue = [];
9391
9601
  const sealedResidue = [];
9392
9602
  const indexResidue = [];
9603
+ const ledgerDeltaResidue = [];
9393
9604
  const blobsEnabled = this.blobStrategy !== void 0;
9394
9605
  const actor = this.keyring.userId;
9395
- const fanoutStats = { recordsErased: 0, aggregatesRecomputed: 0, residueFrozen: [], lookupReferencesCascaded: 0, lookupReferencesNullified: 0, lookupReferencesResidue: [] };
9606
+ const fanoutStats = { recordsErased: 0, aggregatesRecomputed: 0, residueFrozen: [], lookupReferencesCascaded: 0, lookupReferencesNullified: 0, lookupReferencesResidue: [], derivedResidueUndecodable: [], derivedResidueDeclined: [] };
9396
9607
  const { partitionSealedCekKeys, shouldSkipBlobScan, bumpResidueCount, residueNoticesFromMap } = await import("./purge-scope-FGNNLWHD.js");
9397
9608
  const scopedPurge = this.forgetStrategy.scopedPurge === true;
9398
9609
  const sealedCekScopedSkipped = /* @__PURE__ */ new Map();
@@ -9437,6 +9648,13 @@ var Vault = class {
9437
9648
  } catch {
9438
9649
  sealedCekResidue.push(`${ref2.collection}:${ref2.id}`);
9439
9650
  }
9651
+ if (blobsEnabled && !shouldSkipBlobScan(scopedPurge, this.blobFieldsRegistry.has(ref2.collection))) {
9652
+ try {
9653
+ await coll.blob(ref2.id).mintShredIntent(live?._tier ?? 0);
9654
+ } catch {
9655
+ blobResidueCollections.add(ref2.collection);
9656
+ }
9657
+ }
9440
9658
  let shred;
9441
9659
  try {
9442
9660
  shred = await coll._writeTombstone(ref2.id, actor);
@@ -9461,6 +9679,11 @@ var Vault = class {
9461
9679
  actor,
9462
9680
  this.encrypted
9463
9681
  );
9682
+ try {
9683
+ ledgerDeltasPurged += await ledger.purgeRecordDeltas(ref2.collection, ref2.id);
9684
+ } catch {
9685
+ ledgerDeltaResidue.push(`${ref2.collection}:${ref2.id}`);
9686
+ }
9464
9687
  const idxPurge = await coll._purgePersistedIndexes(ref2.id);
9465
9688
  indexPostingsPurged += idxPurge.purged;
9466
9689
  for (const field of idxPurge.residue) indexResidue.push(`${ref2.collection}:${ref2.id}:${field}`);
@@ -9472,14 +9695,14 @@ var Vault = class {
9472
9695
  if (blobsEnabled && shouldSkipBlobScan(scopedPurge, this.blobFieldsRegistry.has(ref2.collection))) {
9473
9696
  bumpResidueCount(blobScopedSkipped, ref2.collection, 1);
9474
9697
  } else if (blobsEnabled) {
9475
- const r = await this.collection(ref2.collection).blob(ref2.id).shredAllForRecord();
9698
+ const r = await this.collection(ref2.collection).blob(ref2.id).shredAllForRecord(live?._tier ?? 0);
9476
9699
  blobsShredded += r.shredded.length;
9477
9700
  blobsRetainedShared += r.retainedShared.length;
9478
9701
  if (r.residue.length > 0) blobResidueCollections.add(ref2.collection);
9479
9702
  } else {
9480
9703
  try {
9481
- const slotIds = await this.adapter.list(this.name, `_blob_slots_${ref2.collection}`);
9482
- if (slotIds.includes(ref2.id)) blobResidueCollections.add(ref2.collection);
9704
+ const [slotIds, verKeys] = await Promise.all([this.adapter.list(this.name, `_blob_slots_${ref2.collection}`), this.adapter.list(this.name, `_blob_versions_${ref2.collection}`)]);
9705
+ if (slotIds.includes(ref2.id) || verKeys.some((k) => k.startsWith(`${ref2.id}::`))) blobResidueCollections.add(ref2.collection);
9483
9706
  } catch {
9484
9707
  }
9485
9708
  }
@@ -9493,12 +9716,6 @@ var Vault = class {
9493
9716
  }
9494
9717
  }
9495
9718
  const subjectHash = await sha256Hex(subjectId);
9496
- const ledger = this.getLedgerOrNull();
9497
- if (!ledger) {
9498
- throw new Error(
9499
- 'vault.forget() requires the history strategy for the erasure-proof ledger entry. Pass `historyStrategy: withHistory()` from "@noy-db/hub/history" to createNoydb().'
9500
- );
9501
- }
9502
9719
  const ledgerEntry = await ledger.append({
9503
9720
  op: "forget",
9504
9721
  collection: "",
@@ -9519,7 +9736,9 @@ var Vault = class {
9519
9736
  sealedFieldsShredded,
9520
9737
  sealedCekEnvelopesPurged,
9521
9738
  sealedCekResidueCount: sealedCekResidue.length,
9522
- sealedResidueCount: sealedResidue.length
9739
+ sealedResidueCount: sealedResidue.length,
9740
+ ledgerDeltasPurged,
9741
+ ledgerDeltaResidueCount: ledgerDeltaResidue.length
9523
9742
  })
9524
9743
  });
9525
9744
  const scopedPurgeResidue = [...residueNoticesFromMap(sealedCekScopedSkipped, "skipped-undeclared-sealed-cek"), ...residueNoticesFromMap(blobScopedSkipped, "skipped-undeclared-blob-scan")];
@@ -9545,8 +9764,13 @@ var Vault = class {
9545
9764
  lookupReferencesCascaded: fanoutStats.lookupReferencesCascaded,
9546
9765
  lookupReferencesNullified: fanoutStats.lookupReferencesNullified,
9547
9766
  lookupReferencesResidue: fanoutStats.lookupReferencesResidue,
9548
- scopedPurgeResidue
9549
- // #650 Task 5 (+ review Important fix: residue) + #633
9767
+ scopedPurgeResidue,
9768
+ ledgerDeltasPurged,
9769
+ ledgerDeltaResidue,
9770
+ // #650 Task 5 (+ review Important fix: residue) + #633 + #734
9771
+ derivedResidueUndecodable: fanoutStats.derivedResidueUndecodable,
9772
+ derivedResidueDeclined: fanoutStats.derivedResidueDeclined
9773
+ // #776/#785
9550
9774
  };
9551
9775
  }
9552
9776
  // ─── Record-scoped CEK sealing ─────────────────────────────────────
@@ -9669,7 +9893,7 @@ var Vault = class {
9669
9893
  async _initDerivations(handles) {
9670
9894
  if (handles.length === 0) return;
9671
9895
  const [{ DerivationRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
9672
- import("./registry-NVWEQ2GU.js"),
9896
+ import("./registry-EPKPD5SM.js"),
9673
9897
  import("./read-only-facade-CHCKSEPD.js")
9674
9898
  ]);
9675
9899
  const registry = new DerivationRegistry();
@@ -9701,7 +9925,7 @@ var Vault = class {
9701
9925
  */
9702
9926
  async _initMaterializedViews(handles) {
9703
9927
  if (handles.length === 0) return;
9704
- const { MaterializedViewRegistry } = await import("./registry-SEKL74ET.js");
9928
+ const { MaterializedViewRegistry } = await import("./registry-7MLVD3VO.js");
9705
9929
  const registry = new MaterializedViewRegistry();
9706
9930
  this.materializedViewRegistry = registry;
9707
9931
  const db = this;
@@ -9726,7 +9950,7 @@ var Vault = class {
9726
9950
  */
9727
9951
  async _initOverlayedViews(handles) {
9728
9952
  if (handles.length === 0) return;
9729
- const { OverlayedViewRegistry } = await import("./registry-DZ2T4LL7.js");
9953
+ const { OverlayedViewRegistry } = await import("./registry-P5T7PS2U.js");
9730
9954
  const registry = new OverlayedViewRegistry();
9731
9955
  const mvRegistry = this.materializedViewRegistry;
9732
9956
  const overlayNames = /* @__PURE__ */ new Set();
@@ -9761,27 +9985,27 @@ var Vault = class {
9761
9985
  /**
9762
9986
  * Manual re-materialize for a single registered MV (`refresh: 'manual'` consumers,
9763
9987
  * stale-bit recovery on vault reopen, bulk-recompute escape hatch after a strategy
9764
- * change). Returns `{ written, deleted, failed }` (`deleted` always 0 without
9765
- * tombstoning). Throws if `name` is not a registered MV.
9988
+ * change). Returns `{ written, deleted, failed, residueUndecodable, residueDeclined }` (`deleted`
9989
+ * always 0 without tombstoning; #785 splits the #782 leftovers — undecodable vs #718-declined). Throws if not registered.
9766
9990
  */
9767
9991
  async refreshView(name) {
9768
9992
  const registry = this.materializedViewRegistry;
9769
9993
  if (registry === null) {
9770
- return { written: 0, deleted: 0, failed: 0 };
9994
+ return { written: 0, deleted: 0, failed: 0, residueUndecodable: [], residueDeclined: [] };
9771
9995
  }
9772
9996
  const reg = registry.byName(name);
9773
9997
  if (!reg) {
9774
9998
  throw new Error(`refreshView: no MV registered with name "${name}"`);
9775
9999
  }
9776
- const { MaterializedViewExecutor } = await import("./executor-6OCCE5VM.js");
10000
+ const { MaterializedViewExecutor } = await import("./executor-UNEH5ZYH.js");
9777
10001
  const result = await MaterializedViewExecutor.refresh(reg, {
9778
10002
  getCollection: (n) => this.collection(n),
9779
10003
  getActiveTxContext: () => this.noydb._activeTxContextOrNull,
9780
10004
  getQueryContext: () => this,
9781
10005
  dispatchCtx: this._dispatchCtx({ collection: name, id: "refreshView" })
9782
10006
  });
9783
- const { clearMVStale } = await import("./stale-TJXFQKOJ.js");
9784
- clearMVStale(registry, name);
10007
+ const { clearMVStaleFully } = await import("./stale-OSQ7J3AA.js");
10008
+ await clearMVStaleFully(this.adapter, this.name, registry, name);
9785
10009
  return result;
9786
10010
  }
9787
10011
  /**
@@ -9793,7 +10017,7 @@ var Vault = class {
9793
10017
  if (registry === null) return { derived: 0, failed: 0, skippedFrozen: 0 };
9794
10018
  const strategies = registry.strategiesForSource(sourceCollection);
9795
10019
  if (strategies.length === 0) return { derived: 0, failed: 0, skippedFrozen: 0 };
9796
- const { DerivationExecutor } = await import("./executor-JFVAJY42.js");
10020
+ const { DerivationExecutor } = await import("./executor-OVEXR6RT.js");
9797
10021
  const sourceColl = this.collection(sourceCollection);
9798
10022
  const records = await sourceColl.list();
9799
10023
  const ctx = { vault: this.derivationFacade ?? new (await import("./read-only-facade-CHCKSEPD.js")).ReadOnlyVaultFacade(this, "derivation") };
@@ -9820,7 +10044,7 @@ var Vault = class {
9820
10044
  if (!outSpec) continue;
9821
10045
  const outputColl = this.collection(outSpec.collection);
9822
10046
  if (out.kind === "array") {
9823
- const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-IO2KDUWV.js");
10047
+ const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-A765THMX.js");
9824
10048
  const prior = await loadFanoutSidecar(this.adapter, this.name, spec.source, id, key, this.getDEK, this.encrypted);
9825
10049
  const prevKeys = new Set(prior?.keys ?? []);
9826
10050
  const newKeysList = out.entries.map((e) => e.key);
@@ -10047,7 +10271,7 @@ var Vault = class {
10047
10271
  * collection.
10048
10272
  */
10049
10273
  async delegate(opts) {
10050
- const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-YVSHMIZZ.js");
10274
+ const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-W7ZV2322.js");
10051
10275
  if (!this.keyring.kek) {
10052
10276
  throw new ValidationError(
10053
10277
  "issueDelegation: keyring.kek is null \u2014 issuing a delegation requires a tier-1 unlock. Re-authenticate at tier 1 (passphrase) first."
@@ -10069,7 +10293,7 @@ var Vault = class {
10069
10293
  * if the id does not exist.
10070
10294
  */
10071
10295
  async revokeDelegation(id) {
10072
- const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-YVSHMIZZ.js");
10296
+ const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-W7ZV2322.js");
10073
10297
  await revokeDelegation(this.adapter, this.name, id);
10074
10298
  void DELEGATIONS_COLLECTION;
10075
10299
  }
@@ -10154,11 +10378,11 @@ var Vault = class {
10154
10378
  * Internal — invoked by an `ElevatedHandle.collection().put()` call.
10155
10379
  * Routes through the existing `Collection.putAtTier` code path with
10156
10380
  * the elevation context attached so the cross-tier event reflects
10157
- * the right authorization class.
10381
+ * the right authorization class. Returns `putAtTier`'s `TierMoveResult` (#779).
10158
10382
  */
10159
10383
  async _elevatedPut(collectionName, id, record, tier, reason) {
10160
10384
  const coll = this.collection(collectionName);
10161
- await coll.putAtTier(id, record, tier, {
10385
+ return coll.putAtTier(id, record, tier, {
10162
10386
  elevation: { reason, fromTier: 0 }
10163
10387
  });
10164
10388
  }
@@ -10317,7 +10541,7 @@ var Vault = class {
10317
10541
  * @see docs/superpowers/specs/2026-05-22-schema-dump-design.md
10318
10542
  */
10319
10543
  async dumpSchema(opts = {}) {
10320
- const { dumpVaultSchema } = await import("./walk-XQCBKSBW.js");
10544
+ const { dumpVaultSchema } = await import("./walk-SVNDIZ62.js");
10321
10545
  return dumpVaultSchema(this, opts);
10322
10546
  }
10323
10547
  /**
@@ -10452,7 +10676,7 @@ var Vault = class {
10452
10676
  * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/public-envelope.md
10453
10677
  */
10454
10678
  async getPublicEnvelope(opts = {}) {
10455
- const { readPublicEnvelope } = await import("./public-envelope-GOG4LUM7.js");
10679
+ const { readPublicEnvelope } = await import("./public-envelope-B4KNWVUA.js");
10456
10680
  return readPublicEnvelope(this.adapter, this.name, opts);
10457
10681
  }
10458
10682
  /**
@@ -10467,7 +10691,7 @@ var Vault = class {
10467
10691
  * both modes round-trip cleanly.
10468
10692
  */
10469
10693
  async dump() {
10470
- const { dumpVault } = await import("./backup-2WVBIVXW.js");
10694
+ const { dumpVault } = await import("./backup-BJ57IKAO.js");
10471
10695
  return dumpVault(this.backupContext());
10472
10696
  }
10473
10697
  /**
@@ -10519,7 +10743,7 @@ var Vault = class {
10519
10743
  * — there's no chain to verify against.
10520
10744
  */
10521
10745
  async load(backupJson) {
10522
- const { loadVault } = await import("./backup-2WVBIVXW.js");
10746
+ const { loadVault } = await import("./backup-BJ57IKAO.js");
10523
10747
  return loadVault(this.backupContext(), backupJson);
10524
10748
  }
10525
10749
  /**
@@ -10551,7 +10775,7 @@ var Vault = class {
10551
10775
  * way to detect tampering of an in-place vault.
10552
10776
  */
10553
10777
  async verifyBackupIntegrity() {
10554
- const { verifyBackupIntegrity } = await import("./backup-2WVBIVXW.js");
10778
+ const { verifyBackupIntegrity } = await import("./backup-BJ57IKAO.js");
10555
10779
  return verifyBackupIntegrity(this.backupContext());
10556
10780
  }
10557
10781
  /**
@@ -10769,7 +10993,7 @@ var Vault = class {
10769
10993
  * is the live validator object, not a serialization of it).
10770
10994
  */
10771
10995
  async exportJSON(opts = {}) {
10772
- const { exportVaultJSON } = await import("./backup-2WVBIVXW.js");
10996
+ const { exportVaultJSON } = await import("./backup-BJ57IKAO.js");
10773
10997
  return exportVaultJSON(this.backupContext(), opts);
10774
10998
  }
10775
10999
  };
@@ -12640,7 +12864,7 @@ var Noydb = class {
12640
12864
  if (!facade) return;
12641
12865
  const ctx = { existing, vault: facade, userId: e.userId, role: e.role };
12642
12866
  await registry.runChecks(e.collection, incoming, ctx);
12643
- const { GuardExecutor } = await import("./executor-UPSH5O3F.js");
12867
+ const { GuardExecutor } = await import("./executor-KGWTNEQD.js");
12644
12868
  for (const g of guards) {
12645
12869
  await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming, e.computedFieldNames);
12646
12870
  }
@@ -13919,7 +14143,7 @@ var Noydb = class {
13919
14143
  "setPublicEnvelope: the public-envelope feature is not enabled. Pass `publicEnvelope: true` (or a schema object) to `createNoydb`."
13920
14144
  );
13921
14145
  }
13922
- const { loadPublicEnvelope, savePublicEnvelope, resolveSchema, validatePublicEnvelopeInput } = await import("./public-envelope-GOG4LUM7.js");
14146
+ const { loadPublicEnvelope, savePublicEnvelope, resolveSchema, validatePublicEnvelopeInput } = await import("./public-envelope-B4KNWVUA.js");
13923
14147
  const schema = resolveSchema(this.options.publicEnvelope);
13924
14148
  validatePublicEnvelopeInput(input, schema);
13925
14149
  const now = (/* @__PURE__ */ new Date()).toISOString();
@@ -13948,7 +14172,7 @@ var Noydb = class {
13948
14172
  * regardless).
13949
14173
  */
13950
14174
  async getPublicEnvelope(vault, opts = {}) {
13951
- const { readPublicEnvelope } = await import("./public-envelope-GOG4LUM7.js");
14175
+ const { readPublicEnvelope } = await import("./public-envelope-B4KNWVUA.js");
13952
14176
  return readPublicEnvelope(this.options.store, vault, opts);
13953
14177
  }
13954
14178
  // ─── Auth introspection ─────────────────────────────────────────
@@ -14139,9 +14363,9 @@ async function createNoydb(options) {
14139
14363
  throw new ValidationError("A secret (passphrase) or getKeyring callback is required when encryption is enabled");
14140
14364
  }
14141
14365
  if (!options.coordinationStrategy) options = { ...options, coordinationStrategy: await createDefaultCoordinationProvider(options.store) };
14142
- if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-3TH2GOFQ.js")).createUserApi };
14366
+ if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-ZGS6LCOF.js")).createUserApi };
14143
14367
  if (!options.policyFactory) {
14144
- const policyModule = await import("./policy-5POYLI26.js");
14368
+ const policyModule = await import("./policy-Z3RUAIY2.js");
14145
14369
  options = { ...options, policyFactory: policyModule.createNoydbPolicy, policyCheckGateFn: policyModule.checkGate };
14146
14370
  }
14147
14371
  return new Noydb(options);
@@ -14178,4 +14402,4 @@ export {
14178
14402
  Noydb,
14179
14403
  createNoydb
14180
14404
  };
14181
- //# sourceMappingURL=chunk-YCXKFB7J.js.map
14405
+ //# sourceMappingURL=chunk-X7QBD67R.js.map