@noy-db/hub 0.6.0-pre.2 → 0.6.0-pre.20

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 (490) hide show
  1. package/codemods/0.4.0-pre.json +699 -0
  2. package/codemods/0.6.0-pre.json +211 -0
  3. package/dist/api-Z5VHH24A.js +20 -0
  4. package/dist/attestation/index.js +19 -19
  5. package/dist/{backup-YYBE5RPC.js → backup-K62BFMYK.js} +36 -18
  6. package/dist/backup-K62BFMYK.js.map +1 -0
  7. package/dist/blobs/index.js +13 -13
  8. package/dist/broker/index.js +12 -12
  9. package/dist/cargo/index.js +33 -33
  10. package/dist/{chunk-FDX7OWWI.js → chunk-2E2MKBMI.js} +2 -2
  11. package/dist/{chunk-VOQW5LAM.js → chunk-2IK6AC6A.js} +102 -71
  12. package/dist/chunk-2IK6AC6A.js.map +1 -0
  13. package/dist/{chunk-EDXAQ6JI.js → chunk-32O2N2CH.js} +87 -34
  14. package/dist/chunk-32O2N2CH.js.map +1 -0
  15. package/dist/{chunk-W5W6KHN2.js → chunk-3Y4OFWQJ.js} +1 -1
  16. package/dist/chunk-3Y4OFWQJ.js.map +1 -0
  17. package/dist/{chunk-7G6VDWXB.js → chunk-437FDIHO.js} +3 -3
  18. package/dist/chunk-437FDIHO.js.map +1 -0
  19. package/dist/{chunk-3FSX6LDG.js → chunk-47ZFULEZ.js} +8 -3
  20. package/dist/{chunk-3FSX6LDG.js.map → chunk-47ZFULEZ.js.map} +1 -1
  21. package/dist/{chunk-ZJADGNYF.js → chunk-4AOERLTV.js} +1 -1
  22. package/dist/chunk-4AOERLTV.js.map +1 -0
  23. package/dist/{chunk-MWKDOHEF.js → chunk-4HVTRHSA.js} +17 -10
  24. package/dist/chunk-4HVTRHSA.js.map +1 -0
  25. package/dist/{chunk-V5KYPBUR.js → chunk-5BS6IQZZ.js} +11 -14
  26. package/dist/chunk-5BS6IQZZ.js.map +1 -0
  27. package/dist/{chunk-LWSJG3LI.js → chunk-5EJQNA26.js} +7 -3
  28. package/dist/chunk-5EJQNA26.js.map +1 -0
  29. package/dist/{chunk-7F4DBNSP.js → chunk-5J5TTSGW.js} +3 -3
  30. package/dist/{chunk-BTVYJWSN.js → chunk-5JT4Y5UE.js} +10 -10
  31. package/dist/{chunk-C2OOEM57.js → chunk-6S466CMQ.js} +92 -35
  32. package/dist/chunk-6S466CMQ.js.map +1 -0
  33. package/dist/{chunk-PY7CI6L5.js → chunk-6TXUVKPG.js} +516 -263
  34. package/dist/chunk-6TXUVKPG.js.map +1 -0
  35. package/dist/{chunk-7NXHMW6Y.js → chunk-7RCZ436O.js} +2 -2
  36. package/dist/{chunk-DG27IUVI.js → chunk-A3NTKHDB.js} +2 -2
  37. package/dist/{chunk-CCZJJ4I2.js → chunk-A4K5GLE6.js} +4 -4
  38. package/dist/{chunk-CEJWMBXO.js → chunk-APV42WPR.js} +2 -2
  39. package/dist/{chunk-4HDYQL3J.js → chunk-AQF7JSQR.js} +2 -2
  40. package/dist/{chunk-KUDZVJKQ.js → chunk-BP4I7IBK.js} +2 -2
  41. package/dist/{chunk-4UVDI4XE.js → chunk-BTNKPDZM.js} +4 -4
  42. package/dist/{chunk-HVQGCKY4.js → chunk-C7WJNVJG.js} +2 -2
  43. package/dist/{chunk-WYZ5MYUA.js → chunk-CV7WXCZD.js} +44 -42
  44. package/dist/chunk-CV7WXCZD.js.map +1 -0
  45. package/dist/{chunk-KCQX65FU.js → chunk-CVYXIN5B.js} +3 -3
  46. package/dist/{chunk-VN45YLWM.js → chunk-D5UDZANO.js} +255 -132
  47. package/dist/chunk-D5UDZANO.js.map +1 -0
  48. package/dist/{chunk-AR2JDFAE.js → chunk-DJ23QZIN.js} +2 -2
  49. package/dist/{chunk-PJNTR2NV.js → chunk-DKYEVHZH.js} +7 -10
  50. package/dist/chunk-DKYEVHZH.js.map +1 -0
  51. package/dist/{chunk-SZ2K3MHL.js → chunk-DYASJSKI.js} +8 -11
  52. package/dist/{chunk-SZ2K3MHL.js.map → chunk-DYASJSKI.js.map} +1 -1
  53. package/dist/{chunk-G5APARUV.js → chunk-E6VDPBE3.js} +13 -15
  54. package/dist/chunk-E6VDPBE3.js.map +1 -0
  55. package/dist/{chunk-A67356IR.js → chunk-EG6AQBYW.js} +33 -8
  56. package/dist/chunk-EG6AQBYW.js.map +1 -0
  57. package/dist/{chunk-PVU7LW5L.js → chunk-EJIVFOOQ.js} +6 -6
  58. package/dist/{chunk-VRA4Q7DA.js → chunk-F5AJZC3U.js} +35 -47
  59. package/dist/chunk-F5AJZC3U.js.map +1 -0
  60. package/dist/{chunk-VMCCGUQB.js → chunk-GDGTIWB4.js} +2 -2
  61. package/dist/{chunk-FUHKW252.js → chunk-GILI76SU.js} +2 -2
  62. package/dist/{chunk-35EBKWQU.js → chunk-GT72D4FO.js} +4 -4
  63. package/dist/{chunk-PRDRGL73.js → chunk-GYUCRDAU.js} +17 -14
  64. package/dist/chunk-GYUCRDAU.js.map +1 -0
  65. package/dist/{chunk-JRCYZEHU.js → chunk-HGJC7I5F.js} +2 -2
  66. package/dist/{chunk-TOAIYQJR.js → chunk-HJRTFXAA.js} +7 -10
  67. package/dist/chunk-HJRTFXAA.js.map +1 -0
  68. package/dist/chunk-HK67PX4J.js +27 -0
  69. package/dist/chunk-HK67PX4J.js.map +1 -0
  70. package/dist/{chunk-JXIDGFKS.js → chunk-HTHRCGWP.js} +4 -2
  71. package/dist/chunk-HTHRCGWP.js.map +1 -0
  72. package/dist/{chunk-AHLJSVRL.js → chunk-HTMQBBF3.js} +5 -7
  73. package/dist/chunk-HTMQBBF3.js.map +1 -0
  74. package/dist/{chunk-ZNACADFG.js → chunk-ICCRAPWD.js} +4 -4
  75. package/dist/chunk-ICCRAPWD.js.map +1 -0
  76. package/dist/{chunk-66W5OOCX.js → chunk-IOURTXTM.js} +52 -65
  77. package/dist/chunk-IOURTXTM.js.map +1 -0
  78. package/dist/{chunk-MZ5ZFO2D.js → chunk-IPDS2TYW.js} +84 -112
  79. package/dist/chunk-IPDS2TYW.js.map +1 -0
  80. package/dist/{chunk-UIBGXRDD.js → chunk-JHO6FGZX.js} +25 -31
  81. package/dist/chunk-JHO6FGZX.js.map +1 -0
  82. package/dist/{chunk-YAWK6AWF.js → chunk-JIF3IBRK.js} +2 -2
  83. package/dist/{chunk-HNHCQ556.js → chunk-KBOPY6W2.js} +2 -2
  84. package/dist/{chunk-UHXCLPGC.js → chunk-KDX6VEYV.js} +2 -2
  85. package/dist/chunk-KDX6VEYV.js.map +1 -0
  86. package/dist/{chunk-W3TVWF6N.js → chunk-KM6YR5XF.js} +2 -2
  87. package/dist/{chunk-3737A6EA.js → chunk-KUXTWVAR.js} +75 -18
  88. package/dist/chunk-KUXTWVAR.js.map +1 -0
  89. package/dist/chunk-L2XQ776M.js +123 -0
  90. package/dist/chunk-L2XQ776M.js.map +1 -0
  91. package/dist/{chunk-E6427JU2.js → chunk-L6FSZFG7.js} +18 -2
  92. package/dist/chunk-L6FSZFG7.js.map +1 -0
  93. package/dist/{chunk-5PR33AC4.js → chunk-M4IKEOJS.js} +20 -17
  94. package/dist/chunk-M4IKEOJS.js.map +1 -0
  95. package/dist/{chunk-6HFM7EIT.js → chunk-MNMYHZVU.js} +2 -2
  96. package/dist/{chunk-NIVEDYJZ.js → chunk-MNUTPZRQ.js} +31 -49
  97. package/dist/chunk-MNUTPZRQ.js.map +1 -0
  98. package/dist/{chunk-VV4NSB7P.js → chunk-MQXYR65M.js} +15 -24
  99. package/dist/chunk-MQXYR65M.js.map +1 -0
  100. package/dist/{chunk-QD724WDJ.js → chunk-N2HKBESK.js} +4 -4
  101. package/dist/{chunk-Z45YRGFO.js → chunk-N7YAQKAO.js} +2 -2
  102. package/dist/{chunk-DMQCLZ4Z.js → chunk-NH2MST6J.js} +2 -2
  103. package/dist/{chunk-TAGFGKHP.js → chunk-NRNTXBHT.js} +7 -10
  104. package/dist/chunk-NRNTXBHT.js.map +1 -0
  105. package/dist/{chunk-I6SDX7WX.js → chunk-NYSD43OE.js} +16 -22
  106. package/dist/chunk-NYSD43OE.js.map +1 -0
  107. package/dist/{chunk-I4F6PKUK.js → chunk-ODVIFBAQ.js} +16 -17
  108. package/dist/chunk-ODVIFBAQ.js.map +1 -0
  109. package/dist/{chunk-26JMGSSC.js → chunk-OIIAXFKM.js} +4 -4
  110. package/dist/chunk-OIIAXFKM.js.map +1 -0
  111. package/dist/{chunk-HXGUIPQB.js → chunk-OQLYMBJI.js} +3 -3
  112. package/dist/{chunk-RKKORO4M.js → chunk-OWGEHDT2.js} +10 -10
  113. package/dist/chunk-OWGEHDT2.js.map +1 -0
  114. package/dist/{chunk-HNGSV2YC.js → chunk-P7L3OQLL.js} +25 -10
  115. package/dist/chunk-P7L3OQLL.js.map +1 -0
  116. package/dist/{chunk-MSWYQLMQ.js → chunk-PG6PFMDC.js} +2 -2
  117. package/dist/{chunk-E7OBCBXS.js → chunk-PNAIDIP7.js} +13 -16
  118. package/dist/chunk-PNAIDIP7.js.map +1 -0
  119. package/dist/{chunk-GLKDWWNO.js → chunk-PZSS7MUM.js} +16 -14
  120. package/dist/chunk-PZSS7MUM.js.map +1 -0
  121. package/dist/{chunk-WKPJXWKR.js → chunk-QPIUFRUC.js} +3 -3
  122. package/dist/{chunk-JIUVJ4M7.js → chunk-REL4OLWW.js} +2 -2
  123. package/dist/{chunk-ERB6NDDW.js → chunk-RKDH6L53.js} +134 -33
  124. package/dist/chunk-RKDH6L53.js.map +1 -0
  125. package/dist/{chunk-VW6ZZGCG.js → chunk-RNSC2ARR.js} +3 -3
  126. package/dist/{chunk-WLYIROCJ.js → chunk-RORE2GX2.js} +2 -2
  127. package/dist/{chunk-TDJPS3T2.js → chunk-RQY5UWEL.js} +24 -19
  128. package/dist/chunk-RQY5UWEL.js.map +1 -0
  129. package/dist/{chunk-7TSYBD3E.js → chunk-RSFG7XHM.js} +2 -2
  130. package/dist/{chunk-FAXZQ5UF.js → chunk-S55DBWRC.js} +2 -2
  131. package/dist/{chunk-WHJKIZS7.js → chunk-SA77BQ7F.js} +27 -149
  132. package/dist/chunk-SA77BQ7F.js.map +1 -0
  133. package/dist/{chunk-747LRSOO.js → chunk-SFD2LL7G.js} +2 -2
  134. package/dist/{chunk-P7OG2ETF.js → chunk-SG3OQCRG.js} +3 -3
  135. package/dist/{chunk-55LKVALY.js → chunk-T7IR4N2S.js} +1 -3
  136. package/dist/chunk-T7IR4N2S.js.map +1 -0
  137. package/dist/{chunk-EP7VPR7Y.js → chunk-TC6MBEGH.js} +11 -8
  138. package/dist/chunk-TC6MBEGH.js.map +1 -0
  139. package/dist/{chunk-HFQ6LGIO.js → chunk-TENLCGYD.js} +12 -10
  140. package/dist/{chunk-HFQ6LGIO.js.map → chunk-TENLCGYD.js.map} +1 -1
  141. package/dist/{chunk-WQDTCJ6W.js → chunk-VEX2BQVX.js} +3 -3
  142. package/dist/{chunk-7VHY5E3X.js → chunk-VH2W6BOG.js} +7 -7
  143. package/dist/chunk-VHVMJWM6.js +201 -0
  144. package/dist/chunk-VHVMJWM6.js.map +1 -0
  145. package/dist/{chunk-VCETL77O.js → chunk-VJ4B3ZXY.js} +27 -7
  146. package/dist/chunk-VJ4B3ZXY.js.map +1 -0
  147. package/dist/{chunk-OF3L2SD6.js → chunk-W6NFONOV.js} +2 -2
  148. package/dist/{chunk-NJDQ4YSV.js → chunk-WBNXZU42.js} +4 -4
  149. package/dist/{chunk-FNSMZQS4.js → chunk-WKD5ESK4.js} +2 -2
  150. package/dist/{chunk-NKH7GSIH.js → chunk-XGQGWZ6D.js} +4 -4
  151. package/dist/chunk-YOT7D63X.js +190 -0
  152. package/dist/chunk-YOT7D63X.js.map +1 -0
  153. package/dist/{chunk-4MC5JRRX.js → chunk-YVTADFTC.js} +14 -15
  154. package/dist/chunk-YVTADFTC.js.map +1 -0
  155. package/dist/{chunk-GASWQ3XG.js → chunk-ZBDWKPBW.js} +15 -16
  156. package/dist/chunk-ZBDWKPBW.js.map +1 -0
  157. package/dist/{chunk-52QYGZHH.js → chunk-ZPMXYPBR.js} +2 -2
  158. package/dist/chunk-ZPMXYPBR.js.map +1 -0
  159. package/dist/chunk-ZVAFJQZB.js +66 -0
  160. package/dist/chunk-ZVAFJQZB.js.map +1 -0
  161. package/dist/{chunk-VJFMXYKP.js → chunk-ZWKF3CD3.js} +2 -2
  162. package/dist/{chunk-I4ZAO7F7.js → chunk-ZXW3X3DQ.js} +7 -11
  163. package/dist/chunk-ZXW3X3DQ.js.map +1 -0
  164. package/dist/classified/index.js +5 -5
  165. package/dist/{classified-marker-FTOX7Q5L.js → classified-marker-PMDG3O36.js} +3 -3
  166. package/dist/collection-facade-ZJK5EB33.js +45 -0
  167. package/dist/{computed-6G5M3UPH.js → computed-UHCBRILW.js} +3 -3
  168. package/dist/consent/index.js +10 -10
  169. package/dist/cover/index.js +10 -3
  170. package/dist/custody/index.js +11 -11
  171. package/dist/{dead-filter-ENRIOQIE.js → dead-filter-777VWDER.js} +2 -2
  172. package/dist/debug/index.js +1 -1
  173. package/dist/{delegation-SSEPLXXO.js → delegation-4R5DU23X.js} +24 -23
  174. package/dist/delegation-4R5DU23X.js.map +1 -0
  175. package/dist/derivations/index.js +12 -12
  176. package/dist/derive-3WAS2G5T.js +22 -0
  177. package/dist/directory/index.js +10 -10
  178. package/dist/{dispatch-BDVGYC6X.js → dispatch-3EN6YCCS.js} +18 -18
  179. package/dist/{dispatch-RE74SH6L.js → dispatch-ASL257KG.js} +5 -5
  180. package/dist/{enclave-52VUXNRL.js → enclave-ZJS5R5RH.js} +25 -9
  181. package/dist/executor-GPM6DNWV.js +9 -0
  182. package/dist/executor-LJSMZ4IB.js +9 -0
  183. package/dist/executor-SHUVRZUJ.js +29 -0
  184. package/dist/export-accessible-GNY6DC6U.js +23 -0
  185. package/dist/extract-partition-BG3AF4NZ.js +38 -0
  186. package/dist/{fanout-sidecar-DTBIDOWF.js → fanout-sidecar-TFPWDOME.js} +18 -27
  187. package/dist/fanout-sidecar-TFPWDOME.js.map +1 -0
  188. package/dist/find-KX6OKHDP.js +11 -0
  189. package/dist/forget/index.js +9 -9
  190. package/dist/guards/index.js +4 -4
  191. package/dist/history/index.js +23 -20
  192. package/dist/history/index.js.map +1 -1
  193. package/dist/i18n/index.js +14 -14
  194. package/dist/index.d.ts +32 -15
  195. package/dist/index.js +183 -191
  196. package/dist/index.js.map +1 -1
  197. package/dist/indexing/index.js +2 -2
  198. package/dist/introspection/index.js +11 -11
  199. package/dist/issue-PAUM7NCX.js +19 -0
  200. package/dist/kernel/enclave/crypto.d.ts +24 -4
  201. package/dist/kernel/enclave/index.d.ts +8 -2
  202. package/dist/kernel/enclave/record-aad.d.ts +131 -0
  203. package/dist/kernel/enclave/record-envelope.d.ts +76 -0
  204. package/dist/kernel/enclave/record-keys/envelope-body.d.ts +34 -2
  205. package/dist/kernel/enclave/record-keys/lifecycle.d.ts +22 -5
  206. package/dist/kernel/enclave/record-keys/record-codec.d.ts +47 -14
  207. package/dist/kernel/enclave/record-keys/rekey.d.ts +68 -0
  208. package/dist/kernel/enclave/record-keys/tombstone.d.ts +3 -2
  209. package/dist/kernel/errors.d.ts +23 -11
  210. package/dist/kernel/merge-authority.d.ts +25 -0
  211. package/dist/kernel/noydb.d.ts +9 -3
  212. package/dist/kernel/query/builder.d.ts +15 -2
  213. package/dist/kernel/query/join.d.ts +27 -0
  214. package/dist/kernel/sync-policy.d.ts +0 -2
  215. package/dist/kernel/tier-visibility.d.ts +15 -0
  216. package/dist/kernel/types.d.ts +125 -6
  217. package/dist/kernel/vault.d.ts +21 -17
  218. package/dist/kernel/via/index.d.ts +11 -2
  219. package/dist/{ledger-4WJL66BW.js → ledger-62CEPRPX.js} +11 -11
  220. package/dist/liberate-I6AOLWXW.js +24 -0
  221. package/dist/{link-set-N4ZPV6E6.js → link-set-ZRYNUHN3.js} +11 -11
  222. package/dist/{managed-secret-OTHS64IF.js → managed-secret-T2WB4O47.js} +11 -3
  223. package/dist/materialized-views/index.js +22 -21
  224. package/dist/money/index.js +12 -8
  225. package/dist/noydb-SS6EN7TK.js +84 -0
  226. package/dist/overlay-views/index.js +4 -4
  227. package/dist/periods/index.js +22 -12
  228. package/dist/pod/index.js +75 -86
  229. package/dist/pod-handle-UPLXOGIK.js +41 -0
  230. package/dist/pod-handle-UPLXOGIK.js.map +1 -0
  231. package/dist/policy/index.js +11 -4
  232. package/dist/port/to/index.d.ts +4 -4
  233. package/dist/port/to/locator.d.ts +54 -8
  234. package/dist/port/with/i18n-strategy.d.ts +4 -1
  235. package/dist/port/with/lookup-strategy.d.ts +4 -1
  236. package/dist/port/with/merge-authority.d.ts +52 -0
  237. package/dist/port/with/service-bus.d.ts +0 -4
  238. package/dist/port/with/strategies.d.ts +2 -0
  239. package/dist/portability/index.js +8 -8
  240. package/dist/{post-register-ZAG2CAIY.js → post-register-J4DEVNXK.js} +6 -6
  241. package/dist/query/index.js +3 -3
  242. package/dist/reduce/index.js +4 -4
  243. package/dist/register-UPD4GKBC.js +32 -0
  244. package/dist/registry-7KX2HWFS.js +18 -0
  245. package/dist/registry-PKYYEHEW.js +9 -0
  246. package/dist/registry-XHCYMD34.js +19 -0
  247. package/dist/registry-XIRTZHPC.js +9 -0
  248. package/dist/request-withdrawal-XZSESWZV.js +31 -0
  249. package/dist/{reveal-CMOJY4VO.js → reveal-525XWQU2.js} +6 -6
  250. package/dist/revoke-QI7YHQ2B.js +24 -0
  251. package/dist/satellites/index.js +1 -1
  252. package/dist/schema-update/index.js +2 -2
  253. package/dist/sealed-record/index.js +20 -13
  254. package/dist/sealed-record/index.js.map +1 -1
  255. package/dist/search/index.js +4 -4
  256. package/dist/{seed-UK4QRIUN.js → seed-SGIF3EN4.js} +19 -22
  257. package/dist/seed-SGIF3EN4.js.map +1 -0
  258. package/dist/sequence/index.js +9 -9
  259. package/dist/session/index.js +10 -10
  260. package/dist/shadow/index.js +2 -2
  261. package/dist/share-link/index.js +1 -1
  262. package/dist/signer-BZWDPGGN.js +25 -0
  263. package/dist/snapshots/index.js +10 -10
  264. package/dist/snapshots/index.js.map +1 -1
  265. package/dist/{stale-ZWXSOWJI.js → stale-PQYPVCER.js} +10 -10
  266. package/dist/storage-MJHKNQRO.js +23 -0
  267. package/dist/{store-coordination-provider-PB6QZ57W.js → store-coordination-provider-TFHZLKHG.js} +18 -12
  268. package/dist/store-coordination-provider-TFHZLKHG.js.map +1 -0
  269. package/dist/sync/index.js +11 -11
  270. package/dist/team/index.js +15 -14
  271. package/dist/tiers/index.js +11 -10
  272. package/dist/to/index.js +17 -9
  273. package/dist/to/index.js.map +1 -1
  274. package/dist/transactions/index.js +4 -4
  275. package/dist/{ulid-PTAIMDG4.js → ulid-VQW6ERQN.js} +2 -2
  276. package/dist/util/index.js +1 -1
  277. package/dist/vault-head/index.js +115 -0
  278. package/dist/vault-head/index.js.map +1 -0
  279. package/dist/{verify-RO5RTZOJ.js → verify-J6DEOXP3.js} +5 -5
  280. package/dist/via/lookup/handle.d.ts +4 -1
  281. package/dist/via/money/exact.d.ts +44 -0
  282. package/dist/via/money/index.d.ts +2 -0
  283. package/dist/via/money/normalize.d.ts +20 -0
  284. package/dist/walk-BX4NSB5L.js +21 -0
  285. package/dist/with-audit/guards/immutable-guard.d.ts +14 -0
  286. package/dist/with-audit/periods/active.d.ts +28 -1
  287. package/dist/with-audit/periods/index.d.ts +4 -2
  288. package/dist/with-audit/periods/periods.d.ts +161 -6
  289. package/dist/with-audit/periods/strategy.d.ts +14 -5
  290. package/dist/with-audit/periods/vault-facade.d.ts +89 -10
  291. package/dist/with-audit/periods/window.d.ts +10 -0
  292. package/dist/with-audit/sealed-record/index.d.ts +13 -0
  293. package/dist/with-audit/tiers/index.d.ts +17 -2
  294. package/dist/with-cargo/adopt-partition.d.ts +1 -1
  295. package/dist/with-cargo/extract-partition.d.ts +1 -1
  296. package/dist/with-cargo/index.d.ts +2 -2
  297. package/dist/with-commit/history/history.d.ts +26 -0
  298. package/dist/with-commit/history/index.d.ts +2 -1
  299. package/dist/with-commit/history/ledger/store.d.ts +7 -1
  300. package/dist/with-commit/history/strategy.d.ts +11 -1
  301. package/dist/with-commit/numbering/index.d.ts +0 -5
  302. package/dist/with-commit/vault-head/active.d.ts +2 -0
  303. package/dist/with-commit/vault-head/head.d.ts +28 -0
  304. package/dist/with-commit/vault-head/index.d.ts +10 -0
  305. package/dist/with-commit/vault-head/strategy.d.ts +127 -0
  306. package/dist/with-commit/vault-head/verify.d.ts +90 -0
  307. package/dist/with-formula/materialized-views/types.d.ts +52 -0
  308. package/dist/with-party/directory/cover/storage.d.ts +0 -8
  309. package/dist/with-party/directory/storage.d.ts +0 -11
  310. package/dist/with-party/directory/visibility.d.ts +0 -21
  311. package/dist/with-party/policy/storage.d.ts +0 -10
  312. package/dist/with-party/team/index.d.ts +1 -1
  313. package/dist/with-party/team/keyring.d.ts +17 -3
  314. package/dist/with-party/team/tiers.d.ts +2 -1
  315. package/dist/with-pod/format.d.ts +10 -12
  316. package/dist/with-pod/index.d.ts +10 -10
  317. package/dist/with-pod/open.d.ts +2 -2
  318. package/dist/with-pod/pod-handle.d.ts +19 -0
  319. package/dist/with-pod/pod-store.d.ts +0 -8
  320. package/dist/with-pod/{bundle.d.ts → pod.d.ts} +26 -19
  321. package/dist/with-pod/ulid.d.ts +1 -1
  322. package/dist/with-shape/introspection/index.d.ts +1 -0
  323. package/dist/with-sync/engine.d.ts +54 -5
  324. package/dist/with-sync/strategy.d.ts +3 -0
  325. package/dist/withdraw-accessible-K4CPMH4C.js +28 -0
  326. package/package.json +12 -5
  327. package/dist/api-WVY3H3YH.js +0 -20
  328. package/dist/backup-YYBE5RPC.js.map +0 -1
  329. package/dist/bundle-handle-JEUWU2SJ.js +0 -36
  330. package/dist/bundle-handle-JEUWU2SJ.js.map +0 -1
  331. package/dist/chunk-26JMGSSC.js.map +0 -1
  332. package/dist/chunk-3737A6EA.js.map +0 -1
  333. package/dist/chunk-4MC5JRRX.js.map +0 -1
  334. package/dist/chunk-52QYGZHH.js.map +0 -1
  335. package/dist/chunk-55LKVALY.js.map +0 -1
  336. package/dist/chunk-5PR33AC4.js.map +0 -1
  337. package/dist/chunk-66W5OOCX.js.map +0 -1
  338. package/dist/chunk-7G6VDWXB.js.map +0 -1
  339. package/dist/chunk-A67356IR.js.map +0 -1
  340. package/dist/chunk-AFHQATY4.js +0 -47
  341. package/dist/chunk-AFHQATY4.js.map +0 -1
  342. package/dist/chunk-AHLJSVRL.js.map +0 -1
  343. package/dist/chunk-C2OOEM57.js.map +0 -1
  344. package/dist/chunk-DIMKRG2E.js +0 -131
  345. package/dist/chunk-DIMKRG2E.js.map +0 -1
  346. package/dist/chunk-E6427JU2.js.map +0 -1
  347. package/dist/chunk-E7OBCBXS.js.map +0 -1
  348. package/dist/chunk-EDXAQ6JI.js.map +0 -1
  349. package/dist/chunk-EP7VPR7Y.js.map +0 -1
  350. package/dist/chunk-ERB6NDDW.js.map +0 -1
  351. package/dist/chunk-G5APARUV.js.map +0 -1
  352. package/dist/chunk-GASWQ3XG.js.map +0 -1
  353. package/dist/chunk-GLKDWWNO.js.map +0 -1
  354. package/dist/chunk-HNGSV2YC.js.map +0 -1
  355. package/dist/chunk-I4F6PKUK.js.map +0 -1
  356. package/dist/chunk-I4ZAO7F7.js.map +0 -1
  357. package/dist/chunk-I6SDX7WX.js.map +0 -1
  358. package/dist/chunk-JXIDGFKS.js.map +0 -1
  359. package/dist/chunk-LWSJG3LI.js.map +0 -1
  360. package/dist/chunk-MWKDOHEF.js.map +0 -1
  361. package/dist/chunk-MZ5ZFO2D.js.map +0 -1
  362. package/dist/chunk-NIVEDYJZ.js.map +0 -1
  363. package/dist/chunk-NWCGDAV6.js +0 -45
  364. package/dist/chunk-NWCGDAV6.js.map +0 -1
  365. package/dist/chunk-PJNTR2NV.js.map +0 -1
  366. package/dist/chunk-PRDRGL73.js.map +0 -1
  367. package/dist/chunk-PY7CI6L5.js.map +0 -1
  368. package/dist/chunk-RKKORO4M.js.map +0 -1
  369. package/dist/chunk-TAGFGKHP.js.map +0 -1
  370. package/dist/chunk-TDJPS3T2.js.map +0 -1
  371. package/dist/chunk-TOAIYQJR.js.map +0 -1
  372. package/dist/chunk-UHXCLPGC.js.map +0 -1
  373. package/dist/chunk-UIBGXRDD.js.map +0 -1
  374. package/dist/chunk-V5KYPBUR.js.map +0 -1
  375. package/dist/chunk-VCETL77O.js.map +0 -1
  376. package/dist/chunk-VN45YLWM.js.map +0 -1
  377. package/dist/chunk-VOQW5LAM.js.map +0 -1
  378. package/dist/chunk-VRA4Q7DA.js.map +0 -1
  379. package/dist/chunk-VV4NSB7P.js.map +0 -1
  380. package/dist/chunk-W5W6KHN2.js.map +0 -1
  381. package/dist/chunk-WHJKIZS7.js.map +0 -1
  382. package/dist/chunk-WYZ5MYUA.js.map +0 -1
  383. package/dist/chunk-ZJADGNYF.js.map +0 -1
  384. package/dist/chunk-ZNACADFG.js.map +0 -1
  385. package/dist/collection-facade-QN5ULWYC.js +0 -45
  386. package/dist/delegation-SSEPLXXO.js.map +0 -1
  387. package/dist/derive-6V3PIZF7.js +0 -22
  388. package/dist/executor-CYJQLKKI.js +0 -9
  389. package/dist/executor-FHHLXO4Y.js +0 -28
  390. package/dist/executor-S4QIKEHW.js +0 -9
  391. package/dist/export-accessible-PE5AYKZR.js +0 -23
  392. package/dist/extract-partition-X2L26O6A.js +0 -38
  393. package/dist/fanout-sidecar-DTBIDOWF.js.map +0 -1
  394. package/dist/find-RBBYKXI7.js +0 -11
  395. package/dist/issue-RNU55YOF.js +0 -19
  396. package/dist/liberate-PX4CAT5V.js +0 -24
  397. package/dist/noydb-YPSEGK32.js +0 -83
  398. package/dist/register-TMD6YRCX.js +0 -32
  399. package/dist/registry-CZVINVQH.js +0 -9
  400. package/dist/registry-FVLDWQKT.js +0 -18
  401. package/dist/registry-IKUR2MXD.js +0 -9
  402. package/dist/registry-JET4HBLY.js +0 -19
  403. package/dist/request-withdrawal-RH55LNZL.js +0 -31
  404. package/dist/revoke-R5TBYVA6.js +0 -24
  405. package/dist/seed-UK4QRIUN.js.map +0 -1
  406. package/dist/signer-AGALOXOO.js +0 -25
  407. package/dist/storage-N7LB275C.js +0 -23
  408. package/dist/store-coordination-provider-PB6QZ57W.js.map +0 -1
  409. package/dist/walk-OCUHCYJ6.js +0 -21
  410. package/dist/with-pod/bundle-handle.d.ts +0 -9
  411. package/dist/withdraw-accessible-QQNWM5BO.js +0 -28
  412. /package/dist/{api-WVY3H3YH.js.map → api-Z5VHH24A.js.map} +0 -0
  413. /package/dist/{chunk-FDX7OWWI.js.map → chunk-2E2MKBMI.js.map} +0 -0
  414. /package/dist/{chunk-7F4DBNSP.js.map → chunk-5J5TTSGW.js.map} +0 -0
  415. /package/dist/{chunk-BTVYJWSN.js.map → chunk-5JT4Y5UE.js.map} +0 -0
  416. /package/dist/{chunk-7NXHMW6Y.js.map → chunk-7RCZ436O.js.map} +0 -0
  417. /package/dist/{chunk-DG27IUVI.js.map → chunk-A3NTKHDB.js.map} +0 -0
  418. /package/dist/{chunk-CCZJJ4I2.js.map → chunk-A4K5GLE6.js.map} +0 -0
  419. /package/dist/{chunk-CEJWMBXO.js.map → chunk-APV42WPR.js.map} +0 -0
  420. /package/dist/{chunk-4HDYQL3J.js.map → chunk-AQF7JSQR.js.map} +0 -0
  421. /package/dist/{chunk-KUDZVJKQ.js.map → chunk-BP4I7IBK.js.map} +0 -0
  422. /package/dist/{chunk-4UVDI4XE.js.map → chunk-BTNKPDZM.js.map} +0 -0
  423. /package/dist/{chunk-HVQGCKY4.js.map → chunk-C7WJNVJG.js.map} +0 -0
  424. /package/dist/{chunk-KCQX65FU.js.map → chunk-CVYXIN5B.js.map} +0 -0
  425. /package/dist/{chunk-AR2JDFAE.js.map → chunk-DJ23QZIN.js.map} +0 -0
  426. /package/dist/{chunk-PVU7LW5L.js.map → chunk-EJIVFOOQ.js.map} +0 -0
  427. /package/dist/{chunk-VMCCGUQB.js.map → chunk-GDGTIWB4.js.map} +0 -0
  428. /package/dist/{chunk-FUHKW252.js.map → chunk-GILI76SU.js.map} +0 -0
  429. /package/dist/{chunk-35EBKWQU.js.map → chunk-GT72D4FO.js.map} +0 -0
  430. /package/dist/{chunk-JRCYZEHU.js.map → chunk-HGJC7I5F.js.map} +0 -0
  431. /package/dist/{chunk-YAWK6AWF.js.map → chunk-JIF3IBRK.js.map} +0 -0
  432. /package/dist/{chunk-HNHCQ556.js.map → chunk-KBOPY6W2.js.map} +0 -0
  433. /package/dist/{chunk-W3TVWF6N.js.map → chunk-KM6YR5XF.js.map} +0 -0
  434. /package/dist/{chunk-6HFM7EIT.js.map → chunk-MNMYHZVU.js.map} +0 -0
  435. /package/dist/{chunk-QD724WDJ.js.map → chunk-N2HKBESK.js.map} +0 -0
  436. /package/dist/{chunk-Z45YRGFO.js.map → chunk-N7YAQKAO.js.map} +0 -0
  437. /package/dist/{chunk-DMQCLZ4Z.js.map → chunk-NH2MST6J.js.map} +0 -0
  438. /package/dist/{chunk-HXGUIPQB.js.map → chunk-OQLYMBJI.js.map} +0 -0
  439. /package/dist/{chunk-MSWYQLMQ.js.map → chunk-PG6PFMDC.js.map} +0 -0
  440. /package/dist/{chunk-WKPJXWKR.js.map → chunk-QPIUFRUC.js.map} +0 -0
  441. /package/dist/{chunk-JIUVJ4M7.js.map → chunk-REL4OLWW.js.map} +0 -0
  442. /package/dist/{chunk-VW6ZZGCG.js.map → chunk-RNSC2ARR.js.map} +0 -0
  443. /package/dist/{chunk-WLYIROCJ.js.map → chunk-RORE2GX2.js.map} +0 -0
  444. /package/dist/{chunk-7TSYBD3E.js.map → chunk-RSFG7XHM.js.map} +0 -0
  445. /package/dist/{chunk-FAXZQ5UF.js.map → chunk-S55DBWRC.js.map} +0 -0
  446. /package/dist/{chunk-747LRSOO.js.map → chunk-SFD2LL7G.js.map} +0 -0
  447. /package/dist/{chunk-P7OG2ETF.js.map → chunk-SG3OQCRG.js.map} +0 -0
  448. /package/dist/{chunk-WQDTCJ6W.js.map → chunk-VEX2BQVX.js.map} +0 -0
  449. /package/dist/{chunk-7VHY5E3X.js.map → chunk-VH2W6BOG.js.map} +0 -0
  450. /package/dist/{chunk-OF3L2SD6.js.map → chunk-W6NFONOV.js.map} +0 -0
  451. /package/dist/{chunk-NJDQ4YSV.js.map → chunk-WBNXZU42.js.map} +0 -0
  452. /package/dist/{chunk-FNSMZQS4.js.map → chunk-WKD5ESK4.js.map} +0 -0
  453. /package/dist/{chunk-NKH7GSIH.js.map → chunk-XGQGWZ6D.js.map} +0 -0
  454. /package/dist/{chunk-VJFMXYKP.js.map → chunk-ZWKF3CD3.js.map} +0 -0
  455. /package/dist/{classified-marker-FTOX7Q5L.js.map → classified-marker-PMDG3O36.js.map} +0 -0
  456. /package/dist/{collection-facade-QN5ULWYC.js.map → collection-facade-ZJK5EB33.js.map} +0 -0
  457. /package/dist/{computed-6G5M3UPH.js.map → computed-UHCBRILW.js.map} +0 -0
  458. /package/dist/{dead-filter-ENRIOQIE.js.map → dead-filter-777VWDER.js.map} +0 -0
  459. /package/dist/{derive-6V3PIZF7.js.map → derive-3WAS2G5T.js.map} +0 -0
  460. /package/dist/{dispatch-BDVGYC6X.js.map → dispatch-3EN6YCCS.js.map} +0 -0
  461. /package/dist/{dispatch-RE74SH6L.js.map → dispatch-ASL257KG.js.map} +0 -0
  462. /package/dist/{enclave-52VUXNRL.js.map → enclave-ZJS5R5RH.js.map} +0 -0
  463. /package/dist/{executor-CYJQLKKI.js.map → executor-GPM6DNWV.js.map} +0 -0
  464. /package/dist/{executor-FHHLXO4Y.js.map → executor-LJSMZ4IB.js.map} +0 -0
  465. /package/dist/{executor-S4QIKEHW.js.map → executor-SHUVRZUJ.js.map} +0 -0
  466. /package/dist/{export-accessible-PE5AYKZR.js.map → export-accessible-GNY6DC6U.js.map} +0 -0
  467. /package/dist/{extract-partition-X2L26O6A.js.map → extract-partition-BG3AF4NZ.js.map} +0 -0
  468. /package/dist/{find-RBBYKXI7.js.map → find-KX6OKHDP.js.map} +0 -0
  469. /package/dist/{issue-RNU55YOF.js.map → issue-PAUM7NCX.js.map} +0 -0
  470. /package/dist/{ledger-4WJL66BW.js.map → ledger-62CEPRPX.js.map} +0 -0
  471. /package/dist/{liberate-PX4CAT5V.js.map → liberate-I6AOLWXW.js.map} +0 -0
  472. /package/dist/{link-set-N4ZPV6E6.js.map → link-set-ZRYNUHN3.js.map} +0 -0
  473. /package/dist/{managed-secret-OTHS64IF.js.map → managed-secret-T2WB4O47.js.map} +0 -0
  474. /package/dist/{noydb-YPSEGK32.js.map → noydb-SS6EN7TK.js.map} +0 -0
  475. /package/dist/{post-register-ZAG2CAIY.js.map → post-register-J4DEVNXK.js.map} +0 -0
  476. /package/dist/{register-TMD6YRCX.js.map → register-UPD4GKBC.js.map} +0 -0
  477. /package/dist/{registry-CZVINVQH.js.map → registry-7KX2HWFS.js.map} +0 -0
  478. /package/dist/{registry-FVLDWQKT.js.map → registry-PKYYEHEW.js.map} +0 -0
  479. /package/dist/{registry-IKUR2MXD.js.map → registry-XHCYMD34.js.map} +0 -0
  480. /package/dist/{registry-JET4HBLY.js.map → registry-XIRTZHPC.js.map} +0 -0
  481. /package/dist/{request-withdrawal-RH55LNZL.js.map → request-withdrawal-XZSESWZV.js.map} +0 -0
  482. /package/dist/{reveal-CMOJY4VO.js.map → reveal-525XWQU2.js.map} +0 -0
  483. /package/dist/{revoke-R5TBYVA6.js.map → revoke-QI7YHQ2B.js.map} +0 -0
  484. /package/dist/{signer-AGALOXOO.js.map → signer-BZWDPGGN.js.map} +0 -0
  485. /package/dist/{stale-ZWXSOWJI.js.map → stale-PQYPVCER.js.map} +0 -0
  486. /package/dist/{storage-N7LB275C.js.map → storage-MJHKNQRO.js.map} +0 -0
  487. /package/dist/{ulid-PTAIMDG4.js.map → ulid-VQW6ERQN.js.map} +0 -0
  488. /package/dist/{verify-RO5RTZOJ.js.map → verify-J6DEOXP3.js.map} +0 -0
  489. /package/dist/{walk-OCUHCYJ6.js.map → walk-BX4NSB5L.js.map} +0 -0
  490. /package/dist/{withdraw-accessible-QQNWM5BO.js.map → withdraw-accessible-K4CPMH4C.js.map} +0 -0
@@ -1,75 +1,84 @@
1
+ import {
2
+ LinkIntegrityError,
3
+ declareLink,
4
+ isLinkCollectionName,
5
+ linkCollectionName,
6
+ linkRowKey
7
+ } from "./chunk-KBOPY6W2.js";
1
8
  import {
2
9
  hashFields,
3
10
  validateSatelliteDeclaration
4
- } from "./chunk-HVQGCKY4.js";
11
+ } from "./chunk-C7WJNVJG.js";
5
12
  import {
6
13
  resolveStaleOnRead
7
- } from "./chunk-4HDYQL3J.js";
14
+ } from "./chunk-AQF7JSQR.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-OWGEHDT2.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-TOAIYQJR.js";
30
+ } from "./chunk-HJRTFXAA.js";
25
31
  import {
26
- VectorSet,
27
- buildPersistedIndexCallbacks,
28
- encodeVecId,
29
- syncTierSearch
30
- } from "./chunk-RKKORO4M.js";
32
+ fallbackDerivationName,
33
+ jsonSchemaToFields
34
+ } from "./chunk-KHKKD62N.js";
35
+ import {
36
+ derivePersistedSchema,
37
+ isZod4Schema
38
+ } from "./chunk-N7YAQKAO.js";
31
39
  import {
32
40
  SchemaUpdateGate
33
41
  } from "./chunk-6LJY7X5A.js";
42
+ import {
43
+ NO_ATTESTATION
44
+ } from "./chunk-ZWKF3CD3.js";
34
45
  import {
35
46
  NO_CLASSIFIED,
36
47
  guardClassifiedCompat,
37
48
  resolveClassifiedFields
38
- } from "./chunk-QD724WDJ.js";
49
+ } from "./chunk-N2HKBESK.js";
39
50
  import {
40
51
  NO_TIERS,
41
52
  classifySealedShred,
42
53
  syncDerivedOutputs
43
- } from "./chunk-C2OOEM57.js";
54
+ } from "./chunk-6S466CMQ.js";
44
55
  import {
45
56
  NO_PORTABILITY
46
- } from "./chunk-FUHKW252.js";
57
+ } from "./chunk-GILI76SU.js";
47
58
  import {
48
59
  NO_CARGO,
49
60
  runDrainBarrier
50
- } from "./chunk-DG27IUVI.js";
61
+ } from "./chunk-A3NTKHDB.js";
51
62
  import {
52
63
  saveSealedSecret
53
- } from "./chunk-TAGFGKHP.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-NRNTXBHT.js";
62
65
  import {
63
66
  loadPersistedSchema
64
- } from "./chunk-4MC5JRRX.js";
67
+ } from "./chunk-YVTADFTC.js";
68
+ import {
69
+ NO_SEQUENCE,
70
+ SEQUENCE_COLLECTION,
71
+ compileSequenceFormat,
72
+ resolveSequenceKey
73
+ } from "./chunk-PZSS7MUM.js";
65
74
  import {
66
75
  CustodyApi,
67
76
  NO_CUSTODY
68
- } from "./chunk-NKH7GSIH.js";
77
+ } from "./chunk-XGQGWZ6D.js";
69
78
  import {
70
79
  DEFAULT_POSTURE,
71
80
  ViaGraph
72
- } from "./chunk-7TSYBD3E.js";
81
+ } from "./chunk-RSFG7XHM.js";
73
82
  import {
74
83
  buildLookupAltIndex,
75
84
  buildLookupSnapshotRows,
@@ -93,31 +102,33 @@ import {
93
102
  selfWriteFieldEqual,
94
103
  touchFor,
95
104
  updateReferencingRecords
96
- } from "./chunk-ZNACADFG.js";
105
+ } from "./chunk-ICCRAPWD.js";
97
106
  import {
98
107
  OverlayedCollection
99
- } from "./chunk-OF3L2SD6.js";
108
+ } from "./chunk-W6NFONOV.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,
112
- purgeMarkersOn
113
- } from "./chunk-DIMKRG2E.js";
118
+ isEffectivelyReopened,
119
+ purgeMarkersOn,
120
+ resolvePeriodKey,
121
+ resolveReopenState,
122
+ samePartition
123
+ } from "./chunk-VHVMJWM6.js";
114
124
  import {
115
125
  PERIODS_COLLECTION,
116
126
  PERIOD_ARCHIVES_COLLECTION,
117
127
  PERIOD_FREEZES_COLLECTION,
128
+ PERIOD_REOPENS_COLLECTION,
118
129
  PERIOD_TARGET_PURGES_COLLECTION,
119
130
  periodExclusiveUpperBound
120
- } from "./chunk-JXIDGFKS.js";
131
+ } from "./chunk-HTHRCGWP.js";
121
132
  import {
122
133
  NO_SHADOW
123
134
  } from "./chunk-SMY5X46Z.js";
@@ -127,7 +138,7 @@ import {
127
138
  import {
128
139
  TxContext,
129
140
  bestEffortRevert
130
- } from "./chunk-35EBKWQU.js";
141
+ } from "./chunk-GT72D4FO.js";
131
142
  import {
132
143
  lazy
133
144
  } from "./chunk-5D2ALSM5.js";
@@ -135,29 +146,26 @@ import {
135
146
  InvertedIndex,
136
147
  MemoryIndexStore,
137
148
  NO_SEARCH
138
- } from "./chunk-BTVYJWSN.js";
149
+ } from "./chunk-5JT4Y5UE.js";
139
150
  import {
140
- NO_SEQUENCE,
141
- SEQUENCE_COLLECTION,
142
- compileSequenceFormat,
143
- resolveSequenceKey
144
- } from "./chunk-GLKDWWNO.js";
151
+ NO_SEALED_RECORD
152
+ } from "./chunk-S55DBWRC.js";
145
153
  import {
146
154
  Query,
147
155
  ScanBuilder
148
- } from "./chunk-3737A6EA.js";
156
+ } from "./chunk-KUXTWVAR.js";
149
157
  import {
150
158
  EXPORT_AUDIT_COLLECTION,
151
159
  NO_BLOBS,
152
160
  createExportBlobsHandle,
153
161
  runCompaction
154
- } from "./chunk-VV4NSB7P.js";
162
+ } from "./chunk-MQXYR65M.js";
155
163
  import {
156
164
  LazyQuery,
157
165
  NO_INDEXING,
158
166
  decodeIdxId,
159
167
  encodeIdxId
160
- } from "./chunk-JIUVJ4M7.js";
168
+ } from "./chunk-REL4OLWW.js";
161
169
  import {
162
170
  normalizeIndexDefs
163
171
  } from "./chunk-GQ3BX5EA.js";
@@ -180,7 +188,7 @@ import {
180
188
  } from "./chunk-PVEWA2DU.js";
181
189
  import {
182
190
  dictCollectionName
183
- } from "./chunk-PRDRGL73.js";
191
+ } from "./chunk-GYUCRDAU.js";
184
192
  import {
185
193
  NO_I18N,
186
194
  getAtPath,
@@ -188,11 +196,11 @@ import {
188
196
  isDictKeyDescriptor,
189
197
  isI18nTextDescriptor,
190
198
  isStaticDictDescriptor
191
- } from "./chunk-7G6VDWXB.js";
199
+ } from "./chunk-437FDIHO.js";
192
200
  import {
193
201
  isViaInstalled,
194
202
  viaBinder
195
- } from "./chunk-UHXCLPGC.js";
203
+ } from "./chunk-KDX6VEYV.js";
196
204
  import {
197
205
  NO_TEAM,
198
206
  describeAllUsersAuth,
@@ -215,7 +223,7 @@ import {
215
223
  saveShamirRecoveryEntries,
216
224
  updateAuthenticator,
217
225
  writeMagicLinkGrant
218
- } from "./chunk-VRA4Q7DA.js";
226
+ } from "./chunk-F5AJZC3U.js";
219
227
  import {
220
228
  assertKeyringOpenAllowed,
221
229
  buildRecipientKeyringFile,
@@ -230,32 +238,36 @@ import {
230
238
  listUsers,
231
239
  loadKeyring,
232
240
  updateKeyringIdentity
233
- } from "./chunk-ERB6NDDW.js";
241
+ } from "./chunk-RKDH6L53.js";
234
242
  import {
235
243
  persistDirectoryConfig,
236
244
  readDirectoryConfig
237
- } from "./chunk-UIBGXRDD.js";
245
+ } from "./chunk-JHO6FGZX.js";
238
246
  import {
239
247
  NO_BROKER,
240
248
  buildCredentialBrokerHandle
241
- } from "./chunk-W3TVWF6N.js";
249
+ } from "./chunk-KM6YR5XF.js";
242
250
  import {
243
251
  NO_SESSION
244
252
  } from "./chunk-VKQCVU2Z.js";
245
253
  import {
246
254
  generateULID
247
- } from "./chunk-ZJADGNYF.js";
255
+ } from "./chunk-4AOERLTV.js";
248
256
  import {
249
257
  NO_HISTORY
250
- } from "./chunk-AFHQATY4.js";
258
+ } from "./chunk-YOT7D63X.js";
259
+ import {
260
+ sha256Hex
261
+ } from "./chunk-RNSC2ARR.js";
251
262
  import {
252
263
  assertCutoverTierSafe,
253
264
  assertTierWritable,
265
+ dekKey,
254
266
  liveRecordIsElevated
255
- } from "./chunk-3FSX6LDG.js";
267
+ } from "./chunk-47ZFULEZ.js";
256
268
  import {
257
- sha256Hex
258
- } from "./chunk-VW6ZZGCG.js";
269
+ NO_VAULT_HEAD
270
+ } from "./chunk-HK67PX4J.js";
259
271
  import {
260
272
  NO_FORGET,
261
273
  addSubjectRef,
@@ -264,34 +276,36 @@ import {
264
276
  readDottedPath,
265
277
  rebuildSubjectIndex,
266
278
  removeSubjectRef
267
- } from "./chunk-HFQ6LGIO.js";
268
- import {
269
- NO_SEALED_RECORD
270
- } from "./chunk-FAXZQ5UF.js";
279
+ } from "./chunk-TENLCGYD.js";
271
280
  import {
272
281
  RecordCodec,
273
282
  SEALED_CEK_NS,
283
+ applyRewrappedBody,
284
+ buildRecordAad,
274
285
  findByDet,
275
286
  hasPerRecordKey,
287
+ hasSealedBody,
276
288
  makeReservedEnvelopes,
277
289
  openEnvelopeJson,
278
290
  queryByDet,
279
291
  resolveStableCek,
280
- validateSchemaInput
281
- } from "./chunk-VN45YLWM.js";
292
+ rewrapBodyToDek,
293
+ validateSchemaInput,
294
+ verifyRecordIdentity
295
+ } from "./chunk-D5UDZANO.js";
282
296
  import {
283
297
  buildDeleteMarker,
298
+ buildRecordEnvelope,
284
299
  buildTombstone,
285
300
  isDeleteMarker,
286
301
  isTombstone
287
- } from "./chunk-NWCGDAV6.js";
302
+ } from "./chunk-ZVAFJQZB.js";
288
303
  import {
289
304
  encrypt
290
- } from "./chunk-VCETL77O.js";
305
+ } from "./chunk-VJ4B3ZXY.js";
291
306
  import {
292
- NOYDB_FORMAT_VERSION,
293
307
  SealedHandle
294
- } from "./chunk-W5W6KHN2.js";
308
+ } from "./chunk-3Y4OFWQJ.js";
295
309
  import {
296
310
  AlreadyElevatedError,
297
311
  AttestationError,
@@ -334,7 +348,36 @@ import {
334
348
  UnsupportedTierCompositionError,
335
349
  ValidationError,
336
350
  isConflictError
337
- } from "./chunk-HNGSV2YC.js";
351
+ } from "./chunk-P7L3OQLL.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
+ }
338
381
 
339
382
  // src/with-commit/tx/strategy.ts
340
383
  var NOT_ENABLED = new Error(
@@ -371,6 +414,7 @@ var STRATEGY_DEFAULTS = {
371
414
  custody: NO_CUSTODY,
372
415
  forget: NO_FORGET,
373
416
  history: NO_HISTORY,
417
+ vaultHead: NO_VAULT_HEAD,
374
418
  i18n: NO_I18N,
375
419
  indexing: NO_INDEXING,
376
420
  lazy: IMPLICIT_LAZY,
@@ -464,7 +508,7 @@ function validateSecretModeOptions(options) {
464
508
  }
465
509
  async function resolveEffectiveSecret(options, store, vault) {
466
510
  if (options.secretMode === "managed") {
467
- const { resolveManagedSecret } = await import("./managed-secret-OTHS64IF.js");
511
+ const { resolveManagedSecret } = await import("./managed-secret-T2WB4O47.js");
468
512
  return resolveManagedSecret(store, vault, options.sealingKey);
469
513
  }
470
514
  return options.secret;
@@ -482,7 +526,7 @@ function ownerKeyringOptions(options, secret) {
482
526
 
483
527
  // src/port/by/default-provider.ts
484
528
  async function createDefaultCoordinationProvider(store) {
485
- const { StoreCoordinationProvider } = await import("./store-coordination-provider-PB6QZ57W.js");
529
+ const { StoreCoordinationProvider } = await import("./store-coordination-provider-TFHZLKHG.js");
486
530
  return new StoreCoordinationProvider(store);
487
531
  }
488
532
 
@@ -937,13 +981,13 @@ async function applyCutoverTransform(ctx) {
937
981
  for (const id of ids) {
938
982
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
939
983
  if (!env || isTombstone(env, ctx.storeCiphertext) || isDeleteMarker(env)) continue;
940
- const decoded = await ctx.codec.decryptRecord(env, { skipValidation: true, id });
984
+ const decoded = await ctx.codec.decryptRecord({ collection: ctx.name, id }, env, { skipValidation: true });
941
985
  if (decoded === null) continue;
942
986
  const record = decoded;
943
987
  const next = ctx.transform(record);
944
988
  const nextVersion = (env._v ?? 0) + 1;
945
989
  const cek = ctx.perRecordCek ? await ctx.resolveRecordCek(id) : void 0;
946
- 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);
947
991
  await ctx.adapter.put(ctx.vault, ctx.name, id, migEnvelope);
948
992
  await ctx.onRecordMutated(id, "put", "cutover");
949
993
  if (ctx.ledger) {
@@ -1049,7 +1093,7 @@ async function rebuildIndexes(ctx) {
1049
1093
  const envelope = await ctx.adapter.get(ctx.vault, ctx.name, recordId);
1050
1094
  if (!envelope) continue;
1051
1095
  if ((envelope._tier ?? 0) > 0) continue;
1052
- 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 });
1053
1097
  if (record === null) continue;
1054
1098
  await maintainPersistedIndexesOnPut(ctx, recordId, record, null, envelope._v);
1055
1099
  }
@@ -1083,7 +1127,7 @@ async function reconcileIndex(ctx, field, opts = {}) {
1083
1127
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
1084
1128
  if (!env) continue;
1085
1129
  try {
1086
- const sidecarJson = await ctx.codec.decryptJsonString(env);
1130
+ const sidecarJson = await ctx.codec.decryptJsonString({ collection: ctx.name, id }, env);
1087
1131
  if (sidecarJson === null) {
1088
1132
  sidecar.set(decoded.recordId, void 0);
1089
1133
  } else {
@@ -1103,7 +1147,7 @@ async function reconcileIndex(ctx, field, opts = {}) {
1103
1147
  const env = await ctx.adapter.get(ctx.vault, ctx.name, id);
1104
1148
  if (!env) continue;
1105
1149
  if ((env._tier ?? 0) > 0) continue;
1106
- const record = await ctx.codec.decryptRecord(env, { skipValidation: true, id });
1150
+ const record = await ctx.codec.decryptRecord({ collection: ctx.name, id }, env, { skipValidation: true });
1107
1151
  if (record === null) continue;
1108
1152
  const live = readPersistedValue(record, field);
1109
1153
  const stored = sidecar.get(id);
@@ -1164,7 +1208,7 @@ async function maintainPersistedIndexesOnPut(ctx, id, newRecord, previousRecord,
1164
1208
  recordId: id,
1165
1209
  writtenAt: (/* @__PURE__ */ new Date()).toISOString()
1166
1210
  });
1167
- const envelope = await ctx.codec.encryptJsonString(body, version);
1211
+ const envelope = await ctx.codec.encryptJsonString({ collection: ctx.name, id: idxId }, body, version);
1168
1212
  await ctx.adapter.put(ctx.vault, ctx.name, idxId, envelope);
1169
1213
  }
1170
1214
  } catch (cause) {
@@ -1233,7 +1277,7 @@ async function resolveTierSyncPrior(ctx, id, priorEnvelope) {
1233
1277
  const cached = ctx.cache.get(id)?.record;
1234
1278
  if (cached !== void 0) return cached;
1235
1279
  if (!ctx.lazy || !priorEnvelope || (priorEnvelope._tier ?? 0) > 0) return null;
1236
- return await ctx.codec.decryptRecord(priorEnvelope, { skipValidation: true, id });
1280
+ return await ctx.codec.decryptRecord({ collection: ctx.name, id }, priorEnvelope, { skipValidation: true });
1237
1281
  }
1238
1282
 
1239
1283
  // src/with-lookup/search/serialize.ts
@@ -2416,7 +2460,7 @@ function resolveCollectionConfig(opts) {
2416
2460
  }
2417
2461
 
2418
2462
  // src/with-formula/computed/lazy.ts
2419
- var loadComputed = lazy(() => import("./computed-6G5M3UPH.js"));
2463
+ var loadComputed = lazy(() => import("./computed-UHCBRILW.js"));
2420
2464
  async function loadEvalComputedFields() {
2421
2465
  return (await loadComputed()).evalComputedFields;
2422
2466
  }
@@ -2872,14 +2916,14 @@ var Collection = class {
2872
2916
  if (crdtMode === "yjs") {
2873
2917
  return local._v >= remote._v ? local : remote;
2874
2918
  }
2875
- const localJson = await this.codec.decryptJsonString(local, id);
2876
- const remoteJson = await this.codec.decryptJsonString(remote, id);
2919
+ const localJson = await this.codec.decryptJsonString({ collection: this.name, id }, local);
2920
+ const remoteJson = await this.codec.decryptJsonString({ collection: this.name, id }, remote);
2877
2921
  if (localJson === null) return local;
2878
2922
  if (remoteJson === null) return remote;
2879
2923
  const merged = this.strategies.crdt.mergeCrdtStates(JSON.parse(localJson), JSON.parse(remoteJson));
2880
2924
  const mergedVersion = Math.max(local._v, remote._v) + 1;
2881
2925
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
2882
- return this.codec.encryptJsonString(JSON.stringify(merged), mergedVersion, cek);
2926
+ return this.codec.encryptJsonString({ collection: this.name, id }, JSON.stringify(merged), mergedVersion, cek);
2883
2927
  };
2884
2928
  opts.onRegisterConflictResolver(this.name, crdtResolver);
2885
2929
  }
@@ -2920,14 +2964,14 @@ var Collection = class {
2920
2964
  } else {
2921
2965
  const mergeFn = policy;
2922
2966
  resolver = async (id, local, remote) => {
2923
- const localRecord = await this.codec.decryptRecord(local, { skipValidation: true, id });
2924
- const remoteRecord = await this.codec.decryptRecord(remote, { skipValidation: true, id });
2967
+ const localRecord = await this.codec.decryptRecord({ collection: this.name, id }, local, { skipValidation: true });
2968
+ const remoteRecord = await this.codec.decryptRecord({ collection: this.name, id }, remote, { skipValidation: true });
2925
2969
  if (localRecord === null) return local;
2926
2970
  if (remoteRecord === null) return remote;
2927
2971
  const merged = mergeFn(localRecord, remoteRecord);
2928
2972
  const mergedVersion = Math.max(local._v, remote._v) + 1;
2929
2973
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
2930
- return this.codec.encryptRecord(merged, mergedVersion, cek, void 0, void 0, void 0, id);
2974
+ return this.codec.encryptRecord({ collection: this.name, id }, merged, mergedVersion, cek);
2931
2975
  };
2932
2976
  }
2933
2977
  opts.onRegisterConflictResolver(collectionName, resolver);
@@ -3198,7 +3242,7 @@ var Collection = class {
3198
3242
  }
3199
3243
  await this.onAccess?.("find", "*");
3200
3244
  if (hits.length === 0) return [];
3201
- const { verifyDigestField } = await import("./verify-RO5RTZOJ.js");
3245
+ const { verifyDigestField } = await import("./verify-J6DEOXP3.js");
3202
3246
  const policy = {
3203
3247
  normalize: spec.verifyNormalize ?? "password",
3204
3248
  notLastN: spec.notLastN ?? 0,
@@ -3404,7 +3448,7 @@ var Collection = class {
3404
3448
  }
3405
3449
  }
3406
3450
  if (this.materializedViewSource !== void 0) {
3407
- const { resolveStaleMVOnRead } = await import("./stale-ZWXSOWJI.js");
3451
+ const { resolveStaleMVOnRead } = await import("./stale-PQYPVCER.js");
3408
3452
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
3409
3453
  }
3410
3454
  let record;
@@ -3416,7 +3460,7 @@ var Collection = class {
3416
3460
  const envelope = await this.adapter.get(this.vault, this.name, id);
3417
3461
  if (!envelope) return null;
3418
3462
  if (isTombstone(envelope, this.storeCiphertext) || isDeleteMarker(envelope) || (envelope._tier ?? 0) > 0) return null;
3419
- record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
3463
+ record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
3420
3464
  if (record === null) return null;
3421
3465
  this.lru.set(id, { record, version: envelope._v }, estimateRecordBytes(record));
3422
3466
  }
@@ -3443,7 +3487,7 @@ var Collection = class {
3443
3487
  }
3444
3488
  const envelope = await this.adapter.get(this.vault, this.name, id);
3445
3489
  if (!envelope || (envelope._tier ?? 0) > 0) return null;
3446
- const json = await this.codec.decryptJsonString(envelope);
3490
+ const json = await this.codec.decryptJsonString({ collection: this.name, id }, envelope);
3447
3491
  if (json === null) return null;
3448
3492
  return JSON.parse(json);
3449
3493
  }
@@ -3560,7 +3604,7 @@ var Collection = class {
3560
3604
  if (cached) return cached.record;
3561
3605
  const env = await this.adapter.get(this.vault, this.name, id);
3562
3606
  if (!env || (env._tier ?? 0) > 0) return void 0;
3563
- const rec = await this.codec.decryptRecord(env, { id });
3607
+ const rec = await this.codec.decryptRecord({ collection: this.name, id }, env, {});
3564
3608
  return rec === null ? void 0 : rec;
3565
3609
  }
3566
3610
  await this.ensureHydrated();
@@ -3608,7 +3652,7 @@ var Collection = class {
3608
3652
  if (cached2) return { record: cached2.record, version: cached2.version };
3609
3653
  const env = await this.adapter.get(this.vault, this.name, id);
3610
3654
  if (!env || (env._tier ?? 0) > 0) return { record: null, version: 0 };
3611
- return { record: await this.codec.decryptRecord(env, { skipValidation: true, id }) ?? null, version: env._v };
3655
+ return { record: await this.codec.decryptRecord({ collection: this.name, id }, env, { skipValidation: true }) ?? null, version: env._v };
3612
3656
  }
3613
3657
  await this.ensureHydrated();
3614
3658
  const cached = this.cache.get(id);
@@ -3630,7 +3674,7 @@ var Collection = class {
3630
3674
  if (this.sensitiveFields.size > 0 || this.via?.hasAtRestHooks === true) {
3631
3675
  const env = await this.adapter.get(this.vault, this.name, id);
3632
3676
  if (!env || isTombstone(env, this.storeCiphertext) || (env._tier ?? 0) > 0) return void 0;
3633
- const rec = await this.codec.decryptRecord(env, { skipValidation: true, id });
3677
+ const rec = await this.codec.decryptRecord({ collection: this.name, id }, env, { skipValidation: true });
3634
3678
  return rec === null ? void 0 : { record: rec, version: env._v };
3635
3679
  }
3636
3680
  const cached = this.cache.get(id);
@@ -3642,7 +3686,7 @@ var Collection = class {
3642
3686
  const env = await this.adapter.get(this.vault, this.name, id);
3643
3687
  if (!env) return { env: null, record: null, elided: false };
3644
3688
  if ((env._tier ?? 0) > 0) return { env, record: null, elided: false };
3645
- return { env, record: await this.codec.decryptRecord(env, { skipValidation: true, id }), elided: false };
3689
+ return { env, record: await this.codec.decryptRecord({ collection: this.name, id }, env, { skipValidation: true }), elided: false };
3646
3690
  }
3647
3691
  /**
3648
3692
  * Wraps {@link RecordCodec.toCacheRecord} with an additional strip for
@@ -3666,9 +3710,9 @@ var Collection = class {
3666
3710
  * payload that is not a CRDT state. The `lww-map` and `rga` branches each
3667
3711
  * carried a copy, byte-identical apart from the cast (#842).
3668
3712
  */
3669
- async #decodePriorCrdtState(envelope) {
3713
+ async #decodePriorCrdtState(id, envelope) {
3670
3714
  if (!envelope) return void 0;
3671
- const prevJson = await this.codec.decryptJsonString(envelope);
3715
+ const prevJson = await this.codec.decryptJsonString({ collection: this.name, id }, envelope);
3672
3716
  if (prevJson === null) return void 0;
3673
3717
  const prevParsed = JSON.parse(prevJson);
3674
3718
  if (prevParsed === null || typeof prevParsed !== "object" || !("_crdt" in prevParsed)) {
@@ -3705,7 +3749,8 @@ var Collection = class {
3705
3749
  this.vault,
3706
3750
  this.name,
3707
3751
  id,
3708
- await this.codec.encryptRecord(prior.record, prior.version, cek, void 0, void 0, vdigCtx, id)
3752
+ await this.codec.encryptRecord(this.strategies.history.historyIdentity(this.name, id, prior.version), prior.record, prior.version, cek, void 0, void 0, vdigCtx)
3753
+ // sealed against its _history STORAGE identity (#1041)
3709
3754
  );
3710
3755
  this.emitter.emit("history:save", { vault: this.vault, collection: this.name, id, version: prior.version });
3711
3756
  if (this.historyConfig.maxVersions) {
@@ -3815,20 +3860,20 @@ var Collection = class {
3815
3860
  const now = (/* @__PURE__ */ new Date()).toISOString();
3816
3861
  let crdtState;
3817
3862
  if (this.crdtMode === "lww-map") {
3818
- const existingState = await this.#decodePriorCrdtState(existingEnvelope);
3863
+ const existingState = await this.#decodePriorCrdtState(id, existingEnvelope);
3819
3864
  crdtState = this.strategies.crdt.buildLwwMapState(record, existingState, now);
3820
3865
  } else if (this.crdtMode === "rga") {
3821
- const existingState = await this.#decodePriorCrdtState(existingEnvelope);
3866
+ const existingState = await this.#decodePriorCrdtState(id, existingEnvelope);
3822
3867
  crdtState = this.strategies.crdt.buildRgaState(Array.isArray(record) ? record : [record], existingState, generateULID);
3823
3868
  } else {
3824
3869
  crdtState = { _crdt: "yjs", update: record };
3825
3870
  }
3826
3871
  const version = existingVersion + 1;
3827
3872
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
3828
- const envelope = await this.codec.encryptJsonString(JSON.stringify(crdtState), version, cek, options?.source, options?.sourceTs);
3873
+ const envelope = await this.codec.encryptJsonString({ collection: this.name, id }, JSON.stringify(crdtState), version, cek, options?.source, options?.sourceTs);
3829
3874
  await this.adapter.put(this.vault, this.name, id, envelope);
3830
3875
  const resolvedRecord = this.strategies.crdt.resolveCrdtSnapshot(crdtState);
3831
- const existingResolvedRecord = existingEnvelope ? await this.codec.decryptRecord(existingEnvelope, { skipValidation: true }) : null;
3876
+ const existingResolvedRecord = existingEnvelope ? await this.codec.decryptRecord({ collection: this.name, id }, existingEnvelope, { skipValidation: true }) : null;
3832
3877
  const existingResolved = existingResolvedRecord !== null ? { record: existingResolvedRecord, version: existingVersion } : void 0;
3833
3878
  if (existingResolved) {
3834
3879
  await this.#savePriorHistory(id, existingResolved, cek, this.vdigFields !== null ? { id, prev: existingEnvelope } : void 0);
@@ -3868,7 +3913,7 @@ var Collection = class {
3868
3913
  if (!existing) {
3869
3914
  priorRaw = await this.adapter.get(this.vault, this.name, id);
3870
3915
  if (priorRaw) {
3871
- const previousRecord = await this.codec.decryptRecord(priorRaw, { id });
3916
+ const previousRecord = await this.codec.decryptRecord({ collection: this.name, id }, priorRaw, {});
3872
3917
  if (previousRecord !== null) {
3873
3918
  existing = { record: previousRecord, version: priorRaw._v };
3874
3919
  }
@@ -3888,7 +3933,7 @@ var Collection = class {
3888
3933
  this.uniqueConstraints?.check(id, record);
3889
3934
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
3890
3935
  const vdigCtx = this.vdigFields !== null ? { id, prev: await this.adapter.get(this.vault, this.name, id) } : void 0;
3891
- const envelope = await this.codec.encryptRecord(record, version, cek, options?.source, options?.sourceTs, vdigCtx, id);
3936
+ const envelope = await this.codec.encryptRecord({ collection: this.name, id }, record, version, cek, options?.source, options?.sourceTs, vdigCtx);
3892
3937
  return { id, envelope, version, indexed: record, event: record, prior: existing, cek, vdigCtx, reason: options?.reason };
3893
3938
  }
3894
3939
  /**
@@ -3934,7 +3979,7 @@ var Collection = class {
3934
3979
  */
3935
3980
  async dispatchMaterializedViews(id, record, wave) {
3936
3981
  if (this.materializedViewSource === void 0) return;
3937
- const { dispatchMaterializedViews } = await import("./dispatch-RE74SH6L.js");
3982
+ const { dispatchMaterializedViews } = await import("./dispatch-ASL257KG.js");
3938
3983
  return dispatchMaterializedViews(this.#mvDispatchCtx(this.materializedViewSource), id, record, wave);
3939
3984
  }
3940
3985
  /**
@@ -3962,7 +4007,7 @@ var Collection = class {
3962
4007
  const cached = this.lru.get(id);
3963
4008
  const env = await this.adapter.get(this.vault, this.name, id);
3964
4009
  if (!env || isTombstone(env, this.storeCiphertext) || isDeleteMarker(env)) return null;
3965
- raw = await this.codec.decryptRecord(env, { id });
4010
+ raw = await this.codec.decryptRecord({ collection: this.name, id }, env, {});
3966
4011
  if (raw === null) return null;
3967
4012
  if (!cached) {
3968
4013
  this.lru.set(id, { record: await this.codec.toCacheRecord(raw, env, id), version: env._v }, estimateRecordBytes(raw));
@@ -3973,7 +4018,7 @@ var Collection = class {
3973
4018
  else {
3974
4019
  const env = await this.adapter.get(this.vault, this.name, id);
3975
4020
  if (!env || isTombstone(env, this.storeCiphertext) || isDeleteMarker(env)) return null;
3976
- raw = await this.codec.decryptRecord(env, { id });
4021
+ raw = await this.codec.decryptRecord({ collection: this.name, id }, env, {});
3977
4022
  if (raw === null) return null;
3978
4023
  this.lru.set(id, { record: raw, version: env._v }, estimateRecordBytes(raw));
3979
4024
  }
@@ -3990,7 +4035,7 @@ var Collection = class {
3990
4035
  async _getStoredRecordForDispatch(id) {
3991
4036
  const env = await this.adapter.get(this.vault, this.name, id);
3992
4037
  if (!env || isTombstone(env, this.storeCiphertext) || isDeleteMarker(env)) return null;
3993
- const record = await this.codec.decryptRecord(env, { id });
4038
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, env, {});
3994
4039
  return record === null ? null : { record, version: env._v };
3995
4040
  }
3996
4041
  /**
@@ -4107,7 +4152,7 @@ var Collection = class {
4107
4152
  * dispatch wave's per-target dedup; `undefined` on the local-write path (byte-identical). */
4108
4153
  async dispatchDerivations(id, record, version, wave) {
4109
4154
  if (this.derivationSource === void 0) return;
4110
- const { dispatchDerivations } = await import("./dispatch-BDVGYC6X.js");
4155
+ const { dispatchDerivations } = await import("./dispatch-3EN6YCCS.js");
4111
4156
  return dispatchDerivations({
4112
4157
  ...this.#derivationDeleteCtx(this.derivationSource),
4113
4158
  via: this.via,
@@ -4290,7 +4335,7 @@ var Collection = class {
4290
4335
  if (!existing && this.historyConfig.enabled !== false) {
4291
4336
  const previousEnvelope2 = await this.adapter.get(this.vault, this.name, id);
4292
4337
  if (previousEnvelope2) {
4293
- const previousRecord = await this.codec.decryptRecord(previousEnvelope2, { id });
4338
+ const previousRecord = await this.codec.decryptRecord({ collection: this.name, id }, previousEnvelope2, {});
4294
4339
  if (previousRecord !== null) {
4295
4340
  existing = { record: previousRecord, version: previousEnvelope2._v };
4296
4341
  }
@@ -4305,7 +4350,7 @@ var Collection = class {
4305
4350
  if (this.onDirty) {
4306
4351
  const live = previousEnvelope;
4307
4352
  if (!live || isTombstone(live, this.storeCiphertext) || isDeleteMarker(live)) return null;
4308
- marker = buildDeleteMarker(live._v + 1, this.keyring.userId);
4353
+ marker = buildDeleteMarker({ collection: this.name, id }, live._v + 1, this.keyring.userId);
4309
4354
  }
4310
4355
  const snapshots = existing !== void 0 && this.historyConfig.enabled !== false;
4311
4356
  const cek = snapshots && this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
@@ -4327,7 +4372,7 @@ var Collection = class {
4327
4372
  async _commitDelete(prepared, persist = true) {
4328
4373
  const { id, internal, existing, previousPayloadHash, marker, cek, vdigCtx } = prepared;
4329
4374
  if (existing && this.historyConfig.enabled !== false) {
4330
- 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));
4375
+ 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));
4331
4376
  }
4332
4377
  if (marker) {
4333
4378
  if (persist) await this.adapter.put(this.vault, this.name, id, marker);
@@ -4394,7 +4439,7 @@ var Collection = class {
4394
4439
  */
4395
4440
  async _decodeEnvelope(envelope, id) {
4396
4441
  try {
4397
- const rec = await this.codec.decryptRecord(envelope, { skipValidation: true, id });
4442
+ const rec = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { skipValidation: true });
4398
4443
  return rec === null ? null : rec;
4399
4444
  } catch {
4400
4445
  return null;
@@ -4403,7 +4448,7 @@ var Collection = class {
4403
4448
  async _writeTombstone(id, actor) {
4404
4449
  const live = await this.adapter.get(this.vault, this.name, id);
4405
4450
  if (!live || isTombstone(live, this.storeCiphertext) || isDeleteMarker(live)) return null;
4406
- await this.adapter.put(this.vault, this.name, id, buildTombstone(live._v, actor));
4451
+ await this.adapter.put(this.vault, this.name, id, buildTombstone({ collection: this.name, id }, live._v, actor));
4407
4452
  this.cache.delete(id);
4408
4453
  this.lru?.remove(id);
4409
4454
  this.cekCache?.remove(id);
@@ -4422,7 +4467,7 @@ var Collection = class {
4422
4467
  */
4423
4468
  async dispatchArrayDerivationsOnDelete(id, eraseRecordShapeToo = false) {
4424
4469
  if (this.derivationSource === void 0) return 0;
4425
- const { dispatchArrayDerivationsOnDelete } = await import("./dispatch-BDVGYC6X.js");
4470
+ const { dispatchArrayDerivationsOnDelete } = await import("./dispatch-3EN6YCCS.js");
4426
4471
  return dispatchArrayDerivationsOnDelete(this.#derivationDeleteCtx(this.derivationSource), id, eraseRecordShapeToo);
4427
4472
  }
4428
4473
  /**
@@ -4436,7 +4481,7 @@ var Collection = class {
4436
4481
  */
4437
4482
  async dispatchMaterializedViewsOnDelete(id) {
4438
4483
  if (this.materializedViewSource === void 0) return { deleted: 0, residueUndecodable: [], residueDeclined: [] };
4439
- const { dispatchMaterializedViewsOnDelete } = await import("./dispatch-RE74SH6L.js");
4484
+ const { dispatchMaterializedViewsOnDelete } = await import("./dispatch-ASL257KG.js");
4440
4485
  return dispatchMaterializedViewsOnDelete(this.#mvDispatchCtx(this.materializedViewSource), id);
4441
4486
  }
4442
4487
  /**
@@ -4456,7 +4501,7 @@ var Collection = class {
4456
4501
  );
4457
4502
  }
4458
4503
  if (this.materializedViewSource !== void 0) {
4459
- const { resolveStaleMVOnRead } = await import("./stale-ZWXSOWJI.js");
4504
+ const { resolveStaleMVOnRead } = await import("./stale-PQYPVCER.js");
4460
4505
  await resolveStaleMVOnRead(this.materializedViewSource, this.name, this.#dispatchCtx({ collection: this.name, id: "resolve-on-read" }));
4461
4506
  }
4462
4507
  await this.ensureHydrated();
@@ -4790,7 +4835,7 @@ var Collection = class {
4790
4835
  const entries = [];
4791
4836
  for (const env of envelopes) {
4792
4837
  if ((env._tier ?? 0) > 0) continue;
4793
- const record = await this.codec.decryptRecord(env, { skipValidation: true, id });
4838
+ const record = await this.codec.decryptRecord(this.strategies.history.historyIdentity(this.name, id, env._v), env, { skipValidation: true });
4794
4839
  if (record === null) continue;
4795
4840
  entries.push({
4796
4841
  version: env._v,
@@ -4819,7 +4864,7 @@ var Collection = class {
4819
4864
  version
4820
4865
  );
4821
4866
  if (!envelope || (envelope._tier ?? 0) > 0 || await liveRecordIsElevated(this.adapter, this.vault, this.name, id)) return null;
4822
- return this.codec.decryptRecord(envelope, { skipValidation: true, id });
4867
+ return this.codec.decryptRecord(this.strategies.history.historyIdentity(this.name, id, envelope._v), envelope, { skipValidation: true });
4823
4868
  }
4824
4869
  /** Revert a record to a past version. Creates a new version with the old content. */
4825
4870
  async revert(id, version) {
@@ -4925,7 +4970,7 @@ var Collection = class {
4925
4970
  const id = ids[i];
4926
4971
  const envelope = await this.adapter.get(this.vault, this.name, id);
4927
4972
  if (envelope && (envelope._tier ?? 0) === 0) {
4928
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
4973
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
4929
4974
  if (record === null) continue;
4930
4975
  items.push(record);
4931
4976
  if (!this.lazy && !this.cache.has(id)) {
@@ -5007,7 +5052,7 @@ var Collection = class {
5007
5052
  const out = [];
5008
5053
  for (const { id, envelope } of items) {
5009
5054
  if ((envelope._tier ?? 0) > 0) continue;
5010
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
5055
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
5011
5056
  if (record === null) continue;
5012
5057
  out.push({ id, record, version: envelope._v });
5013
5058
  }
@@ -5068,7 +5113,7 @@ var Collection = class {
5068
5113
  }
5069
5114
  return;
5070
5115
  }
5071
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
5116
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
5072
5117
  if (record === null) {
5073
5118
  this.cache.delete(id);
5074
5119
  if (previous) {
@@ -5164,7 +5209,7 @@ var Collection = class {
5164
5209
  for (const id of ids) {
5165
5210
  const envelope = await this.adapter.get(this.vault, this.name, id);
5166
5211
  if (envelope && !isTombstone(envelope, this.storeCiphertext) && !isDeleteMarker(envelope) && (envelope._tier ?? 0) === 0) {
5167
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
5212
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
5168
5213
  if (record === null) continue;
5169
5214
  this.cache.set(id, { record, version: envelope._v });
5170
5215
  } else if (envelope && isDeleteMarker(envelope)) {
@@ -5183,7 +5228,7 @@ var Collection = class {
5183
5228
  continue;
5184
5229
  }
5185
5230
  if (isTombstone(envelope, this.storeCiphertext) || (envelope._tier ?? 0) > 0) continue;
5186
- const record = await this.codec.decryptRecord(envelope, { id, sealedAsHandles: true });
5231
+ const record = await this.codec.decryptRecord({ collection: this.name, id }, envelope, { sealedAsHandles: true });
5187
5232
  if (record === null) continue;
5188
5233
  this.cache.set(id, { record, version: envelope._v });
5189
5234
  }
@@ -5317,7 +5362,7 @@ var Collection = class {
5317
5362
  for (const [id, entry] of this.cache) {
5318
5363
  const cek = this.perRecordCek ? await this.resolveRecordCek(id) : void 0;
5319
5364
  const prevForVdig = this.vdigFields !== null ? await this.adapter.get(this.vault, this.name, id) : null;
5320
- result[id] = await this.codec.encryptRecord(entry.record, entry.version, cek, void 0, void 0, this.vdigFields !== null ? { id, prev: prevForVdig } : void 0, id);
5365
+ 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);
5321
5366
  }
5322
5367
  return result;
5323
5368
  }
@@ -5432,7 +5477,7 @@ var Collection = class {
5432
5477
  const envelope = await this.adapter.get(this.vault, this.name, id);
5433
5478
  if (!envelope) continue;
5434
5479
  try {
5435
- const json = await this.codec.decryptJsonString(envelope);
5480
+ const json = await this.codec.decryptJsonString({ collection: this.name, id }, envelope);
5436
5481
  if (json === null) continue;
5437
5482
  const body = JSON.parse(json);
5438
5483
  if (typeof body.recordId !== "string") continue;
@@ -5566,14 +5611,14 @@ var Collection = class {
5566
5611
  /** C-A/R10: persist the classified marker once per classified handle (store I/O in config-drift.ts). */
5567
5612
  async _ensureClassifiedMarker() {
5568
5613
  if (this._markerPersisted || this.vdigFields === null) return;
5569
- const { persistClassifiedMarkerForFields } = await import("./classified-marker-FTOX7Q5L.js");
5614
+ const { persistClassifiedMarkerForFields } = await import("./classified-marker-PMDG3O36.js");
5570
5615
  await persistClassifiedMarkerForFields(this.adapter, this.vault, this.name, this.vdigFields, await this.getDEK(this.name));
5571
5616
  this._markerPersisted = true;
5572
5617
  }
5573
5618
  /** C-A/R10 drift signal — the marker's declared digest-only set, memoized to one store read per handle (see config-drift.ts). */
5574
5619
  async _classifiedMarkerDigestOnly() {
5575
5620
  if (this._markerDigestOnlyCache !== void 0) return this._markerDigestOnlyCache;
5576
- const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-FTOX7Q5L.js");
5621
+ const { readClassifiedMarkerDigestOnly } = await import("./classified-marker-PMDG3O36.js");
5577
5622
  this._markerDigestOnlyCache = await readClassifiedMarkerDigestOnly(this.adapter, this.vault, this.name, await this.getDEK(this.name));
5578
5623
  return this._markerDigestOnlyCache;
5579
5624
  }
@@ -5725,8 +5770,9 @@ var Collection = class {
5725
5770
  syncIndexes: (id, rec, version, priorEnvelope) => syncTierIndexes(this.indexingContext(), id, rec, version, priorEnvelope),
5726
5771
  syncSearch: (id, rec, version) => syncTierSearch(this.searchContext(), id, rec, version),
5727
5772
  syncHistory: async (id, fromDek, toDek) => this.strategies.history.rewrapHistory(this.adapter, this.vault, this.name, id, fromDek, toDek, await this.getDEK(this.name)),
5728
- saveHistorySnapshot: async (id, envelope) => {
5773
+ saveHistorySnapshot: async (id, version, seal) => {
5729
5774
  if (this.historyConfig.enabled === false) return;
5775
+ const envelope = await seal(this.strategies.history.historyIdentity(this.name, id, version));
5730
5776
  await this.strategies.history.saveHistory(this.adapter, this.vault, this.name, id, envelope);
5731
5777
  this.emitter.emit("history:save", { vault: this.vault, collection: this.name, id, version: envelope._v });
5732
5778
  if (this.historyConfig.maxVersions) await this.strategies.history.pruneHistory(this.adapter, this.vault, this.name, id, { keepVersions: this.historyConfig.maxVersions });
@@ -6010,17 +6056,18 @@ var DeferredNumberingStore = class {
6010
6056
  async readJson(collection, id) {
6011
6057
  const env = await this.adapter.get(this.vault, collection, id);
6012
6058
  if (!env) return { env: null, value: null };
6013
- const json = this.encrypted ? await openEnvelopeJson(env, await this.dek(collection)) : env._data;
6059
+ const json = this.encrypted ? await openEnvelopeJson({ collection, id }, env, await this.dek(collection)) : env._data;
6014
6060
  return { env, value: JSON.parse(json) };
6015
6061
  }
6016
6062
  async writeJson(collection, id, value, expectedVersion) {
6017
6063
  const json = JSON.stringify(value);
6018
6064
  let env;
6019
6065
  if (!this.encrypted) {
6020
- env = { _noydb: NOYDB_FORMAT_VERSION, _v: expectedVersion + 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: "", _data: json, _by: this.actor };
6066
+ env = buildRecordEnvelope({ collection, id, version: expectedVersion + 1 }, { iv: "", data: json });
6021
6067
  } else {
6022
- const { iv, data } = await encrypt(json, await this.dek(collection));
6023
- env = { _noydb: NOYDB_FORMAT_VERSION, _v: expectedVersion + 1, _ts: (/* @__PURE__ */ new Date()).toISOString(), _iv: iv, _data: data, _by: this.actor };
6068
+ const identity = { collection, id, version: expectedVersion + 1 };
6069
+ const { iv, data } = await encrypt(json, await this.dek(collection), buildRecordAad(identity));
6070
+ env = buildRecordEnvelope(identity, { iv, data });
6024
6071
  }
6025
6072
  await this.adapter.put(this.vault, collection, id, env, expectedVersion);
6026
6073
  }
@@ -6120,6 +6167,18 @@ var DeferredNumberingStore = class {
6120
6167
  };
6121
6168
 
6122
6169
  // src/with-audit/periods/vault-facade.ts
6170
+ function hasPartition(partition) {
6171
+ return partition !== void 0 && partition.length > 0;
6172
+ }
6173
+ function scopeSuffix(options) {
6174
+ return hasPartition(options?.partition) ? ` in partition [${options.partition.join(", ")}]` : "";
6175
+ }
6176
+ function assertVaultWide(op, period, why) {
6177
+ if (!hasPartition(period.partition)) return;
6178
+ throw new ValidationError(
6179
+ `${op}: period "${period.name}" is partitioned ([${period.partition.join(", ")}]), and ${op} ${why} \u2014 it cannot be scoped to one timeline, because the store sees only ciphertext and cannot tell which partition a stored record belongs to. Close partitioned periods for their sealing semantics; run ${op} against an unpartitioned period covering the same window.`
6180
+ );
6181
+ }
6123
6182
  var VaultPeriods = class {
6124
6183
  constructor(deps) {
6125
6184
  this.deps = deps;
@@ -6134,11 +6193,11 @@ var VaultPeriods = class {
6134
6193
  periodCache = null;
6135
6194
  async closePeriod(options) {
6136
6195
  const existing = await this.loadPeriodsCache();
6137
- this.deps.strategy.validatePeriodName(options.name, existing);
6196
+ this.deps.strategy.validatePeriodName(options.name, existing, options.partition);
6138
6197
  if (typeof options.endDate !== "string" || options.endDate.length === 0) {
6139
6198
  throw new ValidationError("closePeriod: endDate must be a non-empty ISO string.");
6140
6199
  }
6141
- const anchor = await this.deps.strategy.chainAnchor(existing);
6200
+ const anchor = await this.deps.strategy.chainAnchor(existing, options.partition);
6142
6201
  const record = {
6143
6202
  name: options.name,
6144
6203
  kind: "closed",
@@ -6147,21 +6206,26 @@ var VaultPeriods = class {
6147
6206
  closedBy: this.deps.userId(),
6148
6207
  priorPeriodHash: anchor.priorPeriodHash,
6149
6208
  ...anchor.priorPeriodName !== void 0 && { priorPeriodName: anchor.priorPeriodName },
6150
- ...options.dateField !== void 0 && { dateField: options.dateField }
6209
+ ...options.dateField !== void 0 && { dateField: options.dateField },
6210
+ ...hasPartition(options.partition) && { partition: options.partition }
6151
6211
  };
6152
- const envelope = await this.writeReserved(PERIODS_COLLECTION, record.name, record);
6153
- await this.deps.strategy.appendPeriodLedgerEntry(this.deps.getLedgerOrNull(), this.deps.userId(), envelope, record.name);
6212
+ const storageKey = resolvePeriodKey(record.name, record.partition);
6213
+ const envelope = await this.writeReserved(PERIODS_COLLECTION, storageKey, record);
6214
+ await this.deps.strategy.appendPeriodLedgerEntry(this.deps.getLedgerOrNull(), this.deps.userId(), envelope, storageKey);
6154
6215
  existing.push(record);
6155
6216
  this.periodCache = existing;
6156
6217
  return record;
6157
6218
  }
6158
6219
  async openPeriod(options) {
6159
6220
  const existing = await this.loadPeriodsCache();
6160
- this.deps.strategy.validatePeriodName(options.name, existing);
6161
- const prior = existing.find((p) => p.name === options.fromPeriod);
6221
+ this.deps.strategy.validatePeriodName(options.name, existing, options.partition);
6222
+ const prior = existing.find(
6223
+ (p) => p.name === options.fromPeriod && samePartition(p.partition, options.partition)
6224
+ );
6162
6225
  if (!prior) {
6226
+ const where = hasPartition(options.partition) ? ` in partition [${options.partition.join(", ")}]` : "";
6163
6227
  throw new ValidationError(
6164
- `openPeriod: fromPeriod "${options.fromPeriod}" does not exist in this vault.`
6228
+ `openPeriod: fromPeriod "${options.fromPeriod}" does not exist in this vault${where}.`
6165
6229
  );
6166
6230
  }
6167
6231
  if (prior.kind !== "closed") {
@@ -6191,7 +6255,7 @@ var VaultPeriods = class {
6191
6255
  }
6192
6256
  openingCollections.push(collName);
6193
6257
  }
6194
- const anchor = await this.deps.strategy.chainAnchor(existing);
6258
+ const anchor = await this.deps.strategy.chainAnchor(existing, options.partition);
6195
6259
  const record = {
6196
6260
  name: options.name,
6197
6261
  kind: "opened",
@@ -6202,10 +6266,12 @@ var VaultPeriods = class {
6202
6266
  closedBy: this.deps.userId(),
6203
6267
  priorPeriodHash: anchor.priorPeriodHash,
6204
6268
  priorPeriodName: anchor.priorPeriodName ?? prior.name,
6205
- ...openingCollections.length > 0 && { openingCollections }
6269
+ ...openingCollections.length > 0 && { openingCollections },
6270
+ ...hasPartition(options.partition) && { partition: options.partition }
6206
6271
  };
6207
- const envelope = await this.writeReserved(PERIODS_COLLECTION, record.name, record);
6208
- await this.deps.strategy.appendPeriodLedgerEntry(this.deps.getLedgerOrNull(), this.deps.userId(), envelope, record.name);
6272
+ const storageKey = resolvePeriodKey(record.name, record.partition);
6273
+ const envelope = await this.writeReserved(PERIODS_COLLECTION, storageKey, record);
6274
+ await this.deps.strategy.appendPeriodLedgerEntry(this.deps.getLedgerOrNull(), this.deps.userId(), envelope, storageKey);
6209
6275
  existing.push(record);
6210
6276
  this.periodCache = existing;
6211
6277
  return record;
@@ -6219,10 +6285,11 @@ var VaultPeriods = class {
6219
6285
  * read only. Idempotent: a second call is a no-op that returns the
6220
6286
  * same merged record without re-purging or re-appending a ledger entry.
6221
6287
  */
6222
- async freezePeriod(name) {
6288
+ async freezePeriod(name, options) {
6223
6289
  const existing = await this.loadPeriodsCache();
6224
- const period = existing.find((p) => p.name === name);
6225
- if (!period) throw new ValidationError(`freezePeriod: no period named "${name}".`);
6290
+ const period = this.findPeriod(existing, name, options);
6291
+ if (!period) throw new ValidationError(`freezePeriod: no period named "${name}"${scopeSuffix(options)}.`);
6292
+ assertVaultWide("freezePeriod", period, "purges delete markers by write-time across the whole store");
6226
6293
  if (period.kind !== "closed") {
6227
6294
  throw new ValidationError(
6228
6295
  `freezePeriod: period "${name}" is "${period.kind}"; only a closed period can be frozen.`
@@ -6262,10 +6329,11 @@ var VaultPeriods = class {
6262
6329
  * through to cold) and idempotent: a second call is a no-op returning the
6263
6330
  * same merged record.
6264
6331
  */
6265
- async archivePeriod(name) {
6332
+ async archivePeriod(name, options) {
6266
6333
  const existing = await this.loadPeriodsCache();
6267
- const period = existing.find((p) => p.name === name);
6268
- if (!period) throw new ValidationError(`archivePeriod: no period named "${name}".`);
6334
+ const period = this.findPeriod(existing, name, options);
6335
+ if (!period) throw new ValidationError(`archivePeriod: no period named "${name}"${scopeSuffix(options)}.`);
6336
+ assertVaultWide("archivePeriod", period, "relocates records by write-time across the whole store");
6269
6337
  if (period.kind !== "closed") {
6270
6338
  throw new ValidationError(
6271
6339
  `archivePeriod: period "${name}" is "${period.kind}"; only a closed period can be archived.`
@@ -6300,10 +6368,11 @@ var VaultPeriods = class {
6300
6368
  * Idempotent once run; with no push-only targets it writes no companion and
6301
6369
  * is re-runnable.
6302
6370
  */
6303
- async purgePeriodTargets(name) {
6371
+ async purgePeriodTargets(name, options) {
6304
6372
  const existing = await this.loadPeriodsCache();
6305
- const period = existing.find((p) => p.name === name);
6306
- if (!period) throw new ValidationError(`purgePeriodTargets: no period named "${name}".`);
6373
+ const period = this.findPeriod(existing, name, options);
6374
+ if (!period) throw new ValidationError(`purgePeriodTargets: no period named "${name}"${scopeSuffix(options)}.`);
6375
+ assertVaultWide("purgePeriodTargets", period, "sweeps delete markers by write-time off whole sync targets");
6307
6376
  if (period.kind !== "closed") {
6308
6377
  throw new ValidationError(
6309
6378
  `purgePeriodTargets: period "${name}" is "${period.kind}"; only a closed period can be target-purged.`
@@ -6363,8 +6432,15 @@ var VaultPeriods = class {
6363
6432
  purgedMarkerCount: freeze.purgedMarkerCount
6364
6433
  };
6365
6434
  }
6366
- /** Return every closed / opened period in `closedAt` order, merged with any freeze + archive companions. */
6367
- async listPeriods() {
6435
+ /**
6436
+ * Return every closed / opened period in `closedAt` order, merged with any
6437
+ * freeze + archive companions.
6438
+ *
6439
+ * With no argument this spans EVERY timeline — the pre-#1005 behaviour, and
6440
+ * the right default for an audit sweep. Pass `{ partition }` to scope to one
6441
+ * timeline; `{ partition: [] }` (or omitting it) means the vault-wide one.
6442
+ */
6443
+ async listPeriods(options) {
6368
6444
  this.periodCache = null;
6369
6445
  const all = await this.loadPeriodsCache();
6370
6446
  const freezeIds = await this.deps.adapter.list(this.deps.vault, PERIOD_FREEZES_COLLECTION);
@@ -6385,7 +6461,9 @@ var VaultPeriods = class {
6385
6461
  const tp = await this.readReserved(PERIOD_TARGET_PURGES_COLLECTION, id);
6386
6462
  if (tp) targetPurges.set(tp.period, tp);
6387
6463
  }
6388
- return all.map((p) => {
6464
+ const scoped = options === void 0 ? all : all.filter((p) => samePartition(p.partition, options.partition));
6465
+ const withReopen = await this.mergeReopenState(scoped);
6466
+ return withReopen.map((p) => {
6389
6467
  const f = freezes.get(p.name);
6390
6468
  let merged = f ? this.mergeFreeze(p, f) : p;
6391
6469
  const a = archives.get(p.name);
@@ -6395,38 +6473,168 @@ var VaultPeriods = class {
6395
6473
  return merged;
6396
6474
  });
6397
6475
  }
6398
- /** Look up a single period by name, merged with its freeze + archive + target-purge companions if any. Returns `null` if not found. */
6399
- async getPeriod(name) {
6476
+ /**
6477
+ * Look up a single period by name within one timeline, merged with its
6478
+ * freeze + archive + target-purge companions if any. Returns `null` if not
6479
+ * found.
6480
+ *
6481
+ * Names are only unique per partition (#1005), so this resolves against the
6482
+ * VAULT-WIDE timeline unless `{ partition }` says otherwise — matching how
6483
+ * every pre-partition period is stored.
6484
+ */
6485
+ async getPeriod(name, options) {
6400
6486
  const all = await this.loadPeriodsCache();
6401
- const period = all.find((p) => p.name === name);
6487
+ const period = this.findPeriod(all, name, options);
6402
6488
  if (!period) return null;
6403
- const freeze = await this.readReserved(PERIOD_FREEZES_COLLECTION, name);
6404
- const archive = await this.readReserved(PERIOD_ARCHIVES_COLLECTION, name);
6489
+ const key = resolvePeriodKey(name, options?.partition);
6490
+ const freeze = await this.readReserved(PERIOD_FREEZES_COLLECTION, key);
6491
+ const archive = await this.readReserved(PERIOD_ARCHIVES_COLLECTION, key);
6405
6492
  let merged = freeze ? this.mergeFreeze(period, freeze) : period;
6406
6493
  if (archive) merged = this.mergeArchive(merged, archive);
6407
- const targetPurge = await this.readReserved(PERIOD_TARGET_PURGES_COLLECTION, name);
6494
+ const targetPurge = await this.readReserved(PERIOD_TARGET_PURGES_COLLECTION, key);
6408
6495
  if (targetPurge) merged = this.mergeTargetPurge(merged, targetPurge);
6496
+ const reopenLog = await this.readReserved(PERIOD_REOPENS_COLLECTION, key);
6497
+ if (reopenLog) merged = { ...merged, ...resolveReopenState(reopenLog.events) };
6409
6498
  return merged;
6410
6499
  }
6411
- /** Called by the gate bus before put/delete. */
6412
- async assertTsWritable(existing, incoming) {
6500
+ /**
6501
+ * The full append-only reopen/reclose log for one period (#1022) — the record
6502
+ * an audit actually asks for, in order. `[]` when never reopened.
6503
+ */
6504
+ async listPeriodReopens(name, options) {
6505
+ const key = resolvePeriodKey(name, options?.partition);
6506
+ const log = await this.readReserved(PERIOD_REOPENS_COLLECTION, key);
6507
+ return log?.events ?? [];
6508
+ }
6509
+ /**
6510
+ * Return a closed period to a writable state (#1022).
6511
+ *
6512
+ * Close is a three-state lifecycle in practice — open / closed / reopened —
6513
+ * because a month gets closed and then a missing invoice arrives, or a filing
6514
+ * is rejected and must be amended. That is routine, and it is supposed to
6515
+ * leave a trail.
6516
+ *
6517
+ * The `_periods/<key>` record is NOT touched: the reopen is appended to a
6518
+ * companion log, so the inter-period hash chain that proves the close
6519
+ * happened survives the reopen intact. The chain reads *closed at T1,
6520
+ * reopened at T2 by U, reclosed at T3*.
6521
+ *
6522
+ * A reopen withdraws the PERIOD's veto and nothing else. Record-level rules —
6523
+ * an `immutableGuard` on a sent receipt, a frozen field — are separate gate
6524
+ * handlers registered ahead of the period gate, so a reopened month cannot
6525
+ * resurrect a document that is independently locked. Period state can only
6526
+ * ever widen what the record-level rule already permits.
6527
+ *
6528
+ * Reopening an already-open window is allowed and appends another event: that
6529
+ * is how a window gets extended, and the log keeps both.
6530
+ */
6531
+ async reopenPeriod(name, options) {
6532
+ const existing = await this.loadPeriodsCache();
6533
+ const period = this.findPeriod(existing, name, options);
6534
+ if (!period) throw new ValidationError(`reopenPeriod: no period named "${name}"${scopeSuffix(options)}.`);
6535
+ if (period.kind !== "closed") {
6536
+ throw new ValidationError(
6537
+ `reopenPeriod: period "${name}" is "${period.kind}"; only a closed period can be reopened.`
6538
+ );
6539
+ }
6540
+ if (options?.until !== void 0 && Number.isNaN(Date.parse(options.until))) {
6541
+ throw new ValidationError(`reopenPeriod: unparseable \`until\` "${options.until}".`);
6542
+ }
6543
+ return this.appendReopenEvent(period, options, {
6544
+ op: "reopen",
6545
+ at: (/* @__PURE__ */ new Date()).toISOString(),
6546
+ by: this.deps.userId(),
6547
+ ...options?.until !== void 0 && { until: options.until },
6548
+ ...options?.reason !== void 0 && { reason: options.reason }
6549
+ });
6550
+ }
6551
+ /**
6552
+ * Seal a reopened period again (#1022), ending the window explicitly rather
6553
+ * than waiting for an `until` to lapse. Appends to the same log, so the
6554
+ * close → reopen → reclose sequence is recoverable in order.
6555
+ */
6556
+ async reclosePeriod(name, options) {
6557
+ const existing = await this.loadPeriodsCache();
6558
+ const period = this.findPeriod(existing, name, options);
6559
+ if (!period) throw new ValidationError(`reclosePeriod: no period named "${name}"${scopeSuffix(options)}.`);
6560
+ const merged = await this.mergeReopenState([period]);
6561
+ if (!isEffectivelyReopened(merged[0], (/* @__PURE__ */ new Date()).toISOString())) {
6562
+ throw new ValidationError(
6563
+ `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.`
6564
+ );
6565
+ }
6566
+ return this.appendReopenEvent(period, options, {
6567
+ op: "reclose",
6568
+ at: (/* @__PURE__ */ new Date()).toISOString(),
6569
+ by: this.deps.userId(),
6570
+ ...options?.reason !== void 0 && { reason: options.reason }
6571
+ });
6572
+ }
6573
+ /** Append one entry to a period's reopen log, ledger it, and invalidate the guard's view. */
6574
+ async appendReopenEvent(period, scope, event) {
6575
+ const key = resolvePeriodKey(period.name, period.partition);
6576
+ const prior = await this.readReserved(PERIOD_REOPENS_COLLECTION, key);
6577
+ const record = {
6578
+ period: period.name,
6579
+ ...hasPartition(period.partition) && { partition: period.partition },
6580
+ events: [...prior?.events ?? [], event]
6581
+ };
6582
+ const envelope = await this.writeReserved(PERIOD_REOPENS_COLLECTION, key, record);
6583
+ await this.deps.strategy.appendPeriodLedgerEntry(
6584
+ this.deps.getLedgerOrNull(),
6585
+ this.deps.userId(),
6586
+ envelope,
6587
+ key,
6588
+ PERIOD_REOPENS_COLLECTION
6589
+ );
6590
+ this.periodCache = null;
6591
+ void scope;
6592
+ return { ...period, ...resolveReopenState(record.events) };
6593
+ }
6594
+ /** Merge each period's reopen log onto it. One adapter listing, not one per period. */
6595
+ async mergeReopenState(periods) {
6596
+ if (periods.length === 0) return [];
6597
+ const ids = await this.deps.adapter.list(this.deps.vault, PERIOD_REOPENS_COLLECTION);
6598
+ if (ids.length === 0) return [...periods];
6599
+ const byKey = /* @__PURE__ */ new Map();
6600
+ for (const id of ids) {
6601
+ const r = await this.readReserved(PERIOD_REOPENS_COLLECTION, id);
6602
+ if (r) byKey.set(id, r);
6603
+ }
6604
+ return periods.map((p) => {
6605
+ const log = byKey.get(resolvePeriodKey(p.name, p.partition));
6606
+ return log ? { ...p, ...resolveReopenState(log.events) } : p;
6607
+ });
6608
+ }
6609
+ /** Resolve one period within the timeline named by `options` (vault-wide when absent). */
6610
+ findPeriod(all, name, options) {
6611
+ return all.find((p) => p.name === name && samePartition(p.partition, options?.partition));
6612
+ }
6613
+ /** Called by the gate bus before put/delete. `collection` selects the subject mapping (#1005). */
6614
+ async assertTsWritable(existing, incoming, collection) {
6413
6615
  if (existing === null && incoming === null) return;
6414
6616
  if (this.periodCache === null) {
6415
- this.periodCache = await this.deps.strategy.loadPeriods(
6617
+ const loaded = await this.deps.strategy.loadPeriods(
6416
6618
  this.deps.adapter,
6417
6619
  this.deps.vault,
6418
- (env) => this.decryptPeriodRecord(env)
6620
+ (id, env) => this.decryptPeriodRecord(id, env)
6419
6621
  );
6622
+ this.periodCache = await this.mergeReopenState(loaded);
6420
6623
  }
6421
6624
  if (this.periodCache.length === 0) return;
6422
- this.deps.strategy.assertTsWritable(existing, incoming, this.periodCache);
6625
+ this.deps.strategy.assertTsWritable(
6626
+ existing,
6627
+ incoming,
6628
+ this.periodCache,
6629
+ collection !== void 0 ? { collection, ...this.deps.strategy.partitionOf !== void 0 && { resolve: this.deps.strategy.partitionOf } } : void 0
6630
+ );
6423
6631
  }
6424
6632
  async loadPeriodsCache() {
6425
6633
  if (this.periodCache !== null) return this.periodCache;
6426
6634
  const loaded = await this.deps.strategy.loadPeriods(
6427
6635
  this.deps.adapter,
6428
6636
  this.deps.vault,
6429
- (env) => this.decryptPeriodRecord(env)
6637
+ (id, env) => this.decryptPeriodRecord(id, env)
6430
6638
  );
6431
6639
  this.periodCache = loaded;
6432
6640
  return loaded;
@@ -6434,27 +6642,15 @@ var VaultPeriods = class {
6434
6642
  /** Generic reserved-collection writer — serves `_periods` and `_period_freezes` alike. */
6435
6643
  async writeReserved(collection, key, value) {
6436
6644
  const json = JSON.stringify(value);
6645
+ const actor = this.deps.userId();
6646
+ const identity = { collection, id: key, by: actor, version: 1 };
6437
6647
  let envelope;
6438
6648
  if (this.deps.encrypted) {
6439
6649
  const dek = await this.deps.getDEK(collection);
6440
- const { iv, data } = await encrypt(json, dek);
6441
- envelope = {
6442
- _noydb: NOYDB_FORMAT_VERSION,
6443
- _v: 1,
6444
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
6445
- _iv: iv,
6446
- _data: data,
6447
- _by: this.deps.userId()
6448
- };
6650
+ const { iv, data } = await encrypt(json, dek, buildRecordAad(identity));
6651
+ envelope = buildRecordEnvelope(identity, { iv, data });
6449
6652
  } else {
6450
- envelope = {
6451
- _noydb: NOYDB_FORMAT_VERSION,
6452
- _v: 1,
6453
- _ts: (/* @__PURE__ */ new Date()).toISOString(),
6454
- _iv: "",
6455
- _data: json,
6456
- _by: this.deps.userId()
6457
- };
6653
+ envelope = buildRecordEnvelope(identity, { iv: "", data: json });
6458
6654
  }
6459
6655
  await this.deps.adapter.put(this.deps.vault, collection, key, envelope);
6460
6656
  if (collection === PERIODS_COLLECTION && this.deps.onDirty) {
@@ -6466,14 +6662,14 @@ var VaultPeriods = class {
6466
6662
  async readReserved(collection, key) {
6467
6663
  const env = await this.deps.adapter.get(this.deps.vault, collection, key);
6468
6664
  if (!env) return null;
6469
- const json = this.deps.encrypted ? await openEnvelopeJson(env, await this.deps.getDEK(collection)) : env._data;
6665
+ const json = this.deps.encrypted ? await openEnvelopeJson({ collection, id: key }, env, await this.deps.getDEK(collection)) : env._data;
6470
6666
  return JSON.parse(json);
6471
6667
  }
6472
- async decryptPeriodRecord(envelope) {
6668
+ async decryptPeriodRecord(periodId, envelope) {
6473
6669
  let json;
6474
6670
  if (this.deps.encrypted) {
6475
6671
  const dek = await this.deps.getDEK(PERIODS_COLLECTION);
6476
- json = await openEnvelopeJson(envelope, dek);
6672
+ json = await openEnvelopeJson({ collection: PERIODS_COLLECTION, id: periodId }, envelope, dek);
6477
6673
  } else {
6478
6674
  json = envelope._data;
6479
6675
  }
@@ -7048,7 +7244,7 @@ var VaultLinks = class {
7048
7244
  // src/with-shape/links/lazy-handle.ts
7049
7245
  function makeLazyLinkSetHandle(d) {
7050
7246
  let engine = null;
7051
- const load = () => engine ??= import("./link-set-N4ZPV6E6.js").then(
7247
+ const load = () => engine ??= import("./link-set-ZRYNUHN3.js").then(
7052
7248
  ({ LinkSet }) => new LinkSet(d.adapter, d.vault, d.name, d.spec, d.encrypted, d.getDEK, d.actor, d.emitter, d.endpointExists)
7053
7249
  );
7054
7250
  return {
@@ -7695,7 +7891,7 @@ function declareSatellite(ctx, collectionName, options, existingRegistry) {
7695
7891
  ctx.forEachSyncEngine((e) => e.remirrorPairResolvers([spec.base, spec.satellite]));
7696
7892
  const registry = reg;
7697
7893
  const baseSchema = ctx.getBaseSchema(spec.base);
7698
- void import("./post-register-ZAG2CAIY.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
7894
+ void import("./post-register-J4DEVNXK.js").then((m) => m.postRegister(ctx.adapter, ctx.vaultName, spec, ctx.getDEK, baseSchema, registry)).catch(() => {
7699
7895
  });
7700
7896
  return reg;
7701
7897
  }
@@ -8678,7 +8874,7 @@ var Vault = class {
8678
8874
  const strategies = options.schemaUpdate ?? [];
8679
8875
  const work = (async () => {
8680
8876
  const dek = await this.getDEK(collectionName);
8681
- const { persistSchemaIfNeeded } = await import("./register-TMD6YRCX.js");
8877
+ const { persistSchemaIfNeeded } = await import("./register-UPD4GKBC.js");
8682
8878
  const result = await persistSchemaIfNeeded({
8683
8879
  store: this.adapter,
8684
8880
  vault: this.name,
@@ -8828,7 +9024,7 @@ var Vault = class {
8828
9024
  const work = (async () => {
8829
9025
  try {
8830
9026
  const dek = await this.getDEK(collectionName);
8831
- await (await import("./register-TMD6YRCX.js")).persistSchemaIfNeeded({
9027
+ await (await import("./register-UPD4GKBC.js")).persistSchemaIfNeeded({
8832
9028
  store: this.adapter,
8833
9029
  vault: this.name,
8834
9030
  collectionName,
@@ -9504,16 +9700,23 @@ var Vault = class {
9504
9700
  */
9505
9701
  // eslint-disable-next-line @typescript-eslint/consistent-type-imports
9506
9702
  async _loadPodSigner() {
9507
- const { loadSigner } = await import("./signer-AGALOXOO.js");
9703
+ const { loadSigner } = await import("./signer-BZWDPGGN.js");
9508
9704
  return loadSigner(this.adapter, this.name, this.getDEK);
9509
9705
  }
9510
9706
  async writeExportAudit(entry) {
9511
9707
  const json = JSON.stringify(entry);
9708
+ const exportAuditIdentity = { collection: EXPORT_AUDIT_COLLECTION, id: entry.id, by: entry.actor, version: 1 };
9512
9709
  const envelope = this.encrypted ? await (async () => {
9513
9710
  const dek = await this.getDEK(EXPORT_AUDIT_COLLECTION);
9514
- const { iv, data } = await encrypt(json, dek);
9515
- return { _noydb: NOYDB_FORMAT_VERSION, _v: 1, _ts: entry.startedAt, _iv: iv, _data: data, _by: entry.actor };
9516
- })() : { _noydb: NOYDB_FORMAT_VERSION, _v: 1, _ts: entry.startedAt, _iv: "", _data: json, _by: entry.actor };
9711
+ const { iv, data } = await encrypt(json, dek, buildRecordAad(exportAuditIdentity));
9712
+ return buildRecordEnvelope(
9713
+ exportAuditIdentity,
9714
+ { ts: entry.startedAt, iv, data }
9715
+ );
9716
+ })() : buildRecordEnvelope(
9717
+ exportAuditIdentity,
9718
+ { ts: entry.startedAt, iv: "", data: json }
9719
+ );
9517
9720
  await this.adapter.put(this.name, EXPORT_AUDIT_COLLECTION, entry.id, envelope);
9518
9721
  }
9519
9722
  canExport(tier, format) {
@@ -9527,12 +9730,12 @@ var Vault = class {
9527
9730
  *
9528
9731
  * @internal
9529
9732
  */
9530
- async _decryptEnvelopeForBundleFilter(env, collectionName) {
9733
+ async _decryptEnvelopeForBundleFilter(env, collectionName, recordId) {
9531
9734
  if (!this.encrypted) {
9532
9735
  return JSON.parse(env._data);
9533
9736
  }
9534
9737
  const dek = await this.getDEK(collectionName);
9535
- const json = await openEnvelopeJson(env, dek);
9738
+ const json = await openEnvelopeJson({ collection: collectionName, id: recordId }, env, dek);
9536
9739
  return JSON.parse(json);
9537
9740
  }
9538
9741
  canImport(tier, format) {
@@ -9987,7 +10190,7 @@ var Vault = class {
9987
10190
  async _initGuards(handles) {
9988
10191
  if (handles.length === 0) return;
9989
10192
  const [{ GuardRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
9990
- import("./registry-IKUR2MXD.js"),
10193
+ import("./registry-XIRTZHPC.js"),
9991
10194
  import("./read-only-facade-CHCKSEPD.js")
9992
10195
  ]);
9993
10196
  const registry = new GuardRegistry();
@@ -10015,7 +10218,7 @@ var Vault = class {
10015
10218
  async _initDerivations(handles) {
10016
10219
  if (handles.length === 0) return;
10017
10220
  const [{ DerivationRegistry }, { ReadOnlyVaultFacade }] = await Promise.all([
10018
- import("./registry-FVLDWQKT.js"),
10221
+ import("./registry-7KX2HWFS.js"),
10019
10222
  import("./read-only-facade-CHCKSEPD.js")
10020
10223
  ]);
10021
10224
  const registry = new DerivationRegistry();
@@ -10047,7 +10250,7 @@ var Vault = class {
10047
10250
  */
10048
10251
  async _initMaterializedViews(handles) {
10049
10252
  if (handles.length === 0) return;
10050
- const { MaterializedViewRegistry } = await import("./registry-JET4HBLY.js");
10253
+ const { MaterializedViewRegistry } = await import("./registry-XHCYMD34.js");
10051
10254
  const registry = new MaterializedViewRegistry();
10052
10255
  this.materializedViewRegistry = registry;
10053
10256
  const db = this;
@@ -10072,7 +10275,7 @@ var Vault = class {
10072
10275
  */
10073
10276
  async _initOverlayedViews(handles) {
10074
10277
  if (handles.length === 0) return;
10075
- const { OverlayedViewRegistry } = await import("./registry-CZVINVQH.js");
10278
+ const { OverlayedViewRegistry } = await import("./registry-PKYYEHEW.js");
10076
10279
  const registry = new OverlayedViewRegistry();
10077
10280
  const mvRegistry = this.materializedViewRegistry;
10078
10281
  const overlayNames = /* @__PURE__ */ new Set();
@@ -10134,14 +10337,14 @@ var Vault = class {
10134
10337
  if (!reg) {
10135
10338
  throw new Error(`refreshView: no MV registered with name "${name}"`);
10136
10339
  }
10137
- const { MaterializedViewExecutor } = await import("./executor-FHHLXO4Y.js");
10340
+ const { MaterializedViewExecutor } = await import("./executor-SHUVRZUJ.js");
10138
10341
  const result = await MaterializedViewExecutor.refresh(reg, {
10139
10342
  getCollection: (n) => this.collection(n),
10140
10343
  getActiveTxContext: () => this.noydb._activeTxContextOrNull,
10141
10344
  getQueryContext: () => this,
10142
10345
  dispatchCtx: this._dispatchCtx({ collection: name, id: "refreshView" })
10143
10346
  });
10144
- const { clearMVStaleFully } = await import("./stale-ZWXSOWJI.js");
10347
+ const { clearMVStaleFully } = await import("./stale-PQYPVCER.js");
10145
10348
  await clearMVStaleFully(this.adapter, this.name, registry, name);
10146
10349
  return result;
10147
10350
  }
@@ -10154,7 +10357,7 @@ var Vault = class {
10154
10357
  if (registry === null) return { derived: 0, failed: 0, skippedFrozen: 0 };
10155
10358
  const strategies = registry.strategiesForSource(sourceCollection);
10156
10359
  if (strategies.length === 0) return { derived: 0, failed: 0, skippedFrozen: 0 };
10157
- const { DerivationExecutor } = await import("./executor-S4QIKEHW.js");
10360
+ const { DerivationExecutor } = await import("./executor-GPM6DNWV.js");
10158
10361
  const sourceColl = this.collection(sourceCollection);
10159
10362
  const records = await sourceColl.list();
10160
10363
  const ctx = { vault: this.derivationFacade ?? new (await import("./read-only-facade-CHCKSEPD.js")).ReadOnlyVaultFacade(this, "derivation") };
@@ -10181,7 +10384,7 @@ var Vault = class {
10181
10384
  if (!outSpec) continue;
10182
10385
  const outputColl = this.collection(outSpec.collection);
10183
10386
  if (out.kind === "array") {
10184
- const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-DTBIDOWF.js");
10387
+ const { loadFanoutSidecar, saveFanoutSidecar } = await import("./fanout-sidecar-TFPWDOME.js");
10185
10388
  const prior = await loadFanoutSidecar(this.adapter, this.name, spec.source, id, key, this.getDEK, this.encrypted);
10186
10389
  const prevKeys = new Set(prior?.keys ?? []);
10187
10390
  const newKeysList = out.entries.map((e) => e.key);
@@ -10408,7 +10611,7 @@ var Vault = class {
10408
10611
  * collection.
10409
10612
  */
10410
10613
  async delegate(opts) {
10411
- const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-SSEPLXXO.js");
10614
+ const { issueDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-4R5DU23X.js");
10412
10615
  if (!this.keyring.kek) {
10413
10616
  throw new ValidationError(
10414
10617
  "issueDelegation: keyring.kek is null \u2014 issuing a delegation requires a tier-1 unlock. Re-authenticate at tier 1 (secret) first."
@@ -10430,7 +10633,7 @@ var Vault = class {
10430
10633
  * if the id does not exist.
10431
10634
  */
10432
10635
  async revokeDelegation(id) {
10433
- const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-SSEPLXXO.js");
10636
+ const { revokeDelegation, DELEGATIONS_COLLECTION } = await import("./delegation-4R5DU23X.js");
10434
10637
  await revokeDelegation(this.adapter, this.name, id);
10435
10638
  void DELEGATIONS_COLLECTION;
10436
10639
  }
@@ -10526,25 +10729,18 @@ var Vault = class {
10526
10729
  async writeElevationAudit(entry) {
10527
10730
  const id = `elev-${Date.now().toString(36)}-${Math.random().toString(16).slice(2, 10)}`;
10528
10731
  const json = JSON.stringify({ id, ...entry });
10732
+ const elevationAuditIdentity = { collection: ELEVATION_AUDIT_COLLECTION, id, by: entry.actor, version: 1 };
10529
10733
  const envelope = this.encrypted ? await (async () => {
10530
10734
  const dek = await this.getDEK(ELEVATION_AUDIT_COLLECTION);
10531
- const { iv, data } = await encrypt(json, dek);
10532
- return {
10533
- _noydb: NOYDB_FORMAT_VERSION,
10534
- _v: 1,
10535
- _ts: entry.startedAt,
10536
- _iv: iv,
10537
- _data: data,
10538
- _by: entry.actor
10539
- };
10540
- })() : {
10541
- _noydb: NOYDB_FORMAT_VERSION,
10542
- _v: 1,
10543
- _ts: entry.startedAt,
10544
- _iv: "",
10545
- _data: json,
10546
- _by: entry.actor
10547
- };
10735
+ const { iv, data } = await encrypt(json, dek, buildRecordAad(elevationAuditIdentity));
10736
+ return buildRecordEnvelope(
10737
+ elevationAuditIdentity,
10738
+ { ts: entry.startedAt, iv, data }
10739
+ );
10740
+ })() : buildRecordEnvelope(
10741
+ elevationAuditIdentity,
10742
+ { ts: entry.startedAt, iv: "", data: json }
10743
+ );
10548
10744
  await this.adapter.put(this.name, ELEVATION_AUDIT_COLLECTION, id, envelope);
10549
10745
  }
10550
10746
  /**
@@ -10609,13 +10805,13 @@ var Vault = class {
10609
10805
  async openPeriod(options) {
10610
10806
  return this.periods.openPeriod(options);
10611
10807
  }
10612
- /** Return every closed / opened period in `closedAt` order. */
10613
- async listPeriods() {
10614
- return this.periods.listPeriods();
10808
+ /** Every closed / opened period in `closedAt` order; ALL timelines unless `{ partition }` scopes it (#1005). */
10809
+ async listPeriods(options) {
10810
+ return this.periods.listPeriods(options);
10615
10811
  }
10616
- /** Look up a single period by name. Returns `null` if not found. */
10617
- async getPeriod(name) {
10618
- return this.periods.getPeriod(name);
10812
+ /** One period by name within a timeline (vault-wide unless `{ partition }`). `null` if not found. */
10813
+ async getPeriod(name, options) {
10814
+ return this.periods.getPeriod(name, options);
10619
10815
  }
10620
10816
  /**
10621
10817
  * Freeze a closed period (#604): purges in-window delete markers and
@@ -10625,8 +10821,8 @@ var Vault = class {
10625
10821
  * and purging re-opens the #589 resurrection window for a peer offline
10626
10822
  * since before the cutoff (see periods.ts's "Freeze" section).
10627
10823
  */
10628
- async freezePeriod(name) {
10629
- return this.periods.freezePeriod(name);
10824
+ async freezePeriod(name, options) {
10825
+ return this.periods.freezePeriod(name, options);
10630
10826
  }
10631
10827
  /**
10632
10828
  * Archive a closed period (#613): relocates its in-window records from the
@@ -10635,8 +10831,8 @@ var Vault = class {
10635
10831
  * the chained `_periods` record. Non-destructive (reads fall through to
10636
10832
  * cold) and idempotent. Requires a routeStore with a cold route.
10637
10833
  */
10638
- async archivePeriod(name) {
10639
- return this.periods.archivePeriod(name);
10834
+ async archivePeriod(name, options) {
10835
+ return this.periods.archivePeriod(name, options);
10640
10836
  }
10641
10837
  /**
10642
10838
  * Target-purge a closed+frozen period (#615): sweeps delete markers off the
@@ -10646,12 +10842,24 @@ var Vault = class {
10646
10842
  * frozen first. Idempotent; a vault with no push-only targets writes no
10647
10843
  * companion and is re-runnable.
10648
10844
  */
10649
- async purgePeriodTargets(name) {
10650
- return this.periods.purgePeriodTargets(name);
10845
+ async purgePeriodTargets(name, options) {
10846
+ return this.periods.purgePeriodTargets(name, options);
10847
+ }
10848
+ /** Return a closed period to writable (#1022); logged append-only, close chain untouched. */
10849
+ async reopenPeriod(name, options) {
10850
+ return this.periods.reopenPeriod(name, options);
10851
+ }
10852
+ /** Seal a reopened period again (#1022) rather than waiting for its `until` to lapse. */
10853
+ async reclosePeriod(name, options) {
10854
+ return this.periods.reclosePeriod(name, options);
10855
+ }
10856
+ /** The append-only reopen/reclose log for one period (#1022), in order. */
10857
+ async listPeriodReopens(name, options) {
10858
+ return this.periods.listPeriodReopens(name, options);
10651
10859
  }
10652
10860
  /** @internal — called by the gate bus before put/delete. */
10653
- async _assertTsWritable(existing, incoming) {
10654
- return this.periods.assertTsWritable(existing, incoming);
10861
+ async _assertTsWritable(existing, incoming, collection) {
10862
+ return this.periods.assertTsWritable(existing, incoming, collection);
10655
10863
  }
10656
10864
  /** List all collection names in this vault. */
10657
10865
  async collections() {
@@ -10678,7 +10886,7 @@ var Vault = class {
10678
10886
  * @see design-history/2026-05-22-schema-dump-design.md
10679
10887
  */
10680
10888
  async dumpSchema(opts = {}) {
10681
- const { dumpVaultSchema } = await import("./walk-OCUHCYJ6.js");
10889
+ const { dumpVaultSchema } = await import("./walk-BX4NSB5L.js");
10682
10890
  return dumpVaultSchema(this, opts);
10683
10891
  }
10684
10892
  /**
@@ -10773,15 +10981,15 @@ var Vault = class {
10773
10981
  * distinct handles, which is the right behavior — they're
10774
10982
  * separate vault instances now.
10775
10983
  */
10776
- async getBundleHandle() {
10777
- const { buildBundleHandle } = await import("./bundle-handle-JEUWU2SJ.js");
10778
- return buildBundleHandle(this.adapter, this.name);
10984
+ async getPodHandle() {
10985
+ const { buildPodHandle } = await import("./pod-handle-UPLXOGIK.js");
10986
+ return buildPodHandle(this.adapter, this.name);
10779
10987
  }
10780
10988
  /**
10781
10989
  * Read the owner-curated cover for this vault (or `undefined` if
10782
10990
  * none is persisted). The cover lives in `_meta/public-envelope`
10783
10991
  * (the frozen wire name) as plaintext — readable without any KEK
10784
- * — so `getBundleHandle`-style callers can label a vault before
10992
+ * — so `getPodHandle`-style callers can label a vault before
10785
10993
  * unlock.
10786
10994
  *
10787
10995
  * Mirrors `Noydb.getCover(vault, opts)` but scoped to a
@@ -10806,7 +11014,7 @@ var Vault = class {
10806
11014
  * both modes round-trip cleanly.
10807
11015
  */
10808
11016
  async dump() {
10809
- const { dumpVault } = await import("./backup-YYBE5RPC.js");
11017
+ const { dumpVault } = await import("./backup-K62BFMYK.js");
10810
11018
  return dumpVault(this.backupContext());
10811
11019
  }
10812
11020
  /**
@@ -10858,7 +11066,7 @@ var Vault = class {
10858
11066
  * — there's no chain to verify against.
10859
11067
  */
10860
11068
  async load(backupJson) {
10861
- const { loadVault } = await import("./backup-YYBE5RPC.js");
11069
+ const { loadVault } = await import("./backup-K62BFMYK.js");
10862
11070
  return loadVault(this.backupContext(), backupJson);
10863
11071
  }
10864
11072
  /**
@@ -10890,7 +11098,7 @@ var Vault = class {
10890
11098
  * way to detect tampering of an in-place vault.
10891
11099
  */
10892
11100
  async verifyBackupIntegrity() {
10893
- const { verifyBackupIntegrity } = await import("./backup-YYBE5RPC.js");
11101
+ const { verifyBackupIntegrity } = await import("./backup-K62BFMYK.js");
10894
11102
  return verifyBackupIntegrity(this.backupContext());
10895
11103
  }
10896
11104
  /**
@@ -11108,7 +11316,7 @@ var Vault = class {
11108
11316
  * is the live validator object, not a serialization of it).
11109
11317
  */
11110
11318
  async exportJSON(opts = {}) {
11111
- const { exportVaultJSON } = await import("./backup-YYBE5RPC.js");
11319
+ const { exportVaultJSON } = await import("./backup-K62BFMYK.js");
11112
11320
  return exportVaultJSON(this.backupContext(), opts);
11113
11321
  }
11114
11322
  };
@@ -12924,6 +13132,7 @@ var Noydb = class {
12924
13132
  this.#registerGuardGate();
12925
13133
  this.#registerPeriodGate();
12926
13134
  this.#registerForgetHooks();
13135
+ this.#registerVaultHeadObserver();
12927
13136
  this.resetSessionTimer();
12928
13137
  }
12929
13138
  /** @internal — resolved forget strategy (NO_FORGET when not configured). */
@@ -12940,6 +13149,22 @@ var Noydb = class {
12940
13149
  // - the subsystemBus `afterDelete` observer fires on delete (onAfterWrite
12941
13150
  // does NOT) — drop the ref so a deleted record never lingers in the
12942
13151
  // index (RISK #2). Without it, forget() would try to shred a ghost.
13152
+ /** #1044 — see `with-commit/vault-head/strategy.ts` for why this is an observer. */
13153
+ #registerVaultHeadObserver() {
13154
+ if (!this.strategies.vaultHead.enabled) return;
13155
+ for (const point of ["afterPut", "afterDelete"]) {
13156
+ this.subsystemBus.register(point, async (event) => {
13157
+ const vault = this.vaultCache.get(event.vault);
13158
+ if (!vault) return;
13159
+ const { adapter, getDEK } = vault._introspectState();
13160
+ await this.strategies.vaultHead.note(adapter, event.vault, getDEK, {
13161
+ collection: event.collection,
13162
+ id: event.docId,
13163
+ version: event.version
13164
+ });
13165
+ });
13166
+ }
13167
+ }
12943
13168
  #registerForgetHooks() {
12944
13169
  const subjects = this.strategies.forget.subjects;
12945
13170
  if (Object.keys(subjects).length === 0) return;
@@ -13005,7 +13230,7 @@ var Noydb = class {
13005
13230
  if (!facade) return;
13006
13231
  const ctx = { existing, vault: facade, userId: e.userId, role: e.role };
13007
13232
  await registry.runChecks(e.collection, incoming, ctx);
13008
- const { GuardExecutor } = await import("./executor-CYJQLKKI.js");
13233
+ const { GuardExecutor } = await import("./executor-LJSMZ4IB.js");
13009
13234
  for (const g of guards) {
13010
13235
  await GuardExecutor.checkFrozenFields(g, e.docId, existing, incoming, e.computedFieldNames);
13011
13236
  }
@@ -13051,7 +13276,7 @@ var Noydb = class {
13051
13276
  const v = this.vaultCache.get(e.vault);
13052
13277
  if (!v) return;
13053
13278
  const existing = e.op === "create" ? null : { ts: e.existingTs ?? null, record: e.existing ?? null };
13054
- await v._assertTsWritable(existing, e.incoming);
13279
+ await v._assertTsWritable(existing, e.incoming, e.collection);
13055
13280
  });
13056
13281
  this.subsystemBus.registerGate("beforeDelete", async (e) => {
13057
13282
  if (e.internal) return;
@@ -13059,7 +13284,8 @@ var Noydb = class {
13059
13284
  if (!v) return;
13060
13285
  await v._assertTsWritable(
13061
13286
  { ts: e.existingTs ?? null, record: e.existing ?? null },
13062
- null
13287
+ null,
13288
+ e.collection
13063
13289
  );
13064
13290
  });
13065
13291
  }
@@ -13125,6 +13351,7 @@ var Noydb = class {
13125
13351
  if (this.options.encrypt !== false && !this.policyCache.has(name)) {
13126
13352
  await this.bootstrapPolicy(name);
13127
13353
  }
13354
+ const mergeAuthority = buildMergeAuthority(keyring);
13128
13355
  let syncEngine;
13129
13356
  const targets = normalizeSyncTargets(this.options.sync);
13130
13357
  if (targets.length > 0) {
@@ -13139,11 +13366,12 @@ var Noydb = class {
13139
13366
  emitter: this.emitter,
13140
13367
  syncPolicy: effectivePolicy,
13141
13368
  role: primary.role,
13369
+ mergeAuthority,
13142
13370
  ...primary.label !== void 0 ? { label: primary.label } : {}
13143
13371
  });
13144
13372
  this.syncEngines.set(name, syncEngine);
13145
13373
  if (declaredPolicy) syncEngine.startScheduler();
13146
- for (const target of targets) {
13374
+ for (const [index, target] of targets.entries()) {
13147
13375
  if (target === primary) continue;
13148
13376
  const targetPolicy = target.policy ?? this.options.syncPolicy ?? INDEXED_STORE_POLICY;
13149
13377
  const engine = this.strategies.sync.buildSyncEngine({
@@ -13154,10 +13382,10 @@ var Noydb = class {
13154
13382
  emitter: this.emitter,
13155
13383
  syncPolicy: targetPolicy,
13156
13384
  role: target.role,
13385
+ mergeAuthority,
13157
13386
  ...target.label !== void 0 ? { label: target.label } : {}
13158
13387
  });
13159
- const key = `${name}::${target.label ?? target.role}`;
13160
- this.syncEngines.set(key, engine);
13388
+ this.syncEngines.set(`${name}::${index}`, engine);
13161
13389
  if (target.policy ?? this.options.syncPolicy) engine.startScheduler();
13162
13390
  }
13163
13391
  }
@@ -13378,8 +13606,8 @@ var Noydb = class {
13378
13606
  * collection) pair that was dropped. Re-run `grant()` for those pairs, or
13379
13607
  * they stay locked out.
13380
13608
  *
13381
- * Unlike `revoke({ rotateKeys: true })`, this call does not REMOVE any
13382
- * user from the vault — they keep membership and their other collections.
13609
+ * Unlike `revoke()`, this call does not REMOVE any user from the vault —
13610
+ * they keep membership and their other collections.
13383
13611
  * This is the "just rotate" path; "revoke and rotate" lives in `revoke()`.
13384
13612
  *
13385
13613
  * Exposed on Noydb (rather than only on the lower-level keyring
@@ -13783,6 +14011,21 @@ var Noydb = class {
13783
14011
  }
13784
14012
  return engine.status();
13785
14013
  }
14014
+ /**
14015
+ * Per-target sync state for `vault` (#1034) — `syncStatus()` reads only the
14016
+ * primary engine, so it cannot express "the LAN store is behind, the cloud
14017
+ * is current". Registration order, primary first. See {@link SyncTargetStatus}.
14018
+ */
14019
+ syncTargetStatus(vault) {
14020
+ const targets = [];
14021
+ for (const [key, engine] of this.syncEngines) {
14022
+ if (key !== vault && !key.startsWith(`${vault}::`)) continue;
14023
+ const { dirty, lastPush, lastPull } = engine.status();
14024
+ const { label, role } = engine;
14025
+ targets.push({ label, role, dirty, lastPush, lastPull, caughtUp: dirty === 0 });
14026
+ }
14027
+ return targets;
14028
+ }
13786
14029
  /**
13787
14030
  * Enumerate the sync targets wired for `vault` (#948) — the primary engine
13788
14031
  * (keyed by vault name) plus any additional targets (keyed `vault::label`
@@ -13805,7 +14048,14 @@ var Noydb = class {
13805
14048
  getSyncEngine(vault) {
13806
14049
  const engine = this.syncEngines.get(vault);
13807
14050
  if (!engine) {
13808
- throw new ValidationError("No sync adapter configured. Pass a `sync` adapter to createNoydb().");
14051
+ if (this.syncEngines.size === 0) {
14052
+ throw new ValidationError(
14053
+ "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."
14054
+ );
14055
+ }
14056
+ throw new ValidationError(
14057
+ `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()\`.`
14058
+ );
13809
14059
  }
13810
14060
  return engine;
13811
14061
  }
@@ -13990,8 +14240,11 @@ var Noydb = class {
13990
14240
  * No-op when `vault` is not currently in cache (idempotent).
13991
14241
  */
13992
14242
  lockVault(vault) {
13993
- this.syncEngines.get(vault)?.stopAutoSync();
13994
- this.syncEngines.delete(vault);
14243
+ for (const [key, engine] of [...this.syncEngines]) {
14244
+ if (key !== vault && !key.startsWith(`${vault}::`)) continue;
14245
+ engine.stopAutoSync();
14246
+ this.syncEngines.delete(key);
14247
+ }
13995
14248
  this.policyEnforcers.get(vault)?.destroy();
13996
14249
  this.policyEnforcers.delete(vault);
13997
14250
  this.vaultCache.get(vault)?._stopFenceCoordination();
@@ -14328,7 +14581,7 @@ async function createNoydb(options) {
14328
14581
  if (!options.store) options = { ...options, store: memoryStore() };
14329
14582
  validateSecretModeOptions(options);
14330
14583
  if (!options.coordinationStrategy) options = { ...options, coordinationStrategy: await createDefaultCoordinationProvider(options.store) };
14331
- if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-WVY3H3YH.js")).createUserApi };
14584
+ if (!options.userApiFactory) options = { ...options, userApiFactory: (await import("./api-Z5VHH24A.js")).createUserApi };
14332
14585
  if (!options.policyFactory) {
14333
14586
  const policyModule = await import("./policy/index.js");
14334
14587
  options = { ...options, policyFactory: policyModule.createNoydbPolicy, policyCheckGateFn: policyModule.checkGate };
@@ -14363,4 +14616,4 @@ export {
14363
14616
  Noydb,
14364
14617
  createNoydb
14365
14618
  };
14366
- //# sourceMappingURL=chunk-PY7CI6L5.js.map
14619
+ //# sourceMappingURL=chunk-6TXUVKPG.js.map