@rocicorp/zero 1.10.0-canary.24 → 1.10.0-canary.26

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 (568) hide show
  1. package/out/analyze-query/src/bin-analyze.js +8 -9
  2. package/out/analyze-query/src/bin-analyze.js.map +1 -1
  3. package/out/replicache/src/btree/node.d.ts.map +1 -1
  4. package/out/replicache/src/btree/node.js +6 -3
  5. package/out/replicache/src/btree/node.js.map +1 -1
  6. package/out/replicache/src/btree/read.d.ts +1 -12
  7. package/out/replicache/src/btree/read.d.ts.map +1 -1
  8. package/out/replicache/src/btree/read.js +12 -24
  9. package/out/replicache/src/btree/read.js.map +1 -1
  10. package/out/replicache/src/dag/gc.d.ts.map +1 -1
  11. package/out/replicache/src/dag/gc.js +11 -8
  12. package/out/replicache/src/dag/gc.js.map +1 -1
  13. package/out/replicache/src/dag/store-impl.d.ts +2 -12
  14. package/out/replicache/src/dag/store-impl.d.ts.map +1 -1
  15. package/out/replicache/src/dag/store-impl.js +8 -22
  16. package/out/replicache/src/dag/store-impl.js.map +1 -1
  17. package/out/replicache/src/db/rebase.d.ts +2 -14
  18. package/out/replicache/src/db/rebase.d.ts.map +1 -1
  19. package/out/replicache/src/db/rebase.js +5 -27
  20. package/out/replicache/src/db/rebase.js.map +1 -1
  21. package/out/replicache/src/db/write.js.map +1 -1
  22. package/out/replicache/src/kv/expo-sqlite/store.d.ts.map +1 -1
  23. package/out/replicache/src/kv/expo-sqlite/store.js +5 -28
  24. package/out/replicache/src/kv/expo-sqlite/store.js.map +1 -1
  25. package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts +5 -15
  26. package/out/replicache/src/kv/idb-store-with-mem-fallback.d.ts.map +1 -1
  27. package/out/replicache/src/kv/idb-store-with-mem-fallback.js +25 -25
  28. package/out/replicache/src/kv/idb-store-with-mem-fallback.js.map +1 -1
  29. package/out/replicache/src/kv/idb-store.d.ts +0 -9
  30. package/out/replicache/src/kv/idb-store.d.ts.map +1 -1
  31. package/out/replicache/src/kv/idb-store.js +2 -14
  32. package/out/replicache/src/kv/idb-store.js.map +1 -1
  33. package/out/replicache/src/kv/mem-store.d.ts +0 -1
  34. package/out/replicache/src/kv/mem-store.d.ts.map +1 -1
  35. package/out/replicache/src/kv/mem-store.js +0 -3
  36. package/out/replicache/src/kv/mem-store.js.map +1 -1
  37. package/out/replicache/src/kv/op-sqlite/store.d.ts.map +1 -1
  38. package/out/replicache/src/kv/op-sqlite/store.js +1 -1
  39. package/out/replicache/src/kv/op-sqlite/store.js.map +1 -1
  40. package/out/replicache/src/kv/sqlite-store.d.ts +1 -13
  41. package/out/replicache/src/kv/sqlite-store.d.ts.map +1 -1
  42. package/out/replicache/src/kv/sqlite-store.js +6 -73
  43. package/out/replicache/src/kv/sqlite-store.js.map +1 -1
  44. package/out/replicache/src/kv/store.d.ts +0 -6
  45. package/out/replicache/src/kv/store.d.ts.map +1 -1
  46. package/out/replicache/src/persist/collect-idb-databases.d.ts +5 -10
  47. package/out/replicache/src/persist/collect-idb-databases.d.ts.map +1 -1
  48. package/out/replicache/src/persist/collect-idb-databases.js +9 -16
  49. package/out/replicache/src/persist/collect-idb-databases.js.map +1 -1
  50. package/out/replicache/src/persist/persist.d.ts.map +1 -1
  51. package/out/replicache/src/persist/persist.js +6 -13
  52. package/out/replicache/src/persist/persist.js.map +1 -1
  53. package/out/replicache/src/persist/refresh.js +2 -6
  54. package/out/replicache/src/persist/refresh.js.map +1 -1
  55. package/out/replicache/src/replicache-impl.d.ts +3 -14
  56. package/out/replicache/src/replicache-impl.d.ts.map +1 -1
  57. package/out/replicache/src/replicache-impl.js +11 -118
  58. package/out/replicache/src/replicache-impl.js.map +1 -1
  59. package/out/replicache/src/replicache-options.d.ts +0 -9
  60. package/out/replicache/src/replicache-options.d.ts.map +1 -1
  61. package/out/replicache/src/transactions.d.ts.map +1 -1
  62. package/out/replicache/src/transactions.js +1 -1
  63. package/out/replicache/src/transactions.js.map +1 -1
  64. package/out/shared/src/arrays.d.ts +0 -5
  65. package/out/shared/src/arrays.d.ts.map +1 -1
  66. package/out/shared/src/arrays.js +24 -8
  67. package/out/shared/src/arrays.js.map +1 -1
  68. package/out/shared/src/base64.d.ts +19 -0
  69. package/out/shared/src/base64.d.ts.map +1 -0
  70. package/out/shared/src/base64.js +40 -0
  71. package/out/shared/src/base64.js.map +1 -0
  72. package/out/shared/src/error.d.ts +0 -11
  73. package/out/shared/src/error.d.ts.map +1 -1
  74. package/out/shared/src/error.js +1 -35
  75. package/out/shared/src/error.js.map +1 -1
  76. package/out/shared/src/hash.d.ts +0 -1
  77. package/out/shared/src/hash.d.ts.map +1 -1
  78. package/out/shared/src/hash.js +10 -87
  79. package/out/shared/src/hash.js.map +1 -1
  80. package/out/shared/src/iterables.d.ts +0 -2
  81. package/out/shared/src/iterables.d.ts.map +1 -1
  82. package/out/shared/src/iterables.js +1 -18
  83. package/out/shared/src/iterables.js.map +1 -1
  84. package/out/shared/src/json.d.ts.map +1 -1
  85. package/out/shared/src/json.js +2 -2
  86. package/out/shared/src/json.js.map +1 -1
  87. package/out/shared/src/map.d.ts +2 -24
  88. package/out/shared/src/map.d.ts.map +1 -1
  89. package/out/shared/src/map.js +4 -18
  90. package/out/shared/src/map.js.map +1 -1
  91. package/out/shared/src/ring-buffer.d.ts +0 -8
  92. package/out/shared/src/ring-buffer.d.ts.map +1 -1
  93. package/out/shared/src/ring-buffer.js +1 -22
  94. package/out/shared/src/ring-buffer.js.map +1 -1
  95. package/out/z2s/src/sql.d.ts.map +1 -1
  96. package/out/z2s/src/sql.js +2 -2
  97. package/out/z2s/src/sql.js.map +1 -1
  98. package/out/zero/package.js +3 -2
  99. package/out/zero/package.js.map +1 -1
  100. package/out/zero-cache/src/auth/read-authorizer.js +1 -1
  101. package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
  102. package/out/zero-cache/src/auth/write-authorizer.js +0 -1
  103. package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
  104. package/out/zero-cache/src/config/zero-config.d.ts +2 -42
  105. package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
  106. package/out/zero-cache/src/config/zero-config.js +28 -149
  107. package/out/zero-cache/src/config/zero-config.js.map +1 -1
  108. package/out/zero-cache/src/custom-queries/transform-query.js +1 -1
  109. package/out/zero-cache/src/db/create.d.ts.map +1 -1
  110. package/out/zero-cache/src/db/create.js +1 -4
  111. package/out/zero-cache/src/db/create.js.map +1 -1
  112. package/out/zero-cache/src/db/lite-tables.d.ts +2 -10
  113. package/out/zero-cache/src/db/lite-tables.d.ts.map +1 -1
  114. package/out/zero-cache/src/db/lite-tables.js +6 -10
  115. package/out/zero-cache/src/db/lite-tables.js.map +1 -1
  116. package/out/zero-cache/src/db/specs.d.ts +0 -41
  117. package/out/zero-cache/src/db/specs.d.ts.map +1 -1
  118. package/out/zero-cache/src/db/specs.js +3 -30
  119. package/out/zero-cache/src/db/specs.js.map +1 -1
  120. package/out/zero-cache/src/observability/metrics.d.ts.map +1 -1
  121. package/out/zero-cache/src/observability/metrics.js +7 -2
  122. package/out/zero-cache/src/observability/metrics.js.map +1 -1
  123. package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
  124. package/out/zero-cache/src/server/change-streamer.js +4 -13
  125. package/out/zero-cache/src/server/change-streamer.js.map +1 -1
  126. package/out/zero-cache/src/server/inspector-delegate.d.ts +2 -18
  127. package/out/zero-cache/src/server/inspector-delegate.d.ts.map +1 -1
  128. package/out/zero-cache/src/server/inspector-delegate.js +17 -25
  129. package/out/zero-cache/src/server/inspector-delegate.js.map +1 -1
  130. package/out/zero-cache/src/server/main.d.ts.map +1 -1
  131. package/out/zero-cache/src/server/main.js +1 -8
  132. package/out/zero-cache/src/server/main.js.map +1 -1
  133. package/out/zero-cache/src/server/mutator.js +0 -2
  134. package/out/zero-cache/src/server/mutator.js.map +1 -1
  135. package/out/zero-cache/src/server/reaper.d.ts.map +1 -1
  136. package/out/zero-cache/src/server/reaper.js +0 -2
  137. package/out/zero-cache/src/server/reaper.js.map +1 -1
  138. package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
  139. package/out/zero-cache/src/server/replicator.js +2 -8
  140. package/out/zero-cache/src/server/replicator.js.map +1 -1
  141. package/out/zero-cache/src/server/runner/zero-dispatcher.d.ts.map +1 -1
  142. package/out/zero-cache/src/server/runner/zero-dispatcher.js +0 -3
  143. package/out/zero-cache/src/server/runner/zero-dispatcher.js.map +1 -1
  144. package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
  145. package/out/zero-cache/src/server/syncer.js +1 -5
  146. package/out/zero-cache/src/server/syncer.js.map +1 -1
  147. package/out/zero-cache/src/services/analyze.d.ts.map +1 -1
  148. package/out/zero-cache/src/services/analyze.js +9 -11
  149. package/out/zero-cache/src/services/analyze.js.map +1 -1
  150. package/out/zero-cache/src/services/change-source/common/backfill-manager.d.ts.map +1 -1
  151. package/out/zero-cache/src/services/change-source/common/backfill-manager.js +1 -14
  152. package/out/zero-cache/src/services/change-source/common/backfill-manager.js.map +1 -1
  153. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.d.ts.map +1 -1
  154. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js +3 -15
  155. package/out/zero-cache/src/services/change-source/common/change-stream-multiplexer.js.map +1 -1
  156. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts +1 -11
  157. package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
  158. package/out/zero-cache/src/services/change-source/pg/change-source.js +2 -21
  159. package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
  160. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts +0 -1
  161. package/out/zero-cache/src/services/change-source/pg/initial-sync.d.ts.map +1 -1
  162. package/out/zero-cache/src/services/change-source/pg/initial-sync.js +7 -8
  163. package/out/zero-cache/src/services/change-source/pg/initial-sync.js.map +1 -1
  164. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +229 -1513
  165. package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
  166. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +2 -2
  167. package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
  168. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts +1 -1
  169. package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
  170. package/out/zero-cache/src/services/change-source/pg/schema/init.js +6 -15
  171. package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
  172. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts +20 -137
  173. package/out/zero-cache/src/services/change-source/pg/schema/published.d.ts.map +1 -1
  174. package/out/zero-cache/src/services/change-source/pg/schema/published.js +13 -82
  175. package/out/zero-cache/src/services/change-source/pg/schema/published.js.map +1 -1
  176. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts +21 -128
  177. package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
  178. package/out/zero-cache/src/services/change-source/pg/schema/shard.js +5 -5
  179. package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
  180. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts +0 -2
  181. package/out/zero-cache/src/services/change-source/protocol/current/data.d.ts.map +1 -1
  182. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts +0 -3
  183. package/out/zero-cache/src/services/change-source/protocol/current/downstream.d.ts.map +1 -1
  184. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +0 -3
  185. package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
  186. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +1 -3
  187. package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
  188. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts +0 -1
  189. package/out/zero-cache/src/services/change-streamer/change-streamer.d.ts.map +1 -1
  190. package/out/zero-cache/src/services/litestream/commands.d.ts.map +1 -1
  191. package/out/zero-cache/src/services/litestream/commands.js +3 -8
  192. package/out/zero-cache/src/services/litestream/commands.js.map +1 -1
  193. package/out/zero-cache/src/services/litestream/config-v5.yml +1 -15
  194. package/out/zero-cache/src/services/mutagen/mutagen.d.ts +0 -5
  195. package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
  196. package/out/zero-cache/src/services/mutagen/mutagen.js +1 -7
  197. package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
  198. package/out/zero-cache/src/services/mutagen/pusher.d.ts +119 -119
  199. package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
  200. package/out/zero-cache/src/services/mutagen/pusher.js +6 -5
  201. package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
  202. package/out/zero-cache/src/services/replicator/change-processor.d.ts.map +1 -1
  203. package/out/zero-cache/src/services/replicator/change-processor.js +16 -16
  204. package/out/zero-cache/src/services/replicator/change-processor.js.map +1 -1
  205. package/out/zero-cache/src/services/replicator/incremental-sync.d.ts.map +1 -1
  206. package/out/zero-cache/src/services/replicator/incremental-sync.js +0 -1
  207. package/out/zero-cache/src/services/replicator/incremental-sync.js.map +1 -1
  208. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts +2 -27
  209. package/out/zero-cache/src/services/replicator/write-worker-client.d.ts.map +1 -1
  210. package/out/zero-cache/src/services/replicator/write-worker-client.js +2 -3
  211. package/out/zero-cache/src/services/replicator/write-worker-client.js.map +1 -1
  212. package/out/zero-cache/src/services/replicator/write-worker.js +5 -24
  213. package/out/zero-cache/src/services/replicator/write-worker.js.map +1 -1
  214. package/out/zero-cache/src/services/run-ast.d.ts +0 -12
  215. package/out/zero-cache/src/services/run-ast.d.ts.map +1 -1
  216. package/out/zero-cache/src/services/run-ast.js +15 -27
  217. package/out/zero-cache/src/services/run-ast.js.map +1 -1
  218. package/out/zero-cache/src/services/runner.d.ts.map +1 -1
  219. package/out/zero-cache/src/services/runner.js +1 -1
  220. package/out/zero-cache/src/services/runner.js.map +1 -1
  221. package/out/zero-cache/src/services/view-syncer/cvr.d.ts +0 -45
  222. package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
  223. package/out/zero-cache/src/services/view-syncer/cvr.js +1 -133
  224. package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
  225. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts +1 -14
  226. package/out/zero-cache/src/services/view-syncer/drain-coordinator.d.ts.map +1 -1
  227. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js +4 -30
  228. package/out/zero-cache/src/services/view-syncer/drain-coordinator.js.map +1 -1
  229. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts +1 -1
  230. package/out/zero-cache/src/services/view-syncer/inspect-handler.d.ts.map +1 -1
  231. package/out/zero-cache/src/services/view-syncer/inspect-handler.js +2 -2
  232. package/out/zero-cache/src/services/view-syncer/inspect-handler.js.map +1 -1
  233. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts +1 -2
  234. package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
  235. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +27 -48
  236. package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
  237. package/out/zero-cache/src/services/view-syncer/query-covering.d.ts.map +1 -1
  238. package/out/zero-cache/src/services/view-syncer/query-covering.js +6 -2
  239. package/out/zero-cache/src/services/view-syncer/query-covering.js.map +1 -1
  240. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts +4 -42
  241. package/out/zero-cache/src/services/view-syncer/snapshotter.d.ts.map +1 -1
  242. package/out/zero-cache/src/services/view-syncer/snapshotter.js +28 -117
  243. package/out/zero-cache/src/services/view-syncer/snapshotter.js.map +1 -1
  244. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +1 -11
  245. package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
  246. package/out/zero-cache/src/services/view-syncer/view-syncer.js +95 -466
  247. package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
  248. package/out/zero-cache/src/types/processes.d.ts +0 -32
  249. package/out/zero-cache/src/types/processes.d.ts.map +1 -1
  250. package/out/zero-cache/src/types/processes.js +4 -43
  251. package/out/zero-cache/src/types/processes.js.map +1 -1
  252. package/out/zero-cache/src/types/profiler.d.ts +0 -12
  253. package/out/zero-cache/src/types/profiler.d.ts.map +1 -1
  254. package/out/zero-cache/src/types/profiler.js +1 -46
  255. package/out/zero-cache/src/types/profiler.js.map +1 -1
  256. package/out/zero-cache/src/types/row-key.d.ts.map +1 -1
  257. package/out/zero-cache/src/types/row-key.js +5 -5
  258. package/out/zero-cache/src/types/row-key.js.map +1 -1
  259. package/out/zero-cache/src/workers/connect-params.d.ts +7 -0
  260. package/out/zero-cache/src/workers/connect-params.d.ts.map +1 -1
  261. package/out/zero-cache/src/workers/connect-params.js +20 -1
  262. package/out/zero-cache/src/workers/connect-params.js.map +1 -1
  263. package/out/zero-cache/src/workers/connection.d.ts +4 -4
  264. package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
  265. package/out/zero-cache/src/workers/connection.js +8 -8
  266. package/out/zero-cache/src/workers/connection.js.map +1 -1
  267. package/out/zero-cache/src/workers/replicator.d.ts +0 -1
  268. package/out/zero-cache/src/workers/replicator.d.ts.map +1 -1
  269. package/out/zero-cache/src/workers/replicator.js +2 -4
  270. package/out/zero-cache/src/workers/replicator.js.map +1 -1
  271. package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
  272. package/out/zero-cache/src/workers/syncer-ws-message-handler.js +16 -21
  273. package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
  274. package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
  275. package/out/zero-cache/src/workers/syncer.js +1 -10
  276. package/out/zero-cache/src/workers/syncer.js.map +1 -1
  277. package/out/zero-client/src/client/connection-manager.d.ts +0 -20
  278. package/out/zero-client/src/client/connection-manager.d.ts.map +1 -1
  279. package/out/zero-client/src/client/connection-manager.js +13 -77
  280. package/out/zero-client/src/client/connection-manager.js.map +1 -1
  281. package/out/zero-client/src/client/connection-status-enum.d.ts +0 -2
  282. package/out/zero-client/src/client/connection-status-enum.d.ts.map +1 -1
  283. package/out/zero-client/src/client/connection-status-enum.js +1 -3
  284. package/out/zero-client/src/client/connection-status-enum.js.map +1 -1
  285. package/out/zero-client/src/client/connection.d.ts +0 -6
  286. package/out/zero-client/src/client/connection.d.ts.map +1 -1
  287. package/out/zero-client/src/client/connection.js +1 -2
  288. package/out/zero-client/src/client/connection.js.map +1 -1
  289. package/out/zero-client/src/client/context.d.ts +2 -27
  290. package/out/zero-client/src/client/context.d.ts.map +1 -1
  291. package/out/zero-client/src/client/context.js +1 -112
  292. package/out/zero-client/src/client/context.js.map +1 -1
  293. package/out/zero-client/src/client/custom.js +2 -2
  294. package/out/zero-client/src/client/custom.js.map +1 -1
  295. package/out/zero-client/src/client/error.js +1 -1
  296. package/out/zero-client/src/client/inspector/lazy-inspector.js +2 -2
  297. package/out/zero-client/src/client/inspector/lazy-inspector.js.map +1 -1
  298. package/out/zero-client/src/client/ivm-branch.d.ts.map +1 -1
  299. package/out/zero-client/src/client/ivm-branch.js +3 -20
  300. package/out/zero-client/src/client/ivm-branch.js.map +1 -1
  301. package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
  302. package/out/zero-client/src/client/mutation-tracker.js +1 -1
  303. package/out/zero-client/src/client/mutation-tracker.js.map +1 -1
  304. package/out/zero-client/src/client/mutator-proxy.d.ts.map +1 -1
  305. package/out/zero-client/src/client/mutator-proxy.js +1 -2
  306. package/out/zero-client/src/client/mutator-proxy.js.map +1 -1
  307. package/out/zero-client/src/client/options.d.ts +0 -3
  308. package/out/zero-client/src/client/options.d.ts.map +1 -1
  309. package/out/zero-client/src/client/options.js.map +1 -1
  310. package/out/zero-client/src/client/query-manager.d.ts +0 -2
  311. package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
  312. package/out/zero-client/src/client/query-manager.js +14 -50
  313. package/out/zero-client/src/client/query-manager.js.map +1 -1
  314. package/out/zero-client/src/client/version.js +1 -1
  315. package/out/zero-client/src/client/zero-rep.d.ts +0 -1
  316. package/out/zero-client/src/client/zero-rep.d.ts.map +1 -1
  317. package/out/zero-client/src/client/zero-rep.js +6 -9
  318. package/out/zero-client/src/client/zero-rep.js.map +1 -1
  319. package/out/zero-client/src/client/zero.d.ts +3 -18
  320. package/out/zero-client/src/client/zero.d.ts.map +1 -1
  321. package/out/zero-client/src/client/zero.js +36 -123
  322. package/out/zero-client/src/client/zero.js.map +1 -1
  323. package/out/zero-client/src/types/query-result.d.ts +0 -2
  324. package/out/zero-client/src/types/query-result.d.ts.map +1 -1
  325. package/out/zero-protocol/src/analyze-query-result.d.ts +5 -5
  326. package/out/zero-protocol/src/analyze-query-result.d.ts.map +1 -1
  327. package/out/zero-protocol/src/analyze-query-result.js +1 -1
  328. package/out/zero-protocol/src/analyze-query-result.js.map +1 -1
  329. package/out/zero-protocol/src/ast.d.ts +1 -64
  330. package/out/zero-protocol/src/ast.d.ts.map +1 -1
  331. package/out/zero-protocol/src/ast.js +54 -225
  332. package/out/zero-protocol/src/ast.js.map +1 -1
  333. package/out/zero-protocol/src/connect.d.ts +13 -0
  334. package/out/zero-protocol/src/connect.d.ts.map +1 -1
  335. package/out/zero-protocol/src/connect.js +30 -1
  336. package/out/zero-protocol/src/connect.js.map +1 -1
  337. package/out/zero-protocol/src/down.d.ts +2 -2
  338. package/out/zero-protocol/src/error.d.ts +1 -1
  339. package/out/zero-protocol/src/inspect-down.d.ts +6 -6
  340. package/out/zero-protocol/src/poke.d.ts +11 -4
  341. package/out/zero-protocol/src/poke.d.ts.map +1 -1
  342. package/out/zero-protocol/src/poke.js +3 -2
  343. package/out/zero-protocol/src/poke.js.map +1 -1
  344. package/out/zero-protocol/src/protocol-flag-enum.d.ts +7 -0
  345. package/out/zero-protocol/src/protocol-flag-enum.d.ts.map +1 -0
  346. package/out/zero-protocol/src/protocol-flag-enum.js +7 -0
  347. package/out/zero-protocol/src/protocol-flag-enum.js.map +1 -0
  348. package/out/zero-protocol/src/protocol-flag.d.ts +14 -0
  349. package/out/zero-protocol/src/protocol-flag.d.ts.map +1 -0
  350. package/out/zero-protocol/src/protocol-flag.js +8 -0
  351. package/out/zero-protocol/src/protocol-flag.js.map +1 -0
  352. package/out/zero-protocol/src/protocol-version.d.ts +30 -6
  353. package/out/zero-protocol/src/protocol-version.d.ts.map +1 -1
  354. package/out/zero-protocol/src/protocol-version.js +1 -1
  355. package/out/zero-protocol/src/protocol-version.js.map +1 -1
  356. package/out/zero-protocol/src/query-hash.d.ts +2 -7
  357. package/out/zero-protocol/src/query-hash.d.ts.map +1 -1
  358. package/out/zero-protocol/src/query-hash.js +10 -10
  359. package/out/zero-protocol/src/query-hash.js.map +1 -1
  360. package/out/zero-react/src/use-query.d.ts +4 -5
  361. package/out/zero-react/src/use-query.d.ts.map +1 -1
  362. package/out/zero-react/src/use-query.js +9 -86
  363. package/out/zero-react/src/use-query.js.map +1 -1
  364. package/out/zero-solid/src/solid-view.d.ts +0 -17
  365. package/out/zero-solid/src/solid-view.d.ts.map +1 -1
  366. package/out/zero-solid/src/solid-view.js +1 -39
  367. package/out/zero-solid/src/solid-view.js.map +1 -1
  368. package/out/zero-solid/src/use-query.js +3 -5
  369. package/out/zero-solid/src/use-query.js.map +1 -1
  370. package/out/zql/src/builder/builder.d.ts +0 -19
  371. package/out/zql/src/builder/builder.d.ts.map +1 -1
  372. package/out/zql/src/builder/builder.js +11 -28
  373. package/out/zql/src/builder/builder.js.map +1 -1
  374. package/out/zql/src/builder/debug-delegate.d.ts +1 -6
  375. package/out/zql/src/builder/debug-delegate.d.ts.map +1 -1
  376. package/out/zql/src/builder/debug-delegate.js +2 -14
  377. package/out/zql/src/builder/debug-delegate.js.map +1 -1
  378. package/out/zql/src/ivm/array-view.d.ts +0 -29
  379. package/out/zql/src/ivm/array-view.d.ts.map +1 -1
  380. package/out/zql/src/ivm/array-view.js +12 -63
  381. package/out/zql/src/ivm/array-view.js.map +1 -1
  382. package/out/zql/src/ivm/cap.d.ts.map +1 -1
  383. package/out/zql/src/ivm/cap.js +3 -5
  384. package/out/zql/src/ivm/cap.js.map +1 -1
  385. package/out/zql/src/ivm/data.d.ts.map +1 -1
  386. package/out/zql/src/ivm/data.js +3 -8
  387. package/out/zql/src/ivm/data.js.map +1 -1
  388. package/out/zql/src/ivm/exists.d.ts +1 -1
  389. package/out/zql/src/ivm/exists.d.ts.map +1 -1
  390. package/out/zql/src/ivm/exists.js.map +1 -1
  391. package/out/zql/src/ivm/fan-in.d.ts +2 -2
  392. package/out/zql/src/ivm/fan-in.d.ts.map +1 -1
  393. package/out/zql/src/ivm/fan-in.js +5 -6
  394. package/out/zql/src/ivm/fan-in.js.map +1 -1
  395. package/out/zql/src/ivm/fan-out.d.ts +2 -2
  396. package/out/zql/src/ivm/fan-out.d.ts.map +1 -1
  397. package/out/zql/src/ivm/fan-out.js.map +1 -1
  398. package/out/zql/src/ivm/filter-operators.d.ts +6 -7
  399. package/out/zql/src/ivm/filter-operators.d.ts.map +1 -1
  400. package/out/zql/src/ivm/filter-operators.js +12 -29
  401. package/out/zql/src/ivm/filter-operators.js.map +1 -1
  402. package/out/zql/src/ivm/filter.d.ts +2 -2
  403. package/out/zql/src/ivm/filter.d.ts.map +1 -1
  404. package/out/zql/src/ivm/filter.js +4 -7
  405. package/out/zql/src/ivm/filter.js.map +1 -1
  406. package/out/zql/src/ivm/flipped-join.js +2 -2
  407. package/out/zql/src/ivm/flipped-join.js.map +1 -1
  408. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts +1 -1
  409. package/out/zql/src/ivm/maybe-split-and-push-edit-change.d.ts.map +1 -1
  410. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js +4 -6
  411. package/out/zql/src/ivm/maybe-split-and-push-edit-change.js.map +1 -1
  412. package/out/zql/src/ivm/memory-source.d.ts +3 -15
  413. package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
  414. package/out/zql/src/ivm/memory-source.js +23 -57
  415. package/out/zql/src/ivm/memory-source.js.map +1 -1
  416. package/out/zql/src/ivm/operator.d.ts +0 -40
  417. package/out/zql/src/ivm/operator.d.ts.map +1 -1
  418. package/out/zql/src/ivm/operator.js.map +1 -1
  419. package/out/zql/src/ivm/take.d.ts.map +1 -1
  420. package/out/zql/src/ivm/take.js +4 -3
  421. package/out/zql/src/ivm/take.js.map +1 -1
  422. package/out/zql/src/ivm/union-fan-in.d.ts.map +1 -1
  423. package/out/zql/src/ivm/union-fan-in.js +7 -9
  424. package/out/zql/src/ivm/union-fan-in.js.map +1 -1
  425. package/out/zql/src/ivm/view-apply-change.d.ts.map +1 -1
  426. package/out/zql/src/ivm/view-apply-change.js +4 -9
  427. package/out/zql/src/ivm/view-apply-change.js.map +1 -1
  428. package/out/zql/src/ivm/view.d.ts +0 -15
  429. package/out/zql/src/ivm/view.d.ts.map +1 -1
  430. package/out/zql/src/mutate/mutator-registry.d.ts.map +1 -1
  431. package/out/zql/src/mutate/mutator-registry.js +2 -2
  432. package/out/zql/src/mutate/mutator-registry.js.map +1 -1
  433. package/out/zql/src/planner/planner-builder.d.ts +3 -12
  434. package/out/zql/src/planner/planner-builder.d.ts.map +1 -1
  435. package/out/zql/src/planner/planner-builder.js +20 -40
  436. package/out/zql/src/planner/planner-builder.js.map +1 -1
  437. package/out/zql/src/planner/planner-connection.d.ts +2 -28
  438. package/out/zql/src/planner/planner-connection.d.ts.map +1 -1
  439. package/out/zql/src/planner/planner-connection.js +8 -108
  440. package/out/zql/src/planner/planner-connection.js.map +1 -1
  441. package/out/zql/src/planner/planner-debug.d.ts +1 -1
  442. package/out/zql/src/planner/planner-debug.d.ts.map +1 -1
  443. package/out/zql/src/planner/planner-debug.js +8 -3
  444. package/out/zql/src/planner/planner-debug.js.map +1 -1
  445. package/out/zql/src/planner/planner-fan-out.d.ts +0 -1
  446. package/out/zql/src/planner/planner-fan-out.d.ts.map +1 -1
  447. package/out/zql/src/planner/planner-fan-out.js +0 -3
  448. package/out/zql/src/planner/planner-fan-out.js.map +1 -1
  449. package/out/zql/src/planner/planner-graph.d.ts +0 -2
  450. package/out/zql/src/planner/planner-graph.d.ts.map +1 -1
  451. package/out/zql/src/planner/planner-graph.js +0 -2
  452. package/out/zql/src/planner/planner-graph.js.map +1 -1
  453. package/out/zql/src/planner/planner-join.d.ts +0 -2
  454. package/out/zql/src/planner/planner-join.d.ts.map +1 -1
  455. package/out/zql/src/planner/planner-join.js +0 -7
  456. package/out/zql/src/planner/planner-join.js.map +1 -1
  457. package/out/zql/src/planner/planner-node.d.ts +1 -2
  458. package/out/zql/src/planner/planner-node.d.ts.map +1 -1
  459. package/out/zql/src/planner/planner-node.js.map +1 -1
  460. package/out/zql/src/planner/planner-source.d.ts +2 -2
  461. package/out/zql/src/planner/planner-source.d.ts.map +1 -1
  462. package/out/zql/src/planner/planner-source.js +2 -2
  463. package/out/zql/src/planner/planner-source.js.map +1 -1
  464. package/out/zql/src/query/query-delegate-base.d.ts +1 -9
  465. package/out/zql/src/query/query-delegate-base.d.ts.map +1 -1
  466. package/out/zql/src/query/query-delegate-base.js +36 -132
  467. package/out/zql/src/query/query-delegate-base.js.map +1 -1
  468. package/out/zql/src/query/query-delegate.d.ts +1 -50
  469. package/out/zql/src/query/query-delegate.d.ts.map +1 -1
  470. package/out/zql/src/query/query-impl.d.ts +14 -25
  471. package/out/zql/src/query/query-impl.d.ts.map +1 -1
  472. package/out/zql/src/query/query-impl.js +94 -397
  473. package/out/zql/src/query/query-impl.js.map +1 -1
  474. package/out/zql/src/query/query-internals.d.ts +11 -21
  475. package/out/zql/src/query/query-internals.d.ts.map +1 -1
  476. package/out/zql/src/query/query-internals.js.map +1 -1
  477. package/out/zql/src/query/query.d.ts +2 -11
  478. package/out/zql/src/query/query.d.ts.map +1 -1
  479. package/out/zql/src/query/runnable-query-impl.d.ts +2 -3
  480. package/out/zql/src/query/runnable-query-impl.d.ts.map +1 -1
  481. package/out/zql/src/query/runnable-query-impl.js +2 -15
  482. package/out/zql/src/query/runnable-query-impl.js.map +1 -1
  483. package/out/zql/src/query/typed-view.d.ts +1 -1
  484. package/out/zql/src/query/typed-view.d.ts.map +1 -1
  485. package/out/zqlite/src/db.d.ts +1 -9
  486. package/out/zqlite/src/db.d.ts.map +1 -1
  487. package/out/zqlite/src/db.js +2 -8
  488. package/out/zqlite/src/db.js.map +1 -1
  489. package/out/zqlite/src/query-builder.d.ts +1 -1
  490. package/out/zqlite/src/query-builder.d.ts.map +1 -1
  491. package/out/zqlite/src/query-builder.js +2 -4
  492. package/out/zqlite/src/query-builder.js.map +1 -1
  493. package/out/zqlite/src/query-delegate.d.ts.map +1 -1
  494. package/out/zqlite/src/query-delegate.js +6 -5
  495. package/out/zqlite/src/query-delegate.js.map +1 -1
  496. package/out/zqlite/src/sqlite-cost-model.d.ts.map +1 -1
  497. package/out/zqlite/src/sqlite-cost-model.js +30 -2
  498. package/out/zqlite/src/sqlite-cost-model.js.map +1 -1
  499. package/out/zqlite/src/sqlite-stat-fanout.d.ts.map +1 -1
  500. package/out/zqlite/src/sqlite-stat-fanout.js +5 -4
  501. package/out/zqlite/src/sqlite-stat-fanout.js.map +1 -1
  502. package/out/zqlite/src/table-source.d.ts +3 -16
  503. package/out/zqlite/src/table-source.d.ts.map +1 -1
  504. package/out/zqlite/src/table-source.js +14 -33
  505. package/out/zqlite/src/table-source.js.map +1 -1
  506. package/package.json +3 -2
  507. package/out/replicache/src/dag/invalid-ref-count-error.d.ts +0 -12
  508. package/out/replicache/src/dag/invalid-ref-count-error.d.ts.map +0 -1
  509. package/out/replicache/src/dag/invalid-ref-count-error.js +0 -19
  510. package/out/replicache/src/dag/invalid-ref-count-error.js.map +0 -1
  511. package/out/shared/src/xxhash32.d.ts +0 -36
  512. package/out/shared/src/xxhash32.d.ts.map +0 -1
  513. package/out/shared/src/xxhash32.js +0 -51
  514. package/out/shared/src/xxhash32.js.map +0 -1
  515. package/out/zero-cache/src/db/index-predicate.d.ts +0 -4
  516. package/out/zero-cache/src/db/index-predicate.d.ts.map +0 -1
  517. package/out/zero-cache/src/db/index-predicate.js +0 -46
  518. package/out/zero-cache/src/db/index-predicate.js.map +0 -1
  519. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts +0 -19
  520. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.d.ts.map +0 -1
  521. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js +0 -581
  522. package/out/zero-cache/src/services/change-source/pg/schema/index-predicate.js.map +0 -1
  523. package/out/zero-cache/src/services/litestream/litestream-checkpointer.js +0 -131
  524. package/out/zero-cache/src/services/litestream/litestream-checkpointer.js.map +0 -1
  525. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts +0 -70
  526. package/out/zero-cache/src/services/litestream/litestream-controller.d.ts.map +0 -1
  527. package/out/zero-cache/src/services/litestream/litestream-controller.js +0 -101
  528. package/out/zero-cache/src/services/litestream/litestream-controller.js.map +0 -1
  529. package/out/zero-cache/src/services/profz.d.ts +0 -7
  530. package/out/zero-cache/src/services/profz.d.ts.map +0 -1
  531. package/out/zero-cache/src/services/profz.js +0 -103
  532. package/out/zero-cache/src/services/profz.js.map +0 -1
  533. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts +0 -33
  534. package/out/zero-cache/src/services/view-syncer/hydration-budget.d.ts.map +0 -1
  535. package/out/zero-cache/src/services/view-syncer/hydration-budget.js +0 -62
  536. package/out/zero-cache/src/services/view-syncer/hydration-budget.js.map +0 -1
  537. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts +0 -51
  538. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.d.ts.map +0 -1
  539. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js +0 -78
  540. package/out/zero-cache/src/services/view-syncer/hydration-circuit-breaker.js.map +0 -1
  541. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts +0 -95
  542. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.d.ts.map +0 -1
  543. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js +0 -155
  544. package/out/zero-cache/src/services/view-syncer/snapshot-row-cache.js.map +0 -1
  545. package/out/zero-protocol/src/query-hash-visitor.d.ts +0 -81
  546. package/out/zero-protocol/src/query-hash-visitor.d.ts.map +0 -1
  547. package/out/zero-protocol/src/query-hash-visitor.js +0 -324
  548. package/out/zero-protocol/src/query-hash-visitor.js.map +0 -1
  549. package/out/zql/src/builder/correlated-predicate-pushdown.d.ts +0 -43
  550. package/out/zql/src/builder/correlated-predicate-pushdown.d.ts.map +0 -1
  551. package/out/zql/src/builder/correlated-predicate-pushdown.js +0 -161
  552. package/out/zql/src/builder/correlated-predicate-pushdown.js.map +0 -1
  553. package/out/zql/src/ivm/connection-index.d.ts +0 -68
  554. package/out/zql/src/ivm/connection-index.d.ts.map +0 -1
  555. package/out/zql/src/ivm/connection-index.js +0 -149
  556. package/out/zql/src/ivm/connection-index.js.map +0 -1
  557. package/out/zql/src/ivm/deferred-input.d.ts +0 -44
  558. package/out/zql/src/ivm/deferred-input.d.ts.map +0 -1
  559. package/out/zql/src/ivm/deferred-input.js +0 -89
  560. package/out/zql/src/ivm/deferred-input.js.map +0 -1
  561. package/out/zql/src/planner/planner-filter.d.ts +0 -59
  562. package/out/zql/src/planner/planner-filter.d.ts.map +0 -1
  563. package/out/zql/src/planner/planner-filter.js +0 -116
  564. package/out/zql/src/planner/planner-filter.js.map +0 -1
  565. package/out/zql/src/query/query-transitions.d.ts +0 -171
  566. package/out/zql/src/query/query-transitions.d.ts.map +0 -1
  567. package/out/zql/src/query/query-transitions.js +0 -204
  568. package/out/zql/src/query/query-transitions.js.map +0 -1
@@ -1,6 +1,4 @@
1
1
  import { assert, unreachable } from "../../../../shared/src/asserts.js";
2
- import { getOrInsertComputed } from "../../../../shared/src/map.js";
3
- import { newArray } from "../../../../shared/src/arrays.js";
4
2
  import { must } from "../../../../shared/src/must.js";
5
3
  import { h64 } from "../../../../shared/src/hash.js";
6
4
  import { Internal, InvalidConnectionRequest, InvalidConnectionRequestBaseCookie, Rehome } from "../../../../zero-protocol/src/error-kind-enum.js";
@@ -13,11 +11,12 @@ import { manualSpan, startAsyncSpan, startSpan } from "../../../../otel/src/span
13
11
  import { ZERO_VERSION_COLUMN_NAME } from "../replicator/schema/constants.js";
14
12
  import { transformAndHashQuery } from "../../auth/read-authorizer.js";
15
13
  import { randInt } from "../../../../shared/src/rand.js";
16
- import { getOrCreateCounter, getOrCreateLatencyHistogram, getOrCreateNativeHistogram, getOrCreateUpDownCounter, getOrCreateValueHistogram } from "../../observability/metrics.js";
14
+ import { getOrCreateCounter, getOrCreateLatencyHistogram, getOrCreateNativeHistogram, getOrCreateUpDownCounter } from "../../observability/metrics.js";
17
15
  import { rowIDString } from "../../types/row-key.js";
18
16
  import "../replicator/schema/replication-state.js";
19
17
  import { parseSignature } from "./row-set-signature.js";
20
18
  import { ResetPipelinesSignal } from "./snapshotter.js";
19
+ import "./pipeline-driver.js";
21
20
  import { Subscription } from "../../types/subscription.js";
22
21
  import { CustomKeyMap } from "../../../../shared/src/custom-key-map.js";
23
22
  import { ttlClockAsNumber, ttlClockFromNumber } from "./ttl-clock.js";
@@ -27,10 +26,8 @@ import { isAuthErrorBody } from "../../auth/auth.js";
27
26
  import { ClientHandler, startPoke } from "./client-handler.js";
28
27
  import { tracer } from "./tracer.js";
29
28
  import { CVRStore, ClientNotFoundError } from "./cvr-store.js";
30
- import { CVRConfigDrivenUpdater, CVRQueryDrivenUpdater, classifyQueriesForHydration, nextEvictionTime } from "./cvr.js";
29
+ import { CVRConfigDrivenUpdater, CVRQueryDrivenUpdater, nextEvictionTime } from "./cvr.js";
31
30
  import { E2EServingLagTracker } from "./e2e-serving-lag.js";
32
- import { HydrationBudget } from "./hydration-budget.js";
33
- import { HydrationCircuitBreaker } from "./hydration-circuit-breaker.js";
34
31
  import { handleInspect } from "./inspect-handler.js";
35
32
  import { QueryCoveringIndex } from "./query-covering.js";
36
33
  import { resolver } from "@rocicorp/resolver";
@@ -65,7 +62,6 @@ var ViewSyncerService = class {
65
62
  #drainCoordinator;
66
63
  #keepaliveMs;
67
64
  #slowHydrateThreshold;
68
- #hydrationCircuitBreaker;
69
65
  #lastConnectTime = Date.now();
70
66
  /**
71
67
  * The TTL clock is used to determine the time at which queries are considered
@@ -93,36 +89,14 @@ var ViewSyncerService = class {
93
89
  #lock = new Lock();
94
90
  #cvrStore;
95
91
  #stopped = resolver();
96
- /**
97
- * Set when {@link #cleanup} begins. Lock tasks that were in flight when the
98
- * view-syncer was stopped may still complete after the timers have been
99
- * cleared; this flag prevents them from scheduling new timers, which would
100
- * otherwise outlive the service (and retain everything it references).
101
- */
102
- #shuttingDown = false;
103
92
  #initialized = resolver();
104
93
  #cvr;
105
- /**
106
- * Indicates whether the query pipelines have completed initial catch-up and
107
- * hydration with the CVR snapshot, and are ready for steady-state operation.
108
- *
109
- * - When `false`: The syncer is in its initial catch-up phase. The replica
110
- * advances without diffs until it reaches `cvr.version.stateVersion`,
111
- * after which `#maybeHydratePipelines` hydrates queries.
112
- * - When `true`: Pipelines are fully populated and in steady-state; replica
113
- * changes advance incrementally via `#advancePipelines`, and client query
114
- * updates are processed via `#syncQueryPipelineSet`.
115
- *
116
- * Resets to `false` if `#advancePipelines` returns a `ResetPipelinesSignal`
117
- * and pipelines must be reset and rehydrated.
118
- */
119
- #pipelinesHydrated = false;
94
+ #pipelinesSynced = false;
120
95
  #servedVersion = null;
121
96
  #e2eServingLagTracker = new E2EServingLagTracker();
122
97
  #expiredQueriesTimer = 0;
123
98
  #authMaintenanceTimer = 0;
124
99
  #setTimeout;
125
- #now;
126
100
  #customQueryTransformer;
127
101
  #queryReplacements = /* @__PURE__ */ new Map();
128
102
  #activeClients = getOrCreateUpDownCounter("sync", "active-clients", "Number of active sync clients");
@@ -149,64 +123,10 @@ var ViewSyncerService = class {
149
123
  #pipelineResets = getOrCreateCounter("sync", "pipeline-resets", "Number of pipeline resets");
150
124
  #rowSetSignatureDrifts = getOrCreateCounter("sync", "query.row-set-signature-drifts", "Number of times re-hydration of an unchanged query produced a different row-set signature than what is stored in the CVR (forcing a configVersion bump and full re-execution). Expected to be near-zero in steady state; persistent non-zero values indicate non-deterministic query execution (e.g. Cap operator picking different N-row subsets).");
151
125
  #sameHashRehydrationVersionBumps = getOrCreateCounter("sync", "query.same-hash-rehydrations-forced-bump", "Number of times query-set reconciliation forced a configVersion bump for already-gotten same-transformation-hash query rehydration because trackQueries would not otherwise bump. Expected to be near-zero; non-zero values indicate pipeline/CVR row-set drift reached query-set reconciliation.");
152
- #hydrationBudgetExhaustions = getOrCreateCounter("sync", "hydration_budget_exhaustions", {
153
- description: "Number of hydration passes that exhaust their budget.",
154
- unit: "{pass}"
155
- });
156
- #hydrationBudgetEvictions = getOrCreateCounter("sync", "hydration_budget_evictions", {
157
- description: "Number of inactive queries removed after hydration budget exhaustion.",
158
- unit: "{query}"
159
- });
160
- #hydrationBudgetElapsed = getOrCreateValueHistogram("sync", "hydration_budget_elapsed", {
161
- description: "Elapsed milliseconds when optional query hydration stopped.",
162
- unit: "ms",
163
- bucketBoundaries: [
164
- 1,
165
- 2,
166
- 5,
167
- 10,
168
- 20,
169
- 50,
170
- 100,
171
- 200,
172
- 500,
173
- 1e3,
174
- 5e3
175
- ]
176
- });
177
- #hydrationBudgetOvershoot = getOrCreateValueHistogram("sync", "hydration_budget_overshoot", {
178
- description: "Milliseconds elapsed beyond the configured hydration budget.",
179
- unit: "ms",
180
- bucketBoundaries: [
181
- 0,
182
- 1,
183
- 2,
184
- 5,
185
- 10,
186
- 20,
187
- 50,
188
- 100,
189
- 200,
190
- 500,
191
- 1e3
192
- ]
193
- });
194
- #queryEvictions = getOrCreateCounter("sync", "query_evictions", {
195
- description: "Number of queries evicted from the CVR ahead of their removal by the client, grouped by reason. Inactive queries are evicted by ttl and hydration-budget; hydration-timeout and hydration-circuit-breaker evict active queries as well.",
196
- unit: "{query}"
197
- });
198
- #hydrationTimeouts = getOrCreateCounter("sync", "hydration_timeouts", {
199
- description: "Number of query hydrations aborted for exceeding the query hydration timeout.",
200
- unit: "{query}"
201
- });
202
- #hydrationCircuitBreakerRejections = getOrCreateCounter("sync", "hydration_circuit_breaker_rejections", {
203
- description: "Number of queries rejected without hydration because their hydration circuit breaker was open.",
204
- unit: "{query}"
205
- });
206
126
  #inspectorDelegate;
207
127
  #config;
208
128
  #runPriorityOp;
209
- constructor(config, lc, shard, taskID, clientGroupID, cvrDb, pipelineDriver, versionChanges, drainCoordinator, slowHydrateThreshold, inspectorDelegate, connContextManager, customQueryTransformer, runPriorityOp, keepaliveMs = DEFAULT_KEEPALIVE_MS, setTimeoutFn = setTimeout.bind(globalThis), now = performance.now.bind(performance)) {
129
+ constructor(config, lc, shard, taskID, clientGroupID, cvrDb, pipelineDriver, versionChanges, drainCoordinator, slowHydrateThreshold, inspectorDelegate, connContextManager, customQueryTransformer, runPriorityOp, keepaliveMs = DEFAULT_KEEPALIVE_MS, setTimeoutFn = setTimeout.bind(globalThis)) {
210
130
  this.#config = config;
211
131
  this.id = clientGroupID;
212
132
  this.connContextManager = connContextManager;
@@ -221,8 +141,6 @@ var ViewSyncerService = class {
221
141
  this.#customQueryTransformer = customQueryTransformer;
222
142
  this.#cvrStore = new CVRStore(lc, cvrDb, shard, taskID, clientGroupID, () => this.#stateChanges.cancel());
223
143
  this.#setTimeout = setTimeoutFn;
224
- this.#now = now;
225
- this.#hydrationCircuitBreaker = new HydrationCircuitBreaker(config.viewSyncerQueryHydrationTimeoutMs ?? 0, void 0, now);
226
144
  this.#runPriorityOp = runPriorityOp;
227
145
  this.keepalive();
228
146
  }
@@ -272,20 +190,10 @@ var ViewSyncerService = class {
272
190
  });
273
191
  }
274
192
  readyState() {
275
- return new Promise((resolve, reject) => {
276
- const unsubscribe = this.#drainCoordinator.onDraining(() => resolve("draining"));
277
- this.#initialized.promise.then((state) => {
278
- unsubscribe();
279
- resolve(state);
280
- }, (err) => {
281
- unsubscribe();
282
- reject(err);
283
- });
284
- });
193
+ return Promise.race([this.#initialized.promise, this.#drainCoordinator.draining]);
285
194
  }
286
195
  async run() {
287
196
  try {
288
- this.#scheduleShutdown(this.#keepaliveMs);
289
197
  if (await this.readyState() === "draining") {
290
198
  this.#lc.debug?.(`draining view-syncer ${this.id} before running`);
291
199
  this.stop();
@@ -306,29 +214,26 @@ var ViewSyncerService = class {
306
214
  lc.info?.(`resetting CVR: ${message}`);
307
215
  throw new ClientNotFoundError(message);
308
216
  }
309
- let previousQueries;
310
- if (this.#pipelinesHydrated) {
217
+ if (this.#pipelinesSynced) {
311
218
  const result = await this.#advancePipelines(lc, cvr);
312
219
  if (result === "success") return;
313
220
  lc.info?.(`resetting pipelines: ${result.message}`);
314
221
  this.#pipelineResets.add(1, { reason: result.reason });
315
- switch (result.reason) {
316
- case "advancement-timeout":
317
- case "scalar-subquery":
318
- case "truncation":
319
- case "schema-change":
320
- if (!Object.values(cvr.queries).some((q) => q.type === "client")) previousQueries = new Map(this.#pipelines.queries());
321
- break;
322
- case "permissions-change": break;
323
- default: unreachable(result.reason);
324
- }
325
222
  this.#pipelines.reset(clientSchema);
326
- this.#pipelinesHydrated = false;
223
+ this.#pipelinesSynced = false;
327
224
  this.connContextManager.setSharedRetransformReady(false);
328
225
  }
329
- const backgroundConnCtx = this.connContextManager.getBackgroundConnectionContext();
330
- if (backgroundConnCtx) await this.#maybeHydratePipelines(lc, cvr, backgroundConnCtx, previousQueries);
331
- else lc.info?.("No validated background connection; deferring pipeline init");
226
+ const version = this.#pipelines.advanceWithoutDiff();
227
+ const cvrVer = versionString(cvr.version);
228
+ if (version < cvr.version.stateVersion) {
229
+ lc.debug?.(`replica@${version} is behind cvr@${cvrVer}`);
230
+ return;
231
+ }
232
+ lc.info?.(`init pipelines@${version} (cvr@${cvrVer})`);
233
+ const driftedQueryIDs = await this.#hydrateUnchangedQueries(lc, cvr);
234
+ await this.#syncQueryPipelineSet(lc, cvr, "missing", void 0, driftedQueryIDs);
235
+ this.#pipelinesSynced = true;
236
+ this.connContextManager.setSharedRetransformReady(true);
332
237
  });
333
238
  }
334
239
  if (this.#drainCoordinator.shouldDrain()) this.#drainCoordinator.drainNextIn(this.#totalHydrationTimeMs());
@@ -342,57 +247,11 @@ var ViewSyncerService = class {
342
247
  this.#stopped.resolve();
343
248
  }
344
249
  }
345
- /**
346
- * Ensures that query pipelines are hydrated and ready for steady-state
347
- * operation.
348
- *
349
- * Preconditions:
350
- * 1. Must be called from within the `#lock`.
351
- * 2. The caller must provide an active, validated `ConnectionContext` for
352
- * evaluating custom query transforms and permissions.
353
- *
354
- * Readiness prerequisites:
355
- * - The underlying `QueryPipelineDriver` must be initialized with the schema
356
- * (i.e. `this.#pipelines.initialized()` is true).
357
- * - The SQLite replica must have caught up to at least the CVR's
358
- * `stateVersion` (`version >= cvr.version.stateVersion`).
359
- *
360
- * If either prerequisite is not met, this method returns early as a no-op,
361
- * waiting for the replica to catch up or the driver to initialize.
362
- *
363
- * Once ready:
364
- * - Hydrates unchanged queries from the CVR snapshot without full row diffing.
365
- * - Syncs missing, errored, or drifted queries via `#syncQueryPipelineSet`.
366
- * - Sets `#pipelinesHydrated = true` and enables shared retransformations.
367
- */
368
- async #maybeHydratePipelines(lc, cvr, connCtx, previousQueries) {
369
- if (!this.#pipelines.initialized()) return;
370
- const version = this.#pipelines.advanceWithoutDiff();
371
- const cvrVer = versionString(cvr.version);
372
- if (version < cvr.version.stateVersion) {
373
- lc.debug?.(`replica@${version} is behind cvr@${cvrVer}`);
374
- return;
375
- }
376
- lc.info?.(`init pipelines@${version} (cvr@${cvrVer})`);
377
- const hydrationBudget = new HydrationBudget(this.#config.viewSyncerHydrationBudgetMs ?? 0, this.#now);
378
- const hydrationPassStats = {
379
- activeHydratedQueries: 0,
380
- inactiveHydratedQueries: 0
381
- };
382
- const driftedQueryIDs = await this.#hydrateUnchangedQueries(lc, cvr, connCtx, hydrationPassStats, hydrationBudget, previousQueries);
383
- await this.#syncQueryPipelineSet(lc, cvr, "missing", connCtx, driftedQueryIDs, hydrationBudget, hydrationPassStats, previousQueries);
384
- this.#pipelinesHydrated = true;
385
- this.connContextManager.setSharedRetransformReady(true);
386
- }
387
250
  #removeExpiredQueries = async (lc, cvr) => {
388
251
  if (hasExpiredQueries(cvr)) {
389
252
  lc = lc.withContext("method", "#removeExpiredQueries");
390
253
  lc.debug?.("Queries have expired");
391
- if (this.#pipelinesHydrated) {
392
- const connCtx = this.connContextManager.getBackgroundConnectionContext();
393
- if (connCtx) await this.#syncQueryPipelineSet(lc, cvr, "missing", connCtx);
394
- else lc.info?.("No validated background connection to remove expired queries; deferring");
395
- }
254
+ if (this.#pipelinesSynced) await this.#syncQueryPipelineSet(lc, cvr, "missing", void 0);
396
255
  }
397
256
  this.#scheduleExpireEviction(lc, cvr);
398
257
  };
@@ -474,14 +333,7 @@ var ViewSyncerService = class {
474
333
  return true;
475
334
  }
476
335
  #shutdownTimer = null;
477
- #stopShutdownTimer() {
478
- if (this.#shutdownTimer !== null) {
479
- clearTimeout(this.#shutdownTimer);
480
- this.#shutdownTimer = null;
481
- }
482
- }
483
336
  #scheduleShutdown(delayMs = 0) {
484
- if (this.#shuttingDown) return;
485
337
  this.#shutdownTimer ??= this.#setTimeout(() => {
486
338
  this.#shutdownTimer = null;
487
339
  this.#runInLockWithCVR(() => {}).catch((e) => this.#stateChanges.fail(e));
@@ -528,7 +380,6 @@ var ViewSyncerService = class {
528
380
  */
529
381
  #scheduleAuthMaintenance(lc) {
530
382
  this.#stopAuthMaintenanceTimer();
531
- if (this.#shuttingDown) return;
532
383
  const plan = this.connContextManager.planMaintenance();
533
384
  if (plan.earliestDeadlineAt === void 0) {
534
385
  lc.debug?.("No auth maintenance wakeup scheduled");
@@ -616,7 +467,7 @@ var ViewSyncerService = class {
616
467
  }
617
468
  lc.debug?.("Auth changed, re-validating and re-transforming queries");
618
469
  const connCtx = this.connContextManager.mustGetConnectionContext(selector);
619
- if (!this.#pipelinesHydrated) {
470
+ if (!this.#pipelinesSynced) {
620
471
  if (!await this.#validateConnection(connCtx)) return;
621
472
  }
622
473
  return await this.#handleConfigUpdate(lc, clientID, {}, cvr, "all", void 0, connCtx);
@@ -645,7 +496,6 @@ var ViewSyncerService = class {
645
496
  }
646
497
  #startTTLClockInterval(lc) {
647
498
  this.#stopTTLClockInterval();
648
- if (this.#shuttingDown) return;
649
499
  this.#ttlClockInterval = this.#setTimeout(() => {
650
500
  this.#updateTTLClockInCVRWithoutLock(lc);
651
501
  this.#startTTLClockInterval(lc);
@@ -679,8 +529,7 @@ var ViewSyncerService = class {
679
529
  await pokers.end(newCVR.version);
680
530
  });
681
531
  }
682
- if (!this.#pipelinesHydrated) await this.#maybeHydratePipelines(lc, this.#cvr, connCtx);
683
- else await this.#syncQueryPipelineSet(lc, this.#cvr, customQueryTransformMode, connCtx);
532
+ if (this.#pipelinesSynced) await this.#syncQueryPipelineSet(lc, this.#cvr, customQueryTransformMode, connCtx);
684
533
  return this.#cvr;
685
534
  }
686
535
  /**
@@ -776,7 +625,6 @@ var ViewSyncerService = class {
776
625
  #scheduleExpireEviction(lc, cvr) {
777
626
  const { ttlClock } = cvr;
778
627
  this.#stopExpireTimer();
779
- if (this.#shuttingDown) return;
780
628
  const next = nextEvictionTime(cvr);
781
629
  if (next === void 0) {
782
630
  lc.debug?.("no inactive queries with ttl");
@@ -804,7 +652,7 @@ var ViewSyncerService = class {
804
652
  *
805
653
  * This must be called from within the #lock.
806
654
  */
807
- async #hydrateUnchangedQueries(lc, cvr, connCtx, hydrationPassStats, hydrationBudget, previousQueries) {
655
+ async #hydrateUnchangedQueries(lc, cvr) {
808
656
  assert(this.#pipelines.initialized(), "pipelines must be initialized");
809
657
  const dbVersion = this.#pipelines.currentVersion();
810
658
  const cvrVersion = cvr.version;
@@ -813,34 +661,33 @@ var ViewSyncerService = class {
813
661
  return /* @__PURE__ */ new Set();
814
662
  }
815
663
  const gotQueries = Object.entries(cvr.queries).filter(([_, state]) => state.transformationHash !== void 0);
816
- const { required: requiredGotQueries } = classifyQueriesForHydration(gotQueries.map(([, query]) => query));
817
664
  const customQueries = /* @__PURE__ */ new Map();
818
665
  const otherQueries = [];
819
- const inactivatedCount = gotQueries.length - requiredGotQueries.length;
666
+ let inactivatedCount = 0;
667
+ for (const [, query] of gotQueries) {
668
+ if (query.type !== "internal" && Object.values(query.clientState).every(({ inactivatedAt }) => inactivatedAt !== void 0)) {
669
+ inactivatedCount++;
670
+ continue;
671
+ }
672
+ if (query.type === "custom") customQueries.set(query.id, query);
673
+ else otherQueries.push(query);
674
+ }
820
675
  const transformedQueries = [];
821
- for (const query of requiredGotQueries) if (query.type === "custom") {
822
- const previous = previousQueries?.get(query.id);
823
- if (previous && previous.transformationHash === query.transformationHash) transformedQueries.push({
824
- id: query.id,
825
- transformationHash: previous.transformationHash,
826
- transformedAst: previous.originalAst ?? previous.transformedAst
827
- });
828
- else customQueries.set(query.id, query);
829
- } else otherQueries.push(query);
830
676
  let customErrorCount = 0;
831
677
  let customHashMismatchCount = 0;
832
678
  let otherHashMismatchCount = 0;
833
679
  if (customQueries.size > 0 && !this.#customQueryTransformer) lc.warn?.("Custom/named queries were requested but no `ZERO_QUERY_URL` is configured for Zero Cache.");
680
+ const backgroundContext = this.connContextManager.mustGetBackgroundConnectionContext();
834
681
  const customQueryTransformer = this.#customQueryTransformer;
835
682
  if (customQueryTransformer && customQueries.size > 0) {
836
- const transformedCustomQueries = await hydrationBudget.excluding(() => this.#runPriorityOp(lc, "#hydrateUnchangedQueries transforming custom queries", () => customQueryTransformer.transform(connCtx, customQueries.values())));
837
- if (transformedCustomQueries.kind === "success" && !transformedCustomQueries.cached) this.connContextManager.validateConnection(connCtx, connCtx.revision, transformedCustomQueries.validation);
683
+ const transformedCustomQueries = await this.#runPriorityOp(lc, "#hydrateUnchangedQueries transforming custom queries", () => customQueryTransformer.transform(backgroundContext, customQueries.values()));
684
+ if (transformedCustomQueries.kind === "success" && !transformedCustomQueries.cached) this.connContextManager.validateConnection(backgroundContext, backgroundContext.revision, transformedCustomQueries.validation);
838
685
  if (Array.isArray(transformedCustomQueries.result)) for (const q of transformedCustomQueries.result) if ("error" in q) customErrorCount++;
839
686
  else if (q.transformationHash !== customQueries.get(q.id)?.transformationHash) customHashMismatchCount++;
840
687
  else transformedQueries.push(q);
841
688
  }
842
689
  for (const q of otherQueries) {
843
- const transformed = transformAndHashQuery(lc, q.id, q.ast, must(this.#pipelines.currentPermissions()).permissions ?? { tables: {} }, connCtx.auth?.type === "jwt" ? connCtx.auth : void 0, q.type === "internal");
690
+ const transformed = transformAndHashQuery(lc, q.id, q.ast, must(this.#pipelines.currentPermissions()).permissions ?? { tables: {} }, backgroundContext.auth?.type === "jwt" ? backgroundContext.auth : void 0, q.type === "internal");
844
691
  if (transformed.transformationHash === q.transformationHash) transformedQueries.push(transformed);
845
692
  else otherHashMismatchCount++;
846
693
  }
@@ -853,10 +700,6 @@ var ViewSyncerService = class {
853
700
  for (const { id: queryID, transformationHash, transformedAst } of transformedQueries) {
854
701
  const query = cvr.queries[queryID];
855
702
  const queryName = query.type === "custom" ? query.name : void 0;
856
- if (query.type !== "internal" && this.#hydrationCircuitBreaker.isOpen(transformationHash)) {
857
- lc.info?.(`skipping hydration of ${queryID}: hydration circuit breaker open`);
858
- continue;
859
- }
860
703
  const covered = queryCoveringIndex ? this.#findQueryCoverageShadowHit(queryCoveringIndex, queryID, transformationHash, transformedAst, queryName) : void 0;
861
704
  totalHydratedQueries++;
862
705
  if (covered) {
@@ -865,35 +708,19 @@ var ViewSyncerService = class {
865
708
  }
866
709
  const timer = new TimeSliceTimer(lc);
867
710
  let count = 0;
868
- let timedOut = false;
869
711
  await startAsyncSpan(tracer, "vs.#hydrateUnchangedQueries.addQuery", async (span) => {
870
712
  span.setAttribute("queryHash", queryID);
871
713
  span.setAttribute("transformationHash", transformationHash);
872
714
  span.setAttribute("table", transformedAst.table);
873
715
  if (queryName !== void 0) span.setAttribute("queryName", queryName);
874
- for (const change of this.#pipelines.addQuery(transformationHash, queryID, transformedAst, await timer.start(), queryName, "unchanged-query-rehydrate")) if (change === "yield") {
875
- if (query.type !== "internal" && this.#hydrationCircuitBreaker.exceeded(timer.totalElapsed())) {
876
- timedOut = true;
877
- await timer.yieldProcess("yield in hydrateUnchangedQueries");
878
- break;
879
- }
880
- await timer.yieldProcess("yield in hydrateUnchangedQueries");
881
- } else count++;
716
+ for (const change of this.#pipelines.addQuery(transformationHash, queryID, transformedAst, await timer.start(), queryName, "unchanged-query-rehydrate")) if (change === "yield") await timer.yieldProcess("yield in hydrateUnchangedQueries");
717
+ else count++;
882
718
  });
883
719
  const elapsed = timer.totalElapsed();
884
- if (timedOut) {
885
- this.#recordHydrationTimeout(lc, {
886
- id: queryID,
887
- transformationHash,
888
- name: queryName
889
- }, elapsed, count);
890
- continue;
891
- }
892
- hydrationPassStats.activeHydratedQueries++;
893
720
  this.#hydrations.add(1);
894
721
  this.#hydrationTime.recordMs(elapsed);
895
- this.#addQueryMaterializationServerMetric(queryID, elapsed);
896
- this.#inspectorDelegate.addQuery(queryID, transformedAst);
722
+ this.#addQueryMaterializationServerMetric(transformationHash, elapsed);
723
+ this.#inspectorDelegate.addQuery(transformationHash, transformedAst);
897
724
  lc.debug?.(`hydrated ${count} rows for ${queryID} (${elapsed} ms)`);
898
725
  let drifted = false;
899
726
  const storedSigHex = cvr.queries[queryID]?.rowSetSignature;
@@ -954,7 +781,11 @@ var ViewSyncerService = class {
954
781
  return;
955
782
  }
956
783
  const appErrorGroups = /* @__PURE__ */ new Map();
957
- for (const err of errorOrErrors) for (const clientId of getAffectedClientIDs([err.id])) getOrInsertComputed(appErrorGroups, clientId, newArray).push(err);
784
+ for (const err of errorOrErrors) for (const clientId of getAffectedClientIDs([err.id])) {
785
+ const group = appErrorGroups.get(clientId) ?? [];
786
+ group.push(err);
787
+ appErrorGroups.set(clientId, group);
788
+ }
958
789
  for (const [clientId, errors] of appErrorGroups) this.#clients.get(clientId)?.sendQueryTransformApplicationErrors(errors);
959
790
  }
960
791
  #addQueryMaterializationServerMetric(queryID, elapsed) {
@@ -990,10 +821,7 @@ var ViewSyncerService = class {
990
821
  *
991
822
  * This must be called from within the #lock.
992
823
  */
993
- #syncQueryPipelineSet(lc, cvr, customQueryTransformMode, connCtx, driftedQueryIDs = /* @__PURE__ */ new Set(), hydrationBudget = new HydrationBudget(this.#config.viewSyncerHydrationBudgetMs ?? 0, this.#now), hydrationPassStats = {
994
- activeHydratedQueries: 0,
995
- inactiveHydratedQueries: 0
996
- }, previousQueries) {
824
+ #syncQueryPipelineSet(lc, cvr, customQueryTransformMode, connCtx, driftedQueryIDs = /* @__PURE__ */ new Set()) {
997
825
  return startAsyncSpan(tracer, "vs.#syncQueryPipelineSet", async (span) => {
998
826
  const start = performance.now();
999
827
  span.setAttribute("clientGroupID", this.id);
@@ -1002,45 +830,38 @@ var ViewSyncerService = class {
1002
830
  const now = Date.now();
1003
831
  const ttlClock = this.#getTTLClock(now);
1004
832
  const cvrQueryEntires = Object.entries(cvr.queries);
833
+ const customQueries = /* @__PURE__ */ new Map();
834
+ const otherQueries = [];
1005
835
  const transformedQueries = [];
1006
- const naturallyExpiredQueryIDs = new Set(cvrQueryEntires.map(([, query]) => query).filter((query) => expired(ttlClock, query)).map((query) => query.id));
1007
- if (naturallyExpiredQueryIDs.size > 0) this.#queryEvictions.add(naturallyExpiredQueryIDs.size, { reason: "ttl" });
1008
- const hydrationCandidates = cvrQueryEntires.map(([, query]) => query).filter((query) => !naturallyExpiredQueryIDs.has(query.id));
1009
- const { required, optional } = classifyQueriesForHydration(hydrationCandidates);
1010
- const requiredQueryIDs = new Set(required.map((query) => query.id));
1011
- const optionalToHydrate = hydrationBudget.limitMs === 0 ? optional : optional.filter((query) => query.patchVersion !== void 0);
1012
- if (!this.#customQueryTransformer && hydrationCandidates.some((query) => query.type === "custom")) lc.warn?.("Custom/named queries were requested but no `ZERO_QUERY_URL` is configured for Zero Cache.");
836
+ const resolvedConnCtx = connCtx ?? this.connContextManager.mustGetBackgroundConnectionContext();
837
+ for (const [id, query] of cvrQueryEntires) if (query.type === "custom") {
838
+ assert(id === query.id, "custom query id mismatch");
839
+ customQueries.set(id, query);
840
+ } else otherQueries.push({
841
+ id,
842
+ query
843
+ });
844
+ for (const { id, query: origQuery } of otherQueries) {
845
+ assert(id === origQuery.id, "query id mismatch");
846
+ const transformed = transformAndHashQuery(lc, origQuery.id, origQuery.ast, must(this.#pipelines.currentPermissions()).permissions ?? { tables: {} }, resolvedConnCtx.auth?.type === "jwt" ? resolvedConnCtx.auth : void 0, origQuery.type === "internal");
847
+ transformedQueries.push({
848
+ id,
849
+ origQuery,
850
+ transformed
851
+ });
852
+ }
853
+ if (customQueries.size > 0 && !this.#customQueryTransformer) lc.warn?.("Custom/named queries were requested but no `ZERO_QUERY_URL` is configured for Zero Cache.");
854
+ let erroredQueryIDs;
855
+ const customQueriesToTransform = customQueryTransformMode === "all" ? [...customQueries.values()] : customQueryTransformMode && [...customQueries.values()].filter((q) => !this.#pipelines.queries().has(q.id));
1013
856
  const customQueryTransformer = this.#customQueryTransformer;
1014
- const erroredQueryIDs = [];
1015
- let transformedCustomQueryCount = 0;
1016
- const transformOtherQueries = (queries) => {
1017
- for (const origQuery of queries) {
1018
- if (origQuery.type === "custom") continue;
1019
- const transformed = transformAndHashQuery(lc, origQuery.id, origQuery.ast, must(this.#pipelines.currentPermissions()).permissions ?? { tables: {} }, connCtx.auth?.type === "jwt" ? connCtx.auth : void 0, origQuery.type === "internal");
1020
- transformedQueries.push({
1021
- id: origQuery.id,
1022
- origQuery,
1023
- transformed
1024
- });
1025
- }
1026
- };
1027
- const shouldTransformCustomQuery = (query) => {
1028
- if (customQueryTransformMode === "all") return true;
1029
- if (this.#pipelines.queries().has(query.id)) return false;
1030
- const previous = previousQueries?.get(query.id);
1031
- if (previous && previous.transformationHash === query.transformationHash) return false;
1032
- return true;
1033
- };
1034
- const transformCustomQueries = async (queries) => {
1035
- if (!customQueryTransformer || queries.length === 0) return;
1036
- transformedCustomQueryCount += queries.length;
857
+ if (customQueryTransformer && customQueriesToTransform.length > 0) {
1037
858
  const transformStart = performance.now();
1038
859
  let transformedCustomQueries;
1039
860
  try {
1040
- transformedCustomQueries = await hydrationBudget.excluding(() => this.#runPriorityOp(lc, "#syncQueryPipelineSet transforming custom queries", () => customQueryTransformer.transform(connCtx, queries)));
861
+ transformedCustomQueries = await this.#runPriorityOp(lc, "#syncQueryPipelineSet transforming custom queries", () => customQueryTransformer.transform(resolvedConnCtx, customQueriesToTransform));
1041
862
  if (transformedCustomQueries.kind === "failed") throw new ProtocolErrorWithLevel(transformedCustomQueries.result, "warn");
1042
863
  else {
1043
- if (!transformedCustomQueries.cached) this.connContextManager.validateConnection(connCtx, connCtx.revision, transformedCustomQueries.validation);
864
+ if (!transformedCustomQueries.cached) this.connContextManager.validateConnection(resolvedConnCtx, resolvedConnCtx.revision, transformedCustomQueries.validation);
1044
865
  this.#queryTransformations.add(1, { result: "success" });
1045
866
  }
1046
867
  } catch (e) {
@@ -1051,9 +872,8 @@ var ViewSyncerService = class {
1051
872
  this.#queryTransformationTime.recordMs(transformDuration);
1052
873
  }
1053
874
  const successfullyTransformedCustomQueries = /* @__PURE__ */ new Map();
1054
- const customQueryMap = new Map(queries.map((query) => [query.id, query]));
1055
- erroredQueryIDs.push(...this.#processTransformedCustomQueries(lc, transformedCustomQueries.result, (q) => {
1056
- const origQuery = customQueryMap.get(q.id);
875
+ erroredQueryIDs = this.#processTransformedCustomQueries(lc, transformedCustomQueries.result, (q) => {
876
+ const origQuery = customQueries.get(q.id);
1057
877
  if (origQuery) {
1058
878
  successfullyTransformedCustomQueries.set(q.id, q);
1059
879
  transformedQueries.push({
@@ -1062,7 +882,7 @@ var ViewSyncerService = class {
1062
882
  transformed: q
1063
883
  });
1064
884
  }
1065
- }, customQueryMap));
885
+ }, customQueries);
1066
886
  for (const [queryID, newTransform] of successfullyTransformedCustomQueries) {
1067
887
  const existingTransformHash = cvr.queries[queryID]?.transformationHash;
1068
888
  if (existingTransformHash) {
@@ -1075,55 +895,21 @@ var ViewSyncerService = class {
1075
895
  } else this.#queryTransformationNoOps.add(1);
1076
896
  }
1077
897
  }
1078
- };
1079
- const queriesToTransform = [...required, ...optionalToHydrate];
1080
- transformOtherQueries(queriesToTransform);
1081
- if (customQueryTransformMode === "missing" && previousQueries) {
1082
- for (const query of queriesToTransform) if (query.type === "custom" && !this.#pipelines.queries().has(query.id)) {
1083
- const previous = previousQueries.get(query.id);
1084
- if (previous && previous.transformationHash === query.transformationHash) {
1085
- this.#queryTransformationNoOps.add(1);
1086
- transformedQueries.push({
1087
- id: query.id,
1088
- origQuery: query,
1089
- transformed: {
1090
- id: query.id,
1091
- transformationHash: previous.transformationHash,
1092
- transformedAst: previous.originalAst ?? previous.transformedAst
1093
- }
1094
- });
1095
- }
1096
- }
1097
898
  }
1098
- await transformCustomQueries(queriesToTransform.filter((query) => query.type === "custom" && shouldTransformCustomQuery(query)));
1099
- const circuitBrokenQueries = transformedQueries.filter(({ id, origQuery, transformed }) => origQuery.type !== "internal" && this.#pipelines.queries().get(id)?.transformationHash !== transformed.transformationHash && this.#hydrationCircuitBreaker.isOpen(transformed.transformationHash)).map(({ id, origQuery, transformed }) => ({
1100
- id,
1101
- transformationHash: transformed.transformationHash,
1102
- name: origQuery.type === "custom" ? origQuery.name : void 0
1103
- }));
1104
- if (circuitBrokenQueries.length > 0) this.#rejectCircuitBrokenQueries(lc, cvr, circuitBrokenQueries);
1105
- const removeQueriesQueryIds = new Set([
1106
- ...naturallyExpiredQueryIDs,
1107
- ...erroredQueryIDs,
1108
- ...circuitBrokenQueries.map(({ id }) => id)
1109
- ]);
899
+ const removeQueriesQueryIds = new Set([...Object.values(cvr.queries).filter((q) => expired(ttlClock, q)).map((q) => q.id), ...erroredQueryIDs || []]);
1110
900
  const addQueries = transformedQueries.map(({ id, origQuery, transformed }) => ({
1111
901
  id,
1112
902
  ast: transformed.transformedAst,
1113
903
  transformationHash: transformed.transformationHash,
1114
904
  name: origQuery.type === "custom" ? origQuery.name : void 0
1115
905
  })).filter((q) => !removeQueriesQueryIds.has(q.id) && this.#pipelines.queries().get(q.id)?.transformationHash !== q.transformationHash);
1116
- const hydrationOrder = new Map([...required, ...optional].map((query, index) => [query.id, index]));
1117
- addQueries.sort((a, b) => must(hydrationOrder.get(a.id)) - must(hydrationOrder.get(b.id)));
1118
- const requiredAddQueries = addQueries.filter((query) => requiredQueryIDs.has(query.id));
1119
- const optionalAddQueries = addQueries.filter((query) => !requiredQueryIDs.has(query.id));
1120
- lc.info?.(`syncQueryPipelineSet: ${cvrQueryEntires.length} CVR queries, ${transformedCustomQueryCount} custom re-transformed, ${erroredQueryIDs.length} errored, ${circuitBrokenQueries.length} circuit-broken, ${removeQueriesQueryIds.size} to remove, ${addQueries.length} to add`);
906
+ lc.info?.(`syncQueryPipelineSet: ${cvrQueryEntires.length} CVR queries, ${customQueriesToTransform.length} custom re-transformed, ${erroredQueryIDs?.length ?? 0} errored, ${removeQueriesQueryIds.size} to remove, ${addQueries.length} to add`);
1121
907
  for (const q of addQueries) {
1122
908
  const orig = cvr.queries[q.id];
1123
909
  lc.debug?.("ViewSyncer adding query", q.ast, "transformed from", orig.type === "custom" ? orig.name : orig.ast);
1124
910
  }
1125
911
  if (addQueries.length > 0 || removeQueriesQueryIds.size > 0) {
1126
- await this.#addAndRemoveQueries(lc, cvr, requiredAddQueries, optionalAddQueries, Array.from(removeQueriesQueryIds, (id) => ({ id })), hydrationBudget, hydrationPassStats, driftedQueryIDs);
912
+ await this.#addAndRemoveQueries(lc, cvr, addQueries, Array.from(removeQueriesQueryIds, (id) => ({ id })), driftedQueryIDs);
1127
913
  if (addQueries.length > 0) this.#viewSyncerHydration.recordMs(performance.now() - start);
1128
914
  } else await this.#catchupClients(lc, cvr);
1129
915
  });
@@ -1156,93 +942,8 @@ var ViewSyncerService = class {
1156
942
  record.count++;
1157
943
  if (record.count >= THRASH_THRESHOLD) this.#lc.warn?.(`Query thrashing detected for query ${queryID}. ${record.count} replacements in 60s. This may indicate clients with different auth contexts connecting to the same client group.`);
1158
944
  }
1159
- /**
1160
- * Records that hydrating `query` was aborted for exceeding the query
1161
- * hydration timeout, and opens its circuit breaker.
1162
- */
1163
- #recordHydrationTimeout(lc, query, elapsedMs, rowCount) {
1164
- this.#hydrationCircuitBreaker.trip(query.transformationHash);
1165
- this.#hydrationTimeouts.add(1);
1166
- lc.warn?.("Query hydration aborted for exceeding the hydration timeout", {
1167
- clientGroupID: this.id,
1168
- queryHash: query.id,
1169
- transformationHash: query.transformationHash,
1170
- ...query.name !== void 0 && { queryName: query.name },
1171
- hydrationTimeoutMs: this.#hydrationCircuitBreaker.timeoutMs,
1172
- hydrationElapsedMs: elapsedMs,
1173
- ...rowCount !== void 0 && { hydrationRowCount: rowCount },
1174
- circuitBreakerOpenMs: this.#hydrationCircuitBreaker.openMs
1175
- });
1176
- }
1177
- /** Records that `query` was rejected without hydration by its open breaker. */
1178
- #recordCircuitBreakerRejection(lc, query) {
1179
- this.#hydrationCircuitBreakerRejections.add(1);
1180
- lc.warn?.("Query rejected by its open hydration circuit breaker", {
1181
- clientGroupID: this.id,
1182
- queryHash: query.id,
1183
- transformationHash: query.transformationHash,
1184
- ...query.name !== void 0 && { queryName: query.name },
1185
- hydrationTimeoutMs: this.#hydrationCircuitBreaker.timeoutMs,
1186
- circuitBreakerOpenMs: this.#hydrationCircuitBreaker.openMs
1187
- });
1188
- }
1189
- /**
1190
- * Handles queries whose hydration circuit breaker is open: they are counted,
1191
- * logged, and errored to the affected clients. The caller removes them from
1192
- * the CVR.
1193
- */
1194
- #rejectCircuitBrokenQueries(lc, cvr, queries) {
1195
- for (const query of queries) this.#recordCircuitBreakerRejection(lc, query);
1196
- this.#queryEvictions.add(queries.length, { reason: "hydration-circuit-breaker" });
1197
- this.#sendHydrationTimeoutErrors(cvr, queries);
1198
- }
1199
- /**
1200
- * Sends a per-query error to every client that desires one of `queries`.
1201
- * The error goes out as a `transformError` application error, which every
1202
- * client understands as "this query errored" without affecting the
1203
- * connection or the client's other queries.
1204
- */
1205
- #sendHydrationTimeoutErrors(cvr, queries) {
1206
- const timeoutMs = this.#hydrationCircuitBreaker.timeoutMs;
1207
- const errorsByClient = /* @__PURE__ */ new Map();
1208
- for (const { id, name } of queries) {
1209
- const query = cvr.queries[id];
1210
- if (query === void 0 || query.type === "internal") continue;
1211
- const error = {
1212
- error: "app",
1213
- id,
1214
- name: name ?? (query.type === "custom" ? query.name : "legacy"),
1215
- message: `Query hydration exceeded the ${timeoutMs}ms limit (ZERO_VIEW_SYNCER_QUERY_HYDRATION_TIMEOUT_MS) and was aborted`,
1216
- details: {
1217
- kind: "HydrationTimeout",
1218
- timeoutMs
1219
- }
1220
- };
1221
- for (const clientID of Object.keys(query.clientState)) getOrInsertComputed(errorsByClient, clientID, newArray).push(error);
1222
- }
1223
- for (const [clientID, errors] of errorsByClient) this.#clients.get(clientID)?.sendQueryTransformApplicationErrors(errors);
1224
- }
1225
- #recordHydrationBudgetExhaustion(lc, hydrationBudget, activeHydratedQueries, inactiveHydratedQueries, inactiveEvictedQueryIDs) {
1226
- const elapsedMs = hydrationBudget.exhaustedAtMs;
1227
- if (elapsedMs === void 0) return;
1228
- this.#hydrationBudgetExhaustions.add(1);
1229
- this.#hydrationBudgetEvictions.add(inactiveEvictedQueryIDs.length);
1230
- this.#hydrationBudgetElapsed.record(elapsedMs);
1231
- this.#hydrationBudgetOvershoot.record(Math.max(0, elapsedMs - hydrationBudget.limitMs));
1232
- if (inactiveEvictedQueryIDs.length > 0) this.#queryEvictions.add(inactiveEvictedQueryIDs.length, { reason: "hydration-budget" });
1233
- lc.info?.("view-syncer hydration budget exhausted", {
1234
- clientGroupID: this.id,
1235
- hydrationBudgetMs: hydrationBudget.limitMs,
1236
- hydrationElapsedMs: elapsedMs,
1237
- activeHydratedQueries,
1238
- inactiveHydratedQueries,
1239
- inactiveEvictedQueries: inactiveEvictedQueryIDs.length,
1240
- firstEvictedQueryHash: inactiveEvictedQueryIDs[0] ?? null
1241
- });
1242
- }
1243
- #addAndRemoveQueries(lc, cvr, requiredQueries, optionalQueries, removeQueries, hydrationBudget, hydrationPassStats, driftedQueryIDs = /* @__PURE__ */ new Set()) {
945
+ #addAndRemoveQueries(lc, cvr, addQueries, removeQueries, driftedQueryIDs = /* @__PURE__ */ new Set()) {
1244
946
  return startAsyncSpan(tracer, "vs.#addAndRemoveQueries", async () => {
1245
- const addQueries = [...requiredQueries, ...optionalQueries];
1246
947
  assert(addQueries.length > 0 || removeQueries.length > 0, "Must have queries to add or remove");
1247
948
  const start = performance.now();
1248
949
  const stateVersion = this.#pipelines.currentVersion();
@@ -1259,7 +960,6 @@ var ViewSyncerService = class {
1259
960
  updater.ensureNewVersion();
1260
961
  }
1261
962
  const { queryPatches, newVersion } = updater.trackQueries(lc, addQueries, removeQueries);
1262
- if (hydrationBudget.limitMs !== 0 && optionalQueries.length > 0) assert(cmpVersions(cvr.version, newVersion) < 0, "Optional hydration requires a final poke version before row processing so a removal is actually poked");
1263
963
  const pokers = startPoke(this.#getClients(), newVersion);
1264
964
  for (const patch of queryPatches) await pokers.addPatch(patch);
1265
965
  for (const q of removeQueries) {
@@ -1276,54 +976,22 @@ var ViewSyncerService = class {
1276
976
  let totalHydratedQueries = 0;
1277
977
  let coveredHydratedQueries = 0;
1278
978
  let firstCoveredQuery;
1279
- const hydratedQueryIDs = [];
1280
- const budgetEvictedQueryIDs = [];
1281
- const timedOutQueries = [];
1282
- const rejectedQueries = [];
1283
- const circuitBreaker = this.#hydrationCircuitBreaker;
1284
979
  const self = this;
1285
980
  await yieldProcess(lc);
1286
- function* hydrateQueries(queries, optional, slowHydrateThreshold) {
1287
- for (let i = 0; i < queries.length; i++) {
1288
- if (optional && hydrationBudget.exhausted()) {
1289
- budgetEvictedQueryIDs.push(...queries.slice(i).map((query) => query.id));
1290
- return;
1291
- }
1292
- const q = must(queries[i]);
981
+ function* generateRowChanges(slowHydrateThreshold) {
982
+ for (const q of addQueries) {
1293
983
  let queryLC = lc.withContext("hash", q.id).withContext("queryHash", q.id).withContext("transformationHash", q.transformationHash);
1294
984
  if (q.name !== void 0) queryLC = queryLC.withContext("queryName", q.name);
1295
985
  queryLC.debug?.(`adding pipeline for query`, q.ast);
1296
- const breakable = cvr.queries[q.id]?.type !== "internal";
1297
- if (breakable && circuitBreaker.isOpen(q.transformationHash)) {
1298
- rejectedQueries.push(q);
1299
- self.#recordCircuitBreakerRejection(queryLC, q);
1300
- continue;
1301
- }
1302
986
  const covered = queryCoveringIndex ? self.#findQueryCoverageShadowHit(queryCoveringIndex, q.id, q.transformationHash, q.ast, q.name) : void 0;
1303
987
  totalHydratedQueries++;
1304
988
  if (covered) {
1305
989
  coveredHydratedQueries++;
1306
990
  firstCoveredQuery ??= covered;
1307
991
  }
1308
- let timedOut = false;
1309
- for (const change of pipelines.addQuery(q.transformationHash, q.id, q.ast, timer.startWithoutYielding(), q.name, "query-set-sync")) {
1310
- if (change === "yield" && breakable && circuitBreaker.exceeded(timer.totalElapsed())) {
1311
- timedOut = true;
1312
- yield change;
1313
- break;
1314
- }
1315
- yield change;
1316
- }
992
+ yield* pipelines.addQuery(q.transformationHash, q.id, q.ast, timer.startWithoutYielding(), q.name, "query-set-sync");
1317
993
  const elapsed = timer.stop();
1318
994
  totalProcessTime += elapsed;
1319
- if (timedOut) {
1320
- timedOutQueries.push(q);
1321
- self.#recordHydrationTimeout(queryLC, q, elapsed);
1322
- continue;
1323
- }
1324
- hydratedQueryIDs.push(q.id);
1325
- if (optional) hydrationPassStats.inactiveHydratedQueries++;
1326
- else hydrationPassStats.activeHydratedQueries++;
1327
995
  self.#addQueryMaterializationServerMetric(q.id, elapsed);
1328
996
  self.#inspectorDelegate.addQuery(q.id, q.ast);
1329
997
  queryCoveringIndex?.add(q.id, {
@@ -1337,43 +1005,18 @@ var ViewSyncerService = class {
1337
1005
  transformationHash: q.transformationHash,
1338
1006
  ...q.name !== void 0 && { name: q.name }
1339
1007
  });
1340
- hydrations.add(1);
1341
- hydrationTime.recordMs(elapsed);
1342
1008
  }
1343
- }
1344
- function* generateRowChanges(slowHydrateThreshold) {
1345
- yield* hydrateQueries(requiredQueries, false, slowHydrateThreshold);
1346
- yield* hydrateQueries(optionalQueries, true, slowHydrateThreshold);
1009
+ hydrations.add(1);
1010
+ hydrationTime.recordMs(totalProcessTime);
1347
1011
  }
1348
1012
  await this.#processChanges(lc, timer, generateRowChanges(this.#slowHydrateThreshold), updater, pokers);
1349
- const abortedQueries = [...timedOutQueries, ...rejectedQueries];
1350
- if (abortedQueries.length > 0) {
1351
- const abortedQueryIDs = abortedQueries.map(({ id }) => id);
1352
- for (const patch of await updater.abortExecutedQueries(lc, abortedQueryIDs)) await pokers.addPatch(patch);
1353
- for (const queryID of abortedQueryIDs) {
1354
- this.#pipelines.removeQuery(queryID);
1355
- this.#inspectorDelegate.removeQuery(queryID);
1356
- this.#queryReplacements.delete(queryID);
1357
- }
1358
- if (timedOutQueries.length > 0) this.#queryEvictions.add(timedOutQueries.length, { reason: "hydration-timeout" });
1359
- if (rejectedQueries.length > 0) this.#queryEvictions.add(rejectedQueries.length, { reason: "hydration-circuit-breaker" });
1360
- this.#sendHydrationTimeoutErrors(cvr, abortedQueries);
1361
- }
1362
- for (const patch of updater.removeTrackedQueries(budgetEvictedQueryIDs)) await pokers.addPatch(patch);
1363
- for (const queryID of budgetEvictedQueryIDs) {
1364
- this.#pipelines.removeQuery(queryID);
1365
- this.#inspectorDelegate.removeQuery(queryID);
1366
- this.#queryReplacements.delete(queryID);
1367
- }
1368
- this.#recordHydrationBudgetExhaustion(lc, hydrationBudget, hydrationPassStats.activeHydratedQueries, hydrationPassStats.inactiveHydratedQueries, budgetEvictedQueryIDs);
1369
1013
  this.#logQueryCoverageShadowSummary(lc, "add", totalHydratedQueries, coveredHydratedQueries, firstCoveredQuery);
1370
1014
  await startAsyncSpan(tracer, "vs.#syncQueryPipelineSet.deleteUnreferencedRows", async () => {
1371
1015
  for (const patch of await updater.deleteUnreferencedRows(lc)) await pokers.addPatch(patch);
1372
1016
  });
1373
1017
  this.#cvr = await this.#flushUpdater(lc, updater);
1374
- if (budgetEvictedQueryIDs.length > 0) this.#scheduleExpireEviction(lc, this.#cvr);
1375
1018
  const finalVersion = this.#cvr.version;
1376
- await this.#catchupClients(lc, cvr, finalVersion, hydratedQueryIDs, pokers);
1019
+ await this.#catchupClients(lc, cvr, finalVersion, addQueries.map((q) => q.id), pokers);
1377
1020
  await startAsyncSpan(tracer, "vs.#syncQueryPipelineSet.pokeEnd", () => pokers.end(finalVersion));
1378
1021
  this.#markVersionServed(stateVersion);
1379
1022
  const wallTime = performance.now() - start;
@@ -1514,9 +1157,7 @@ var ViewSyncerService = class {
1514
1157
  *
1515
1158
  * Must be called from within the #lock.
1516
1159
  *
1517
- * Returns 'success' if changes were successfully processed and poked,
1518
- * or a `ResetPipelinesSignal` if advancement aborted (e.g. schema change,
1519
- * timeout) and pipelines need to be reset and rehydrated.
1160
+ * Returns false if the advancement failed due to a schema change.
1520
1161
  */
1521
1162
  #advancePipelines(lc, cvr) {
1522
1163
  return startAsyncSpan(tracer, "vs.#advancePipelines", async (span) => {
@@ -1524,27 +1165,20 @@ var ViewSyncerService = class {
1524
1165
  assert(this.#pipelines.initialized(), "pipelines must be initialized (advancePipelines");
1525
1166
  const start = performance.now();
1526
1167
  const timer = new TimeSliceTimer(lc);
1527
- let pokers;
1528
- let updater;
1529
- let version;
1530
- let numChanges = 0;
1168
+ const { version, numChanges, changes } = this.#pipelines.advance(timer);
1169
+ lc = lc.withContext("newVersion", version);
1170
+ const updater = new CVRQueryDrivenUpdater(this.#cvrStore, cvr, version, this.#pipelines.replicaVersion, (queryID) => this.#pipelines.rowSetSignature(queryID));
1171
+ const pokers = startPoke(this.#getClients(cvr.version), updater.updatedVersion());
1172
+ lc.debug?.(`applying ${numChanges} to advance to ${version}`);
1531
1173
  try {
1532
- const advancement = this.#pipelines.advance(timer);
1533
- version = advancement.version;
1534
- numChanges = advancement.numChanges;
1535
- lc = lc.withContext("newVersion", version);
1536
- updater = new CVRQueryDrivenUpdater(this.#cvrStore, cvr, version, this.#pipelines.replicaVersion, (queryID) => this.#pipelines.rowSetSignature(queryID));
1537
- pokers = startPoke(this.#getClients(cvr.version), updater.updatedVersion());
1538
- lc.debug?.(`applying ${numChanges} to advance to ${version}`);
1539
- await this.#processChanges(lc, await timer.start(), advancement.changes, updater, pokers);
1174
+ await this.#processChanges(lc, await timer.start(), changes, updater, pokers);
1540
1175
  } catch (e) {
1541
1176
  if (e instanceof ResetPipelinesSignal) {
1542
- await pokers?.cancel();
1177
+ await pokers.cancel();
1543
1178
  return e;
1544
1179
  }
1545
1180
  throw e;
1546
1181
  }
1547
- assert(updater && pokers && version !== void 0, "advancement state missing");
1548
1182
  this.#cvr = await this.#flushUpdater(lc, updater);
1549
1183
  const finalVersion = this.#cvr.version;
1550
1184
  await startAsyncSpan(tracer, "vs.#advancePipelines.pokeEnd", () => pokers.end(finalVersion));
@@ -1565,7 +1199,7 @@ var ViewSyncerService = class {
1565
1199
  clientID,
1566
1200
  wsID: client.wsID
1567
1201
  });
1568
- return handleInspect(lc, body, cvr, client, this.#inspectorDelegate, this.id, this, this.#cvrStore, this.#config, connCtx);
1202
+ return handleInspect(lc, body, cvr, client, this.#inspectorDelegate, this.id, this.#cvrStore, this.#config, connCtx);
1569
1203
  };
1570
1204
  async #runBackgroundRetransform(lc) {
1571
1205
  const attemptRetransform = async (connCtx) => {
@@ -1652,18 +1286,15 @@ var ViewSyncerService = class {
1652
1286
  return this.#stopped.promise;
1653
1287
  }
1654
1288
  async #cleanup(err) {
1655
- this.#shuttingDown = true;
1656
1289
  this.connContextManager.setSharedRetransformReady(false);
1657
1290
  this.#stopTTLClockInterval();
1658
1291
  this.#stopExpireTimer();
1659
1292
  this.#stopAuthMaintenanceTimer();
1660
- this.#stopShutdownTimer();
1661
1293
  this.#customQueryTransformer?.destroy();
1662
1294
  for (const client of this.#clients.values()) if (err) client.fail(err);
1663
1295
  else client.close(`closed clientGroupID=${this.id}`);
1664
1296
  await this.#lock.withLock(() => {});
1665
1297
  this.#pipelines.destroy();
1666
- this.#inspectorDelegate.clearAuthenticated(this.id, this);
1667
1298
  }
1668
1299
  /**
1669
1300
  * Test helper: Manually mark initialization as complete.
@@ -1699,10 +1330,8 @@ function isTransformFailedError(error) {
1699
1330
  return error.errorBody.kind === "TransformFailed" && !isAuthErrorBody(error.errorBody);
1700
1331
  }
1701
1332
  /**
1702
- * Whether a query's TTL has elapsed. A query must be expired for all clients
1703
- * in order to be considered expired.
1704
- *
1705
- * Exported for testing.
1333
+ * A query must be expired for all clients in order to be considered
1334
+ * expired.
1706
1335
  */
1707
1336
  function expired(ttlClock, q) {
1708
1337
  if (q.type === "internal") return false;