@opendatalabs/personal-server-ts-core 0.0.1-canary.052d47e → 0.0.1-canary.0620a9a

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 (837) hide show
  1. package/dist/additions/budget.d.ts +34 -0
  2. package/dist/additions/budget.d.ts.map +1 -0
  3. package/dist/additions/budget.js +144 -0
  4. package/dist/additions/budget.js.map +1 -0
  5. package/dist/additions/durable.d.ts +94 -0
  6. package/dist/additions/durable.d.ts.map +1 -0
  7. package/dist/additions/durable.js +823 -0
  8. package/dist/additions/durable.js.map +1 -0
  9. package/dist/additions/first-added.d.ts +204 -0
  10. package/dist/additions/first-added.d.ts.map +1 -0
  11. package/dist/additions/first-added.js +598 -0
  12. package/dist/additions/first-added.js.map +1 -0
  13. package/dist/additions/index.d.ts +9 -0
  14. package/dist/additions/index.d.ts.map +1 -0
  15. package/dist/additions/index.js +9 -0
  16. package/dist/additions/index.js.map +1 -0
  17. package/dist/additions/ledger-store.d.ts +69 -0
  18. package/dist/additions/ledger-store.d.ts.map +1 -0
  19. package/dist/additions/ledger-store.js +407 -0
  20. package/dist/additions/ledger-store.js.map +1 -0
  21. package/dist/additions/record-rules.d.ts +54 -0
  22. package/dist/additions/record-rules.d.ts.map +1 -0
  23. package/dist/additions/record-rules.js +198 -0
  24. package/dist/additions/record-rules.js.map +1 -0
  25. package/dist/additions/scope-lock.d.ts +14 -0
  26. package/dist/additions/scope-lock.d.ts.map +1 -0
  27. package/dist/additions/scope-lock.js +32 -0
  28. package/dist/additions/scope-lock.js.map +1 -0
  29. package/dist/additions/summary.d.ts +143 -0
  30. package/dist/additions/summary.d.ts.map +1 -0
  31. package/dist/additions/summary.js +279 -0
  32. package/dist/additions/summary.js.map +1 -0
  33. package/dist/additions/version-inventory.d.ts +86 -0
  34. package/dist/additions/version-inventory.d.ts.map +1 -0
  35. package/dist/additions/version-inventory.js +244 -0
  36. package/dist/additions/version-inventory.js.map +1 -0
  37. package/dist/api/index.d.ts +192 -8
  38. package/dist/api/index.d.ts.map +1 -1
  39. package/dist/api/index.js +1227 -153
  40. package/dist/api/index.js.map +1 -1
  41. package/dist/api/oura-collection-requirements.d.ts +16 -0
  42. package/dist/api/oura-collection-requirements.d.ts.map +1 -0
  43. package/dist/api/oura-collection-requirements.js +70 -0
  44. package/dist/api/oura-collection-requirements.js.map +1 -0
  45. package/dist/api/raw-envelope.d.ts +3 -0
  46. package/dist/api/raw-envelope.d.ts.map +1 -0
  47. package/dist/api/raw-envelope.js +215 -0
  48. package/dist/api/raw-envelope.js.map +1 -0
  49. package/dist/api/scope-upload-batches.d.ts +18 -0
  50. package/dist/api/scope-upload-batches.d.ts.map +1 -0
  51. package/dist/api/scope-upload-batches.js +71 -0
  52. package/dist/api/scope-upload-batches.js.map +1 -0
  53. package/dist/api/scope-uploads.d.ts +112 -0
  54. package/dist/api/scope-uploads.d.ts.map +1 -0
  55. package/dist/api/scope-uploads.js +369 -0
  56. package/dist/api/scope-uploads.js.map +1 -0
  57. package/dist/auth/index.d.ts +3 -1
  58. package/dist/auth/index.d.ts.map +1 -1
  59. package/dist/auth/index.js +3 -1
  60. package/dist/auth/index.js.map +1 -1
  61. package/dist/auth/proof-id.d.ts +8 -0
  62. package/dist/auth/proof-id.d.ts.map +1 -0
  63. package/dist/auth/proof-id.js +29 -0
  64. package/dist/auth/proof-id.js.map +1 -0
  65. package/dist/auth/request.d.ts +24 -0
  66. package/dist/auth/request.d.ts.map +1 -1
  67. package/dist/auth/request.js +99 -4
  68. package/dist/auth/request.js.map +1 -1
  69. package/dist/client.d.ts +70 -0
  70. package/dist/client.d.ts.map +1 -1
  71. package/dist/client.js +1 -0
  72. package/dist/client.js.map +1 -1
  73. package/dist/contracts/auth-device.d.ts +10 -0
  74. package/dist/contracts/auth-device.d.ts.map +1 -1
  75. package/dist/contracts/auth-device.js +2 -0
  76. package/dist/contracts/auth-device.js.map +1 -1
  77. package/dist/contracts/data.d.ts +102 -8
  78. package/dist/contracts/data.d.ts.map +1 -1
  79. package/dist/contracts/data.js +320 -47
  80. package/dist/contracts/data.js.map +1 -1
  81. package/dist/contracts/grants.d.ts.map +1 -1
  82. package/dist/contracts/grants.js +7 -0
  83. package/dist/contracts/grants.js.map +1 -1
  84. package/dist/contracts/index.d.ts +4 -2
  85. package/dist/contracts/index.d.ts.map +1 -1
  86. package/dist/contracts/index.js +3 -1
  87. package/dist/contracts/index.js.map +1 -1
  88. package/dist/contracts/oura-collection-requirements.d.ts +17 -0
  89. package/dist/contracts/oura-collection-requirements.d.ts.map +1 -0
  90. package/dist/contracts/oura-collection-requirements.js +49 -0
  91. package/dist/contracts/oura-collection-requirements.js.map +1 -0
  92. package/dist/contracts/sync.d.ts.map +1 -1
  93. package/dist/contracts/sync.js +1 -0
  94. package/dist/contracts/sync.js.map +1 -1
  95. package/dist/derivatives/answer-shape.d.ts +83 -0
  96. package/dist/derivatives/answer-shape.d.ts.map +1 -0
  97. package/dist/derivatives/answer-shape.js +320 -0
  98. package/dist/derivatives/answer-shape.js.map +1 -0
  99. package/dist/derivatives/api.d.ts +1 -1
  100. package/dist/derivatives/api.d.ts.map +1 -1
  101. package/dist/derivatives/api.js +8 -0
  102. package/dist/derivatives/api.js.map +1 -1
  103. package/dist/derivatives/compute.d.ts +9 -3
  104. package/dist/derivatives/compute.d.ts.map +1 -1
  105. package/dist/derivatives/compute.js +68 -6
  106. package/dist/derivatives/compute.js.map +1 -1
  107. package/dist/derivatives/index.d.ts +2 -1
  108. package/dist/derivatives/index.d.ts.map +1 -1
  109. package/dist/derivatives/index.js +2 -1
  110. package/dist/derivatives/index.js.map +1 -1
  111. package/dist/derivatives/prompt.d.ts +35 -0
  112. package/dist/derivatives/prompt.d.ts.map +1 -1
  113. package/dist/derivatives/prompt.js +96 -8
  114. package/dist/derivatives/prompt.js.map +1 -1
  115. package/dist/derivatives/registration.d.ts +6 -9
  116. package/dist/derivatives/registration.d.ts.map +1 -1
  117. package/dist/derivatives/registration.js +14 -6
  118. package/dist/derivatives/registration.js.map +1 -1
  119. package/dist/derivatives/scheduler.d.ts +39 -9
  120. package/dist/derivatives/scheduler.d.ts.map +1 -1
  121. package/dist/derivatives/scheduler.js +99 -8
  122. package/dist/derivatives/scheduler.js.map +1 -1
  123. package/dist/derivatives/store.d.ts.map +1 -1
  124. package/dist/derivatives/store.js +2 -0
  125. package/dist/derivatives/store.js.map +1 -1
  126. package/dist/derivatives/types.d.ts +13 -3
  127. package/dist/derivatives/types.d.ts.map +1 -1
  128. package/dist/derivatives/types.js +2 -0
  129. package/dist/derivatives/types.js.map +1 -1
  130. package/dist/errors/pdpp-catalog.d.ts +36 -0
  131. package/dist/errors/pdpp-catalog.d.ts.map +1 -0
  132. package/dist/errors/pdpp-catalog.js +86 -0
  133. package/dist/errors/pdpp-catalog.js.map +1 -0
  134. package/dist/grants/index.d.ts +2 -0
  135. package/dist/grants/index.d.ts.map +1 -1
  136. package/dist/grants/index.js +4 -0
  137. package/dist/grants/index.js.map +1 -1
  138. package/dist/grants/pdpp-binding-store.d.ts +89 -0
  139. package/dist/grants/pdpp-binding-store.d.ts.map +1 -0
  140. package/dist/grants/pdpp-binding-store.js +112 -0
  141. package/dist/grants/pdpp-binding-store.js.map +1 -0
  142. package/dist/grants/pdpp-binding.d.ts +169 -0
  143. package/dist/grants/pdpp-binding.d.ts.map +1 -0
  144. package/dist/grants/pdpp-binding.js +236 -0
  145. package/dist/grants/pdpp-binding.js.map +1 -0
  146. package/dist/legacy-projection/bindings.d.ts +31 -0
  147. package/dist/legacy-projection/bindings.d.ts.map +1 -0
  148. package/dist/legacy-projection/bindings.js +4512 -0
  149. package/dist/legacy-projection/bindings.js.map +1 -0
  150. package/dist/legacy-projection/claude-source-record.d.ts +22 -0
  151. package/dist/legacy-projection/claude-source-record.d.ts.map +1 -0
  152. package/dist/legacy-projection/claude-source-record.js +360 -0
  153. package/dist/legacy-projection/claude-source-record.js.map +1 -0
  154. package/dist/legacy-projection/declared-text.d.ts +41 -0
  155. package/dist/legacy-projection/declared-text.d.ts.map +1 -0
  156. package/dist/legacy-projection/declared-text.js +199 -0
  157. package/dist/legacy-projection/declared-text.js.map +1 -0
  158. package/dist/legacy-projection/github-browser-bindings.d.ts +3 -0
  159. package/dist/legacy-projection/github-browser-bindings.d.ts.map +1 -0
  160. package/dist/legacy-projection/github-browser-bindings.js +212 -0
  161. package/dist/legacy-projection/github-browser-bindings.js.map +1 -0
  162. package/dist/legacy-projection/github-legacy-fields.d.ts +6 -0
  163. package/dist/legacy-projection/github-legacy-fields.d.ts.map +1 -0
  164. package/dist/legacy-projection/github-legacy-fields.js +202 -0
  165. package/dist/legacy-projection/github-legacy-fields.js.map +1 -0
  166. package/dist/legacy-projection/index.d.ts +38 -0
  167. package/dist/legacy-projection/index.d.ts.map +1 -0
  168. package/dist/legacy-projection/index.js +231 -0
  169. package/dist/legacy-projection/index.js.map +1 -0
  170. package/dist/legacy-projection/meta-040-bindings.d.ts +3 -0
  171. package/dist/legacy-projection/meta-040-bindings.d.ts.map +1 -0
  172. package/dist/legacy-projection/meta-040-bindings.js +112 -0
  173. package/dist/legacy-projection/meta-040-bindings.js.map +1 -0
  174. package/dist/legacy-projection/oura-browser-bindings.d.ts +5 -0
  175. package/dist/legacy-projection/oura-browser-bindings.d.ts.map +1 -0
  176. package/dist/legacy-projection/oura-browser-bindings.js +141 -0
  177. package/dist/legacy-projection/oura-browser-bindings.js.map +1 -0
  178. package/dist/legacy-projection/provenance.d.ts +57 -0
  179. package/dist/legacy-projection/provenance.d.ts.map +1 -0
  180. package/dist/legacy-projection/provenance.js +2 -0
  181. package/dist/legacy-projection/provenance.js.map +1 -0
  182. package/dist/legacy-projection/strava-browser-bindings.d.ts +3 -0
  183. package/dist/legacy-projection/strava-browser-bindings.d.ts.map +1 -0
  184. package/dist/legacy-projection/strava-browser-bindings.js +32 -0
  185. package/dist/legacy-projection/strava-browser-bindings.js.map +1 -0
  186. package/dist/legacy-projection/test-debris.d.ts +2 -0
  187. package/dist/legacy-projection/test-debris.d.ts.map +1 -0
  188. package/dist/legacy-projection/test-debris.js +49 -0
  189. package/dist/legacy-projection/test-debris.js.map +1 -0
  190. package/dist/legacy-projection/types.d.ts +235 -0
  191. package/dist/legacy-projection/types.d.ts.map +1 -0
  192. package/dist/legacy-projection/types.js +2 -0
  193. package/dist/legacy-projection/types.js.map +1 -0
  194. package/dist/mcp/approval-url.d.ts +68 -0
  195. package/dist/mcp/approval-url.d.ts.map +1 -0
  196. package/dist/mcp/approval-url.js +95 -0
  197. package/dist/mcp/approval-url.js.map +1 -0
  198. package/dist/mcp/connection-api.d.ts +187 -3
  199. package/dist/mcp/connection-api.d.ts.map +1 -1
  200. package/dist/mcp/connection-api.js +600 -26
  201. package/dist/mcp/connection-api.js.map +1 -1
  202. package/dist/mcp/grantee.d.ts +1 -1
  203. package/dist/mcp/grantee.d.ts.map +1 -1
  204. package/dist/mcp/index.d.ts +4 -0
  205. package/dist/mcp/index.d.ts.map +1 -1
  206. package/dist/mcp/index.js +4 -0
  207. package/dist/mcp/index.js.map +1 -1
  208. package/dist/mcp/oauth-redirect.d.ts +14 -0
  209. package/dist/mcp/oauth-redirect.d.ts.map +1 -0
  210. package/dist/mcp/oauth-redirect.js +51 -0
  211. package/dist/mcp/oauth-redirect.js.map +1 -0
  212. package/dist/mcp/read-client.d.ts +5 -1
  213. package/dist/mcp/read-client.d.ts.map +1 -1
  214. package/dist/mcp/read-client.js +18 -4
  215. package/dist/mcp/read-client.js.map +1 -1
  216. package/dist/mcp/resources.d.ts.map +1 -1
  217. package/dist/mcp/resources.js +3 -0
  218. package/dist/mcp/resources.js.map +1 -1
  219. package/dist/mcp/server.d.ts +30 -0
  220. package/dist/mcp/server.d.ts.map +1 -1
  221. package/dist/mcp/server.js +172 -17
  222. package/dist/mcp/server.js.map +1 -1
  223. package/dist/mcp/session.d.ts +1 -1
  224. package/dist/mcp/session.d.ts.map +1 -1
  225. package/dist/mcp/session.js +17 -3
  226. package/dist/mcp/session.js.map +1 -1
  227. package/dist/mcp/store.d.ts +10 -1
  228. package/dist/mcp/store.d.ts.map +1 -1
  229. package/dist/mcp/store.js +72 -0
  230. package/dist/mcp/store.js.map +1 -1
  231. package/dist/mcp/token-expiry.d.ts +48 -0
  232. package/dist/mcp/token-expiry.d.ts.map +1 -0
  233. package/dist/mcp/token-expiry.js +69 -0
  234. package/dist/mcp/token-expiry.js.map +1 -0
  235. package/dist/mcp/tools.d.ts +92 -3
  236. package/dist/mcp/tools.d.ts.map +1 -1
  237. package/dist/mcp/tools.js +513 -28
  238. package/dist/mcp/tools.js.map +1 -1
  239. package/dist/mcp/types.d.ts +103 -4
  240. package/dist/mcp/types.d.ts.map +1 -1
  241. package/dist/mcp/types.js +13 -1
  242. package/dist/mcp/types.js.map +1 -1
  243. package/dist/mcp/write-client.d.ts +81 -0
  244. package/dist/mcp/write-client.d.ts.map +1 -0
  245. package/dist/mcp/write-client.js +140 -0
  246. package/dist/mcp/write-client.js.map +1 -0
  247. package/dist/oura/history-policy.d.ts +12 -0
  248. package/dist/oura/history-policy.d.ts.map +1 -0
  249. package/dist/oura/history-policy.js +54 -0
  250. package/dist/oura/history-policy.js.map +1 -0
  251. package/dist/oura/index.d.ts +51 -0
  252. package/dist/oura/index.d.ts.map +1 -0
  253. package/dist/oura/index.js +315 -0
  254. package/dist/oura/index.js.map +1 -0
  255. package/dist/payment/own-app.d.ts +8 -0
  256. package/dist/payment/own-app.d.ts.map +1 -0
  257. package/dist/payment/own-app.js +47 -0
  258. package/dist/payment/own-app.js.map +1 -0
  259. package/dist/pdpp/approval.d.ts +271 -0
  260. package/dist/pdpp/approval.d.ts.map +1 -0
  261. package/dist/pdpp/approval.js +486 -0
  262. package/dist/pdpp/approval.js.map +1 -0
  263. package/dist/pdpp/client-identity.d.ts +88 -0
  264. package/dist/pdpp/client-identity.d.ts.map +1 -0
  265. package/dist/pdpp/client-identity.js +196 -0
  266. package/dist/pdpp/client-identity.js.map +1 -0
  267. package/dist/pdpp/client-metadata.d.ts +95 -0
  268. package/dist/pdpp/client-metadata.d.ts.map +1 -0
  269. package/dist/pdpp/client-metadata.js +96 -0
  270. package/dist/pdpp/client-metadata.js.map +1 -0
  271. package/dist/pdpp/commitments.d.ts +75 -0
  272. package/dist/pdpp/commitments.d.ts.map +1 -0
  273. package/dist/pdpp/commitments.js +113 -0
  274. package/dist/pdpp/commitments.js.map +1 -0
  275. package/dist/pdpp/declaration-limits.d.ts +7 -0
  276. package/dist/pdpp/declaration-limits.d.ts.map +1 -0
  277. package/dist/pdpp/declaration-limits.js +7 -0
  278. package/dist/pdpp/declaration-limits.js.map +1 -0
  279. package/dist/pdpp/declaration.d.ts +119 -0
  280. package/dist/pdpp/declaration.d.ts.map +1 -0
  281. package/dist/pdpp/declaration.js +837 -0
  282. package/dist/pdpp/declaration.js.map +1 -0
  283. package/dist/pdpp/index.d.ts +38 -0
  284. package/dist/pdpp/index.d.ts.map +1 -0
  285. package/dist/pdpp/index.js +24 -0
  286. package/dist/pdpp/index.js.map +1 -0
  287. package/dist/pdpp/issuance.d.ts +126 -0
  288. package/dist/pdpp/issuance.d.ts.map +1 -0
  289. package/dist/pdpp/issuance.js +184 -0
  290. package/dist/pdpp/issuance.js.map +1 -0
  291. package/dist/pdpp/pkce.d.ts +53 -0
  292. package/dist/pdpp/pkce.d.ts.map +1 -0
  293. package/dist/pdpp/pkce.js +109 -0
  294. package/dist/pdpp/pkce.js.map +1 -0
  295. package/dist/pdpp/redirect.d.ts +60 -0
  296. package/dist/pdpp/redirect.d.ts.map +1 -0
  297. package/dist/pdpp/redirect.js +125 -0
  298. package/dist/pdpp/redirect.js.map +1 -0
  299. package/dist/pdpp/resolve.d.ts +120 -0
  300. package/dist/pdpp/resolve.d.ts.map +1 -0
  301. package/dist/pdpp/resolve.js +491 -0
  302. package/dist/pdpp/resolve.js.map +1 -0
  303. package/dist/pdpp/review.d.ts +280 -0
  304. package/dist/pdpp/review.d.ts.map +1 -0
  305. package/dist/pdpp/review.js +205 -0
  306. package/dist/pdpp/review.js.map +1 -0
  307. package/dist/pdpp/selection.d.ts +79 -0
  308. package/dist/pdpp/selection.d.ts.map +1 -0
  309. package/dist/pdpp/selection.js +493 -0
  310. package/dist/pdpp/selection.js.map +1 -0
  311. package/dist/pdpp/store.d.ts +228 -0
  312. package/dist/pdpp/store.d.ts.map +1 -0
  313. package/dist/pdpp/store.js +542 -0
  314. package/dist/pdpp/store.js.map +1 -0
  315. package/dist/pdpp/time.d.ts +39 -0
  316. package/dist/pdpp/time.d.ts.map +1 -0
  317. package/dist/pdpp/time.js +173 -0
  318. package/dist/pdpp/time.js.map +1 -0
  319. package/dist/pdpp/tokens.d.ts +181 -0
  320. package/dist/pdpp/tokens.d.ts.map +1 -0
  321. package/dist/pdpp/tokens.js +421 -0
  322. package/dist/pdpp/tokens.js.map +1 -0
  323. package/dist/pdpp/types.d.ts +457 -0
  324. package/dist/pdpp/types.d.ts.map +1 -0
  325. package/dist/pdpp/types.js +68 -0
  326. package/dist/pdpp/types.js.map +1 -0
  327. package/dist/pdpp-version.d.ts +28 -0
  328. package/dist/pdpp-version.d.ts.map +1 -0
  329. package/dist/pdpp-version.js +28 -0
  330. package/dist/pdpp-version.js.map +1 -0
  331. package/dist/policy/data-read.d.ts +52 -1
  332. package/dist/policy/data-read.d.ts.map +1 -1
  333. package/dist/policy/data-read.js +157 -3
  334. package/dist/policy/data-read.js.map +1 -1
  335. package/dist/policy/data-write.d.ts.map +1 -1
  336. package/dist/policy/data-write.js +18 -1
  337. package/dist/policy/data-write.js.map +1 -1
  338. package/dist/policy/index.d.ts +2 -1
  339. package/dist/policy/index.d.ts.map +1 -1
  340. package/dist/policy/index.js +2 -1
  341. package/dist/policy/index.js.map +1 -1
  342. package/dist/policy/reserved-scopes.d.ts +10 -0
  343. package/dist/policy/reserved-scopes.d.ts.map +1 -0
  344. package/dist/policy/reserved-scopes.js +16 -0
  345. package/dist/policy/reserved-scopes.js.map +1 -0
  346. package/dist/ports/index.d.ts +266 -5
  347. package/dist/ports/index.d.ts.map +1 -1
  348. package/dist/ports/index.js.map +1 -1
  349. package/dist/ports/pdpp-auth.d.ts +119 -0
  350. package/dist/ports/pdpp-auth.d.ts.map +1 -0
  351. package/dist/ports/pdpp-auth.js +46 -0
  352. package/dist/ports/pdpp-auth.js.map +1 -0
  353. package/dist/ports/pdpp-auth.test-utils.d.ts +9 -0
  354. package/dist/ports/pdpp-auth.test-utils.d.ts.map +1 -0
  355. package/dist/ports/pdpp-auth.test-utils.js +18 -0
  356. package/dist/ports/pdpp-auth.test-utils.js.map +1 -0
  357. package/dist/publication/publish.d.ts +109 -0
  358. package/dist/publication/publish.d.ts.map +1 -0
  359. package/dist/publication/publish.js +263 -0
  360. package/dist/publication/publish.js.map +1 -0
  361. package/dist/replication/completion.d.ts +20 -0
  362. package/dist/replication/completion.d.ts.map +1 -0
  363. package/dist/replication/completion.js +73 -0
  364. package/dist/replication/completion.js.map +1 -0
  365. package/dist/replication/coordinator-state.d.ts +29 -0
  366. package/dist/replication/coordinator-state.d.ts.map +1 -0
  367. package/dist/replication/coordinator-state.js +88 -0
  368. package/dist/replication/coordinator-state.js.map +1 -0
  369. package/dist/replication/coordinator-state.test-utils.d.ts +32 -0
  370. package/dist/replication/coordinator-state.test-utils.d.ts.map +1 -0
  371. package/dist/replication/coordinator-state.test-utils.js +113 -0
  372. package/dist/replication/coordinator-state.test-utils.js.map +1 -0
  373. package/dist/replication/coordinator.d.ts +264 -0
  374. package/dist/replication/coordinator.d.ts.map +1 -0
  375. package/dist/replication/coordinator.js +499 -0
  376. package/dist/replication/coordinator.js.map +1 -0
  377. package/dist/replication/copies.d.ts +126 -0
  378. package/dist/replication/copies.d.ts.map +1 -0
  379. package/dist/replication/copies.js +437 -0
  380. package/dist/replication/copies.js.map +1 -0
  381. package/dist/replication/copy-promotion.d.ts +132 -0
  382. package/dist/replication/copy-promotion.d.ts.map +1 -0
  383. package/dist/replication/copy-promotion.js +126 -0
  384. package/dist/replication/copy-promotion.js.map +1 -0
  385. package/dist/replication/door.d.ts +33 -0
  386. package/dist/replication/door.d.ts.map +1 -0
  387. package/dist/replication/door.js +10 -0
  388. package/dist/replication/door.js.map +1 -0
  389. package/dist/replication/dpv2.d.ts +141 -0
  390. package/dist/replication/dpv2.d.ts.map +1 -0
  391. package/dist/replication/dpv2.js +320 -0
  392. package/dist/replication/dpv2.js.map +1 -0
  393. package/dist/replication/effects.d.ts +68 -0
  394. package/dist/replication/effects.d.ts.map +1 -0
  395. package/dist/replication/effects.js +89 -0
  396. package/dist/replication/effects.js.map +1 -0
  397. package/dist/replication/engine.d.ts +378 -0
  398. package/dist/replication/engine.d.ts.map +1 -0
  399. package/dist/replication/engine.js +3197 -0
  400. package/dist/replication/engine.js.map +1 -0
  401. package/dist/replication/envelope.d.ts +481 -0
  402. package/dist/replication/envelope.d.ts.map +1 -0
  403. package/dist/replication/envelope.js +192 -0
  404. package/dist/replication/envelope.js.map +1 -0
  405. package/dist/replication/evidence.d.ts +118 -0
  406. package/dist/replication/evidence.d.ts.map +1 -0
  407. package/dist/replication/evidence.js +198 -0
  408. package/dist/replication/evidence.js.map +1 -0
  409. package/dist/replication/finality.d.ts +16 -0
  410. package/dist/replication/finality.d.ts.map +1 -0
  411. package/dist/replication/finality.js +11 -0
  412. package/dist/replication/finality.js.map +1 -0
  413. package/dist/replication/fixtures.d.ts +16 -0
  414. package/dist/replication/fixtures.d.ts.map +1 -0
  415. package/dist/replication/fixtures.js +47 -0
  416. package/dist/replication/fixtures.js.map +1 -0
  417. package/dist/replication/host-config.d.ts +52 -0
  418. package/dist/replication/host-config.d.ts.map +1 -0
  419. package/dist/replication/host-config.js +111 -0
  420. package/dist/replication/host-config.js.map +1 -0
  421. package/dist/replication/host-driver.d.ts +95 -0
  422. package/dist/replication/host-driver.d.ts.map +1 -0
  423. package/dist/replication/host-driver.js +202 -0
  424. package/dist/replication/host-driver.js.map +1 -0
  425. package/dist/replication/host-ports.d.ts +48 -0
  426. package/dist/replication/host-ports.d.ts.map +1 -0
  427. package/dist/replication/host-ports.js +69 -0
  428. package/dist/replication/host-ports.js.map +1 -0
  429. package/dist/replication/identity.d.ts +13 -0
  430. package/dist/replication/identity.d.ts.map +1 -0
  431. package/dist/replication/identity.js +22 -0
  432. package/dist/replication/identity.js.map +1 -0
  433. package/dist/replication/limits.d.ts +124 -0
  434. package/dist/replication/limits.d.ts.map +1 -0
  435. package/dist/replication/limits.js +182 -0
  436. package/dist/replication/limits.js.map +1 -0
  437. package/dist/replication/merge-plan.d.ts +92 -0
  438. package/dist/replication/merge-plan.d.ts.map +1 -0
  439. package/dist/replication/merge-plan.js +229 -0
  440. package/dist/replication/merge-plan.js.map +1 -0
  441. package/dist/replication/namespace.d.ts +4 -0
  442. package/dist/replication/namespace.d.ts.map +1 -0
  443. package/dist/replication/namespace.js +7 -0
  444. package/dist/replication/namespace.js.map +1 -0
  445. package/dist/replication/outcome.d.ts +178 -0
  446. package/dist/replication/outcome.d.ts.map +1 -0
  447. package/dist/replication/outcome.js +83 -0
  448. package/dist/replication/outcome.js.map +1 -0
  449. package/dist/replication/payload.d.ts +39 -0
  450. package/dist/replication/payload.d.ts.map +1 -0
  451. package/dist/replication/payload.js +137 -0
  452. package/dist/replication/payload.js.map +1 -0
  453. package/dist/replication/preparation.d.ts +42 -0
  454. package/dist/replication/preparation.d.ts.map +1 -0
  455. package/dist/replication/preparation.js +118 -0
  456. package/dist/replication/preparation.js.map +1 -0
  457. package/dist/replication/rebaseline.d.ts +33 -0
  458. package/dist/replication/rebaseline.d.ts.map +1 -0
  459. package/dist/replication/rebaseline.js +40 -0
  460. package/dist/replication/rebaseline.js.map +1 -0
  461. package/dist/replication/rebinding.d.ts +43 -0
  462. package/dist/replication/rebinding.d.ts.map +1 -0
  463. package/dist/replication/rebinding.js +52 -0
  464. package/dist/replication/rebinding.js.map +1 -0
  465. package/dist/replication/receive.d.ts +57 -0
  466. package/dist/replication/receive.d.ts.map +1 -0
  467. package/dist/replication/receive.js +114 -0
  468. package/dist/replication/receive.js.map +1 -0
  469. package/dist/replication/record-reducer.d.ts +16 -0
  470. package/dist/replication/record-reducer.d.ts.map +1 -0
  471. package/dist/replication/record-reducer.js +52 -0
  472. package/dist/replication/record-reducer.js.map +1 -0
  473. package/dist/replication/revision.d.ts +24 -0
  474. package/dist/replication/revision.d.ts.map +1 -0
  475. package/dist/replication/revision.js +35 -0
  476. package/dist/replication/revision.js.map +1 -0
  477. package/dist/replication/roster.d.ts +53 -0
  478. package/dist/replication/roster.d.ts.map +1 -0
  479. package/dist/replication/roster.js +115 -0
  480. package/dist/replication/roster.js.map +1 -0
  481. package/dist/replication/schedule.d.ts +73 -0
  482. package/dist/replication/schedule.d.ts.map +1 -0
  483. package/dist/replication/schedule.js +182 -0
  484. package/dist/replication/schedule.js.map +1 -0
  485. package/dist/replication/stream.d.ts +73 -0
  486. package/dist/replication/stream.d.ts.map +1 -0
  487. package/dist/replication/stream.js +542 -0
  488. package/dist/replication/stream.js.map +1 -0
  489. package/dist/replication/transport.d.ts +236 -0
  490. package/dist/replication/transport.d.ts.map +1 -0
  491. package/dist/replication/transport.js +440 -0
  492. package/dist/replication/transport.js.map +1 -0
  493. package/dist/replication/visibility-engine.d.ts +337 -0
  494. package/dist/replication/visibility-engine.d.ts.map +1 -0
  495. package/dist/replication/visibility-engine.js +602 -0
  496. package/dist/replication/visibility-engine.js.map +1 -0
  497. package/dist/replication/visibility-policy.d.ts +26 -0
  498. package/dist/replication/visibility-policy.d.ts.map +1 -0
  499. package/dist/replication/visibility-policy.js +33 -0
  500. package/dist/replication/visibility-policy.js.map +1 -0
  501. package/dist/replication/writer-identity-store.d.ts +100 -0
  502. package/dist/replication/writer-identity-store.d.ts.map +1 -0
  503. package/dist/replication/writer-identity-store.js +218 -0
  504. package/dist/replication/writer-identity-store.js.map +1 -0
  505. package/dist/replication/writer-identity.d.ts +252 -0
  506. package/dist/replication/writer-identity.d.ts.map +1 -0
  507. package/dist/replication/writer-identity.js +281 -0
  508. package/dist/replication/writer-identity.js.map +1 -0
  509. package/dist/replication/writer-identity.test-utils.d.ts +24 -0
  510. package/dist/replication/writer-identity.test-utils.d.ts.map +1 -0
  511. package/dist/replication/writer-identity.test-utils.js +86 -0
  512. package/dist/replication/writer-identity.test-utils.js.map +1 -0
  513. package/dist/schemas/server-config.d.ts +71 -0
  514. package/dist/schemas/server-config.d.ts.map +1 -1
  515. package/dist/schemas/server-config.js +151 -0
  516. package/dist/schemas/server-config.js.map +1 -1
  517. package/dist/signing/request-signer.d.ts +2 -0
  518. package/dist/signing/request-signer.d.ts.map +1 -1
  519. package/dist/signing/request-signer.js +1 -0
  520. package/dist/signing/request-signer.js.map +1 -1
  521. package/dist/storage/adapters/index.d.ts +3 -1
  522. package/dist/storage/adapters/index.d.ts.map +1 -1
  523. package/dist/storage/adapters/index.js +2 -0
  524. package/dist/storage/adapters/index.js.map +1 -1
  525. package/dist/storage/adapters/interface.d.ts +21 -1
  526. package/dist/storage/adapters/interface.d.ts.map +1 -1
  527. package/dist/storage/adapters/interface.js +13 -1
  528. package/dist/storage/adapters/interface.js.map +1 -1
  529. package/dist/storage/adapters/sdk.d.ts +2 -1
  530. package/dist/storage/adapters/sdk.d.ts.map +1 -1
  531. package/dist/storage/adapters/sdk.js +21 -3
  532. package/dist/storage/adapters/sdk.js.map +1 -1
  533. package/dist/storage/adapters/vana-audience.d.ts +24 -0
  534. package/dist/storage/adapters/vana-audience.d.ts.map +1 -0
  535. package/dist/storage/adapters/vana-audience.js +87 -0
  536. package/dist/storage/adapters/vana-audience.js.map +1 -0
  537. package/dist/storage/adapters/vana.d.ts +5 -3
  538. package/dist/storage/adapters/vana.d.ts.map +1 -1
  539. package/dist/storage/adapters/vana.js +69 -23
  540. package/dist/storage/adapters/vana.js.map +1 -1
  541. package/dist/storage/blocks/cursor.d.ts +5 -1
  542. package/dist/storage/blocks/cursor.d.ts.map +1 -1
  543. package/dist/storage/blocks/cursor.js +13 -1
  544. package/dist/storage/blocks/cursor.js.map +1 -1
  545. package/dist/storage/blocks/page.d.ts +18 -0
  546. package/dist/storage/blocks/page.d.ts.map +1 -0
  547. package/dist/storage/blocks/page.js +113 -0
  548. package/dist/storage/blocks/page.js.map +1 -0
  549. package/dist/storage/canonical-legacy-projection.d.ts +262 -0
  550. package/dist/storage/canonical-legacy-projection.d.ts.map +1 -0
  551. package/dist/storage/canonical-legacy-projection.js +759 -0
  552. package/dist/storage/canonical-legacy-projection.js.map +1 -0
  553. package/dist/storage/hierarchy/paths.d.ts.map +1 -1
  554. package/dist/storage/hierarchy/paths.js +9 -2
  555. package/dist/storage/hierarchy/paths.js.map +1 -1
  556. package/dist/storage/index/manager.d.ts +30 -3
  557. package/dist/storage/index/manager.d.ts.map +1 -1
  558. package/dist/storage/index/schema.d.ts +1 -1
  559. package/dist/storage/index/schema.js +1 -1
  560. package/dist/storage/index/types.d.ts +7 -1
  561. package/dist/storage/index/types.d.ts.map +1 -1
  562. package/dist/storage/legacy-projection.d.ts +88 -0
  563. package/dist/storage/legacy-projection.d.ts.map +1 -0
  564. package/dist/storage/legacy-projection.js +755 -0
  565. package/dist/storage/legacy-projection.js.map +1 -0
  566. package/dist/storage/legacy-scope-coverage-exceptions.d.ts +13 -0
  567. package/dist/storage/legacy-scope-coverage-exceptions.d.ts.map +1 -0
  568. package/dist/storage/legacy-scope-coverage-exceptions.js +14 -0
  569. package/dist/storage/legacy-scope-coverage-exceptions.js.map +1 -0
  570. package/dist/storage/legacy-scope-coverage.d.ts +53 -0
  571. package/dist/storage/legacy-scope-coverage.d.ts.map +1 -0
  572. package/dist/storage/legacy-scope-coverage.js +416 -0
  573. package/dist/storage/legacy-scope-coverage.js.map +1 -0
  574. package/dist/storage/legacy-scope-entity-keys.d.ts +17 -0
  575. package/dist/storage/legacy-scope-entity-keys.d.ts.map +1 -0
  576. package/dist/storage/legacy-scope-entity-keys.js +109 -0
  577. package/dist/storage/legacy-scope-entity-keys.js.map +1 -0
  578. package/dist/storage/legacy-scope-view.d.ts +206 -0
  579. package/dist/storage/legacy-scope-view.d.ts.map +1 -0
  580. package/dist/storage/legacy-scope-view.js +1061 -0
  581. package/dist/storage/legacy-scope-view.js.map +1 -0
  582. package/dist/storage/pdpp-records/completion.d.ts +91 -0
  583. package/dist/storage/pdpp-records/completion.d.ts.map +1 -0
  584. package/dist/storage/pdpp-records/completion.js +170 -0
  585. package/dist/storage/pdpp-records/completion.js.map +1 -0
  586. package/dist/storage/pdpp-records/cursor.d.ts +86 -0
  587. package/dist/storage/pdpp-records/cursor.d.ts.map +1 -0
  588. package/dist/storage/pdpp-records/cursor.js +56 -0
  589. package/dist/storage/pdpp-records/cursor.js.map +1 -0
  590. package/dist/storage/pdpp-records/declaration-witness.d.ts +58 -0
  591. package/dist/storage/pdpp-records/declaration-witness.d.ts.map +1 -0
  592. package/dist/storage/pdpp-records/declaration-witness.js +230 -0
  593. package/dist/storage/pdpp-records/declaration-witness.js.map +1 -0
  594. package/dist/storage/pdpp-records/enforcement.d.ts +39 -0
  595. package/dist/storage/pdpp-records/enforcement.d.ts.map +1 -0
  596. package/dist/storage/pdpp-records/enforcement.js +143 -0
  597. package/dist/storage/pdpp-records/enforcement.js.map +1 -0
  598. package/dist/storage/pdpp-records/index.d.ts +7 -0
  599. package/dist/storage/pdpp-records/index.d.ts.map +1 -0
  600. package/dist/storage/pdpp-records/index.js +6 -0
  601. package/dist/storage/pdpp-records/index.js.map +1 -0
  602. package/dist/storage/pdpp-records/ingest-plan.d.ts +39 -0
  603. package/dist/storage/pdpp-records/ingest-plan.d.ts.map +1 -0
  604. package/dist/storage/pdpp-records/ingest-plan.js +103 -0
  605. package/dist/storage/pdpp-records/ingest-plan.js.map +1 -0
  606. package/dist/storage/pdpp-records/interface.d.ts +111 -0
  607. package/dist/storage/pdpp-records/interface.d.ts.map +1 -0
  608. package/dist/storage/pdpp-records/interface.js +2 -0
  609. package/dist/storage/pdpp-records/interface.js.map +1 -0
  610. package/dist/storage/pdpp-records/list-page.d.ts +35 -0
  611. package/dist/storage/pdpp-records/list-page.d.ts.map +1 -0
  612. package/dist/storage/pdpp-records/list-page.js +106 -0
  613. package/dist/storage/pdpp-records/list-page.js.map +1 -0
  614. package/dist/storage/pdpp-records/memory-store.d.ts +9 -0
  615. package/dist/storage/pdpp-records/memory-store.d.ts.map +1 -0
  616. package/dist/storage/pdpp-records/memory-store.js +462 -0
  617. package/dist/storage/pdpp-records/memory-store.js.map +1 -0
  618. package/dist/storage/pdpp-records/portable.d.ts +12 -0
  619. package/dist/storage/pdpp-records/portable.d.ts.map +1 -0
  620. package/dist/storage/pdpp-records/portable.js +11 -0
  621. package/dist/storage/pdpp-records/portable.js.map +1 -0
  622. package/dist/storage/pdpp-records/read-port.d.ts +44 -0
  623. package/dist/storage/pdpp-records/read-port.d.ts.map +1 -0
  624. package/dist/storage/pdpp-records/read-port.js +22 -0
  625. package/dist/storage/pdpp-records/read-port.js.map +1 -0
  626. package/dist/storage/pdpp-records/record-key.d.ts +52 -0
  627. package/dist/storage/pdpp-records/record-key.d.ts.map +1 -0
  628. package/dist/storage/pdpp-records/record-key.js +97 -0
  629. package/dist/storage/pdpp-records/record-key.js.map +1 -0
  630. package/dist/storage/pdpp-records/replication-journal.d.ts +20 -0
  631. package/dist/storage/pdpp-records/replication-journal.d.ts.map +1 -0
  632. package/dist/storage/pdpp-records/replication-journal.js +2 -0
  633. package/dist/storage/pdpp-records/replication-journal.js.map +1 -0
  634. package/dist/storage/pdpp-records/schema.d.ts +41 -0
  635. package/dist/storage/pdpp-records/schema.d.ts.map +1 -0
  636. package/dist/storage/pdpp-records/schema.js +153 -0
  637. package/dist/storage/pdpp-records/schema.js.map +1 -0
  638. package/dist/storage/pdpp-records/stream-declaration.d.ts +86 -0
  639. package/dist/storage/pdpp-records/stream-declaration.d.ts.map +1 -0
  640. package/dist/storage/pdpp-records/stream-declaration.js +48 -0
  641. package/dist/storage/pdpp-records/stream-declaration.js.map +1 -0
  642. package/dist/storage/pdpp-records/sync-selection.d.ts +4 -0
  643. package/dist/storage/pdpp-records/sync-selection.d.ts.map +1 -0
  644. package/dist/storage/pdpp-records/sync-selection.js +37 -0
  645. package/dist/storage/pdpp-records/sync-selection.js.map +1 -0
  646. package/dist/storage/pdpp-records/types.d.ts +202 -0
  647. package/dist/storage/pdpp-records/types.d.ts.map +1 -0
  648. package/dist/storage/pdpp-records/types.js +38 -0
  649. package/dist/storage/pdpp-records/types.js.map +1 -0
  650. package/dist/stream-sync/artifacts.d.ts +31 -0
  651. package/dist/stream-sync/artifacts.d.ts.map +1 -0
  652. package/dist/stream-sync/artifacts.js +106 -0
  653. package/dist/stream-sync/artifacts.js.map +1 -0
  654. package/dist/stream-sync/blobs.d.ts +11 -0
  655. package/dist/stream-sync/blobs.d.ts.map +1 -0
  656. package/dist/stream-sync/blobs.js +34 -0
  657. package/dist/stream-sync/blobs.js.map +1 -0
  658. package/dist/stream-sync/crypto.d.ts +21 -0
  659. package/dist/stream-sync/crypto.d.ts.map +1 -0
  660. package/dist/stream-sync/crypto.js +45 -0
  661. package/dist/stream-sync/crypto.js.map +1 -0
  662. package/dist/stream-sync/home.d.ts +46 -0
  663. package/dist/stream-sync/home.d.ts.map +1 -0
  664. package/dist/stream-sync/home.js +37 -0
  665. package/dist/stream-sync/home.js.map +1 -0
  666. package/dist/stream-sync/index.d.ts +14 -0
  667. package/dist/stream-sync/index.d.ts.map +1 -0
  668. package/dist/stream-sync/index.js +14 -0
  669. package/dist/stream-sync/index.js.map +1 -0
  670. package/dist/stream-sync/intake.d.ts +165 -0
  671. package/dist/stream-sync/intake.d.ts.map +1 -0
  672. package/dist/stream-sync/intake.js +467 -0
  673. package/dist/stream-sync/intake.js.map +1 -0
  674. package/dist/stream-sync/io-barrier.d.ts +39 -0
  675. package/dist/stream-sync/io-barrier.d.ts.map +1 -0
  676. package/dist/stream-sync/io-barrier.js +130 -0
  677. package/dist/stream-sync/io-barrier.js.map +1 -0
  678. package/dist/stream-sync/memory-files.d.ts +6 -0
  679. package/dist/stream-sync/memory-files.d.ts.map +1 -0
  680. package/dist/stream-sync/memory-files.js +50 -0
  681. package/dist/stream-sync/memory-files.js.map +1 -0
  682. package/dist/stream-sync/ports.d.ts +134 -0
  683. package/dist/stream-sync/ports.d.ts.map +1 -0
  684. package/dist/stream-sync/ports.js +26 -0
  685. package/dist/stream-sync/ports.js.map +1 -0
  686. package/dist/stream-sync/publish-plan.d.ts +157 -0
  687. package/dist/stream-sync/publish-plan.d.ts.map +1 -0
  688. package/dist/stream-sync/publish-plan.js +212 -0
  689. package/dist/stream-sync/publish-plan.js.map +1 -0
  690. package/dist/stream-sync/registry.d.ts +19 -0
  691. package/dist/stream-sync/registry.d.ts.map +1 -0
  692. package/dist/stream-sync/registry.js +125 -0
  693. package/dist/stream-sync/registry.js.map +1 -0
  694. package/dist/stream-sync/scope-routing.d.ts +17 -0
  695. package/dist/stream-sync/scope-routing.d.ts.map +1 -0
  696. package/dist/stream-sync/scope-routing.js +24 -0
  697. package/dist/stream-sync/scope-routing.js.map +1 -0
  698. package/dist/stream-sync/spool.d.ts +69 -0
  699. package/dist/stream-sync/spool.d.ts.map +1 -0
  700. package/dist/stream-sync/spool.js +197 -0
  701. package/dist/stream-sync/spool.js.map +1 -0
  702. package/dist/stream-sync/writer-overlay.d.ts +19 -0
  703. package/dist/stream-sync/writer-overlay.d.ts.map +1 -0
  704. package/dist/stream-sync/writer-overlay.js +55 -0
  705. package/dist/stream-sync/writer-overlay.js.map +1 -0
  706. package/dist/stream-sync/writer.d.ts +404 -0
  707. package/dist/stream-sync/writer.d.ts.map +1 -0
  708. package/dist/stream-sync/writer.js +1994 -0
  709. package/dist/stream-sync/writer.js.map +1 -0
  710. package/dist/stream-sync-read/fold.d.ts +69 -0
  711. package/dist/stream-sync-read/fold.d.ts.map +1 -0
  712. package/dist/stream-sync-read/fold.js +83 -0
  713. package/dist/stream-sync-read/fold.js.map +1 -0
  714. package/dist/stream-sync-read/importer.d.ts +81 -0
  715. package/dist/stream-sync-read/importer.d.ts.map +1 -0
  716. package/dist/stream-sync-read/importer.js +226 -0
  717. package/dist/stream-sync-read/importer.js.map +1 -0
  718. package/dist/stream-sync-read/index.d.ts +8 -0
  719. package/dist/stream-sync-read/index.d.ts.map +1 -0
  720. package/dist/stream-sync-read/index.js +5 -0
  721. package/dist/stream-sync-read/index.js.map +1 -0
  722. package/dist/stream-sync-read/keys.d.ts +16 -0
  723. package/dist/stream-sync-read/keys.d.ts.map +1 -0
  724. package/dist/stream-sync-read/keys.js +48 -0
  725. package/dist/stream-sync-read/keys.js.map +1 -0
  726. package/dist/stream-sync-read/lines.d.ts +37 -0
  727. package/dist/stream-sync-read/lines.d.ts.map +1 -0
  728. package/dist/stream-sync-read/lines.js +98 -0
  729. package/dist/stream-sync-read/lines.js.map +1 -0
  730. package/dist/stream-sync-read/memory-files.d.ts +6 -0
  731. package/dist/stream-sync-read/memory-files.d.ts.map +1 -0
  732. package/dist/stream-sync-read/memory-files.js +34 -0
  733. package/dist/stream-sync-read/memory-files.js.map +1 -0
  734. package/dist/stream-sync-read/mirror.d.ts +80 -0
  735. package/dist/stream-sync-read/mirror.d.ts.map +1 -0
  736. package/dist/stream-sync-read/mirror.js +189 -0
  737. package/dist/stream-sync-read/mirror.js.map +1 -0
  738. package/dist/stream-sync-read/ports.d.ts +155 -0
  739. package/dist/stream-sync-read/ports.d.ts.map +1 -0
  740. package/dist/stream-sync-read/ports.js +9 -0
  741. package/dist/stream-sync-read/ports.js.map +1 -0
  742. package/dist/stream-sync-read/projection.d.ts +47 -0
  743. package/dist/stream-sync-read/projection.d.ts.map +1 -0
  744. package/dist/stream-sync-read/projection.js +338 -0
  745. package/dist/stream-sync-read/projection.js.map +1 -0
  746. package/dist/stream-sync-read/routing.d.ts +27 -0
  747. package/dist/stream-sync-read/routing.d.ts.map +1 -0
  748. package/dist/stream-sync-read/routing.js +49 -0
  749. package/dist/stream-sync-read/routing.js.map +1 -0
  750. package/dist/stream-sync-read/service-fixture.d.ts +94 -0
  751. package/dist/stream-sync-read/service-fixture.d.ts.map +1 -0
  752. package/dist/stream-sync-read/service-fixture.js +227 -0
  753. package/dist/stream-sync-read/service-fixture.js.map +1 -0
  754. package/dist/stream-sync-read/service.d.ts +260 -0
  755. package/dist/stream-sync-read/service.d.ts.map +1 -0
  756. package/dist/stream-sync-read/service.js +975 -0
  757. package/dist/stream-sync-read/service.js.map +1 -0
  758. package/dist/stream-sync-read/testing.d.ts +54 -0
  759. package/dist/stream-sync-read/testing.d.ts.map +1 -0
  760. package/dist/stream-sync-read/testing.js +80 -0
  761. package/dist/stream-sync-read/testing.js.map +1 -0
  762. package/dist/stream-sync-read/view-store.d.ts +98 -0
  763. package/dist/stream-sync-read/view-store.d.ts.map +1 -0
  764. package/dist/stream-sync-read/view-store.js +278 -0
  765. package/dist/stream-sync-read/view-store.js.map +1 -0
  766. package/dist/stream-sync-read/writer-rig.d.ts +122 -0
  767. package/dist/stream-sync-read/writer-rig.d.ts.map +1 -0
  768. package/dist/stream-sync-read/writer-rig.js +301 -0
  769. package/dist/stream-sync-read/writer-rig.js.map +1 -0
  770. package/dist/sync/data-point-feed.d.ts +3 -0
  771. package/dist/sync/data-point-feed.d.ts.map +1 -1
  772. package/dist/sync/data-point-feed.js +20 -1
  773. package/dist/sync/data-point-feed.js.map +1 -1
  774. package/dist/sync/delete-data-port.d.ts +19 -0
  775. package/dist/sync/delete-data-port.d.ts.map +1 -1
  776. package/dist/sync/delete-data-port.js +42 -9
  777. package/dist/sync/delete-data-port.js.map +1 -1
  778. package/dist/sync/engine/sync-manager.d.ts +21 -1
  779. package/dist/sync/engine/sync-manager.d.ts.map +1 -1
  780. package/dist/sync/engine/sync-manager.js +140 -11
  781. package/dist/sync/engine/sync-manager.js.map +1 -1
  782. package/dist/sync/index.d.ts +6 -2
  783. package/dist/sync/index.d.ts.map +1 -1
  784. package/dist/sync/index.js +7 -1
  785. package/dist/sync/index.js.map +1 -1
  786. package/dist/sync/pdpp-import.d.ts +192 -0
  787. package/dist/sync/pdpp-import.d.ts.map +1 -0
  788. package/dist/sync/pdpp-import.js +441 -0
  789. package/dist/sync/pdpp-import.js.map +1 -0
  790. package/dist/sync/pending-blob-deletions.d.ts +18 -2
  791. package/dist/sync/pending-blob-deletions.d.ts.map +1 -1
  792. package/dist/sync/pending-blob-deletions.js +97 -23
  793. package/dist/sync/pending-blob-deletions.js.map +1 -1
  794. package/dist/sync/scope-deletions.d.ts +12 -0
  795. package/dist/sync/scope-deletions.d.ts.map +1 -1
  796. package/dist/sync/scope-deletions.js +99 -25
  797. package/dist/sync/scope-deletions.js.map +1 -1
  798. package/dist/sync/tombstone-finality.d.ts +36 -0
  799. package/dist/sync/tombstone-finality.d.ts.map +1 -0
  800. package/dist/sync/tombstone-finality.js +142 -0
  801. package/dist/sync/tombstone-finality.js.map +1 -0
  802. package/dist/sync/tombstone-resubmits.d.ts +61 -0
  803. package/dist/sync/tombstone-resubmits.d.ts.map +1 -0
  804. package/dist/sync/tombstone-resubmits.js +85 -0
  805. package/dist/sync/tombstone-resubmits.js.map +1 -0
  806. package/dist/sync/types.d.ts +10 -0
  807. package/dist/sync/types.d.ts.map +1 -1
  808. package/dist/sync/workers/delete.d.ts +54 -5
  809. package/dist/sync/workers/delete.d.ts.map +1 -1
  810. package/dist/sync/workers/delete.js +594 -170
  811. package/dist/sync/workers/delete.js.map +1 -1
  812. package/dist/sync/workers/download.d.ts +42 -1
  813. package/dist/sync/workers/download.d.ts.map +1 -1
  814. package/dist/sync/workers/download.js +344 -24
  815. package/dist/sync/workers/download.js.map +1 -1
  816. package/dist/sync/workers/lost-data-points.d.ts +38 -0
  817. package/dist/sync/workers/lost-data-points.d.ts.map +1 -0
  818. package/dist/sync/workers/lost-data-points.js +72 -0
  819. package/dist/sync/workers/lost-data-points.js.map +1 -0
  820. package/dist/sync/workers/upload.d.ts +27 -6
  821. package/dist/sync/workers/upload.d.ts.map +1 -1
  822. package/dist/sync/workers/upload.js +169 -274
  823. package/dist/sync/workers/upload.js.map +1 -1
  824. package/dist/test-utils/memory-storage.d.ts +1 -1
  825. package/dist/test-utils/memory-storage.d.ts.map +1 -1
  826. package/dist/test-utils/memory-storage.js +83 -17
  827. package/dist/test-utils/memory-storage.js.map +1 -1
  828. package/dist/write/attribution.d.ts.map +1 -1
  829. package/dist/write/attribution.js +8 -4
  830. package/dist/write/attribution.js.map +1 -1
  831. package/dist/write/route.d.ts.map +1 -1
  832. package/dist/write/route.js +9 -10
  833. package/dist/write/route.js.map +1 -1
  834. package/dist/write/session.d.ts.map +1 -1
  835. package/dist/write/session.js +13 -0
  836. package/dist/write/session.js.map +1 -1
  837. package/package.json +103 -3
@@ -1,4 +1,8 @@
1
+ import { withScopeLock } from "../../additions/scope-lock.js";
1
2
  import { computeDataPointId } from "../data-point-id.js";
3
+ import { isGatewayReservedScope } from "../delete-data-port.js";
4
+ import { createMemoryPendingBlobDeletionStore } from "../pending-blob-deletions.js";
5
+ import { DEFAULT_TOMBSTONE_RESUBMIT_MAX_ATTEMPTS, } from "../tombstone-resubmits.js";
2
6
  import { deletionTimestamp, isEntryCoveredByTombstone, tombstoneVersion, } from "../scope-deletions.js";
3
7
  /**
4
8
  * Exact blob deletes sent per pass. vana-storage allows 30 DELETE requests
@@ -38,13 +42,71 @@ export function planBlobDeletions(storage, scope, tombstoneVersionValue) {
38
42
  range: last === null || last < 1n ? null : { from: "1", to: last.toString() },
39
43
  };
40
44
  }
45
+ /**
46
+ * Snapshot matching rows synchronously. Owner-intent capture precedes remote
47
+ * work; tombstone capture precedes blob cleanup. Later rows stay outside each fence.
48
+ */
49
+ function captureEntries(storage, scope, includes) {
50
+ const covered = [];
51
+ const PAGE_SIZE = 500;
52
+ for (let offset = 0;; offset += PAGE_SIZE) {
53
+ const entries = storage.listVersions(scope, { limit: PAGE_SIZE, offset });
54
+ for (const entry of entries) {
55
+ if (includes(entry)) {
56
+ covered.push({
57
+ id: entry.id,
58
+ path: entry.path,
59
+ collectedAt: entry.collectedAt,
60
+ afterTombstoneVersion: entry.afterTombstoneVersion,
61
+ });
62
+ }
63
+ }
64
+ if (entries.length < PAGE_SIZE)
65
+ break;
66
+ }
67
+ return covered;
68
+ }
69
+ /**
70
+ * Erase exactly the fenced versions, one at a time, each through the storage's
71
+ * fenced erase. The storage checks the row's id and path at the erase itself,
72
+ * under its own lock or transaction, so a replacement that took a fenced stamp
73
+ * after capture is left alone and reported as not erased. No snapshot is taken
74
+ * here, because a snapshot is stale by the time the erase runs.
75
+ *
76
+ * The scope's first-seen sidecar was derived from the fenced rows, so it is
77
+ * dropped after the erases, under the scope lock: a rebuild that read the old
78
+ * rows cannot write it back once this returns. The next read rebuilds it from
79
+ * the rows that survive (a re-add starts afresh there).
80
+ */
81
+ async function eraseCoveredEntries(storage, scope, fence) {
82
+ if (fence.length === 0)
83
+ return 0;
84
+ let erased = 0;
85
+ try {
86
+ for (const captured of fence) {
87
+ const removed = await storage.deleteVersion(scope, captured.collectedAt, {
88
+ id: captured.id,
89
+ path: captured.path,
90
+ });
91
+ if (removed)
92
+ erased += 1;
93
+ }
94
+ }
95
+ finally {
96
+ await withScopeLock(scope, async () => {
97
+ await storage.deleteFirstSeenLedger?.(scope);
98
+ });
99
+ }
100
+ return erased;
101
+ }
41
102
  /** Take up to `count` versions from the head of a range; `rest` is what remains. */
42
- function takeFromRange(range, count) {
103
+ function takeFromRange(range, count, cap = null) {
43
104
  const from = BigInt(range.from);
44
105
  const to = BigInt(range.to);
106
+ const last = cap !== null && cap < to ? cap : to;
45
107
  const versions = [];
46
108
  let cursor = from;
47
- while (cursor <= to && versions.length < count) {
109
+ while (cursor <= last && versions.length < count) {
48
110
  versions.push(cursor.toString());
49
111
  cursor += 1n;
50
112
  }
@@ -74,29 +136,7 @@ function countPendingKeys(markers) {
74
136
  ? Number.MAX_SAFE_INTEGER
75
137
  : Number(total);
76
138
  }
77
- /**
78
- * Durable scope deletion, in the only order that cannot resurrect data:
79
- *
80
- * 1. gateway tombstone (owner-signed AddData at current + 1; the fact)
81
- * 2. storage blobs (exact keys of every version the tombstone covers)
82
- * 3. local copy (index rows + files + sidecars)
83
- *
84
- * The local delete never runs before the gateway has acknowledged: until the
85
- * registry says "deleted", the next sync cycle would re-pull the point from
86
- * the still-live row. Step 2 deletes exact per-version keys, never the scope
87
- * prefix, so a re-add another replica lands at any time keeps its ciphertext
88
- * (it is registered above the tombstone version and stored under that key).
89
- * Keys that could not be deleted in this pass are queued as exact retry
90
- * markers; step 3 does not wait for them because the tombstone already makes
91
- * the deletion stick.
92
- *
93
- * Not serialised here: the sync manager runs this under the same lock as its
94
- * upload/download cycles so a delete cannot interleave with an upload of the
95
- * same scope on this replica (see engine/sync-manager.ts). Uploads racing on
96
- * another replica are handled by the upload worker's deletion guard and the
97
- * download worker's reconcile.
98
- */
99
- export async function deleteScope(deps, scope) {
139
+ export async function deleteScope(deps, scope, options = {}) {
100
140
  const { storage, deleteData, pendingBlobDeletions, scopeDeletions, logger } = deps;
101
141
  const now = deps.now ?? (() => new Date());
102
142
  const dataPointId = deps.serverOwner
@@ -113,14 +153,27 @@ export async function deleteScope(deps, scope) {
113
153
  },
114
154
  pendingBlobDeletion: false,
115
155
  };
156
+ // A new owner request also covers already-acknowledged local re-adds. Capture
157
+ // them before remote work; background retries never get this owner-intent fence.
158
+ const requestedReadds = deleteData
159
+ ? captureEntries(storage, scope, (entry) => entry.dataPointId === null &&
160
+ Number.isSafeInteger(entry.afterTombstoneVersion) &&
161
+ Number(entry.afterTombstoneVersion) > 0)
162
+ : [];
163
+ // Set only once a gateway tombstone has landed (see step 2).
164
+ let covered = null;
116
165
  if (deleteData) {
117
166
  // 1. Gateway tombstone: the durable fact. Nothing else happens if it
118
167
  // fails, so the owner gets a clear "nothing was deleted" instead of a
119
168
  // local delete that sync silently undoes.
120
169
  let tombstoneVersionValue = null;
121
170
  let tombstoneKnown = false;
171
+ let replacedHead = null;
122
172
  try {
123
- let outcome = await deleteData.tombstone(scope);
173
+ const tombstone = () => options.fence
174
+ ? deleteData.tombstone(scope, options.fence)
175
+ : deleteData.tombstone(scope);
176
+ let outcome = await tombstone();
124
177
  if (outcome.status === "not-registered") {
125
178
  // "Nothing to tombstone" is only durable if the registry still has
126
179
  // no row. A registration racing our lookup would otherwise survive
@@ -129,7 +182,7 @@ export async function deleteScope(deps, scope) {
129
182
  // registry cannot be asked, refuse rather than delete on a guess.
130
183
  let registry = await registryState(deps, scope);
131
184
  if (registry.status === "live") {
132
- outcome = await deleteData.tombstone(scope);
185
+ outcome = await tombstone();
133
186
  registry = await registryState(deps, scope);
134
187
  }
135
188
  if (outcome.status === "not-registered" &&
@@ -144,6 +197,9 @@ export async function deleteScope(deps, scope) {
144
197
  }
145
198
  else {
146
199
  tombstoneKnown = true;
200
+ if (outcome.status === "tombstoned") {
201
+ replacedHead = outcome.replaced ?? null;
202
+ }
147
203
  tombstoneVersionValue =
148
204
  outcome.version === null
149
205
  ? null
@@ -164,6 +220,9 @@ export async function deleteScope(deps, scope) {
164
220
  deletedAt: outcome.deletedAt ?? now().toISOString(),
165
221
  version: outcome.version,
166
222
  }, "local-delete");
223
+ // A tombstone was just queued (or re-confirmed): read its finality
224
+ // on the next pass instead of waiting out an earlier backoff.
225
+ deps.tombstoneFinality?.recheckNow?.(scope);
167
226
  }
168
227
  result.durable = true;
169
228
  }
@@ -176,31 +235,43 @@ export async function deleteScope(deps, scope) {
176
235
  return result;
177
236
  }
178
237
  // 2. Storage blobs: exact keys, one pass of at most a batch, the rest
179
- // queued. A tombstone whose version the gateway did not report cannot be
180
- // expanded into registry keys yet; a version-less marker asks the retry
181
- // to expand it once the registry answers.
182
- const plan = planBlobDeletions(storage, scope, tombstoneVersionValue);
183
- const batch = plan.keys.slice(0, BLOB_DELETE_BATCH_SIZE);
184
- const leftovers = plan.keys
185
- .slice(BLOB_DELETE_BATCH_SIZE)
186
- .map((version) => ({ scope, version }));
187
- if (plan.range) {
188
- const taken = takeFromRange(plan.range, BLOB_DELETE_BATCH_SIZE - batch.length);
189
- batch.push(...taken.versions);
190
- if (taken.rest)
191
- leftovers.push({ scope, version: null, range: taken.rest });
192
- }
193
- if (tombstoneKnown && tombstoneVersionValue === null) {
194
- leftovers.push({ scope, version: null });
238
+ // queued. A repeated delete of a scope whose cleanup is still running
239
+ // resumes from the queue: only work not taken on before is recorded, and
240
+ // the pass drains the scope's queue head, so no confirmed key is re-sent
241
+ // and no queued key is dropped. A tombstone whose version the gateway did
242
+ // not report cannot be expanded into registry keys yet; a version-less
243
+ // marker asks the retry to expand it once the registry answers.
244
+ // Fence first: the covered entries as they stand before the remote await.
245
+ covered = captureEntries(storage, scope, (entry) => isEntryCoveredByTombstone(entry, { version: tombstoneVersionValue }));
246
+ if (tombstoneVersionValue !== null) {
247
+ const anchor = BigInt(tombstoneVersionValue);
248
+ const coveredIds = new Set(covered.map((entry) => entry.id));
249
+ for (const entry of requestedReadds) {
250
+ if (typeof entry.afterTombstoneVersion === "number" &&
251
+ BigInt(entry.afterTombstoneVersion) <= anchor &&
252
+ !coveredIds.has(entry.id))
253
+ covered.push(entry);
254
+ }
195
255
  }
196
- const storageStep = await deleteBlobKeys({ deleteData, pendingBlobDeletions, logger }, scope, batch, leftovers);
256
+ const plan = planBlobDeletions(storage, scope, tombstoneVersionValue);
257
+ const storageStep = await deleteScopeBlobs({
258
+ deleteData,
259
+ pendingBlobDeletions,
260
+ tombstoneFinality: deps.tombstoneFinality,
261
+ logger,
262
+ }, scope, plan, tombstoneKnown && tombstoneVersionValue === null, options.storagePass ?? true, replacedHead);
197
263
  result.steps.storage = storageStep.step;
198
264
  result.pendingBlobDeletion = storageStep.pending > 0;
199
265
  }
200
266
  // 3. Local copy. Safe now: the registry row is a tombstone (or the point
201
- // was never registered / sync is off), so nothing can re-pull it.
267
+ // was never registered / sync is off), so nothing can re-pull it. Only the
268
+ // versions fenced by the tombstone or this owner request are erased: a
269
+ // later re-add stays outside the owner fence. With no gateway
270
+ // there is no fence and the whole local copy goes.
202
271
  try {
203
- const deletedCount = await storage.deleteScope(scope);
272
+ const deletedCount = covered
273
+ ? await eraseCoveredEntries(storage, scope, covered)
274
+ : await storage.deleteScope(scope);
204
275
  result.steps.local = { status: "ok", deletedCount };
205
276
  }
206
277
  catch (err) {
@@ -219,51 +290,329 @@ export async function deleteScope(deps, scope) {
219
290
  return result;
220
291
  }
221
292
  /**
222
- * Delete one pass worth of exact keys and reconcile the retry markers:
223
- * completed keys (deleted or already absent) leave the store, failed and
224
- * not-yet-attempted keys enter it.
293
+ * Where a repeated delete of `scope` resumes: the highest tombstone version
294
+ * whose covered range was already taken on. The store's watermark says so
295
+ * directly; a queued range also proves its own upper bound was planned
296
+ * (which covers marker files written before the watermark existed).
225
297
  */
226
- async function deleteBlobKeys(deps, scope, batch, leftovers) {
227
- const { deleteData, pendingBlobDeletions, logger } = deps;
228
- let outcome;
229
- try {
230
- outcome =
231
- batch.length > 0 && deleteData
232
- ? await deleteData.deleteBlobVersions(scope, batch)
233
- : { deleted: [], missing: [], failed: [] };
298
+ async function resumePoint(store, scope, markers) {
299
+ const stored = store.plannedThrough
300
+ ? await store.plannedThrough(scope)
301
+ : null;
302
+ let through = stored === null ? null : BigInt(stored);
303
+ for (const marker of markers) {
304
+ if (marker.scope !== scope || marker.version !== null || !marker.range) {
305
+ continue;
306
+ }
307
+ const to = BigInt(marker.range.to);
308
+ if (through === null || to > through)
309
+ through = to;
234
310
  }
235
- catch (err) {
236
- // The port reports per-key failures; a thrown error means none of the
237
- // batch can be trusted as done.
238
- outcome = {
239
- deleted: [],
240
- missing: [],
241
- failed: batch.map((version) => ({ version, error: errorMessage(err) })),
311
+ return through;
312
+ }
313
+ /**
314
+ * The part of `plan` not taken on yet: its exact keys, and the registry range
315
+ * above `through`. Keys at or below `through` are already deleted or still
316
+ * queued, so planning them again would only re-send confirmed deletes.
317
+ */
318
+ function unplannedWork(scope, plan, through, replacedHead = null) {
319
+ // A range is gated by its own `range.to`, the tombstone that covers it.
320
+ // The exact keys lie above that tombstone (or no tombstone exists), so
321
+ // their slots are still open: each is gated by its own version and waits
322
+ // for a finalized tombstone at or above it.
323
+ const work = plan.keys.map((version) => ({
324
+ scope,
325
+ version,
326
+ }));
327
+ if (plan.range) {
328
+ let from = BigInt(plan.range.from);
329
+ if (through !== null && through + 1n > from)
330
+ from = through + 1n;
331
+ if (from <= BigInt(plan.range.to)) {
332
+ work.push({
333
+ scope,
334
+ version: null,
335
+ range: { from: from.toString(), to: plan.range.to },
336
+ ...(replacedHead ? { replacedHead } : {}),
337
+ });
338
+ }
339
+ }
340
+ return work;
341
+ }
342
+ /** Record work and its watermark together when the store supports it. */
343
+ async function recordPlannedWork(store, scope, work, through) {
344
+ if (store.enqueue)
345
+ await store.enqueue(scope, work, through);
346
+ else
347
+ await store.add(work);
348
+ }
349
+ function sameHead(a, b) {
350
+ return (a.expectedVersion === b.expectedVersion &&
351
+ a.dataHash.toLowerCase() === b.dataHash.toLowerCase() &&
352
+ a.metadataHash.toLowerCase() === b.metadataHash.toLowerCase());
353
+ }
354
+ /**
355
+ * The tombstone version whose finality frees a marker's keys: its recorded
356
+ * gate, else a range's upper bound, else an exact key's own version (a key at
357
+ * or below a finalized tombstone can never be registered again). Null for an
358
+ * unexpanded marker, which is never sent.
359
+ */
360
+ function markerGate(marker) {
361
+ if (marker.tombstoneVersion !== undefined) {
362
+ return marker.version !== null || marker.range
363
+ ? BigInt(marker.tombstoneVersion)
364
+ : null;
365
+ }
366
+ if (marker.version !== null)
367
+ return BigInt(marker.version);
368
+ if (marker.range)
369
+ return BigInt(marker.range.to);
370
+ return null;
371
+ }
372
+ /**
373
+ * The markers whose keys may be sent now. Without a finality port, all of
374
+ * them (keys go on the tombstone's acknowledgement). With one, only markers
375
+ * gated at or below the scope's highest finalized tombstone: one inventory
376
+ * read per scope that has work. A read that fails holds the scope's markers
377
+ * for a later pass; holding a key only delays its deletion. Scopes whose
378
+ * deletion the registry rolled back are reported for re-submission.
379
+ */
380
+ async function releasableMarkers(finality, markers, logger) {
381
+ const rolledBack = new Map();
382
+ const converged = new Set();
383
+ if (!finality) {
384
+ return {
385
+ released: markers.map((marker) => ({ marker, through: null })),
386
+ rolledBack,
387
+ converged,
242
388
  };
243
389
  }
244
- const completed = [...outcome.deleted, ...outcome.missing].map((version) => ({ scope, version }));
245
- const remaining = [
246
- ...outcome.failed.map(({ version }) => ({ scope, version })),
247
- ...leftovers,
248
- ];
249
- const remainingKeys = countPendingKeys(remaining);
250
- let recorded = remainingKeys;
251
- if (pendingBlobDeletions) {
390
+ const lowestGate = new Map();
391
+ for (const marker of markers) {
392
+ const gate = markerGate(marker);
393
+ if (gate === null)
394
+ continue;
395
+ const lowest = lowestGate.get(marker.scope);
396
+ if (lowest === undefined || gate < lowest) {
397
+ lowestGate.set(marker.scope, gate);
398
+ }
399
+ }
400
+ const finalized = new Map();
401
+ for (const [scope, lowest] of lowestGate) {
252
402
  try {
253
- if (completed.length > 0)
254
- await pendingBlobDeletions.remove(completed);
255
- if (remaining.length > 0)
256
- await pendingBlobDeletions.add(remaining);
403
+ const state = await finality.tombstoneState(scope, lowest.toString());
404
+ finalized.set(scope, state.finalized === null ? null : BigInt(state.finalized));
405
+ if (state.rolledBack !== null)
406
+ rolledBack.set(scope, state.rolledBack);
407
+ else if (state.finalized !== null && !state.settling)
408
+ converged.add(scope);
409
+ }
410
+ catch (err) {
411
+ finalized.set(scope, null);
412
+ logger.warn({ scope, error: errorMessage(err) }, "Could not read tombstone finality; blob deletions wait for a later pass");
413
+ }
414
+ }
415
+ // A key at or below a finalized tombstone is free (see the safety argument
416
+ // on `TombstoneFinalityPort`): exact keys by their own version, ranges up
417
+ // to the finalized version, the rest of the range staying queued.
418
+ const released = [];
419
+ const held = new Map();
420
+ for (const marker of markers) {
421
+ const gate = markerGate(marker);
422
+ if (gate === null)
423
+ continue;
424
+ const through = finalized.get(marker.scope) ?? null;
425
+ const lowestKey = marker.version !== null
426
+ ? BigInt(marker.version)
427
+ : BigInt(marker.range.from);
428
+ if (through !== null && lowestKey <= through) {
429
+ released.push({ marker, through: marker.range ? through : null });
430
+ }
431
+ const highestKey = marker.version !== null
432
+ ? BigInt(marker.version)
433
+ : BigInt(marker.range.to);
434
+ if (through === null || highestKey > through) {
435
+ held.set(marker.scope, (held.get(marker.scope) ?? 0) + 1);
436
+ }
437
+ }
438
+ for (const [scope, count] of held) {
439
+ logger.info({ scope, markers: count }, "Blob deletions wait until the covering tombstone is finalized");
440
+ }
441
+ return { released, rolledBack, converged };
442
+ }
443
+ /**
444
+ * Send one rate-limited batch taken from `markers` (exact keys first, then
445
+ * range heads, in stored order) and reconcile the store: acknowledged exact
446
+ * markers (2xx or 404) leave it, a failed key taken from a range becomes an
447
+ * exact marker, and each consumed range is advanced in place. A key queued
448
+ * twice (an exact marker inside a range) is sent once.
449
+ */
450
+ async function drainOnePass(deleteData, store, released) {
451
+ let budget = BLOB_DELETE_BATCH_SIZE;
452
+ const byScope = new Map();
453
+ const queued = new Set();
454
+ const exactOrigin = new Set();
455
+ // Gate of each key taken from a range, so a failed key keeps it.
456
+ const rangeGate = new Map();
457
+ const advancedRanges = [];
458
+ const keyOf = (scope, version) => `${scope}\u0000${version}`;
459
+ const take = (scope, version) => {
460
+ const id = keyOf(scope, version);
461
+ if (queued.has(id))
462
+ return false;
463
+ queued.add(id);
464
+ const versions = byScope.get(scope) ?? [];
465
+ versions.push(version);
466
+ byScope.set(scope, versions);
467
+ return true;
468
+ };
469
+ for (const { marker } of released) {
470
+ if (budget === 0)
471
+ break;
472
+ if (marker.version !== null) {
473
+ exactOrigin.add(keyOf(marker.scope, marker.version));
474
+ if (take(marker.scope, marker.version))
475
+ budget -= 1;
476
+ }
477
+ }
478
+ for (const { marker, through } of released) {
479
+ if (budget === 0)
480
+ break;
481
+ if (marker.version === null && marker.range) {
482
+ const taken = takeFromRange(marker.range, budget, through);
483
+ const gate = marker.tombstoneVersion ?? marker.range.to;
484
+ for (const version of taken.versions) {
485
+ if (take(marker.scope, version)) {
486
+ budget -= 1;
487
+ rangeGate.set(keyOf(marker.scope, version), gate);
488
+ }
489
+ }
490
+ advancedRanges.push({
491
+ old: marker,
492
+ next: taken.rest
493
+ ? {
494
+ scope: marker.scope,
495
+ version: null,
496
+ range: taken.rest,
497
+ ...(marker.tombstoneVersion !== undefined
498
+ ? { tombstoneVersion: marker.tombstoneVersion }
499
+ : {}),
500
+ ...(marker.replacedHead
501
+ ? { replacedHead: marker.replacedHead }
502
+ : {}),
503
+ }
504
+ : null,
505
+ });
506
+ }
507
+ }
508
+ const outcomes = new Map();
509
+ for (const [scope, versions] of byScope) {
510
+ let outcome;
511
+ try {
512
+ outcome = await deleteData.deleteBlobVersions(scope, versions);
513
+ }
514
+ catch (err) {
515
+ // The port reports per-key failures; a thrown error means none of the
516
+ // batch can be trusted as done.
517
+ const message = errorMessage(err);
518
+ outcome = {
519
+ deleted: [],
520
+ missing: [],
521
+ failed: versions.map((version) => ({ version, error: message })),
522
+ };
523
+ }
524
+ outcomes.set(scope, outcome);
525
+ const completed = [...outcome.deleted, ...outcome.missing]
526
+ .filter((version) => exactOrigin.has(keyOf(scope, version)))
527
+ .map((version) => ({ scope, version }));
528
+ if (completed.length > 0)
529
+ await store.remove(completed);
530
+ // A failed key that came from a range becomes an exact marker; a failed
531
+ // exact marker simply stays.
532
+ const failedFromRange = outcome.failed
533
+ .filter(({ version }) => !exactOrigin.has(keyOf(scope, version)))
534
+ .map(({ version }) => {
535
+ const gate = rangeGate.get(keyOf(scope, version));
536
+ return {
537
+ scope,
538
+ version,
539
+ ...(gate !== undefined ? { tombstoneVersion: gate } : {}),
540
+ };
541
+ });
542
+ if (failedFromRange.length > 0)
543
+ await store.add(failedFromRange);
544
+ }
545
+ // Advance the ranges only now: a crash mid-pass re-sends already-deleted
546
+ // keys (404, harmless) rather than skipping keys that were never sent. The
547
+ // successor is persisted before its predecessor is dropped, so a failed or
548
+ // interrupted write leaves the old range standing, never a gap.
549
+ for (const { old, next } of advancedRanges) {
550
+ if (next)
551
+ await store.add([next]);
552
+ await store.remove([old]);
553
+ }
554
+ return outcomes;
555
+ }
556
+ /**
557
+ * The storage step of one DELETE call: record the work not taken on yet
558
+ * (with the scope's planned watermark), then send one batch from the head of
559
+ * the scope's queue and report what is still owed. A first delete and a
560
+ * repeat of it run the same path, so a repeat resumes where the queue stands.
561
+ */
562
+ async function deleteScopeBlobs(deps, scope, plan, versionUnknown, storagePass, replacedHead) {
563
+ const { deleteData, logger } = deps;
564
+ const withUnknown = (work) => versionUnknown ? [...work, { scope, version: null }] : work;
565
+ let work = withUnknown(unplannedWork(scope, plan, null, replacedHead));
566
+ let store = deps.pendingBlobDeletions ?? null;
567
+ // This scope's markers already in the durable store before this call.
568
+ let queuedBefore = [];
569
+ if (store) {
570
+ try {
571
+ const markers = await store.list();
572
+ queuedBefore = markers.filter((m) => m.scope === scope);
573
+ const through = await resumePoint(store, scope, markers);
574
+ work = withUnknown(unplannedWork(scope, plan, through, replacedHead));
575
+ await recordPlannedWork(store, scope, work, plan.range?.to ?? null);
257
576
  }
258
577
  catch (markerErr) {
259
- recorded = 0;
260
- logger.error({ scope, error: errorMessage(markerErr), keys: remainingKeys }, "Could not record pending blob deletion markers");
578
+ logger.error({ scope, error: errorMessage(markerErr), keys: countPendingKeys(work) }, "Could not record pending blob deletion markers");
579
+ store = null;
261
580
  }
262
581
  }
263
- else if (remaining.length > 0) {
264
- recorded = 0;
582
+ // Without a usable marker store this pass still sends a batch, taken from
583
+ // the scope's queue as last read plus the new work. The new work it cannot
584
+ // send is reported, not recorded; the durable queue keeps its old markers
585
+ // untouched, so that work is still owed and reported as pending.
586
+ const recorded = store !== null;
587
+ const passStore = store ?? createMemoryPendingBlobDeletionStore();
588
+ if (!recorded)
589
+ await passStore.add([...queuedBefore, ...work]);
590
+ const durablyOwed = recorded ? 0 : countPendingKeys(queuedBefore);
591
+ let outcome;
592
+ let remainingKeys;
593
+ try {
594
+ const { released: queued } = storagePass
595
+ ? await releasableMarkers(deps.tombstoneFinality, (await passStore.list()).filter((m) => m.scope === scope), logger)
596
+ : { released: [] };
597
+ outcome = (await drainOnePass(deleteData, passStore, queued)).get(scope) ?? { deleted: [], missing: [], failed: [] };
598
+ remainingKeys = countPendingKeys((await passStore.list()).filter((m) => m.scope === scope));
599
+ }
600
+ catch (markerErr) {
601
+ // A marker write failed mid-pass. The store never loses owed keys (see
602
+ // drainOnePass), so the queue still holds this scope's work.
603
+ const message = errorMessage(markerErr);
604
+ logger.error({ scope, error: message }, "Could not update pending blob deletion markers");
605
+ return {
606
+ step: { status: "failed", error: message },
607
+ pending: recorded || durablyOwed > 0 ? 1 : 0,
608
+ };
609
+ }
610
+ if (!recorded && remainingKeys > durablyOwed) {
265
611
  logger.error({ scope, keys: remainingKeys }, "Blob deletions left unfinished with no marker store to retry them");
266
612
  }
613
+ if (!recorded)
614
+ remainingKeys = Math.max(remainingKeys, durablyOwed);
615
+ const pending = recorded ? remainingKeys : durablyOwed;
267
616
  const counts = {
268
617
  blobsDeleted: outcome.deleted.length,
269
618
  blobsMissing: outcome.missing.length,
@@ -271,24 +620,19 @@ async function deleteBlobKeys(deps, scope, batch, leftovers) {
271
620
  };
272
621
  if (outcome.failed.length > 0) {
273
622
  const first = outcome.failed[0];
274
- logger.warn({
275
- scope,
276
- failed: outcome.failed.length,
277
- pending: recorded,
278
- error: first.error,
279
- }, "Storage blob deletion failed for some keys after gateway tombstone; will retry");
623
+ logger.warn({ scope, failed: outcome.failed.length, pending, error: first.error }, "Storage blob deletion failed for some keys after gateway tombstone; will retry");
280
624
  return {
281
625
  step: {
282
626
  status: "failed",
283
627
  error: `${outcome.failed.length} blob delete(s) failed: ${first.error}`,
284
628
  ...counts,
285
629
  },
286
- pending: recorded,
630
+ pending,
287
631
  };
288
632
  }
289
- if (remaining.length > 0) {
633
+ if (remainingKeys > 0) {
290
634
  logger.info({ scope, ...counts }, "Storage blob deletion continues on later sync cycles (rate-limited batch)");
291
- return { step: { status: "deferred", ...counts }, pending: recorded };
635
+ return { step: { status: "deferred", ...counts }, pending };
292
636
  }
293
637
  return { step: { status: "ok", ...counts }, pending: 0 };
294
638
  }
@@ -301,8 +645,12 @@ async function deleteBlobKeys(deps, scope, batch, leftovers) {
301
645
  * are expanded from the registry first; if the registry shows the scope live
302
646
  * again the old tombstone's version is unknowable, so the marker is dropped
303
647
  * and the pre-tombstone ciphertext stays (owner-decryptable only) until the
304
- * next delete of that scope.
648
+ * next delete of that scope. With `tombstoneFinality` wired, a key is sent
649
+ * only once a tombstone at or above its gate is finalized; a failed
650
+ * tombstone's keys stay queued (the deletion did not happen) until a later
651
+ * deletion of the scope is finalized.
305
652
  */
653
+ export const TOMBSTONE_RESUBMIT_MAX_ATTEMPTS = DEFAULT_TOMBSTONE_RESUBMIT_MAX_ATTEMPTS;
306
654
  export async function retryPendingBlobDeletions(deps) {
307
655
  const { deleteData, pendingBlobDeletions, logger } = deps;
308
656
  const result = {
@@ -332,85 +680,28 @@ export async function retryPendingBlobDeletions(deps) {
332
680
  result.superseded.push(marker.scope);
333
681
  logger.warn({
334
682
  scope: marker.scope,
335
- dataPointId: registry.record.id,
336
- version: registry.record.expectedVersion,
683
+ dataPointId: registry.id,
684
+ version: registry.expectedVersion,
337
685
  }, "Scope was re-added after its tombstone; dropping the unexpanded blob deletion marker so the live version's ciphertext survives");
338
686
  continue;
339
687
  }
340
688
  const plan = planBlobDeletions(deps.storage ?? { listVersions: () => [] }, marker.scope, registry.status === "deleted" ? registry.version : null);
341
- const expanded = plan.keys.map((version) => ({
342
- scope: marker.scope,
343
- version,
344
- }));
345
- if (plan.range) {
346
- expanded.push({ scope: marker.scope, version: null, range: plan.range });
347
- }
689
+ // Only the part not taken on yet: a repeated delete may already have
690
+ // queued (or finished) the same tombstone's range.
691
+ const expanded = unplannedWork(marker.scope, plan, await resumePoint(pendingBlobDeletions, marker.scope, markers));
692
+ // Persist the expansion before dropping the unexpanded marker: a failed or
693
+ // interrupted write leaves the marker to expand again (the same keys), and
694
+ // never drops keys that are still owed.
695
+ await recordPlannedWork(pendingBlobDeletions, marker.scope, expanded, plan.range?.to ?? null);
348
696
  await pendingBlobDeletions.remove([marker]);
349
- await pendingBlobDeletions.add(expanded);
350
697
  }
351
698
  markers = await pendingBlobDeletions.list();
352
- // One rate-limited batch in stored order: exact keys, then range heads.
353
- let budget = BLOB_DELETE_BATCH_SIZE;
354
- const byScope = new Map();
355
- const exactOrigin = new Set();
356
- const advancedRanges = [];
357
- const enqueue = (scope, version) => {
358
- const versions = byScope.get(scope) ?? [];
359
- versions.push(version);
360
- byScope.set(scope, versions);
361
- };
362
- for (const marker of markers) {
363
- if (budget === 0)
364
- break;
365
- if (marker.version !== null) {
366
- enqueue(marker.scope, marker.version);
367
- exactOrigin.add(`${marker.scope}\u0000${marker.version}`);
368
- budget -= 1;
369
- }
370
- }
371
- for (const marker of markers) {
372
- if (budget === 0)
373
- break;
374
- if (marker.version === null && marker.range) {
375
- const taken = takeFromRange(marker.range, budget);
376
- for (const version of taken.versions)
377
- enqueue(marker.scope, version);
378
- budget -= taken.versions.length;
379
- advancedRanges.push({
380
- old: marker,
381
- next: taken.rest
382
- ? { scope: marker.scope, version: null, range: taken.rest }
383
- : null,
384
- });
385
- }
386
- }
387
- for (const [scope, versions] of byScope) {
388
- let outcome;
389
- try {
390
- outcome = await deleteData.deleteBlobVersions(scope, versions);
391
- }
392
- catch (err) {
393
- const message = errorMessage(err);
394
- outcome = {
395
- deleted: [],
396
- missing: [],
397
- failed: versions.map((version) => ({ version, error: message })),
398
- };
399
- }
400
- const completed = [...outcome.deleted, ...outcome.missing]
401
- .filter((version) => exactOrigin.has(`${scope}\u0000${version}`))
402
- .map((version) => ({ scope, version }));
403
- if (completed.length > 0)
404
- await pendingBlobDeletions.remove(completed);
699
+ // One rate-limited batch in stored order: exact keys, then range heads,
700
+ // taken only from markers whose covering tombstone is final.
701
+ const decision = await releasableMarkers(deps.tombstoneFinality, markers, logger);
702
+ const outcomes = await drainOnePass(deleteData, pendingBlobDeletions, decision.released);
703
+ for (const [scope, outcome] of outcomes) {
405
704
  result.completed.push(...[...outcome.deleted, ...outcome.missing].map((version) => ({ scope, version })));
406
- // A failed key that came from a range becomes an exact marker; a failed
407
- // exact marker simply stays.
408
- const failedFromRange = outcome.failed
409
- .filter(({ version }) => !exactOrigin.has(`${scope}\u0000${version}`))
410
- .map(({ version }) => ({ scope, version }));
411
- if (failedFromRange.length > 0) {
412
- await pendingBlobDeletions.add(failedFromRange);
413
- }
414
705
  for (const failure of outcome.failed) {
415
706
  result.failed.push({ scope, ...failure });
416
707
  }
@@ -429,16 +720,119 @@ export async function retryPendingBlobDeletions(deps) {
429
720
  }, "Pending blob deletion failed again");
430
721
  }
431
722
  }
432
- // Advance the ranges only now: a crash mid-pass re-sends already-deleted
433
- // keys (404, harmless) rather than skipping keys that were never sent.
434
- for (const { old, next } of advancedRanges) {
435
- await pendingBlobDeletions.remove([old]);
436
- if (next)
437
- await pendingBlobDeletions.add([next]);
723
+ for (const [scope, rollback] of decision.rolledBack) {
724
+ await resubmitRolledBackDeletion(deps, scope, rollback, markers.filter((marker) => marker.scope === scope));
725
+ }
726
+ const left = await pendingBlobDeletions.list();
727
+ // A scope with nothing left to free has converged; forget its attempts.
728
+ if (deps.tombstoneResubmits) {
729
+ const waiting = new Set(left.map((marker) => marker.scope));
730
+ const tracked = deps.tombstoneResubmits.snapshot();
731
+ for (const { scope } of [...tracked.retrying, ...tracked.failed]) {
732
+ if (!waiting.has(scope) || decision.converged.has(scope)) {
733
+ deps.tombstoneResubmits.reset(scope);
734
+ }
735
+ }
438
736
  }
439
- result.remaining = (await pendingBlobDeletions.list()).length;
737
+ result.remaining = left.length;
440
738
  return result;
441
739
  }
740
+ /**
741
+ * The user deleted `scope`, its tombstone failed to settle, and the gateway
742
+ * shows the scope live again (the finality port only reports a rollback when
743
+ * no newer version of the scope exists). Re-submit the delete through the
744
+ * ordinary delete path, but only over exactly the head the user's tombstone
745
+ * replaced: the queued range marker remembers that head, the inventory read
746
+ * reports the restored one, and the port refuses any other. A different
747
+ * restored head is reported once as a failed delete instead. A write that
748
+ * recovered a failed slot below the tombstone, or that lands between the read
749
+ * and the re-submission, is therefore never deleted. This replica's own
750
+ * index is checked too: any unsynced entry (written after the delete erased
751
+ * the covered ones), or a synced one at or above the failed tombstone, is a
752
+ * re-add, and a re-add is never deleted again.
753
+ *
754
+ * Bounded by the tracker: attempts back off exponentially, and after the
755
+ * last one the scope is logged as an error and reported in the tracker's
756
+ * `failed` list. Its markers stay queued (nothing is freed while the scope
757
+ * is live) and drain if a later delete of the scope becomes final.
758
+ */
759
+ async function resubmitRolledBackDeletion(deps, scope, rollback, scopeMarkers) {
760
+ const { logger, tombstoneResubmits: tracker } = deps;
761
+ const failedVersion = rollback.tombstoneVersion;
762
+ if (!deps.resubmitDeletion || !tracker) {
763
+ logger.warn({ scope, tombstoneVersion: failedVersion }, "Scope tombstone failed and the scope is live again; its storage copies stay until the scope is deleted again");
764
+ return;
765
+ }
766
+ const remembered = scopeMarkers.find((marker) => marker.version === null &&
767
+ marker.range &&
768
+ BigInt(marker.range.to) === BigInt(failedVersion) &&
769
+ marker.replacedHead)?.replacedHead;
770
+ if (readdedLocally(deps.storage, scope, failedVersion)) {
771
+ logger.info({ scope, tombstoneVersion: failedVersion }, "Scope tombstone failed, but the scope was re-added after the delete; not deleting it again");
772
+ return;
773
+ }
774
+ if (tracker.exhausted(scope))
775
+ return;
776
+ if (!remembered || !sameHead(remembered, rollback.head)) {
777
+ // The user's delete did not happen and the scope is live again, but the
778
+ // restored head may be newer data, so it is not deleted automatically.
779
+ // Report it once, so no surface shows the scope as deleted.
780
+ const state = tracker.giveUp(scope, failedVersion, "head-changed");
781
+ logger.error({
782
+ scope,
783
+ tombstoneVersion: failedVersion,
784
+ head: rollback.head.expectedVersion,
785
+ remembered: remembered?.expectedVersion ?? null,
786
+ }, "Scope deletion did not complete: the gateway tombstone failed and the restored head is not the one the delete replaced, so it is not deleted again automatically. Delete it again to retry.");
787
+ deps.onDeletionAbandoned?.(state);
788
+ return;
789
+ }
790
+ if (tracker.outOfAttempts(scope)) {
791
+ const state = tracker.giveUp(scope, failedVersion);
792
+ logger.error({
793
+ scope,
794
+ attempts: state.attempts,
795
+ tombstoneVersion: failedVersion,
796
+ }, "Scope deletion did not complete: every gateway tombstone failed and the scope is live again. Delete it again to retry.");
797
+ deps.onDeletionAbandoned?.(state);
798
+ return;
799
+ }
800
+ if (!tracker.due(scope))
801
+ return;
802
+ const attempt = tracker.recordAttempt(scope, failedVersion);
803
+ logger.warn({ scope, tombstoneVersion: failedVersion, attempt }, "Scope tombstone failed and the scope is live again; re-submitting the user's delete");
804
+ try {
805
+ const outcome = await deps.resubmitDeletion(scope, {
806
+ fence: { head: rollback.head },
807
+ storagePass: false,
808
+ });
809
+ if (outcome.steps.gateway.status === "failed") {
810
+ logger.warn({ scope, attempt, error: outcome.steps.gateway.error }, "Re-submitted scope delete was refused by the gateway; will retry");
811
+ }
812
+ }
813
+ catch (err) {
814
+ logger.warn({ scope, attempt, error: errorMessage(err) }, "Re-submitted scope delete failed; will retry");
815
+ }
816
+ }
817
+ /** Whether this replica holds data of `scope` the failed delete did not cover. */
818
+ function readdedLocally(storage, scope, failedVersion) {
819
+ // Without a local index nothing proves the scope was not re-added.
820
+ if (!storage)
821
+ return true;
822
+ const failed = BigInt(failedVersion);
823
+ const PAGE_SIZE = 500;
824
+ for (let offset = 0;; offset += PAGE_SIZE) {
825
+ const entries = storage.listVersions(scope, { limit: PAGE_SIZE, offset });
826
+ for (const entry of entries) {
827
+ if (entry.dataPointId === null)
828
+ return true;
829
+ if (BigInt(entry.version) >= failed)
830
+ return true;
831
+ }
832
+ if (entries.length < PAGE_SIZE)
833
+ return false;
834
+ }
835
+ }
442
836
  /**
443
837
  * What the registry currently says about `scope`. "live" means a row exists
444
838
  * that is not a tombstone; "deleted" carries the tombstone's version;
@@ -446,6 +840,31 @@ export async function retryPendingBlobDeletions(deps) {
446
840
  * wired) or the row is gone.
447
841
  */
448
842
  async function registryState(deps, scope) {
843
+ // The gateway refuses an unsigned read of a reserved point; ask the port.
844
+ if (isGatewayReservedScope(scope) &&
845
+ deps.deleteData?.head &&
846
+ deps.serverOwner) {
847
+ let head;
848
+ try {
849
+ head = await deps.deleteData.head(scope);
850
+ }
851
+ catch (err) {
852
+ return {
853
+ status: "unknown",
854
+ error: err instanceof Error ? err : new Error(String(err)),
855
+ };
856
+ }
857
+ if (head === null)
858
+ return { status: "deleted-or-absent" };
859
+ if (head.deletedAt === null) {
860
+ return {
861
+ status: "live",
862
+ id: computeDataPointId(deps.serverOwner, scope),
863
+ expectedVersion: head.expectedVersion,
864
+ };
865
+ }
866
+ return { status: "deleted", version: tombstoneVersion(head) };
867
+ }
449
868
  if (!deps.dataPointFeed || !deps.serverOwner) {
450
869
  return { status: "deleted-or-absent" };
451
870
  }
@@ -464,8 +883,13 @@ async function registryState(deps, scope) {
464
883
  }
465
884
  if (record === null)
466
885
  return { status: "deleted-or-absent" };
467
- if (deletionTimestamp(record) === null)
468
- return { status: "live", record };
886
+ if (deletionTimestamp(record) === null) {
887
+ return {
888
+ status: "live",
889
+ id: record.id,
890
+ expectedVersion: record.expectedVersion,
891
+ };
892
+ }
469
893
  return { status: "deleted", version: tombstoneVersion(record) };
470
894
  }
471
895
  function errorMessage(err) {