@noy-db/hub 0.6.0-pre.8 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (512) hide show
  1. package/CHANGELOG.md +7079 -0
  2. package/codemods/0.6.0-pre.json +211 -0
  3. package/dist/api-6X2VLZ7J.js +20 -0
  4. package/dist/attestation/index.js +19 -19
  5. package/dist/{backup-KULFZ2T4.js → backup-VL4GRIEW.js} +36 -18
  6. package/dist/backup-VL4GRIEW.js.map +1 -0
  7. package/dist/blobs/index.js +22 -20
  8. package/dist/blobs/index.js.map +1 -1
  9. package/dist/broker/index.js +12 -12
  10. package/dist/cargo/index.js +35 -35
  11. package/dist/{chunk-KUDZVJKQ.js → chunk-22GR3O4J.js} +2 -2
  12. package/dist/{chunk-CCZJJ4I2.js → chunk-2CBFYXJX.js} +6 -6
  13. package/dist/{chunk-JJNOLSG5.js → chunk-2J5IT37K.js} +15 -16
  14. package/dist/chunk-2J5IT37K.js.map +1 -0
  15. package/dist/{chunk-PNKHAKQ7.js → chunk-2ZCWHCLF.js} +17 -10
  16. package/dist/chunk-2ZCWHCLF.js.map +1 -0
  17. package/dist/{chunk-2BMRJ6LQ.js → chunk-2ZT4INZ4.js} +8 -11
  18. package/dist/{chunk-2BMRJ6LQ.js.map → chunk-2ZT4INZ4.js.map} +1 -1
  19. package/dist/{chunk-FAXZQ5UF.js → chunk-323MN67Z.js} +2 -2
  20. package/dist/{chunk-VMCCGUQB.js → chunk-36CEG6CM.js} +2 -2
  21. package/dist/{chunk-PDLLCOGD.js → chunk-3OE2QNSM.js} +20 -17
  22. package/dist/chunk-3OE2QNSM.js.map +1 -0
  23. package/dist/{chunk-AHLJSVRL.js → chunk-3YGUHUJA.js} +5 -7
  24. package/dist/chunk-3YGUHUJA.js.map +1 -0
  25. package/dist/{chunk-ZJADGNYF.js → chunk-4AOERLTV.js} +1 -1
  26. package/dist/chunk-4AOERLTV.js.map +1 -0
  27. package/dist/{chunk-J7FM3RAU.js → chunk-4ATF4BLF.js} +87 -34
  28. package/dist/chunk-4ATF4BLF.js.map +1 -0
  29. package/dist/{chunk-747LRSOO.js → chunk-4K6BIMLF.js} +2 -2
  30. package/dist/{chunk-PXCBVDFY.js → chunk-5ATC6UT4.js} +40 -7
  31. package/dist/chunk-5ATC6UT4.js.map +1 -0
  32. package/dist/{chunk-4GZ6XOVW.js → chunk-5F7BZAGV.js} +44 -42
  33. package/dist/chunk-5F7BZAGV.js.map +1 -0
  34. package/dist/{chunk-FNSMZQS4.js → chunk-5IHGJHWC.js} +2 -2
  35. package/dist/{chunk-4I72F5DF.js → chunk-5LZZQMIC.js} +11 -14
  36. package/dist/chunk-5LZZQMIC.js.map +1 -0
  37. package/dist/{chunk-JXIDGFKS.js → chunk-5O5ZSW7N.js} +4 -2
  38. package/dist/chunk-5O5ZSW7N.js.map +1 -0
  39. package/dist/{chunk-CEJWMBXO.js → chunk-5OT4G5N5.js} +6 -2
  40. package/dist/chunk-5OT4G5N5.js.map +1 -0
  41. package/dist/{chunk-GAG7QOVO.js → chunk-64WHKBMP.js} +53 -18
  42. package/dist/chunk-64WHKBMP.js.map +1 -0
  43. package/dist/{chunk-7TSYBD3E.js → chunk-65JXA63J.js} +2 -2
  44. package/dist/{chunk-Z45YRGFO.js → chunk-6NR36UNB.js} +2 -2
  45. package/dist/{chunk-W77KZHCW.js → chunk-6RH7PRTL.js} +16 -17
  46. package/dist/chunk-6RH7PRTL.js.map +1 -0
  47. package/dist/{chunk-3JVXVJ7L.js → chunk-7OBIBPCV.js} +10 -10
  48. package/dist/{chunk-AR2JDFAE.js → chunk-7Q3RHOA5.js} +2 -2
  49. package/dist/chunk-7ZGPQOFV.js +190 -0
  50. package/dist/chunk-7ZGPQOFV.js.map +1 -0
  51. package/dist/{chunk-QULVCV3M.js → chunk-AJGGBXWA.js} +4 -4
  52. package/dist/{chunk-CADUYBQD.js → chunk-ATL3ZVXT.js} +2 -2
  53. package/dist/{chunk-DMQCLZ4Z.js → chunk-ATY3ZASK.js} +2 -2
  54. package/dist/{chunk-4HDYQL3J.js → chunk-B4CRUZPR.js} +2 -2
  55. package/dist/{chunk-IMZLOJTK.js → chunk-BMU2DS3S.js} +30 -21
  56. package/dist/chunk-BMU2DS3S.js.map +1 -0
  57. package/dist/{chunk-6SAFL5YE.js → chunk-BZ3WMOYX.js} +3 -3
  58. package/dist/{chunk-UHXCLPGC.js → chunk-C3XWJCG7.js} +2 -2
  59. package/dist/chunk-C3XWJCG7.js.map +1 -0
  60. package/dist/{chunk-HXGUIPQB.js → chunk-CKKN25P2.js} +3 -3
  61. package/dist/{chunk-3URQC7EH.js → chunk-CXPOG3ZY.js} +355 -132
  62. package/dist/chunk-CXPOG3ZY.js.map +1 -0
  63. package/dist/{chunk-3FSX6LDG.js → chunk-D2YFQ7XG.js} +18 -3
  64. package/dist/{chunk-3FSX6LDG.js.map → chunk-D2YFQ7XG.js.map} +1 -1
  65. package/dist/{chunk-52JPHN5N.js → chunk-D6SXRMZZ.js} +27 -149
  66. package/dist/chunk-D6SXRMZZ.js.map +1 -0
  67. package/dist/{chunk-2DHSSLOD.js → chunk-DECNV4QK.js} +13 -15
  68. package/dist/chunk-DECNV4QK.js.map +1 -0
  69. package/dist/{chunk-6BU3L4UE.js → chunk-DNKVKO7K.js} +7 -10
  70. package/dist/chunk-DNKVKO7K.js.map +1 -0
  71. package/dist/{chunk-6HFM7EIT.js → chunk-EHRIDNZX.js} +2 -2
  72. package/dist/{chunk-3737A6EA.js → chunk-EHW7NLGD.js} +127 -31
  73. package/dist/chunk-EHW7NLGD.js.map +1 -0
  74. package/dist/{chunk-BEFVYAR5.js → chunk-EQOTJL76.js} +4 -4
  75. package/dist/chunk-EQOTJL76.js.map +1 -0
  76. package/dist/{chunk-E6427JU2.js → chunk-EV2TDHQZ.js} +19 -3
  77. package/dist/chunk-EV2TDHQZ.js.map +1 -0
  78. package/dist/{chunk-WFUIE565.js → chunk-FNYCT27B.js} +17 -14
  79. package/dist/chunk-FNYCT27B.js.map +1 -0
  80. package/dist/{chunk-RTAMLDWP.js → chunk-FU5VYEYK.js} +2 -2
  81. package/dist/chunk-FX3UIDCS.js +66 -0
  82. package/dist/chunk-FX3UIDCS.js.map +1 -0
  83. package/dist/{chunk-7F4DBNSP.js → chunk-GANFIM2M.js} +135 -18
  84. package/dist/chunk-GANFIM2M.js.map +1 -0
  85. package/dist/{chunk-4VUPLMZ6.js → chunk-GCU42IG7.js} +66 -71
  86. package/dist/chunk-GCU42IG7.js.map +1 -0
  87. package/dist/{chunk-RXYYFSBB.js → chunk-GKTW3KLV.js} +4 -4
  88. package/dist/chunk-HK67PX4J.js +27 -0
  89. package/dist/chunk-HK67PX4J.js.map +1 -0
  90. package/dist/{chunk-OF3L2SD6.js → chunk-HOPNIR5R.js} +2 -2
  91. package/dist/{chunk-WLZ47GSL.js → chunk-HSJBJIB2.js} +12 -10
  92. package/dist/{chunk-WLZ47GSL.js.map → chunk-HSJBJIB2.js.map} +1 -1
  93. package/dist/{chunk-ADW22QSB.js → chunk-HWI7GHJZ.js} +4 -4
  94. package/dist/{chunk-GQ3BX5EA.js → chunk-I3ISCYT7.js} +2 -2
  95. package/dist/{chunk-YJ6IONGA.js → chunk-IWKCJCLP.js} +11 -3
  96. package/dist/{chunk-YJ6IONGA.js.map → chunk-IWKCJCLP.js.map} +1 -1
  97. package/dist/{chunk-NJDQ4YSV.js → chunk-IWQPYT6S.js} +4 -4
  98. package/dist/{chunk-JRKZTEZZ.js → chunk-J6I5VR6P.js} +444 -73
  99. package/dist/chunk-J6I5VR6P.js.map +1 -0
  100. package/dist/{chunk-2Z3NCLNX.js → chunk-JHYKSMVX.js} +7 -7
  101. package/dist/{chunk-6FJWSWFT.js → chunk-JIHWBKMQ.js} +3 -3
  102. package/dist/{chunk-YAWK6AWF.js → chunk-JKATP6OE.js} +2 -2
  103. package/dist/{chunk-PL2GHSCM.js → chunk-JMJSCI7U.js} +157 -90
  104. package/dist/chunk-JMJSCI7U.js.map +1 -0
  105. package/dist/{chunk-Q6TEJXBX.js → chunk-JXHNUYQO.js} +31 -49
  106. package/dist/chunk-JXHNUYQO.js.map +1 -0
  107. package/dist/{chunk-WK5XUYYF.js → chunk-JYPRZWCZ.js} +473 -231
  108. package/dist/chunk-JYPRZWCZ.js.map +1 -0
  109. package/dist/{chunk-5ZKS6ZE2.js → chunk-K6CPIK3R.js} +4 -4
  110. package/dist/chunk-K6CPIK3R.js.map +1 -0
  111. package/dist/{chunk-CDB2HVQW.js → chunk-KM6ZXG7U.js} +14 -15
  112. package/dist/chunk-KM6ZXG7U.js.map +1 -0
  113. package/dist/{chunk-DG27IUVI.js → chunk-LC6NE4IQ.js} +2 -2
  114. package/dist/{chunk-WASHZV34.js → chunk-LIR2DJWP.js} +63 -25
  115. package/dist/chunk-LIR2DJWP.js.map +1 -0
  116. package/dist/{chunk-VZ3XFUQ7.js → chunk-LUYPYCHY.js} +16 -22
  117. package/dist/chunk-LUYPYCHY.js.map +1 -0
  118. package/dist/{chunk-G6S5VVHP.js → chunk-M7WBE3OR.js} +10 -10
  119. package/dist/chunk-M7WBE3OR.js.map +1 -0
  120. package/dist/{chunk-VJFMXYKP.js → chunk-MPKP6L5E.js} +2 -2
  121. package/dist/{chunk-IGJCYUT5.js → chunk-NSITFOCJ.js} +1 -1
  122. package/dist/chunk-NSITFOCJ.js.map +1 -0
  123. package/dist/{chunk-FUHKW252.js → chunk-OCJ3JA4O.js} +2 -2
  124. package/dist/{chunk-VCETL77O.js → chunk-ONPVHX2Y.js} +36 -7
  125. package/dist/chunk-ONPVHX2Y.js.map +1 -0
  126. package/dist/{chunk-WLYIROCJ.js → chunk-OQMCFHUX.js} +2 -2
  127. package/dist/{chunk-JRCYZEHU.js → chunk-OR2FYRYR.js} +2 -2
  128. package/dist/{chunk-HNHCQ556.js → chunk-PFWE7FJG.js} +2 -2
  129. package/dist/{chunk-NPP5R7FF.js → chunk-PJX72ICF.js} +22 -18
  130. package/dist/chunk-PJX72ICF.js.map +1 -0
  131. package/dist/{chunk-U5O6GIWZ.js → chunk-POFYIGQ2.js} +3 -3
  132. package/dist/{chunk-35EBKWQU.js → chunk-QH47SQLD.js} +4 -4
  133. package/dist/{chunk-FZ6NYJ7L.js → chunk-QQRRKO7W.js} +11 -8
  134. package/dist/chunk-QQRRKO7W.js.map +1 -0
  135. package/dist/{chunk-HVQGCKY4.js → chunk-QVXZFJBU.js} +2 -2
  136. package/dist/{chunk-FMQJZH4R.js → chunk-RDB66EKD.js} +6 -6
  137. package/dist/{chunk-X56RTUK3.js → chunk-RJZQ2PVD.js} +3 -3
  138. package/dist/{chunk-SUFG5E73.js → chunk-RPRASGEY.js} +2 -2
  139. package/dist/{chunk-XWX7GL56.js → chunk-S2I5MYSA.js} +7 -10
  140. package/dist/chunk-S2I5MYSA.js.map +1 -0
  141. package/dist/{chunk-FFDNKRCY.js → chunk-S6PJ6ZKE.js} +2 -2
  142. package/dist/chunk-S6PJ6ZKE.js.map +1 -0
  143. package/dist/{chunk-JIUVJ4M7.js → chunk-S7PM7Z4K.js} +3 -3
  144. package/dist/{chunk-55LKVALY.js → chunk-T7IR4N2S.js} +1 -3
  145. package/dist/chunk-T7IR4N2S.js.map +1 -0
  146. package/dist/{chunk-N35NC4JH.js → chunk-TKBB62DN.js} +2 -2
  147. package/dist/{chunk-YPYHVOXP.js → chunk-UJ4Z67UQ.js} +2 -2
  148. package/dist/chunk-UJ4Z67UQ.js.map +1 -0
  149. package/dist/{chunk-7MNBICB5.js → chunk-W3HAIN6U.js} +16 -14
  150. package/dist/chunk-W3HAIN6U.js.map +1 -0
  151. package/dist/{chunk-4UVDI4XE.js → chunk-WPZ5FVAS.js} +4 -4
  152. package/dist/{chunk-MSWYQLMQ.js → chunk-XINT4VJA.js} +2 -2
  153. package/dist/{chunk-7G6VDWXB.js → chunk-XPEPMK4Y.js} +3 -3
  154. package/dist/chunk-XPEPMK4Y.js.map +1 -0
  155. package/dist/{chunk-W3TVWF6N.js → chunk-YCGLAANM.js} +2 -2
  156. package/dist/{chunk-O2ERS4UJ.js → chunk-YTUFV7U7.js} +80 -51
  157. package/dist/chunk-YTUFV7U7.js.map +1 -0
  158. package/dist/{chunk-FDX7OWWI.js → chunk-YYV53EHO.js} +2 -2
  159. package/dist/{chunk-HNGSV2YC.js → chunk-Z3BZXPRO.js} +67 -10
  160. package/dist/chunk-Z3BZXPRO.js.map +1 -0
  161. package/dist/{chunk-6NVPFKN3.js → chunk-ZIMQDXTQ.js} +92 -35
  162. package/dist/chunk-ZIMQDXTQ.js.map +1 -0
  163. package/dist/{chunk-5JY5TSVY.js → chunk-ZJUZOJVW.js} +25 -31
  164. package/dist/chunk-ZJUZOJVW.js.map +1 -0
  165. package/dist/{chunk-3IXIU6FP.js → chunk-ZY6P7M52.js} +7 -10
  166. package/dist/chunk-ZY6P7M52.js.map +1 -0
  167. package/dist/{chunk-H73G4XF4.js → chunk-ZYZJLYNS.js} +7 -11
  168. package/dist/chunk-ZYZJLYNS.js.map +1 -0
  169. package/dist/classified/index.js +5 -5
  170. package/dist/{classified-marker-2KJAXRRO.js → classified-marker-AZDSDG6V.js} +3 -3
  171. package/dist/collection-facade-WSUAYFJ4.js +45 -0
  172. package/dist/{computed-6G5M3UPH.js → computed-VG2PCM4L.js} +3 -3
  173. package/dist/consent/index.js +10 -10
  174. package/dist/cover/index.js +10 -3
  175. package/dist/custody/index.js +12 -11
  176. package/dist/{dead-filter-DCB62VWW.js → dead-filter-JNQNB3TA.js} +2 -2
  177. package/dist/debug/index.js +1 -1
  178. package/dist/{delegation-MO7YZYJS.js → delegation-5F36DRDH.js} +24 -23
  179. package/dist/delegation-5F36DRDH.js.map +1 -0
  180. package/dist/derivations/index.js +12 -12
  181. package/dist/derive-MPOGZ4NR.js +22 -0
  182. package/dist/directory/index.js +10 -10
  183. package/dist/{dispatch-MJ6SHB3Y.js → dispatch-3ZA733EY.js} +18 -18
  184. package/dist/{dispatch-FZEAWKVM.js → dispatch-TNM5CRLZ.js} +9 -6
  185. package/dist/dispatch-TNM5CRLZ.js.map +1 -0
  186. package/dist/{enclave-JU4YIEPB.js → enclave-Y2ALNDRD.js} +31 -9
  187. package/dist/executor-BBEEUFO3.js +9 -0
  188. package/dist/executor-G6G3YEWR.js +9 -0
  189. package/dist/executor-ZUTUMTPA.js +29 -0
  190. package/dist/export-accessible-S3KEB763.js +23 -0
  191. package/dist/extract-partition-KVCTSUVE.js +38 -0
  192. package/dist/{fanout-sidecar-NNAJQXMX.js → fanout-sidecar-3QZU7ZZX.js} +18 -27
  193. package/dist/fanout-sidecar-3QZU7ZZX.js.map +1 -0
  194. package/dist/find-V4FN5ITT.js +11 -0
  195. package/dist/forget/index.js +9 -9
  196. package/dist/guards/index.js +7 -7
  197. package/dist/history/index.js +23 -20
  198. package/dist/history/index.js.map +1 -1
  199. package/dist/i18n/index.js +14 -14
  200. package/dist/index.d.ts +30 -13
  201. package/dist/index.js +180 -188
  202. package/dist/index.js.map +1 -1
  203. package/dist/indexing/index.js +4 -4
  204. package/dist/introspection/index.js +11 -11
  205. package/dist/issue-5CFBWBRX.js +19 -0
  206. package/dist/kernel/collection.d.ts +8 -2
  207. package/dist/kernel/constants.d.ts +36 -0
  208. package/dist/kernel/enclave/crypto.d.ts +52 -4
  209. package/dist/kernel/enclave/index.d.ts +10 -3
  210. package/dist/kernel/enclave/record-aad.d.ts +131 -0
  211. package/dist/kernel/enclave/record-envelope.d.ts +76 -0
  212. package/dist/kernel/enclave/record-keys/envelope-body.d.ts +34 -2
  213. package/dist/kernel/enclave/record-keys/lifecycle.d.ts +22 -5
  214. package/dist/kernel/enclave/record-keys/record-codec.d.ts +47 -14
  215. package/dist/kernel/enclave/record-keys/rekey-blob.d.ts +88 -0
  216. package/dist/kernel/enclave/record-keys/rekey.d.ts +91 -0
  217. package/dist/kernel/enclave/record-keys/tombstone.d.ts +3 -2
  218. package/dist/kernel/errors.d.ts +132 -12
  219. package/dist/kernel/merge-authority.d.ts +25 -0
  220. package/dist/kernel/noydb.d.ts +27 -4
  221. package/dist/kernel/query/builder.d.ts +51 -4
  222. package/dist/kernel/query/join.d.ts +27 -0
  223. package/dist/kernel/query/live.d.ts +31 -9
  224. package/dist/kernel/query/predicate.d.ts +9 -0
  225. package/dist/kernel/refs.d.ts +3 -1
  226. package/dist/kernel/sync-policy.d.ts +0 -2
  227. package/dist/kernel/tier-visibility.d.ts +34 -0
  228. package/dist/kernel/types.d.ts +111 -13
  229. package/dist/kernel/vault.d.ts +14 -8
  230. package/dist/kernel/via/index.d.ts +11 -2
  231. package/dist/kernel/via/reconcile.d.ts +12 -0
  232. package/dist/{ledger-AETNF4OM.js → ledger-MQIIOTZB.js} +11 -11
  233. package/dist/liberate-LW7OKVBH.js +25 -0
  234. package/dist/{link-set-E5HNY67I.js → link-set-5PJBBR63.js} +11 -11
  235. package/dist/{managed-secret-CWQ6PND5.js → managed-secret-ETDG6AAE.js} +11 -3
  236. package/dist/materialized-views/index.js +24 -24
  237. package/dist/migrate-cek-V3VDRV24.js +19 -0
  238. package/dist/migrate-cek-V3VDRV24.js.map +1 -0
  239. package/dist/money/index.js +5 -5
  240. package/dist/noydb-LFDRMYZ5.js +85 -0
  241. package/dist/overlay-views/index.js +4 -4
  242. package/dist/periods/index.js +18 -12
  243. package/dist/pod/index.js +79 -89
  244. package/dist/pod-handle-AZ3CXY5Y.js +41 -0
  245. package/dist/pod-handle-AZ3CXY5Y.js.map +1 -0
  246. package/dist/policy/index.js +11 -4
  247. package/dist/port/to/index.d.ts +4 -4
  248. package/dist/port/to/locator.d.ts +54 -8
  249. package/dist/port/with/i18n-strategy.d.ts +4 -1
  250. package/dist/port/with/lookup-strategy.d.ts +4 -1
  251. package/dist/port/with/merge-authority.d.ts +52 -0
  252. package/dist/port/with/service-bus.d.ts +0 -4
  253. package/dist/port/with/strategies.d.ts +2 -0
  254. package/dist/port/with/team-strategy.d.ts +5 -1
  255. package/dist/portability/index.js +8 -8
  256. package/dist/{post-register-2XSSMGEQ.js → post-register-QCJYRMIK.js} +6 -6
  257. package/dist/query/index.js +6 -6
  258. package/dist/reduce/index.js +6 -6
  259. package/dist/register-JBOEHTVX.js +32 -0
  260. package/dist/registry-5DYHQFJS.js +9 -0
  261. package/dist/registry-EANV44W2.js +9 -0
  262. package/dist/registry-J25H6VB4.js +19 -0
  263. package/dist/registry-R23SQUQH.js +18 -0
  264. package/dist/request-withdrawal-KQ4W4UT5.js +31 -0
  265. package/dist/{reveal-BW36KCOQ.js → reveal-W7BKZSUP.js} +6 -6
  266. package/dist/revoke-H3VSTAIE.js +24 -0
  267. package/dist/satellites/index.js +1 -1
  268. package/dist/schema-update/index.js +2 -2
  269. package/dist/sealed-record/index.js +20 -13
  270. package/dist/sealed-record/index.js.map +1 -1
  271. package/dist/search/index.js +4 -4
  272. package/dist/{seed-GDV5PT4R.js → seed-55FPOMYP.js} +20 -22
  273. package/dist/seed-55FPOMYP.js.map +1 -0
  274. package/dist/sequence/index.js +9 -9
  275. package/dist/session/index.js +10 -10
  276. package/dist/shadow/index.js +2 -2
  277. package/dist/share-link/index.js +1 -1
  278. package/dist/signer-53AQ3BU2.js +25 -0
  279. package/dist/snapshots/index.js +10 -10
  280. package/dist/snapshots/index.js.map +1 -1
  281. package/dist/{stale-ARHFVL5U.js → stale-TH7SSVRV.js} +10 -10
  282. package/dist/storage-WSF7ZKTL.js +23 -0
  283. package/dist/{store-coordination-provider-GFCUOBR6.js → store-coordination-provider-R27VRD6K.js} +18 -12
  284. package/dist/store-coordination-provider-R27VRD6K.js.map +1 -0
  285. package/dist/sync/index.js +11 -11
  286. package/dist/team/index.js +15 -14
  287. package/dist/tiers/index.js +11 -10
  288. package/dist/to/index.js +17 -9
  289. package/dist/to/index.js.map +1 -1
  290. package/dist/transactions/index.js +4 -4
  291. package/dist/{ulid-PTAIMDG4.js → ulid-VQW6ERQN.js} +2 -2
  292. package/dist/util/index.js +1 -1
  293. package/dist/vault-head/index.js +115 -0
  294. package/dist/vault-head/index.js.map +1 -0
  295. package/dist/{verify-RO5RTZOJ.js → verify-M5LQH43C.js} +5 -5
  296. package/dist/via/blob/index.d.ts +3 -0
  297. package/dist/via/lookup/handle.d.ts +4 -1
  298. package/dist/walk-NABCHDZN.js +21 -0
  299. package/dist/with-audit/periods/index.d.ts +3 -3
  300. package/dist/with-audit/periods/periods.d.ts +82 -2
  301. package/dist/with-audit/periods/strategy.d.ts +1 -1
  302. package/dist/with-audit/periods/vault-facade.d.ts +54 -1
  303. package/dist/with-audit/periods/window.d.ts +10 -0
  304. package/dist/with-audit/sealed-record/index.d.ts +13 -0
  305. package/dist/with-audit/tiers/index.d.ts +17 -2
  306. package/dist/with-cargo/adopt-partition.d.ts +1 -1
  307. package/dist/with-cargo/extract-partition.d.ts +1 -1
  308. package/dist/with-cargo/index.d.ts +1 -1
  309. package/dist/with-commit/history/history.d.ts +26 -0
  310. package/dist/with-commit/history/index.d.ts +2 -1
  311. package/dist/with-commit/history/ledger/store.d.ts +7 -1
  312. package/dist/with-commit/history/strategy.d.ts +11 -1
  313. package/dist/with-commit/numbering/index.d.ts +0 -5
  314. package/dist/with-commit/vault-head/active.d.ts +2 -0
  315. package/dist/with-commit/vault-head/head.d.ts +28 -0
  316. package/dist/with-commit/vault-head/index.d.ts +10 -0
  317. package/dist/with-commit/vault-head/strategy.d.ts +127 -0
  318. package/dist/with-commit/vault-head/verify.d.ts +90 -0
  319. package/dist/with-formula/materialized-views/dependency-analyzer.d.ts +4 -0
  320. package/dist/with-formula/materialized-views/projection-legs.d.ts +59 -0
  321. package/dist/with-formula/materialized-views/registry.d.ts +50 -0
  322. package/dist/with-formula/materialized-views/types.d.ts +68 -10
  323. package/dist/with-party/directory/cover/storage.d.ts +0 -8
  324. package/dist/with-party/directory/storage.d.ts +0 -11
  325. package/dist/with-party/directory/visibility.d.ts +0 -21
  326. package/dist/with-party/policy/storage.d.ts +0 -10
  327. package/dist/with-party/team/index.d.ts +1 -1
  328. package/dist/with-party/team/keyring.d.ts +139 -2
  329. package/dist/with-party/team/noydb-facade.d.ts +5 -1
  330. package/dist/with-party/team/roster-tag.d.ts +101 -0
  331. package/dist/with-party/team/tiers.d.ts +2 -1
  332. package/dist/with-pod/format.d.ts +10 -12
  333. package/dist/with-pod/index.d.ts +10 -10
  334. package/dist/with-pod/open.d.ts +2 -2
  335. package/dist/with-pod/pod-handle.d.ts +19 -0
  336. package/dist/with-pod/pod-store.d.ts +0 -8
  337. package/dist/with-pod/{bundle.d.ts → pod.d.ts} +11 -19
  338. package/dist/with-pod/ulid.d.ts +1 -1
  339. package/dist/with-shape/blobs/blob-compaction.d.ts +13 -0
  340. package/dist/with-shape/blobs/blob-set.d.ts +83 -11
  341. package/dist/with-shape/blobs/orphan-report.d.ts +62 -0
  342. package/dist/with-shape/introspection/index.d.ts +1 -0
  343. package/dist/with-sync/engine.d.ts +54 -5
  344. package/dist/with-sync/strategy.d.ts +3 -0
  345. package/dist/withdraw-accessible-VCINIG6V.js +28 -0
  346. package/package.json +10 -4
  347. package/dist/api-RXUMEKT3.js +0 -20
  348. package/dist/backup-KULFZ2T4.js.map +0 -1
  349. package/dist/bundle-handle-GFNHT52M.js +0 -36
  350. package/dist/bundle-handle-GFNHT52M.js.map +0 -1
  351. package/dist/chunk-2DHSSLOD.js.map +0 -1
  352. package/dist/chunk-3737A6EA.js.map +0 -1
  353. package/dist/chunk-3IXIU6FP.js.map +0 -1
  354. package/dist/chunk-3URQC7EH.js.map +0 -1
  355. package/dist/chunk-4GZ6XOVW.js.map +0 -1
  356. package/dist/chunk-4I72F5DF.js.map +0 -1
  357. package/dist/chunk-4VUPLMZ6.js.map +0 -1
  358. package/dist/chunk-52JPHN5N.js.map +0 -1
  359. package/dist/chunk-55LKVALY.js.map +0 -1
  360. package/dist/chunk-5JY5TSVY.js.map +0 -1
  361. package/dist/chunk-5ZKS6ZE2.js.map +0 -1
  362. package/dist/chunk-6BU3L4UE.js.map +0 -1
  363. package/dist/chunk-6NVPFKN3.js.map +0 -1
  364. package/dist/chunk-7F4DBNSP.js.map +0 -1
  365. package/dist/chunk-7G6VDWXB.js.map +0 -1
  366. package/dist/chunk-7H73RIE3.js +0 -45
  367. package/dist/chunk-7H73RIE3.js.map +0 -1
  368. package/dist/chunk-7MNBICB5.js.map +0 -1
  369. package/dist/chunk-AFHQATY4.js +0 -47
  370. package/dist/chunk-AFHQATY4.js.map +0 -1
  371. package/dist/chunk-AHLJSVRL.js.map +0 -1
  372. package/dist/chunk-BEFVYAR5.js.map +0 -1
  373. package/dist/chunk-CDB2HVQW.js.map +0 -1
  374. package/dist/chunk-CEJWMBXO.js.map +0 -1
  375. package/dist/chunk-E6427JU2.js.map +0 -1
  376. package/dist/chunk-FFDNKRCY.js.map +0 -1
  377. package/dist/chunk-FZ6NYJ7L.js.map +0 -1
  378. package/dist/chunk-G6S5VVHP.js.map +0 -1
  379. package/dist/chunk-GAG7QOVO.js.map +0 -1
  380. package/dist/chunk-H73G4XF4.js.map +0 -1
  381. package/dist/chunk-HNGSV2YC.js.map +0 -1
  382. package/dist/chunk-IGJCYUT5.js.map +0 -1
  383. package/dist/chunk-IMZLOJTK.js.map +0 -1
  384. package/dist/chunk-J7FM3RAU.js.map +0 -1
  385. package/dist/chunk-JJNOLSG5.js.map +0 -1
  386. package/dist/chunk-JRKZTEZZ.js.map +0 -1
  387. package/dist/chunk-JXIDGFKS.js.map +0 -1
  388. package/dist/chunk-NPP5R7FF.js.map +0 -1
  389. package/dist/chunk-O2ERS4UJ.js.map +0 -1
  390. package/dist/chunk-PDLLCOGD.js.map +0 -1
  391. package/dist/chunk-PL2GHSCM.js.map +0 -1
  392. package/dist/chunk-PNKHAKQ7.js.map +0 -1
  393. package/dist/chunk-PXCBVDFY.js.map +0 -1
  394. package/dist/chunk-Q6TEJXBX.js.map +0 -1
  395. package/dist/chunk-UHXCLPGC.js.map +0 -1
  396. package/dist/chunk-VCETL77O.js.map +0 -1
  397. package/dist/chunk-VZ3XFUQ7.js.map +0 -1
  398. package/dist/chunk-W77KZHCW.js.map +0 -1
  399. package/dist/chunk-WASHZV34.js.map +0 -1
  400. package/dist/chunk-WFUIE565.js.map +0 -1
  401. package/dist/chunk-WK5XUYYF.js.map +0 -1
  402. package/dist/chunk-XWX7GL56.js.map +0 -1
  403. package/dist/chunk-YPYHVOXP.js.map +0 -1
  404. package/dist/chunk-ZJADGNYF.js.map +0 -1
  405. package/dist/collection-facade-QEJIM6BC.js +0 -45
  406. package/dist/delegation-MO7YZYJS.js.map +0 -1
  407. package/dist/derive-IUA6JFLB.js +0 -22
  408. package/dist/dispatch-FZEAWKVM.js.map +0 -1
  409. package/dist/executor-CYJQLKKI.js +0 -9
  410. package/dist/executor-S4QIKEHW.js +0 -9
  411. package/dist/executor-YIQB2S6N.js +0 -29
  412. package/dist/export-accessible-4S36PQNR.js +0 -23
  413. package/dist/extract-partition-IO7FDZ2P.js +0 -38
  414. package/dist/fanout-sidecar-NNAJQXMX.js.map +0 -1
  415. package/dist/find-RBBYKXI7.js +0 -11
  416. package/dist/issue-RIVHSY2S.js +0 -19
  417. package/dist/liberate-GFN4C7RR.js +0 -24
  418. package/dist/noydb-3MT74MZS.js +0 -83
  419. package/dist/register-4EFJCVYD.js +0 -32
  420. package/dist/registry-4SDHHOJ7.js +0 -18
  421. package/dist/registry-CZVINVQH.js +0 -9
  422. package/dist/registry-IKUR2MXD.js +0 -9
  423. package/dist/registry-OYTFGWVK.js +0 -19
  424. package/dist/request-withdrawal-KGXGDPVQ.js +0 -31
  425. package/dist/revoke-JFN773KF.js +0 -24
  426. package/dist/seed-GDV5PT4R.js.map +0 -1
  427. package/dist/signer-TA55QB6R.js +0 -25
  428. package/dist/storage-V7MTFAQJ.js +0 -23
  429. package/dist/store-coordination-provider-GFCUOBR6.js.map +0 -1
  430. package/dist/walk-3ZECBFDA.js +0 -21
  431. package/dist/with-pod/bundle-handle.d.ts +0 -9
  432. package/dist/withdraw-accessible-7PG4DYQK.js +0 -28
  433. /package/dist/{api-RXUMEKT3.js.map → api-6X2VLZ7J.js.map} +0 -0
  434. /package/dist/{chunk-KUDZVJKQ.js.map → chunk-22GR3O4J.js.map} +0 -0
  435. /package/dist/{chunk-CCZJJ4I2.js.map → chunk-2CBFYXJX.js.map} +0 -0
  436. /package/dist/{chunk-FAXZQ5UF.js.map → chunk-323MN67Z.js.map} +0 -0
  437. /package/dist/{chunk-VMCCGUQB.js.map → chunk-36CEG6CM.js.map} +0 -0
  438. /package/dist/{chunk-747LRSOO.js.map → chunk-4K6BIMLF.js.map} +0 -0
  439. /package/dist/{chunk-FNSMZQS4.js.map → chunk-5IHGJHWC.js.map} +0 -0
  440. /package/dist/{chunk-7TSYBD3E.js.map → chunk-65JXA63J.js.map} +0 -0
  441. /package/dist/{chunk-Z45YRGFO.js.map → chunk-6NR36UNB.js.map} +0 -0
  442. /package/dist/{chunk-3JVXVJ7L.js.map → chunk-7OBIBPCV.js.map} +0 -0
  443. /package/dist/{chunk-AR2JDFAE.js.map → chunk-7Q3RHOA5.js.map} +0 -0
  444. /package/dist/{chunk-QULVCV3M.js.map → chunk-AJGGBXWA.js.map} +0 -0
  445. /package/dist/{chunk-CADUYBQD.js.map → chunk-ATL3ZVXT.js.map} +0 -0
  446. /package/dist/{chunk-DMQCLZ4Z.js.map → chunk-ATY3ZASK.js.map} +0 -0
  447. /package/dist/{chunk-4HDYQL3J.js.map → chunk-B4CRUZPR.js.map} +0 -0
  448. /package/dist/{chunk-6SAFL5YE.js.map → chunk-BZ3WMOYX.js.map} +0 -0
  449. /package/dist/{chunk-HXGUIPQB.js.map → chunk-CKKN25P2.js.map} +0 -0
  450. /package/dist/{chunk-6HFM7EIT.js.map → chunk-EHRIDNZX.js.map} +0 -0
  451. /package/dist/{chunk-RTAMLDWP.js.map → chunk-FU5VYEYK.js.map} +0 -0
  452. /package/dist/{chunk-RXYYFSBB.js.map → chunk-GKTW3KLV.js.map} +0 -0
  453. /package/dist/{chunk-OF3L2SD6.js.map → chunk-HOPNIR5R.js.map} +0 -0
  454. /package/dist/{chunk-ADW22QSB.js.map → chunk-HWI7GHJZ.js.map} +0 -0
  455. /package/dist/{chunk-GQ3BX5EA.js.map → chunk-I3ISCYT7.js.map} +0 -0
  456. /package/dist/{chunk-NJDQ4YSV.js.map → chunk-IWQPYT6S.js.map} +0 -0
  457. /package/dist/{chunk-2Z3NCLNX.js.map → chunk-JHYKSMVX.js.map} +0 -0
  458. /package/dist/{chunk-6FJWSWFT.js.map → chunk-JIHWBKMQ.js.map} +0 -0
  459. /package/dist/{chunk-YAWK6AWF.js.map → chunk-JKATP6OE.js.map} +0 -0
  460. /package/dist/{chunk-DG27IUVI.js.map → chunk-LC6NE4IQ.js.map} +0 -0
  461. /package/dist/{chunk-VJFMXYKP.js.map → chunk-MPKP6L5E.js.map} +0 -0
  462. /package/dist/{chunk-FUHKW252.js.map → chunk-OCJ3JA4O.js.map} +0 -0
  463. /package/dist/{chunk-WLYIROCJ.js.map → chunk-OQMCFHUX.js.map} +0 -0
  464. /package/dist/{chunk-JRCYZEHU.js.map → chunk-OR2FYRYR.js.map} +0 -0
  465. /package/dist/{chunk-HNHCQ556.js.map → chunk-PFWE7FJG.js.map} +0 -0
  466. /package/dist/{chunk-U5O6GIWZ.js.map → chunk-POFYIGQ2.js.map} +0 -0
  467. /package/dist/{chunk-35EBKWQU.js.map → chunk-QH47SQLD.js.map} +0 -0
  468. /package/dist/{chunk-HVQGCKY4.js.map → chunk-QVXZFJBU.js.map} +0 -0
  469. /package/dist/{chunk-FMQJZH4R.js.map → chunk-RDB66EKD.js.map} +0 -0
  470. /package/dist/{chunk-X56RTUK3.js.map → chunk-RJZQ2PVD.js.map} +0 -0
  471. /package/dist/{chunk-SUFG5E73.js.map → chunk-RPRASGEY.js.map} +0 -0
  472. /package/dist/{chunk-JIUVJ4M7.js.map → chunk-S7PM7Z4K.js.map} +0 -0
  473. /package/dist/{chunk-N35NC4JH.js.map → chunk-TKBB62DN.js.map} +0 -0
  474. /package/dist/{chunk-4UVDI4XE.js.map → chunk-WPZ5FVAS.js.map} +0 -0
  475. /package/dist/{chunk-MSWYQLMQ.js.map → chunk-XINT4VJA.js.map} +0 -0
  476. /package/dist/{chunk-W3TVWF6N.js.map → chunk-YCGLAANM.js.map} +0 -0
  477. /package/dist/{chunk-FDX7OWWI.js.map → chunk-YYV53EHO.js.map} +0 -0
  478. /package/dist/{classified-marker-2KJAXRRO.js.map → classified-marker-AZDSDG6V.js.map} +0 -0
  479. /package/dist/{collection-facade-QEJIM6BC.js.map → collection-facade-WSUAYFJ4.js.map} +0 -0
  480. /package/dist/{computed-6G5M3UPH.js.map → computed-VG2PCM4L.js.map} +0 -0
  481. /package/dist/{dead-filter-DCB62VWW.js.map → dead-filter-JNQNB3TA.js.map} +0 -0
  482. /package/dist/{derive-IUA6JFLB.js.map → derive-MPOGZ4NR.js.map} +0 -0
  483. /package/dist/{dispatch-MJ6SHB3Y.js.map → dispatch-3ZA733EY.js.map} +0 -0
  484. /package/dist/{enclave-JU4YIEPB.js.map → enclave-Y2ALNDRD.js.map} +0 -0
  485. /package/dist/{executor-CYJQLKKI.js.map → executor-BBEEUFO3.js.map} +0 -0
  486. /package/dist/{executor-S4QIKEHW.js.map → executor-G6G3YEWR.js.map} +0 -0
  487. /package/dist/{executor-YIQB2S6N.js.map → executor-ZUTUMTPA.js.map} +0 -0
  488. /package/dist/{export-accessible-4S36PQNR.js.map → export-accessible-S3KEB763.js.map} +0 -0
  489. /package/dist/{extract-partition-IO7FDZ2P.js.map → extract-partition-KVCTSUVE.js.map} +0 -0
  490. /package/dist/{find-RBBYKXI7.js.map → find-V4FN5ITT.js.map} +0 -0
  491. /package/dist/{issue-RIVHSY2S.js.map → issue-5CFBWBRX.js.map} +0 -0
  492. /package/dist/{ledger-AETNF4OM.js.map → ledger-MQIIOTZB.js.map} +0 -0
  493. /package/dist/{liberate-GFN4C7RR.js.map → liberate-LW7OKVBH.js.map} +0 -0
  494. /package/dist/{link-set-E5HNY67I.js.map → link-set-5PJBBR63.js.map} +0 -0
  495. /package/dist/{managed-secret-CWQ6PND5.js.map → managed-secret-ETDG6AAE.js.map} +0 -0
  496. /package/dist/{noydb-3MT74MZS.js.map → noydb-LFDRMYZ5.js.map} +0 -0
  497. /package/dist/{post-register-2XSSMGEQ.js.map → post-register-QCJYRMIK.js.map} +0 -0
  498. /package/dist/{register-4EFJCVYD.js.map → register-JBOEHTVX.js.map} +0 -0
  499. /package/dist/{registry-4SDHHOJ7.js.map → registry-5DYHQFJS.js.map} +0 -0
  500. /package/dist/{registry-CZVINVQH.js.map → registry-EANV44W2.js.map} +0 -0
  501. /package/dist/{registry-IKUR2MXD.js.map → registry-J25H6VB4.js.map} +0 -0
  502. /package/dist/{registry-OYTFGWVK.js.map → registry-R23SQUQH.js.map} +0 -0
  503. /package/dist/{request-withdrawal-KGXGDPVQ.js.map → request-withdrawal-KQ4W4UT5.js.map} +0 -0
  504. /package/dist/{reveal-BW36KCOQ.js.map → reveal-W7BKZSUP.js.map} +0 -0
  505. /package/dist/{revoke-JFN773KF.js.map → revoke-H3VSTAIE.js.map} +0 -0
  506. /package/dist/{signer-TA55QB6R.js.map → signer-53AQ3BU2.js.map} +0 -0
  507. /package/dist/{stale-ARHFVL5U.js.map → stale-TH7SSVRV.js.map} +0 -0
  508. /package/dist/{storage-V7MTFAQJ.js.map → storage-WSF7ZKTL.js.map} +0 -0
  509. /package/dist/{ulid-PTAIMDG4.js.map → ulid-VQW6ERQN.js.map} +0 -0
  510. /package/dist/{verify-RO5RTZOJ.js.map → verify-M5LQH43C.js.map} +0 -0
  511. /package/dist/{walk-3ZECBFDA.js.map → walk-NABCHDZN.js.map} +0 -0
  512. /package/dist/{withdraw-accessible-7PG4DYQK.js.map → withdraw-accessible-VCINIG6V.js.map} +0 -0
@@ -1,75 +1,84 @@
1
+ import {
2
+ LinkIntegrityError,
3
+ declareLink,
4
+ isLinkCollectionName,
5
+ linkCollectionName,
6
+ linkRowKey
7
+ } from "./chunk-PFWE7FJG.js";
1
8
  import {
2
9
  hashFields,
3
10
  validateSatelliteDeclaration
4
- } from "./chunk-HVQGCKY4.js";
11
+ } from "./chunk-QVXZFJBU.js";
5
12
  import {
6
13
  resolveStaleOnRead
7
- } from "./chunk-4HDYQL3J.js";
14
+ } from "./chunk-B4CRUZPR.js";
8
15
  import {
9
16
  isManifestReservedCollection
10
17
  } from "./chunk-EPFF7LOX.js";
11
18
  import {
12
- LinkIntegrityError,
13
- declareLink,
14
- isLinkCollectionName,
15
- linkCollectionName,
16
- linkRowKey
17
- } from "./chunk-HNHCQ556.js";
19
+ VectorSet,
20
+ buildPersistedIndexCallbacks,
21
+ encodeVecId,
22
+ syncTierSearch
23
+ } from "./chunk-M7WBE3OR.js";
18
24
  import {
19
25
  isBaseLive,
20
26
  liveBaseIdSet
21
27
  } from "./chunk-GYGLAVCX.js";
22
28
  import {
23
29
  loadFence
24
- } from "./chunk-6BU3L4UE.js";
30
+ } from "./chunk-DNKVKO7K.js";
25
31
  import {
26
- VectorSet,
27
- buildPersistedIndexCallbacks,
28
- encodeVecId,
29
- syncTierSearch
30
- } from "./chunk-G6S5VVHP.js";
32
+ fallbackDerivationName,
33
+ jsonSchemaToFields
34
+ } from "./chunk-KHKKD62N.js";
35
+ import {
36
+ derivePersistedSchema,
37
+ isZod4Schema
38
+ } from "./chunk-6NR36UNB.js";
31
39
  import {
32
40
  SchemaUpdateGate
33
41
  } from "./chunk-6LJY7X5A.js";
42
+ import {
43
+ NO_ATTESTATION
44
+ } from "./chunk-MPKP6L5E.js";
34
45
  import {
35
46
  NO_CLASSIFIED,
36
47
  guardClassifiedCompat,
37
48
  resolveClassifiedFields
38
- } from "./chunk-QULVCV3M.js";
49
+ } from "./chunk-AJGGBXWA.js";
39
50
  import {
40
51
  NO_TIERS,
41
52
  classifySealedShred,
42
53
  syncDerivedOutputs
43
- } from "./chunk-6NVPFKN3.js";
54
+ } from "./chunk-ZIMQDXTQ.js";
44
55
  import {
45
56
  NO_PORTABILITY
46
- } from "./chunk-FUHKW252.js";
57
+ } from "./chunk-OCJ3JA4O.js";
47
58
  import {
48
59
  NO_CARGO,
49
60
  runDrainBarrier
50
- } from "./chunk-DG27IUVI.js";
61
+ } from "./chunk-LC6NE4IQ.js";
51
62
  import {
52
63
  saveSealedSecret
53
- } from "./chunk-XWX7GL56.js";
54
- import {
55
- fallbackDerivationName,
56
- jsonSchemaToFields
57
- } from "./chunk-KHKKD62N.js";
58
- import {
59
- derivePersistedSchema,
60
- isZod4Schema
61
- } from "./chunk-Z45YRGFO.js";
64
+ } from "./chunk-S2I5MYSA.js";
62
65
  import {
63
66
  loadPersistedSchema
64
- } from "./chunk-CDB2HVQW.js";
67
+ } from "./chunk-KM6ZXG7U.js";
68
+ import {
69
+ NO_SEQUENCE,
70
+ SEQUENCE_COLLECTION,
71
+ compileSequenceFormat,
72
+ resolveSequenceKey
73
+ } from "./chunk-W3HAIN6U.js";
65
74
  import {
66
75
  CustodyApi,
67
76
  NO_CUSTODY
68
- } from "./chunk-ADW22QSB.js";
77
+ } from "./chunk-HWI7GHJZ.js";
69
78
  import {
70
79
  DEFAULT_POSTURE,
71
80
  ViaGraph
72
- } from "./chunk-7TSYBD3E.js";
81
+ } from "./chunk-65JXA63J.js";
73
82
  import {
74
83
  buildLookupAltIndex,
75
84
  buildLookupSnapshotRows,
@@ -93,33 +102,33 @@ import {
93
102
  selfWriteFieldEqual,
94
103
  touchFor,
95
104
  updateReferencingRecords
96
- } from "./chunk-5ZKS6ZE2.js";
105
+ } from "./chunk-K6CPIK3R.js";
97
106
  import {
98
107
  OverlayedCollection
99
- } from "./chunk-OF3L2SD6.js";
108
+ } from "./chunk-HOPNIR5R.js";
100
109
  import {
101
110
  INDEXED_STORE_POLICY,
102
111
  NO_SYNC
103
- } from "./chunk-55LKVALY.js";
104
- import {
105
- NO_ATTESTATION
106
- } from "./chunk-VJFMXYKP.js";
112
+ } from "./chunk-T7IR4N2S.js";
107
113
  import {
108
114
  NO_CONSENT
109
115
  } from "./chunk-PEOZ34EM.js";
110
116
  import {
111
117
  NO_PERIODS,
118
+ isEffectivelyReopened,
112
119
  purgeMarkersOn,
113
120
  resolvePeriodKey,
121
+ resolveReopenState,
114
122
  samePartition
115
- } from "./chunk-PXCBVDFY.js";
123
+ } from "./chunk-5ATC6UT4.js";
116
124
  import {
117
125
  PERIODS_COLLECTION,
118
126
  PERIOD_ARCHIVES_COLLECTION,
119
127
  PERIOD_FREEZES_COLLECTION,
128
+ PERIOD_REOPENS_COLLECTION,
120
129
  PERIOD_TARGET_PURGES_COLLECTION,
121
130
  periodExclusiveUpperBound
122
- } from "./chunk-JXIDGFKS.js";
131
+ } from "./chunk-5O5ZSW7N.js";
123
132
  import {
124
133
  NO_SHADOW
125
134
  } from "./chunk-SMY5X46Z.js";
@@ -129,7 +138,7 @@ import {
129
138
  import {
130
139
  TxContext,
131
140
  bestEffortRevert
132
- } from "./chunk-35EBKWQU.js";
141
+ } from "./chunk-QH47SQLD.js";
133
142
  import {
134
143
  lazy
135
144
  } from "./chunk-5D2ALSM5.js";
@@ -137,32 +146,29 @@ import {
137
146
  InvertedIndex,
138
147
  MemoryIndexStore,
139
148
  NO_SEARCH
140
- } from "./chunk-3JVXVJ7L.js";
149
+ } from "./chunk-7OBIBPCV.js";
141
150
  import {
142
- NO_SEQUENCE,
143
- SEQUENCE_COLLECTION,
144
- compileSequenceFormat,
145
- resolveSequenceKey
146
- } from "./chunk-7MNBICB5.js";
151
+ NO_SEALED_RECORD
152
+ } from "./chunk-323MN67Z.js";
147
153
  import {
148
154
  Query,
149
155
  ScanBuilder
150
- } from "./chunk-3737A6EA.js";
156
+ } from "./chunk-EHW7NLGD.js";
151
157
  import {
152
158
  EXPORT_AUDIT_COLLECTION,
153
159
  NO_BLOBS,
154
160
  createExportBlobsHandle,
155
161
  runCompaction
156
- } from "./chunk-WASHZV34.js";
162
+ } from "./chunk-LIR2DJWP.js";
157
163
  import {
158
164
  LazyQuery,
159
165
  NO_INDEXING,
160
166
  decodeIdxId,
161
167
  encodeIdxId
162
- } from "./chunk-JIUVJ4M7.js";
168
+ } from "./chunk-S7PM7Z4K.js";
163
169
  import {
164
170
  normalizeIndexDefs
165
- } from "./chunk-GQ3BX5EA.js";
171
+ } from "./chunk-I3ISCYT7.js";
166
172
  import {
167
173
  IMPLICIT_LAZY,
168
174
  Lru,
@@ -176,13 +182,13 @@ import {
176
182
  } from "./chunk-YMUFFJCO.js";
177
183
  import {
178
184
  readPath
179
- } from "./chunk-IGJCYUT5.js";
185
+ } from "./chunk-NSITFOCJ.js";
180
186
  import {
181
187
  NO_CRDT
182
188
  } from "./chunk-PVEWA2DU.js";
183
189
  import {
184
190
  dictCollectionName
185
- } from "./chunk-WFUIE565.js";
191
+ } from "./chunk-FNYCT27B.js";
186
192
  import {
187
193
  NO_I18N,
188
194
  getAtPath,
@@ -190,11 +196,11 @@ import {
190
196
  isDictKeyDescriptor,
191
197
  isI18nTextDescriptor,
192
198
  isStaticDictDescriptor
193
- } from "./chunk-7G6VDWXB.js";
199
+ } from "./chunk-XPEPMK4Y.js";
194
200
  import {
195
201
  isViaInstalled,
196
202
  viaBinder
197
- } from "./chunk-UHXCLPGC.js";
203
+ } from "./chunk-C3XWJCG7.js";
198
204
  import {
199
205
  NO_TEAM,
200
206
  describeAllUsersAuth,
@@ -217,7 +223,7 @@ import {
217
223
  saveShamirRecoveryEntries,
218
224
  updateAuthenticator,
219
225
  writeMagicLinkGrant
220
- } from "./chunk-O2ERS4UJ.js";
226
+ } from "./chunk-YTUFV7U7.js";
221
227
  import {
222
228
  assertKeyringOpenAllowed,
223
229
  buildRecipientKeyringFile,
@@ -232,32 +238,36 @@ import {
232
238
  listUsers,
233
239
  loadKeyring,
234
240
  updateKeyringIdentity
235
- } from "./chunk-JRKZTEZZ.js";
241
+ } from "./chunk-J6I5VR6P.js";
236
242
  import {
237
243
  persistDirectoryConfig,
238
244
  readDirectoryConfig
239
- } from "./chunk-5JY5TSVY.js";
245
+ } from "./chunk-ZJUZOJVW.js";
240
246
  import {
241
247
  NO_BROKER,
242
248
  buildCredentialBrokerHandle
243
- } from "./chunk-W3TVWF6N.js";
249
+ } from "./chunk-YCGLAANM.js";
244
250
  import {
245
251
  NO_SESSION
246
252
  } from "./chunk-VKQCVU2Z.js";
247
253
  import {
248
254
  generateULID
249
- } from "./chunk-ZJADGNYF.js";
255
+ } from "./chunk-4AOERLTV.js";
250
256
  import {
251
257
  NO_HISTORY
252
- } from "./chunk-AFHQATY4.js";
258
+ } from "./chunk-7ZGPQOFV.js";
259
+ import {
260
+ sha256Hex
261
+ } from "./chunk-BZ3WMOYX.js";
253
262
  import {
254
263
  assertCutoverTierSafe,
255
264
  assertTierWritable,
265
+ dekKey,
256
266
  liveRecordIsElevated
257
- } from "./chunk-3FSX6LDG.js";
267
+ } from "./chunk-D2YFQ7XG.js";
258
268
  import {
259
- sha256Hex
260
- } from "./chunk-6SAFL5YE.js";
269
+ NO_VAULT_HEAD
270
+ } from "./chunk-HK67PX4J.js";
261
271
  import {
262
272
  NO_FORGET,
263
273
  addSubjectRef,
@@ -266,34 +276,36 @@ import {
266
276
  readDottedPath,
267
277
  rebuildSubjectIndex,
268
278
  removeSubjectRef
269
- } from "./chunk-WLZ47GSL.js";
270
- import {
271
- NO_SEALED_RECORD
272
- } from "./chunk-FAXZQ5UF.js";
279
+ } from "./chunk-HSJBJIB2.js";
273
280
  import {
274
281
  RecordCodec,
275
282
  SEALED_CEK_NS,
283
+ applyRewrappedBody,
284
+ buildRecordAad,
276
285
  findByDet,
277
286
  hasPerRecordKey,
287
+ hasSealedBody,
278
288
  makeReservedEnvelopes,
279
289
  openEnvelopeJson,
280
290
  queryByDet,
281
291
  resolveStableCek,
282
- validateSchemaInput
283
- } from "./chunk-3URQC7EH.js";
292
+ rewrapBodyToDek,
293
+ validateSchemaInput,
294
+ verifyRecordIdentity
295
+ } from "./chunk-CXPOG3ZY.js";
284
296
  import {
285
297
  buildDeleteMarker,
298
+ buildRecordEnvelope,
286
299
  buildTombstone,
287
300
  isDeleteMarker,
288
301
  isTombstone
289
- } from "./chunk-7H73RIE3.js";
302
+ } from "./chunk-FX3UIDCS.js";
290
303
  import {
291
304
  encrypt
292
- } from "./chunk-VCETL77O.js";
305
+ } from "./chunk-ONPVHX2Y.js";
293
306
  import {
294
- NOYDB_FORMAT_VERSION,
295
307
  SealedHandle
296
- } from "./chunk-YPYHVOXP.js";
308
+ } from "./chunk-UJ4Z67UQ.js";
297
309
  import {
298
310
  AlreadyElevatedError,
299
311
  AttestationError,
@@ -336,7 +348,36 @@ import {
336
348
  UnsupportedTierCompositionError,
337
349
  ValidationError,
338
350
  isConflictError
339
- } from "./chunk-HNGSV2YC.js";
351
+ } from "./chunk-Z3BZXPRO.js";
352
+
353
+ // src/kernel/merge-authority.ts
354
+ function buildMergeAuthority(keyring) {
355
+ return {
356
+ verify: async (collection, id, envelope) => {
357
+ const dek = keyring.deks.get(dekKey(collection, envelope._tier ?? 0));
358
+ if (dek === void 0) return true;
359
+ return verifyRecordIdentity({ collection, id }, envelope, dek);
360
+ },
361
+ advance: async (collection, id, envelope, toVersion) => {
362
+ if (!hasSealedBody(envelope)) return { ...envelope, _v: toVersion };
363
+ const dek = keyring.deks.get(dekKey(collection, envelope._tier ?? 0));
364
+ if (dek === void 0) {
365
+ throw new ValidationError(
366
+ `sync: cannot advance "${collection}/${id}" past the remote \u2014 no key for it, so its body cannot be re-sealed at the new version. The local copy is unchanged.`
367
+ );
368
+ }
369
+ const from = {
370
+ collection,
371
+ id,
372
+ version: envelope._v,
373
+ ...envelope._tier !== void 0 ? { tier: envelope._tier } : {},
374
+ ...envelope._by !== void 0 ? { by: envelope._by } : {}
375
+ };
376
+ const body = await rewrapBodyToDek(from, { ...from, version: toVersion }, envelope, dek, dek);
377
+ return { ...applyRewrappedBody(envelope, body), _v: toVersion };
378
+ }
379
+ };
380
+ }
340
381
 
341
382
  // src/with-commit/tx/strategy.ts
342
383
  var NOT_ENABLED = new Error(
@@ -373,6 +414,7 @@ var STRATEGY_DEFAULTS = {
373
414
  custody: NO_CUSTODY,
374
415
  forget: NO_FORGET,
375
416
  history: NO_HISTORY,
417
+ vaultHead: NO_VAULT_HEAD,
376
418
  i18n: NO_I18N,
377
419
  indexing: NO_INDEXING,
378
420
  lazy: IMPLICIT_LAZY,
@@ -466,7 +508,7 @@ function validateSecretModeOptions(options) {
466
508
  }
467
509
  async function resolveEffectiveSecret(options, store, vault) {
468
510
  if (options.secretMode === "managed") {
469
- const { resolveManagedSecret } = await import("./managed-secret-CWQ6PND5.js");
511
+ const { resolveManagedSecret } = await import("./managed-secret-ETDG6AAE.js");
470
512
  return resolveManagedSecret(store, vault, options.sealingKey);
471
513
  }
472
514
  return options.secret;
@@ -484,7 +526,7 @@ function ownerKeyringOptions(options, secret) {
484
526
 
485
527
  // src/port/by/default-provider.ts
486
528
  async function createDefaultCoordinationProvider(store) {
487
- const { StoreCoordinationProvider } = await import("./store-coordination-provider-GFCUOBR6.js");
529
+ const { StoreCoordinationProvider } = await import("./store-coordination-provider-R27VRD6K.js");
488
530
  return new StoreCoordinationProvider(store);
489
531
  }
490
532
 
@@ -939,13 +981,13 @@ async function applyCutoverTransform(ctx) {
939
981
  for (const id of ids) {
940
982
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
941
983
  if (!env || isTombstone(env, ctx.storeCiphertext) || isDeleteMarker(env)) continue;
942
- const decoded = await ctx.codec.decryptRecord(env, { skipValidation: true, id });
984
+ const decoded = await ctx.codec.decryptRecord({ collection: ctx.name, id }, env, { skipValidation: true });
943
985
  if (decoded === null) continue;
944
986
  const record = decoded;
945
987
  const next = ctx.transform(record);
946
988
  const nextVersion = (env._v ?? 0) + 1;
947
989
  const cek = ctx.perRecordCek ? await ctx.resolveRecordCek(id) : void 0;
948
- const migEnvelope = await ctx.codec.encryptRecord(next, nextVersion, cek, void 0, void 0, ctx.vdigFields !== null ? { id, prev: env } : void 0, id);
990
+ const migEnvelope = await ctx.codec.encryptRecord({ collection: ctx.name, id }, next, nextVersion, cek, void 0, void 0, ctx.vdigFields !== null ? { id, prev: env } : void 0);
949
991
  await ctx.adapter.put(ctx.vault, ctx.name, id, migEnvelope);
950
992
  await ctx.onRecordMutated(id, "put", "cutover");
951
993
  if (ctx.ledger) {
@@ -1051,7 +1093,7 @@ async function rebuildIndexes(ctx) {
1051
1093
  const envelope = await ctx.adapter.get(ctx.vault, ctx.name, recordId);
1052
1094
  if (!envelope) continue;
1053
1095
  if ((envelope._tier ?? 0) > 0) continue;
1054
- const record = await ctx.codec.decryptRecord(envelope, { skipValidation: true, id: recordId });
1096
+ const record = await ctx.codec.decryptRecord({ collection: ctx.name, id: recordId }, envelope, { skipValidation: true });
1055
1097
  if (record === null) continue;
1056
1098
  await maintainPersistedIndexesOnPut(ctx, recordId, record, null, envelope._v);
1057
1099
  }
@@ -1085,7 +1127,7 @@ async function reconcileIndex(ctx, field, opts = {}) {
1085
1127
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
1086
1128
  if (!env) continue;
1087
1129
  try {
1088
- const sidecarJson = await ctx.codec.decryptJsonString(env);
1130
+ const sidecarJson = await ctx.codec.decryptJsonString({ collection: ctx.name, id }, env);
1089
1131
  if (sidecarJson === null) {
1090
1132
  sidecar.set(decoded.recordId, void 0);
1091
1133
  } else {
@@ -1105,7 +1147,7 @@ async function reconcileIndex(ctx, field, opts = {}) {
1105
1147
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
1106
1148
  if (!env) continue;
1107
1149
  if ((env._tier ?? 0) > 0) continue;
1108
- const record = await ctx.codec.decryptRecord(env, { skipValidation: true, id });
1150
+ const record = await ctx.codec.decryptRecord({ collection: ctx.name, id }, env, { skipValidation: true });
1109
1151
  if (record === null) continue;
1110
1152
  const live = readPersistedValue(record, field);
1111
1153
  const stored = sidecar.get(id);
@@ -1166,7 +1208,7 @@ async function maintainPersistedIndexesOnPut(ctx, id, newRecord, previousRecord,
1166
1208
  recordId: id,
1167
1209
  writtenAt: (/* @__PURE__ */ new Date()).toISOString()
1168
1210
  });
1169
- const envelope = await ctx.codec.encryptJsonString(body, version);
1211
+ const envelope = await ctx.codec.encryptJsonString({ collection: ctx.name, id: idxId }, body, version);
1170
1212
  await ctx.adapter.put(ctx.vault, ctx.name, idxId, envelope);
1171
1213
  }
1172
1214
  } catch (cause) {
@@ -1235,7 +1277,7 @@ async function resolveTierSyncPrior(ctx, id, priorEnvelope) {
1235
1277
  const cached = ctx.cache.get(id)?.record;
1236
1278
  if (cached !== void 0) return cached;
1237
1279
  if (!ctx.lazy || !priorEnvelope || (priorEnvelope._tier ?? 0) > 0) return null;
1238
- return await ctx.codec.decryptRecord(priorEnvelope, { skipValidation: true, id });
1280
+ return await ctx.codec.decryptRecord({ collection: ctx.name, id }, priorEnvelope, { skipValidation: true });
1239
1281
  }
1240
1282
 
1241
1283
  // src/with-lookup/search/serialize.ts
@@ -2418,7 +2460,7 @@ function resolveCollectionConfig(opts) {
2418
2460
  }
2419
2461
 
2420
2462
  // src/with-formula/computed/lazy.ts
2421
- var loadComputed = lazy(() => import("./computed-6G5M3UPH.js"));
2463
+ var loadComputed = lazy(() => import("./computed-VG2PCM4L.js"));
2422
2464
  async function loadEvalComputedFields() {
2423
2465
  return (await loadComputed()).evalComputedFields;
2424
2466
  }
@@ -2604,7 +2646,8 @@ var Collection = class {
2604
2646
  fieldMeta;
2605
2647
  /** Collection-level descriptive metadata declared via `meta`; read by `getMeta()`, surfaced in `describe()`. */
2606
2648
  meta;
2607
- /** Outbound ref declarations (snapshot from vault refRegistry at construction time); used by `describe()`. */
2649
+ /** Outbound ref declarations (snapshot from the vault refRegistry); read by `describe()` and
2650
+ * {@link _txAtomicSafe}. Mutable for {@link _attachDeclaredRefs} (#1141). */
2608
2651
  _refs;
2609
2652
  /** Money field descriptors keyed by field path, typed as the opaque {@link ViaDescriptor} marker
2610
2653
  * (the kernel never inspects the concrete shape); `put()` quantizes to a scaled-int string,
@@ -2874,14 +2917,14 @@ var Collection = class {
2874
2917
  if (crdtMode === "yjs") {
2875
2918
  return local._v >= remote._v ? local : remote;
2876
2919
  }
2877
- const localJson = await this.codec.decryptJsonString(local, id);
2878
- const remoteJson = await this.codec.decryptJsonString(remote, id);
2920
+ const localJson = await this.codec.decryptJsonString({ collection: this.name, id }, local);
2921
+ const remoteJson = await this.codec.decryptJsonString({ collection: this.name, id }, remote);
2879
2922
  if (localJson === null) return local;
2880
2923
  if (remoteJson === null) return remote;
2881
2924
  const merged = this.strategies.crdt.mergeCrdtStates(JSON.parse(localJson), JSON.parse(remoteJson));
2882
2925
  const mergedVersion = Math.max(local._v, remote._v) + 1;
2883
2926
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
2884
- return this.codec.encryptJsonString(JSON.stringify(merged), mergedVersion, cek);
2927
+ return this.codec.encryptJsonString({ collection: this.name, id }, JSON.stringify(merged), mergedVersion, cek);
2885
2928
  };
2886
2929
  opts.onRegisterConflictResolver(this.name, crdtResolver);
2887
2930
  }
@@ -2922,14 +2965,14 @@ var Collection = class {
2922
2965
  } else {
2923
2966
  const mergeFn = policy;
2924
2967
  resolver = async (id, local, remote) => {
2925
- const localRecord = await this.codec.decryptRecord(local, { skipValidation: true, id });
2926
- const remoteRecord = await this.codec.decryptRecord(remote, { skipValidation: true, id });
2968
+ const localRecord = await this.codec.decryptRecord({ collection: this.name, id }, local, { skipValidation: true });
2969
+ const remoteRecord = await this.codec.decryptRecord({ collection: this.name, id }, remote, { skipValidation: true });
2927
2970
  if (localRecord === null) return local;
2928
2971
  if (remoteRecord === null) return remote;
2929
2972
  const merged = mergeFn(localRecord, remoteRecord);
2930
2973
  const mergedVersion = Math.max(local._v, remote._v) + 1;
2931
2974
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
2932
- return this.codec.encryptRecord(merged, mergedVersion, cek, void 0, void 0, void 0, id);
2975
+ return this.codec.encryptRecord({ collection: this.name, id }, merged, mergedVersion, cek);
2933
2976
  };
2934
2977
  }
2935
2978
  opts.onRegisterConflictResolver(collectionName, resolver);
@@ -3200,7 +3243,7 @@ var Collection = class {
3200
3243
  }
3201
3244
  await this.onAccess?.("find", "*");
3202
3245
  if (hits.length === 0) return [];
3203
- const { verifyDigestField } = await import("./verify-RO5RTZOJ.js");
3246
+ const { verifyDigestField } = await import("./verify-M5LQH43C.js");
3204
3247
  const policy = {
3205
3248
  normalize: spec.verifyNormalize ?? "password",
3206
3249
  notLastN: spec.notLastN ?? 0,
@@ -3314,6 +3357,12 @@ var Collection = class {
3314
3357
  _applyMeta(meta) {
3315
3358
  if (this.meta === void 0) this.meta = meta;
3316
3359
  }
3360
+ /** @internal #1141 — refresh the ref snapshot after a late `refs` declaration. Overwrites rather
3361
+ * than first-wins, deliberately: the argument is the ref registry's own merged view (see
3362
+ * `reconcileViaAttach`), which `RefRegistry.register` has already refused to let conflict. */
3363
+ _attachDeclaredRefs(refs) {
3364
+ this._refs = refs;
3365
+ }
3317
3366
  /**
3318
3367
  * @internal — attach classified fields post-construction. See {@link _applyMoneyFields}.
3319
3368
  * First-wins. Note: unlike money/computed/meta, this cannot retro-seal a
@@ -3406,7 +3455,7 @@ var Collection = class {
3406
3455
  }
3407
3456
  }
3408
3457
  if (this.materializedViewSource !== void 0) {
3409
- const { resolveStaleMVOnRead } = await import("./stale-ARHFVL5U.js");
3458
+ const { resolveStaleMVOnRead } = await import("./stale-TH7SSVRV.js");
3410
3459
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
3411
3460
  }
3412
3461
  let record;
@@ -3418,7 +3467,7 @@ var Collection = class {
3418
3467
  const envelope = await this.adapter.get(this.vault, this.name, id);
3419
3468
  if (!envelope) return null;
3420
3469
  if (isTombstone(envelope, this.storeCiphertext) || isDeleteMarker(envelope) || (envelope._tier ?? 0) > 0) return null;
3421
- record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
3470
+ record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
3422
3471
  if (record === null) return null;
3423
3472
  this.lru.set(id, { record, version: envelope._v }, estimateRecordBytes(record));
3424
3473
  }
@@ -3445,7 +3494,7 @@ var Collection = class {
3445
3494
  }
3446
3495
  const envelope = await this.adapter.get(this.vault, this.name, id);
3447
3496
  if (!envelope || (envelope._tier ?? 0) > 0) return null;
3448
- const json = await this.codec.decryptJsonString(envelope);
3497
+ const json = await this.codec.decryptJsonString({ collection: this.name, id }, envelope);
3449
3498
  if (json === null) return null;
3450
3499
  return JSON.parse(json);
3451
3500
  }
@@ -3562,7 +3611,7 @@ var Collection = class {
3562
3611
  if (cached) return cached.record;
3563
3612
  const env = await this.adapter.get(this.vault, this.name, id);
3564
3613
  if (!env || (env._tier ?? 0) > 0) return void 0;
3565
- const rec = await this.codec.decryptRecord(env, { id });
3614
+ const rec = await this.codec.decryptRecord({ collection: this.name, id }, env, {});
3566
3615
  return rec === null ? void 0 : rec;
3567
3616
  }
3568
3617
  await this.ensureHydrated();
@@ -3610,7 +3659,7 @@ var Collection = class {
3610
3659
  if (cached2) return { record: cached2.record, version: cached2.version };
3611
3660
  const env = await this.adapter.get(this.vault, this.name, id);
3612
3661
  if (!env || (env._tier ?? 0) > 0) return { record: null, version: 0 };
3613
- return { record: await this.codec.decryptRecord(env, { skipValidation: true, id }) ?? null, version: env._v };
3662
+ return { record: await this.codec.decryptRecord({ collection: this.name, id }, env, { skipValidation: true }) ?? null, version: env._v };
3614
3663
  }
3615
3664
  await this.ensureHydrated();
3616
3665
  const cached = this.cache.get(id);
@@ -3632,7 +3681,7 @@ var Collection = class {
3632
3681
  if (this.sensitiveFields.size > 0 || this.via?.hasAtRestHooks === true) {
3633
3682
  const env = await this.adapter.get(this.vault, this.name, id);
3634
3683
  if (!env || isTombstone(env, this.storeCiphertext) || (env._tier ?? 0) > 0) return void 0;
3635
- const rec = await this.codec.decryptRecord(env, { skipValidation: true, id });
3684
+ const rec = await this.codec.decryptRecord({ collection: this.name, id }, env, { skipValidation: true });
3636
3685
  return rec === null ? void 0 : { record: rec, version: env._v };
3637
3686
  }
3638
3687
  const cached = this.cache.get(id);
@@ -3644,7 +3693,7 @@ var Collection = class {
3644
3693
  const env = await this.adapter.get(this.vault, this.name, id);
3645
3694
  if (!env) return { env: null, record: null, elided: false };
3646
3695
  if ((env._tier ?? 0) > 0) return { env, record: null, elided: false };
3647
- return { env, record: await this.codec.decryptRecord(env, { skipValidation: true, id }), elided: false };
3696
+ return { env, record: await this.codec.decryptRecord({ collection: this.name, id }, env, { skipValidation: true }), elided: false };
3648
3697
  }
3649
3698
  /**
3650
3699
  * Wraps {@link RecordCodec.toCacheRecord} with an additional strip for
@@ -3668,9 +3717,9 @@ var Collection = class {
3668
3717
  * payload that is not a CRDT state. The `lww-map` and `rga` branches each
3669
3718
  * carried a copy, byte-identical apart from the cast (#842).
3670
3719
  */
3671
- async #decodePriorCrdtState(envelope) {
3720
+ async #decodePriorCrdtState(id, envelope) {
3672
3721
  if (!envelope) return void 0;
3673
- const prevJson = await this.codec.decryptJsonString(envelope);
3722
+ const prevJson = await this.codec.decryptJsonString({ collection: this.name, id }, envelope);
3674
3723
  if (prevJson === null) return void 0;
3675
3724
  const prevParsed = JSON.parse(prevJson);
3676
3725
  if (prevParsed === null || typeof prevParsed !== "object" || !("_crdt" in prevParsed)) {
@@ -3707,7 +3756,8 @@ var Collection = class {
3707
3756
  this.vault,
3708
3757
  this.name,
3709
3758
  id,
3710
- await this.codec.encryptRecord(prior.record, prior.version, cek, void 0, void 0, vdigCtx, id)
3759
+ await this.codec.encryptRecord(this.strategies.history.historyIdentity(this.name, id, prior.version), prior.record, prior.version, cek, void 0, void 0, vdigCtx)
3760
+ // sealed against its _history STORAGE identity (#1041)
3711
3761
  );
3712
3762
  this.emitter.emit("history:save", { vault: this.vault, collection: this.name, id, version: prior.version });
3713
3763
  if (this.historyConfig.maxVersions) {
@@ -3817,20 +3867,20 @@ var Collection = class {
3817
3867
  const now = (/* @__PURE__ */ new Date()).toISOString();
3818
3868
  let crdtState;
3819
3869
  if (this.crdtMode === "lww-map") {
3820
- const existingState = await this.#decodePriorCrdtState(existingEnvelope);
3870
+ const existingState = await this.#decodePriorCrdtState(id, existingEnvelope);
3821
3871
  crdtState = this.strategies.crdt.buildLwwMapState(record, existingState, now);
3822
3872
  } else if (this.crdtMode === "rga") {
3823
- const existingState = await this.#decodePriorCrdtState(existingEnvelope);
3873
+ const existingState = await this.#decodePriorCrdtState(id, existingEnvelope);
3824
3874
  crdtState = this.strategies.crdt.buildRgaState(Array.isArray(record) ? record : [record], existingState, generateULID);
3825
3875
  } else {
3826
3876
  crdtState = { _crdt: "yjs", update: record };
3827
3877
  }
3828
3878
  const version = existingVersion + 1;
3829
3879
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
3830
- const envelope = await this.codec.encryptJsonString(JSON.stringify(crdtState), version, cek, options?.source, options?.sourceTs);
3880
+ const envelope = await this.codec.encryptJsonString({ collection: this.name, id }, JSON.stringify(crdtState), version, cek, options?.source, options?.sourceTs);
3831
3881
  await this.adapter.put(this.vault, this.name, id, envelope);
3832
3882
  const resolvedRecord = this.strategies.crdt.resolveCrdtSnapshot(crdtState);
3833
- const existingResolvedRecord = existingEnvelope ? await this.codec.decryptRecord(existingEnvelope, { skipValidation: true }) : null;
3883
+ const existingResolvedRecord = existingEnvelope ? await this.codec.decryptRecord({ collection: this.name, id }, existingEnvelope, { skipValidation: true }) : null;
3834
3884
  const existingResolved = existingResolvedRecord !== null ? { record: existingResolvedRecord, version: existingVersion } : void 0;
3835
3885
  if (existingResolved) {
3836
3886
  await this.#savePriorHistory(id, existingResolved, cek, this.vdigFields !== null ? { id, prev: existingEnvelope } : void 0);
@@ -3870,7 +3920,7 @@ var Collection = class {
3870
3920
  if (!existing) {
3871
3921
  priorRaw = await this.adapter.get(this.vault, this.name, id);
3872
3922
  if (priorRaw) {
3873
- const previousRecord = await this.codec.decryptRecord(priorRaw, { id });
3923
+ const previousRecord = await this.codec.decryptRecord({ collection: this.name, id }, priorRaw, {});
3874
3924
  if (previousRecord !== null) {
3875
3925
  existing = { record: previousRecord, version: priorRaw._v };
3876
3926
  }
@@ -3890,7 +3940,7 @@ var Collection = class {
3890
3940
  this.uniqueConstraints?.check(id, record);
3891
3941
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
3892
3942
  const vdigCtx = this.vdigFields !== null ? { id, prev: await this.adapter.get(this.vault, this.name, id) } : void 0;
3893
- const envelope = await this.codec.encryptRecord(record, version, cek, options?.source, options?.sourceTs, vdigCtx, id);
3943
+ const envelope = await this.codec.encryptRecord({ collection: this.name, id }, record, version, cek, options?.source, options?.sourceTs, vdigCtx);
3894
3944
  return { id, envelope, version, indexed: record, event: record, prior: existing, cek, vdigCtx, reason: options?.reason };
3895
3945
  }
3896
3946
  /**
@@ -3936,7 +3986,7 @@ var Collection = class {
3936
3986
  */
3937
3987
  async dispatchMaterializedViews(id, record, wave) {
3938
3988
  if (this.materializedViewSource === void 0) return;
3939
- const { dispatchMaterializedViews } = await import("./dispatch-FZEAWKVM.js");
3989
+ const { dispatchMaterializedViews } = await import("./dispatch-TNM5CRLZ.js");
3940
3990
  return dispatchMaterializedViews(this.#mvDispatchCtx(this.materializedViewSource), id, record, wave);
3941
3991
  }
3942
3992
  /**
@@ -3964,7 +4014,7 @@ var Collection = class {
3964
4014
  const cached = this.lru.get(id);
3965
4015
  const env = await this.adapter.get(this.vault, this.name, id);
3966
4016
  if (!env || isTombstone(env, this.storeCiphertext) || isDeleteMarker(env)) return null;
3967
- raw = await this.codec.decryptRecord(env, { id });
4017
+ raw = await this.codec.decryptRecord({ collection: this.name, id }, env, {});
3968
4018
  if (raw === null) return null;
3969
4019
  if (!cached) {
3970
4020
  this.lru.set(id, { record: await this.codec.toCacheRecord(raw, env, id), version: env._v }, estimateRecordBytes(raw));
@@ -3975,7 +4025,7 @@ var Collection = class {
3975
4025
  else {
3976
4026
  const env = await this.adapter.get(this.vault, this.name, id);
3977
4027
  if (!env || isTombstone(env, this.storeCiphertext) || isDeleteMarker(env)) return null;
3978
- raw = await this.codec.decryptRecord(env, { id });
4028
+ raw = await this.codec.decryptRecord({ collection: this.name, id }, env, {});
3979
4029
  if (raw === null) return null;
3980
4030
  this.lru.set(id, { record: raw, version: env._v }, estimateRecordBytes(raw));
3981
4031
  }
@@ -3992,7 +4042,7 @@ var Collection = class {
3992
4042
  async _getStoredRecordForDispatch(id) {
3993
4043
  const env = await this.adapter.get(this.vault, this.name, id);
3994
4044
  if (!env || isTombstone(env, this.storeCiphertext) || isDeleteMarker(env)) return null;
3995
- const record = await this.codec.decryptRecord(env, { id });
4045
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, env, {});
3996
4046
  return record === null ? null : { record, version: env._v };
3997
4047
  }
3998
4048
  /**
@@ -4109,7 +4159,7 @@ var Collection = class {
4109
4159
  * dispatch wave's per-target dedup; `undefined` on the local-write path (byte-identical). */
4110
4160
  async dispatchDerivations(id, record, version, wave) {
4111
4161
  if (this.derivationSource === void 0) return;
4112
- const { dispatchDerivations } = await import("./dispatch-MJ6SHB3Y.js");
4162
+ const { dispatchDerivations } = await import("./dispatch-3ZA733EY.js");
4113
4163
  return dispatchDerivations({
4114
4164
  ...this.#derivationDeleteCtx(this.derivationSource),
4115
4165
  via: this.via,
@@ -4292,7 +4342,7 @@ var Collection = class {
4292
4342
  if (!existing && this.historyConfig.enabled !== false) {
4293
4343
  const previousEnvelope2 = await this.adapter.get(this.vault, this.name, id);
4294
4344
  if (previousEnvelope2) {
4295
- const previousRecord = await this.codec.decryptRecord(previousEnvelope2, { id });
4345
+ const previousRecord = await this.codec.decryptRecord({ collection: this.name, id }, previousEnvelope2, {});
4296
4346
  if (previousRecord !== null) {
4297
4347
  existing = { record: previousRecord, version: previousEnvelope2._v };
4298
4348
  }
@@ -4307,7 +4357,7 @@ var Collection = class {
4307
4357
  if (this.onDirty) {
4308
4358
  const live = previousEnvelope;
4309
4359
  if (!live || isTombstone(live, this.storeCiphertext) || isDeleteMarker(live)) return null;
4310
- marker = buildDeleteMarker(live._v + 1, this.keyring.userId);
4360
+ marker = buildDeleteMarker({ collection: this.name, id }, live._v + 1, this.keyring.userId);
4311
4361
  }
4312
4362
  const snapshots = existing !== void 0 && this.historyConfig.enabled !== false;
4313
4363
  const cek = snapshots && this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
@@ -4329,7 +4379,7 @@ var Collection = class {
4329
4379
  async _commitDelete(prepared, persist = true) {
4330
4380
  const { id, internal, existing, previousPayloadHash, marker, cek, vdigCtx } = prepared;
4331
4381
  if (existing && this.historyConfig.enabled !== false) {
4332
- await this.strategies.history.saveHistory(this.adapter, this.vault, this.name, id, await this.codec.encryptRecord(existing.record, existing.version, cek, void 0, void 0, vdigCtx, id));
4382
+ await this.strategies.history.saveHistory(this.adapter, this.vault, this.name, id, await this.codec.encryptRecord(this.strategies.history.historyIdentity(this.name, id, existing.version), existing.record, existing.version, cek, void 0, void 0, vdigCtx));
4333
4383
  }
4334
4384
  if (marker) {
4335
4385
  if (persist) await this.adapter.put(this.vault, this.name, id, marker);
@@ -4396,7 +4446,7 @@ var Collection = class {
4396
4446
  */
4397
4447
  async _decodeEnvelope(envelope, id) {
4398
4448
  try {
4399
- const rec = await this.codec.decryptRecord(envelope, { skipValidation: true, id });
4449
+ const rec = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { skipValidation: true });
4400
4450
  return rec === null ? null : rec;
4401
4451
  } catch {
4402
4452
  return null;
@@ -4405,7 +4455,7 @@ var Collection = class {
4405
4455
  async _writeTombstone(id, actor) {
4406
4456
  const live = await this.adapter.get(this.vault, this.name, id);
4407
4457
  if (!live || isTombstone(live, this.storeCiphertext) || isDeleteMarker(live)) return null;
4408
- await this.adapter.put(this.vault, this.name, id, buildTombstone(live._v, actor));
4458
+ await this.adapter.put(this.vault, this.name, id, buildTombstone({ collection: this.name, id }, live._v, actor));
4409
4459
  this.cache.delete(id);
4410
4460
  this.lru?.remove(id);
4411
4461
  this.cekCache?.remove(id);
@@ -4424,7 +4474,7 @@ var Collection = class {
4424
4474
  */
4425
4475
  async dispatchArrayDerivationsOnDelete(id, eraseRecordShapeToo = false) {
4426
4476
  if (this.derivationSource === void 0) return 0;
4427
- const { dispatchArrayDerivationsOnDelete } = await import("./dispatch-MJ6SHB3Y.js");
4477
+ const { dispatchArrayDerivationsOnDelete } = await import("./dispatch-3ZA733EY.js");
4428
4478
  return dispatchArrayDerivationsOnDelete(this.#derivationDeleteCtx(this.derivationSource), id, eraseRecordShapeToo);
4429
4479
  }
4430
4480
  /**
@@ -4438,7 +4488,7 @@ var Collection = class {
4438
4488
  */
4439
4489
  async dispatchMaterializedViewsOnDelete(id) {
4440
4490
  if (this.materializedViewSource === void 0) return { deleted: 0, residueUndecodable: [], residueDeclined: [] };
4441
- const { dispatchMaterializedViewsOnDelete } = await import("./dispatch-FZEAWKVM.js");
4491
+ const { dispatchMaterializedViewsOnDelete } = await import("./dispatch-TNM5CRLZ.js");
4442
4492
  return dispatchMaterializedViewsOnDelete(this.#mvDispatchCtx(this.materializedViewSource), id);
4443
4493
  }
4444
4494
  /**
@@ -4458,7 +4508,7 @@ var Collection = class {
4458
4508
  );
4459
4509
  }
4460
4510
  if (this.materializedViewSource !== void 0) {
4461
- const { resolveStaleMVOnRead } = await import("./stale-ARHFVL5U.js");
4511
+ const { resolveStaleMVOnRead } = await import("./stale-TH7SSVRV.js");
4462
4512
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
4463
4513
  }
4464
4514
  await this.ensureHydrated();
@@ -4792,7 +4842,7 @@ var Collection = class {
4792
4842
  const entries = [];
4793
4843
  for (const env of envelopes) {
4794
4844
  if ((env._tier ?? 0) > 0) continue;
4795
- const record = await this.codec.decryptRecord(env, { skipValidation: true, id });
4845
+ const record = await this.codec.decryptRecord(this.strategies.history.historyIdentity(this.name, id, env._v), env, { skipValidation: true });
4796
4846
  if (record === null) continue;
4797
4847
  entries.push({
4798
4848
  version: env._v,
@@ -4821,7 +4871,7 @@ var Collection = class {
4821
4871
  version
4822
4872
  );
4823
4873
  if (!envelope || (envelope._tier ?? 0) > 0 || await liveRecordIsElevated(this.adapter, this.vault, this.name, id)) return null;
4824
- return this.codec.decryptRecord(envelope, { skipValidation: true, id });
4874
+ return this.codec.decryptRecord(this.strategies.history.historyIdentity(this.name, id, envelope._v), envelope, { skipValidation: true });
4825
4875
  }
4826
4876
  /** Revert a record to a past version. Creates a new version with the old content. */
4827
4877
  async revert(id, version) {
@@ -4927,7 +4977,7 @@ var Collection = class {
4927
4977
  const id = ids[i];
4928
4978
  const envelope = await this.adapter.get(this.vault, this.name, id);
4929
4979
  if (envelope && (envelope._tier ?? 0) === 0) {
4930
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
4980
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
4931
4981
  if (record === null) continue;
4932
4982
  items.push(record);
4933
4983
  if (!this.lazy && !this.cache.has(id)) {
@@ -5009,7 +5059,7 @@ var Collection = class {
5009
5059
  const out = [];
5010
5060
  for (const { id, envelope } of items) {
5011
5061
  if ((envelope._tier ?? 0) > 0) continue;
5012
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
5062
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
5013
5063
  if (record === null) continue;
5014
5064
  out.push({ id, record, version: envelope._v });
5015
5065
  }
@@ -5070,7 +5120,7 @@ var Collection = class {
5070
5120
  }
5071
5121
  return;
5072
5122
  }
5073
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
5123
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
5074
5124
  if (record === null) {
5075
5125
  this.cache.delete(id);
5076
5126
  if (previous) {
@@ -5166,7 +5216,7 @@ var Collection = class {
5166
5216
  for (const id of ids) {
5167
5217
  const envelope = await this.adapter.get(this.vault, this.name, id);
5168
5218
  if (envelope && !isTombstone(envelope, this.storeCiphertext) && !isDeleteMarker(envelope) && (envelope._tier ?? 0) === 0) {
5169
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
5219
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
5170
5220
  if (record === null) continue;
5171
5221
  this.cache.set(id, { record, version: envelope._v });
5172
5222
  } else if (envelope && isDeleteMarker(envelope)) {
@@ -5185,7 +5235,7 @@ var Collection = class {
5185
5235
  continue;
5186
5236
  }
5187
5237
  if (isTombstone(envelope, this.storeCiphertext) || (envelope._tier ?? 0) > 0) continue;
5188
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
5238
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
5189
5239
  if (record === null) continue;
5190
5240
  this.cache.set(id, { record, version: envelope._v });
5191
5241
  }
@@ -5319,7 +5369,7 @@ var Collection = class {
5319
5369
  for (const [id, entry] of this.cache) {
5320
5370
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
5321
5371
  const prevForVdig = this.vdigFields !== null ? await this.adapter.get(this.vault, this.name, id) : null;
5322
- result[id] = await this.codec.encryptRecord(entry.record, entry.version, cek, void 0, void 0, this.vdigFields !== null ? { id, prev: prevForVdig } : void 0, id);
5372
+ result[id] = await this.codec.encryptRecord({ collection: this.name, id }, entry.record, entry.version, cek, void 0, void 0, this.vdigFields !== null ? { id, prev: prevForVdig } : void 0);
5323
5373
  }
5324
5374
  return result;
5325
5375
  }
@@ -5434,7 +5484,7 @@ var Collection = class {
5434
5484
  const envelope = await this.adapter.get(this.vault, this.name, id);
5435
5485
  if (!envelope) continue;
5436
5486
  try {
5437
- const json = await this.codec.decryptJsonString(envelope);
5487
+ const json = await this.codec.decryptJsonString({ collection: this.name, id }, envelope);
5438
5488
  if (json === null) continue;
5439
5489
  const body = JSON.parse(json);
5440
5490
  if (typeof body.recordId !== "string") continue;
@@ -5568,14 +5618,14 @@ var Collection = class {
5568
5618
  /** C-A/R10: persist the classified marker once per classified handle (store I/O in config-drift.ts). */
5569
5619
  async _ensureClassifiedMarker() {
5570
5620
  if (this._markerPersisted || this.vdigFields === null) return;
5571
- const { persistClassifiedMarkerForFields } = await import("./classified-marker-2KJAXRRO.js");
5621
+ const { persistClassifiedMarkerForFields } = await import("./classified-marker-AZDSDG6V.js");
5572
5622
  await persistClassifiedMarkerForFields(this.adapter, this.vault, this.name, this.vdigFields, await this.getDEK(this.name));
5573
5623
  this._markerPersisted = true;
5574
5624
  }
5575
5625
  /** C-A/R10 drift signal — the marker's declared digest-only set, memoized to one store read per handle (see config-drift.ts). */
5576
5626
  async _classifiedMarkerDigestOnly() {
5577
5627
  if (this._markerDigestOnlyCache !== void 0) return this._markerDigestOnlyCache;
5578
- const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-2KJAXRRO.js");
5628
+ const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-AZDSDG6V.js");
5579
5629
  this._markerDigestOnlyCache = await readClassifiedMarkerDigestOnly(this.adapter, this.vault, this.name, await this.getDEK(this.name));
5580
5630
  return this._markerDigestOnlyCache;
5581
5631
  }
@@ -5697,10 +5747,10 @@ var Collection = class {
5697
5747
  if (busActive) await this.subsystemBus.dispatch(busPoint, event);
5698
5748
  }
5699
5749
  _txAtomicSafe(opType) {
5700
- if (this.materializedViewSource !== void 0 && this.materializedViewSource.registry().mvsForSource(this.name).length > 0 || this.derivationSource !== void 0 && this.derivationSource.registry().strategiesForSource(this.name).length > 0 || this.crdtMode !== void 0 || this.uniqueConstraints !== null || this.writeHooks !== void 0 && this.writeHooks.hasBeforeHandlers && !this.writeHooks.suppressed) return false;
5750
+ if (this.materializedViewSource !== void 0 && (this.materializedViewSource.registry().hasPendingPlans() || this.materializedViewSource.registry().mvsForSource(this.name).length > 0) || this.derivationSource !== void 0 && this.derivationSource.registry().strategiesForSource(this.name).length > 0 || this.crdtMode !== void 0 || this.uniqueConstraints !== null || this.writeHooks !== void 0 && this.writeHooks.hasBeforeHandlers && !this.writeHooks.suppressed) return false;
5701
5751
  return opType === "put" ? Object.keys(this._refs).length === 0 : this.refEnforcer === void 0 || !this.refEnforcer._deleteCascadesPossible(this.name);
5702
5752
  }
5703
- // @internal #893/#906-prep atomic-commit eligibility gate (Task 4) — false on any derivation/MV source (any lifecycle), CRDT mode, unique constraints, or refs on this write direction. Put uses precise outbound `_refs`; delete (#922) consults the enforcer's `_deleteCascadesPossible(name)` — Vault unions ALL THREE cascade sources `enforceRefsOnDelete` (with-shape/links/vault-facade.ts) fires from (lookup-ref edges, classic inbound refs, managed links); anything narrower (e.g. `getInbound` alone) would admit unsafe atomic deletes, because `_prepareDelete` runs those cascades DURING prepare. #931 narrows #906's hooks blanket: only BEFORE-hooks gate (they can REFUSE a write, which only `put()`/`delete()` honors); after-hooks and the `afterPut`/`afterDelete` observe bus cannot refuse, so the atomic path fires them itself post-finalize via `_fireAtomicAfterWrite` instead of forfeiting the batch (the pre-#931 db-global blanket cost multi-tab write-relay and forget-subject apps the atomic path entirely). See atomic-eligibility.ts.
5753
+ // @internal #893/#906-prep atomic-commit eligibility gate (Task 4) — false on any derivation/MV source (any lifecycle), false while ANY query-form MV plan is still parked (#1139: an unplanned strategy has no `_bySource` entry, so `mvsForSource` cannot see that this collection is one of its sources — and the atomic path skips MV dispatch, which is the very thing that would replan it), CRDT mode, unique constraints, or refs on this write direction. Put uses precise outbound `_refs`; delete (#922) consults the enforcer's `_deleteCascadesPossible(name)` — Vault unions ALL THREE cascade sources `enforceRefsOnDelete` (with-shape/links/vault-facade.ts) fires from (lookup-ref edges, classic inbound refs, managed links); anything narrower (e.g. `getInbound` alone) would admit unsafe atomic deletes, because `_prepareDelete` runs those cascades DURING prepare. #931 narrows #906's hooks blanket: only BEFORE-hooks gate (they can REFUSE a write, which only `put()`/`delete()` honors); after-hooks and the `afterPut`/`afterDelete` observe bus cannot refuse, so the atomic path fires them itself post-finalize via `_fireAtomicAfterWrite` instead of forfeiting the batch (the pre-#931 db-global blanket cost multi-tab write-relay and forget-subject apps the atomic path entirely). See atomic-eligibility.ts.
5704
5754
  _reconcileReadState(patch) {
5705
5755
  if (patch.dictKeyFields) this.dictKeyFields = { ...patch.dictKeyFields, ...this.dictKeyFields };
5706
5756
  if (patch.i18nFields) this.i18nFields = { ...patch.i18nFields, ...this.i18nFields };
@@ -5727,8 +5777,9 @@ var Collection = class {
5727
5777
  syncIndexes: (id, rec, version, priorEnvelope) => syncTierIndexes(this.indexingContext(), id, rec, version, priorEnvelope),
5728
5778
  syncSearch: (id, rec, version) => syncTierSearch(this.searchContext(), id, rec, version),
5729
5779
  syncHistory: async (id, fromDek, toDek) => this.strategies.history.rewrapHistory(this.adapter, this.vault, this.name, id, fromDek, toDek, await this.getDEK(this.name)),
5730
- saveHistorySnapshot: async (id, envelope) => {
5780
+ saveHistorySnapshot: async (id, version, seal) => {
5731
5781
  if (this.historyConfig.enabled === false) return;
5782
+ const envelope = await seal(this.strategies.history.historyIdentity(this.name, id, version));
5732
5783
  await this.strategies.history.saveHistory(this.adapter, this.vault, this.name, id, envelope);
5733
5784
  this.emitter.emit("history:save", { vault: this.vault, collection: this.name, id, version: envelope._v });
5734
5785
  if (this.historyConfig.maxVersions) await this.strategies.history.pruneHistory(this.adapter, this.vault, this.name, id, { keepVersions: this.historyConfig.maxVersions });
@@ -6012,17 +6063,18 @@ var DeferredNumberingStore = class {
6012
6063
  async readJson(collection, id) {
6013
6064
  const env = await this.adapter.get(this.vault, collection, id);
6014
6065
  if (!env) return { env: null, value: null };
6015
- const json = this.encrypted ? await openEnvelopeJson(env, await this.dek(collection)) : env._data;
6066
+ const json = this.encrypted ? await openEnvelopeJson({ collection, id }, env, await this.dek(collection)) : env._data;
6016
6067
  return { env, value: JSON.parse(json) };
6017
6068
  }
6018
6069
  async writeJson(collection, id, value, expectedVersion) {
6019
6070
  const json = JSON.stringify(value);
6020
6071
  let env;
6021
6072
  if (!this.encrypted) {
6022
- env = { _noydb: NOYDB_FORMAT_VERSION, _v: expectedVersion + 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: "", _data: json, _by: this.actor };
6073
+ env = buildRecordEnvelope({ collection, id, version: expectedVersion + 1 }, { iv: "", data: json });
6023
6074
  } else {
6024
- const { iv, data } = await encrypt(json, await this.dek(collection));
6025
- env = { _noydb: NOYDB_FORMAT_VERSION, _v: expectedVersion + 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: iv, _data: data, _by: this.actor };
6075
+ const identity = { collection, id, version: expectedVersion + 1 };
6076
+ const { iv, data } = await encrypt(json, await this.dek(collection), buildRecordAad(identity));
6077
+ env = buildRecordEnvelope(identity, { iv, data });
6026
6078
  }
6027
6079
  await this.adapter.put(this.vault, collection, id, env, expectedVersion);
6028
6080
  }
@@ -6417,7 +6469,8 @@ var VaultPeriods = class {
6417
6469
  if (tp) targetPurges.set(tp.period, tp);
6418
6470
  }
6419
6471
  const scoped = options === void 0 ? all : all.filter((p) => samePartition(p.partition, options.partition));
6420
- return scoped.map((p) => {
6472
+ const withReopen = await this.mergeReopenState(scoped);
6473
+ return withReopen.map((p) => {
6421
6474
  const f = freezes.get(p.name);
6422
6475
  let merged = f ? this.mergeFreeze(p, f) : p;
6423
6476
  const a = archives.get(p.name);
@@ -6447,8 +6500,119 @@ var VaultPeriods = class {
6447
6500
  if (archive) merged = this.mergeArchive(merged, archive);
6448
6501
  const targetPurge = await this.readReserved(PERIOD_TARGET_PURGES_COLLECTION, key);
6449
6502
  if (targetPurge) merged = this.mergeTargetPurge(merged, targetPurge);
6503
+ const reopenLog = await this.readReserved(PERIOD_REOPENS_COLLECTION, key);
6504
+ if (reopenLog) merged = { ...merged, ...resolveReopenState(reopenLog.events) };
6450
6505
  return merged;
6451
6506
  }
6507
+ /**
6508
+ * The full append-only reopen/reclose log for one period (#1022) — the record
6509
+ * an audit actually asks for, in order. `[]` when never reopened.
6510
+ */
6511
+ async listPeriodReopens(name, options) {
6512
+ const key = resolvePeriodKey(name, options?.partition);
6513
+ const log = await this.readReserved(PERIOD_REOPENS_COLLECTION, key);
6514
+ return log?.events ?? [];
6515
+ }
6516
+ /**
6517
+ * Return a closed period to a writable state (#1022).
6518
+ *
6519
+ * Close is a three-state lifecycle in practice — open / closed / reopened —
6520
+ * because a month gets closed and then a missing invoice arrives, or a filing
6521
+ * is rejected and must be amended. That is routine, and it is supposed to
6522
+ * leave a trail.
6523
+ *
6524
+ * The `_periods/<key>` record is NOT touched: the reopen is appended to a
6525
+ * companion log, so the inter-period hash chain that proves the close
6526
+ * happened survives the reopen intact. The chain reads *closed at T1,
6527
+ * reopened at T2 by U, reclosed at T3*.
6528
+ *
6529
+ * A reopen withdraws the PERIOD's veto and nothing else. Record-level rules —
6530
+ * an `immutableGuard` on a sent receipt, a frozen field — are separate gate
6531
+ * handlers registered ahead of the period gate, so a reopened month cannot
6532
+ * resurrect a document that is independently locked. Period state can only
6533
+ * ever widen what the record-level rule already permits.
6534
+ *
6535
+ * Reopening an already-open window is allowed and appends another event: that
6536
+ * is how a window gets extended, and the log keeps both.
6537
+ */
6538
+ async reopenPeriod(name, options) {
6539
+ const existing = await this.loadPeriodsCache();
6540
+ const period = this.findPeriod(existing, name, options);
6541
+ if (!period) throw new ValidationError(`reopenPeriod: no period named "${name}"${scopeSuffix(options)}.`);
6542
+ if (period.kind !== "closed") {
6543
+ throw new ValidationError(
6544
+ `reopenPeriod: period "${name}" is "${period.kind}"; only a closed period can be reopened.`
6545
+ );
6546
+ }
6547
+ if (options?.until !== void 0 && Number.isNaN(Date.parse(options.until))) {
6548
+ throw new ValidationError(`reopenPeriod: unparseable \`until\` "${options.until}".`);
6549
+ }
6550
+ return this.appendReopenEvent(period, options, {
6551
+ op: "reopen",
6552
+ at: (/* @__PURE__ */ new Date()).toISOString(),
6553
+ by: this.deps.userId(),
6554
+ ...options?.until !== void 0 && { until: options.until },
6555
+ ...options?.reason !== void 0 && { reason: options.reason }
6556
+ });
6557
+ }
6558
+ /**
6559
+ * Seal a reopened period again (#1022), ending the window explicitly rather
6560
+ * than waiting for an `until` to lapse. Appends to the same log, so the
6561
+ * close → reopen → reclose sequence is recoverable in order.
6562
+ */
6563
+ async reclosePeriod(name, options) {
6564
+ const existing = await this.loadPeriodsCache();
6565
+ const period = this.findPeriod(existing, name, options);
6566
+ if (!period) throw new ValidationError(`reclosePeriod: no period named "${name}"${scopeSuffix(options)}.`);
6567
+ const merged = await this.mergeReopenState([period]);
6568
+ if (!isEffectivelyReopened(merged[0], (/* @__PURE__ */ new Date()).toISOString())) {
6569
+ throw new ValidationError(
6570
+ `reclosePeriod: period "${name}"${scopeSuffix(options)} is not currently reopened \u2014 nothing to reclose. A period whose \`until\` has already lapsed re-sealed on its own.`
6571
+ );
6572
+ }
6573
+ return this.appendReopenEvent(period, options, {
6574
+ op: "reclose",
6575
+ at: (/* @__PURE__ */ new Date()).toISOString(),
6576
+ by: this.deps.userId(),
6577
+ ...options?.reason !== void 0 && { reason: options.reason }
6578
+ });
6579
+ }
6580
+ /** Append one entry to a period's reopen log, ledger it, and invalidate the guard's view. */
6581
+ async appendReopenEvent(period, scope, event) {
6582
+ const key = resolvePeriodKey(period.name, period.partition);
6583
+ const prior = await this.readReserved(PERIOD_REOPENS_COLLECTION, key);
6584
+ const record = {
6585
+ period: period.name,
6586
+ ...hasPartition(period.partition) && { partition: period.partition },
6587
+ events: [...prior?.events ?? [], event]
6588
+ };
6589
+ const envelope = await this.writeReserved(PERIOD_REOPENS_COLLECTION, key, record);
6590
+ await this.deps.strategy.appendPeriodLedgerEntry(
6591
+ this.deps.getLedgerOrNull(),
6592
+ this.deps.userId(),
6593
+ envelope,
6594
+ key,
6595
+ PERIOD_REOPENS_COLLECTION
6596
+ );
6597
+ this.periodCache = null;
6598
+ void scope;
6599
+ return { ...period, ...resolveReopenState(record.events) };
6600
+ }
6601
+ /** Merge each period's reopen log onto it. One adapter listing, not one per period. */
6602
+ async mergeReopenState(periods) {
6603
+ if (periods.length === 0) return [];
6604
+ const ids = await this.deps.adapter.list(this.deps.vault, PERIOD_REOPENS_COLLECTION);
6605
+ if (ids.length === 0) return [...periods];
6606
+ const byKey = /* @__PURE__ */ new Map();
6607
+ for (const id of ids) {
6608
+ const r = await this.readReserved(PERIOD_REOPENS_COLLECTION, id);
6609
+ if (r) byKey.set(id, r);
6610
+ }
6611
+ return periods.map((p) => {
6612
+ const log = byKey.get(resolvePeriodKey(p.name, p.partition));
6613
+ return log ? { ...p, ...resolveReopenState(log.events) } : p;
6614
+ });
6615
+ }
6452
6616
  /** Resolve one period within the timeline named by `options` (vault-wide when absent). */
6453
6617
  findPeriod(all, name, options) {
6454
6618
  return all.find((p) => p.name === name && samePartition(p.partition, options?.partition));
@@ -6457,11 +6621,12 @@ var VaultPeriods = class {
6457
6621
  async assertTsWritable(existing, incoming, collection) {
6458
6622
  if (existing === null && incoming === null) return;
6459
6623
  if (this.periodCache === null) {
6460
- this.periodCache = await this.deps.strategy.loadPeriods(
6624
+ const loaded = await this.deps.strategy.loadPeriods(
6461
6625
  this.deps.adapter,
6462
6626
  this.deps.vault,
6463
- (env) => this.decryptPeriodRecord(env)
6627
+ (id, env) => this.decryptPeriodRecord(id, env)
6464
6628
  );
6629
+ this.periodCache = await this.mergeReopenState(loaded);
6465
6630
  }
6466
6631
  if (this.periodCache.length === 0) return;
6467
6632
  this.deps.strategy.assertTsWritable(
@@ -6476,7 +6641,7 @@ var VaultPeriods = class {
6476
6641
  const loaded = await this.deps.strategy.loadPeriods(
6477
6642
  this.deps.adapter,
6478
6643
  this.deps.vault,
6479
- (env) => this.decryptPeriodRecord(env)
6644
+ (id, env) => this.decryptPeriodRecord(id, env)
6480
6645
  );
6481
6646
  this.periodCache = loaded;
6482
6647
  return loaded;
@@ -6484,27 +6649,15 @@ var VaultPeriods = class {
6484
6649
  /** Generic reserved-collection writer — serves `_periods` and `_period_freezes` alike. */
6485
6650
  async writeReserved(collection, key, value) {
6486
6651
  const json = JSON.stringify(value);
6652
+ const actor = this.deps.userId();
6653
+ const identity = { collection, id: key, by: actor, version: 1 };
6487
6654
  let envelope;
6488
6655
  if (this.deps.encrypted) {
6489
6656
  const dek = await this.deps.getDEK(collection);
6490
- const { iv, data } = await encrypt(json, dek);
6491
- envelope = {
6492
- _noydb: NOYDB_FORMAT_VERSION,
6493
- _v: 1,
6494
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
6495
- _iv: iv,
6496
- _data: data,
6497
- _by: this.deps.userId()
6498
- };
6657
+ const { iv, data } = await encrypt(json, dek, buildRecordAad(identity));
6658
+ envelope = buildRecordEnvelope(identity, { iv, data });
6499
6659
  } else {
6500
- envelope = {
6501
- _noydb: NOYDB_FORMAT_VERSION,
6502
- _v: 1,
6503
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
6504
- _iv: "",
6505
- _data: json,
6506
- _by: this.deps.userId()
6507
- };
6660
+ envelope = buildRecordEnvelope(identity, { iv: "", data: json });
6508
6661
  }
6509
6662
  await this.deps.adapter.put(this.deps.vault, collection, key, envelope);
6510
6663
  if (collection === PERIODS_COLLECTION && this.deps.onDirty) {
@@ -6516,14 +6669,14 @@ var VaultPeriods = class {
6516
6669
  async readReserved(collection, key) {
6517
6670
  const env = await this.deps.adapter.get(this.deps.vault, collection, key);
6518
6671
  if (!env) return null;
6519
- const json = this.deps.encrypted ? await openEnvelopeJson(env, await this.deps.getDEK(collection)) : env._data;
6672
+ const json = this.deps.encrypted ? await openEnvelopeJson({ collection, id: key }, env, await this.deps.getDEK(collection)) : env._data;
6520
6673
  return JSON.parse(json);
6521
6674
  }
6522
- async decryptPeriodRecord(envelope) {
6675
+ async decryptPeriodRecord(periodId, envelope) {
6523
6676
  let json;
6524
6677
  if (this.deps.encrypted) {
6525
6678
  const dek = await this.deps.getDEK(PERIODS_COLLECTION);
6526
- json = await openEnvelopeJson(envelope, dek);
6679
+ json = await openEnvelopeJson({ collection: PERIODS_COLLECTION, id: periodId }, envelope, dek);
6527
6680
  } else {
6528
6681
  json = envelope._data;
6529
6682
  }
@@ -7098,7 +7251,7 @@ var VaultLinks = class {
7098
7251
  // src/with-shape/links/lazy-handle.ts
7099
7252
  function makeLazyLinkSetHandle(d) {
7100
7253
  let engine = null;
7101
- const load = () => engine ??= import("./link-set-E5HNY67I.js").then(
7254
+ const load = () => engine ??= import("./link-set-5PJBBR63.js").then(
7102
7255
  ({ LinkSet }) => new LinkSet(d.adapter, d.vault, d.name, d.spec, d.encrypted, d.getDEK, d.actor, d.emitter, d.endpointExists)
7103
7256
  );
7104
7257
  return {
@@ -7504,6 +7657,10 @@ function reconcileViaAttach(coll, graph, name, vaultCtx, plan) {
7504
7657
  classifiedFields: plan.classifiedFields,
7505
7658
  computed: plan.computed
7506
7659
  }) : void 0;
7660
+ if (plan.refs !== void 0) {
7661
+ vaultCtx.refRegistry.register(name, plan.refs);
7662
+ coll._attachDeclaredRefs(vaultCtx.refRegistry.getOutbound(name));
7663
+ }
7507
7664
  if (plan.effectiveViaFields.moneyFields) coll._applyMoneyFields(plan.effectiveViaFields.moneyFields);
7508
7665
  if (plan.computed) coll._applyComputed(plan.computed);
7509
7666
  if (plan.fieldMeta) coll._applyFieldMeta(plan.fieldMeta);
@@ -7745,7 +7902,7 @@ function declareSatellite(ctx, collectionName, options, existingRegistry) {
7745
7902
  ctx.forEachSyncEngine((e) => e.remirrorPairResolvers([spec.base, spec.satellite]));
7746
7903
  const registry = reg;
7747
7904
  const baseSchema = ctx.getBaseSchema(spec.base);
7748
- void import("./post-register-2XSSMGEQ.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
7905
+ void import("./post-register-QCJYRMIK.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
7749
7906
  });
7750
7907
  return reg;
7751
7908
  }
@@ -8065,17 +8222,6 @@ function expandRefsWithSatellites(refs, registry) {
8065
8222
  return anySat ? out : refs;
8066
8223
  }
8067
8224
 
8068
- // src/with-shape/satellites/migrate-cek.ts
8069
- async function migrateSatelliteCek(name, coll) {
8070
- if (coll.getConfig()?.perRecordKeys !== true) {
8071
- throw new SatelliteConfigError(
8072
- `migrateSatellitePerRecordKeys: collection "${name}" was already opened this session without perRecordKeys (construction-only); migrate before its first open, or restart the session.`
8073
- );
8074
- }
8075
- const migrated = await coll._applyCutoverTransform((doc) => doc);
8076
- return { migrated };
8077
- }
8078
-
8079
8225
  // src/with-shape/schema-update/fence-controller.ts
8080
8226
  function schemaBumpAuditHook(getLedger, actor) {
8081
8227
  return async (generation) => {
@@ -8638,6 +8784,7 @@ var Vault = class {
8638
8784
  * dispatch reads/writes — from this vault's OWN privates, rather than passing `this` itself. */
8639
8785
  _viaReconcileCtx() {
8640
8786
  return {
8787
+ refRegistry: this.refRegistry,
8641
8788
  i18nStrategy: this.strategies.i18n,
8642
8789
  locale: this.locale,
8643
8790
  translateText: this.translateText,
@@ -8713,6 +8860,8 @@ var Vault = class {
8713
8860
  if (coll) {
8714
8861
  reconcileViaAttach(coll, this.graph, collectionName, this._viaReconcileCtx(), {
8715
8862
  effectiveViaFields,
8863
+ ...options?.refs !== void 0 ? { refs: options.refs } : {},
8864
+ // #1141 — late `refs` declaration
8716
8865
  ...options?.computed !== void 0 ? { computed: options.computed } : {},
8717
8866
  ...options?.fieldMeta !== void 0 ? { fieldMeta: options.fieldMeta } : {},
8718
8867
  ...options?.meta !== void 0 ? { meta: options.meta } : {},
@@ -8728,7 +8877,7 @@ var Vault = class {
8728
8877
  const strategies = options.schemaUpdate ?? [];
8729
8878
  const work = (async () => {
8730
8879
  const dek = await this.getDEK(collectionName);
8731
- const { persistSchemaIfNeeded } = await import("./register-4EFJCVYD.js");
8880
+ const { persistSchemaIfNeeded } = await import("./register-JBOEHTVX.js");
8732
8881
  const result = await persistSchemaIfNeeded({
8733
8882
  store: this.adapter,
8734
8883
  vault: this.name,
@@ -8878,7 +9027,7 @@ var Vault = class {
8878
9027
  const work = (async () => {
8879
9028
  try {
8880
9029
  const dek = await this.getDEK(collectionName);
8881
- await (await import("./register-4EFJCVYD.js")).persistSchemaIfNeeded({
9030
+ await (await import("./register-JBOEHTVX.js")).persistSchemaIfNeeded({
8882
9031
  store: this.adapter,
8883
9032
  vault: this.name,
8884
9033
  collectionName,
@@ -8921,9 +9070,10 @@ var Vault = class {
8921
9070
  * unblocks R-S7 when a base gains forget coverage after its satellite was
8922
9071
  * already declared without `perRecordKeys`. Call BEFORE re-declaring with
8923
9072
  * `{ satelliteOf, perRecordKeys: true }` AND before this collection serves
8924
- * writes (unfenced walk — see {@link migrateSatelliteCek}); resumable.
9073
+ * writes (unfenced walk — see `with-shape/satellites/migrate-cek.ts`); resumable.
8925
9074
  */
8926
9075
  async migrateSatellitePerRecordKeys(satelliteName) {
9076
+ const { migrateSatelliteCek } = await import("./migrate-cek-V3VDRV24.js");
8927
9077
  return migrateSatelliteCek(satelliteName, this.collection(satelliteName, { perRecordKeys: true }));
8928
9078
  }
8929
9079
  /**
@@ -9554,16 +9704,23 @@ var Vault = class {
9554
9704
  */
9555
9705
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
9556
9706
  async _loadPodSigner() {
9557
- const { loadSigner } = await import("./signer-TA55QB6R.js");
9707
+ const { loadSigner } = await import("./signer-53AQ3BU2.js");
9558
9708
  return loadSigner(this.adapter, this.name, this.getDEK);
9559
9709
  }
9560
9710
  async writeExportAudit(entry) {
9561
9711
  const json = JSON.stringify(entry);
9712
+ const exportAuditIdentity = { collection: EXPORT_AUDIT_COLLECTION, id: entry.id, by: entry.actor, version: 1 };
9562
9713
  const envelope = this.encrypted ? await (async () => {
9563
9714
  const dek = await this.getDEK(EXPORT_AUDIT_COLLECTION);
9564
- const { iv, data } = await encrypt(json, dek);
9565
- return { _noydb: NOYDB_FORMAT_VERSION, _v: 1, _ts: entry.startedAt, _iv: iv, _data: data, _by: entry.actor };
9566
- })() : { _noydb: NOYDB_FORMAT_VERSION, _v: 1, _ts: entry.startedAt, _iv: "", _data: json, _by: entry.actor };
9715
+ const { iv, data } = await encrypt(json, dek, buildRecordAad(exportAuditIdentity));
9716
+ return buildRecordEnvelope(
9717
+ exportAuditIdentity,
9718
+ { ts: entry.startedAt, iv, data }
9719
+ );
9720
+ })() : buildRecordEnvelope(
9721
+ exportAuditIdentity,
9722
+ { ts: entry.startedAt, iv: "", data: json }
9723
+ );
9567
9724
  await this.adapter.put(this.name, EXPORT_AUDIT_COLLECTION, entry.id, envelope);
9568
9725
  }
9569
9726
  canExport(tier, format) {
@@ -9577,12 +9734,12 @@ var Vault = class {
9577
9734
  *
9578
9735
  * @internal
9579
9736
  */
9580
- async _decryptEnvelopeForBundleFilter(env, collectionName) {
9737
+ async _decryptEnvelopeForBundleFilter(env, collectionName, recordId) {
9581
9738
  if (!this.encrypted) {
9582
9739
  return JSON.parse(env._data);
9583
9740
  }
9584
9741
  const dek = await this.getDEK(collectionName);
9585
- const json = await openEnvelopeJson(env, dek);
9742
+ const json = await openEnvelopeJson({ collection: collectionName, id: recordId }, env, dek);
9586
9743
  return JSON.parse(json);
9587
9744
  }
9588
9745
  canImport(tier, format) {
@@ -10037,7 +10194,7 @@ var Vault = class {
10037
10194
  async _initGuards(handles) {
10038
10195
  if (handles.length === 0) return;
10039
10196
  const [{ GuardRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
10040
- import("./registry-IKUR2MXD.js"),
10197
+ import("./registry-5DYHQFJS.js"),
10041
10198
  import("./read-only-facade-CHCKSEPD.js")
10042
10199
  ]);
10043
10200
  const registry = new GuardRegistry();
@@ -10065,7 +10222,7 @@ var Vault = class {
10065
10222
  async _initDerivations(handles) {
10066
10223
  if (handles.length === 0) return;
10067
10224
  const [{ DerivationRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
10068
- import("./registry-4SDHHOJ7.js"),
10225
+ import("./registry-R23SQUQH.js"),
10069
10226
  import("./read-only-facade-CHCKSEPD.js")
10070
10227
  ]);
10071
10228
  const registry = new DerivationRegistry();
@@ -10097,7 +10254,7 @@ var Vault = class {
10097
10254
  */
10098
10255
  async _initMaterializedViews(handles) {
10099
10256
  if (handles.length === 0) return;
10100
- const { MaterializedViewRegistry } = await import("./registry-OYTFGWVK.js");
10257
+ const { MaterializedViewRegistry } = await import("./registry-J25H6VB4.js");
10101
10258
  const registry = new MaterializedViewRegistry();
10102
10259
  this.materializedViewRegistry = registry;
10103
10260
  const db = this;
@@ -10122,7 +10279,7 @@ var Vault = class {
10122
10279
  */
10123
10280
  async _initOverlayedViews(handles) {
10124
10281
  if (handles.length === 0) return;
10125
- const { OverlayedViewRegistry } = await import("./registry-CZVINVQH.js");
10282
+ const { OverlayedViewRegistry } = await import("./registry-EANV44W2.js");
10126
10283
  const registry = new OverlayedViewRegistry();
10127
10284
  const mvRegistry = this.materializedViewRegistry;
10128
10285
  const overlayNames = /* @__PURE__ */ new Set();
@@ -10180,18 +10337,19 @@ var Vault = class {
10180
10337
  if (registry === null) {
10181
10338
  return { written: 0, deleted: 0, failed: 0, residueUndecodable: [], residueDeclined: [] };
10182
10339
  }
10340
+ await registry.resolvePendingPlans();
10183
10341
  const reg = registry.byName(name);
10184
10342
  if (!reg) {
10185
10343
  throw new Error(`refreshView: no MV registered with name "${name}"`);
10186
10344
  }
10187
- const { MaterializedViewExecutor } = await import("./executor-YIQB2S6N.js");
10345
+ const { MaterializedViewExecutor } = await import("./executor-ZUTUMTPA.js");
10188
10346
  const result = await MaterializedViewExecutor.refresh(reg, {
10189
10347
  getCollection: (n) => this.collection(n),
10190
10348
  getActiveTxContext: () => this.noydb._activeTxContextOrNull,
10191
10349
  getQueryContext: () => this,
10192
10350
  dispatchCtx: this._dispatchCtx({ collection: name, id: "refreshView" })
10193
10351
  });
10194
- const { clearMVStaleFully } = await import("./stale-ARHFVL5U.js");
10352
+ const { clearMVStaleFully } = await import("./stale-TH7SSVRV.js");
10195
10353
  await clearMVStaleFully(this.adapter, this.name, registry, name);
10196
10354
  return result;
10197
10355
  }
@@ -10204,7 +10362,7 @@ var Vault = class {
10204
10362
  if (registry === null) return { derived: 0, failed: 0, skippedFrozen: 0 };
10205
10363
  const strategies = registry.strategiesForSource(sourceCollection);
10206
10364
  if (strategies.length === 0) return { derived: 0, failed: 0, skippedFrozen: 0 };
10207
- const { DerivationExecutor } = await import("./executor-S4QIKEHW.js");
10365
+ const { DerivationExecutor } = await import("./executor-BBEEUFO3.js");
10208
10366
  const sourceColl = this.collection(sourceCollection);
10209
10367
  const records = await sourceColl.list();
10210
10368
  const ctx = { vault: this.derivationFacade ?? new (await import("./read-only-facade-CHCKSEPD.js")).ReadOnlyVaultFacade(this, "derivation") };
@@ -10231,7 +10389,7 @@ var Vault = class {
10231
10389
  if (!outSpec) continue;
10232
10390
  const outputColl = this.collection(outSpec.collection);
10233
10391
  if (out.kind === "array") {
10234
- const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-NNAJQXMX.js");
10392
+ const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-3QZU7ZZX.js");
10235
10393
  const prior = await loadFanoutSidecar(this.adapter, this.name, spec.source, id, key, this.getDEK, this.encrypted);
10236
10394
  const prevKeys = new Set(prior?.keys ?? []);
10237
10395
  const newKeysList = out.entries.map((e) => e.key);
@@ -10458,7 +10616,7 @@ var Vault = class {
10458
10616
  * collection.
10459
10617
  */
10460
10618
  async delegate(opts) {
10461
- const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-MO7YZYJS.js");
10619
+ const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-5F36DRDH.js");
10462
10620
  if (!this.keyring.kek) {
10463
10621
  throw new ValidationError(
10464
10622
  "issueDelegation: keyring.kek is null \u2014 issuing a delegation requires a tier-1 unlock. Re-authenticate at tier 1 (secret) first."
@@ -10480,7 +10638,7 @@ var Vault = class {
10480
10638
  * if the id does not exist.
10481
10639
  */
10482
10640
  async revokeDelegation(id) {
10483
- const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-MO7YZYJS.js");
10641
+ const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-5F36DRDH.js");
10484
10642
  await revokeDelegation(this.adapter, this.name, id);
10485
10643
  void DELEGATIONS_COLLECTION;
10486
10644
  }
@@ -10576,25 +10734,18 @@ var Vault = class {
10576
10734
  async writeElevationAudit(entry) {
10577
10735
  const id = `elev-${Date.now().toString(36)}-${Math.random().toString(16).slice(2, 10)}`;
10578
10736
  const json = JSON.stringify({ id, ...entry });
10737
+ const elevationAuditIdentity = { collection: ELEVATION_AUDIT_COLLECTION, id, by: entry.actor, version: 1 };
10579
10738
  const envelope = this.encrypted ? await (async () => {
10580
10739
  const dek = await this.getDEK(ELEVATION_AUDIT_COLLECTION);
10581
- const { iv, data } = await encrypt(json, dek);
10582
- return {
10583
- _noydb: NOYDB_FORMAT_VERSION,
10584
- _v: 1,
10585
- _ts: entry.startedAt,
10586
- _iv: iv,
10587
- _data: data,
10588
- _by: entry.actor
10589
- };
10590
- })() : {
10591
- _noydb: NOYDB_FORMAT_VERSION,
10592
- _v: 1,
10593
- _ts: entry.startedAt,
10594
- _iv: "",
10595
- _data: json,
10596
- _by: entry.actor
10597
- };
10740
+ const { iv, data } = await encrypt(json, dek, buildRecordAad(elevationAuditIdentity));
10741
+ return buildRecordEnvelope(
10742
+ elevationAuditIdentity,
10743
+ { ts: entry.startedAt, iv, data }
10744
+ );
10745
+ })() : buildRecordEnvelope(
10746
+ elevationAuditIdentity,
10747
+ { ts: entry.startedAt, iv: "", data: json }
10748
+ );
10598
10749
  await this.adapter.put(this.name, ELEVATION_AUDIT_COLLECTION, id, envelope);
10599
10750
  }
10600
10751
  /**
@@ -10699,6 +10850,18 @@ var Vault = class {
10699
10850
  async purgePeriodTargets(name, options) {
10700
10851
  return this.periods.purgePeriodTargets(name, options);
10701
10852
  }
10853
+ /** Return a closed period to writable (#1022); logged append-only, close chain untouched. */
10854
+ async reopenPeriod(name, options) {
10855
+ return this.periods.reopenPeriod(name, options);
10856
+ }
10857
+ /** Seal a reopened period again (#1022) rather than waiting for its `until` to lapse. */
10858
+ async reclosePeriod(name, options) {
10859
+ return this.periods.reclosePeriod(name, options);
10860
+ }
10861
+ /** The append-only reopen/reclose log for one period (#1022), in order. */
10862
+ async listPeriodReopens(name, options) {
10863
+ return this.periods.listPeriodReopens(name, options);
10864
+ }
10702
10865
  /** @internal — called by the gate bus before put/delete. */
10703
10866
  async _assertTsWritable(existing, incoming, collection) {
10704
10867
  return this.periods.assertTsWritable(existing, incoming, collection);
@@ -10728,7 +10891,7 @@ var Vault = class {
10728
10891
  * @see design-history/2026-05-22-schema-dump-design.md
10729
10892
  */
10730
10893
  async dumpSchema(opts = {}) {
10731
- const { dumpVaultSchema } = await import("./walk-3ZECBFDA.js");
10894
+ const { dumpVaultSchema } = await import("./walk-NABCHDZN.js");
10732
10895
  return dumpVaultSchema(this, opts);
10733
10896
  }
10734
10897
  /**
@@ -10823,15 +10986,15 @@ var Vault = class {
10823
10986
  * distinct handles, which is the right behavior — they're
10824
10987
  * separate vault instances now.
10825
10988
  */
10826
- async getBundleHandle() {
10827
- const { buildBundleHandle } = await import("./bundle-handle-GFNHT52M.js");
10828
- return buildBundleHandle(this.adapter, this.name);
10989
+ async getPodHandle() {
10990
+ const { buildPodHandle } = await import("./pod-handle-AZ3CXY5Y.js");
10991
+ return buildPodHandle(this.adapter, this.name);
10829
10992
  }
10830
10993
  /**
10831
10994
  * Read the owner-curated cover for this vault (or `undefined` if
10832
10995
  * none is persisted). The cover lives in `_meta/public-envelope`
10833
10996
  * (the frozen wire name) as plaintext — readable without any KEK
10834
- * — so `getBundleHandle`-style callers can label a vault before
10997
+ * — so `getPodHandle`-style callers can label a vault before
10835
10998
  * unlock.
10836
10999
  *
10837
11000
  * Mirrors `Noydb.getCover(vault, opts)` but scoped to a
@@ -10856,7 +11019,7 @@ var Vault = class {
10856
11019
  * both modes round-trip cleanly.
10857
11020
  */
10858
11021
  async dump() {
10859
- const { dumpVault } = await import("./backup-KULFZ2T4.js");
11022
+ const { dumpVault } = await import("./backup-VL4GRIEW.js");
10860
11023
  return dumpVault(this.backupContext());
10861
11024
  }
10862
11025
  /**
@@ -10908,7 +11071,7 @@ var Vault = class {
10908
11071
  * — there's no chain to verify against.
10909
11072
  */
10910
11073
  async load(backupJson) {
10911
- const { loadVault } = await import("./backup-KULFZ2T4.js");
11074
+ const { loadVault } = await import("./backup-VL4GRIEW.js");
10912
11075
  return loadVault(this.backupContext(), backupJson);
10913
11076
  }
10914
11077
  /**
@@ -10940,7 +11103,7 @@ var Vault = class {
10940
11103
  * way to detect tampering of an in-place vault.
10941
11104
  */
10942
11105
  async verifyBackupIntegrity() {
10943
- const { verifyBackupIntegrity } = await import("./backup-KULFZ2T4.js");
11106
+ const { verifyBackupIntegrity } = await import("./backup-VL4GRIEW.js");
10944
11107
  return verifyBackupIntegrity(this.backupContext());
10945
11108
  }
10946
11109
  /**
@@ -11158,7 +11321,7 @@ var Vault = class {
11158
11321
  * is the live validator object, not a serialization of it).
11159
11322
  */
11160
11323
  async exportJSON(opts = {}) {
11161
- const { exportVaultJSON } = await import("./backup-KULFZ2T4.js");
11324
+ const { exportVaultJSON } = await import("./backup-VL4GRIEW.js");
11162
11325
  return exportVaultJSON(this.backupContext(), opts);
11163
11326
  }
11164
11327
  };
@@ -12069,6 +12232,20 @@ var TeamFacade = class {
12069
12232
  this.deps.keyringCache.set(vault, keyring);
12070
12233
  return result;
12071
12234
  }
12235
+ /** Gate + run the `verifyRoster` engine (#1121). See `Noydb.verifyRoster`. */
12236
+ async runVerifyRoster(engine, vault) {
12237
+ const keyring = await this.deps.getKeyringInternal(vault);
12238
+ return engine(this.deps.options.store, vault, keyring);
12239
+ }
12240
+ /** Gate + run the `quarantineKeyring` engine (#1121). See `Noydb.quarantineKeyring`. */
12241
+ async runQuarantine(engine, vault, userId, factors) {
12242
+ this.deps.checkPolicyOperation(vault, "revoke");
12243
+ await this.deps.checkGate(vault, "revoke-user", factors);
12244
+ const keyring = await this.deps.getKeyringInternal(vault);
12245
+ const result = await engine(this.deps.options.store, vault, keyring, userId);
12246
+ this.deps.keyringCache.set(vault, keyring);
12247
+ return result;
12248
+ }
12072
12249
  // ─── Tier-2 enroll / remove ─────────────────────────────────────
12073
12250
  /**
12074
12251
  * Add a tier-2 authenticator slot to the calling user's keyring.
@@ -12974,6 +13151,7 @@ var Noydb = class {
12974
13151
  this.#registerGuardGate();
12975
13152
  this.#registerPeriodGate();
12976
13153
  this.#registerForgetHooks();
13154
+ this.#registerVaultHeadObserver();
12977
13155
  this.resetSessionTimer();
12978
13156
  }
12979
13157
  /** @internal — resolved forget strategy (NO_FORGET when not configured). */
@@ -12990,6 +13168,22 @@ var Noydb = class {
12990
13168
  // - the subsystemBus `afterDelete` observer fires on delete (onAfterWrite
12991
13169
  // does NOT) — drop the ref so a deleted record never lingers in the
12992
13170
  // index (RISK #2). Without it, forget() would try to shred a ghost.
13171
+ /** #1044 — see `with-commit/vault-head/strategy.ts` for why this is an observer. */
13172
+ #registerVaultHeadObserver() {
13173
+ if (!this.strategies.vaultHead.enabled) return;
13174
+ for (const point of ["afterPut", "afterDelete"]) {
13175
+ this.subsystemBus.register(point, async (event) => {
13176
+ const vault = this.vaultCache.get(event.vault);
13177
+ if (!vault) return;
13178
+ const { adapter, getDEK } = vault._introspectState();
13179
+ await this.strategies.vaultHead.note(adapter, event.vault, getDEK, {
13180
+ collection: event.collection,
13181
+ id: event.docId,
13182
+ version: event.version
13183
+ });
13184
+ });
13185
+ }
13186
+ }
12993
13187
  #registerForgetHooks() {
12994
13188
  const subjects = this.strategies.forget.subjects;
12995
13189
  if (Object.keys(subjects).length === 0) return;
@@ -13055,7 +13249,7 @@ var Noydb = class {
13055
13249
  if (!facade) return;
13056
13250
  const ctx = { existing, vault: facade, userId: e.userId, role: e.role };
13057
13251
  await registry.runChecks(e.collection, incoming, ctx);
13058
- const { GuardExecutor } = await import("./executor-CYJQLKKI.js");
13252
+ const { GuardExecutor } = await import("./executor-G6G3YEWR.js");
13059
13253
  for (const g of guards) {
13060
13254
  await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming, e.computedFieldNames);
13061
13255
  }
@@ -13176,6 +13370,7 @@ var Noydb = class {
13176
13370
  if (this.options.encrypt !== false && !this.policyCache.has(name)) {
13177
13371
  await this.bootstrapPolicy(name);
13178
13372
  }
13373
+ const mergeAuthority = buildMergeAuthority(keyring);
13179
13374
  let syncEngine;
13180
13375
  const targets = normalizeSyncTargets(this.options.sync);
13181
13376
  if (targets.length > 0) {
@@ -13190,11 +13385,12 @@ var Noydb = class {
13190
13385
  emitter: this.emitter,
13191
13386
  syncPolicy: effectivePolicy,
13192
13387
  role: primary.role,
13388
+ mergeAuthority,
13193
13389
  ...primary.label !== void 0 ? { label: primary.label } : {}
13194
13390
  });
13195
13391
  this.syncEngines.set(name, syncEngine);
13196
13392
  if (declaredPolicy) syncEngine.startScheduler();
13197
- for (const target of targets) {
13393
+ for (const [index, target] of targets.entries()) {
13198
13394
  if (target === primary) continue;
13199
13395
  const targetPolicy = target.policy ?? this.options.syncPolicy ?? INDEXED_STORE_POLICY;
13200
13396
  const engine = this.strategies.sync.buildSyncEngine({
@@ -13205,10 +13401,10 @@ var Noydb = class {
13205
13401
  emitter: this.emitter,
13206
13402
  syncPolicy: targetPolicy,
13207
13403
  role: target.role,
13404
+ mergeAuthority,
13208
13405
  ...target.label !== void 0 ? { label: target.label } : {}
13209
13406
  });
13210
- const key = `${name}::${target.label ?? target.role}`;
13211
- this.syncEngines.set(key, engine);
13407
+ this.syncEngines.set(`${name}::${index}`, engine);
13212
13408
  if (target.policy ?? this.options.syncPolicy) engine.startScheduler();
13213
13409
  }
13214
13410
  }
@@ -13429,8 +13625,8 @@ var Noydb = class {
13429
13625
  * collection) pair that was dropped. Re-run `grant()` for those pairs, or
13430
13626
  * they stay locked out.
13431
13627
  *
13432
- * Unlike `revoke({ rotateKeys: true })`, this call does not REMOVE any
13433
- * user from the vault — they keep membership and their other collections.
13628
+ * Unlike `revoke()`, this call does not REMOVE any user from the vault —
13629
+ * they keep membership and their other collections.
13434
13630
  * This is the "just rotate" path; "revoke and rotate" lives in `revoke()`.
13435
13631
  *
13436
13632
  * Exposed on Noydb (rather than only on the lower-level keyring
@@ -13441,6 +13637,27 @@ var Noydb = class {
13441
13637
  async rotate(vault, collections) {
13442
13638
  return this.strategies.team.rotate(this.team, vault, collections);
13443
13639
  }
13640
+ /**
13641
+ * Verify every `_keyring` file in the vault. Read-only (#1121).
13642
+ *
13643
+ * Names each failing file and why, so the bad one need not be found by trial.
13644
+ * Reports `checked` too: "nothing unverified" is equally true of a sweep that
13645
+ * examined nothing.
13646
+ */
13647
+ async verifyRoster(vault) {
13648
+ return this.strategies.team.verifyRoster(this.team, vault);
13649
+ }
13650
+ /**
13651
+ * Remove a `_keyring` file that cannot be authenticated, and re-key behind it
13652
+ * (#1121). Owner-only; refuses a file that verifies (use {@link revoke}).
13653
+ *
13654
+ * `revoke` consults the target's own `role`, so it cannot act on a file it
13655
+ * will not trust. This ignores every claim the file makes — which is exactly
13656
+ * why it is restricted to files that already fail authentication.
13657
+ */
13658
+ async quarantineKeyring(vault, userId, factors) {
13659
+ return this.strategies.team.quarantineKeyring(this.team, vault, userId, factors);
13660
+ }
13444
13661
  /** List all users with access to a vault. */
13445
13662
  async listUsers(vault) {
13446
13663
  return listUsers(this.options.store, vault);
@@ -13834,6 +14051,21 @@ var Noydb = class {
13834
14051
  }
13835
14052
  return engine.status();
13836
14053
  }
14054
+ /**
14055
+ * Per-target sync state for `vault` (#1034) — `syncStatus()` reads only the
14056
+ * primary engine, so it cannot express "the LAN store is behind, the cloud
14057
+ * is current". Registration order, primary first. See {@link SyncTargetStatus}.
14058
+ */
14059
+ syncTargetStatus(vault) {
14060
+ const targets = [];
14061
+ for (const [key, engine] of this.syncEngines) {
14062
+ if (key !== vault && !key.startsWith(`${vault}::`)) continue;
14063
+ const { dirty, lastPush, lastPull } = engine.status();
14064
+ const { label, role } = engine;
14065
+ targets.push({ label, role, dirty, lastPush, lastPull, caughtUp: dirty === 0 });
14066
+ }
14067
+ return targets;
14068
+ }
13837
14069
  /**
13838
14070
  * Enumerate the sync targets wired for `vault` (#948) — the primary engine
13839
14071
  * (keyed by vault name) plus any additional targets (keyed `vault::label`
@@ -13856,7 +14088,14 @@ var Noydb = class {
13856
14088
  getSyncEngine(vault) {
13857
14089
  const engine = this.syncEngines.get(vault);
13858
14090
  if (!engine) {
13859
- throw new ValidationError("No sync adapter configured. Pass a `sync` adapter to createNoydb().");
14091
+ if (this.syncEngines.size === 0) {
14092
+ throw new ValidationError(
14093
+ "No sync adapter configured. Pass a `sync` adapter to createNoydb() \u2014 a NoydbStore, a SyncTarget (`{ store, role }`), or an array of them \u2014 and `syncStrategy: withSync()` to enable the engine."
14094
+ );
14095
+ }
14096
+ throw new ValidationError(
14097
+ `No sync engine for vault "${String(vault)}". Sync is configured, but for [${[...this.syncEngines.keys()].map((k) => `"${k}"`).join(", ")}] \u2014 an engine is built per vault when it is opened, so open this vault first. Note the vault name is a REQUIRED argument: \`db.pull(vaultName)\`, not \`db.pull()\`.`
14098
+ );
13860
14099
  }
13861
14100
  return engine;
13862
14101
  }
@@ -14041,8 +14280,11 @@ var Noydb = class {
14041
14280
  * No-op when `vault` is not currently in cache (idempotent).
14042
14281
  */
14043
14282
  lockVault(vault) {
14044
- this.syncEngines.get(vault)?.stopAutoSync();
14045
- this.syncEngines.delete(vault);
14283
+ for (const [key, engine] of [...this.syncEngines]) {
14284
+ if (key !== vault && !key.startsWith(`${vault}::`)) continue;
14285
+ engine.stopAutoSync();
14286
+ this.syncEngines.delete(key);
14287
+ }
14046
14288
  this.policyEnforcers.get(vault)?.destroy();
14047
14289
  this.policyEnforcers.delete(vault);
14048
14290
  this.vaultCache.get(vault)?._stopFenceCoordination();
@@ -14379,7 +14621,7 @@ async function createNoydb(options) {
14379
14621
  if (!options.store) options = { ...options, store: memoryStore() };
14380
14622
  validateSecretModeOptions(options);
14381
14623
  if (!options.coordinationStrategy) options = { ...options, coordinationStrategy: await createDefaultCoordinationProvider(options.store) };
14382
- if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-RXUMEKT3.js")).createUserApi };
14624
+ if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-6X2VLZ7J.js")).createUserApi };
14383
14625
  if (!options.policyFactory) {
14384
14626
  const policyModule = await import("./policy/index.js");
14385
14627
  options = { ...options, policyFactory: policyModule.createNoydbPolicy, policyCheckGateFn: policyModule.checkGate };
@@ -14414,4 +14656,4 @@ export {
14414
14656
  Noydb,
14415
14657
  createNoydb
14416
14658
  };
14417
- //# sourceMappingURL=chunk-WK5XUYYF.js.map
14659
+ //# sourceMappingURL=chunk-JYPRZWCZ.js.map