@optimystic/db-core 0.13.5 → 0.14.1

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 (447) hide show
  1. package/dist/src/cluster/structs.d.ts +13 -0
  2. package/dist/src/cluster/structs.d.ts.map +1 -1
  3. package/dist/src/cohort-topic/addressing.d.ts +53 -0
  4. package/dist/src/cohort-topic/addressing.d.ts.map +1 -0
  5. package/dist/src/cohort-topic/addressing.js +95 -0
  6. package/dist/src/cohort-topic/addressing.js.map +1 -0
  7. package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts +105 -0
  8. package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.d.ts.map +1 -0
  9. package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js +197 -0
  10. package/dist/src/cohort-topic/antidos/bootstrap-evidence-envelope.js.map +1 -0
  11. package/dist/src/cohort-topic/antidos/bootstrap-evidence.d.ts +50 -0
  12. package/dist/src/cohort-topic/antidos/bootstrap-evidence.d.ts.map +1 -0
  13. package/dist/src/cohort-topic/antidos/bootstrap-evidence.js +62 -0
  14. package/dist/src/cohort-topic/antidos/bootstrap-evidence.js.map +1 -0
  15. package/dist/src/cohort-topic/antidos/index.d.ts +6 -0
  16. package/dist/src/cohort-topic/antidos/index.d.ts.map +1 -0
  17. package/dist/src/cohort-topic/antidos/index.js +6 -0
  18. package/dist/src/cohort-topic/antidos/index.js.map +1 -0
  19. package/dist/src/cohort-topic/antidos/rate-limiter.d.ts +95 -0
  20. package/dist/src/cohort-topic/antidos/rate-limiter.d.ts.map +1 -0
  21. package/dist/src/cohort-topic/antidos/rate-limiter.js +146 -0
  22. package/dist/src/cohort-topic/antidos/rate-limiter.js.map +1 -0
  23. package/dist/src/cohort-topic/antidos/replay-guard.d.ts +37 -0
  24. package/dist/src/cohort-topic/antidos/replay-guard.d.ts.map +1 -0
  25. package/dist/src/cohort-topic/antidos/replay-guard.js +78 -0
  26. package/dist/src/cohort-topic/antidos/replay-guard.js.map +1 -0
  27. package/dist/src/cohort-topic/antidos/topic-budget.d.ts +50 -0
  28. package/dist/src/cohort-topic/antidos/topic-budget.d.ts.map +1 -0
  29. package/dist/src/cohort-topic/antidos/topic-budget.js +95 -0
  30. package/dist/src/cohort-topic/antidos/topic-budget.js.map +1 -0
  31. package/dist/src/cohort-topic/antiflood/index.d.ts +3 -0
  32. package/dist/src/cohort-topic/antiflood/index.d.ts.map +1 -0
  33. package/dist/src/cohort-topic/antiflood/index.js +3 -0
  34. package/dist/src/cohort-topic/antiflood/index.js.map +1 -0
  35. package/dist/src/cohort-topic/antiflood/invariants.d.ts +70 -0
  36. package/dist/src/cohort-topic/antiflood/invariants.d.ts.map +1 -0
  37. package/dist/src/cohort-topic/antiflood/invariants.js +86 -0
  38. package/dist/src/cohort-topic/antiflood/invariants.js.map +1 -0
  39. package/dist/src/cohort-topic/antiflood/jitter.d.ts +65 -0
  40. package/dist/src/cohort-topic/antiflood/jitter.d.ts.map +1 -0
  41. package/dist/src/cohort-topic/antiflood/jitter.js +75 -0
  42. package/dist/src/cohort-topic/antiflood/jitter.js.map +1 -0
  43. package/dist/src/cohort-topic/coldstart.d.ts +117 -0
  44. package/dist/src/cohort-topic/coldstart.d.ts.map +1 -0
  45. package/dist/src/cohort-topic/coldstart.js +127 -0
  46. package/dist/src/cohort-topic/coldstart.js.map +1 -0
  47. package/dist/src/cohort-topic/dmax.d.ts +44 -0
  48. package/dist/src/cohort-topic/dmax.d.ts.map +1 -0
  49. package/dist/src/cohort-topic/dmax.js +70 -0
  50. package/dist/src/cohort-topic/dmax.js.map +1 -0
  51. package/dist/src/cohort-topic/gossip/bus.d.ts +85 -0
  52. package/dist/src/cohort-topic/gossip/bus.d.ts.map +1 -0
  53. package/dist/src/cohort-topic/gossip/bus.js +146 -0
  54. package/dist/src/cohort-topic/gossip/bus.js.map +1 -0
  55. package/dist/src/cohort-topic/gossip/index.d.ts +4 -0
  56. package/dist/src/cohort-topic/gossip/index.d.ts.map +1 -0
  57. package/dist/src/cohort-topic/gossip/index.js +4 -0
  58. package/dist/src/cohort-topic/gossip/index.js.map +1 -0
  59. package/dist/src/cohort-topic/gossip/records.d.ts +12 -0
  60. package/dist/src/cohort-topic/gossip/records.d.ts.map +1 -0
  61. package/dist/src/cohort-topic/gossip/records.js +41 -0
  62. package/dist/src/cohort-topic/gossip/records.js.map +1 -0
  63. package/dist/src/cohort-topic/gossip/view.d.ts +39 -0
  64. package/dist/src/cohort-topic/gossip/view.d.ts.map +1 -0
  65. package/dist/src/cohort-topic/gossip/view.js +30 -0
  66. package/dist/src/cohort-topic/gossip/view.js.map +1 -0
  67. package/dist/src/cohort-topic/index.d.ts +21 -0
  68. package/dist/src/cohort-topic/index.d.ts.map +1 -0
  69. package/dist/src/cohort-topic/index.js +21 -0
  70. package/dist/src/cohort-topic/index.js.map +1 -0
  71. package/dist/src/cohort-topic/load/barometer.d.ts +78 -0
  72. package/dist/src/cohort-topic/load/barometer.d.ts.map +1 -0
  73. package/dist/src/cohort-topic/load/barometer.js +93 -0
  74. package/dist/src/cohort-topic/load/barometer.js.map +1 -0
  75. package/dist/src/cohort-topic/load/index.d.ts +2 -0
  76. package/dist/src/cohort-topic/load/index.d.ts.map +1 -0
  77. package/dist/src/cohort-topic/load/index.js +2 -0
  78. package/dist/src/cohort-topic/load/index.js.map +1 -0
  79. package/dist/src/cohort-topic/member-engine.d.ts +134 -0
  80. package/dist/src/cohort-topic/member-engine.d.ts.map +1 -0
  81. package/dist/src/cohort-topic/member-engine.js +264 -0
  82. package/dist/src/cohort-topic/member-engine.js.map +1 -0
  83. package/dist/src/cohort-topic/membership/index.d.ts +4 -0
  84. package/dist/src/cohort-topic/membership/index.d.ts.map +1 -0
  85. package/dist/src/cohort-topic/membership/index.js +4 -0
  86. package/dist/src/cohort-topic/membership/index.js.map +1 -0
  87. package/dist/src/cohort-topic/membership/publisher.d.ts +82 -0
  88. package/dist/src/cohort-topic/membership/publisher.d.ts.map +1 -0
  89. package/dist/src/cohort-topic/membership/publisher.js +107 -0
  90. package/dist/src/cohort-topic/membership/publisher.js.map +1 -0
  91. package/dist/src/cohort-topic/membership/source.d.ts +31 -0
  92. package/dist/src/cohort-topic/membership/source.d.ts.map +1 -0
  93. package/dist/src/cohort-topic/membership/source.js +32 -0
  94. package/dist/src/cohort-topic/membership/source.js.map +1 -0
  95. package/dist/src/cohort-topic/membership/verifier.d.ts +96 -0
  96. package/dist/src/cohort-topic/membership/verifier.d.ts.map +1 -0
  97. package/dist/src/cohort-topic/membership/verifier.js +250 -0
  98. package/dist/src/cohort-topic/membership/verifier.js.map +1 -0
  99. package/dist/src/cohort-topic/ports.d.ts +149 -0
  100. package/dist/src/cohort-topic/ports.d.ts.map +1 -0
  101. package/dist/src/cohort-topic/ports.js +25 -0
  102. package/dist/src/cohort-topic/ports.js.map +1 -0
  103. package/dist/src/cohort-topic/promotion.d.ts +135 -0
  104. package/dist/src/cohort-topic/promotion.d.ts.map +1 -0
  105. package/dist/src/cohort-topic/promotion.js +269 -0
  106. package/dist/src/cohort-topic/promotion.js.map +1 -0
  107. package/dist/src/cohort-topic/registration/bytes.d.ts +16 -0
  108. package/dist/src/cohort-topic/registration/bytes.d.ts.map +1 -0
  109. package/dist/src/cohort-topic/registration/bytes.js +32 -0
  110. package/dist/src/cohort-topic/registration/bytes.js.map +1 -0
  111. package/dist/src/cohort-topic/registration/handoff.d.ts +69 -0
  112. package/dist/src/cohort-topic/registration/handoff.d.ts.map +1 -0
  113. package/dist/src/cohort-topic/registration/handoff.js +98 -0
  114. package/dist/src/cohort-topic/registration/handoff.js.map +1 -0
  115. package/dist/src/cohort-topic/registration/index.d.ts +7 -0
  116. package/dist/src/cohort-topic/registration/index.d.ts.map +1 -0
  117. package/dist/src/cohort-topic/registration/index.js +7 -0
  118. package/dist/src/cohort-topic/registration/index.js.map +1 -0
  119. package/dist/src/cohort-topic/registration/renewal.d.ts +115 -0
  120. package/dist/src/cohort-topic/registration/renewal.d.ts.map +1 -0
  121. package/dist/src/cohort-topic/registration/renewal.js +306 -0
  122. package/dist/src/cohort-topic/registration/renewal.js.map +1 -0
  123. package/dist/src/cohort-topic/registration/sharding.d.ts +31 -0
  124. package/dist/src/cohort-topic/registration/sharding.d.ts.map +1 -0
  125. package/dist/src/cohort-topic/registration/sharding.js +48 -0
  126. package/dist/src/cohort-topic/registration/sharding.js.map +1 -0
  127. package/dist/src/cohort-topic/registration/store.d.ts +13 -0
  128. package/dist/src/cohort-topic/registration/store.d.ts.map +1 -0
  129. package/dist/src/cohort-topic/registration/store.js +72 -0
  130. package/dist/src/cohort-topic/registration/store.js.map +1 -0
  131. package/dist/src/cohort-topic/registration/types.d.ts +71 -0
  132. package/dist/src/cohort-topic/registration/types.d.ts.map +1 -0
  133. package/dist/src/cohort-topic/registration/types.js +27 -0
  134. package/dist/src/cohort-topic/registration/types.js.map +1 -0
  135. package/dist/src/cohort-topic/ring-hash.d.ts +27 -0
  136. package/dist/src/cohort-topic/ring-hash.d.ts.map +1 -0
  137. package/dist/src/cohort-topic/ring-hash.js +45 -0
  138. package/dist/src/cohort-topic/ring-hash.js.map +1 -0
  139. package/dist/src/cohort-topic/service.d.ts +157 -0
  140. package/dist/src/cohort-topic/service.d.ts.map +1 -0
  141. package/dist/src/cohort-topic/service.js +237 -0
  142. package/dist/src/cohort-topic/service.js.map +1 -0
  143. package/dist/src/cohort-topic/sig/index.d.ts +3 -0
  144. package/dist/src/cohort-topic/sig/index.d.ts.map +1 -0
  145. package/dist/src/cohort-topic/sig/index.js +3 -0
  146. package/dist/src/cohort-topic/sig/index.js.map +1 -0
  147. package/dist/src/cohort-topic/sig/payloads.d.ts +25 -0
  148. package/dist/src/cohort-topic/sig/payloads.d.ts.map +1 -0
  149. package/dist/src/cohort-topic/sig/payloads.js +25 -0
  150. package/dist/src/cohort-topic/sig/payloads.js.map +1 -0
  151. package/dist/src/cohort-topic/sig/threshold.d.ts +33 -0
  152. package/dist/src/cohort-topic/sig/threshold.d.ts.map +1 -0
  153. package/dist/src/cohort-topic/sig/threshold.js +51 -0
  154. package/dist/src/cohort-topic/sig/threshold.js.map +1 -0
  155. package/dist/src/cohort-topic/tiers.d.ts +58 -0
  156. package/dist/src/cohort-topic/tiers.d.ts.map +1 -0
  157. package/dist/src/cohort-topic/tiers.js +49 -0
  158. package/dist/src/cohort-topic/tiers.js.map +1 -0
  159. package/dist/src/cohort-topic/traffic.d.ts +90 -0
  160. package/dist/src/cohort-topic/traffic.d.ts.map +1 -0
  161. package/dist/src/cohort-topic/traffic.js +146 -0
  162. package/dist/src/cohort-topic/traffic.js.map +1 -0
  163. package/dist/src/cohort-topic/walk.d.ts +123 -0
  164. package/dist/src/cohort-topic/walk.d.ts.map +1 -0
  165. package/dist/src/cohort-topic/walk.js +150 -0
  166. package/dist/src/cohort-topic/walk.js.map +1 -0
  167. package/dist/src/cohort-topic/willingness.d.ts +123 -0
  168. package/dist/src/cohort-topic/willingness.d.ts.map +1 -0
  169. package/dist/src/cohort-topic/willingness.js +143 -0
  170. package/dist/src/cohort-topic/willingness.js.map +1 -0
  171. package/dist/src/cohort-topic/wire/codec.d.ts +42 -0
  172. package/dist/src/cohort-topic/wire/codec.d.ts.map +1 -0
  173. package/dist/src/cohort-topic/wire/codec.js +163 -0
  174. package/dist/src/cohort-topic/wire/codec.js.map +1 -0
  175. package/dist/src/cohort-topic/wire/index.d.ts +6 -0
  176. package/dist/src/cohort-topic/wire/index.d.ts.map +1 -0
  177. package/dist/src/cohort-topic/wire/index.js +6 -0
  178. package/dist/src/cohort-topic/wire/index.js.map +1 -0
  179. package/dist/src/cohort-topic/wire/payloads.d.ts +38 -0
  180. package/dist/src/cohort-topic/wire/payloads.d.ts.map +1 -0
  181. package/dist/src/cohort-topic/wire/payloads.js +102 -0
  182. package/dist/src/cohort-topic/wire/payloads.js.map +1 -0
  183. package/dist/src/cohort-topic/wire/types.d.ts +304 -0
  184. package/dist/src/cohort-topic/wire/types.d.ts.map +1 -0
  185. package/dist/src/cohort-topic/wire/types.js +16 -0
  186. package/dist/src/cohort-topic/wire/types.js.map +1 -0
  187. package/dist/src/cohort-topic/wire/validate.d.ts +25 -0
  188. package/dist/src/cohort-topic/wire/validate.d.ts.map +1 -0
  189. package/dist/src/cohort-topic/wire/validate.js +427 -0
  190. package/dist/src/cohort-topic/wire/validate.js.map +1 -0
  191. package/dist/src/collection/collection.d.ts +58 -1
  192. package/dist/src/collection/collection.d.ts.map +1 -1
  193. package/dist/src/collection/collection.js +76 -0
  194. package/dist/src/collection/collection.js.map +1 -1
  195. package/dist/src/collections/tree/tree.d.ts +58 -2
  196. package/dist/src/collections/tree/tree.d.ts.map +1 -1
  197. package/dist/src/collections/tree/tree.js +59 -2
  198. package/dist/src/collections/tree/tree.js.map +1 -1
  199. package/dist/src/index.d.ts +3 -0
  200. package/dist/src/index.d.ts.map +1 -1
  201. package/dist/src/index.js +3 -0
  202. package/dist/src/index.js.map +1 -1
  203. package/dist/src/log/log.d.ts +42 -4
  204. package/dist/src/log/log.d.ts.map +1 -1
  205. package/dist/src/log/log.js +71 -3
  206. package/dist/src/log/log.js.map +1 -1
  207. package/dist/src/log/struct.d.ts +122 -2
  208. package/dist/src/log/struct.d.ts.map +1 -1
  209. package/dist/src/log/struct.js.map +1 -1
  210. package/dist/src/matchmaking/capability-filter.d.ts +24 -0
  211. package/dist/src/matchmaking/capability-filter.d.ts.map +1 -0
  212. package/dist/src/matchmaking/capability-filter.js +37 -0
  213. package/dist/src/matchmaking/capability-filter.js.map +1 -0
  214. package/dist/src/matchmaking/config.d.ts +77 -0
  215. package/dist/src/matchmaking/config.d.ts.map +1 -0
  216. package/dist/src/matchmaking/config.js +69 -0
  217. package/dist/src/matchmaking/config.js.map +1 -0
  218. package/dist/src/matchmaking/index.d.ts +21 -0
  219. package/dist/src/matchmaking/index.d.ts.map +1 -0
  220. package/dist/src/matchmaking/index.js +21 -0
  221. package/dist/src/matchmaking/index.js.map +1 -0
  222. package/dist/src/matchmaking/multi-cohort-seeker.d.ts +133 -0
  223. package/dist/src/matchmaking/multi-cohort-seeker.d.ts.map +1 -0
  224. package/dist/src/matchmaking/multi-cohort-seeker.js +142 -0
  225. package/dist/src/matchmaking/multi-cohort-seeker.js.map +1 -0
  226. package/dist/src/matchmaking/provider.d.ts +70 -0
  227. package/dist/src/matchmaking/provider.d.ts.map +1 -0
  228. package/dist/src/matchmaking/provider.js +93 -0
  229. package/dist/src/matchmaking/provider.js.map +1 -0
  230. package/dist/src/matchmaking/query-eval.d.ts +53 -0
  231. package/dist/src/matchmaking/query-eval.d.ts.map +1 -0
  232. package/dist/src/matchmaking/query-eval.js +69 -0
  233. package/dist/src/matchmaking/query-eval.js.map +1 -0
  234. package/dist/src/matchmaking/seeker-walk.d.ts +95 -0
  235. package/dist/src/matchmaking/seeker-walk.d.ts.map +1 -0
  236. package/dist/src/matchmaking/seeker-walk.js +75 -0
  237. package/dist/src/matchmaking/seeker-walk.js.map +1 -0
  238. package/dist/src/matchmaking/seeker.d.ts +51 -0
  239. package/dist/src/matchmaking/seeker.d.ts.map +1 -0
  240. package/dist/src/matchmaking/seeker.js +62 -0
  241. package/dist/src/matchmaking/seeker.js.map +1 -0
  242. package/dist/src/matchmaking/topic-anchor.d.ts +54 -0
  243. package/dist/src/matchmaking/topic-anchor.d.ts.map +1 -0
  244. package/dist/src/matchmaking/topic-anchor.js +67 -0
  245. package/dist/src/matchmaking/topic-anchor.js.map +1 -0
  246. package/dist/src/matchmaking/voting-quorum.d.ts +233 -0
  247. package/dist/src/matchmaking/voting-quorum.d.ts.map +1 -0
  248. package/dist/src/matchmaking/voting-quorum.js +238 -0
  249. package/dist/src/matchmaking/voting-quorum.js.map +1 -0
  250. package/dist/src/matchmaking/wire.d.ts +259 -0
  251. package/dist/src/matchmaking/wire.d.ts.map +1 -0
  252. package/dist/src/matchmaking/wire.js +484 -0
  253. package/dist/src/matchmaking/wire.js.map +1 -0
  254. package/dist/src/network/i-repo.d.ts +9 -0
  255. package/dist/src/network/i-repo.d.ts.map +1 -1
  256. package/dist/src/network/repo-protocol.d.ts +3 -1
  257. package/dist/src/network/repo-protocol.d.ts.map +1 -1
  258. package/dist/src/network/struct.d.ts +23 -1
  259. package/dist/src/network/struct.d.ts.map +1 -1
  260. package/dist/src/reactivity/backfill.d.ts +118 -0
  261. package/dist/src/reactivity/backfill.d.ts.map +1 -0
  262. package/dist/src/reactivity/backfill.js +137 -0
  263. package/dist/src/reactivity/backfill.js.map +1 -0
  264. package/dist/src/reactivity/backpressure.d.ts +99 -0
  265. package/dist/src/reactivity/backpressure.d.ts.map +1 -0
  266. package/dist/src/reactivity/backpressure.js +153 -0
  267. package/dist/src/reactivity/backpressure.js.map +1 -0
  268. package/dist/src/reactivity/checkpoint.d.ts +165 -0
  269. package/dist/src/reactivity/checkpoint.d.ts.map +1 -0
  270. package/dist/src/reactivity/checkpoint.js +232 -0
  271. package/dist/src/reactivity/checkpoint.js.map +1 -0
  272. package/dist/src/reactivity/config.d.ts +131 -0
  273. package/dist/src/reactivity/config.d.ts.map +1 -0
  274. package/dist/src/reactivity/config.js +135 -0
  275. package/dist/src/reactivity/config.js.map +1 -0
  276. package/dist/src/reactivity/dedupe.d.ts +51 -0
  277. package/dist/src/reactivity/dedupe.d.ts.map +1 -0
  278. package/dist/src/reactivity/dedupe.js +90 -0
  279. package/dist/src/reactivity/dedupe.js.map +1 -0
  280. package/dist/src/reactivity/forwarder.d.ts +50 -0
  281. package/dist/src/reactivity/forwarder.d.ts.map +1 -0
  282. package/dist/src/reactivity/forwarder.js +52 -0
  283. package/dist/src/reactivity/forwarder.js.map +1 -0
  284. package/dist/src/reactivity/index.d.ts +34 -0
  285. package/dist/src/reactivity/index.d.ts.map +1 -0
  286. package/dist/src/reactivity/index.js +34 -0
  287. package/dist/src/reactivity/index.js.map +1 -0
  288. package/dist/src/reactivity/notification.d.ts +72 -0
  289. package/dist/src/reactivity/notification.d.ts.map +1 -0
  290. package/dist/src/reactivity/notification.js +92 -0
  291. package/dist/src/reactivity/notification.js.map +1 -0
  292. package/dist/src/reactivity/policy.d.ts +59 -0
  293. package/dist/src/reactivity/policy.d.ts.map +1 -0
  294. package/dist/src/reactivity/policy.js +64 -0
  295. package/dist/src/reactivity/policy.js.map +1 -0
  296. package/dist/src/reactivity/push-state.d.ts +140 -0
  297. package/dist/src/reactivity/push-state.d.ts.map +1 -0
  298. package/dist/src/reactivity/push-state.js +270 -0
  299. package/dist/src/reactivity/push-state.js.map +1 -0
  300. package/dist/src/reactivity/recover.d.ts +75 -0
  301. package/dist/src/reactivity/recover.d.ts.map +1 -0
  302. package/dist/src/reactivity/recover.js +105 -0
  303. package/dist/src/reactivity/recover.js.map +1 -0
  304. package/dist/src/reactivity/replay-buffer.d.ts +57 -0
  305. package/dist/src/reactivity/replay-buffer.d.ts.map +1 -0
  306. package/dist/src/reactivity/replay-buffer.js +88 -0
  307. package/dist/src/reactivity/replay-buffer.js.map +1 -0
  308. package/dist/src/reactivity/resume.d.ts +214 -0
  309. package/dist/src/reactivity/resume.d.ts.map +1 -0
  310. package/dist/src/reactivity/resume.js +358 -0
  311. package/dist/src/reactivity/resume.js.map +1 -0
  312. package/dist/src/reactivity/rotation.d.ts +283 -0
  313. package/dist/src/reactivity/rotation.d.ts.map +1 -0
  314. package/dist/src/reactivity/rotation.js +265 -0
  315. package/dist/src/reactivity/rotation.js.map +1 -0
  316. package/dist/src/reactivity/subscriber.d.ts +66 -0
  317. package/dist/src/reactivity/subscriber.d.ts.map +1 -0
  318. package/dist/src/reactivity/subscriber.js +75 -0
  319. package/dist/src/reactivity/subscriber.js.map +1 -0
  320. package/dist/src/reactivity/subscription.d.ts +52 -0
  321. package/dist/src/reactivity/subscription.d.ts.map +1 -0
  322. package/dist/src/reactivity/subscription.js +28 -0
  323. package/dist/src/reactivity/subscription.js.map +1 -0
  324. package/dist/src/reactivity/topic-anchor.d.ts +46 -0
  325. package/dist/src/reactivity/topic-anchor.d.ts.map +1 -0
  326. package/dist/src/reactivity/topic-anchor.js +61 -0
  327. package/dist/src/reactivity/topic-anchor.js.map +1 -0
  328. package/dist/src/reactivity/verify.d.ts +41 -0
  329. package/dist/src/reactivity/verify.d.ts.map +1 -0
  330. package/dist/src/reactivity/verify.js +48 -0
  331. package/dist/src/reactivity/verify.js.map +1 -0
  332. package/dist/src/reactivity/wire-validate.d.ts +28 -0
  333. package/dist/src/reactivity/wire-validate.d.ts.map +1 -0
  334. package/dist/src/reactivity/wire-validate.js +79 -0
  335. package/dist/src/reactivity/wire-validate.js.map +1 -0
  336. package/dist/src/reactivity/wire.d.ts +102 -0
  337. package/dist/src/reactivity/wire.d.ts.map +1 -0
  338. package/dist/src/reactivity/wire.js +129 -0
  339. package/dist/src/reactivity/wire.js.map +1 -0
  340. package/dist/src/transaction/coordinator.d.ts +9 -5
  341. package/dist/src/transaction/coordinator.d.ts.map +1 -1
  342. package/dist/src/transaction/coordinator.js +48 -25
  343. package/dist/src/transaction/coordinator.js.map +1 -1
  344. package/dist/src/transactor/change-notifier.d.ts +74 -0
  345. package/dist/src/transactor/change-notifier.d.ts.map +1 -0
  346. package/dist/src/transactor/change-notifier.js +4 -0
  347. package/dist/src/transactor/change-notifier.js.map +1 -0
  348. package/dist/src/transactor/index.d.ts +1 -0
  349. package/dist/src/transactor/index.d.ts.map +1 -1
  350. package/dist/src/transactor/index.js +1 -0
  351. package/dist/src/transactor/index.js.map +1 -1
  352. package/dist/src/transactor/network-transactor.d.ts +34 -2
  353. package/dist/src/transactor/network-transactor.d.ts.map +1 -1
  354. package/dist/src/transactor/network-transactor.js +113 -13
  355. package/dist/src/transactor/network-transactor.js.map +1 -1
  356. package/package.json +2 -2
  357. package/src/cluster/structs.ts +13 -0
  358. package/src/cohort-topic/addressing.ts +112 -0
  359. package/src/cohort-topic/antidos/bootstrap-evidence-envelope.ts +253 -0
  360. package/src/cohort-topic/antidos/bootstrap-evidence.ts +94 -0
  361. package/src/cohort-topic/antidos/index.ts +5 -0
  362. package/src/cohort-topic/antidos/rate-limiter.ts +210 -0
  363. package/src/cohort-topic/antidos/replay-guard.ts +109 -0
  364. package/src/cohort-topic/antidos/topic-budget.ts +145 -0
  365. package/src/cohort-topic/antiflood/index.ts +2 -0
  366. package/src/cohort-topic/antiflood/invariants.ts +108 -0
  367. package/src/cohort-topic/antiflood/jitter.ts +117 -0
  368. package/src/cohort-topic/coldstart.ts +204 -0
  369. package/src/cohort-topic/dmax.ts +88 -0
  370. package/src/cohort-topic/gossip/bus.ts +217 -0
  371. package/src/cohort-topic/gossip/index.ts +3 -0
  372. package/src/cohort-topic/gossip/records.ts +45 -0
  373. package/src/cohort-topic/gossip/view.ts +66 -0
  374. package/src/cohort-topic/index.ts +20 -0
  375. package/src/cohort-topic/load/barometer.ts +134 -0
  376. package/src/cohort-topic/load/index.ts +1 -0
  377. package/src/cohort-topic/member-engine.ts +409 -0
  378. package/src/cohort-topic/membership/index.ts +3 -0
  379. package/src/cohort-topic/membership/publisher.ts +171 -0
  380. package/src/cohort-topic/membership/source.ts +41 -0
  381. package/src/cohort-topic/membership/verifier.ts +345 -0
  382. package/src/cohort-topic/ports.ts +157 -0
  383. package/src/cohort-topic/promotion.ts +384 -0
  384. package/src/cohort-topic/registration/bytes.ts +37 -0
  385. package/src/cohort-topic/registration/handoff.ts +154 -0
  386. package/src/cohort-topic/registration/index.ts +6 -0
  387. package/src/cohort-topic/registration/renewal.ts +423 -0
  388. package/src/cohort-topic/registration/sharding.ts +61 -0
  389. package/src/cohort-topic/registration/store.ts +81 -0
  390. package/src/cohort-topic/registration/types.ts +76 -0
  391. package/src/cohort-topic/ring-hash.ts +50 -0
  392. package/src/cohort-topic/service.ts +390 -0
  393. package/src/cohort-topic/sig/index.ts +2 -0
  394. package/src/cohort-topic/sig/payloads.ts +39 -0
  395. package/src/cohort-topic/sig/threshold.ts +64 -0
  396. package/src/cohort-topic/tiers.ts +74 -0
  397. package/src/cohort-topic/traffic.ts +211 -0
  398. package/src/cohort-topic/walk.ts +255 -0
  399. package/src/cohort-topic/willingness.ts +237 -0
  400. package/src/cohort-topic/wire/codec.ts +204 -0
  401. package/src/cohort-topic/wire/index.ts +16 -0
  402. package/src/cohort-topic/wire/payloads.ts +117 -0
  403. package/src/cohort-topic/wire/types.ts +343 -0
  404. package/src/cohort-topic/wire/validate.ts +478 -0
  405. package/src/collection/collection.ts +93 -1
  406. package/src/collections/tree/tree.ts +84 -3
  407. package/src/index.ts +3 -0
  408. package/src/log/log.ts +86 -7
  409. package/src/log/struct.ts +126 -2
  410. package/src/matchmaking/capability-filter.ts +45 -0
  411. package/src/matchmaking/config.ts +98 -0
  412. package/src/matchmaking/index.ts +21 -0
  413. package/src/matchmaking/multi-cohort-seeker.ts +234 -0
  414. package/src/matchmaking/provider.ts +123 -0
  415. package/src/matchmaking/query-eval.ts +105 -0
  416. package/src/matchmaking/seeker-walk.ts +127 -0
  417. package/src/matchmaking/seeker.ts +86 -0
  418. package/src/matchmaking/topic-anchor.ts +90 -0
  419. package/src/matchmaking/voting-quorum.ts +394 -0
  420. package/src/matchmaking/wire.ts +680 -0
  421. package/src/network/i-repo.ts +9 -0
  422. package/src/network/repo-protocol.ts +3 -2
  423. package/src/network/struct.ts +24 -1
  424. package/src/reactivity/backfill.ts +220 -0
  425. package/src/reactivity/backpressure.ts +191 -0
  426. package/src/reactivity/checkpoint.ts +308 -0
  427. package/src/reactivity/config.ts +172 -0
  428. package/src/reactivity/dedupe.ts +132 -0
  429. package/src/reactivity/forwarder.ts +87 -0
  430. package/src/reactivity/index.ts +34 -0
  431. package/src/reactivity/notification.ts +123 -0
  432. package/src/reactivity/policy.ts +79 -0
  433. package/src/reactivity/push-state.ts +343 -0
  434. package/src/reactivity/recover.ts +153 -0
  435. package/src/reactivity/replay-buffer.ts +141 -0
  436. package/src/reactivity/resume.ts +549 -0
  437. package/src/reactivity/rotation.ts +415 -0
  438. package/src/reactivity/subscriber.ts +132 -0
  439. package/src/reactivity/subscription.ts +66 -0
  440. package/src/reactivity/topic-anchor.ts +71 -0
  441. package/src/reactivity/verify.ts +73 -0
  442. package/src/reactivity/wire-validate.ts +87 -0
  443. package/src/reactivity/wire.ts +224 -0
  444. package/src/transaction/coordinator.ts +53 -27
  445. package/src/transactor/change-notifier.ts +80 -0
  446. package/src/transactor/index.ts +1 -0
  447. package/src/transactor/network-transactor.ts +133 -15
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-state.js","sourceRoot":"","sources":["../../../src/reactivity/push-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAClJ,OAAO,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,4BAA4B,EAA6D,MAAM,mBAAmB,CAAC;AAC5H,OAAO,EAAE,iBAAiB,EAA+D,MAAM,iBAAiB,CAAC;AACjH,OAAO,EAAE,kBAAkB,EAAyC,MAAM,aAAa,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAmE,MAAM,oBAAoB,CAAC;AACzH,OAAO,EAAE,sBAAsB,EAAuB,MAAM,WAAW,CAAC;AAmDxE;;;GAGG;AACH,MAAM,OAAO,SAAS;IACZ,YAAY,CAAS;IACrB,OAAO,CAAS;IACzB,YAAY,CAAS;IACrB,YAAY,CAAa;IACzB,YAAY,CAAc;IACjB,YAAY,CAAe;IAC3B,MAAM,CAAe;IAC9B,YAAY,CAAS;IAErB;;;;;OAKG;IACM,UAAU,CAAoB;IACvC;;;;OAIG;IACM,kBAAkB,CAAyB;IACpD;;;;;;OAMG;IACK,SAAS,CAAqB;IAEtC,YAAY,IAAmB;QAC9B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI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E,aAAa,CAAC,OAAO,CAAC,EAAE;QAClE,CAAC,CAAC,EAAE,KAAK,EAAE,aAAa,CAAC,KAAK,CAAC,EAAE,CAAC;AACpC,CAAC"}
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Reactivity — recover RPC envelope (`docs/reactivity.md` §Backfill RPC, §Resume, §Wire formats).
3
+ *
4
+ * The db-p2p recover transport runs **one** request-reply protocol
5
+ * (`/optimystic/reactivity/1.0.0/recover`) carrying either a backfill or a resume exchange. Rather than
6
+ * disambiguate two payload shapes structurally off the wire, this module owns an explicit discriminated
7
+ * wrapper so the `kind` discriminant is authoritative: a `kind: "backfill"` frame MUST carry a `backfill`
8
+ * body and no `resume` body (and vice-versa). db-core owns every reactivity wire codec, so the envelope
9
+ * lives here next to the {@link import("./backfill.js").BackfillV1} / {@link import("./resume.js").ResumeV1}
10
+ * payloads it wraps and reuses their per-message validators for the inner branches.
11
+ *
12
+ * **Reply-only `"rotated"` kind.** A subscriber only ever *asks* for a backfill or a resume, so
13
+ * {@link RecoverKind} (the request discriminant) is the narrower `"backfill" | "resume"`. A *reply*,
14
+ * however, may carry a third kind — `"rotated"`, the drain-window {@link RotationRedirectV1} a serving
15
+ * cohort hands a request that arrived at an outgoing tail after it rotated (`docs/reactivity.md` §Tail
16
+ * rotation). The recover reply is the only reactivity surface a subscriber reaches a serving cohort on (a
17
+ * fresh subscribe rides generic cohort-topic `service.register`, whose walk only understands tier-`Promoted`,
18
+ * never a topic redirect), so the redirect rides the recover reply rather than registration.
19
+ *
20
+ * **Forward-compat (fail-closed).** A decoder that predates the `"rotated"` kind rejects it outright — its
21
+ * `kind` narrower only admits `backfill`/`resume` — so an older peer cannot misread a redirect; it simply
22
+ * treats the reply as malformed (no reply / decode failure) and the subscriber falls back to a chain read,
23
+ * which is always safe. A redirect is therefore an *optional optimization* a newer serving cohort offers,
24
+ * never a correctness dependency.
25
+ *
26
+ * Wire conventions match the rest of reactivity: JSON, byte fields base64url, `v: 1`, per-message
27
+ * structural validation on decode (a `kind`/branch mismatch is `failWire`).
28
+ */
29
+ import { type BackfillV1, type BackfillReplyV1 } from "./backfill.js";
30
+ import { type ResumeV1, type ResumeReplyV1 } from "./resume.js";
31
+ import { type RotationRedirectV1 } from "./rotation.js";
32
+ /** The recover RPC **request** discriminant: which of the two recovery exchanges a subscriber asks for. */
33
+ export type RecoverKind = "backfill" | "resume";
34
+ /**
35
+ * The recover RPC **reply** discriminant. A superset of {@link RecoverKind}: a reply may additionally be a
36
+ * `"rotated"` {@link RotationRedirectV1} (a subscriber never *asks* for a redirect, so the request kind
37
+ * stays narrower).
38
+ */
39
+ export type RecoverReplyKind = RecoverKind | "rotated";
40
+ /** A subscriber's recover request — exactly one of {@link backfill} / {@link resume}, per {@link kind}. */
41
+ export interface RecoverRequestV1 {
42
+ v: 1;
43
+ kind: RecoverKind;
44
+ /** Present iff `kind === "backfill"`. */
45
+ backfill?: BackfillV1;
46
+ /** Present iff `kind === "resume"`. */
47
+ resume?: ResumeV1;
48
+ }
49
+ /**
50
+ * The cohort's recover reply — exactly one of {@link backfillReply} / {@link resumeReply} / {@link rotated},
51
+ * per {@link kind}.
52
+ */
53
+ export interface RecoverReplyV1 {
54
+ v: 1;
55
+ kind: RecoverReplyKind;
56
+ /** Present iff `kind === "backfill"`. */
57
+ backfillReply?: BackfillReplyV1;
58
+ /** Present iff `kind === "resume"`. */
59
+ resumeReply?: ResumeReplyV1;
60
+ /** Present iff `kind === "rotated"` — the drain-window redirect to the rotated tree. */
61
+ rotated?: RotationRedirectV1;
62
+ }
63
+ /** Narrow an already-parsed value to {@link RecoverRequestV1}, throwing on any defect or kind/branch mismatch. */
64
+ export declare function validateRecoverRequestV1(value: unknown): RecoverRequestV1;
65
+ /** Narrow an already-parsed value to {@link RecoverReplyV1}, throwing on any defect or kind/branch mismatch. */
66
+ export declare function validateRecoverReplyV1(value: unknown): RecoverReplyV1;
67
+ /** Encode a {@link RecoverRequestV1} as a length-prefixed UTF-8 JSON frame. */
68
+ export declare function encodeRecoverRequestV1(msg: RecoverRequestV1, maxMessageBytes?: number): Uint8Array;
69
+ /** Decode a length-prefixed {@link RecoverRequestV1} frame. */
70
+ export declare function decodeRecoverRequestV1(bytes: Uint8Array, maxMessageBytes?: number): RecoverRequestV1;
71
+ /** Encode a {@link RecoverReplyV1} as a length-prefixed UTF-8 JSON frame. */
72
+ export declare function encodeRecoverReplyV1(msg: RecoverReplyV1, maxMessageBytes?: number): Uint8Array;
73
+ /** Decode a length-prefixed {@link RecoverReplyV1} frame. */
74
+ export declare function decodeRecoverReplyV1(bytes: Uint8Array, maxMessageBytes?: number): RecoverReplyV1;
75
+ //# sourceMappingURL=recover.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recover.d.ts","sourceRoot":"","sources":["../../../src/reactivity/recover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAQH,OAAO,EAA+C,KAAK,UAAU,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AACnH,OAAO,EAA2C,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACzG,OAAO,EAA8B,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEpF,2GAA2G;AAC3G,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEhD;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,SAAS,CAAC;AAEvD,2GAA2G;AAC3G,MAAM,WAAW,gBAAgB;IAChC,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,WAAW,CAAC;IAClB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB,uCAAuC;IACvC,MAAM,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC9B,CAAC,EAAE,CAAC,CAAC;IACL,IAAI,EAAE,gBAAgB,CAAC;IACvB,yCAAyC;IACzC,aAAa,CAAC,EAAE,eAAe,CAAC;IAChC,uCAAuC;IACvC,WAAW,CAAC,EAAE,aAAa,CAAC;IAC5B,wFAAwF;IACxF,OAAO,CAAC,EAAE,kBAAkB,CAAC;CAC7B;AA2BD,kHAAkH;AAClH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAWzE;AAED,gHAAgH;AAChH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,CAkBrE;AAED,+EAA+E;AAC/E,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,gBAAgB,EAAE,eAAe,GAAE,MAAkC,GAAG,UAAU,CAE7H;AAED,+DAA+D;AAC/D,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAEpG;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,cAAc,EAAE,eAAe,GAAE,MAAkC,GAAG,UAAU,CAEzH;AAED,6DAA6D;AAC7D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,cAAc,CAEhG"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Reactivity — recover RPC envelope (`docs/reactivity.md` §Backfill RPC, §Resume, §Wire formats).
3
+ *
4
+ * The db-p2p recover transport runs **one** request-reply protocol
5
+ * (`/optimystic/reactivity/1.0.0/recover`) carrying either a backfill or a resume exchange. Rather than
6
+ * disambiguate two payload shapes structurally off the wire, this module owns an explicit discriminated
7
+ * wrapper so the `kind` discriminant is authoritative: a `kind: "backfill"` frame MUST carry a `backfill`
8
+ * body and no `resume` body (and vice-versa). db-core owns every reactivity wire codec, so the envelope
9
+ * lives here next to the {@link import("./backfill.js").BackfillV1} / {@link import("./resume.js").ResumeV1}
10
+ * payloads it wraps and reuses their per-message validators for the inner branches.
11
+ *
12
+ * **Reply-only `"rotated"` kind.** A subscriber only ever *asks* for a backfill or a resume, so
13
+ * {@link RecoverKind} (the request discriminant) is the narrower `"backfill" | "resume"`. A *reply*,
14
+ * however, may carry a third kind — `"rotated"`, the drain-window {@link RotationRedirectV1} a serving
15
+ * cohort hands a request that arrived at an outgoing tail after it rotated (`docs/reactivity.md` §Tail
16
+ * rotation). The recover reply is the only reactivity surface a subscriber reaches a serving cohort on (a
17
+ * fresh subscribe rides generic cohort-topic `service.register`, whose walk only understands tier-`Promoted`,
18
+ * never a topic redirect), so the redirect rides the recover reply rather than registration.
19
+ *
20
+ * **Forward-compat (fail-closed).** A decoder that predates the `"rotated"` kind rejects it outright — its
21
+ * `kind` narrower only admits `backfill`/`resume` — so an older peer cannot misread a redirect; it simply
22
+ * treats the reply as malformed (no reply / decode failure) and the subscriber falls back to a chain read,
23
+ * which is always safe. A redirect is therefore an *optional optimization* a newer serving cohort offers,
24
+ * never a correctness dependency.
25
+ *
26
+ * Wire conventions match the rest of reactivity: JSON, byte fields base64url, `v: 1`, per-message
27
+ * structural validation on decode (a `kind`/branch mismatch is `failWire`).
28
+ */
29
+ import { decodeCohortMessage, encodeCohortMessage, DEFAULT_MAX_MESSAGE_BYTES, } from "../cohort-topic/wire/codec.js";
30
+ import { asObject, failWire, requireV1 } from "./wire-validate.js";
31
+ import { validateBackfillV1, validateBackfillReplyV1 } from "./backfill.js";
32
+ import { validateResumeV1, validateResumeReplyV1 } from "./resume.js";
33
+ import { validateRotationRedirectV1 } from "./rotation.js";
34
+ /** Narrow `obj.kind` to a {@link RecoverKind} (request side), throwing on any other value. */
35
+ function reqKind(obj, what) {
36
+ const kind = obj["kind"];
37
+ if (kind !== "backfill" && kind !== "resume") {
38
+ failWire(`${what}: field "kind" must be "backfill" or "resume"`);
39
+ }
40
+ return kind;
41
+ }
42
+ /** Narrow `obj.kind` to a {@link RecoverReplyKind} (reply side — also admits `"rotated"`). */
43
+ function reqReplyKind(obj, what) {
44
+ const kind = obj["kind"];
45
+ if (kind !== "backfill" && kind !== "resume" && kind !== "rotated") {
46
+ failWire(`${what}: field "kind" must be "backfill", "resume", or "rotated"`);
47
+ }
48
+ return kind;
49
+ }
50
+ /** Reject a frame carrying `branch`, the body that does not belong to the declared `kind`. */
51
+ function rejectStrayBranch(obj, branch, what) {
52
+ if (obj[branch] !== undefined) {
53
+ failWire(`${what}: a "${branch}" body is present but does not match the declared kind`);
54
+ }
55
+ }
56
+ /** Narrow an already-parsed value to {@link RecoverRequestV1}, throwing on any defect or kind/branch mismatch. */
57
+ export function validateRecoverRequestV1(value) {
58
+ const what = "RecoverRequestV1";
59
+ const obj = asObject(value, what);
60
+ requireV1(obj, what);
61
+ const kind = reqKind(obj, what);
62
+ if (kind === "backfill") {
63
+ rejectStrayBranch(obj, "resume", what);
64
+ return { v: 1, kind, backfill: validateBackfillV1(obj["backfill"]) };
65
+ }
66
+ rejectStrayBranch(obj, "backfill", what);
67
+ return { v: 1, kind, resume: validateResumeV1(obj["resume"]) };
68
+ }
69
+ /** Narrow an already-parsed value to {@link RecoverReplyV1}, throwing on any defect or kind/branch mismatch. */
70
+ export function validateRecoverReplyV1(value) {
71
+ const what = "RecoverReplyV1";
72
+ const obj = asObject(value, what);
73
+ requireV1(obj, what);
74
+ const kind = reqReplyKind(obj, what);
75
+ if (kind === "backfill") {
76
+ rejectStrayBranch(obj, "resumeReply", what);
77
+ rejectStrayBranch(obj, "rotated", what);
78
+ return { v: 1, kind, backfillReply: validateBackfillReplyV1(obj["backfillReply"]) };
79
+ }
80
+ if (kind === "resume") {
81
+ rejectStrayBranch(obj, "backfillReply", what);
82
+ rejectStrayBranch(obj, "rotated", what);
83
+ return { v: 1, kind, resumeReply: validateResumeReplyV1(obj["resumeReply"]) };
84
+ }
85
+ rejectStrayBranch(obj, "backfillReply", what);
86
+ rejectStrayBranch(obj, "resumeReply", what);
87
+ return { v: 1, kind, rotated: validateRotationRedirectV1(obj["rotated"]) };
88
+ }
89
+ /** Encode a {@link RecoverRequestV1} as a length-prefixed UTF-8 JSON frame. */
90
+ export function encodeRecoverRequestV1(msg, maxMessageBytes = DEFAULT_MAX_MESSAGE_BYTES) {
91
+ return encodeCohortMessage(validateRecoverRequestV1(msg), maxMessageBytes);
92
+ }
93
+ /** Decode a length-prefixed {@link RecoverRequestV1} frame. */
94
+ export function decodeRecoverRequestV1(bytes, maxMessageBytes) {
95
+ return validateRecoverRequestV1(decodeCohortMessage(bytes, maxMessageBytes));
96
+ }
97
+ /** Encode a {@link RecoverReplyV1} as a length-prefixed UTF-8 JSON frame. */
98
+ export function encodeRecoverReplyV1(msg, maxMessageBytes = DEFAULT_MAX_MESSAGE_BYTES) {
99
+ return encodeCohortMessage(validateRecoverReplyV1(msg), maxMessageBytes);
100
+ }
101
+ /** Decode a length-prefixed {@link RecoverReplyV1} frame. */
102
+ export function decodeRecoverReplyV1(bytes, maxMessageBytes) {
103
+ return validateRecoverReplyV1(decodeCohortMessage(bytes, maxMessageBytes));
104
+ }
105
+ //# sourceMappingURL=recover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recover.js","sourceRoot":"","sources":["../../../src/reactivity/recover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EACN,mBAAmB,EACnB,mBAAmB,EACnB,yBAAyB,GACzB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,kBAAkB,EAAE,uBAAuB,EAAyC,MAAM,eAAe,CAAC;AACnH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAqC,MAAM,aAAa,CAAC;AACzG,OAAO,EAAE,0BAA0B,EAA2B,MAAM,eAAe,CAAC;AAqCpF,8FAA8F;AAC9F,SAAS,OAAO,CAAC,GAA4B,EAAE,IAAY;IAC1D,MAAM,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,IAAI,KAAK,UAAU,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,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC;AAC5E,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,sBAAsB,CAAC,GAAqB,EAAE,kBAA0B,yBAAyB;IAChH,OAAO,mBAAmB,CAAC,wBAAwB,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,CAAC;AAC5E,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,sBAAsB,CAAC,KAAiB,EAAE,eAAwB;IACjF,OAAO,wBAAwB,CAAC,mBAAmB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC;AAC9E,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,oBAAoB,CAAC,GAAmB,EAAE,kBAA0B,yBAAyB;IAC5G,OAAO,mBAAmB,CAAC,sBAAsB,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,CAAC;AAC1E,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,oBAAoB,CAAC,KAAiB,EAAE,eAAwB;IAC/E,OAAO,sBAAsB,CAAC,mBAAmB,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Reactivity — replay window (`docs/reactivity.md` §Replay window).
3
+ *
4
+ * Each forwarder and the tail cohort keep a per-collection ring buffer of the last `W` notifications
5
+ * (default 256). Entries are gossiped across the cohort ({@link ReplayBuffer.serialize} /
6
+ * {@link ReplayBuffer.merge}) so **any** cohort member — not just the primary — can serve a replay if
7
+ * the primary is unavailable. This buffer is the substrate the backfill/resume ticket reads from; this
8
+ * ticket owns its construction, ring semantics, gossip replication, and the any-member-serves property.
9
+ *
10
+ * The ring is keyed by revision, not by insertion slot, so a retransmit that arrives out of order (the
11
+ * recovery case the dedupe window admits) lands at its correct revision. Capacity `W` bounds the number
12
+ * of *distinct revisions* retained; the lowest revision is dropped when a new one overflows the ring.
13
+ */
14
+ import type { NotificationV1 } from "./wire.js";
15
+ /** One replay-buffer entry: the full signed notification plus its local receive time. */
16
+ export interface RevisionEntry {
17
+ readonly revision: number;
18
+ /** The full signed notification (retains the original threshold signature; backfills verify end-to-end). */
19
+ readonly payload: NotificationV1;
20
+ /** Unix ms. */
21
+ readonly receivedAt: number;
22
+ }
23
+ /** Serializable replay-buffer state for intra-cohort gossip replication. */
24
+ export interface ReplayBufferStateV1 {
25
+ readonly capacity: number;
26
+ readonly entries: readonly RevisionEntry[];
27
+ }
28
+ /** A per-collection ring buffer of the last `W` notifications, gossip-replicated across the cohort. */
29
+ export interface ReplayBuffer {
30
+ /** Configured ring capacity `W`. */
31
+ readonly capacity: number;
32
+ /** Number of distinct revisions currently retained. */
33
+ readonly size: number;
34
+ /** Lowest retained revision, or `undefined` when empty. */
35
+ readonly lowRevision: number | undefined;
36
+ /** Highest retained revision, or `undefined` when empty. */
37
+ readonly highRevision: number | undefined;
38
+ /** Append (or replace, on a retransmit) the entry for its revision, evicting the lowest on overflow. */
39
+ append(entry: RevisionEntry): void;
40
+ /** The entry for `revision`, or `undefined` if not in the window. */
41
+ get(revision: number): RevisionEntry | undefined;
42
+ /** Entries with `from <= revision <= to`, ascending — the intersection with the window. */
43
+ range(from: number, to: number): RevisionEntry[];
44
+ /** All retained entries, ascending by revision. */
45
+ entries(): RevisionEntry[];
46
+ /** Snapshot for gossip. */
47
+ serialize(): ReplayBufferStateV1;
48
+ /** Merge another member's gossiped buffer (newer `receivedAt` wins a per-revision tie). */
49
+ merge(state: ReplayBufferStateV1): void;
50
+ }
51
+ /**
52
+ * Build a {@link ReplayBuffer} with capacity `W` (default {@link W_DEFAULT}). `onEvict`, when supplied, is
53
+ * invoked with each entry retired from the ring's low edge (the {@link PushState} wires it to the rolling
54
+ * checkpoint so revisions leaving the replay window roll into the parent-checkpoint summary).
55
+ */
56
+ export declare function createReplayBuffer(capacity?: number, onEvict?: (entry: RevisionEntry) => void): ReplayBuffer;
57
+ //# sourceMappingURL=replay-buffer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,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ACxC;AA+ED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,GAAE,MAAkB,EAAE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,GAAG,YAAY,CAEvH"}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Reactivity — replay window (`docs/reactivity.md` §Replay window).
3
+ *
4
+ * Each forwarder and the tail cohort keep a per-collection ring buffer of the last `W` notifications
5
+ * (default 256). Entries are gossiped across the cohort ({@link ReplayBuffer.serialize} /
6
+ * {@link ReplayBuffer.merge}) so **any** cohort member — not just the primary — can serve a replay if
7
+ * the primary is unavailable. This buffer is the substrate the backfill/resume ticket reads from; this
8
+ * ticket owns its construction, ring semantics, gossip replication, and the any-member-serves property.
9
+ *
10
+ * The ring is keyed by revision, not by insertion slot, so a retransmit that arrives out of order (the
11
+ * recovery case the dedupe window admits) lands at its correct revision. Capacity `W` bounds the number
12
+ * of *distinct revisions* retained; the lowest revision is dropped when a new one overflows the ring.
13
+ */
14
+ import { W_DEFAULT } from "./config.js";
15
+ class RingReplayBuffer {
16
+ capacity;
17
+ /** revision → entry; trimmed to the highest `capacity` revisions. */
18
+ byRevision = new Map();
19
+ onEvict;
20
+ constructor(capacity, onEvict) {
21
+ if (!Number.isInteger(capacity) || capacity < 1) {
22
+ throw new RangeError(`reactivity replay buffer: capacity must be an integer >= 1, got ${capacity}`);
23
+ }
24
+ this.capacity = capacity;
25
+ this.onEvict = onEvict;
26
+ }
27
+ get size() {
28
+ return this.byRevision.size;
29
+ }
30
+ get lowRevision() {
31
+ return this.size === 0 ? undefined : Math.min(...this.byRevision.keys());
32
+ }
33
+ get highRevision() {
34
+ return this.size === 0 ? undefined : Math.max(...this.byRevision.keys());
35
+ }
36
+ append(entry) {
37
+ this.byRevision.set(entry.revision, entry);
38
+ this.trim();
39
+ }
40
+ get(revision) {
41
+ return this.byRevision.get(revision);
42
+ }
43
+ range(from, to) {
44
+ // Iterate the retained entries (≤ capacity) rather than every integer in `[from, to]`: a backfill
45
+ // request carries a subscriber-supplied range that may be arbitrarily wide, so a per-integer scan
46
+ // would be an unbounded loop on attacker-controlled input. The intersection with the window is
47
+ // bounded by `capacity` regardless.
48
+ return this.entries().filter((e) => e.revision >= from && e.revision <= to);
49
+ }
50
+ entries() {
51
+ return [...this.byRevision.values()].sort((a, b) => a.revision - b.revision);
52
+ }
53
+ serialize() {
54
+ return { capacity: this.capacity, entries: this.entries() };
55
+ }
56
+ merge(state) {
57
+ for (const entry of state.entries) {
58
+ const existing = this.byRevision.get(entry.revision);
59
+ // Per-revision convergence: the freshest receiver's copy wins (they carry the same end-to-end
60
+ // signature, so this only breaks ties on `receivedAt`, never trusts a forged payload).
61
+ if (existing === undefined || entry.receivedAt > existing.receivedAt) {
62
+ this.byRevision.set(entry.revision, entry);
63
+ }
64
+ }
65
+ this.trim();
66
+ }
67
+ /** Evict the lowest revisions until at most `capacity` distinct revisions remain. */
68
+ trim() {
69
+ while (this.byRevision.size > this.capacity) {
70
+ const lowest = Math.min(...this.byRevision.keys());
71
+ const evicted = this.byRevision.get(lowest);
72
+ this.byRevision.delete(lowest);
73
+ // Hand the retired revision to the (optional) observer — the rolling parent checkpoint
74
+ // (`docs/reactivity.md` §Parent checkpoint summaries) feeds on exactly these evictions so its
75
+ // span tracks the window immediately below the ring's low edge.
76
+ this.onEvict?.(evicted);
77
+ }
78
+ }
79
+ }
80
+ /**
81
+ * Build a {@link ReplayBuffer} with capacity `W` (default {@link W_DEFAULT}). `onEvict`, when supplied, is
82
+ * invoked with each entry retired from the ring's low edge (the {@link PushState} wires it to the rolling
83
+ * checkpoint so revisions leaving the replay window roll into the parent-checkpoint summary).
84
+ */
85
+ export function createReplayBuffer(capacity = W_DEFAULT, onEvict) {
86
+ return new RingReplayBuffer(capacity, onEvict);
87
+ }
88
+ //# sourceMappingURL=replay-buffer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replay-buffer.js","sourceRoot":"","sources":["../../../src/reactivity/replay-buff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I,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;YACnD,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAE,CAAC;YAC7C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAC/B,uFAAuF;YACvF,8FAA8F;YAC9F,gEAAgE;YAChE,IAAI,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;IACF,CAAC;CACD;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,WAAmB,SAAS,EAAE,OAAwC;IACxG,OAAO,IAAI,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Reactivity — Resume RPC: classification, serving, and subscriber-side apply
3
+ * (`docs/reactivity.md` §Resume, §Parent checkpoint summaries, §Wire formats Resume).
4
+ *
5
+ * A subscriber waking from sleep sends one {@link ResumeV1} to its cached primary (or any cohort member).
6
+ * The serving cohort classifies the request against its **stacked** recovery windows — the `W`-deep replay
7
+ * ring sits on top of the `W_checkpoint`-span parent checkpoint immediately below it, so a single round
8
+ * trip recovers `W + W_checkpoint` revisions — and answers with one of four {@link ResumeReplyV1} variants
9
+ * (`docs/reactivity.md` §Replay window, the authoritative stacked semantics):
10
+ *
11
+ * - **Backfill** — `fromRevision` is within the replay ring (`fromRevision ≥ ringLow`). Returns the
12
+ * `[fromRevision, currentRevision]` slice + `currentRevision`. One RT.
13
+ * - **CheckpointWindow** — `fromRevision` is below the ring but within the parent checkpoint span
14
+ * (`chain low ≤ fromRevision < ringLow`). Returns an ordered, contiguous **chain** of
15
+ * {@link CheckpointSummary}s (`checkpoints`, low→high) + the ring's `recentEntries`. The subscriber
16
+ * verifies every link's endpoints, applies each link's merged digest, advances its contiguity head past
17
+ * the whole chain, then replays the recent entries deduped against `lastRevision`. One RT. The chain is a
18
+ * single link in steady state; a new tail that took over across a rotation serves a **two-link**
19
+ * `[inherited, rolling]` chain when a `fromRevision` below both the ring and the rolling checkpoint falls
20
+ * inside the inherited handoff window — so the full stacked range recovers in one reply regardless of
21
+ * where the new tail's own rolling checkpoint has formed (`docs/reactivity.md` §Tail rotation step 5 —
22
+ * "the new tail holds the old checkpoint").
23
+ * - **OutOfWindow** — older than even the checkpoint. Returns `currentTailId` + `currentRevision`; the
24
+ * subscriber falls back to a chain read, then a fresh subscribe.
25
+ * - **TailRotated** — the request's `latestKnownTailId` does not match the cohort's current tail (the
26
+ * subscriber slept across a rotation). Returns `newTailId` + `newRevisionAtRotation`; the subscriber
27
+ * re-registers under the new tail. This is checked **first**: a stale tail means the whole tree moved,
28
+ * so the lag-against-windows classification is moot. The rotation *lifecycle* is owned by
29
+ * [reactivity-rotation-backpressure-policy]; this module only **detects** the stale tail and emits the
30
+ * reply so resume composes with rotation.
31
+ *
32
+ * Wire conventions match the rest of reactivity: JSON, byte fields base64url, unix-ms timestamps, `v: 1`,
33
+ * per-message structural validation on decode. `ResumeV1` is signed by the subscriber's peer key
34
+ * (`signature`); replay protection rides the request envelope as elsewhere in the substrate.
35
+ */
36
+ import { type CheckpointSummary, type RollingCheckpoint } from "./checkpoint.js";
37
+ import type { ReplayBuffer } from "./replay-buffer.js";
38
+ import type { ReactivitySubscriber } from "./subscriber.js";
39
+ import type { NotificationVerifier } from "./verify.js";
40
+ import { type NotificationV1 } from "./wire.js";
41
+ /** The four resume classifications (`docs/reactivity.md` §Resume). */
42
+ export type ResumeResult = "backfill" | "checkpoint_window" | "out_of_window" | "tail_rotated";
43
+ /** A subscriber's resume request after waking from sleep. */
44
+ export interface ResumeV1 {
45
+ v: 1;
46
+ /** Collection id, base64url. */
47
+ collectionId: string;
48
+ /** First revision the subscriber still needs (`lastRevision + 1`). */
49
+ fromRevision: number;
50
+ /** Tail block id the subscriber believes is current, base64url (the stale-tail detector). */
51
+ latestKnownTailId: string;
52
+ /** The subscriber's ring coordinate, base64url (for the cohort to route the reply). */
53
+ subscriberCoord: string;
54
+ /** Unix ms. */
55
+ timestamp: number;
56
+ /** Subscriber peer-key signature over the request. */
57
+ signature: string;
58
+ }
59
+ /** The cohort's classified reply. Fields are populated per the `result` discriminant. */
60
+ export interface ResumeReplyV1 {
61
+ v: 1;
62
+ result: ResumeResult;
63
+ /** The `[fromRevision, currentRevision]` slice held in the replay ring (backfill). */
64
+ entries?: NotificationV1[];
65
+ /** Highest committed revision the serving cohort knows (backfill / checkpoint_window / out_of_window). */
66
+ currentRevision?: number;
67
+ /**
68
+ * The parent-checkpoint chain spanning `[chain[0].fromRevision, ringLow − 1]` (checkpoint_window), ordered
69
+ * low→high and **contiguous**: each `checkpoints[i].fromRevision === checkpoints[i-1].toRevision + 1`. A
70
+ * single link in steady state; a cross-rotation resume carries the two-link `[inherited, rolling]` bridge.
71
+ * The subscriber verifies and applies every link in sequence (see {@link applyResumeReply}).
72
+ */
73
+ checkpoints?: CheckpointSummary[];
74
+ /** The replay ring's entries, replayed deduped against `lastRevision` after the digests apply. */
75
+ recentEntries?: NotificationV1[];
76
+ /** Current tail block id, base64url — the subscriber re-subscribes after a chain read (out_of_window). */
77
+ currentTailId?: string;
78
+ /** New tail block id the topic rotated to, base64url (tail_rotated). */
79
+ newTailId?: string;
80
+ /** Revision at which the rotation took effect (tail_rotated). */
81
+ newRevisionAtRotation?: number;
82
+ }
83
+ /** Narrow an already-parsed value to {@link ResumeV1}, throwing on any defect. */
84
+ export declare function validateResumeV1(value: unknown): ResumeV1;
85
+ /** Narrow an already-parsed value to {@link ResumeReplyV1}, throwing on any defect. */
86
+ export declare function validateResumeReplyV1(value: unknown): ResumeReplyV1;
87
+ /** A {@link ResumeV1} minus its `signature` — the canonical bytes the subscriber peer-key-signs. */
88
+ export type ResumeSignable = Omit<ResumeV1, "signature">;
89
+ /**
90
+ * Canonical signed byte image of a {@link ResumeV1} (every field except `signature`). Mirrors
91
+ * {@link import("./backfill.js").backfillSigningPayload}: an explicitly-ordered, type-tagged JSON array
92
+ * encoded as UTF-8. The `"ResumeV1"` tag means a resume image can never collide with the `"BackfillV1"`
93
+ * image. `subscriberCoord` is part of the image, so a verifier recomputes over whatever coordinate the
94
+ * request carries — the field order is the byte-for-byte contract between signer and verifier.
95
+ */
96
+ export declare function resumeSigningPayload(body: ResumeSignable): Uint8Array;
97
+ /** Encode a {@link ResumeV1} as a length-prefixed UTF-8 JSON frame. */
98
+ export declare function encodeResumeV1(msg: ResumeV1, maxMessageBytes?: number): Uint8Array;
99
+ /** Decode a length-prefixed {@link ResumeV1} frame. */
100
+ export declare function decodeResumeV1(bytes: Uint8Array, maxMessageBytes?: number): ResumeV1;
101
+ /** Encode a {@link ResumeReplyV1} as a length-prefixed UTF-8 JSON frame. */
102
+ export declare function encodeResumeReplyV1(msg: ResumeReplyV1, maxMessageBytes?: number): Uint8Array;
103
+ /** Decode a length-prefixed {@link ResumeReplyV1} frame. */
104
+ export declare function decodeResumeReplyV1(bytes: Uint8Array, maxMessageBytes?: number): ResumeReplyV1;
105
+ /**
106
+ * Classify a resume request against the serving cohort's stacked windows. The decision order is:
107
+ *
108
+ * 1. **tail_rotated** — `req.latestKnownTailId !== currentTailId`. A stale tail means the tree migrated,
109
+ * so the lag classification below is moot.
110
+ * 2. **backfill** — `fromRevision` is at/above the replay ring's low edge (within, or already current).
111
+ * 3. **checkpoint_window** — below the ring but a gap-free {@link resumeCheckpointChain} covers it: the
112
+ * rolling checkpoint (steady state), the inherited cross-rotation handoff (`docs/reactivity.md` §Tail
113
+ * rotation step 5 — "the new tail holds the old checkpoint"), or the two-link `[inherited, rolling]`
114
+ * bridge spanning both when the new tail's own rolling checkpoint has formed between the handoff and the
115
+ * ring.
116
+ * 4. **out_of_window** — older than even the deepest window, or a gap leaves no contiguous chain to the
117
+ * ring (a chain read), or every window is empty/absent.
118
+ */
119
+ export declare function classifyResume(req: ResumeV1, buffer: ReplayBuffer, checkpoint: RollingCheckpoint | undefined, currentTailId: string, inherited?: CheckpointSummary): ResumeResult;
120
+ /** Construction inputs for {@link serveResume}. */
121
+ export interface ResumeServingDeps {
122
+ /** The cohort's replay ring (the live `PushState.replayBuffer`). */
123
+ readonly buffer: ReplayBuffer;
124
+ /** The cohort's rolling parent checkpoint (the live `PushState.checkpoint`). */
125
+ readonly checkpoint?: RollingCheckpoint;
126
+ /**
127
+ * The checkpoint migrated from the **outgoing** tail when this cohort became the new tail across a
128
+ * rotation (the live `PushState.inheritedCheckpoint`). Consulted when the rolling {@link checkpoint} does
129
+ * not cover `fromRevision`: a resume whose span crosses the rotation is answered from the inherited window
130
+ * — either alone (it abuts the ring directly) or as the lower link of the two-link `[inherited, rolling]`
131
+ * bridge when the new tail's own rolling checkpoint has formed between the handoff and the ring (see
132
+ * {@link resumeCheckpointChain}) — instead of falling to `out_of_window` (`docs/reactivity.md` §Tail
133
+ * rotation step 5).
134
+ */
135
+ readonly inheritedCheckpoint?: CheckpointSummary;
136
+ /** The cohort's current tail block id, base64url. */
137
+ readonly currentTailId: string;
138
+ /** Highest committed revision the cohort knows (the live `PushState.lastRevision`). */
139
+ readonly currentRevision: number;
140
+ /** Revision the current tail became effective (for a tail_rotated reply); defaults to `currentRevision`. */
141
+ readonly rotationRevision?: number;
142
+ /** Collection this cohort serves, base64url — a foreign-collection request is rejected. */
143
+ readonly expectedCollectionId: string;
144
+ }
145
+ /**
146
+ * Serve a {@link ResumeV1} from a cohort's stacked windows, producing the classified {@link ResumeReplyV1}.
147
+ * Pure over the supplied snapshot — no I/O, no clock. A request whose `collectionId` does not match
148
+ * `expectedCollectionId` is rejected (a resume is collection-scoped).
149
+ */
150
+ export declare function serveResume(req: ResumeV1, deps: ResumeServingDeps): ResumeReplyV1;
151
+ /** The outcome of applying a {@link ResumeReplyV1} subscriber-side. */
152
+ export type ResumeApplyOutcome =
153
+ /** Backfill entries were replayed through the delivery path; the subscriber is current. */
154
+ "backfilled"
155
+ /** Checkpoint endpoints verified, digest applied, recent entries replayed; the subscriber is current. */
156
+ | "checkpoint_applied"
157
+ /** Checkpoint bracketing endpoints failed to verify (forged/tampered) — the subscriber must chain-read. */
158
+ | "checkpoint_untrusted"
159
+ /** Out of every window — the subscriber must chain-read then re-subscribe. */
160
+ | "out_of_window"
161
+ /** Tail rotated — the subscriber must re-register under the new tail. */
162
+ | "tail_rotated";
163
+ /** Sinks for {@link applyResumeReply} — each non-backfill variant escalates to the application. */
164
+ export interface ResumeApplyDeps {
165
+ /** Feeds replayed entries through the verify → contiguity → deliver path (closing the gap, deduping). */
166
+ readonly subscriber: ReactivitySubscriber;
167
+ /** Verifies a checkpoint's bracketing endpoints are real committed revisions. */
168
+ readonly verifier: NotificationVerifier;
169
+ /** Apply a verified checkpoint's merged digest (e.g. invalidate the changed keys). */
170
+ readonly onCheckpointDigest?: (summary: CheckpointSummary) => void;
171
+ /** Fall back to a chain read + fresh subscribe (out_of_window, or an untrusted checkpoint). */
172
+ readonly onChainRead?: (currentTailId: string | undefined, currentRevision: number | undefined) => void;
173
+ /** Re-register under the rotated tail (tail_rotated). */
174
+ readonly onTailRotated?: (newTailId: string, newRevisionAtRotation: number) => void;
175
+ }
176
+ /**
177
+ * Apply a {@link ResumeReplyV1} on the subscriber side, returning the {@link ResumeApplyOutcome}. Backfill
178
+ * and checkpoint-window entries re-enter through {@link ReactivitySubscriber.onNotification} (so they are
179
+ * verified, contiguity-checked, and deduped exactly like live notifications); the other variants escalate
180
+ * to the application via the supplied sinks. A checkpoint whose bracketing endpoints do not verify is
181
+ * **not** applied — the subscriber chain-reads instead (a forged checkpoint must never advance state).
182
+ */
183
+ export declare function applyResumeReply(reply: ResumeReplyV1, deps: ResumeApplyDeps): Promise<ResumeApplyOutcome>;
184
+ /**
185
+ * A cached cohort hint for fast reactivity re-attach (`docs/reactivity.md` §Edge profile: "`cohortHint`
186
+ * is sticky-cached across reconnects so brief network flaps don't trigger re-walk"). Distinct from the
187
+ * cohort-topic `CohortHint` (the full resolved cohort) — this is the minimal sticky-cached slice the
188
+ * subscriber dials a resume at directly. All ids base64url.
189
+ */
190
+ export interface ReactivityCohortHint {
191
+ /** The collection's tail-anchored topic id at cache time. */
192
+ readonly topicId: string;
193
+ /** The cached serving primary. */
194
+ readonly primary: string;
195
+ /** The cohort member set for fast re-attach. */
196
+ readonly cohortHint: readonly string[];
197
+ }
198
+ /**
199
+ * A sticky per-collection cache of the last-known serving cohort, keyed by collection id. **Sticky** means
200
+ * it survives reconnects — a brief network flap reuses the cached primary so resume is one round trip
201
+ * instead of a re-walk from `d_max`. It is invalidated only on an explicit signal (a `TailRotated` reply,
202
+ * or a confirmed-stale primary), never merely on a transient failure.
203
+ */
204
+ export interface StickyCohortHintCache {
205
+ /** The cached hint for `collectionId`, or `undefined` if none. */
206
+ get(collectionId: string): ReactivityCohortHint | undefined;
207
+ /** Cache (or refresh) the hint for `collectionId`. */
208
+ set(collectionId: string, hint: ReactivityCohortHint): void;
209
+ /** Drop the cached hint for `collectionId` (on rotation / confirmed staleness). */
210
+ invalidate(collectionId: string): void;
211
+ }
212
+ /** Build a {@link StickyCohortHintCache} (a plain per-collection map; sticky across reconnects). */
213
+ export declare function createStickyCohortHintCache(): StickyCohortHintCache;
214
+ //# sourceMappingURL=resume.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resume.d.ts","sourceRoot":"","sources":["../../../src/reactivity/resume.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAgBH,OAAO,EAAwD,KAAK,iBAAiB,EAAE,KAAK,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEvI,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAA6B,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAE3E,sEAAsE;AACtE,MAAM,MAAM,YAA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