@rivetkit/engine 1.0.0 → 2.2.1-pr.4600.b74ff3b

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 (1038) hide show
  1. package/CLAUDE.md +38 -0
  2. package/artifacts/config-schema.json +1140 -0
  3. package/artifacts/errors/actor.kv_storage_quota_exceeded.json +5 -0
  4. package/artifacts/errors/actor.no_runner_config_configured.json +5 -0
  5. package/artifacts/errors/guard.actor_runner_failed.json +5 -0
  6. package/artifacts/errors/guard.invalid_request.json +5 -0
  7. package/artifacts/errors/guard.invalid_request_body.json +5 -0
  8. package/artifacts/errors/guard.invalid_response_body.json +5 -0
  9. package/artifacts/errors/guard.missing_query_parameter.json +5 -0
  10. package/artifacts/errors/guard.query_ambiguous_runner_configs.json +5 -0
  11. package/artifacts/errors/guard.query_duplicate_param.json +5 -0
  12. package/artifacts/errors/guard.query_empty_actor_name.json +5 -0
  13. package/artifacts/errors/guard.query_get_disallowed_params.json +5 -0
  14. package/artifacts/errors/guard.query_invalid_base64_input.json +5 -0
  15. package/artifacts/errors/guard.query_invalid_cbor_input.json +5 -0
  16. package/artifacts/errors/guard.query_invalid_params.json +5 -0
  17. package/artifacts/errors/guard.query_invalid_percent_encoding.json +5 -0
  18. package/artifacts/errors/guard.query_missing_runner_name.json +5 -0
  19. package/artifacts/errors/guard.query_no_runner_configs.json +5 -0
  20. package/artifacts/errors/guard.query_param_missing_equals.json +5 -0
  21. package/artifacts/errors/guard.query_path_token_syntax.json +5 -0
  22. package/artifacts/errors/guard.query_unknown_param.json +5 -0
  23. package/artifacts/errors/guard.request_body_too_large.json +5 -0
  24. package/artifacts/errors/guard.response_body_too_large.json +5 -0
  25. package/artifacts/errors/serverless_runner_pool.failed_to_fetch_metadata.json +5 -0
  26. package/artifacts/errors/serverless_runner_pool.not_found.json +5 -0
  27. package/artifacts/errors/{api.rate_limited.json → test.api_rate_limited.json} +2 -2
  28. package/artifacts/errors/{namespace.invalid_name.json → test.namespace_invalid_name.json} +2 -2
  29. package/artifacts/errors/ws.going_away.json +5 -0
  30. package/artifacts/openapi.json +458 -6
  31. package/docker/builder-base/linux-gnu.Dockerfile +21 -0
  32. package/docker/builder-base/linux-musl.Dockerfile +53 -0
  33. package/docker/builder-base/osxcross.Dockerfile +42 -0
  34. package/docker/builder-base/windows-mingw.Dockerfile +41 -0
  35. package/docker/builder-base/windows-msvc.Dockerfile +25 -0
  36. package/docker/dev/docker-compose.yml +43 -18
  37. package/docker/dev/grafana/dashboards/api.json +1077 -1239
  38. package/docker/dev/grafana/dashboards/cache.json +911 -1074
  39. package/docker/dev/grafana/dashboards/epoxy.json +1606 -0
  40. package/docker/dev/grafana/dashboards/futures.json +242 -229
  41. package/docker/dev/grafana/dashboards/gasoline.json +2663 -2476
  42. package/docker/dev/grafana/dashboards/guard.json +1433 -1273
  43. package/docker/dev/grafana/dashboards/operation.json +871 -0
  44. package/docker/dev/grafana/dashboards/pegboard.json +1274 -0
  45. package/docker/dev/grafana/dashboards/tokio.json +930 -1004
  46. package/docker/dev/grafana/dashboards/traces.json +35 -13
  47. package/docker/dev/grafana/provisioning/datasources/datasources.yaml +8 -0
  48. package/docker/{dev-multinode/otel-collector-server → dev/otel-collector}/config.yaml +18 -13
  49. package/docker/dev/prometheus/prometheus.yml +4 -0
  50. package/docker/dev/rivet-engine/config.jsonc +9 -16
  51. package/docker/dev-host/docker-compose.yml +38 -16
  52. package/docker/dev-host/grafana/dashboards/api.json +1077 -1239
  53. package/docker/dev-host/grafana/dashboards/cache.json +911 -1074
  54. package/docker/dev-host/grafana/dashboards/epoxy.json +1606 -0
  55. package/docker/dev-host/grafana/dashboards/futures.json +242 -229
  56. package/docker/dev-host/grafana/dashboards/gasoline.json +2663 -2476
  57. package/docker/dev-host/grafana/dashboards/guard.json +1433 -1273
  58. package/docker/dev-host/grafana/dashboards/operation.json +871 -0
  59. package/docker/dev-host/grafana/dashboards/pegboard.json +1274 -0
  60. package/docker/dev-host/grafana/dashboards/tokio.json +930 -1004
  61. package/docker/dev-host/grafana/dashboards/traces.json +35 -13
  62. package/docker/dev-host/grafana/provisioning/datasources/datasources.yaml +8 -0
  63. package/docker/dev-host/{otel-collector-server → otel-collector}/config.yaml +18 -13
  64. package/docker/dev-host/prometheus/prometheus.yml +4 -0
  65. package/docker/dev-host/rivet-engine/config.jsonc +9 -16
  66. package/docker/dev-multidc/core/grafana/dashboards/api.json +1077 -1239
  67. package/docker/dev-multidc/core/grafana/dashboards/cache.json +911 -1074
  68. package/docker/dev-multidc/core/grafana/dashboards/epoxy.json +1606 -0
  69. package/docker/dev-multidc/core/grafana/dashboards/futures.json +242 -229
  70. package/docker/dev-multidc/core/grafana/dashboards/gasoline.json +2663 -2476
  71. package/docker/dev-multidc/core/grafana/dashboards/guard.json +1433 -1273
  72. package/docker/dev-multidc/core/grafana/dashboards/operation.json +871 -0
  73. package/docker/dev-multidc/core/grafana/dashboards/pegboard.json +1274 -0
  74. package/docker/dev-multidc/core/grafana/dashboards/tokio.json +930 -1004
  75. package/docker/dev-multidc/core/grafana/dashboards/traces.json +35 -13
  76. package/docker/dev-multidc/core/grafana/provisioning/datasources/datasources.yaml +8 -0
  77. package/docker/dev-multidc/core/prometheus/prometheus.yml +4 -0
  78. package/docker/dev-multidc/datacenters/dc-a/{otel-collector-server → otel-collector}/config.yaml +18 -13
  79. package/docker/dev-multidc/datacenters/dc-a/rivet-engine/config.jsonc +23 -22
  80. package/docker/{dev-multidc-multinode/datacenters/dc-b/otel-collector-server → dev-multidc/datacenters/dc-b/otel-collector}/config.yaml +18 -13
  81. package/docker/dev-multidc/datacenters/dc-b/rivet-engine/config.jsonc +23 -22
  82. package/docker/dev-multidc/datacenters/dc-c/{otel-collector-server → otel-collector}/config.yaml +18 -13
  83. package/docker/dev-multidc/datacenters/dc-c/rivet-engine/config.jsonc +23 -22
  84. package/docker/dev-multidc/docker-compose.yml +71 -64
  85. package/docker/dev-multidc-multinode/core/grafana/dashboards/api.json +1077 -1239
  86. package/docker/dev-multidc-multinode/core/grafana/dashboards/cache.json +911 -1074
  87. package/docker/dev-multidc-multinode/core/grafana/dashboards/epoxy.json +1606 -0
  88. package/docker/dev-multidc-multinode/core/grafana/dashboards/futures.json +242 -229
  89. package/docker/dev-multidc-multinode/core/grafana/dashboards/gasoline.json +2663 -2476
  90. package/docker/dev-multidc-multinode/core/grafana/dashboards/guard.json +1433 -1273
  91. package/docker/dev-multidc-multinode/core/grafana/dashboards/operation.json +871 -0
  92. package/docker/dev-multidc-multinode/core/grafana/dashboards/pegboard.json +1274 -0
  93. package/docker/dev-multidc-multinode/core/grafana/dashboards/tokio.json +930 -1004
  94. package/docker/dev-multidc-multinode/core/grafana/dashboards/traces.json +35 -13
  95. package/docker/dev-multidc-multinode/core/grafana/provisioning/datasources/datasources.yaml +8 -0
  96. package/docker/dev-multidc-multinode/core/prometheus/prometheus.yml +4 -0
  97. package/docker/dev-multidc-multinode/datacenters/dc-a/{otel-collector-server → otel-collector}/config.yaml +28 -13
  98. package/docker/dev-multidc-multinode/datacenters/dc-a/rivet-engine/0/config.jsonc +23 -22
  99. package/docker/dev-multidc-multinode/datacenters/dc-a/rivet-engine/1/config.jsonc +23 -22
  100. package/docker/dev-multidc-multinode/datacenters/dc-a/rivet-engine/2/config.jsonc +23 -22
  101. package/docker/{dev-multidc/datacenters/dc-b/otel-collector-server → dev-multidc-multinode/datacenters/dc-b/otel-collector}/config.yaml +28 -13
  102. package/docker/dev-multidc-multinode/datacenters/dc-b/rivet-engine/0/config.jsonc +23 -22
  103. package/docker/dev-multidc-multinode/datacenters/dc-b/rivet-engine/1/config.jsonc +23 -22
  104. package/docker/dev-multidc-multinode/datacenters/dc-b/rivet-engine/2/config.jsonc +23 -22
  105. package/docker/dev-multidc-multinode/datacenters/dc-c/{otel-collector-server → otel-collector}/config.yaml +28 -13
  106. package/docker/dev-multidc-multinode/datacenters/dc-c/rivet-engine/0/config.jsonc +23 -22
  107. package/docker/dev-multidc-multinode/datacenters/dc-c/rivet-engine/1/config.jsonc +23 -22
  108. package/docker/dev-multidc-multinode/datacenters/dc-c/rivet-engine/2/config.jsonc +23 -22
  109. package/docker/dev-multidc-multinode/docker-compose.yml +113 -88
  110. package/docker/dev-multinode/docker-compose.yml +57 -26
  111. package/docker/dev-multinode/grafana/dashboards/api.json +1077 -1239
  112. package/docker/dev-multinode/grafana/dashboards/cache.json +911 -1074
  113. package/docker/dev-multinode/grafana/dashboards/epoxy.json +1606 -0
  114. package/docker/dev-multinode/grafana/dashboards/futures.json +242 -229
  115. package/docker/dev-multinode/grafana/dashboards/gasoline.json +2663 -2476
  116. package/docker/dev-multinode/grafana/dashboards/guard.json +1433 -1273
  117. package/docker/dev-multinode/grafana/dashboards/operation.json +871 -0
  118. package/docker/dev-multinode/grafana/dashboards/pegboard.json +1274 -0
  119. package/docker/dev-multinode/grafana/dashboards/tokio.json +930 -1004
  120. package/docker/dev-multinode/grafana/dashboards/traces.json +35 -13
  121. package/docker/dev-multinode/grafana/provisioning/datasources/datasources.yaml +8 -0
  122. package/docker/{dev/otel-collector-server → dev-multinode/otel-collector}/config.yaml +28 -13
  123. package/docker/dev-multinode/prometheus/prometheus.yml +4 -0
  124. package/docker/dev-multinode/rivet-engine/0/config.jsonc +9 -16
  125. package/docker/dev-multinode/rivet-engine/1/config.jsonc +9 -16
  126. package/docker/dev-multinode/rivet-engine/2/config.jsonc +9 -16
  127. package/docker/engine/linux-aarch64.Dockerfile +9 -49
  128. package/docker/engine/linux-x86_64.Dockerfile +7 -57
  129. package/docker/engine/macos-aarch64.Dockerfile +8 -54
  130. package/docker/engine/macos-x86_64.Dockerfile +9 -55
  131. package/docker/engine/windows.Dockerfile +5 -53
  132. package/docker/template/grafana-dashboards/api.json +1077 -1239
  133. package/docker/template/grafana-dashboards/cache.json +911 -1074
  134. package/docker/template/grafana-dashboards/epoxy.json +1606 -0
  135. package/docker/template/grafana-dashboards/futures.json +242 -229
  136. package/docker/template/grafana-dashboards/gasoline.json +2663 -2476
  137. package/docker/template/grafana-dashboards/guard.json +1433 -1273
  138. package/docker/template/grafana-dashboards/operation.json +871 -0
  139. package/docker/template/grafana-dashboards/pegboard.json +1274 -0
  140. package/docker/template/grafana-dashboards/tokio.json +930 -1004
  141. package/docker/template/grafana-dashboards/traces.json +35 -13
  142. package/docker/template/node_modules/.bin/js-yaml +4 -4
  143. package/docker/template/node_modules/.bin/tsc +4 -4
  144. package/docker/template/node_modules/.bin/tsserver +4 -4
  145. package/docker/template/node_modules/.bin/tsx +4 -4
  146. package/docker/template/src/docker-compose.ts +42 -29
  147. package/docker/template/src/main.ts +4 -4
  148. package/docker/template/src/services/core/grafana.ts +14 -1
  149. package/docker/template/src/services/core/prometheus.ts +20 -0
  150. package/docker/template/src/services/edge/{otel-collector-server.ts → otel-collector.ts} +55 -24
  151. package/docker/template/src/services/edge/rivet-engine.ts +4 -16
  152. package/docker/template/src/services/edge/runner.ts +2 -3
  153. package/docker/universal/Dockerfile +5 -3
  154. package/package.json +2 -5
  155. package/packages/api-builder/src/global_context.rs +1 -1
  156. package/packages/api-builder/src/metrics.rs +28 -24
  157. package/packages/api-builder/src/middleware.rs +30 -48
  158. package/packages/api-builder/src/router.rs +13 -1
  159. package/packages/api-peer/Cargo.toml +7 -9
  160. package/packages/api-peer/src/actors/delete.rs +56 -57
  161. package/packages/api-peer/src/actors/get_or_create.rs +139 -0
  162. package/packages/api-peer/src/actors/kv_get.rs +40 -28
  163. package/packages/api-peer/src/actors/list.rs +31 -14
  164. package/packages/api-peer/src/actors/list_names.rs +6 -6
  165. package/packages/api-peer/src/actors/mod.rs +3 -0
  166. package/packages/api-peer/src/actors/reschedule.rs +55 -0
  167. package/packages/api-peer/src/actors/sleep.rs +55 -0
  168. package/packages/api-peer/src/envoys.rs +57 -0
  169. package/packages/api-peer/src/internal.rs +441 -24
  170. package/packages/api-peer/src/lib.rs +2 -1
  171. package/packages/api-peer/src/namespaces.rs +24 -9
  172. package/packages/api-peer/src/router.rs +31 -7
  173. package/packages/api-peer/src/runner_configs.rs +66 -19
  174. package/packages/api-peer/src/runners.rs +30 -32
  175. package/packages/api-public/Cargo.toml +2 -0
  176. package/packages/api-public/src/actors/create.rs +8 -17
  177. package/packages/api-public/src/actors/delete.rs +11 -35
  178. package/packages/api-public/src/actors/get_or_create.rs +23 -95
  179. package/packages/api-public/src/actors/kv_get.rs +12 -29
  180. package/packages/api-public/src/actors/list.rs +56 -78
  181. package/packages/api-public/src/actors/list_names.rs +15 -14
  182. package/packages/api-public/src/actors/mod.rs +2 -0
  183. package/packages/api-public/src/actors/reschedule.rs +65 -0
  184. package/packages/api-public/src/actors/sleep.rs +64 -0
  185. package/packages/api-public/src/actors/utils.rs +12 -60
  186. package/packages/api-public/src/ctx.rs +14 -6
  187. package/packages/api-public/src/datacenters.rs +5 -5
  188. package/packages/api-public/src/envoys.rs +57 -0
  189. package/packages/api-public/src/errors.rs +0 -7
  190. package/packages/api-public/src/health.rs +51 -44
  191. package/packages/api-public/src/lib.rs +2 -1
  192. package/packages/api-public/src/metadata.rs +44 -14
  193. package/packages/api-public/src/namespaces.rs +11 -11
  194. package/packages/api-public/src/router.rs +22 -5
  195. package/packages/api-public/src/runner_configs/delete.rs +13 -10
  196. package/packages/api-public/src/runner_configs/list.rs +5 -2
  197. package/packages/api-public/src/runner_configs/refresh_metadata.rs +1 -1
  198. package/packages/api-public/src/runner_configs/serverless_health_check.rs +2 -2
  199. package/packages/api-public/src/runner_configs/upsert.rs +12 -9
  200. package/packages/api-public/src/runner_configs/utils.rs +35 -175
  201. package/packages/api-public/src/runners.rs +17 -45
  202. package/packages/{dump-openapi → api-public-openapi-gen}/Cargo.toml +1 -1
  203. package/packages/api-types/src/actors/create.rs +1 -0
  204. package/packages/api-types/src/actors/delete.rs +20 -0
  205. package/packages/api-types/src/actors/get_or_create.rs +30 -0
  206. package/packages/api-types/src/actors/kv_get.rs +25 -0
  207. package/packages/api-types/src/actors/list.rs +8 -1
  208. package/packages/api-types/src/actors/mod.rs +5 -0
  209. package/packages/api-types/src/actors/reschedule.rs +26 -0
  210. package/packages/api-types/src/actors/sleep.rs +26 -0
  211. package/packages/api-types/src/datacenters/list.rs +2 -2
  212. package/packages/api-types/src/envoys/list.rs +24 -0
  213. package/packages/api-types/src/envoys/mod.rs +1 -0
  214. package/packages/api-types/src/lib.rs +1 -0
  215. package/packages/api-types/src/namespaces/list.rs +4 -0
  216. package/packages/api-types/src/namespaces/runner_configs.rs +23 -2
  217. package/packages/api-types/src/runner_configs/list.rs +6 -1
  218. package/packages/api-types/src/runner_configs/mod.rs +12 -0
  219. package/packages/api-types/src/runners/list.rs +4 -0
  220. package/packages/api-types/src/runners/list_names.rs +21 -0
  221. package/packages/api-types/src/runners/mod.rs +1 -0
  222. package/packages/api-util/src/lib.rs +44 -21
  223. package/packages/bootstrap/Cargo.toml +7 -4
  224. package/packages/bootstrap/src/backfill.rs +53 -0
  225. package/packages/bootstrap/src/lib.rs +43 -7
  226. package/packages/cache/Cargo.toml +3 -1
  227. package/packages/cache/src/driver.rs +43 -151
  228. package/packages/cache/src/getter_ctx.rs +48 -70
  229. package/packages/cache/src/inner.rs +28 -18
  230. package/packages/cache/src/key.rs +17 -3
  231. package/packages/cache/src/lib.rs +0 -2
  232. package/packages/cache/src/metrics.rs +43 -31
  233. package/packages/cache/src/req_config.rs +219 -156
  234. package/packages/cache/tests/fetch.rs +91 -0
  235. package/packages/cache/tests/in_flight.rs +361 -0
  236. package/packages/cache/tests/ttl.rs +314 -0
  237. package/packages/cache-purge/src/lib.rs +1 -1
  238. package/packages/config/Cargo.toml +1 -0
  239. package/packages/config/src/config/cache.rs +10 -3
  240. package/packages/config/src/config/clickhouse.rs +0 -30
  241. package/packages/config/src/config/{db.rs → db/mod.rs} +3 -18
  242. package/packages/config/src/config/db/postgres.rs +59 -0
  243. package/packages/config/src/config/guard.rs +19 -0
  244. package/packages/config/src/config/metrics.rs +22 -0
  245. package/packages/config/src/config/mod.rs +44 -10
  246. package/packages/config/src/config/pegboard.rs +242 -16
  247. package/packages/config/src/config/pubsub.rs +11 -0
  248. package/packages/config/src/config/runtime.rs +58 -0
  249. package/packages/config/src/config/telemetry.rs +1 -0
  250. package/packages/config/src/config/topology.rs +78 -19
  251. package/packages/config/src/defaults.rs +3 -0
  252. package/packages/config/src/lib.rs +10 -1
  253. package/packages/config-schema-gen/Cargo.toml +11 -0
  254. package/packages/config-schema-gen/build.rs +26 -0
  255. package/packages/config-schema-gen/src/lib.rs +2 -0
  256. package/packages/engine/Cargo.toml +11 -2
  257. package/packages/engine/src/commands/db/mod.rs +0 -10
  258. package/packages/engine/src/commands/epoxy.rs +395 -0
  259. package/packages/engine/src/commands/mod.rs +1 -1
  260. package/packages/engine/src/commands/start.rs +43 -63
  261. package/packages/engine/src/commands/udb/cli.rs +148 -4
  262. package/packages/engine/src/commands/wf/mod.rs +83 -12
  263. package/packages/engine/src/commands/wf/signal.rs +38 -0
  264. package/packages/engine/src/lib.rs +6 -3
  265. package/packages/engine/src/main.rs +1 -1
  266. package/packages/engine/src/run_config.rs +6 -7
  267. package/packages/engine/src/util/db.rs +1 -25
  268. package/packages/engine/src/util/wf/mod.rs +39 -5
  269. package/packages/engine/tests/common/actors.rs +50 -332
  270. package/packages/engine/tests/common/api/mod.rs +7 -0
  271. package/packages/engine/tests/common/api/peer.rs +364 -0
  272. package/packages/engine/tests/common/api/public.rs +473 -0
  273. package/packages/engine/tests/common/ctx.rs +15 -3
  274. package/packages/engine/tests/common/mod.rs +8 -5
  275. package/packages/engine/tests/common/test_envoy.rs +87 -0
  276. package/packages/engine/tests/common/test_helpers.rs +218 -130
  277. package/packages/engine/tests/common/test_runner.rs +273 -0
  278. package/packages/engine/tests/envoy/actors_lifecycle.rs +1277 -0
  279. package/packages/engine/tests/envoy/mod.rs +1 -0
  280. package/packages/engine/tests/mod.rs +3 -0
  281. package/packages/engine/tests/runner/actors_alarm.rs +1453 -0
  282. package/packages/engine/tests/runner/actors_kv_crud.rs +996 -0
  283. package/packages/engine/tests/runner/actors_kv_delete_range.rs +126 -0
  284. package/packages/engine/tests/runner/actors_kv_drop.rs +255 -0
  285. package/packages/engine/tests/runner/actors_kv_list.rs +1061 -0
  286. package/packages/engine/tests/runner/actors_kv_misc.rs +882 -0
  287. package/packages/engine/tests/runner/actors_lifecycle.rs +1284 -0
  288. package/packages/engine/tests/runner/actors_scheduling_errors.rs +1005 -0
  289. package/packages/engine/tests/runner/api_actors_create.rs +422 -0
  290. package/packages/engine/tests/runner/api_actors_delete.rs +487 -0
  291. package/packages/engine/tests/runner/api_actors_get_or_create.rs +634 -0
  292. package/packages/engine/tests/runner/api_actors_list.rs +1771 -0
  293. package/packages/engine/tests/runner/api_actors_list_names.rs +691 -0
  294. package/packages/engine/tests/runner/api_namespaces_create.rs +428 -0
  295. package/packages/engine/tests/runner/api_namespaces_list.rs +760 -0
  296. package/packages/engine/tests/runner/api_runner_configs_list.rs +646 -0
  297. package/packages/engine/tests/runner/api_runner_configs_upsert.rs +651 -0
  298. package/packages/engine/tests/runner/api_runners_list.rs +166 -0
  299. package/packages/engine/tests/runner/api_runners_list_names.rs +386 -0
  300. package/packages/engine/tests/runner/mod.rs +20 -0
  301. package/packages/engine/tests/runner/runner_drain_on_version.rs +620 -0
  302. package/packages/env/Cargo.toml +0 -4
  303. package/packages/env/src/lib.rs +0 -18
  304. package/packages/epoxy/Cargo.toml +3 -2
  305. package/packages/epoxy/README.md +554 -93
  306. package/packages/epoxy/src/consts.rs +4 -36
  307. package/packages/epoxy/src/http_client.rs +59 -26
  308. package/packages/epoxy/src/http_routes.rs +73 -10
  309. package/packages/epoxy/src/keys/keys.rs +260 -11
  310. package/packages/epoxy/src/keys/mod.rs +11 -1
  311. package/packages/epoxy/src/keys/replica.rs +5 -260
  312. package/packages/epoxy/src/lib.rs +2 -1
  313. package/packages/epoxy/src/metrics.rs +118 -0
  314. package/packages/epoxy/src/ops/kv/get_local.rs +15 -24
  315. package/packages/epoxy/src/ops/kv/get_optimistic.rs +102 -64
  316. package/packages/epoxy/src/ops/kv/mod.rs +1 -0
  317. package/packages/epoxy/src/ops/kv/purge_local.rs +18 -9
  318. package/packages/epoxy/src/ops/kv/read_value.rs +92 -0
  319. package/packages/epoxy/src/ops/mod.rs +0 -1
  320. package/packages/epoxy/src/ops/propose.rs +1079 -194
  321. package/packages/epoxy/src/replica/ballot.rs +162 -102
  322. package/packages/epoxy/src/replica/changelog.rs +147 -0
  323. package/packages/epoxy/src/replica/commit_kv.rs +69 -66
  324. package/packages/epoxy/src/replica/message_request.rs +33 -48
  325. package/packages/epoxy/src/replica/messages/accept.rs +82 -41
  326. package/packages/epoxy/src/replica/messages/commit.rs +21 -33
  327. package/packages/epoxy/src/replica/messages/mod.rs +0 -8
  328. package/packages/epoxy/src/replica/messages/prepare.rs +68 -69
  329. package/packages/epoxy/src/replica/mod.rs +1 -6
  330. package/packages/epoxy/src/replica/update_config.rs +3 -1
  331. package/packages/epoxy/src/types.rs +30 -54
  332. package/packages/epoxy/src/utils.rs +149 -16
  333. package/packages/epoxy/src/workflows/backfill.rs +233 -0
  334. package/packages/epoxy/src/workflows/coordinator/mod.rs +33 -7
  335. package/packages/epoxy/src/workflows/coordinator/reconfigure.rs +44 -0
  336. package/packages/epoxy/src/workflows/coordinator/replica_status_change.rs +4 -3
  337. package/packages/epoxy/src/workflows/mod.rs +1 -1
  338. package/packages/epoxy/src/workflows/replica/mod.rs +4 -6
  339. package/packages/epoxy/src/workflows/replica/setup.rs +130 -771
  340. package/packages/epoxy/tests/backfill.rs +65 -0
  341. package/packages/epoxy/tests/backfill_snapshot.rs +233 -0
  342. package/packages/epoxy/tests/common/mod.rs +77 -21
  343. package/packages/epoxy/tests/common/utils.rs +366 -10
  344. package/packages/epoxy/tests/consensus_regressions.rs +285 -0
  345. package/packages/epoxy/tests/kv.rs +128 -167
  346. package/packages/epoxy/tests/kv_get_optimistic.rs +257 -157
  347. package/packages/epoxy/tests/migration.rs +75 -0
  348. package/packages/epoxy/tests/proposal.rs +133 -28
  349. package/packages/epoxy/tests/reconfigure.rs +92 -474
  350. package/packages/error/tests/basic.rs +8 -8
  351. package/packages/gasoline/Cargo.toml +1 -0
  352. package/packages/gasoline/src/builder/common/message.rs +19 -47
  353. package/packages/gasoline/src/builder/common/signal.rs +37 -21
  354. package/packages/gasoline/src/builder/common/workflow.rs +19 -15
  355. package/packages/gasoline/src/builder/workflow/lupe.rs +295 -0
  356. package/packages/gasoline/src/builder/workflow/message.rs +24 -47
  357. package/packages/gasoline/src/builder/workflow/mod.rs +1 -0
  358. package/packages/gasoline/src/builder/workflow/signal.rs +68 -22
  359. package/packages/gasoline/src/builder/workflow/sub_workflow.rs +6 -15
  360. package/packages/gasoline/src/ctx/activity.rs +46 -6
  361. package/packages/gasoline/src/ctx/common.rs +26 -23
  362. package/packages/gasoline/src/ctx/listen.rs +33 -50
  363. package/packages/gasoline/src/ctx/message.rs +76 -64
  364. package/packages/gasoline/src/ctx/operation.rs +15 -5
  365. package/packages/gasoline/src/ctx/standalone.rs +32 -4
  366. package/packages/gasoline/src/ctx/test.rs +31 -6
  367. package/packages/gasoline/src/ctx/versioned_workflow.rs +33 -7
  368. package/packages/gasoline/src/ctx/workflow.rs +194 -384
  369. package/packages/gasoline/src/db/debug.rs +49 -9
  370. package/packages/gasoline/src/db/kv/debug.rs +905 -15
  371. package/packages/gasoline/src/db/kv/keys/history.rs +434 -9
  372. package/packages/gasoline/src/db/kv/keys/metric.rs +70 -47
  373. package/packages/gasoline/src/db/kv/keys/signal.rs +19 -3
  374. package/packages/gasoline/src/db/kv/keys/workflow.rs +349 -3
  375. package/packages/gasoline/src/db/kv/mod.rs +975 -514
  376. package/packages/gasoline/src/db/kv/system.rs +155 -18
  377. package/packages/gasoline/src/db/mod.rs +29 -7
  378. package/packages/gasoline/src/error.rs +26 -21
  379. package/packages/gasoline/src/executable.rs +3 -1
  380. package/packages/gasoline/src/history/cursor.rs +436 -336
  381. package/packages/gasoline/src/history/event.rs +24 -15
  382. package/packages/gasoline/src/listen.rs +2 -14
  383. package/packages/gasoline/src/message.rs +1 -1
  384. package/packages/gasoline/src/metrics.rs +260 -143
  385. package/packages/gasoline/src/prelude.rs +1 -1
  386. package/packages/gasoline/src/registry.rs +6 -2
  387. package/packages/gasoline/src/signal.rs +34 -31
  388. package/packages/gasoline/src/utils/mod.rs +1 -18
  389. package/packages/gasoline/src/utils/topic.rs +35 -0
  390. package/packages/gasoline/src/worker.rs +71 -14
  391. package/packages/gasoline/src/workflow.rs +13 -0
  392. package/packages/gasoline/tests/workflows/eviction_test.rs +2 -2
  393. package/packages/gasoline-macros/src/lib.rs +74 -12
  394. package/packages/gasoline-runtime/Cargo.toml +18 -0
  395. package/packages/gasoline-runtime/src/lib.rs +12 -0
  396. package/packages/gasoline-runtime/src/workflows/mod.rs +1 -0
  397. package/packages/gasoline-runtime/src/workflows/pruner.rs +55 -0
  398. package/packages/guard/Cargo.toml +16 -8
  399. package/packages/guard/src/cache/mod.rs +63 -43
  400. package/packages/guard/src/cache/pegboard_gateway.rs +144 -0
  401. package/packages/guard/src/errors.rs +105 -0
  402. package/packages/guard/src/lib.rs +5 -15
  403. package/packages/guard/src/metrics.rs +12 -0
  404. package/packages/guard/src/routing/actor_path.rs +409 -0
  405. package/packages/guard/src/routing/api_public.rs +6 -14
  406. package/packages/guard/src/routing/envoy.rs +98 -0
  407. package/packages/guard/src/routing/mod.rs +152 -206
  408. package/packages/guard/src/routing/pegboard_gateway/mod.rs +572 -0
  409. package/packages/guard/src/routing/pegboard_gateway/resolve_actor_query.rs +236 -0
  410. package/packages/guard/src/routing/runner.rs +24 -54
  411. package/packages/guard/src/routing/ws_health.rs +61 -0
  412. package/packages/guard/src/shared_state.rs +11 -2
  413. package/packages/guard/tests/parse_actor_path.rs +418 -165
  414. package/packages/guard-core/Cargo.toml +3 -10
  415. package/packages/guard-core/src/custom_serve.rs +4 -10
  416. package/packages/guard-core/src/errors.rs +20 -4
  417. package/packages/guard-core/src/lib.rs +6 -4
  418. package/packages/guard-core/src/metrics.rs +66 -53
  419. package/packages/guard-core/src/proxy_service.rs +618 -1520
  420. package/packages/guard-core/src/request_context.rs +149 -169
  421. package/packages/guard-core/src/response_body.rs +65 -0
  422. package/packages/guard-core/src/route.rs +76 -0
  423. package/packages/guard-core/src/server.rs +60 -26
  424. package/packages/guard-core/src/task_group.rs +4 -0
  425. package/packages/guard-core/src/utils.rs +296 -0
  426. package/packages/guard-core/src/websocket_handle.rs +3 -3
  427. package/packages/guard-core/tests/common/mod.rs +0 -1
  428. package/packages/guard-core/tests/custom_serve.rs +4 -6
  429. package/packages/guard-core/tests/simple_websocket.rs +19 -19
  430. package/packages/guard-core/tests/streaming_response.rs +4 -9
  431. package/packages/metrics/Cargo.toml +3 -2
  432. package/packages/metrics/src/buckets.rs +5 -11
  433. package/packages/metrics/src/lib.rs +6 -3
  434. package/packages/metrics/src/providers.rs +2 -42
  435. package/packages/metrics/src/registry.rs +7 -0
  436. package/packages/metrics/src/server.rs +57 -0
  437. package/packages/namespace/Cargo.toml +0 -3
  438. package/packages/namespace/src/keys/metric.rs +301 -0
  439. package/packages/namespace/src/keys/mod.rs +1 -1
  440. package/packages/namespace/src/ops/get_global.rs +7 -4
  441. package/packages/namespace/src/ops/get_local.rs +32 -16
  442. package/packages/namespace/src/ops/mod.rs +0 -1
  443. package/packages/namespace/src/ops/resolve_for_name_global.rs +7 -4
  444. package/packages/namespace/src/ops/resolve_for_name_local.rs +39 -19
  445. package/packages/namespace/src/workflows/namespace.rs +3 -3
  446. package/packages/pegboard/Cargo.toml +22 -0
  447. package/packages/pegboard/src/actor_kv/entry.rs +47 -0
  448. package/packages/pegboard/src/actor_kv/metrics.rs +19 -0
  449. package/packages/pegboard/src/actor_kv/mod.rs +530 -0
  450. package/packages/pegboard/src/actor_kv/preload.rs +363 -0
  451. package/packages/{actor-kv/src → pegboard/src/actor_kv}/utils.rs +36 -35
  452. package/packages/pegboard/src/errors.rs +39 -5
  453. package/packages/pegboard/src/keys/actor.rs +285 -2
  454. package/packages/{actor-kv/src/entry.rs → pegboard/src/keys/actor_kv.rs} +73 -39
  455. package/packages/pegboard/src/keys/backfill.rs +49 -0
  456. package/packages/pegboard/src/keys/envoy.rs +1070 -0
  457. package/packages/pegboard/src/keys/epoxy/ns.rs +1 -1
  458. package/packages/pegboard/src/keys/mod.rs +4 -6
  459. package/packages/pegboard/src/keys/ns.rs +493 -14
  460. package/packages/pegboard/src/keys/runner.rs +281 -0
  461. package/packages/{namespace → pegboard}/src/keys/runner_config.rs +53 -0
  462. package/packages/pegboard/src/lib.rs +15 -2
  463. package/packages/pegboard/src/metrics.rs +57 -16
  464. package/packages/pegboard/src/ops/actor/create.rs +123 -53
  465. package/packages/pegboard/src/ops/actor/get.rs +14 -45
  466. package/packages/pegboard/src/ops/actor/get_for_gateway.rs +16 -0
  467. package/packages/pegboard/src/ops/actor/get_for_key.rs +3 -0
  468. package/packages/pegboard/src/ops/actor/get_for_kv.rs +43 -0
  469. package/packages/pegboard/src/ops/actor/get_for_runner.rs +99 -0
  470. package/packages/pegboard/src/ops/actor/get_reservation_for_key.rs +1 -0
  471. package/packages/pegboard/src/ops/actor/list_for_ns.rs +10 -38
  472. package/packages/pegboard/src/ops/actor/list_names.rs +3 -3
  473. package/packages/pegboard/src/ops/actor/mod.rs +3 -1
  474. package/packages/pegboard/src/ops/actor/util.rs +263 -0
  475. package/packages/pegboard/src/ops/envoy/drain.rs +101 -0
  476. package/packages/pegboard/src/ops/envoy/evict_actors.rs +54 -0
  477. package/packages/pegboard/src/ops/envoy/expire.rs +92 -0
  478. package/packages/pegboard/src/ops/envoy/get.rs +135 -0
  479. package/packages/pegboard/src/ops/envoy/list.rs +131 -0
  480. package/packages/pegboard/src/ops/envoy/mod.rs +6 -0
  481. package/packages/pegboard/src/ops/envoy/update_ping.rs +92 -0
  482. package/packages/pegboard/src/ops/mod.rs +3 -0
  483. package/packages/pegboard/src/ops/runner/drain.rs +110 -0
  484. package/packages/pegboard/src/ops/runner/list_names.rs +3 -3
  485. package/packages/pegboard/src/ops/runner/list_runner_config_enabled_dcs.rs +199 -0
  486. package/packages/pegboard/src/ops/runner/list_runner_config_epoxy_replica_ids.rs +51 -0
  487. package/packages/pegboard/src/ops/runner/mod.rs +3 -1
  488. package/packages/pegboard/src/ops/runner/update_alloc_idx.rs +17 -5
  489. package/packages/{namespace → pegboard}/src/ops/runner_config/delete.rs +18 -9
  490. package/packages/pegboard/src/ops/runner_config/ensure_normal_if_missing.rs +62 -0
  491. package/packages/{namespace → pegboard}/src/ops/runner_config/get.rs +15 -5
  492. package/packages/pegboard/src/ops/runner_config/get_error.rs +146 -0
  493. package/packages/{namespace → pegboard}/src/ops/runner_config/list.rs +13 -12
  494. package/packages/pegboard/src/ops/runner_config/mod.rs +7 -0
  495. package/packages/pegboard/src/ops/runner_config/refresh_metadata.rs +124 -0
  496. package/packages/pegboard/src/ops/runner_config/upsert.rs +206 -0
  497. package/packages/pegboard/src/ops/serverless_metadata/fetch.rs +223 -0
  498. package/packages/pegboard/src/ops/serverless_metadata/mod.rs +1 -0
  499. package/packages/pegboard/src/pubsub_subjects.rs +52 -0
  500. package/packages/pegboard/src/utils.rs +36 -2
  501. package/packages/pegboard/src/workflows/actor/destroy.rs +135 -99
  502. package/packages/pegboard/src/workflows/actor/keys.rs +59 -5
  503. package/packages/pegboard/src/workflows/actor/metrics.rs +345 -0
  504. package/packages/pegboard/src/workflows/actor/mod.rs +848 -204
  505. package/packages/pegboard/src/workflows/actor/runtime.rs +785 -212
  506. package/packages/pegboard/src/workflows/actor/setup.rs +61 -0
  507. package/packages/pegboard/src/workflows/actor2/keys.rs +337 -0
  508. package/packages/pegboard/src/workflows/actor2/metrics.rs +334 -0
  509. package/packages/pegboard/src/workflows/actor2/mod.rs +1251 -0
  510. package/packages/pegboard/src/workflows/actor2/runtime.rs +1005 -0
  511. package/packages/pegboard/src/workflows/actor_runner_name_selector_backfill.rs +266 -0
  512. package/packages/pegboard/src/workflows/metrics_aggregator.rs +282 -0
  513. package/packages/pegboard/src/workflows/mod.rs +8 -0
  514. package/packages/pegboard/src/workflows/runner.rs +62 -56
  515. package/packages/pegboard/src/workflows/runner2.rs +978 -0
  516. package/packages/pegboard/src/workflows/runner_pool.rs +298 -0
  517. package/packages/pegboard/src/workflows/runner_pool_error_tracker.rs +173 -0
  518. package/packages/pegboard/src/workflows/runner_pool_metadata_poller.rs +237 -0
  519. package/packages/pegboard/src/workflows/serverless/backfill.rs +120 -0
  520. package/packages/pegboard/src/workflows/serverless/conn.rs +702 -0
  521. package/packages/pegboard/src/workflows/serverless/mod.rs +3 -0
  522. package/packages/pegboard/src/workflows/serverless/receiver.rs +87 -0
  523. package/packages/pegboard/tests/actor_v1_pre_migration.rs +77 -0
  524. package/packages/{actor-kv/tests/list_edge_cases.rs → pegboard/tests/kv_list_edge_cases.rs} +74 -59
  525. package/packages/{actor-kv → pegboard}/tests/kv_operations.rs +77 -48
  526. package/packages/pegboard-envoy/Cargo.toml +43 -0
  527. package/packages/pegboard-envoy/src/actor_event_demuxer.rs +165 -0
  528. package/packages/pegboard-envoy/src/conn.rs +417 -0
  529. package/packages/pegboard-envoy/src/errors.rs +38 -0
  530. package/packages/pegboard-envoy/src/lib.rs +250 -0
  531. package/packages/pegboard-envoy/src/metrics.rs +44 -0
  532. package/packages/pegboard-envoy/src/ping_task.rs +61 -0
  533. package/packages/pegboard-envoy/src/tunnel_to_ws_task.rs +183 -0
  534. package/packages/pegboard-envoy/src/utils.rs +68 -0
  535. package/packages/pegboard-envoy/src/ws_to_tunnel_task.rs +536 -0
  536. package/packages/pegboard-envoy/tests/support/ws_to_tunnel_task.rs +82 -0
  537. package/packages/pegboard-gateway/Cargo.toml +2 -0
  538. package/packages/pegboard-gateway/src/keepalive_task.rs +1 -1
  539. package/packages/pegboard-gateway/src/lib.rs +506 -128
  540. package/packages/pegboard-gateway/src/metrics.rs +7 -11
  541. package/packages/pegboard-gateway/src/metrics_task.rs +80 -0
  542. package/packages/pegboard-gateway/src/ping_task.rs +9 -2
  543. package/packages/pegboard-gateway/src/shared_state.rs +110 -74
  544. package/packages/pegboard-gateway/src/tunnel_to_ws_task.rs +21 -7
  545. package/packages/pegboard-gateway/src/ws_to_tunnel_task.rs +12 -6
  546. package/packages/pegboard-gateway2/Cargo.toml +37 -0
  547. package/packages/pegboard-gateway2/src/keepalive_task.rs +61 -0
  548. package/packages/pegboard-gateway2/src/lib.rs +1044 -0
  549. package/packages/pegboard-gateway2/src/metrics.rs +10 -0
  550. package/packages/pegboard-gateway2/src/metrics_task.rs +80 -0
  551. package/packages/pegboard-gateway2/src/ping_task.rs +30 -0
  552. package/packages/pegboard-gateway2/src/shared_state.rs +601 -0
  553. package/packages/pegboard-gateway2/src/tunnel_to_ws_task.rs +99 -0
  554. package/packages/pegboard-gateway2/src/ws_to_tunnel_task.rs +71 -0
  555. package/packages/{pegboard-serverless → pegboard-outbound}/Cargo.toml +9 -9
  556. package/packages/pegboard-outbound/src/lib.rs +487 -0
  557. package/packages/pegboard-outbound/src/metrics.rs +17 -0
  558. package/packages/pegboard-runner/Cargo.toml +11 -5
  559. package/packages/pegboard-runner/src/actor_event_demuxer.rs +163 -0
  560. package/packages/pegboard-runner/src/conn.rs +358 -122
  561. package/packages/pegboard-runner/src/errors.rs +5 -0
  562. package/packages/pegboard-runner/src/lib.rs +62 -36
  563. package/packages/pegboard-runner/src/metrics.rs +44 -0
  564. package/packages/pegboard-runner/src/ping_task.rs +60 -13
  565. package/packages/pegboard-runner/src/tunnel_to_ws_task.rs +249 -110
  566. package/packages/pegboard-runner/src/ws_to_tunnel_task.rs +738 -113
  567. package/packages/pegboard-runner/tests/support/ws_to_tunnel_task.rs +150 -0
  568. package/packages/pools/Cargo.toml +1 -2
  569. package/packages/pools/src/db/clickhouse.rs +7 -6
  570. package/packages/pools/src/db/udb.rs +16 -3
  571. package/packages/pools/src/db/ups.rs +27 -5
  572. package/packages/pools/src/error.rs +0 -3
  573. package/packages/pools/src/lib.rs +0 -2
  574. package/packages/pools/src/metrics.rs +33 -28
  575. package/packages/pools/src/pools.rs +15 -39
  576. package/packages/pools/src/prelude.rs +1 -1
  577. package/packages/postgres-util/Cargo.toml +13 -0
  578. package/packages/postgres-util/src/lib.rs +84 -0
  579. package/packages/runner-protocol/build.rs +157 -0
  580. package/packages/runner-protocol/src/lib.rs +16 -0
  581. package/packages/runner-protocol/src/util.rs +14 -0
  582. package/packages/runner-protocol/src/versioned.rs +4345 -0
  583. package/packages/runtime/src/lib.rs +46 -46
  584. package/packages/runtime/src/metrics.rs +39 -30
  585. package/packages/runtime/src/term_signal.rs +25 -12
  586. package/packages/runtime/src/traces.rs +5 -8
  587. package/packages/service-manager/src/lib.rs +66 -15
  588. package/packages/test-deps/src/datacenter.rs +22 -8
  589. package/packages/test-deps/src/lib.rs +47 -25
  590. package/packages/test-deps-docker/src/database.rs +45 -36
  591. package/packages/test-snapshot-gen/Cargo.toml +39 -0
  592. package/packages/test-snapshot-gen/snapshots/.gitkeep +0 -0
  593. package/packages/test-snapshot-gen/snapshots/epoxy-v1/metadata.json +3 -0
  594. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/000008.log +0 -0
  595. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/000009.sst +3 -0
  596. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/CURRENT +3 -0
  597. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/MANIFEST-000005 +3 -0
  598. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-1/OPTIONS-000007 +3 -0
  599. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/000008.log +0 -0
  600. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/000009.sst +3 -0
  601. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/CURRENT +3 -0
  602. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/MANIFEST-000005 +3 -0
  603. package/packages/test-snapshot-gen/snapshots/epoxy-v1/replica-2/OPTIONS-000007 +3 -0
  604. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/metadata.json +3 -0
  605. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/000008.log +0 -0
  606. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/000009.sst +3 -0
  607. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/CURRENT +3 -0
  608. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/MANIFEST-000005 +3 -0
  609. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-1/OPTIONS-000007 +3 -0
  610. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/000008.log +0 -0
  611. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/000009.sst +3 -0
  612. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/CURRENT +3 -0
  613. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/MANIFEST-000005 +3 -0
  614. package/packages/test-snapshot-gen/snapshots/pb-actor-v1-pre-migration/replica-2/OPTIONS-000007 +3 -0
  615. package/packages/test-snapshot-gen/src/lib.rs +328 -0
  616. package/packages/test-snapshot-gen/src/main.rs +145 -0
  617. package/packages/test-snapshot-gen/src/scenarios/epoxy_keys.rs +60 -0
  618. package/packages/test-snapshot-gen/src/scenarios/mod.rs +27 -0
  619. package/packages/test-snapshot-gen/src/scenarios/pb_actor_v1_pre_migration.rs +56 -0
  620. package/packages/test-snapshot-gen/src/test_cluster.rs +234 -0
  621. package/packages/tracing-reconfigure/src/lib.rs +1 -1
  622. package/packages/tracing-utils/src/lib.rs +12 -20
  623. package/packages/types/src/actor/error.rs +59 -0
  624. package/packages/types/src/actor/mod.rs +2 -0
  625. package/packages/types/src/actors.rs +5 -0
  626. package/packages/types/src/envoys.rs +21 -0
  627. package/packages/types/src/keys/backfill.rs +5 -0
  628. package/packages/types/src/keys/mod.rs +1 -0
  629. package/packages/types/src/lib.rs +2 -1
  630. package/packages/types/src/runner_configs.rs +43 -14
  631. package/packages/universaldb/Cargo.toml +4 -0
  632. package/packages/universaldb/src/database.rs +50 -5
  633. package/packages/universaldb/src/driver/mod.rs +12 -2
  634. package/packages/universaldb/src/driver/postgres/database.rs +88 -27
  635. package/packages/universaldb/src/driver/postgres/mod.rs +1 -1
  636. package/packages/universaldb/src/driver/postgres/transaction.rs +4 -7
  637. package/packages/universaldb/src/driver/postgres/transaction_task.rs +30 -52
  638. package/packages/universaldb/src/driver/rocksdb/database.rs +13 -7
  639. package/packages/universaldb/src/driver/rocksdb/transaction_conflict_tracker.rs +5 -5
  640. package/packages/universaldb/src/driver/rocksdb/transaction_task.rs +2 -1
  641. package/packages/universaldb/src/metrics.rs +39 -23
  642. package/packages/universaldb/src/prelude.rs +1 -1
  643. package/packages/universaldb/src/transaction.rs +9 -2
  644. package/packages/universaldb/src/utils/cherry_pick.rs +46 -46
  645. package/packages/universaldb/src/utils/keys.rs +21 -2
  646. package/packages/universaldb/src/utils/mod.rs +8 -0
  647. package/packages/universaldb/src/utils/subspace.rs +9 -4
  648. package/packages/universaldb/tests/integration.rs +5 -3
  649. package/packages/universaldb/tests/integration_gas.rs +5 -3
  650. package/packages/universaldb/tests/rocksdb.rs +152 -19
  651. package/packages/universalpubsub/Cargo.toml +8 -2
  652. package/packages/universalpubsub/benches/simple.rs +28 -8
  653. package/packages/universalpubsub/src/chunking.rs +27 -5
  654. package/packages/universalpubsub/src/driver/memory/mod.rs +131 -20
  655. package/packages/universalpubsub/src/driver/mod.rs +5 -0
  656. package/packages/universalpubsub/src/driver/nats/mod.rs +8 -0
  657. package/packages/universalpubsub/src/driver/postgres/mod.rs +505 -96
  658. package/packages/universalpubsub/src/lib.rs +3 -0
  659. package/packages/universalpubsub/src/metrics.rs +60 -0
  660. package/packages/universalpubsub/src/pubsub.rs +227 -87
  661. package/packages/universalpubsub/src/subject.rs +32 -0
  662. package/packages/universalpubsub/tests/chunking.rs +298 -0
  663. package/packages/universalpubsub/tests/integration.rs +148 -7
  664. package/packages/universalpubsub/tests/reconnect.rs +8 -6
  665. package/packages/util/Cargo.toml +1 -3
  666. package/packages/util/build.rs +6 -0
  667. package/packages/util/src/lib.rs +7 -2
  668. package/packages/util/src/metric.rs +1 -0
  669. package/packages/util/src/serde.rs +1 -516
  670. package/packages/{internal → util-serde}/Cargo.toml +4 -5
  671. package/packages/util-serde/src/lib.rs +517 -0
  672. package/packages/workflow-worker/Cargo.toml +4 -4
  673. package/packages/workflow-worker/src/lib.rs +3 -2
  674. package/sdks/go/api-full/client/client.go +17 -4
  675. package/sdks/go/api-full/metadata/client.go +50 -0
  676. package/sdks/go/api-full/namespaces/client.go +3 -0
  677. package/sdks/go/api-full/namespaces.go +6 -4
  678. package/sdks/go/api-full/runners/client.go +3 -0
  679. package/sdks/go/api-full/runners.go +8 -6
  680. package/sdks/go/api-full/types.go +107 -23
  681. package/sdks/rust/api-full/rust/.openapi-generator/FILES +6 -0
  682. package/sdks/rust/api-full/rust/Cargo.toml +1 -1
  683. package/sdks/rust/api-full/rust/README.md +5 -2
  684. package/sdks/rust/api-full/rust/docs/Actor.md +1 -0
  685. package/sdks/rust/api-full/rust/docs/ActorsDeleteApi.md +1 -1
  686. package/sdks/rust/api-full/rust/docs/ActorsKvGetApi.md +2 -1
  687. package/sdks/rust/api-full/rust/docs/ActorsListApi.md +3 -2
  688. package/sdks/rust/api-full/rust/docs/MetadataApi.md +34 -0
  689. package/sdks/rust/api-full/rust/docs/MetadataGetResponse.md +18 -0
  690. package/sdks/rust/api-full/rust/docs/NamespacesApi.md +3 -2
  691. package/sdks/rust/api-full/rust/docs/RunnerConfig.md +1 -0
  692. package/sdks/rust/api-full/rust/docs/RunnerConfigKindOneOf1Serverless.md +1 -0
  693. package/sdks/rust/api-full/rust/docs/RunnerConfigResponse.md +15 -0
  694. package/sdks/rust/api-full/rust/docs/RunnerConfigsListApi.md +3 -2
  695. package/sdks/rust/api-full/rust/docs/RunnerConfigsListResponseRunnerConfigsValue.md +1 -1
  696. package/sdks/rust/api-full/rust/docs/RunnersApi.md +3 -2
  697. package/sdks/rust/api-full/rust/src/apis/actors_create_api.rs +1 -1
  698. package/sdks/rust/api-full/rust/src/apis/actors_delete_api.rs +3 -5
  699. package/sdks/rust/api-full/rust/src/apis/actors_get_or_create_api.rs +1 -1
  700. package/sdks/rust/api-full/rust/src/apis/actors_kv_get_api.rs +4 -2
  701. package/sdks/rust/api-full/rust/src/apis/actors_list_api.rs +9 -2
  702. package/sdks/rust/api-full/rust/src/apis/actors_list_names_api.rs +1 -1
  703. package/sdks/rust/api-full/rust/src/apis/configuration.rs +2 -2
  704. package/sdks/rust/api-full/rust/src/apis/datacenters_api.rs +1 -1
  705. package/sdks/rust/api-full/rust/src/apis/health_api.rs +1 -1
  706. package/sdks/rust/api-full/rust/src/apis/metadata_api.rs +62 -0
  707. package/sdks/rust/api-full/rust/src/apis/mod.rs +1 -0
  708. package/sdks/rust/api-full/rust/src/apis/namespaces_api.rs +9 -2
  709. package/sdks/rust/api-full/rust/src/apis/runner_configs_delete_api.rs +1 -1
  710. package/sdks/rust/api-full/rust/src/apis/runner_configs_list_api.rs +9 -2
  711. package/sdks/rust/api-full/rust/src/apis/runner_configs_refresh_metadata_api.rs +1 -1
  712. package/sdks/rust/api-full/rust/src/apis/runner_configs_serverless_health_check_api.rs +1 -1
  713. package/sdks/rust/api-full/rust/src/apis/runner_configs_upsert_api.rs +1 -1
  714. package/sdks/rust/api-full/rust/src/apis/runners_api.rs +9 -2
  715. package/sdks/rust/api-full/rust/src/models/actor.rs +5 -1
  716. package/sdks/rust/api-full/rust/src/models/actor_name.rs +1 -1
  717. package/sdks/rust/api-full/rust/src/models/actors_create_request.rs +1 -1
  718. package/sdks/rust/api-full/rust/src/models/actors_create_response.rs +1 -1
  719. package/sdks/rust/api-full/rust/src/models/actors_get_or_create_request.rs +1 -1
  720. package/sdks/rust/api-full/rust/src/models/actors_get_or_create_response.rs +1 -1
  721. package/sdks/rust/api-full/rust/src/models/actors_kv_get_response.rs +1 -1
  722. package/sdks/rust/api-full/rust/src/models/actors_list_names_response.rs +1 -1
  723. package/sdks/rust/api-full/rust/src/models/actors_list_response.rs +1 -1
  724. package/sdks/rust/api-full/rust/src/models/crash_policy.rs +1 -1
  725. package/sdks/rust/api-full/rust/src/models/datacenter.rs +1 -1
  726. package/sdks/rust/api-full/rust/src/models/datacenter_health.rs +1 -1
  727. package/sdks/rust/api-full/rust/src/models/datacenters_list_response.rs +1 -1
  728. package/sdks/rust/api-full/rust/src/models/health_fanout_response.rs +1 -1
  729. package/sdks/rust/api-full/rust/src/models/health_response.rs +1 -1
  730. package/sdks/rust/api-full/rust/src/models/health_status.rs +1 -1
  731. package/sdks/rust/api-full/rust/src/models/metadata_get_response.rs +48 -0
  732. package/sdks/rust/api-full/rust/src/models/mod.rs +4 -0
  733. package/sdks/rust/api-full/rust/src/models/namespace.rs +1 -1
  734. package/sdks/rust/api-full/rust/src/models/namespace_list_response.rs +1 -1
  735. package/sdks/rust/api-full/rust/src/models/namespaces_create_request.rs +1 -1
  736. package/sdks/rust/api-full/rust/src/models/namespaces_create_response.rs +1 -1
  737. package/sdks/rust/api-full/rust/src/models/pagination.rs +1 -1
  738. package/sdks/rust/api-full/rust/src/models/runner.rs +1 -1
  739. package/sdks/rust/api-full/rust/src/models/runner_config.rs +4 -1
  740. package/sdks/rust/api-full/rust/src/models/runner_config_kind.rs +1 -1
  741. package/sdks/rust/api-full/rust/src/models/runner_config_kind_one_of.rs +1 -1
  742. package/sdks/rust/api-full/rust/src/models/runner_config_kind_one_of_1.rs +1 -1
  743. package/sdks/rust/api-full/rust/src/models/runner_config_kind_one_of_1_serverless.rs +5 -1
  744. package/sdks/rust/api-full/rust/src/models/runner_config_response.rs +39 -0
  745. package/sdks/rust/api-full/rust/src/models/runner_config_variant.rs +1 -1
  746. package/sdks/rust/api-full/rust/src/models/runner_configs_list_response.rs +1 -1
  747. package/sdks/rust/api-full/rust/src/models/runner_configs_list_response_runner_configs_value.rs +3 -3
  748. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_request.rs +1 -1
  749. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response.rs +1 -1
  750. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of.rs +1 -1
  751. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of_1.rs +1 -1
  752. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of_1_failure.rs +1 -1
  753. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_health_check_response_one_of_success.rs +1 -1
  754. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error.rs +1 -1
  755. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of.rs +1 -1
  756. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_1.rs +1 -1
  757. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_2.rs +1 -1
  758. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_3.rs +1 -1
  759. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_3_non_success_status.rs +1 -1
  760. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_4.rs +1 -1
  761. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_4_invalid_response_json.rs +1 -1
  762. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_5.rs +1 -1
  763. package/sdks/rust/api-full/rust/src/models/runner_configs_serverless_metadata_error_one_of_5_invalid_response_schema.rs +1 -1
  764. package/sdks/rust/api-full/rust/src/models/runner_configs_upsert_request_body.rs +1 -1
  765. package/sdks/rust/api-full/rust/src/models/runner_configs_upsert_response.rs +1 -1
  766. package/sdks/rust/api-full/rust/src/models/runners_list_names_response.rs +1 -1
  767. package/sdks/rust/api-full/rust/src/models/runners_list_response.rs +1 -1
  768. package/sdks/rust/api-full/src/apis/actors_api.rs +8 -4
  769. package/sdks/rust/api-full/src/apis/ns_api.rs +8 -4
  770. package/sdks/rust/data/src/converted.rs +7 -4
  771. package/sdks/rust/data/src/lib.rs +2 -2
  772. package/sdks/rust/data/src/versioned/mod.rs +47 -4
  773. package/sdks/rust/data/src/versioned/namespace_runner_config.rs +256 -6
  774. package/sdks/rust/envoy-client/Cargo.toml +25 -0
  775. package/sdks/rust/envoy-client/src/actor.rs +992 -0
  776. package/sdks/rust/envoy-client/src/commands.rs +88 -0
  777. package/sdks/rust/envoy-client/src/config.rs +159 -0
  778. package/sdks/rust/envoy-client/src/connection.rs +288 -0
  779. package/sdks/rust/envoy-client/src/context.rs +24 -0
  780. package/sdks/rust/envoy-client/src/envoy.rs +432 -0
  781. package/sdks/rust/envoy-client/src/events.rs +62 -0
  782. package/sdks/rust/envoy-client/src/handle.rs +355 -0
  783. package/sdks/rust/envoy-client/src/kv.rs +132 -0
  784. package/sdks/rust/envoy-client/src/latency_channel.rs +27 -0
  785. package/sdks/rust/envoy-client/src/lib.rs +15 -0
  786. package/sdks/rust/envoy-client/src/stringify.rs +322 -0
  787. package/sdks/rust/envoy-client/src/tunnel.rs +265 -0
  788. package/sdks/rust/envoy-client/src/utils.rs +172 -0
  789. package/sdks/rust/envoy-protocol/Cargo.toml +22 -0
  790. package/sdks/rust/envoy-protocol/build.rs +200 -0
  791. package/sdks/rust/envoy-protocol/src/generated.rs +1 -0
  792. package/sdks/rust/envoy-protocol/src/lib.rs +8 -0
  793. package/sdks/rust/envoy-protocol/src/versioned.rs +208 -0
  794. package/sdks/rust/epoxy-protocol/Cargo.toml +0 -2
  795. package/sdks/rust/epoxy-protocol/build.rs +7 -0
  796. package/sdks/rust/epoxy-protocol/src/lib.rs +2 -5
  797. package/sdks/rust/epoxy-protocol/src/protocol.rs +128 -0
  798. package/sdks/rust/test-envoy/Cargo.toml +23 -0
  799. package/sdks/rust/test-envoy/Dockerfile +22 -0
  800. package/sdks/rust/test-envoy/src/behaviors.rs +141 -0
  801. package/sdks/rust/test-envoy/src/lib.rs +11 -0
  802. package/sdks/rust/test-envoy/src/main.rs +4 -0
  803. package/sdks/rust/test-envoy/src/server.rs +269 -0
  804. package/sdks/schemas/README.md +1 -2
  805. package/sdks/schemas/data/namespace.runner_config.v3.bare +24 -0
  806. package/sdks/schemas/data/namespace.runner_config.v4.bare +25 -0
  807. package/sdks/schemas/data/namespace.runner_config.v5.bare +26 -0
  808. package/sdks/schemas/data/pegboard.namespace.runner_alloc_idx.v2.bare +8 -0
  809. package/sdks/schemas/envoy-protocol/v1.bare +459 -0
  810. package/sdks/schemas/epoxy-protocol/v2.bare +220 -0
  811. package/sdks/schemas/runner-protocol/v4.bare +438 -0
  812. package/sdks/schemas/runner-protocol/v5.bare +430 -0
  813. package/sdks/schemas/runner-protocol/v6.bare +432 -0
  814. package/sdks/schemas/runner-protocol/v7.bare +438 -0
  815. package/sdks/typescript/api-full/.turbo/turbo-build.log +28 -27
  816. package/sdks/typescript/api-full/build.js +7 -1
  817. package/sdks/typescript/api-full/package.json +66 -57
  818. package/sdks/typescript/api-full/rivetkit-engine-api-full-25.5.3.tgz +0 -0
  819. package/sdks/typescript/api-full/src/Client.ts +41 -10
  820. package/sdks/typescript/api-full/src/api/client/requests/ActorsDeleteRequest.ts +4 -2
  821. package/sdks/typescript/api-full/src/api/client/requests/ActorsKvGetRequest.ts +13 -0
  822. package/sdks/typescript/api-full/src/api/client/requests/ActorsListRequest.ts +6 -0
  823. package/sdks/typescript/api-full/src/api/client/requests/RunnerConfigsListRequest.ts +4 -0
  824. package/sdks/typescript/api-full/src/api/client/requests/index.ts +1 -0
  825. package/sdks/typescript/api-full/src/api/resources/index.ts +1 -0
  826. package/sdks/typescript/api-full/src/api/resources/metadata/client/Client.ts +97 -0
  827. package/sdks/typescript/api-full/src/api/resources/metadata/client/index.ts +1 -0
  828. package/sdks/typescript/api-full/src/api/resources/metadata/index.ts +1 -0
  829. package/sdks/typescript/api-full/src/api/resources/namespaces/client/Client.ts +12 -2
  830. package/sdks/typescript/api-full/src/api/resources/namespaces/client/requests/NamespacesListRequest.ts +6 -0
  831. package/sdks/typescript/api-full/src/api/resources/runners/client/Client.ts +12 -2
  832. package/sdks/typescript/api-full/src/api/resources/runners/client/requests/RunnersListRequest.ts +6 -0
  833. package/sdks/typescript/api-full/src/api/types/Actor.ts +2 -0
  834. package/sdks/typescript/api-full/src/api/types/MetadataGetResponse.ts +14 -0
  835. package/sdks/typescript/api-full/src/api/types/RunnerConfig.ts +1 -0
  836. package/sdks/typescript/api-full/src/api/types/RunnerConfigKindServerlessServerless.ts +2 -0
  837. package/sdks/typescript/api-full/src/api/types/RunnerConfigResponse.ts +9 -0
  838. package/sdks/typescript/api-full/src/api/types/RunnerConfigServerless.ts +2 -0
  839. package/sdks/typescript/api-full/src/api/types/RunnerConfigsListResponseRunnerConfigsValue.ts +1 -1
  840. package/sdks/typescript/api-full/src/api/types/index.ts +2 -0
  841. package/sdks/typescript/api-full/src/core/fetcher/stream-wrappers/Node18UniversalStreamWrapper.ts +6 -4
  842. package/sdks/typescript/api-full/src/core/fetcher/stream-wrappers/UndiciStreamWrapper.ts +4 -3
  843. package/sdks/typescript/api-full/src/serialization/types/Actor.ts +2 -0
  844. package/sdks/typescript/api-full/src/serialization/types/MetadataGetResponse.ts +34 -0
  845. package/sdks/typescript/api-full/src/serialization/types/RunnerConfig.ts +5 -0
  846. package/sdks/typescript/api-full/src/serialization/types/RunnerConfigKindServerlessServerless.ts +2 -0
  847. package/sdks/typescript/api-full/src/serialization/types/RunnerConfigResponse.ts +26 -0
  848. package/sdks/typescript/api-full/src/serialization/types/RunnerConfigServerless.ts +2 -0
  849. package/sdks/typescript/api-full/src/serialization/types/RunnerConfigsListResponseRunnerConfigsValue.ts +3 -3
  850. package/sdks/typescript/api-full/src/serialization/types/index.ts +2 -0
  851. package/sdks/typescript/api-full/turbo.json +9 -0
  852. package/sdks/typescript/envoy-protocol/.turbo/turbo-build.log +23 -0
  853. package/sdks/typescript/{runner-protocol → envoy-protocol}/dist/index.cjs +466 -281
  854. package/sdks/typescript/envoy-protocol/dist/index.cjs.map +1 -0
  855. package/sdks/typescript/envoy-protocol/dist/index.d.cts +699 -0
  856. package/sdks/typescript/envoy-protocol/dist/index.d.ts +699 -0
  857. package/sdks/typescript/{runner-protocol → envoy-protocol}/dist/index.js +530 -345
  858. package/sdks/typescript/envoy-protocol/dist/index.js.map +1 -0
  859. package/sdks/typescript/{runner-protocol → envoy-protocol}/node_modules/.bin/tsc +4 -4
  860. package/{tests/load → sdks/typescript/envoy-protocol}/node_modules/.bin/tsserver +4 -4
  861. package/sdks/typescript/envoy-protocol/node_modules/.bin/tsup +21 -0
  862. package/sdks/typescript/envoy-protocol/node_modules/.bin/tsup-node +21 -0
  863. package/sdks/typescript/envoy-protocol/package.json +36 -0
  864. package/sdks/typescript/envoy-protocol/src/index.ts +2331 -0
  865. package/sdks/typescript/envoy-protocol/tsconfig.json +9 -0
  866. package/sdks/typescript/envoy-protocol/tsup.config.ts +4 -0
  867. package/sdks/typescript/runner/package.json +8 -2
  868. package/sdks/typescript/runner/src/actor.ts +38 -0
  869. package/sdks/typescript/runner/src/mod.ts +435 -229
  870. package/sdks/typescript/runner/src/stringify.ts +36 -33
  871. package/sdks/typescript/runner/src/tunnel.ts +52 -56
  872. package/sdks/typescript/runner/src/utils.ts +19 -0
  873. package/sdks/typescript/runner/src/websocket-tunnel-adapter.ts +98 -435
  874. package/sdks/typescript/runner-protocol/package.json +11 -9
  875. package/sdks/typescript/runner-protocol/src/index.ts +224 -156
  876. package/sdks/typescript/runner-protocol/tsconfig.json +1 -9
  877. package/sdks/typescript/test-runner/.turbo/turbo-build.log +5 -5
  878. package/sdks/typescript/test-runner/dist/index.js +53 -44
  879. package/sdks/typescript/test-runner/dist/index.js.map +1 -1
  880. package/sdks/typescript/test-runner/node_modules/.bin/pino +2 -2
  881. package/sdks/typescript/test-runner/node_modules/.bin/tsc +4 -4
  882. package/sdks/typescript/test-runner/node_modules/.bin/tsserver +4 -4
  883. package/sdks/typescript/test-runner/node_modules/.bin/tsup +4 -4
  884. package/sdks/typescript/test-runner/node_modules/.bin/tsup-node +4 -4
  885. package/sdks/typescript/test-runner/node_modules/.bin/tsx +4 -4
  886. package/sdks/typescript/test-runner/node_modules/.bin/vitest +4 -4
  887. package/sdks/typescript/test-runner/package.json +3 -3
  888. package/sdks/typescript/test-runner/src/index.ts +65 -42
  889. package/sdks/typescript/test-runner/src/log.ts +4 -18
  890. package/artifacts/errors/actor.no_runners_available.json +0 -5
  891. package/artifacts/errors/guard.actor_destroyed.json +0 -5
  892. package/artifacts/errors/guard.actor_not_found.json +0 -5
  893. package/contrib-docs/ACTOR_KEY_RESERVATION.md +0 -101
  894. package/contrib-docs/API.md +0 -11
  895. package/contrib-docs/DOCKER.md +0 -5
  896. package/contrib-docs/ERRORS.md +0 -13
  897. package/contrib-docs/GUARD.md +0 -76
  898. package/contrib-docs/PEGBOARD_TUNNEL_RETRIES.md +0 -83
  899. package/contrib-docs/RUNNER_LIFECYCLE.md +0 -172
  900. package/contrib-docs/SDKS.md +0 -9
  901. package/contrib-docs/TEST_DEPENDENCIES.md +0 -43
  902. package/contrib-docs/design-choicse/EMBEDDED_KV.md +0 -80
  903. package/contrib-docs/operate/TRACING_RECONFIGURE.md +0 -78
  904. package/docker/dev/otel-collector-client/config.yaml +0 -39
  905. package/docker/dev-host/otel-collector-client/config.yaml +0 -39
  906. package/docker/dev-multidc/datacenters/dc-a/otel-collector-client/config.yaml +0 -39
  907. package/docker/dev-multidc/datacenters/dc-b/otel-collector-client/config.yaml +0 -39
  908. package/docker/dev-multidc/datacenters/dc-c/otel-collector-client/config.yaml +0 -39
  909. package/docker/dev-multidc-multinode/datacenters/dc-a/otel-collector-client/config.yaml +0 -39
  910. package/docker/dev-multidc-multinode/datacenters/dc-b/otel-collector-client/config.yaml +0 -39
  911. package/docker/dev-multidc-multinode/datacenters/dc-c/otel-collector-client/config.yaml +0 -39
  912. package/docker/dev-multinode/otel-collector-client/config.yaml +0 -39
  913. package/docker/template/src/services/edge/otel-collector-client.ts +0 -64
  914. package/packages/actor-kv/Cargo.toml +0 -31
  915. package/packages/actor-kv/src/key.rs +0 -81
  916. package/packages/actor-kv/src/lib.rs +0 -357
  917. package/packages/cache/src/rate_limit.rs +0 -109
  918. package/packages/cache/tests/integration.rs +0 -582
  919. package/packages/clickhouse-inserter/Cargo.toml +0 -17
  920. package/packages/clickhouse-inserter/src/error.rs +0 -16
  921. package/packages/clickhouse-inserter/src/lib.rs +0 -179
  922. package/packages/clickhouse-user-query/Cargo.toml +0 -16
  923. package/packages/clickhouse-user-query/examples/case_sensitivity_demo.rs +0 -100
  924. package/packages/clickhouse-user-query/examples/group_by_example.rs +0 -53
  925. package/packages/clickhouse-user-query/examples/string_contains_demo.rs +0 -96
  926. package/packages/clickhouse-user-query/src/builder.rs +0 -445
  927. package/packages/clickhouse-user-query/src/error.rs +0 -37
  928. package/packages/clickhouse-user-query/src/lib.rs +0 -61
  929. package/packages/clickhouse-user-query/src/query.rs +0 -143
  930. package/packages/clickhouse-user-query/src/schema.rs +0 -78
  931. package/packages/clickhouse-user-query/tests/builder_tests.rs +0 -619
  932. package/packages/clickhouse-user-query/tests/case_sensitivity_tests.rs +0 -307
  933. package/packages/clickhouse-user-query/tests/integration_tests.rs +0 -540
  934. package/packages/clickhouse-user-query/tests/query_tests.rs +0 -263
  935. package/packages/clickhouse-user-query/tests/schema_tests.rs +0 -44
  936. package/packages/config/src/config/vector.rs +0 -18
  937. package/packages/engine/src/commands/udb_keys.rs +0 -200
  938. package/packages/engine/tests/actors_create.rs +0 -524
  939. package/packages/engine/tests/actors_delete.rs +0 -243
  940. package/packages/engine/tests/actors_general.rs +0 -191
  941. package/packages/engine/tests/actors_get.rs +0 -230
  942. package/packages/engine/tests/actors_get_by_id.rs +0 -170
  943. package/packages/engine/tests/actors_get_or_create.rs +0 -294
  944. package/packages/engine/tests/actors_get_or_create_by_id.rs +0 -147
  945. package/packages/engine/tests/actors_lifecycle.rs +0 -165
  946. package/packages/engine/tests/actors_list.rs +0 -798
  947. package/packages/engine/tests/actors_list_names.rs +0 -353
  948. package/packages/engine/tests/common/ns.rs +0 -36
  949. package/packages/engine/tests/common/runner.rs +0 -134
  950. package/packages/engine/tests/runners_dupe_key.rs +0 -27
  951. package/packages/engine/tests/runners_version.rs +0 -50
  952. package/packages/env/build.rs +0 -8
  953. package/packages/epoxy/spec/KEYS.md +0 -33
  954. package/packages/epoxy/spec/PROPOSAL.md +0 -125
  955. package/packages/epoxy/spec/RECONFIGURE.md +0 -40
  956. package/packages/epoxy/src/ops/explicit_prepare.rs +0 -342
  957. package/packages/epoxy/src/replica/decide_path.rs +0 -51
  958. package/packages/epoxy/src/replica/lead_consensus.rs +0 -65
  959. package/packages/epoxy/src/replica/log.rs +0 -84
  960. package/packages/epoxy/src/replica/messages/accepted.rs +0 -35
  961. package/packages/epoxy/src/replica/messages/committed.rs +0 -41
  962. package/packages/epoxy/src/replica/messages/download_instances.rs +0 -69
  963. package/packages/epoxy/src/replica/messages/pre_accept.rs +0 -69
  964. package/packages/epoxy/src/replica/utils.rs +0 -111
  965. package/packages/epoxy/src/workflows/purger.rs +0 -81
  966. package/packages/guard/src/cache/actor.rs +0 -43
  967. package/packages/guard/src/middleware.rs +0 -42
  968. package/packages/guard/src/routing/pegboard_gateway.rs +0 -260
  969. package/packages/guard-core/src/analytics.rs +0 -46
  970. package/packages/internal/README.md +0 -1
  971. package/packages/internal/src/lib.rs +0 -1
  972. package/packages/internal/src/ops/bump_serverless_autoscaler_global.rs +0 -64
  973. package/packages/internal/src/ops/cache/mod.rs +0 -1
  974. package/packages/internal/src/ops/cache/purge_global.rs +0 -81
  975. package/packages/internal/src/ops/mod.rs +0 -2
  976. package/packages/namespace/src/ops/runner_config/mod.rs +0 -4
  977. package/packages/namespace/src/ops/runner_config/upsert.rs +0 -148
  978. package/packages/pegboard/src/ops/actor/get_runner.rs +0 -64
  979. package/packages/pegboard/src/ops/runner/find_dc_with_runner.rs +0 -222
  980. package/packages/pegboard-serverless/src/lib.rs +0 -523
  981. package/packages/types/src/msgs/mod.rs +0 -1
  982. package/packages/types/src/msgs/pegboard.rs +0 -5
  983. package/sdks/rust/epoxy-protocol/src/versioned.rs +0 -206
  984. package/sdks/rust/runner-protocol/build.rs +0 -115
  985. package/sdks/rust/runner-protocol/src/lib.rs +0 -10
  986. package/sdks/rust/runner-protocol/src/versioned.rs +0 -1734
  987. package/sdks/schemas/epoxy-protocol/v1.bare +0 -260
  988. package/sdks/typescript/runner/.turbo/turbo-build.log +0 -22
  989. package/sdks/typescript/runner/dist/mod.cjs +0 -2951
  990. package/sdks/typescript/runner/dist/mod.cjs.map +0 -1
  991. package/sdks/typescript/runner/dist/mod.d.cts +0 -326
  992. package/sdks/typescript/runner/dist/mod.d.ts +0 -326
  993. package/sdks/typescript/runner/dist/mod.js +0 -2951
  994. package/sdks/typescript/runner/dist/mod.js.map +0 -1
  995. package/sdks/typescript/runner/node_modules/.bin/pino +0 -21
  996. package/sdks/typescript/runner/node_modules/.bin/tsc +0 -21
  997. package/sdks/typescript/runner/node_modules/.bin/tsserver +0 -21
  998. package/sdks/typescript/runner/node_modules/.bin/tsup +0 -21
  999. package/sdks/typescript/runner/node_modules/.bin/tsup-node +0 -21
  1000. package/sdks/typescript/runner/node_modules/.bin/tsx +0 -21
  1001. package/sdks/typescript/runner/node_modules/.bin/uuid +0 -21
  1002. package/sdks/typescript/runner/node_modules/.bin/vitest +0 -21
  1003. package/sdks/typescript/runner-protocol/.turbo/turbo-build.log +0 -22
  1004. package/sdks/typescript/runner-protocol/dist/index.cjs.map +0 -1
  1005. package/sdks/typescript/runner-protocol/dist/index.d.cts +0 -666
  1006. package/sdks/typescript/runner-protocol/dist/index.d.ts +0 -666
  1007. package/sdks/typescript/runner-protocol/dist/index.js.map +0 -1
  1008. package/sdks/typescript/runner-protocol/node_modules/.bin/tsserver +0 -21
  1009. package/sdks/typescript/runner-protocol/node_modules/.bin/tsup +0 -21
  1010. package/sdks/typescript/runner-protocol/node_modules/.bin/tsup-node +0 -21
  1011. package/sdks/typescript/test-runner/Dockerfile +0 -26
  1012. package/tests/load/README.md +0 -28
  1013. package/tests/load/actor-lifecycle/README.md +0 -26
  1014. package/tests/load/actor-lifecycle/actor.ts +0 -41
  1015. package/tests/load/actor-lifecycle/config.ts +0 -14
  1016. package/tests/load/actor-lifecycle/index.ts +0 -62
  1017. package/tests/load/actor-lifecycle/rivet_api.ts +0 -140
  1018. package/tests/load/actor-lifecycle/types.ts +0 -17
  1019. package/tests/load/node_modules/.bin/biome +0 -21
  1020. package/tests/load/node_modules/.bin/tsc +0 -21
  1021. package/tests/load/package.json +0 -15
  1022. package/tests/load/tsconfig.json +0 -20
  1023. package/tests/smoke/README.md +0 -32
  1024. package/tests/smoke/package.json +0 -19
  1025. package/tests/smoke/scripts/connect.ts +0 -41
  1026. package/tests/smoke/src/server/registry.ts +0 -32
  1027. package/tests/smoke/src/server/server.ts +0 -7
  1028. package/tests/smoke/src/smoke-test/index.ts +0 -161
  1029. package/tests/smoke/src/smoke-test/spawn-actor.ts +0 -109
  1030. package/tests/smoke/tsconfig.json +0 -43
  1031. /package/packages/{dump-openapi → api-public-openapi-gen}/build.rs +0 -0
  1032. /package/packages/{dump-openapi → api-public-openapi-gen}/src/lib.rs +0 -0
  1033. /package/{sdks/rust → packages}/runner-protocol/Cargo.toml +0 -0
  1034. /package/{sdks/rust → packages}/runner-protocol/src/compat.rs +0 -0
  1035. /package/{sdks/rust → packages}/runner-protocol/src/generated.rs +0 -0
  1036. /package/{sdks/rust → packages}/runner-protocol/src/uuid_compat.rs +0 -0
  1037. /package/sdks/rust/{runner-protocol → envoy-protocol}/src/util.rs +0 -0
  1038. /package/{tests/smoke → sdks/typescript/envoy-protocol}/turbo.json +0 -0
@@ -1,158 +1,619 @@
1
1
  # Epoxy
2
2
 
3
- Epoxy is a geo-distributed, strongly-consistent KV store based on the EPaxos protocol.
3
+ Epoxy is a geo-distributed, strongly consistent KV store. Keys are immutable by default, with opt-in mutable overwrite semantics for workloads that need them. The consensus protocol is single-decree Fast Paxos (Lamport, 2006), run independently per key. Fresh keys commit in 1 RTT by skipping Phase 1 (Prepare) and going straight to Phase 2 (Accept). Keys with prior in-flight state fall back to classic two-phase Paxos (Prepare + Accept) at 2 RTT.
4
4
 
5
- ## EPaxos Overview
5
+ ### Why immutable keys
6
6
 
7
- ### Resources
7
+ Immutability is not a limitation. It is the design choice that makes everything else cheap:
8
8
 
9
- Paper:
9
+ - **No read quorums.** A committed value can never change, so any replica that has it can serve reads locally. Reads never touch the network in steady state.
10
+ - **Aggressive caching.** Replicas can cache committed values from other datacenters indefinitely. Cache invalidation is trivial because there is nothing to invalidate.
11
+ - **Idempotent replication.** Commit messages and changelog catch-up can deliver the same key multiple times safely. The second write is always a no-op.
12
+ - **No conflict resolution.** There is no merge logic or last-writer-wins. Either your value won or someone else got there first.
13
+ - **Unordered changelogs.** Each replica's changelog can have entries in a different order. This is safe because the final state is the same set of committed values regardless of application order.
10
14
 
11
- https://www.cs.cmu.edu/~dga/papers/epaxos-sosp2013.pdf
15
+ Mutable keys trade some of these properties for overwrite capability. Their optimistic cache must be invalidated on commit, changelog catch-up becomes version-aware, and duplicate committed values are only idempotent when the version matches.
12
16
 
13
- Reference implementations:
17
+ ### Why single-decree per key
14
18
 
15
- - https://github.com/efficient/epaxos/tree/master/src/epaxos
16
- - https://github.com/pisimulation/epaxos/tree/master
19
+ Each key only needs agreement on one value, so each key gets its own independent single-decree Paxos instance. This gives:
17
20
 
18
- TODO: Correctness issue: https://github.com/otrack/on-epaxos-correctness
21
+ - **No shared log.** Keys are independent. There is no global ordering to maintain across unrelated keys.
22
+ - **No leader election.** Any replica can propose for any key at any time. There is no distinguished leader to elect or fail over.
23
+ - **Lazy crash recovery.** A stalled proposal only affects one key. There is no failure detector or background scan. Recovery happens only when another proposer tries to write the same key.
19
24
 
20
- Talks:
25
+ ### Terminology
21
26
 
22
- - Original paper: https://www.youtube.com/watch?v=KxoWlUZNKn8&t=357s
23
- - Optimization: https://www.youtube.com/watch?v=aysKrS_SAXo
27
+ Epoxy now uses standard Fast Paxos terminology. Earlier versions of this codebase inherited the name `PreAccept` from its EPaxos ancestry, but that phase was always standard Paxos Phase 2a.
24
28
 
25
- Other resources:
29
+ | Epoxy | Fast Paxos | Purpose |
30
+ |----------------|----------------|-------------------------------------------------|
31
+ | Prepare | Phase 1a | Leader asks replicas to promise a ballot |
32
+ | Prepare Ok | Phase 1b | Replicas promise and report any accepted value |
33
+ | Accept | Phase 2a | Leader asks replicas to accept a value at ballot |
34
+ | Accept Ok | Phase 2b | Replicas confirm they accepted |
35
+ | Commit | Learn/Decide | Leader tells replicas the value is final |
36
+
37
+ Rivet uses Epoxy for two workflows:
38
+
39
+ - `pegboard::workflows::actor::actor_keys::Propose` reserves an actor key with a single-key set-if-absent write.
40
+ - `pegboard::ops::get_reservation_for_key` resolves that reservation with an optimistic read.
41
+
42
+ Those workloads do not need cross-key ordering or shared global proposal metadata, so Epoxy keeps consensus state per key. For workloads that do need cross-key ordering in high-latency geo-distributed environments, EPaxos (Moraru et al., 2013) is a useful reference.
43
+
44
+ ## Model
45
+
46
+ Each key is handled independently by single-decree Paxos.
47
+
48
+ - A proposal leader first runs ballot selection by reading `kv/{key}/value` and `kv/{key}/ballot` atomically.
49
+ - Fresh keys skip Prepare and go straight to `Accept`, which gives the common 1 RTT write path.
50
+ - Keys with prior in-flight state run `Prepare` first, adopt the highest accepted value if one exists, then continue with `Accept`.
51
+ - Successful proposals commit locally in one UDB transaction and then broadcast `Commit` to every replica.
52
+ - Immutable values keep the 1 RTT fast path and indefinite optimistic caching. Mutable values reuse the same per-key Paxos flow, but each overwrite runs a new versioned round for that key.
53
+
54
+ ### Why there is only one Phase 2 message
55
+
56
+ In standard Paxos, Phase 2 (`Accept`) asks replicas to accept a value at a given ballot. Epoxy uses that standard message directly: it writes the ballot and accepted value to `kv/{key}/ballot` and `kv/{key}/accepted` in one transaction, and `Commit` is the Learn/Decide notification that tells replicas the value is final.
57
+
58
+ ### Crash recovery
59
+
60
+ If a proposer crashes after `Accept` succeeds but before `Commit` completes, the key is left with a non-zero ballot and an accepted value but no committed value.
61
+
62
+ Recovery is lazy. There is no failure detector, timeout, or background scan that notices the stranded state. Recovery only happens when another proposer tries to write the same key. That proposer's ballot selection sees the non-zero ballot, enters the `Prepare` path, and collects the accepted value from the replicas that stored it. If nobody ever tries to write that key again, the stranded state sits there indefinitely, which is harmless.
63
+
64
+ This works because Epoxy only serves actor key reservation. If a key matters, a caller will eventually try to reserve it and trigger recovery as a side effect. Standard Paxos safety requires re-proposing the highest accepted value, which is what the recovering leader does. This ensures the earlier majority-accepted value is not lost.
65
+
66
+ ## Sequence Diagrams
67
+
68
+ ### Fast path: new key (1 RTT)
69
+
70
+ The common case for actor key reservation. No prior state exists for the key. Replica A is the proposing leader. All three replicas participate in the quorum (the leader sends to itself through the same handler).
71
+
72
+ ```text
73
+ Replica A (leader) Replica B Replica C
74
+ | | |
75
+ | [read local: no value, no ballot] |
76
+ | [generate ballot (1, A)] | |
77
+ | | |
78
+ |--- Accept(val, 1,A) ------->| |
79
+ |--- Accept(val, 1,A) -------------------------------->|
80
+ | | |
81
+ |<------------- Ok --------------| |
82
+ |<------------- Ok ----------------------------------------|
83
+ | | |
84
+ | [fast quorum reached (3/3)] | |
85
+ | [commit local tx] | |
86
+ | | |
87
+ |--- Commit(key, val) ----------->| |
88
+ |--- Commit(key, val) ---------------------------------->|
89
+ | | |
90
+ v done: Committed v v
91
+ ```
92
+
93
+ ### Already committed key (0 RTT immutable write, local read)
94
+
95
+ A read or duplicate immutable write hits a key that was already committed. Ballot selection short-circuits without any network traffic. Mutable keys do not stop here. They use the committed value's version to start the next overwrite round.
96
+
97
+ ```text
98
+ Replica A (leader)
99
+ |
100
+ | [read local: value exists]
101
+ | [return AlreadyCommitted(v)]
102
+ |
103
+ v done
104
+ ```
105
+
106
+ ### Slow path: prior in-flight state (2 RTT)
107
+
108
+ Replica C starts a proposal but crashes before it can commit. Later, Replica A tries to write the same key for an unrelated reservation. A's ballot selection finds C's stranded ballot and triggers recovery. Even though A has a lower replica ID than C, it supersedes C's stalled proposal by incrementing the counter to `(2, A)`, which is higher than `(1, C)` because the counter is compared first.
109
+
110
+ ```text
111
+ Replica A Replica B Replica C
112
+ | | |
113
+ | | [generate ballot (1, C)]
114
+ | | |
115
+ |<--- Accept(val, 1,C) --------|<-- Accept(val, 1,C) --
116
+ | | |
117
+ |-------------- Ok -------------->|------------- Ok ----->|
118
+ | | |
119
+ | | [fast quorum (3/3)]
120
+ | | [crash before Commit]
121
+ | | x
122
+ | | x
123
+ | --- later, A tries to write this key --- x
124
+ | | x
125
+ | [read local: no value, ballot (1, C)] x
126
+ | [prior state found, must Prepare] x
127
+ | [generate ballot (2, A)] | x
128
+ | [(2, A) > (1, C) because 2 > 1] | x
129
+ | | x
130
+ |--- Prepare(key, 2,A) --------->| x
131
+ | | x
132
+ |<--- Ok(accepted=val@1,C) ------| x
133
+ | | x
134
+ | [slow quorum reached (2/3)] | x
135
+ | [re-propose C's accepted value] | x
136
+ | | x
137
+ |--- Accept(val, 2,A) ------->| x
138
+ | | x
139
+ |<------------- Ok --------------| x
140
+ | | x
141
+ | [fast quorum reached (2/2)] | x
142
+ | [commit local tx] | x
143
+ | | x
144
+ |--- Commit(key, val) ----------->| x
145
+ | | x
146
+ v done: Committed v x
147
+ ```
148
+
149
+ ### Concurrent proposers on a fresh key (contention)
150
+
151
+ Replica A and Replica C both try to write the same fresh key simultaneously. Both see no prior state and skip Prepare. With `n=3`, the fast quorum is 3 (all replicas), so at most one proposer can reach it. The loser falls back to the slow path on retry.
152
+
153
+ ```text
154
+ Replica A (leader) Replica B Replica C (leader)
155
+ | | |
156
+ | [no value, no ballot] | [no value, no ballot]
157
+ | [generate ballot (1, A)] | [generate ballot (1, C)]
158
+ | | |
159
+ |--- Accept(val_a, 1,A) ----->| |
160
+ | |<-- Accept(val_c, 1,C) --
161
+ | | |
162
+ | [B accepts (1,A)] |
163
+ | [then sees (1,C) > (1,A)] |
164
+ | | |
165
+ |<------- HigherBallot ----------| |
166
+ | |----------- Ok ------->|
167
+ | | |
168
+ | [only 1/3, no fast quorum] | [3/3, fast quorum reached]
169
+ | [ConsensusFailed] | |
170
+ | | [commit local tx]
171
+ | |<--- Commit(val_c) ----|
172
+ |<---------- Commit(val_c) ------| |
173
+ | | |
174
+ | [retry: read local] | |
175
+ | [sees committed val_c] | |
176
+ | [AlreadyCommitted or | |
177
+ | ExpectedValueDoesNotMatch] | |
178
+ | | |
179
+ v v v
180
+ ```
181
+
182
+ The replica-ID component of the ballot is the tiebreaker. When two leaders use the same counter, the higher replica ID wins Accept at any replica that sees both requests. Since fast quorum requires all replicas for `n=3`, the lower-ID leader cannot reach quorum.
183
+
184
+ ### Learner catch-up (reconfiguration)
185
+
186
+ A new datacenter joins the cluster. The coordinator (which runs on Replica A) adds the new replica as `Joining`, broadcasts the updated config so live commits reach it, then starts catch-up. The joining replica pages the changelog from one active source while also applying live commits that arrive concurrently.
187
+
188
+ ```text
189
+ Replica A (coordinator) Replica B (source) Replica C (joining)
190
+ | | |
191
+ | [detect new DC (C)] | |
192
+ | [health check OK] | |
193
+ | [add C as Joining to config] | |
194
+ | | |
195
+ |--- UpdateConfig(+C joining) -->| |
196
+ |--- UpdateConfig(+C joining) -------------------------------->|
197
+ | | |
198
+ | [config broadcast done] | |
199
+ | [live commits now reach C] | |
200
+ | | |
201
+ |--- BeginLearning ------------------------------------------>|
202
+ | | |
203
+ | | [choose B as source]
204
+ | |<-- ChangelogRead(cursor=0, N)
205
+ | |--- [{k1,v1},{k2,v2}] --->|
206
+ | | [apply k1, k2] |
207
+ | | |
208
+ | |--- Commit(k3,v3) --->|
209
+ | | [apply k3] |
210
+ | | |
211
+ | |<-- ChangelogRead(cursor=page1.last)
212
+ | |--- [{k3,v3}] -------->|
213
+ | | [k3 exists, no-op]
214
+ | | |
215
+ | |<-- ChangelogRead(cursor=page2.last)
216
+ | |--- empty page -------->|
217
+ | | [catch-up complete]
218
+ | | |
219
+ |<----------- UpdateReplicaStatus(Active) ----------------|
220
+ | | |
221
+ | [mark C Active, bump epoch] | |
222
+ |--- UpdateConfig(C active) ---->| |
223
+ |--- UpdateConfig(C active) --------------------------------->|
224
+ | [trigger changelog GC] | |
225
+ | | |
226
+ v v v
227
+ ```
228
+
229
+ The key safety property is idempotency. A committed value that arrives via both a live `Commit` and the changelog page is applied only once because the second write is a no-op when `kv/{key}/value` already exists.
230
+
231
+ ## Key Layout
232
+
233
+ All new consensus state lives under each replica's v2 UDB subspace. There is no shared global
234
+ log or shared ballot counter.
235
+
236
+ ```text
237
+ /rivet/epoxy_v2/
238
+ replica/{replica_id}/
239
+ config = ClusterConfig
240
+
241
+ kv/{key}/value = CommittedValue { value, version, mutable }
242
+ kv/{key}/ballot = Ballot
243
+ kv/{key}/accepted = KvAcceptedValue { value, ballot, version, mutable }
244
+ kv/{key}/cache = CommittedValue { value, version, mutable }
245
+
246
+ changelog/{versionstamp} = ChangelogEntry { key, value, version, mutable }
247
+ ```
248
+
249
+ Legacy committed values remain read-only under `/rivet/epoxy/replica/{replica_id}/kv/{key}`.
250
+ Reads still check `committed_value`, then `value`, in that legacy subspace so old actors remain
251
+ visible after the hard cutover.
252
+
253
+ ### `config`
254
+
255
+ The current cluster configuration for this replica. This includes the coordinator replica id, the config epoch, and every replica's status and peer URLs.
256
+
257
+ ### `kv/{key}/value`
258
+
259
+ The committed value for `key`.
260
+
261
+ - Immutable keys write `CommittedValue { value, version = 1, mutable = false }` and never change again.
262
+ - Mutable keys overwrite this record with a higher `version` on every successful commit.
263
+ - Legacy raw values are still readable and are treated as `version = 0, mutable = false`.
264
+
265
+ ### `kv/{key}/ballot`
26
266
 
27
- - Atlas follow up: https://software.imdea.org/~gotsman/papers/atlas-eurosys20.pdf
267
+ The highest ballot this replica has seen for `key`. A replica will not accept proposals with a lower ballot. Ballots are `(counter, replica_id)` tuples compared lexicographically (counter first, then replica_id as tiebreak). Each ballot is scoped to one logical user key. There is no shared ballot across unrelated keys.
28
268
 
29
- ### Glossary
269
+ The ballot has two components for different reasons. The counter provides liveness: any replica can supersede any other replica's stalled proposal by incrementing the counter, which is necessary for crash recovery. Without it, a crashed high-ID replica would permanently block a key because no lower-ID replica could generate a higher ballot. The replica ID provides deterministic tiebreaking when two proposers use the same counter, which happens when multiple replicas try to write a fresh key simultaneously.
30
270
 
31
- - **Replica** one of the datacenters running epaxos
32
- - **Coordinator** — the workflow that manages adding and removing replicas from the cluster
33
- - **Instance** — per-replica slot (R.1, R.2, …); at most one command is chosen per slot. **This is not the same as a replica.**
34
- - **Command** — an operation to be ran on the KV store
35
- - **Command leader** — the replica that received the client’s command (not a fixed global leader)
36
- - **Interference (interf)** — two commands "interfere" if they conflict (i.e., same key)
37
- - **Dependencies (deps)** — set of interfering instances that a command depends on.
38
- - **Sequence number (seq)** — integer used (with deps) to break cycles and order execution.
39
- - **Log** — each replica’s private log of instances and their attributes/status.
40
- - **Ballot number** — monotonic proposal id; includes an epoch prefix to order configurations.
41
- - **Epoch** — configuration/version used to order ballots across reconfigurations.
271
+ Ballot selection reads `value` and `ballot` together to decide whether the leader can use the fast path or must run `Prepare`.
42
272
 
43
- ### Interference Overview
273
+ ### `kv/{key}/accepted`
44
274
 
45
- Interference is at the core of EPaxos. Interference is used to determine if a command can be committed on the fast path without executing the full slow-path Paxos protocol.
275
+ The latest accepted but not yet committed proposal for `key`.
46
276
 
47
- Some notes related to Rivet's workload requirements relating to interference:
277
+ ```text
278
+ {
279
+ value: Vec<u8>,
280
+ ballot: Ballot,
281
+ version: u64,
282
+ mutable: bool,
283
+ }
284
+ ```
48
285
 
49
- - Any write to the same key is an interference, regardless of the operation kind
50
- - The only case where we could optimize this more is if commands are communicative (i.e. simila to UDB's atomic operations)
51
- - Even though we use CAS for actor keys:
52
- - This counts as a write regardless of the previous value, since CAS commands are non-communicative
53
- - CAS get written to the log even though it may have no effect on the value
54
- - If there is no conflict, the fast-path will return a success since CAS is equivalent to a write
55
- - The CAS will be written to the log regardless, but we will determine if the write was a success when committed
56
- - Consistent reads also count as interference, which is not good for read-heavy operations
57
- - Rivet is designed to ensure that values do not change after they are set so we can use optimistic reads instead (see dev-docs/ACTOR_KEY_RESERVATION.md)
58
- - This pattern is similar to the lease pattern that the paper proposes
286
+ - `Accept` writes this record together with `ballot`.
287
+ - `Prepare` returns it so a recovery leader can re-propose the highest accepted value.
288
+ - `Commit` and changelog catch-up clear it once the value becomes committed.
59
289
 
60
- ## Workloads Depending On Epoxy
290
+ ### `kv/{key}/cache`
61
291
 
62
- - `pegboard::workflows::actor::actor_keys::Propose`: Uses check or set operation for the actor key's reservation ID
63
- - `pegboard::ops::get_reservation_for_key`: Uses an optimistic read to find the reservation ID to resolve the actual actor ID
292
+ An optimistic cache of a committed value observed from another replica. Only used by `kv_get_optimistic`.
64
293
 
65
- ## Architecture
294
+ - Immutable keys can stay cached indefinitely.
295
+ - Mutable keys store the version in cache and invalidate older cache entries on commit.
296
+ - `SkipCache` reads bypass this key entirely and do not populate it.
66
297
 
67
- ### Coordinator Workflow
298
+ ### `changelog/{versionstamp}`
68
299
 
69
- The leader datacenter holds a coordinator workflow. This workflow detect config changes and handle:
300
+ An append-only per-replica changelog entry:
70
301
 
71
- - Gracefully adding replicas
72
- - Propagating cluster config changes
73
- - Epoch number
302
+ ```text
303
+ {
304
+ key: Vec<u8>,
305
+ value: Vec<u8>,
306
+ version: u64,
307
+ mutable: bool,
308
+ }
309
+ ```
74
310
 
75
- See `spec/RECONFIGURE.md` for more information.
311
+ Entries are written with an FDB versionstamp key so appends do not contend with each other. Each replica maintains its own changelog because versionstamps are local ordering tokens, not globally comparable across replicas. Learners page this changelog during catch-up. The coordinator uses learner cursors to garbage-collect old entries.
76
312
 
77
- ### Replcia Workflow
313
+ The cursor returned by `ChangelogRead` is only meaningful for the replica that produced it. Catch-up must stay on a single source replica for the whole session.
78
314
 
79
- Each datacenter has its own replica workflow that is responsible for:
315
+ ## Proposal Flow
80
316
 
81
- - Downloading instances from other replicas
82
- - Notifying coordinator when joined cluster
317
+ The compiled proposal path accepts the old `Proposal` wrapper for compatibility, but the supported operation is intentionally narrow: exactly one command, exactly one key, and a concrete value. Immutable writes use set-if-absent semantics. Mutable writes opt into overwrite semantics at the operation input.
83
318
 
84
- ### Messages
319
+ ### 1. Ballot Selection
85
320
 
86
- All peer-to-peer communication is done via the `POST /v{version}/epoxy/message` using the versioned BARE epoxy protocol.
321
+ The leader reads the local state for the target key in one serializable UDB transaction:
87
322
 
88
- ### Proposals
323
+ 1. Read `kv/{key}/value`
324
+ 2. Read `kv/{key}/ballot`
89
325
 
90
- Proposals are the mechanism for establishing consensus when making a chance to the KV store.
326
+ Outcomes:
91
327
 
92
- Proposals are not implemented as a workflow since they're:
328
+ - If `value` exists and the key is immutable, stop and return `AlreadyCommitted` with the committed value. The caller compares this against the requested value later.
329
+ - If `value` exists and the key is mutable and the caller requested a mutable write, continue with `version = committed.version + 1`. If the ballot was cleared by the previous mutable commit, the proposer can use the fast path again.
330
+ - If `ballot` is missing or zero, generate a fresh ballot `(1, replica_id)` and continue to Accept.
331
+ - If `ballot` already exists, run Prepare first.
93
332
 
94
- - Inherently designed to be fallable so they don't benefit from the overhead of workflows
95
- - They can operate in paralle, while a single replica workflow cannot — though a workflow-per-proposal would technically work fine
333
+ This preserves the 1 RTT fast path for untouched keys while still recovering safely from prior in-flight proposals.
96
334
 
97
- See `spec/PROPOSAL.md` for more information.
335
+ ### 2. Prepare
98
336
 
99
- ## Coordinator & Dynamic Topology Configuration
337
+ Prepare is Paxos Phase 1 for a single key. The leader uses it whenever ballot selection finds prior ballot state.
100
338
 
101
- **Do not use `rivet_config::config::Topology` (i.e. `ctx.config().topology()`) from this service.** Instead, read the cluster config propagated from the coordinator with `epoxy::ops::read_cluster_config`.
339
+ #### Request
102
340
 
103
- The leader datacenter runs a coordinator workflow in charge of coordinating config changes across all peers.
341
+ ```text
342
+ PrepareRequest {
343
+ key,
344
+ ballot,
345
+ mutable,
346
+ version,
347
+ }
348
+ ```
104
349
 
105
- This ensures that peers receive config changes at the exact same time.
350
+ The leader chooses `ballot = (max_counter + 1, replica_id)`, where `max_counter` is the highest counter it has seen so far for that key.
106
351
 
107
- ## Joining Replicas
352
+ #### Replica behavior
108
353
 
109
- ### Reconfigure Abort
354
+ Each replica reads `kv/{key}/value`, `kv/{key}/ballot`, and `kv/{key}/accepted` in one transaction.
110
355
 
111
- The coordinator will attempt to propagate the config change to all new replicas when a config change is detected.
356
+ - If `value` exists, reply `AlreadyCommitted`.
357
+ - If `value` exists but the request targets a higher mutable version, continue normally.
358
+ - If `request.ballot <= current_ballot`, reply `HigherBallot`.
359
+ - Otherwise, write `kv/{key}/ballot = request.ballot` and reply `Ok` with:
360
+ - `highest_ballot`
361
+ - `accepted_value`, including its version and mutable flag, if any
362
+ - `accepted_ballot`, if any
112
363
 
113
- If the config is invalid (i.e. the replica cannot be reached), the workflow will keep retrying indefinitely.
364
+ #### Leader behavior
114
365
 
115
- Reconfigure will be aborted if there is a config change detected. In this case, all changes will be abandoned and the coordinator will attempt to reconfigure with the new config.
366
+ The leader sends Prepare to a slow quorum, including itself through the standard message path.
116
367
 
117
- ### Error in EPaxos Join Specification
368
+ - If any replica returns `AlreadyCommitted`, stop and return the committed value.
369
+ - If too many replicas reject with higher ballots to reach the quorum, bump the ballot and retry Prepare with exponential backoff and jitter (10ms initial, 2x, 1s cap, max 10 retries).
370
+ - If quorum promises succeed, choose the value for Phase 2:
371
+ - If any replica reported an accepted value, re-propose the value with the highest accepted ballot.
372
+ - Otherwise, keep the client's requested value.
118
373
 
119
- The paper has an incorrect explanation of adding new replicas. It describes the join process as:
374
+ Re-proposing the highest accepted value is the safety rule that prevents an earlier majority-accepted value from being lost.
120
375
 
121
- 1. Broadcast _Join_ with new epoch
122
- 2. Download instances from other replicas
123
- 3. Replica begins voting
376
+ ### 3. Accept
124
377
 
125
- The issue with this is that the quorum count will have changed, but the replica cannot vote yet. This means that if you add too many replicas at the same time you will cause a complete outage until the new replicas have downloaded all instances and began voting.
378
+ Accept is Epoxy's Phase 2 message.
126
379
 
127
- Instead, we opt to:
380
+ #### Request
128
381
 
129
- 1. Add replica as a learner (starts receiving commits)
130
- 2. Download instances from other replicas
131
- 3. Corodinator increments voting once node is active
132
- 4. Replica begins voting
382
+ ```text
383
+ AcceptRequest {
384
+ key,
385
+ value,
386
+ ballot,
387
+ mutable,
388
+ version,
389
+ }
390
+ ```
133
391
 
134
- This enables clusters to add many new replicas at once without causing an outage.
392
+ #### Replica behavior
135
393
 
136
- ### Misc Notes
394
+ Each replica reads `kv/{key}/value` and `kv/{key}/ballot` in one transaction.
137
395
 
138
- - Downloading replicas receive commits from other replicas even though they are not part of the quorum while they are downloading. This ensures that they have received all messages, even though they are not part of the quorum.
396
+ - If `value` exists and the request is immutable, or the request's mutable version is stale, reply `AlreadyCommitted`.
397
+ - If `current_ballot > request.ballot`, reply `HigherBallot`.
398
+ - Otherwise:
399
+ - write `kv/{key}/ballot = request.ballot`
400
+ - write `kv/{key}/accepted = { value, ballot, version, mutable }`
401
+ - reply `Ok`
139
402
 
140
- ## Future Optimizations
403
+ #### Leader behavior
141
404
 
142
- ## Integrate Explicit Prepare
405
+ The leader sends Accept to the target quorum for the current path.
143
406
 
144
- Explicit Prepare is implemented but not integrated anywhere.
407
+ - If any replica returns `AlreadyCommitted`, stop and return that value.
408
+ - If some replicas return `HigherBallot`, keep waiting for other responses.
409
+ - If the target quorum replies `Ok`, continue to commit.
410
+ - If the target quorum becomes unreachable, return `ConsensusFailed`.
145
411
 
146
- ### Avoiding Execution Livelock (§4.9)
412
+ The common case for a fresh actor key is ballot selection plus one Accept round, which is the 1 RTT write path.
147
413
 
148
- The paper recommends prioritizing earlier commands. We don't have functionality to do this right now, but the current design has almost no contention so this is not a concern.
414
+ ### 4. Commit
149
415
 
150
- ### Batching (§7.6)
416
+ The leader commits locally before broadcasting the replicated commit.
151
417
 
152
- The paper recommends batching requests for a "9x" improvement in throughput. We don't need to do this since we (a) execute requests in parallel, (b) assume low contention, and (c) built the system to be stateless + scale horizontally with UDB.
418
+ #### Local commit transaction
153
419
 
154
- ### Optimized Epaxos (§4.4)
420
+ The leader runs one serializable UDB transaction that:
155
421
 
156
- The paper recommends an optimize recovery mechanism that requires less replicas for consensus.
422
+ 1. Reads `kv/{key}/ballot`
423
+ 2. Rejects if a higher ballot has appeared and this replica no longer has a matching accepted
424
+ record for the chosen value
425
+ 3. Reads `kv/{key}/value`
426
+ 4. Returns `AlreadyCommitted` if the key is already committed
427
+ 5. Writes `kv/{key}/value = { value, version, mutable }`
428
+ 6. Deletes `kv/{key}/accepted`
429
+ 7. Deletes `kv/{key}/ballot` and `kv/{key}/cache` for mutable commits
430
+ 8. Appends `{ key, value, version, mutable }` to `changelog/{versionstamp}`
157
431
 
432
+ If this transaction fails because the ballot was preempted before this replica accepted the chosen
433
+ value, the proposal returns `ConsensusFailed`.
158
434
 
435
+ #### Commit broadcast
436
+
437
+ After the local write succeeds, the leader broadcasts:
438
+
439
+ ```text
440
+ CommitRequest {
441
+ key,
442
+ value,
443
+ ballot,
444
+ mutable,
445
+ version,
446
+ }
447
+ ```
448
+
449
+ Replica behavior:
450
+
451
+ - If `kv/{key}/value` already exists, return `AlreadyCommitted`.
452
+ - Mutable commits only overwrite when `request.version` is higher than the committed version.
453
+ - If `commit.ballot < current_ballot`, return `StaleCommit`.
454
+ - Otherwise:
455
+ - write `kv/{key}/value`
456
+ - clear `kv/{key}/accepted`
457
+ - clear `kv/{key}/ballot` and `kv/{key}/cache` for mutable keys
458
+ - append the entry to the local changelog
459
+ - return `Ok`
460
+
461
+ Commit is intentionally idempotent. That is required for retry handling and learner catch-up.
462
+
463
+ ### Caller result mapping
464
+
465
+ Immutable writes keep the old set-if-absent result mapping.
466
+
467
+ - If an immutable committed value matches the requested value, the proposal returns `Committed`.
468
+ - If an immutable committed value differs, the proposal returns `ExpectedValueDoesNotMatch`.
469
+ - Mutable writes return `Committed` when their overwrite commits successfully.
470
+ - If quorum cannot be reached without a higher-ballot retry, the proposal returns `ConsensusFailed` and the caller retries.
471
+
472
+ ## Quorums
473
+
474
+ Epoxy uses Fast Paxos quorum sizes:
475
+
476
+ - Slow quorum: `floor(n / 2) + 1`
477
+ - Fast quorum: `n - floor((slow_q - 1) / 2)`
478
+ - Safety invariant: `2 * fast_q + slow_q > 2 * n`
479
+
480
+ This keeps slow quorums at a strict majority and ensures any two fast quorums plus one slow quorum still intersect safely. In small clusters this means:
481
+
482
+ | n | slow_q | fast_q |
483
+ |---|--------|--------|
484
+ | 3 | 2 | 3 |
485
+ | 4 | 3 | 3 |
486
+ | 5 | 3 | 4 |
487
+ | 7 | 4 | 6 |
488
+
489
+ Only `Active` replicas participate in proposal quorums. Sender-excluded fanout quorum helpers subtract one from these sizes for `Fast`, `Slow`, and `All`, while `Any` still targets a single response. Commit fanout still goes to joining learners so catch-up can stay current while they bootstrap.
490
+
491
+ ## Reads
492
+
493
+ Reads support two cache behaviors.
494
+
495
+ - `Optimistic` checks the local optimistic cache on miss and writes back the first remote committed value it finds.
496
+ - `SkipCache` bypasses the local optimistic cache entirely and does not populate it. It still checks the local committed value first.
497
+
498
+ The local read order is:
499
+
500
+ 1. v2 `kv/{key}/value`
501
+ 2. Legacy `kv/{key}/committed_value`
502
+ 3. Legacy `kv/{key}/value`
503
+ 4. v2 `kv/{key}/cache` when using `Optimistic`
504
+ 5. Fan out to other datacenters and cache the first committed value found when using `Optimistic`
505
+
506
+ This keeps the steady-state read path local.
507
+
508
+ ### Why reads use a separate cache key
509
+
510
+ On an optimistic cache miss, the fanout result is written to `kv/{key}/cache` instead of `kv/{key}/value`. This keeps reads isolated from the Paxos consensus path. Writing directly to `kv/{key}/value` would require a full Commit transaction: checking the ballot, clearing `kv/{key}/accepted`, and appending a changelog entry. Skipping any of those steps would leave the replica in an inconsistent state.
511
+
512
+ The separate cache key is simpler because it does not touch consensus state at all. The tradeoff is one extra key per remotely-read value, but it avoids turning reads into write transactions.
513
+
514
+ #### TODO: eliminate the cache key
515
+
516
+ The cache key could be removed by running a proper Commit transaction on fanout hit. The value is already committed on another replica and values are immutable, so this is safe. The benefits would be:
517
+
518
+ - One fewer key per remotely-read value
519
+ - Reads would populate `kv/{key}/value` directly, so subsequent reads skip the cache lookup
520
+ - The changelog would be complete, so learners catching up from this replica would not miss the entry
521
+
522
+ The cost is that a cache-miss read becomes a write transaction (ballot check + value write + accepted clear + changelog append) instead of a single cache key write. This is a latency and contention tradeoff: the current cache approach adds ~0 RTT overhead on the read path, while a Commit transaction would add the cost of a serializable UDB transaction. For now, the separate cache key is the simpler approach because it keeps reads completely outside the well-defined Paxos flow.
523
+
524
+ ## Reconfiguration
525
+
526
+ Each datacenter runs a replica workflow, and the leader datacenter also runs a coordinator workflow.
527
+
528
+ ### Coordinator flow
529
+
530
+ When the coordinator detects new datacenters in topology:
531
+
532
+ 1. Read the current topology and compare it with the stored cluster config.
533
+ 2. Health check each new replica until it is reachable or the topology changes again.
534
+ 3. Add the new replicas to cluster config with status `Joining`.
535
+ 4. Register each joining replica in coordinator learner state for changelog GC tracking.
536
+ 5. Broadcast the joining config to every replica before catch-up starts.
537
+ 6. Send `BeginLearning` to each joining replica.
538
+
539
+ Step 5 is important. Commit fanout uses the current config's full replica list, so broadcasting the joining config first is what lets live commits reach the learner while it is downloading history.
540
+
541
+ ### Learner flow
542
+
543
+ On `BeginLearning`, the learner:
544
+
545
+ 1. Stores the provided cluster config locally.
546
+ 2. Chooses one active source replica from that config.
547
+ 3. If there is no active source replica yet, skips catch-up and reports `Active`.
548
+ 4. Otherwise pages that source replica's changelog until it reaches the end.
549
+
550
+ ### Changelog catch-up loop
551
+
552
+ For each page:
553
+
554
+ 1. Send `ChangelogRead(afterVersionstamp, count)` to the chosen source replica.
555
+ 2. For every returned `{ key, value, version, mutable }` entry, apply it locally:
556
+ - write `kv/{key}/value` if the key is absent
557
+ - keep immutable duplicates only when the value matches exactly
558
+ - overwrite mutable values only when the incoming version is higher
559
+ - clear `kv/{key}/accepted`
560
+ - clear `kv/{key}/ballot` and `kv/{key}/cache` for mutable entries
561
+ - append the entry to the learner's own changelog
562
+ 3. Advance `afterVersionstamp` to the page's `lastVersionstamp`.
563
+ 4. Repeat until the source returns an empty page.
564
+
565
+ This path is idempotent, so live `Commit` messages that arrive while the learner is still paging history are safe. If the same committed value arrives twice, the second apply is a no-op.
566
+
567
+ ### Promotion to Active
568
+
569
+ After catch-up finishes, the learner sends `CoordinatorUpdateReplicaStatus(status=Active)`.
570
+
571
+ The coordinator then:
572
+
573
+ 1. Marks the replica `Active` in cluster config.
574
+ 2. Removes it from learner GC tracking.
575
+ 3. Increments the config epoch.
576
+ 4. Broadcasts the updated config to every replica.
577
+ 5. Triggers changelog GC.
578
+
579
+ The config epoch versions cluster membership changes. It is not part of the per-key Paxos ballot.
580
+
581
+ ### Changelog GC
582
+
583
+ The coordinator tracks learners by source replica and remembers the oldest catch-up cursor still in use.
584
+
585
+ - If learners are reading from a source replica, that oldest cursor becomes the GC watermark for that source.
586
+ - If no learners are reading from a source replica, GC can truncate through the replica's latest currently visible changelog entry.
587
+ - If a learner has not established a cursor yet, GC must not truncate that source replica's changelog.
588
+
589
+ Each replica's changelog is garbage-collected independently because versionstamp cursors are replica-local.
590
+
591
+ ## Transport
592
+
593
+ Peer-to-peer traffic uses raw BARE payloads over fixed v2 HTTP endpoints:
594
+
595
+ - `POST /v2/epoxy/message` for replica RPCs such as `Prepare`, `Accept`, `Commit`, `UpdateConfig`, and status updates
596
+ - `POST /v2/epoxy/changelog-read` for paginated changelog reads during learner catch-up
597
+
598
+ The route layer still validates request kinds so changelog reads do not silently fall back onto
599
+ the generic message endpoint.
600
+
601
+ ## Legacy Fallback
602
+
603
+ The legacy key layout stored committed values under `/rivet/epoxy/replica/{replica_id}` while the
604
+ current layout uses `/rivet/epoxy_v2/replica/{replica_id}`. There is no background migration. All
605
+ new writes go to v2 and old committed values are discovered through local dual-read fallback.
606
+
607
+ ### Dual-read fallback
608
+
609
+ Reads check both layouts in order: v2 `kv/{key}/value`, legacy `kv/{key}/committed_value`,
610
+ legacy `kv/{key}/value`, then v2 `kv/{key}/cache`. `ops/kv/read_value.rs` handles that lookup,
611
+ and `replica/ballot.rs` uses the same legacy subspace checks so already-committed legacy keys
612
+ still short-circuit before any new ballot is written.
613
+
614
+ ### Legacy state that is not preserved
615
+
616
+ Only committed values are read from the legacy subspace. Legacy ballots, accepted values,
617
+ changelogs, and config are ignored after the cutover. If an old replica had an in-flight accepted
618
+ value without a commit, that proposal is lost and a later proposer will either find a committed
619
+ value in the legacy subspace or retry the key from scratch.