@fuzdev/fuz_app 0.150.0 → 0.152.0

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 (597) hide show
  1. package/README.md +1 -1
  2. package/dist/actions/CLAUDE.md +324 -299
  3. package/dist/actions/action_bridge.d.ts +5 -86
  4. package/dist/actions/action_bridge.d.ts.map +1 -1
  5. package/dist/actions/action_bridge.js +4 -84
  6. package/dist/actions/action_codegen.d.ts +8 -166
  7. package/dist/actions/action_codegen.d.ts.map +1 -1
  8. package/dist/actions/action_codegen.js +19 -95
  9. package/dist/actions/action_dispatcher.d.ts +10 -0
  10. package/dist/actions/action_dispatcher.d.ts.map +1 -1
  11. package/dist/actions/action_dispatcher.js +9 -6
  12. package/dist/actions/action_event.d.ts +1 -2
  13. package/dist/actions/action_event.d.ts.map +1 -1
  14. package/dist/actions/action_event.js +7 -13
  15. package/dist/actions/action_event_helpers.d.ts +1 -40
  16. package/dist/actions/action_event_helpers.d.ts.map +1 -1
  17. package/dist/actions/action_event_helpers.js +1 -25
  18. package/dist/actions/action_rpc.d.ts +10 -215
  19. package/dist/actions/action_rpc.d.ts.map +1 -1
  20. package/dist/actions/action_rpc.js +56 -111
  21. package/dist/actions/action_spec.d.ts +2 -2
  22. package/dist/actions/action_spec.js +2 -2
  23. package/dist/actions/action_types.d.ts +229 -8
  24. package/dist/actions/action_types.d.ts.map +1 -1
  25. package/dist/actions/action_types.js +56 -5
  26. package/dist/actions/broadcast_api.d.ts +22 -17
  27. package/dist/actions/broadcast_api.d.ts.map +1 -1
  28. package/dist/actions/broadcast_api.js +16 -27
  29. package/dist/actions/cancel.d.ts +4 -13
  30. package/dist/actions/cancel.d.ts.map +1 -1
  31. package/dist/actions/cancel.js +5 -17
  32. package/dist/actions/compile_action_registry.d.ts +1 -2
  33. package/dist/actions/compile_action_registry.d.ts.map +1 -1
  34. package/dist/actions/connection_closer.d.ts +120 -50
  35. package/dist/actions/connection_closer.d.ts.map +1 -1
  36. package/dist/actions/connection_closer.js +139 -31
  37. package/dist/actions/{transports_ws_backend.d.ts → connection_registry.d.ts} +120 -132
  38. package/dist/actions/connection_registry.d.ts.map +1 -0
  39. package/dist/actions/{transports_ws_backend.js → connection_registry.js} +149 -152
  40. package/dist/actions/frontend_rpc_client.d.ts +52 -2
  41. package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
  42. package/dist/actions/frontend_rpc_client.js +42 -4
  43. package/dist/actions/peer_ping.d.ts +7 -9
  44. package/dist/actions/peer_ping.d.ts.map +1 -1
  45. package/dist/actions/peer_ping.js +6 -8
  46. package/dist/actions/peer_request.d.ts +6 -5
  47. package/dist/actions/peer_request.d.ts.map +1 -1
  48. package/dist/actions/peer_request.js +6 -5
  49. package/dist/actions/perform_action.d.ts +36 -28
  50. package/dist/actions/perform_action.d.ts.map +1 -1
  51. package/dist/actions/perform_action.js +60 -34
  52. package/dist/actions/protocol.d.ts +14 -0
  53. package/dist/actions/protocol.d.ts.map +1 -1
  54. package/dist/actions/protocol.js +18 -0
  55. package/dist/actions/register_action_ws.d.ts +137 -298
  56. package/dist/actions/register_action_ws.d.ts.map +1 -1
  57. package/dist/actions/register_action_ws.js +155 -923
  58. package/dist/actions/socket.svelte.d.ts +9 -0
  59. package/dist/actions/socket.svelte.d.ts.map +1 -1
  60. package/dist/actions/socket.svelte.js +16 -5
  61. package/dist/actions/transports.d.ts +88 -34
  62. package/dist/actions/transports.d.ts.map +1 -1
  63. package/dist/actions/transports.js +76 -76
  64. package/dist/actions/transports_http.d.ts +48 -12
  65. package/dist/actions/transports_http.d.ts.map +1 -1
  66. package/dist/actions/transports_http.js +75 -44
  67. package/dist/actions/transports_ws.d.ts +29 -0
  68. package/dist/actions/transports_ws.d.ts.map +1 -1
  69. package/dist/actions/transports_ws.js +34 -8
  70. package/dist/actions/ws_endpoint_spec.d.ts +52 -75
  71. package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
  72. package/dist/actions/ws_endpoint_spec.js +27 -10
  73. package/dist/actions/ws_outbound_writer.d.ts +3 -3
  74. package/dist/actions/ws_outbound_writer.js +3 -3
  75. package/dist/actions/ws_socket_session.d.ts +321 -0
  76. package/dist/actions/ws_socket_session.d.ts.map +1 -0
  77. package/dist/actions/ws_socket_session.js +783 -0
  78. package/dist/auth/CLAUDE.md +70 -44
  79. package/dist/auth/account_action_specs.d.ts +2 -0
  80. package/dist/auth/account_action_specs.d.ts.map +1 -1
  81. package/dist/auth/account_actions.d.ts +1 -1
  82. package/dist/auth/account_actions.d.ts.map +1 -1
  83. package/dist/auth/account_actions.js +9 -3
  84. package/dist/auth/account_queries.d.ts +10 -0
  85. package/dist/auth/account_queries.d.ts.map +1 -1
  86. package/dist/auth/account_queries.js +27 -17
  87. package/dist/auth/account_routes.d.ts +2 -1
  88. package/dist/auth/account_routes.d.ts.map +1 -1
  89. package/dist/auth/account_routes.js +14 -17
  90. package/dist/auth/account_schema.d.ts +5 -5
  91. package/dist/auth/account_schema.d.ts.map +1 -1
  92. package/dist/auth/account_schema.js +5 -2
  93. package/dist/auth/actor_lookup_actions.d.ts +1 -1
  94. package/dist/auth/actor_lookup_actions.d.ts.map +1 -1
  95. package/dist/auth/actor_lookup_actions.js +1 -1
  96. package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
  97. package/dist/auth/actor_search_action_specs.js +2 -1
  98. package/dist/auth/actor_search_actions.d.ts +1 -1
  99. package/dist/auth/actor_search_actions.d.ts.map +1 -1
  100. package/dist/auth/actor_search_actions.js +1 -1
  101. package/dist/auth/actor_search_queries.d.ts +5 -5
  102. package/dist/auth/actor_search_queries.d.ts.map +1 -1
  103. package/dist/auth/actor_search_queries.js +7 -7
  104. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  105. package/dist/auth/admin_action_specs.js +3 -1
  106. package/dist/auth/admin_actions.d.ts +1 -1
  107. package/dist/auth/admin_actions.d.ts.map +1 -1
  108. package/dist/auth/admin_actions.js +12 -42
  109. package/dist/auth/all_cell_actions.d.ts +6 -4
  110. package/dist/auth/all_cell_actions.d.ts.map +1 -1
  111. package/dist/auth/all_cell_actions.js +1 -1
  112. package/dist/auth/api_token_queries.d.ts +1 -0
  113. package/dist/auth/api_token_queries.d.ts.map +1 -1
  114. package/dist/auth/api_token_queries.js +1 -0
  115. package/dist/auth/audit_emitter.d.ts +3 -3
  116. package/dist/auth/audit_emitter.js +2 -2
  117. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  118. package/dist/auth/audit_log_route_schema.js +3 -2
  119. package/dist/auth/audit_log_routes.d.ts +20 -11
  120. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  121. package/dist/auth/audit_log_routes.js +49 -29
  122. package/dist/auth/audit_log_schema.d.ts +13 -21
  123. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  124. package/dist/auth/audit_log_schema.js +10 -18
  125. package/dist/auth/bearer_auth.d.ts +7 -4
  126. package/dist/auth/bearer_auth.d.ts.map +1 -1
  127. package/dist/auth/bearer_auth.js +21 -15
  128. package/dist/auth/cell_action_helpers.d.ts +89 -0
  129. package/dist/auth/cell_action_helpers.d.ts.map +1 -0
  130. package/dist/auth/cell_action_helpers.js +113 -0
  131. package/dist/auth/cell_actions.d.ts +22 -13
  132. package/dist/auth/cell_actions.d.ts.map +1 -1
  133. package/dist/auth/cell_actions.js +105 -167
  134. package/dist/auth/cell_audit_actions.d.ts +1 -1
  135. package/dist/auth/cell_audit_actions.d.ts.map +1 -1
  136. package/dist/auth/cell_audit_actions.js +3 -12
  137. package/dist/auth/cell_audit_metadata.d.ts +1 -1
  138. package/dist/auth/cell_audit_metadata.js +1 -1
  139. package/dist/auth/cell_field_actions.d.ts +1 -1
  140. package/dist/auth/cell_field_actions.d.ts.map +1 -1
  141. package/dist/auth/cell_field_actions.js +16 -66
  142. package/dist/auth/cell_grant_action_specs.d.ts +2 -2
  143. package/dist/auth/cell_grant_action_specs.js +3 -3
  144. package/dist/auth/cell_grant_actions.d.ts +73 -11
  145. package/dist/auth/cell_grant_actions.d.ts.map +1 -1
  146. package/dist/auth/cell_grant_actions.js +63 -55
  147. package/dist/auth/cell_grant_audit_metadata.d.ts +6 -3
  148. package/dist/auth/cell_grant_audit_metadata.d.ts.map +1 -1
  149. package/dist/auth/cell_grant_audit_metadata.js +7 -4
  150. package/dist/auth/cell_item_actions.d.ts +1 -1
  151. package/dist/auth/cell_item_actions.d.ts.map +1 -1
  152. package/dist/auth/cell_item_actions.js +21 -82
  153. package/dist/auth/cleanup.d.ts +1 -1
  154. package/dist/auth/cleanup.d.ts.map +1 -1
  155. package/dist/auth/cleanup.js +6 -3
  156. package/dist/auth/credential_deadline.d.ts +3 -3
  157. package/dist/auth/credential_deadline.js +3 -3
  158. package/dist/auth/credential_type_schema.d.ts +5 -5
  159. package/dist/auth/credential_type_schema.js +5 -5
  160. package/dist/auth/daemon_token_middleware.d.ts +12 -6
  161. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  162. package/dist/auth/daemon_token_middleware.js +28 -17
  163. package/dist/auth/deps.d.ts +4 -4
  164. package/dist/auth/fail_floor.d.ts +55 -0
  165. package/dist/auth/fail_floor.d.ts.map +1 -0
  166. package/dist/auth/fail_floor.js +63 -0
  167. package/dist/auth/invite_queries.d.ts +3 -15
  168. package/dist/auth/invite_queries.d.ts.map +1 -1
  169. package/dist/auth/invite_queries.js +3 -21
  170. package/dist/auth/middleware.d.ts +12 -7
  171. package/dist/auth/middleware.d.ts.map +1 -1
  172. package/dist/auth/middleware.js +42 -29
  173. package/dist/auth/migrations.d.ts +5 -33
  174. package/dist/auth/migrations.d.ts.map +1 -1
  175. package/dist/auth/migrations.js +9 -16
  176. package/dist/auth/request_context.d.ts +101 -71
  177. package/dist/auth/request_context.d.ts.map +1 -1
  178. package/dist/auth/request_context.js +137 -140
  179. package/dist/auth/resolved_auth.d.ts +122 -36
  180. package/dist/auth/resolved_auth.d.ts.map +1 -1
  181. package/dist/auth/resolved_auth.js +89 -38
  182. package/dist/auth/role_grant_offer_action_specs.d.ts +99 -14
  183. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  184. package/dist/auth/role_grant_offer_action_specs.js +26 -13
  185. package/dist/auth/role_grant_offer_actions.d.ts +13 -7
  186. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  187. package/dist/auth/role_grant_offer_actions.js +14 -12
  188. package/dist/auth/role_grant_offer_notifications.d.ts +3 -3
  189. package/dist/auth/role_grant_offer_notifications.js +1 -1
  190. package/dist/auth/role_grant_offer_queries.d.ts +0 -5
  191. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  192. package/dist/auth/role_grant_offer_queries.js +9 -41
  193. package/dist/auth/role_grant_queries.d.ts +17 -67
  194. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  195. package/dist/auth/role_grant_queries.js +34 -106
  196. package/dist/auth/role_grant_sql.d.ts +42 -0
  197. package/dist/auth/role_grant_sql.d.ts.map +1 -0
  198. package/dist/auth/role_grant_sql.js +54 -0
  199. package/dist/auth/scope_kind_schema.d.ts +1 -1
  200. package/dist/auth/scope_kind_schema.js +1 -1
  201. package/dist/auth/self_service_role_actions.d.ts +1 -1
  202. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  203. package/dist/auth/self_service_role_actions.js +1 -1
  204. package/dist/auth/session_queries.d.ts +2 -1
  205. package/dist/auth/session_queries.d.ts.map +1 -1
  206. package/dist/auth/session_queries.js +2 -1
  207. package/dist/auth/signup_routes.d.ts +2 -1
  208. package/dist/auth/signup_routes.d.ts.map +1 -1
  209. package/dist/auth/signup_routes.js +14 -13
  210. package/dist/auth/standard_rpc_actions.d.ts +1 -1
  211. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  212. package/dist/auth/token_scope.d.ts +19 -46
  213. package/dist/auth/token_scope.d.ts.map +1 -1
  214. package/dist/auth/token_scope.js +23 -41
  215. package/dist/db/CLAUDE.md +9 -4
  216. package/dist/db/cell_ddl.d.ts +5 -142
  217. package/dist/db/cell_ddl.d.ts.map +1 -1
  218. package/dist/db/cell_ddl.js +17 -16
  219. package/dist/db/cell_field_queries.d.ts +0 -13
  220. package/dist/db/cell_field_queries.d.ts.map +1 -1
  221. package/dist/db/cell_field_queries.js +0 -16
  222. package/dist/db/cell_grant_queries.d.ts +10 -5
  223. package/dist/db/cell_grant_queries.d.ts.map +1 -1
  224. package/dist/db/cell_grant_queries.js +13 -7
  225. package/dist/db/cell_item_queries.d.ts +0 -7
  226. package/dist/db/cell_item_queries.d.ts.map +1 -1
  227. package/dist/db/cell_item_queries.js +0 -10
  228. package/dist/db/cell_queries.d.ts +12 -48
  229. package/dist/db/cell_queries.d.ts.map +1 -1
  230. package/dist/db/cell_queries.js +24 -55
  231. package/dist/db/cell_view_sql.d.ts +1 -6
  232. package/dist/db/cell_view_sql.d.ts.map +1 -1
  233. package/dist/db/cell_view_sql.js +1 -2
  234. package/dist/db/fact_ddl.d.ts +5 -30
  235. package/dist/db/fact_ddl.d.ts.map +1 -1
  236. package/dist/db/fact_ddl.js +14 -13
  237. package/dist/db/fact_store.d.ts +11 -0
  238. package/dist/db/fact_store.d.ts.map +1 -1
  239. package/dist/db/fact_store.js +4 -1
  240. package/dist/db/migrate.d.ts +44 -6
  241. package/dist/db/migrate.d.ts.map +1 -1
  242. package/dist/db/migrate.js +63 -4
  243. package/dist/dev/setup.d.ts +18 -14
  244. package/dist/dev/setup.d.ts.map +1 -1
  245. package/dist/dev/setup.js +42 -39
  246. package/dist/env/dotenv.d.ts +2 -2
  247. package/dist/env/dotenv.js +2 -2
  248. package/dist/env/update_env_variable.d.ts +33 -21
  249. package/dist/env/update_env_variable.d.ts.map +1 -1
  250. package/dist/env/update_env_variable.js +54 -35
  251. package/dist/hono_context.d.ts +15 -90
  252. package/dist/hono_context.d.ts.map +1 -1
  253. package/dist/hono_context.js +9 -56
  254. package/dist/http/CLAUDE.md +35 -20
  255. package/dist/http/auth_shape.d.ts +1 -8
  256. package/dist/http/auth_shape.d.ts.map +1 -1
  257. package/dist/http/auth_shape.js +6 -12
  258. package/dist/http/common_routes.d.ts.map +1 -1
  259. package/dist/http/common_routes.js +3 -2
  260. package/dist/http/db_routes.d.ts +3 -3
  261. package/dist/http/db_routes.js +3 -3
  262. package/dist/http/error_schemas.d.ts +1 -2
  263. package/dist/http/error_schemas.d.ts.map +1 -1
  264. package/dist/http/error_schemas.js +1 -2
  265. package/dist/http/health_schema.d.ts +16 -0
  266. package/dist/http/health_schema.d.ts.map +1 -0
  267. package/dist/http/health_schema.js +12 -0
  268. package/dist/http/jsonrpc_errors.d.ts +22 -2
  269. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  270. package/dist/http/jsonrpc_errors.js +41 -3
  271. package/dist/http/jsonrpc_helpers.d.ts +60 -17
  272. package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
  273. package/dist/http/jsonrpc_helpers.js +67 -25
  274. package/dist/http/origin.d.ts +30 -1
  275. package/dist/http/origin.d.ts.map +1 -1
  276. package/dist/http/origin.js +46 -9
  277. package/dist/http/origin_wildcard.d.ts +97 -0
  278. package/dist/http/origin_wildcard.d.ts.map +1 -0
  279. package/dist/http/origin_wildcard.js +142 -0
  280. package/dist/http/pending_effects.d.ts +28 -0
  281. package/dist/http/pending_effects.d.ts.map +1 -1
  282. package/dist/http/pending_effects.js +32 -1
  283. package/dist/http/route_spec.d.ts +4 -3
  284. package/dist/http/route_spec.d.ts.map +1 -1
  285. package/dist/http/route_spec.js +54 -45
  286. package/dist/http/surface.d.ts +1 -1
  287. package/dist/http/surface.d.ts.map +1 -1
  288. package/dist/http/surface_query.d.ts +9 -50
  289. package/dist/http/surface_query.d.ts.map +1 -1
  290. package/dist/http/surface_query.js +48 -94
  291. package/dist/realtime/audit_log_sse.d.ts +180 -0
  292. package/dist/realtime/audit_log_sse.d.ts.map +1 -0
  293. package/dist/realtime/audit_log_sse.js +154 -0
  294. package/dist/realtime/sse.d.ts +21 -6
  295. package/dist/realtime/sse.d.ts.map +1 -1
  296. package/dist/realtime/sse.js +33 -10
  297. package/dist/realtime/sse_constants.d.ts +29 -2
  298. package/dist/realtime/sse_constants.d.ts.map +1 -1
  299. package/dist/realtime/sse_constants.js +35 -2
  300. package/dist/realtime/{subscriber_registry.d.ts → sse_registry.d.ts} +12 -12
  301. package/dist/realtime/sse_registry.d.ts.map +1 -0
  302. package/dist/realtime/{subscriber_registry.js → sse_registry.js} +4 -4
  303. package/dist/schema_meta.d.ts +30 -10
  304. package/dist/schema_meta.d.ts.map +1 -1
  305. package/dist/schema_meta.js +85 -21
  306. package/dist/sensitivity.d.ts +9 -3
  307. package/dist/sensitivity.d.ts.map +1 -1
  308. package/dist/sensitivity.js +3 -2
  309. package/dist/server/app_backend.d.ts +8 -5
  310. package/dist/server/app_backend.d.ts.map +1 -1
  311. package/dist/server/app_backend.js +6 -12
  312. package/dist/server/app_server.d.ts +62 -51
  313. package/dist/server/app_server.d.ts.map +1 -1
  314. package/dist/server/app_server.js +84 -71
  315. package/dist/server/app_server_context.d.ts +1 -1
  316. package/dist/server/app_server_context.d.ts.map +1 -1
  317. package/dist/server/env.d.ts +24 -20
  318. package/dist/server/env.d.ts.map +1 -1
  319. package/dist/server/env.js +24 -34
  320. package/dist/server/serve_fact_route.d.ts +12 -16
  321. package/dist/server/serve_fact_route.d.ts.map +1 -1
  322. package/dist/server/serve_fact_route.js +59 -34
  323. package/dist/server/static.d.ts.map +1 -1
  324. package/dist/server/static.js +2 -2
  325. package/dist/testing/CLAUDE.md +179 -158
  326. package/dist/testing/admin_integration.d.ts.map +1 -1
  327. package/dist/testing/admin_integration.js +10 -19
  328. package/dist/testing/adversarial_headers.d.ts.map +1 -1
  329. package/dist/testing/adversarial_headers.js +8 -0
  330. package/dist/testing/app_server.d.ts +9 -77
  331. package/dist/testing/app_server.d.ts.map +1 -1
  332. package/dist/testing/app_server.js +31 -112
  333. package/dist/testing/attack_surface.d.ts.map +1 -1
  334. package/dist/testing/attack_surface.js +3 -4
  335. package/dist/testing/audit_completeness.d.ts.map +1 -1
  336. package/dist/testing/audit_completeness.js +4 -5
  337. package/dist/testing/auth_apps.d.ts +3 -3
  338. package/dist/testing/auth_apps.d.ts.map +1 -1
  339. package/dist/testing/auth_apps.js +9 -6
  340. package/dist/testing/connection_closer_helpers.d.ts +8 -16
  341. package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
  342. package/dist/testing/connection_closer_helpers.js +7 -20
  343. package/dist/testing/cross_backend/action_manifest.d.ts +15 -4
  344. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  345. package/dist/testing/cross_backend/action_manifest.js +13 -3
  346. package/dist/testing/cross_backend/action_manifest_parity.d.ts +15 -7
  347. package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
  348. package/dist/testing/cross_backend/action_manifest_parity.js +8 -1
  349. package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
  350. package/dist/testing/cross_backend/body_size.js +25 -22
  351. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +22 -3
  352. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  353. package/dist/testing/cross_backend/build_test_backend_paths.js +34 -11
  354. package/dist/testing/cross_backend/capabilities.d.ts +13 -7
  355. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  356. package/dist/testing/cross_backend/cell_grant_role.js +2 -2
  357. package/dist/testing/cross_backend/cell_grant_steward.d.ts +4 -0
  358. package/dist/testing/cross_backend/cell_grant_steward.d.ts.map +1 -0
  359. package/dist/testing/cross_backend/cell_grant_steward.js +120 -0
  360. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  361. package/dist/testing/cross_backend/cell_relations.js +21 -0
  362. package/dist/testing/cross_backend/conformance_table.d.ts +1 -1
  363. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  364. package/dist/testing/cross_backend/default_backend_configs.d.ts +18 -4
  365. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  366. package/dist/testing/cross_backend/default_backend_configs.js +29 -9
  367. package/dist/testing/cross_backend/default_spine_surface.d.ts +7 -7
  368. package/dist/testing/cross_backend/default_spine_surface.js +2 -2
  369. package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
  370. package/dist/testing/cross_backend/fact_serving.js +48 -0
  371. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -4
  372. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  373. package/dist/testing/cross_backend/full_spine_mount.js +9 -2
  374. package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -1
  375. package/dist/testing/cross_backend/origin_scope.js +5 -13
  376. package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
  377. package/dist/testing/cross_backend/peer_ping_ws.js +29 -4
  378. package/dist/testing/cross_backend/postgres_database.d.ts +32 -0
  379. package/dist/testing/cross_backend/postgres_database.d.ts.map +1 -1
  380. package/dist/testing/cross_backend/postgres_database.js +56 -1
  381. package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
  382. package/dist/testing/cross_backend/query_shape.js +18 -1
  383. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  384. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +23 -1
  385. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -2
  386. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
  387. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  388. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +17 -5
  389. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  390. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +5 -4
  391. package/dist/testing/cross_backend/session_cap.d.ts +8 -0
  392. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  393. package/dist/testing/cross_backend/session_cap.js +66 -2
  394. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  395. package/dist/testing/cross_backend/setup.js +5 -4
  396. package/dist/testing/cross_backend/spine_suites.d.ts +4 -1
  397. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  398. package/dist/testing/cross_backend/spine_suites.js +21 -0
  399. package/dist/testing/cross_backend/spine_surface_constants.d.ts +22 -7
  400. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  401. package/dist/testing/cross_backend/spine_surface_constants.js +22 -7
  402. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  403. package/dist/testing/cross_backend/sse_round_trip.js +4 -3
  404. package/dist/testing/cross_backend/standard.d.ts +6 -12
  405. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  406. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts +8 -0
  407. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts.map +1 -0
  408. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.js +22 -0
  409. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  410. package/dist/testing/cross_backend/testing_backdoor.js +4 -6
  411. package/dist/testing/cross_backend/testing_origin_check.d.ts +1 -1
  412. package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
  413. package/dist/testing/cross_backend/testing_origin_check.js +1 -1
  414. package/dist/testing/cross_backend/testing_reset_actions.d.ts +10 -5
  415. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  416. package/dist/testing/cross_backend/testing_reset_actions.js +7 -6
  417. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  418. package/dist/testing/cross_backend/testing_server_bun.js +5 -4
  419. package/dist/testing/cross_backend/testing_server_core.d.ts +6 -7
  420. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  421. package/dist/testing/cross_backend/testing_server_core.js +1 -1
  422. package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
  423. package/dist/testing/cross_backend/testing_server_node.js +13 -2
  424. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  425. package/dist/testing/cross_backend/token_lifetime.js +68 -0
  426. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  427. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  428. package/dist/testing/cross_backend/transport_composition.js +45 -3
  429. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +16 -2
  430. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  431. package/dist/testing/cross_backend/ts_spine_backend_config.js +11 -8
  432. package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
  433. package/dist/testing/cross_backend/ws_action_rate_limit.js +30 -12
  434. package/dist/testing/cross_backend/ws_connection_cap.d.ts.map +1 -1
  435. package/dist/testing/cross_backend/ws_connection_cap.js +5 -7
  436. package/dist/testing/cross_backend/ws_endpoint.d.ts +2 -3
  437. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  438. package/dist/testing/cross_backend/ws_envelope.d.ts +17 -0
  439. package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -0
  440. package/dist/testing/cross_backend/ws_envelope.js +172 -0
  441. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts +16 -0
  442. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts.map +1 -1
  443. package/dist/testing/cross_backend/ws_inbound_dispatch.js +8 -4
  444. package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
  445. package/dist/testing/cross_backend/ws_outbound_overflow.js +5 -8
  446. package/dist/testing/cross_backend/ws_role_gated.js +2 -2
  447. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  448. package/dist/testing/cross_backend/ws_round_trip.js +6 -4
  449. package/dist/{cli/daemon.d.ts → testing/daemon_info.d.ts} +15 -47
  450. package/dist/testing/daemon_info.d.ts.map +1 -0
  451. package/dist/testing/daemon_info.js +108 -0
  452. package/dist/testing/daemon_token_rotation.js +1 -1
  453. package/dist/testing/data_exposure.d.ts.map +1 -1
  454. package/dist/testing/data_exposure.js +3 -4
  455. package/dist/testing/db.js +2 -2
  456. package/dist/testing/integration.d.ts.map +1 -1
  457. package/dist/testing/integration.js +35 -65
  458. package/dist/testing/integration_helpers.d.ts +0 -15
  459. package/dist/testing/integration_helpers.d.ts.map +1 -1
  460. package/dist/testing/integration_helpers.js +2 -42
  461. package/dist/testing/middleware.d.ts +20 -12
  462. package/dist/testing/middleware.d.ts.map +1 -1
  463. package/dist/testing/middleware.js +49 -40
  464. package/dist/testing/rate_limiting.d.ts.map +1 -1
  465. package/dist/testing/rate_limiting.js +13 -22
  466. package/dist/testing/resolved_auth.d.ts +30 -0
  467. package/dist/testing/resolved_auth.d.ts.map +1 -0
  468. package/dist/testing/resolved_auth.js +41 -0
  469. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  470. package/dist/testing/rpc_envelope_cases.js +3 -0
  471. package/dist/testing/rpc_helpers.d.ts +1 -1
  472. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  473. package/dist/testing/rpc_helpers.js +2 -1
  474. package/dist/testing/sse_round_trip.d.ts +5 -4
  475. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  476. package/dist/testing/sse_round_trip.js +2 -2
  477. package/dist/testing/stubs.d.ts +2 -2
  478. package/dist/testing/stubs.d.ts.map +1 -1
  479. package/dist/testing/stubs.js +24 -21
  480. package/dist/testing/test_origin.d.ts +25 -0
  481. package/dist/testing/test_origin.d.ts.map +1 -0
  482. package/dist/testing/test_origin.js +28 -0
  483. package/dist/testing/transports/raw_http.d.ts +54 -0
  484. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  485. package/dist/testing/transports/raw_http.js +58 -0
  486. package/dist/testing/transports/ws_raw_client.d.ts +8 -0
  487. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  488. package/dist/testing/transports/ws_raw_client.js +13 -0
  489. package/dist/testing/transports/ws_transport.d.ts +15 -2
  490. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  491. package/dist/testing/transports/ws_transport.js +4 -2
  492. package/dist/testing/ws_round_trip.d.ts +27 -25
  493. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  494. package/dist/testing/ws_round_trip.js +34 -26
  495. package/dist/ui/AccountSessions.svelte +48 -19
  496. package/dist/ui/AccountSessions.svelte.d.ts +2 -17
  497. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
  498. package/dist/ui/AdminAccounts.svelte +6 -1
  499. package/dist/ui/AdminAuditLog.svelte +61 -22
  500. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
  501. package/dist/ui/AdminInvites.svelte +1 -1
  502. package/dist/ui/AdminOverview.svelte +76 -37
  503. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  504. package/dist/ui/AdminRoleGrantHistory.svelte +6 -1
  505. package/dist/ui/AdminSessions.svelte +1 -1
  506. package/dist/ui/AppShell.svelte +3 -2
  507. package/dist/ui/AppShell.svelte.d.ts +3 -2
  508. package/dist/ui/AppShell.svelte.d.ts.map +1 -1
  509. package/dist/ui/CLAUDE.md +121 -35
  510. package/dist/ui/Datatable.svelte +33 -18
  511. package/dist/ui/Datatable.svelte.d.ts +2 -14
  512. package/dist/ui/Datatable.svelte.d.ts.map +1 -1
  513. package/dist/ui/OpenSignupToggle.svelte +10 -1
  514. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
  515. package/dist/ui/PopoverButton.svelte +13 -8
  516. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
  517. package/dist/ui/RoleGrantOfferForm.svelte +3 -2
  518. package/dist/ui/RoleGrantOfferForm.svelte.d.ts +3 -2
  519. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
  520. package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
  521. package/dist/ui/RoleGrantOfferInbox.svelte +19 -15
  522. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
  523. package/dist/ui/SurfaceExplorer.svelte +66 -27
  524. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  525. package/dist/ui/account_sessions_state.svelte.d.ts +7 -14
  526. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  527. package/dist/ui/admin_accounts_state.svelte.d.ts +14 -9
  528. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  529. package/dist/ui/admin_accounts_state.svelte.js +6 -4
  530. package/dist/ui/admin_invites_state.svelte.d.ts +2 -2
  531. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
  532. package/dist/ui/admin_rpc_adapters.d.ts +9 -9
  533. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  534. package/dist/ui/admin_rpc_adapters.js +9 -9
  535. package/dist/ui/app_settings_state.svelte.d.ts +2 -2
  536. package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
  537. package/dist/ui/audit_log_state.svelte.d.ts +70 -13
  538. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  539. package/dist/ui/audit_log_state.svelte.js +239 -47
  540. package/dist/ui/backend_probe.svelte.d.ts +93 -0
  541. package/dist/ui/backend_probe.svelte.d.ts.map +1 -0
  542. package/dist/ui/backend_probe.svelte.js +140 -0
  543. package/dist/ui/format_scope.d.ts +7 -7
  544. package/dist/ui/format_scope.d.ts.map +1 -1
  545. package/dist/ui/format_scope.js +4 -4
  546. package/dist/ui/keyed_async_slot.svelte.d.ts +2 -2
  547. package/dist/ui/keyed_async_slot.svelte.js +2 -2
  548. package/dist/ui/popover.svelte.d.ts +18 -19
  549. package/dist/ui/popover.svelte.d.ts.map +1 -1
  550. package/dist/ui/popover.svelte.js +103 -16
  551. package/dist/ui/role_grant_offers_state.svelte.d.ts +41 -46
  552. package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
  553. package/dist/ui/role_grant_offers_state.svelte.js +37 -19
  554. package/dist/ui/ui_format.d.ts +17 -0
  555. package/dist/ui/ui_format.d.ts.map +1 -1
  556. package/dist/ui/ui_format.js +20 -0
  557. package/package.json +9 -8
  558. package/dist/actions/register_ws_endpoint.d.ts +0 -79
  559. package/dist/actions/register_ws_endpoint.d.ts.map +0 -1
  560. package/dist/actions/register_ws_endpoint.js +0 -109
  561. package/dist/actions/transports_ws_auth_guard.d.ts +0 -96
  562. package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
  563. package/dist/actions/transports_ws_auth_guard.js +0 -141
  564. package/dist/actions/transports_ws_backend.d.ts.map +0 -1
  565. package/dist/cli/args.d.ts +0 -55
  566. package/dist/cli/args.d.ts.map +0 -1
  567. package/dist/cli/args.js +0 -100
  568. package/dist/cli/config.d.ts +0 -47
  569. package/dist/cli/config.d.ts.map +0 -1
  570. package/dist/cli/config.js +0 -77
  571. package/dist/cli/daemon.d.ts.map +0 -1
  572. package/dist/cli/daemon.js +0 -181
  573. package/dist/cli/help.d.ts +0 -124
  574. package/dist/cli/help.d.ts.map +0 -1
  575. package/dist/cli/help.js +0 -215
  576. package/dist/cli/logger.d.ts +0 -46
  577. package/dist/cli/logger.d.ts.map +0 -1
  578. package/dist/cli/logger.js +0 -48
  579. package/dist/cli/util.d.ts +0 -36
  580. package/dist/cli/util.d.ts.map +0 -1
  581. package/dist/cli/util.js +0 -50
  582. package/dist/realtime/sse_auth_guard.d.ts +0 -197
  583. package/dist/realtime/sse_auth_guard.d.ts.map +0 -1
  584. package/dist/realtime/sse_auth_guard.js +0 -239
  585. package/dist/realtime/subscriber_registry.d.ts.map +0 -1
  586. package/dist/testing/bootstrap_success.d.ts +0 -29
  587. package/dist/testing/bootstrap_success.d.ts.map +0 -1
  588. package/dist/testing/bootstrap_success.js +0 -144
  589. package/dist/testing/mock_fs.d.ts +0 -20
  590. package/dist/testing/mock_fs.d.ts.map +0 -1
  591. package/dist/testing/mock_fs.js +0 -28
  592. package/dist/testing/standard.d.ts +0 -122
  593. package/dist/testing/standard.d.ts.map +0 -1
  594. package/dist/testing/standard.js +0 -73
  595. package/dist/testing/testing_rate_limiter.d.ts +0 -65
  596. package/dist/testing/testing_rate_limiter.d.ts.map +0 -1
  597. package/dist/testing/testing_rate_limiter.js +0 -80
@@ -1,12 +1,12 @@
1
1
  # actions/ — SAES (Symmetric Action Event System)
2
2
 
3
- > One declarative `ActionSpec` binds to three transport surfaces (REST,
4
- > JSON-RPC over HTTP, WebSocket) with uniform DEV-only output validation and
5
- > symmetric send/receive.
3
+ > One declarative `ActionSpec` binds to two transport surfaces (JSON-RPC over
4
+ > HTTP, WebSocket) with uniform DEV-only output validation and symmetric
5
+ > send/receive.
6
6
 
7
7
  For consumer wiring (client-authoritative vs server-authoritative dispatch,
8
8
  role-grant-offer UI integration), see ../../../docs/usage.md §Deriving
9
- Route/Event Specs, §Single JSON-RPC 2.0 Endpoint, §WebSocket Endpoint. For
9
+ Event Specs from Action Specs, §Single JSON-RPC 2.0 Endpoint, §WebSocket Endpoint. For
10
10
  DEV-only output validation semantics see ../../../docs/architecture.md
11
11
  §DEV-only Output Validation. For the SAES binding matrix and middleware
12
12
  ordering see the root ../../../CLAUDE.md §Action Spec System (SAES) and
@@ -32,7 +32,7 @@ Canonical source of truth. Three concrete kinds discriminate on `kind`:
32
32
  `RouteAuth` is the flat record
33
33
  `{account, actor, roles?, credential_types?, required_scope?}` from
34
34
  `http/auth_shape.ts` — same shape governs `RouteSpec.auth` so one auth
35
- surface drives REST and SAES. Cross-axis invariants: roles imply
35
+ surface drives routes and SAES. Cross-axis invariants: roles imply
36
36
  `actor: 'required'`; `account: 'none'` implies `actor: 'none'` (no
37
37
  accountless actors in v1); the unrestricted leaf
38
38
  (`account: 'none', actor: 'none'`) cannot declare roles or credential
@@ -65,13 +65,11 @@ dropping per-spec `*_METHOD` constants (readers dereference `.method`). See
65
65
 
66
66
  ## Kind → binding matrix
67
67
 
68
- - `request_response` — REST `RouteSpec` via bridge; RPC `RouteSpec` via `create_rpc_endpoint`; WS dispatch yes; no SSE.
69
- - `remote_notification` — no REST/RPC routes; WS server push; SSE `EventSpec` via bridge.
70
- - `local_call` — none (no REST, no RPC, no WS, no SSE).
68
+ - `request_response` — RPC `RouteSpec` via `create_rpc_endpoint`; WS dispatch yes; no SSE.
69
+ - `remote_notification` — no RPC routes; WS server push; SSE `EventSpec` via `create_action_event_spec`.
70
+ - `local_call` — none (no RPC, no WS, no SSE).
71
71
 
72
- `create_action_route_spec` throws if `spec.auth` is null (notifications and
73
- local calls cannot become routes) or `spec.rate_limit` is set (a bridged route
74
- never reaches the `perform_action` limiters). `create_action_event_spec` throws on any
72
+ `create_action_event_spec` (`actions/action_bridge.ts`) throws on any
75
73
  non-`remote_notification` kind.
76
74
 
77
75
  ## Registry compile (`actions/compile_action_registry.ts`)
@@ -128,25 +126,20 @@ and options on each function's TSDoc.
128
126
  - `get_executor_phases(spec, executor)` — phases an executor participates in for the spec.
129
127
  - `get_handler_return_type` — TS type a phase handler must return; side-effect imports `ActionOutputs`.
130
128
  - `generate_phase_handlers` — per-action typed handler-map fragment.
131
- - `generate_actions_api_method_signature` — single source of truth for the typed `FrontendActionsApi` method shape. Its `input?:` follows `action_input_is_optional` — the schema accepts `undefined`, or accepts `{}` and is not marked `.meta({empty_input_handler_guarded: true})` (`SchemaFieldMeta`, read by `is_empty_input_handler_guarded` in `schema_meta.ts` — set on `cell_get`, `cell_field_list` and `cell_item_list`, whose `{}` reaches a handler guard that refuses it with a declared reason, so their input stays required; a consumer marks its own the same way); an input-shape invariant test reads the same rule.
129
+ - `generate_frontend_actions_api` — typed `FrontendActionsApi` interface. Each method's `input?:` follows `action_input_is_optional` — the schema accepts `undefined`, or accepts `{}` and is not marked `.meta({empty_input_handler_guarded: true})` (`SchemaFieldMeta`, read by `is_empty_input_handler_guarded` in `schema_meta.ts` — set on `cell_get`, `cell_field_list` and `cell_item_list`, whose `{}` reaches a handler guard that refuses it with a declared reason, so their input stays required; a consumer marks its own the same way); an input-shape invariant test reads the same rule.
132
130
  - `generate_action_method_enums` — up to nine `z.enum` + `z.infer` pairs.
133
- - `generate_action_method_enum_block` — lower-level escape hatch for cross-product enums.
134
131
  - `generate_typed_action_event_alias` — fixed-shape `TypedActionEvent<TMethod, TPhase, TStep>` alias.
135
132
  - `generate_action_specs_record` — `ActionSpecs` runtime const + interface + `action_specs` array.
136
133
  - `generate_action_inputs_outputs` — `ActionInputs` + `ActionOutputs` runtime consts + interfaces.
137
134
  - `generate_action_event_datas` — `ActionEventDatas` interface; per-spec variants.
138
- - `generate_frontend_actions_api` — typed `FrontendActionsApi` interface.
139
135
  - `generate_frontend_action_handlers` — `FrontendActionHandlers` interface (Tier 2 only).
140
136
  - `generate_backend_actions_api` — `BackendActionsApi` interface + `broadcast_action_specs` array.
141
- - `generate_backend_action_handlers_map` — `BackendActionHandlers` mapped type.
142
137
  - `compose_gen_file` — wrapper: banner + `imports.build()` + blocks join.
143
138
  - `create_namespace_qualifier(sources, imports)` — multi-source consumer helper; registers `import * as ns` per source.
144
139
 
145
- Shared defaults: `DEFAULT_COLLECTIONS_PATH = './action_collections.ts'`,
146
- `DEFAULT_SPECS_MODULE = './action_specs.ts'`,
147
- `DEFAULT_METATYPES_PATH = './action_metatypes.ts'`,
148
- `resolve_spec_qualifier` (the default-vs-callback resolver every
149
- multi-source-aware helper uses).
140
+ Shared defaults: `collections_path` is `'./action_collections.ts'`,
141
+ `specs_module` is `'./action_specs.ts'`, and `metatypes_path` is
142
+ `'./action_metatypes.ts'`.
150
143
 
151
144
  ### Codegen invariants
152
145
 
@@ -173,40 +166,13 @@ Never calls `generate_typed_action_event_alias` or
173
166
  zzz) emits the full set including `ActionEventDatas`, `TypedActionEvent`,
174
167
  and `FrontendActionHandlers`.
175
168
 
176
- ## HTTP bridge (`actions/action_bridge.ts`)
177
-
178
- Derives transport-specific specs from action specs. HTTP-specific concerns
179
- (path, handler, errors) come from options, not the action spec.
180
-
181
- - `create_action_route_spec(spec, options)` — one action → one `RouteSpec`. HTTP method defaults by `side_effects` (`true` → POST, `false` → GET; override via `options.http_method`). `route.auth` is `spec.auth` plus a derived `required_scope`. `transaction: spec.side_effects`. Throws if `spec.auth` is null, or if `spec.rate_limit` is set (the action limiters run in `perform_action`, which a bridged route never reaches).
182
-
183
- **The bridge carries the token-scope gate across.** A bridged route runs
184
- `options.handler` through the REST pipeline and never reaches
185
- `perform_action`, so the dispatcher's per-method scope check cannot fire on it
186
- — leaving a bearer-reachable surface a **narrowed** token walks through, which
187
- is what the RPC-only rule exists to prevent. So the derived spec declares
188
- `auth.required_scope: 'rpc:<method>'` and `fuz_auth_guard_resolver` mounts the
189
- refusal ahead of the role gate. Per-method rather than a blanket refusal
190
- because a bridged route _has_ a method identity, which the non-RPC surfaces
191
- the RPC-only rule covers do not.
192
-
193
- Bridge something with no request/response shape — an SSE stream, a file
194
- download — and the whole-surface rule applies instead: pass `options.auth` with
195
- `required_scope: 'surface:<name>'`, naming your own surface (the vocabulary is
196
- open on the identifier). An `options.auth` that omits `required_scope` still
197
- gets the derived one; public actions get none (the guard would enforce
198
- nothing). fuz_app mounts no bridged routes itself; this is consumer-facing.
199
-
200
- - `create_action_event_spec(spec, {channel?})` — one notification action → one `EventSpec` for SSE surface + `create_validated_broadcaster`. Throws on non-`remote_notification` kind.
201
- - `derive_http_method(side_effects)` — exported for custom bridges.
202
-
203
169
  ## Single JSON-RPC 2.0 endpoint (`actions/action_rpc.ts`)
204
170
 
205
171
  `create_rpc_endpoint({path, actions, log, action_ip_rate_limiter, action_account_rate_limiter}): RouteSpec[]`
206
172
  produces **two** route specs on the same path (GET + POST) that share one
207
173
  internal dispatcher. The two limiters are required `RateLimiter | null` with
208
174
  no default — `null` is the explicit off switch — and the same holds on
209
- `register_action_ws` / `register_ws_endpoint`, so a hand mount can't run
175
+ `register_action_ws`, so a hand mount can't run
210
176
  unthrottled by omission. `create_app_server` passes its own to every endpoint
211
177
  it mounts (../../../docs/usage.md §Rate limiters). Per-action auth lives inside the dispatcher; the outer routes
212
178
  use `auth: {account: 'none', actor: 'none'}` and `transaction: false`.
@@ -230,27 +196,32 @@ Shim responsibilities (per-request):
230
196
 
231
197
  1. Parse envelope (POST body / GET query string); parse errors → `parse_error` 400. GET reads `method` / `id` / `params` via Hono's `c.req.query()` — first occurrence wins on a duplicated key, unknown keys are ignored, and an empty value counts as missing. This is the cross-impl contract (the Rust GET dispatch mirrors it via `fuz_http`'s `query_first`, including the id numeric-vs-string normalization), pinned by the `query_shape` cross suite.
232
198
  2. Lookup method in the `compile_action_registry`-built map; unknown → `method_not_found`.
233
- 3. GET read restriction — GET rejected for `side_effects: true` actions.
234
- 4. Build `PerformActionInput` from `c.var` + `get_client_ip` + `c.req.raw.signal`. Test-preset escape hatch reads `TEST_CONTEXT_PRESET_KEY` + `REQUEST_CONTEXT_KEY`.
199
+ 3. GET read restriction — GET rejected for `side_effects: true` actions. Every response the GET handler writes, its refusals included, carries `Cache-Control: no-store` (`RPC_GET_CACHE_CONTROL`; a pre-handler middleware refusal, like the origin 403, does not): a read answers one caller at one moment.
200
+ 4. Build `PerformActionInput` from `get_resolved_auth(c)` + `get_client_ip` + `c.req.raw.signal`. Test-preset escape hatch reads `TEST_CONTEXT_PRESET_KEY` + `REQUEST_CONTEXT_KEY`.
235
201
  5. Call `perform_action` (shared core).
236
- 6. Bind result via `perform_action_result_to_envelope(id, result)`; `c.json(envelope, result.status)`.
237
-
238
- Error paths: `ThrownJsonrpcError` (duck-typed via `err instanceof Error &&
239
- is_jsonrpc_error_code(err.code)` to handle cross-copy `instanceof` misses,
240
- e.g. when consumers like zzz throw their own `ThrownJsonrpcError`)
241
- preserves code + data verbatim; an error whose numeric `code` is not a
242
- JSON-RPC one (a `DOMException`) takes the generic path. Generic throws become `internal_error` 500;
243
- message is the raw error under `DEV`, "internal server error" otherwise.
244
-
245
- A result `c.json` cannot serialize (a `bigint`, a cycle) answers the same
246
- `internal_error` 500 rather than throwing. By then `perform_action` has
202
+ 6. Bind result via `serialize_action_result(id, result, method, log)` (`actions/perform_action.ts`, shared with WS) → `{body, status}`, written with `c.json`'s content type.
203
+
204
+ Error paths: `ThrownJsonrpcError` (recognized through
205
+ `to_thrown_jsonrpc_error` in `http/jsonrpc_errors.ts` by its realm-global
206
+ brand, so one from a second fuz_app copy — e.g. a consumer like zzz resolving
207
+ its own — matches where `instanceof` misses; the REST catch layer, the frontend
208
+ transports, and `ActionEvent` read thrown errors the same way) preserves code +
209
+ data verbatim. Anything else takes the generic path: a foreign error class
210
+ carrying a JSON-RPC `code`, a `ThrownJsonrpcError` whose `code` was cast
211
+ outside the JSON-RPC set, a `DOMException`. Generic throws become
212
+ `internal_error` 500; message is the raw error under `DEV`, "internal server
213
+ error" otherwise.
214
+
215
+ A result that cannot be serialized (a `bigint`, a cycle) answers the same
216
+ `internal_error` 500 rather than throwing (`serialize_action_result`, which the
217
+ WS dispatcher shares). By then `perform_action` has
247
218
  committed, and a throw would have the route wrapper
248
219
  (`dispatch_with_post_commit_rollback`) discard the handler's
249
220
  `post_commit_effects` — the connection closes of a revocation that did land.
250
221
 
251
222
  ### Per-request handler shape
252
223
 
253
- Unified across HTTP RPC + WS via `ActionContext`:
224
+ Unified across HTTP RPC + WS via `ActionContext` (`actions/action_types.ts`):
254
225
 
255
226
  ```ts
256
227
  interface ActionContext {
@@ -262,7 +233,7 @@ interface ActionContext {
262
233
  pending_effects: Array<Promise<void>>; // eager — see http/CLAUDE.md §Pending Effects
263
234
  post_commit_effects: Array<() => void | Promise<void>>; // deferred — push via `emit_after_commit`
264
235
  client_ip: string;
265
- credential_type: CredentialType | null; // same value the credential_types gate consumed
236
+ credential_type: BuiltinCredentialType | null; // same value the credential_types gate consumed
266
237
  log: Logger;
267
238
  notify: (method, params) => void; // HTTP: DEV-mode warn + drop; WS: socket-scoped
268
239
  signal: AbortSignal; // HTTP: client-disconnect; WS: AbortSignal.any([socket_close, request_cancel])
@@ -313,8 +284,10 @@ Pipeline (401 → authz → 403 → 429 → 400 → handler):
313
284
  5. Validate params (400) — `spec.input.safeParse` with `z.void()` / `?? {}` rules; a `z.void()` input reads absent, `null` (GET `?params=null`), and `{}` alike as the no-arg call (`to_input_params` in `http/schema_helpers.ts`, via `to_void_params`, the twin of the Rust `require_void_params`; the peer receive path in `ActionDispatcher` runs the same normalizer) and refuses any other shape. A refusal is `to_invalid_params_error`: the generic `invalid params`, `data.reason` when the first issue's field declares an `invalid_reason` in its `.meta()` and no issue sits on the input itself, such as an unknown key (`resolve_issues_invalid_reason`, `schema_meta.ts` — see ../../../docs/architecture.md §Error Schema System), and the Zod issues DEV-only
314
285
  6. Dispatch + DEV output validation + error normalization — `spec.side_effects` picks transaction vs pool. `ThrownJsonrpcError` preserves code + data; generic throws become `internal_error`
315
286
 
316
- `PerformActionInput` carries `account_id`, `credential_type`, `client_ip`,
317
- `signal`, `notify`, optional `connection_id`, optional `preset`.
287
+ `PerformActionInput` carries `auth` (the request's `ResolvedAuth`, `null` for
288
+ anonymous — the authorization phase reads its account, the post-authorization
289
+ gates its type and scope, `ActionContext` its type and session hash),
290
+ `client_ip`, `signal`, `notify`, optional `connection_id`, optional `preset`.
318
291
  `PerformActionDeps` carries `db` (pool-level), `pending_effects`, `log`,
319
292
  the two rate limiters. Audit writes are out-of-band: factories close over
320
293
  `AppDeps.audit` independently.
@@ -330,10 +303,10 @@ surface consistency.
330
303
  ## DEV-only output validation — uniform across surfaces
331
304
 
332
305
  Critical invariant: every action-handler surface applies DEV-only output
333
- validation and produces the **same failure mode** — log an error, return
306
+ validation and produces the **same failure mode** as REST routes'
307
+ `wrap_output_validation` (`http/route_spec.ts`) — log an error, return
334
308
  the response unchanged, do not throw, do not mutate status.
335
309
 
336
- - REST bridge — `http/route_spec.ts` `wrap_output_validation` (applied via `apply_route_specs`; inherited by `create_action_route_spec`). Production hot path short-circuits (no parse).
337
310
  - HTTP RPC + WebSocket dispatch — `actions/perform_action.ts` `if (DEV) spec.output.safeParse(output)` inside the shared dispatch core. Production hot path short-circuits (no parse).
338
311
 
339
312
  Caller-facing `input` schemas are validated **always** (DEV + production)
@@ -345,40 +318,63 @@ Validation for full rationale.
345
318
 
346
319
  `Transport` is the unifying interface — overloaded `send(message, options?)`
347
320
  returning `Promise<JsonrpcResponseOrError>` for requests and
348
- `Promise<JsonrpcErrorResponse | null>` for notifications, plus `is_ready()`
349
- and optional `dispose()`. All transports share `TransportSendOptions`:
321
+ `Promise<JsonrpcErrorResponse | null>` for notifications, plus `is_ready()`,
322
+ optional `queues` (a request sent with `queue` waits on it while not ready —
323
+ `FrontendWebsocketTransport`, while its connection `will_reconnect`), and
324
+ optional `dispose()`. All transports share
325
+ `TransportSendOptions`:
350
326
 
351
327
  - `signal?: AbortSignal` — per-call cancel. Bottoms out at
352
328
  `FrontendWebsocketClient.request({signal})` on WS (sends `cancel`
353
329
  notification on abort) and at `fetch({signal})` on HTTP.
354
330
  - `queue?: boolean` — per-call durable-queue opt-in. Honored only by
355
331
  `FrontendWebsocketTransport` on the `request_response` path (default
356
- `false`). HTTP, backend, and WS notifications all ignore it.
357
-
358
- `Transports` registry holds multiple transports with a `current` selection
359
- and `allow_fallback: boolean` (default `true`). Explicit
360
- `transport_for_method` (on `rpc_client`) or
361
- `default_send_options.transport_name` (on `ActionDispatcher`) takes precedence.
332
+ `false`). HTTP and WS notifications ignore it.
333
+
334
+ `Transports` holds transports by name; the first registered is the default.
335
+ `get_transport(name?, {queue?})` returns the preferred transport — the named
336
+ one, else the default — when it is ready, or when it is not but the call is a
337
+ queued request and it `queues`; otherwise the first ready transport, the
338
+ default first. Explicit `transport_for_method` (on `rpc_client`) or
339
+ `default_send_options.transport_name` (on `ActionDispatcher`) names it.
340
+
341
+ **Queue routing.** `ActionDispatcher.send` resolves a request's `queue` once —
342
+ the call's, else `default_send_options.queue`, else off — and it drives both
343
+ the transport choice and the send, so a WS-routed request on a disconnected
344
+ socket waits in the client's durable queue and replays on reconnect (or
345
+ rejects when its `signal` aborts; the queue is size-bounded, not timed). It
346
+ queues only while a reconnect is coming: `FrontendWebsocketTransport.queues`
347
+ reads the connection's `will_reconnect` (`FrontendWebsocketClient`:
348
+ `connecting` or `reconnecting`), so after a close that reopens nothing on its
349
+ own — superseded (4004), permission revoked (4006), `disconnect()`,
350
+ `cancel_reconnect()`, auto-reconnect off — the request falls back to a ready
351
+ transport (HTTP) rather than wait for a `connect()`. (Requests already queued
352
+ before a `cancel_reconnect()` or `set_reconnect(false)` stay queued for the
353
+ next `connect()`.) A notification never queues: it fails fast, or falls back to
354
+ a ready transport.
355
+ The RPC layer defaults it off; a client-authoritative app opts in on the peer
356
+ (`create_frontend_rpc_client`'s `ws.queue`). `FrontendWebsocketClient`'s own
357
+ raw `request()` keeps its default-on queue.
362
358
 
363
359
  ### WS close codes (`actions/transports.ts`)
364
360
 
365
361
  - `WS_CLOSE_SESSION_REVOKED = 4001` — server revoked auth (reason `WS_CLOSE_SESSION_REVOKED_REASON`, `Session revoked`); client enters permanent `revoked` state, no reconnect. Also the close for an upgrade refused at admission because its credential was revoked, or its acting actor soft-deleted, mid-upgrade — indistinguishable on the wire by design — and for a socket whose credential expired while open, with reason `WS_CLOSE_CREDENTIAL_EXPIRED_REASON` (`Credential expired`), which the client treats as the same `revoked` state.
366
- - `WS_CLOSE_CLIENT_HEARTBEAT_TIMEOUT = 4002` — client observed receive-silence past its receive timeout (`resolve_heartbeat_receive_timeout`).
367
- - `WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT = 4003` — server observed receive-silence past `DEFAULT_SERVER_HEARTBEAT_TIMEOUT` (60s).
368
- - `WS_CLOSE_CONNECTION_LIMIT = 4004` — server closed this socket to admit a newer one on the same account, past the per-account connection cap (reason `connection limit`). Not a revocation: the client stays `closed` with `superseded` set and no reconnect, until `connect()` is called. Twin of the Rust spine's constant.
362
+ - `WS_CLOSE_CLIENT_HEARTBEAT_TIMEOUT = 4002` — client observed receive-silence past its receive timeout (`resolve_heartbeat_receive_timeout`), with reason `WS_CLOSE_CLIENT_HEARTBEAT_TIMEOUT_REASON` (`client heartbeat timeout`). TS-only reason: the client is the same against either spine.
363
+ - `WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT = 4003` — server observed receive-silence past `DEFAULT_WS_RECEIVE_TIMEOUT` (60s), with reason `WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT_REASON` (`server heartbeat timeout`). Twin of the Rust spine's constants.
364
+ - `WS_CLOSE_CONNECTION_LIMIT = 4004` — server closed this socket to admit a newer one on the same account, past the per-account connection cap (reason `WS_CLOSE_CONNECTION_LIMIT_REASON`, `connection limit`). Not a revocation: the client stays `closed` with `superseded` set and no reconnect, until `connect()` is called. Twin of the Rust spine's constant.
369
365
  - `WS_CLOSE_OUTBOUND_OVERFLOW = 4005` — the server had more waiting to be written to this socket than its outbound budget holds (reason `WS_CLOSE_OUTBOUND_OVERFLOW_REASON`, `outbound queue overflow`); what was waiting is dropped. Not a revocation, and nothing took the connection's place: the client reconnects under its ordinary backoff. Twin of the Rust spine's constant.
370
366
  - `WS_CLOSE_PERMISSION_REVOKED = 4006` — the socket's account lost a role its endpoint's `required_roles` lists: a revoked global grant (reason `WS_CLOSE_PERMISSION_REVOKED_REASON`, `Permission revoked`), mid-life or at admission. Nothing is sent after it. Not a revocation of the credential: the client stays `closed` until `connect()` is called, without setting `revoked` or `superseded`, and rejects pending and queued requests `forbidden`. Twin of the Rust spine's constant.
371
- - `WS_CLOSE_GOING_AWAY = 1001` — the server is shutting down (reason `WS_CLOSE_GOING_AWAY_REASON`, `Server shutting down`): `close_all_sockets`, which `AppServer.close` runs. Also the close for an upgrade the shutdown refuses — pending at the close-all, or born closed after it. Not a revocation: the client reconnects under its ordinary backoff.
372
- - `WS_CLOSE_MESSAGE_TOO_BIG = 1009` — server received a message over its `max_message_bytes` cap (RFC 6455 "Message Too Big").
373
- - `WS_CLOSE_POLICY_VIOLATION = 1008` — a socket sent too much while it was still opening (before admission and `on_socket_open` completed): past `MAX_PRE_ADMISSION_FRAMES` frames or the `PRE_ADMISSION_QUEUE_BYTES_FACTOR` byte budget.
374
- - `WS_CLOSE_INTERNAL_ERROR = 1011` — the admission credential re-check itself failed (reason `internal error`), `on_socket_open` threw (reason `socket bootstrap failed`), or the socket's connection was removed from the transport without a close (reason `connection unregistered`). Not a revocation: the client reconnects under its ordinary backoff. Twin of the Rust spine's constant.
367
+ - `WS_CLOSE_GOING_AWAY = 1001` — the server is shutting down (reason `WS_CLOSE_GOING_AWAY_REASON`, `Server shutting down`): `close_all_connections`, which `AppServer.close` runs. Also the close for an upgrade the shutdown refuses — pending at the close-all, or born closed after it. Not a revocation: the client reconnects under its ordinary backoff.
368
+ - `WS_CLOSE_MESSAGE_TOO_BIG = 1009` — server received a message over its `max_message_bytes` cap (RFC 6455 "Message Too Big"), with reason `WS_CLOSE_MESSAGE_TOO_BIG_REASON` (`message too big`). Twin of the Rust spine's constants.
369
+ - `WS_CLOSE_POLICY_VIOLATION = 1008` — a socket sent too much while it was still opening (before admission and `on_socket_open` completed): past `MAX_PRE_ADMISSION_FRAMES` frames or the `PRE_ADMISSION_QUEUE_BYTES_FACTOR` byte budget (reason `WS_CLOSE_PRE_ADMISSION_OVERFLOW_REASON`). TS-only: the Rust spine reads no frame before admission (they wait in the socket for its loop), so it has no pre-admission queue to overflow and never sends 1008.
370
+ - `WS_CLOSE_INTERNAL_ERROR = 1011` — the admission credential re-check itself failed or opening the socket threw (reason `WS_CLOSE_INTERNAL_ERROR_REASON`, `internal error` — shared with the Rust spine), `on_socket_open` threw (`WS_CLOSE_SOCKET_OPEN_FAILED_REASON`, `socket bootstrap failed`), or the socket's connection was removed from the transport without a close (`WS_CLOSE_CONNECTION_UNREGISTERED_REASON`, `connection unregistered`) — the last two TS-only. Not a revocation: the client reconnects under its ordinary backoff. Twin of the Rust spine's constant.
375
371
 
376
372
  ### Transport modules
377
373
 
378
- - `actions/transports_http.ts` — `frontend_http_rpc`; thin `fetch` adapter, POST default, GET on `has_side_effects(method) === false`.
379
- - `actions/transports_ws.ts` — `frontend_websocket_rpc`; thin adapter over `WebsocketRpcConnection` (default impl: `FrontendWebsocketClient`). Answers inbound server→client requests: a built-in `peer_ping_responder` for `peer/ping` (zero-wiring liveness), any other request routed through `peer.receive` with the response sent back over the socket (the frontend half of the ActionPeer receive loop).
380
- - `actions/transports_ws_backend.ts` — `backend_websocket_rpc`; server-side WS with session tracking, two-phase registration (`register_pending` / `admit`), the per-account cap, and the per-connection outbound budget; satisfies `FilterableBroadcastTransport`. Server→client requests via `request_connection` (correlation registry in `actions/peer_request.ts`).
381
- - `actions/ws_outbound_writer.ts` — `WsOutboundWriter`, the outbound queue and write pump of one connection, which every frame the transport sends goes through; `realtime/outbound_budget.ts` is the accounting it shares with SSE.
374
+ - `actions/transports_http.ts` — `frontend_http_rpc`; thin `fetch` adapter over `FrontendHttpTransportOptions` (`{url, headers?, lookup_action_spec, max_get_url_length?}`). The transport owns the request policy, derived from the spec `lookup_action_spec` returns, so a hand-built transport can't drop a rule: POST by default; a read (`side_effects: false`) is a GET with no `content-type`, unless its input carries a `'secret'` or `'personal'` value at any depth (`schema_has_sensitive_field`, walked once per spec — a GET puts the params in the URL, which proxies and logs record) or its path and query exceed `max_get_url_length` (`DEFAULT_MAX_GET_URL_LENGTH`, 4096), which go as POST. A method the lookup doesn't know is a POST. The endpoint answers every GET with `Cache-Control: no-store` (`RPC_GET_CACHE_CONTROL`).
375
+ - `actions/transports_ws.ts` — `frontend_websocket_rpc`; thin adapter over `WebsocketRpcConnection` (default impl: `FrontendWebsocketClient`), `queues` while the connection `will_reconnect`. Also `to_same_origin_ws_url(path)`, the page-origin WebSocket URL a same-origin backend is reached at (`path` itself off the browser). Answers inbound server→client requests: a built-in `peer_ping_responder` for `peer/ping` (zero-wiring liveness), any other request routed through `peer.receive` with the response sent back over the socket (the frontend half of the ActionPeer receive loop).
376
+ - `actions/connection_registry.ts` — `ConnectionRegistry`, server-side WS with session tracking, two-phase registration (`register_pending` / `admit`), the per-account cap, and the per-connection outbound budget; the broadcast target of `create_broadcast_api` (`broadcast`, `broadcast_filtered`). Not a `Transport`: it sends nothing a client requested. Server→client requests via `request_connection` (correlation registry in `actions/peer_request.ts`).
377
+ - `actions/ws_outbound_writer.ts` — `WsOutboundWriter`, the outbound queue and write pump of one connection, which every frame the registry sends goes through; `realtime/outbound_budget.ts` is the accounting it shares with SSE.
382
378
 
383
379
  `FrontendHttpTransport` on non-OK HTTP returns the body as-is when it's a
384
380
  JSON-RPC error response for the request (same `id` compared as strings since GET sends it as a query param, or `null`) — the
@@ -394,7 +390,7 @@ buffering would masquerade as success at the rpc_client layer. Requests
394
390
  route via `queue`.
395
391
 
396
392
  **WS message cap.** `DEFAULT_WS_MAX_MESSAGE_BYTES` (1 MiB, in
397
- `actions/transports.ts`, equal to `DEFAULT_MAX_BODY_SIZE` and the twin of the
393
+ `actions/transports.ts`, equal to `DEFAULT_BODY_LIMIT_BYTES` and the twin of the
398
394
  Rust spine's constant) bounds one message both ways. `register_action_ws`
399
395
  (`max_message_bytes`, also on `WsEndpointSpec`) closes the socket with
400
396
  `WS_CLOSE_MESSAGE_TOO_BIG` on a larger inbound message, before parsing — no
@@ -409,15 +405,15 @@ sends it — otherwise the close would fail every request in flight on the
409
405
  socket. A consumer that raises the server cap passes the same value to the
410
406
  client; `null` skips the client-side measurement.
411
407
 
412
- ### `BackendWebsocketTransport` — server-side WS state
408
+ ### `ConnectionRegistry` — server-side WS state
413
409
 
414
410
  One map keyed by `connection_id` (branded `Uuid`), in registration order:
415
411
  `#connections: Map<Uuid, ConnectionEntry>`, each entry `{ws, identity,
416
412
  admitted, abort_controller, writer}`. `identity` is the `ConnectionIdentity`
417
- `{token_hash, account_id, api_token_id, required_roles}` (session sets
418
- `token_hash`, bearer sets `api_token_id`, daemon-token sets both null;
413
+ `{session_hash, account_id, api_token_id, required_roles}` (session sets
414
+ `session_hash`, bearer sets `api_token_id`, daemon-token sets both null;
419
415
  `required_roles` is what the endpoint gated the upgrade on, per registration,
420
- since endpoints with different gates can share one transport).
416
+ since endpoints with different gates can share one registry).
421
417
 
422
418
  The id is the connection's only handle — `register_pending` / `add_connection`
423
419
  return it and `admit` / `remove_connection` / `is_registered` take it. There is
@@ -430,19 +426,20 @@ open and removes by it.
430
426
  socket exists, and a revocation closes only the connections *registered* under
431
427
  what it revoked — so a one-step registration leaves a window in which a
432
428
  revocation closes nothing and the socket is then admitted on a dead credential.
433
- The transport splits registration to close it (the twin of the Rust
429
+ The registry splits registration to close it (the twin of the Rust
434
430
  `fuz_realtime` `ConnectionRegistry`, same method names):
435
431
 
436
- - `register_pending(ws, token_hash, account_id, api_token_id?, abort_controller?, required_roles?)`
437
- inserts the entry **un-admitted**. Every `close_sockets_for_*` matches it
438
- from that instant. Otherwise it is inert: no `send` broadcast,
432
+ - `register_pending(ws, identity, abort_controller?)` (`identity: ConnectionIdentity`, as
433
+ the Rust `register_pending(sender, identity, signal)`; `add_connection` takes the same)
434
+ inserts the entry **un-admitted**. Every `close_connections` matches it
435
+ from that instant. Otherwise it is inert: no `broadcast`,
439
436
  `broadcast_filtered` (the predicate never sees it), `send_to_account`, or
440
- `request_connection` (`connection_gone`) reaches it; `get_connection_count`,
441
- `is_ready`, and `is_registered` don't see it
442
- (`get_pending_connection_count` does); the cap neither counts nor evicts it.
437
+ `request_connection` (`connection_gone`) reaches it; `connection_count`
438
+ and `is_registered` don't see it
439
+ (`pending_connection_count` does); the cap neither counts nor evicts it.
443
440
  - the caller re-reads the credential (`revalidate_resolved_auth`).
444
441
  - `take_pending_close_code(connection_id)` — after a refused `admit`, the
445
- close code the transport closed the pending entry with (4001, 4006, 1001),
442
+ close code the registry closed the pending entry with (4001, 4006, 1001),
446
443
  read once; what `register_action_ws` logs the refusal by.
447
444
  - `admit(connection_id)` returns `false` when the entry is gone — a revocation
448
445
  closed it while pending — and evicts nothing; otherwise it enforces the cap
@@ -456,12 +453,12 @@ harnesses that register a socket directly. An upgrade that authenticated a sessi
456
453
  uses the two-phase form.
457
454
 
458
455
  **Abort at close time.** The `abort_controller` passed at registration is the
459
- socket's per-connection controller. The transport aborts it when it closes the
456
+ socket's per-connection controller. The registry aborts it when it closes the
460
457
  connection — a revocation or a cap eviction — so in-flight handlers see
461
458
  `signal.aborted` at once, not when the close handshake lands.
462
459
  `remove_connection` only removes: it neither closes nor aborts.
463
460
 
464
- **Per-account connection cap.** `new BackendWebsocketTransport({max_connections_per_account})`
461
+ **Per-account connection cap.** `new ConnectionRegistry({max_connections_per_account})`
465
462
  — default `DEFAULT_MAX_CONNECTIONS_PER_ACCOUNT` (50), `null` disables, anything
466
463
  but a positive integer throws. The policy is **evict-oldest**: admission always
467
464
  admits the new connection, first closing the account's oldest admitted ones
@@ -474,7 +471,7 @@ real user. The check runs at **admission** (`admit`, or `add_connection`),
474
471
  which `register_action_ws` reaches in `onOpen` — after every upgrade gate
475
472
  (origin, auth, token scope, acting actor, role) and the credential re-read — so a refused or
476
473
  just-revoked request never closes someone's socket. An evicted connection
477
- leaves the transport's map at once — no broadcast or peer request reaches it,
474
+ leaves the registry's map at once — no broadcast or peer request reaches it,
478
475
  its pending peer requests drain as `connection_gone`, it stops counting toward
479
476
  the cap, its controller is aborted, and `register_action_ws` dispatches nothing
480
477
  more on it — while the socket itself is only closed once the close handshake
@@ -482,9 +479,9 @@ completes. Its `on_socket_close` fires when the close lands, and the
482
479
  `remove_connection` before it is a no-op. An eviction logs
483
480
  `ws: connection cap closed oldest` at
484
481
  info with `{account_id, closed, max}` (the Rust spine's line) through the
485
- transport's `log` (a `[ws]` logger when unset, `null` silences;
486
- `register_action_ws` passes its own to the transport it creates). The cap is per transport:
487
- endpoints sharing one transport share one count per account. The twin of the
482
+ registry's `log` (a `[ws]` logger when unset, `null` silences;
483
+ `register_action_ws` passes its own to the registry it creates). The cap is per registry:
484
+ endpoints sharing one registry share one count per account. The twin of the
488
485
  Rust `fuz_realtime` `ConnectionRegistry`'s cap — same default, same policy,
489
486
  same close code and reason — pinned on both by the
490
487
  `describe_ws_connection_cap_cross_tests` suite.
@@ -506,7 +503,7 @@ which bypasses the budget. A send never waits and never throws.
506
503
  frames over in order, on the microtask after a send and as the buffer drains.
507
504
  So a second send in one synchronous run reaches the socket a microtask later.
508
505
  - **The budget.** What waits is held to `outbound_queue_bytes`
509
- (`new BackendWebsocketTransport({outbound_queue_bytes})`, default
506
+ (`new ConnectionRegistry({outbound_queue_bytes})`, default
510
507
  `DEFAULT_WS_OUTBOUND_QUEUE_BYTES`, 4 MiB — its own constant, not derived from
511
508
  `max_message_bytes`; anything but a positive integer throws): each waiting
512
509
  frame is charged its UTF-8 length plus `OUTBOUND_FRAME_OVERHEAD_BYTES` (64),
@@ -557,22 +554,20 @@ or admitted — removal, abort, then the close through the writer — and answer
557
554
  with it (heartbeat timeout, oversized message, failed `on_socket_open`, refused
558
555
  admission).
559
556
 
560
- Targeted closure (all return socket count closed, use
561
- `WS_CLOSE_SESSION_REVOKED`, match pending and admitted entries alike, and abort
562
- each closed connection's controller):
563
-
564
- - `close_sockets_for_session(token_hash)`
565
- - `close_sockets_for_token(api_token_id)`
566
- - `close_sockets_for_account(account_id)` — coarse, covers session + bearer + daemon-token
567
-
568
- `close_sockets_for_role(account_id, role)` closes the account's connections
569
- whose `required_roles` include `role`, pending included, with
557
+ Targeted closure is `close_connections(target)` (`ConnectionCloser`, below):
558
+ it returns the socket count closed, matches pending and admitted entries alike
559
+ by `connection_identity_matches(identity, target)` — the twin of the Rust
560
+ `ConnectionIdentity::matches` — and aborts each closed connection's
561
+ controller. A `session` (`session_hash`), `token` (`api_token_id`), or
562
+ `account` (`account_id` — coarse, covers session + bearer + daemon-token)
563
+ target closes with `WS_CLOSE_SESSION_REVOKED`; a `role` target closes the
564
+ account's connections whose `required_roles` include `role` with
570
565
  `WS_CLOSE_PERMISSION_REVOKED` instead — over-closing an any-of gate (the loss
571
566
  of any listed role closes, whether or not the account still holds another).
572
567
 
573
- `close_all_sockets()` closes every connection, pending and admitted, with
568
+ `close_all_connections()` closes every connection, pending and admitted, with
574
569
  `WS_CLOSE_GOING_AWAY` instead — the shutdown close, removing and aborting each
575
- the same way — and leaves the transport **closing** for good (`is_closing()`):
570
+ the same way — and leaves the registry **closing** for good (`is_closing()`):
576
571
  every later registration is **born closed**. `register_pending` and
577
572
  `add_connection` then insert nothing, abort the caller's controller, and close
578
573
  the socket with `WS_CLOSE_GOING_AWAY` before returning an id that names
@@ -582,18 +577,19 @@ synchronous step as the closes, so an admission that finds its entry gone
582
577
  during shutdown reads the shutdown, never a revocation. Twin of the Rust
583
578
  registry's closing flag.
584
579
 
585
- Fan-out, to admitted connections only: `send(notification)` broadcasts to every
586
- connection; `broadcast_filtered(message, predicate)` runs per-connection ACL
587
- predicate over `ConnectionIdentity`; `send_to_account` wraps `broadcast_filtered` and
580
+ Fan-out, to admitted connections only, each returning how many connections
581
+ accepted the message: `broadcast(notification)` to every connection;
582
+ `broadcast_filtered(message, predicate)` runs per-connection ACL predicate over
583
+ `ConnectionIdentity`; `send_to_account` wraps `broadcast_filtered` and
588
584
  structurally satisfies `NotificationSender` (see `auth/CLAUDE.md` §WS
589
- notifications). `send(request)` is a misuse (a request has no single
590
- broadcast target) and returns an error envelope.
585
+ notifications). A server→client request has no broadcast form; it targets one
586
+ connection (`request_connection`, below).
591
587
 
592
588
  Server→client request/response (ActionPeer): `request_connection(connection_id,
593
589
  method, params, {timeout_ms?})` sends a `{jsonrpc, method, params, id}` frame to
594
590
  exactly one socket and awaits the reply, returning a `PeerRequestOutcome`
595
591
  (`{ok: true, value}` | `{ok: false, error: PeerRequestError}` —
596
- `timeout`/`connection_gone`/`too_many_in_flight`/`client_error`). The transport
592
+ `timeout`/`connection_gone`/`too_many_in_flight`/`client_error`). The registry
597
593
  owns the socket + the send; the correlation registry — id allocation, the pending
598
594
  map (nested `connection_id → s{n}` id, the nesting being the per-connection
599
595
  isolation guarantee), deadlines, and the in-flight cap — is `PendingPeerRequests`
@@ -602,7 +598,7 @@ in **`actions/peer_request.ts`** (also home to the peer types/constants +
602
598
  socket. `register_action_ws` routes inbound responses back via
603
599
  `resolve_peer_response` (→ `#pending.resolve`); connection close drains pending as
604
600
  `connection_gone`. Defaults: `DEFAULT_PEER_REQUEST_TIMEOUT` (10s),
605
- `MAX_IN_FLIGHT_PEER_REQUESTS_PER_CONNECTION` (256). Threaded to handlers as
601
+ `DEFAULT_MAX_IN_FLIGHT_PEER_REQUESTS_PER_CONNECTION` (256). Threaded to handlers as
606
602
  `ActionContext.request_client` (WS only; `undefined` on HTTP RPC). The `peer/ping`
607
603
  protocol action drives it; see `actions/peer_ping.ts`. An inbound reply matching
608
604
  no pending entry (unsolicited / cross-connection / late) is dropped + audited via
@@ -618,32 +614,34 @@ persistence + rehydration by the consumer.
618
614
  A WebSocket and an SSE stream are authorized once, at open, so a revocation
619
615
  takes effect on an open connection only when something closes it.
620
616
  `ConnectionCloser` is that capability — the twin of the Rust spine's
621
- `SocketRevoker`:
617
+ `ConnectionCloser`:
622
618
 
623
619
  ```ts
624
620
  interface ConnectionCloser {
625
- close_sockets_for_session: (session_token_hash: string) => number;
626
- close_sockets_for_token: (api_token_id: string) => number;
627
- close_sockets_for_account: (account_id: Uuid) => number;
628
- close_sockets_for_role: (account_id: Uuid, role: string) => number; // a revoked global grant
629
- close_all_sockets: () => number; // shutdown, never a revocation
621
+ close_connections: (target: ConnectionCloseTarget) => number;
622
+ close_all_connections: () => number; // shutdown, never a revocation
630
623
  }
624
+ type ConnectionCloseTarget =
625
+ | {kind: 'session'; session_hash: string}
626
+ | {kind: 'token'; api_token_id: string}
627
+ | {kind: 'account'; account_id: Uuid}
628
+ | {kind: 'role'; account_id: Uuid; role: string}; // a revoked global grant
631
629
  ```
632
630
 
633
- `BackendWebsocketTransport` satisfies it structurally;
634
- `create_sse_connection_closer(registry, required_role)` (`realtime/sse_auth_guard.ts`) adapts
635
- a `SubscriberRegistry` (`close_all_sockets` is `SubscriberRegistry.close_all`;
636
- `close_sockets_for_role` closes the account's streams when `role` is the
631
+ `ConnectionRegistry` satisfies it structurally;
632
+ `create_sse_connection_closer(registry, required_role)` (`realtime/audit_log_sse.ts`) adapts
633
+ an `SseRegistry` (`close_all_connections` is `SseRegistry.close_all`;
634
+ a `role` target closes the account's streams when `role` is the
637
635
  registry's gating role). No handler closes for a role: a role revocation's
638
- closes come from the audit listeners alone.
639
- Closing is idempotent and synchronous. `close_all_sockets` is the one method no
636
+ closes come from the revocation guard alone (below).
637
+ Closing is idempotent and synchronous. `close_all_connections` is the one method no
640
638
  revocation calls: `AppServer.close` runs it on `deps.connection_closer` to end
641
639
  every live connection of the backend at shutdown, and it has no
642
- `ConnectionCloseTarget` variant. It also leaves each member closing — the WS
643
- transport and `SubscriberRegistry` refuse every later registration (born
644
- closed) — so a closed transport or registry hosts nothing more. Its Rust
645
- counterpart is `ShutdownCloser::close_all_sockets`, a supertrait of
646
- `SocketRevoker`.
640
+ `ConnectionCloseTarget` variant. It also leaves each member closing — the WS connection
641
+ registry and `SseRegistry` refuse every later registration (born
642
+ closed) — so a closed connection registry or SSE registry hosts nothing more. Its Rust
643
+ counterpart is `ShutdownCloser::close_all_connections`, a supertrait of
644
+ `ConnectionCloser`.
647
645
 
648
646
  **Every revocation closes after its commit.** A handler inside a route or
649
647
  action transaction never calls a closer inline: it calls
@@ -651,15 +649,13 @@ action transaction never calls a closer inline: it calls
651
649
  which puts the close on the request's post-commit queue (`emit_after_commit`).
652
650
  The close runs once the handler's transaction has committed and is discarded
653
651
  when the handler throws — a rolled-back revocation closes nothing. `target` is
654
- a `ConnectionCloseTarget` (`{kind: 'session', session_token_hash}` /
655
- `{kind: 'token', api_token_id}` / `{kind: 'account', account_id}` /
656
- `{kind: 'role', account_id, role}`);
657
- `close_connections(closer, target)` is the immediate form the queue runs. A
652
+ a `ConnectionCloseTarget`; `closer.close_connections(target)` is the
653
+ immediate form the queue runs. A
658
654
  handler with no wrapping transaction (`/login`, `/password`) opens its own
659
655
  around its writes and closes straight after that commit with
660
656
  `close_connections_after_commit(closer, target, log)`, which logs a failing
661
- close as the post-commit flush does. Twin of `queue_socket_close` /
662
- `SocketCloseTarget`.
657
+ close as the post-commit flush does. Twin of `queue_connection_close` /
658
+ `ConnectionCloseTarget`.
663
659
 
664
660
  The order is load-bearing for admission: a connection registers, then re-reads
665
661
  its credential, so a close that missed the registration must belong to a
@@ -676,15 +672,15 @@ carry caller-supplied ids.
676
672
  by reference: a closer added twice is one member, reached once. `add` returns a
677
673
  remover for that addition (idempotent); additions are counted, so the closer
678
674
  stays a member until every addition is removed — one owner releasing a shared
679
- transport leaves it reachable for the others.
675
+ registry leaves it reachable for the others.
680
676
  `create_app_backend` puts one on `AppDeps.connection_closer`; `create_app_server`
681
- adds each mounted WS transport and the audit stream registry itself (passing
682
- `connection_closer: null` to the mount functions so it holds the removers), and
683
- removes them when its assembly fails or `AppServer.close` runs — after
684
- `close_all_sockets` across them all. Twin of
685
- `RealtimeRevoker`. A member that throws does not stop the fan-out — every
677
+ adds each mounted WS connection registry and the audit stream registry itself (passing
678
+ `connection_closer: null` to the mount functions so it holds the removers),
679
+ registers the revocation guard on it, and removes them when its assembly fails
680
+ or `AppServer.close` runs — after `close_all_connections` across them all. Twin of
681
+ `RealtimeCloser`. A member that throws does not stop the fan-out — every
686
682
  member is called, then the first error is thrown for the caller to log;
687
- `BackendWebsocketTransport` and `SubscriberRegistry.close_by_identity` treat a
683
+ `ConnectionRegistry` and `SseRegistry.close_by_identity` treat a
688
684
  throwing socket or stream the same way. `noop_connection_closer` is a `ConnectionCloser` that closes
689
685
  nothing, for hand-built action-factory deps on a backend with no
690
686
  live-connection surface.
@@ -697,13 +693,13 @@ It is required where it is read, so it can't be forgotten:
697
693
  the connections of each expired session it deletes — `auth/CLAUDE.md`
698
694
  §Cleanup), and the
699
695
  `connection_closer: RealtimeCloser | null` option of `register_action_ws` /
700
- `register_ws_endpoint` / `create_audit_log_sse`, which add their transport to it
701
- (`null` is the explicit opt-out, or for a caller that adds the transport itself
696
+ `create_audit_log_sse`, which add their registry to it
697
+ (`null` is the explicit opt-out, or for a caller that adds the registry itself
702
698
  to hold the remover, as `create_app_server` does).
703
699
 
704
- ## WS auth guard (`actions/transports_ws_auth_guard.ts`)
700
+ ### Revocation guard (`create_revocation_guard`)
705
701
 
706
- The audit-listener half of revocation: `create_ws_auth_guard(closer, log)`
702
+ The audit-listener half of revocation: `create_revocation_guard(closer, log)`
707
703
  returns an `on_audit_event` callback that repeats a revocation's close when its
708
704
  audit row is announced. It covers a revocation emitted by code that holds no
709
705
  closer; for the builtin handlers it is a repeat of the close they already
@@ -711,40 +707,43 @@ queued. A success row is announced only after its request's transaction commits
711
707
  (`auth/CLAUDE.md` §Audit emitter), so the guard's close is post-commit too. Its
712
708
  closes reach a connection still pending admission.
713
709
 
714
- `closer` is any `ConnectionCloser` — a `BackendWebsocketTransport`, or a
715
- `RealtimeCloser` to cover every transport from one listener. For standard WS
716
- endpoints mounted via `AppServerOptions.ws_endpoints`, `create_app_server`
717
- registers the guard via `backend.deps.audit.add_listener` automatically (per
718
- `WsEndpointSpec.auth_guard`). For custom wiring, register inside the consumer's
719
- `audit_factory` body.
720
-
721
- It dispatches on the `RevocationScope` each event declares in
722
- `audit_event_revocation_scopes` (`auth/audit_log_schema.ts`), the table the SSE
723
- guard reads too — one declaration, so the two can't drift:
724
-
725
- - `session` (`session_revoke`) → `close_sockets_for_session(metadata.session_id)`
726
- - `token` (`token_revoke`) → `close_sockets_for_token(metadata.token_id)`
710
+ **One guard, on the fan-out.** `create_app_server` registers one on
711
+ `deps.connection_closer` when it mounts a WS endpoint or the audit stream —
712
+ after the audit stream's broadcast listener, so a revocation's row reaches the
713
+ stream before the close — and the fan-out carries each close to every member:
714
+ each WS connection registry and the audit stream registry (`create_sse_connection_closer`).
715
+ A consumer wiring outside `create_app_server` registers its own, over a closer
716
+ holding its transports, inside its `audit_factory` body.
717
+
718
+ It maps each row to a close target with `to_connection_close_target(event)` —
719
+ the twin of the Rust `ConnectionCloseTarget::from_audit_event` — then calls
720
+ `closer.close_connections(target)`. The mapping dispatches on the
721
+ `RevocationScope` each event declares in `audit_event_revocation_scopes`
722
+ (`auth/audit_log_schema.ts`), and a row missing its key (an empty string
723
+ included) maps to nothing:
724
+
725
+ - `session` (`session_revoke`) → `{kind: 'session', session_hash: metadata.session_id}`
726
+ - `token` (`token_revoke`) → `{kind: 'token', api_token_id: metadata.token_id}`
727
727
  - `account` (`session_revoke_all`, `token_revoke_all`, `password_change`,
728
728
  `logout`, `account_delete`, `account_purge`) →
729
- `close_sockets_for_account(target_account_id ?? account_id)`
730
- - `role` (`role_grant_revoke`) → `close_sockets_for_role(target_account_id ??
731
- account_id, metadata.role)` when the revoked grant was global
729
+ `{kind: 'account', account_id: target_account_id ?? account_id}`
730
+ - `role` (`role_grant_revoke`) → `{kind: 'role', account_id: target_account_id ??
731
+ account_id, role: metadata.role}` when the revoked grant was global
732
732
  (`to_global_role_revocation`); a scoped revoke closes nothing. Per-message
733
733
  dispatch re-authorizes each request against its own action, but nothing
734
- re-checks what a socket admitted by a role gate receives — every push its
735
- endpoint sends — so the socket closes, with `WS_CLOSE_PERMISSION_REVOKED`.
736
- The SSE guard closes its streams on the same rows. No handler closes for a
737
- role, so this guard is the one closer.
734
+ re-checks what a connection admitted by a role gate receives — every push its
735
+ endpoint sends, every row the stream sends — so a socket closes with
736
+ `WS_CLOSE_PERMISSION_REVOKED` and a stream gated on the role ends. No handler
737
+ closes for a role, so this guard is the one closer.
738
738
  - `none` → nothing — every other event, and any event type fuz_app doesn't
739
739
  define
740
740
 
741
741
  Only `outcome === 'success'` events act — a failure carries attacker-controlled
742
742
  identifiers, and an outcome outside the enum is no revocation. Reacting to them would let an authenticated caller close
743
- another user's socket by guessing a session hash or token id.
744
-
745
- ## WebSocket dispatch — three layered entry points
743
+ another user's connection by guessing a session hash or token id. Twin of the
744
+ Rust spine's `register_revocation_guard`.
746
745
 
747
- In decreasing abstraction.
746
+ ## WebSocket endpoints
748
747
 
749
748
  ### `create_app_server.ws_endpoints` — canonical mount surface
750
749
 
@@ -753,7 +752,7 @@ of `WsEndpointSpec` or a factory
753
752
  `(ctx: AppServerContext) => ReadonlyArray<WsEndpointSpec>`; factory form
754
753
  runs after server context is assembled so action lists can depend on
755
754
  `ctx.deps` / `ctx.action_*_rate_limiter`. Each entry is auto-mounted via
756
- `register_ws_endpoint` against the assembled Hono app.
755
+ `register_action_ws` against the assembled Hono app.
757
756
 
758
757
  `create_upgrade_websocket: (app: Hono) => UpgradeWebSocket` returns the
759
758
  Hono adapter helper. It is a factory because Node's `createNodeWebSocket({app})`
@@ -767,103 +766,114 @@ NOT trip the check, so feature-flag gated WS surfaces stay safe.
767
766
  What every auto-mount gets, so no hand mount has to remember it: the
768
767
  `action_ip_rate_limiter` / `action_account_rate_limiter` instances the RPC
769
768
  endpoints charge (one budget per action across transports), the server's
770
- `allowed_origins` when the spec sets none (`resolve_ws_endpoints`, read by
771
- both the mount and the surface), registration ahead of
772
- `post_route_middleware` and `static_serving`, the surface entry, and the
773
- guards below. A `ws_endpoints` or `rpc_endpoints` path outside the auth
774
- middleware's scope (`AUTH_MIDDLEWARE_PATH`, `'/api/*'`, from
775
- `auth/middleware.ts` — matched with `middleware_applies`, so `/api` itself is
776
- inside) throws at assembly (`assert_endpoint_in_auth_scope`, which
769
+ `allowed_origins` when the spec sets none and the sole RPC endpoint's actions
770
+ when it omits `actions` (`resolve_ws_endpoints`, read by both the mount and the
771
+ surface), registration ahead of `post_route_middleware` and `static_serving`,
772
+ the surface entry, and the revocation guard. A `ws_endpoints` or `rpc_endpoints`
773
+ path outside the auth middleware's scope (`AUTH_MIDDLEWARE_PATH`, `'/api/*'`,
774
+ from `auth/middleware.ts` — matched with `middleware_applies`, so `/api` itself
775
+ is inside) throws at assembly (`assert_endpoint_in_auth_scope`, which
777
776
  `create_test_app_surface_spec` also runs): there no session or bearer is
778
777
  parsed and every caller would be unauthenticated.
779
778
 
780
779
  `WsEndpointSpec` fields: `path`, `allowed_origins?` (default: the server's),
781
- `actions`,
782
- `required_roles?`, `transport?`, `max_connections_per_account?`,
783
- `outbound_queue_bytes?`, `heartbeat?`,
784
- `artificial_delay?`, `max_message_bytes?`,
785
- `on_socket_open?`, `on_socket_close?`, `auth_guard?` (default `true`,
786
- deduped by reference identity via `WeakSet<BackendWebsocketTransport>`),
787
- `extra_audit_handlers?`. Every mounted transport is added to
788
- `deps.connection_closer`, whatever `auth_guard` says — the flag opts out of
789
- the audit listener, not of the handlers' closes.
780
+ `actions?`, `required_roles?`, `registry?`, `max_connections_per_account?`,
781
+ `outbound_queue_bytes?`, `receive_timeout?`, `max_message_bytes?`,
782
+ `on_socket_open?`, `on_socket_close?`. Every mounted registry is added to
783
+ `deps.connection_closer`.
784
+
785
+ **One action set across transports.** A spec that omits `actions` serves the
786
+ actions of the server's sole `rpc_endpoints` entry through `to_ws_actions`
787
+ (`actions/protocol.ts`): `protocol_actions` first, then the RPC list less any
788
+ protocol action it carries (`peer_ping_action` rides the RPC list so an HTTP
789
+ caller is refused `peer_no_transport` rather than `method_not_found`). One set
790
+ of handler closures then runs on both transports. Assembly throws when a spec
791
+ omits `actions` and no RPC endpoint, or more than one, resolves.
790
792
 
791
793
  `max_connections_per_account` sets the per-account connection cap on the
792
- transport the mount creates (`RegisterActionWsOptions` carries the same field).
793
- It throws alongside `transport` — a supplied transport carries its own cap, set
794
+ registry the mount creates (`RegisterActionWsOptions` carries the same field).
795
+ It throws alongside `registry` — a supplied registry carries its own cap, set
794
796
  where it was constructed, and an option that silently did nothing would read as
795
797
  enforced. `outbound_queue_bytes` sets the per-connection outbound budget on that
796
- transport the same way (default `DEFAULT_WS_OUTBOUND_QUEUE_BYTES`; zero or a
798
+ registry the same way (default `DEFAULT_WS_OUTBOUND_QUEUE_BYTES`; zero or a
797
799
  non-positive value throws at assembly, as does passing it alongside
798
- `transport`).
800
+ `registry`).
799
801
 
800
- Mounted transport reachable at `app_server.ws_endpoints[path]`
801
- (`Readonly<Record<string, BackendWebsocketTransport>>`). Duplicate paths
802
+ Mounted registry reachable at `app_server.ws_endpoints[path]`
803
+ (`Readonly<Record<string, ConnectionRegistry>>`). Duplicate paths
802
804
  across `WsEndpointSpec`s throw at assembly, before any endpoint mounts.
803
805
  Cross-surface collisions (same `GET <path>` on both `RouteSpec` and
804
806
  `WsEndpointSpec`) throw with exact-string match. Pattern overlap (e.g.
805
807
  `GET /api/:resource` vs `/api/ws`) is not detected — Hono's specific-before-wildcard routing keeps
806
808
  those working but avoid the overlap.
807
809
 
808
- `auth_guard` is also the one closer of a role revocation: with it off for a
809
- transport, a revoked role closes none of its sockets. When multiple specs share a transport,
810
- **any** spec with `auth_guard !== false` wires the guard for that
811
- transport (OR-semantics).
812
-
813
810
  `AppSurfaceWsEndpoint.methods` surfaces `request_response` +
814
811
  `remote_notification` specs only — `local_call` specs are filtered out
815
812
  because they don't dispatch over WS.
816
813
 
817
- ### `register_ws_endpoint` — middle tier
818
-
819
- Composes the standard upgrade stack:
820
-
821
- 1. `verify_request_source(allowed_origins)`
822
- 2. `require_auth`
823
- 3. `require_token_scope('surface:ws_upgrade')` — a narrowed token cannot hold a socket
824
- 4. Upgrade-time authorization phase — resolves the acting actor (`?acting=` through `parse_acting`; malformed reads as omitted), seeds `REQUEST_CONTEXT_KEY` for the inner `register_action_ws`
825
- 5. Optional `require_role(required_roles)` — any-of disjunction (coarse upgrade-time gate; per-action `auth` in each spec still applies at dispatch time)
826
- 6. Delegates to `register_action_ws`
827
-
828
- Extends `RegisterActionWsOptions` with `allowed_origins` (required here —
829
- there is no server list to default from) and optional `required_roles`, and
830
- inherits its required `connection_closer` and action limiters. Returns
831
- `{transport}`. Most consumers reach for
832
- `ws_endpoints` above. Call it directly only to mount a WS endpoint outside
833
- `create_app_server`'s assembly.
834
-
835
- ### `register_action_ws` — lower-level dispatcher
836
-
837
- Exposed for tests (`create_ws_test_harness`) that need to drive the
838
- dispatcher without the origin/auth front-stack.
814
+ ### `register_action_ws` — the endpoint
815
+
816
+ Mounts one `GET path` route, its guards in the route-spec pipeline's
817
+ coarse-to-fine order (from `fuz_auth_guard_resolver` over the upgrade's auth
818
+ shape `{account: 'required', actor: 'required', roles?, required_scope:
819
+ 'surface:ws_upgrade'}`):
820
+
821
+ 1. `verify_request_source(allowed_origins)` — 403
822
+ 2. `require_auth` — 401
823
+ 3. `require_token_scope('surface:ws_upgrade')` — a narrowed token cannot hold a socket (403 `token_scope_required`)
824
+ 4. The authorization phase (`run_authorization_phase`, `auth/request_context.ts`) — resolves the acting actor (`?acting=` through `parse_acting`; malformed reads as omitted, and the route declares no query schema, so a credential-less `?acting=garbage` is still the 401), seeds `REQUEST_CONTEXT_KEY`
825
+ 5. `require_role(required_roles)` when the endpoint is gated — any-of disjunction (coarse upgrade-time gate; per-action `auth` in each spec still applies at dispatch time)
826
+ 6. `upgradeWebSocket`
827
+
828
+ Only `GET` is mounted (Hono serves `HEAD` through it, guards included), so any
829
+ other method on the path is a 404. Takes
830
+ `allowed_origins` (required — `create_app_server` passes the server's), the
831
+ required `connection_closer` and action limiters, and optional
832
+ `required_roles`; returns `{registry}`. Most consumers reach for
833
+ `ws_endpoints` above; call it directly only to mount a WS endpoint outside
834
+ `create_app_server`'s assembly. Tests drive the dispatcher without the
835
+ guards through `create_ws_test_harness`, which invokes the captured events
836
+ factory directly.
837
+
838
+ The per-socket half lives in `actions/ws_socket_session.ts`:
839
+ `create_ws_socket_events(endpoint, upgrade)` returns the `WSEvents` for one
840
+ upgraded socket — admission, the pre-admission queue, the receive watchdog,
841
+ the credential deadline, frame dispatch, and close. `register_action_ws` reads
842
+ the Hono context at upgrade into a `WsSocketUpgrade` and derives the
843
+ endpoint's `WsSocketEndpoint` once; the module never touches the Hono app.
844
+ Its exports include the socket bounds (`MAX_PRE_ADMISSION_FRAMES`,
845
+ `PRE_ADMISSION_QUEUE_BYTES_FACTOR`, `MAX_INBOUND_DISPATCHES_PER_CONNECTION`),
846
+ the duplicate-id and overflow wire strings, and the `on_socket_open` /
847
+ `on_socket_close` contexts (`SocketOpenContext`, `SocketCloseContext`).
839
848
 
840
849
  Per-message dispatch delegates to `perform_action` — the shared core that
841
- HTTP RPC also calls. `register_action_ws` owns only WS-specific concerns:
850
+ HTTP RPC also calls. The socket session owns only WS-specific concerns:
842
851
 
843
- - **Wire envelope parsing** — JSON.parse → batch rejection → peer-response routing → envelope-version guard → notification interception (cancel, silent drop) → `JsonrpcRequest.safeParse` → per-message dispatch. The version guard is what makes `{method: 'x'}` and `{jsonrpc: '1.0', method: 'x'}` an `invalid_request` answer rather than a silently dropped notification, matching the first check the Rust `classify` runs. Peer-response routing is the twin's response shape exactly — no `method` key, a string/number `id`, exactly one of `result` / `error` — so a hybrid frame like `{method, id, result}` stays a dispatchable request instead of being demuxed and swallowed. The envelope schema is the same one the HTTP POST path runs, so `params: null`, an array `params`, or a non-string/number `id` answers `invalid_request` (-32600) on both transports rather than reaching the dispatcher as `invalid_params`. It runs **after** the notification/cancel block: notifications carry no id to echo and stay unvalidated, and `cancel` routing precedes it. The version guard echoes the id via `to_jsonrpc_envelope_id` (a scalar frame answers `id: null`), the later steps via `to_jsonrpc_message_id`.
852
+ - **Wire envelope parsing** — JSON.parse → batch rejection → `classify_jsonrpc_message` (`http/jsonrpc_helpers.ts`, the twin of the Rust `fuz_http::classify`, the same classifier the HTTP POST path runs) → per-arm handling: an `invalid` answers its error on its id; a `response` routes to the socket's pending peer request; a `notification` routes `cancel` and is otherwise dropped; a `request` goes on to the duplicate-id and in-flight checks and dispatch. The classifier runs the twin's order — version, then the `method` axis, then `id`, then the `JsonrpcRequest` envelope — so `{method: 'x'}` and `{jsonrpc: '1.0', method: 'x'}` answer `invalid_request` rather than being dropped as notifications; a response is the twin's shape exactly (no string `method`, a string/number `id`, exactly one of `result` / `error`), so a hybrid like `{method, id, result}` stays a dispatchable request; and `params: null`, an array `params`, or a non-string/number `id` answers `invalid_request` (-32600) on both transports rather than reaching the dispatcher as `invalid_params`. Notifications stay unvalidated (they carry no id to echo). A non-object frame answers `id: null`. POST answers a notification or a response `invalid_request` on `id: null`, as the Rust spine does.
844
853
  - **Cancel-notification interception** — `{request_id → AbortController}` map; aborts the matching pending controller before the cancel bubbles past the dispatcher
845
854
  - **Duplicate live ids refused** — a request whose id names a request still running on the socket is answered `invalid_request` with `data.reason` `ERROR_DUPLICATE_REQUEST_ID` and not dispatched; the running request keeps its controller, its cancel entry, and its reply id. An id is free again once its request is answered. Same refusal on the Rust spine
846
- - **In-flight ceiling** — at most `MAX_INBOUND_DISPATCHES_PER_CONNECTION` (128) requests run at once per socket (`@hono/node-ws` does not await `onMessage`, so nothing else bounds them); one more is answered `queue_overflow` (`WS_INBOUND_DISPATCH_OVERFLOW_MESSAGE`) and not dispatched, and the socket stays open and keeps reading — a reply to a server-initiated request still gets through. The duplicate check runs first; neither refusal reaches `perform_action`, so neither charges the action rate limiters. Same cap, message, and order as the Rust spine's `MAX_INBOUND_DISPATCHES_PER_CONN`
847
- - **Socket-scoped notify** — `(method, params) => transport.send_to(connection_id, notification)`, threaded into `perform_action` as `notify`
848
- - **Every send through the transport** — responses, error frames, and notifications all go through `transport.send_to`, so they are held to the connection's outbound budget; a handler that sends past it closes its own socket with `WS_CLOSE_OUTBOUND_OVERFLOW` and gets no response written
855
+ - **In-flight ceiling** — at most `MAX_INBOUND_DISPATCHES_PER_CONNECTION` (128) requests run at once per socket (`@hono/node-ws` does not await `onMessage`, so nothing else bounds them); one more is answered `queue_overflow` (`WS_INBOUND_DISPATCH_OVERFLOW_MESSAGE`) and not dispatched, and the socket stays open and keeps reading — a reply to a server-initiated request still gets through. The duplicate check runs first; neither refusal reaches `perform_action`, so neither charges the action rate limiters. Same cap, message, and order as the Rust spine's `MAX_INBOUND_DISPATCHES_PER_CONNECTION`
856
+ - **Socket-scoped notify** — `(method, params) => registry.send_to(connection_id, notification)`, threaded into `perform_action` as `notify`
857
+ - **Every send through the registry** — responses, error frames, and notifications all go through `registry.send_to`, so they are held to the connection's outbound budget; a handler that sends past it closes its own socket with `WS_CLOSE_OUTBOUND_OVERFLOW` and gets no response written
849
858
  - **Composed abort signal** — `AbortSignal.any([socket_close, per_request_cancel])`, threaded as `signal`
850
- - **Connection lifecycle** — admission (`transport.register_pending` → credential re-read → `transport.admit`, which enforces the per-account connection cap) / `remove_connection`, `on_socket_open` / `_close` hooks, server heartbeat
859
+ - **Connection lifecycle** — admission (`registry.register_pending` → `recheck_admission` → `registry.admit`, which enforces the per-account connection cap) / `remove_connection`, `on_socket_open` / `_close` hooks, server heartbeat
851
860
  - **The inbound gate** — frames queue until the socket is admitted and `on_socket_open` has completed; frames on a socket the server closed are dropped
852
861
 
853
862
  **Admission.** `onOpen` registers the connection pending (synchronously, with
854
- the socket's `AbortController`), re-reads the credential captured at upgrade
855
- (`revalidate_resolved_auth({db}, resolved)` — session row / token row / account
856
- row, no touch; `resolved` is `get_resolved_auth(c)`, the one derivation the
857
- audit stream shares, read off the keys the auth middleware set), then
858
- `transport.admit`s. A dead credential, or a pending entry a revocation closed
863
+ the socket's `AbortController`), re-reads what the gates read
864
+ (`recheck_admission({db}, {resolved, request_context, required_roles})`,
865
+ `auth/resolved_auth.ts`, which the audit stream shares: the credential —
866
+ session row / token row / account row, no touch — the acting actor, and the
867
+ role; `resolved` is `get_resolved_auth(c)`, the value the auth middleware
868
+ set), then `registry.admit`s. A dead credential, or a pending entry a revocation closed
859
869
  meanwhile, closes the socket with `WS_CLOSE_SESSION_REVOKED` and the reason a
860
870
  revoked socket gets; a re-check that throws closes it with
861
871
  `WS_CLOSE_INTERNAL_ERROR` (`internal error`) — fail closed, never admitted
862
- unchecked. An endpoint with `required_roles` re-reads them beside the
863
- credential — the acting actor's grants afresh (`refresh_role_grants`), a global
864
- grant of any listed role admitting, as the gate in front did — and refuses a
865
- lost role with `WS_CLOSE_PERMISSION_REVOKED`; a failed role read is the same
866
- 1011. During shutdown a refusal is the shutdown's instead: an upgrade
872
+ unchecked. A soft-deleted acting actor is refused like a dead credential. An
873
+ endpoint with `required_roles` re-reads them beside the credential — the acting
874
+ actor's grants afresh (`refresh_role_grants`), a global grant of any listed role
875
+ admitting, as the gate in front did — and refuses a lost role with
876
+ `WS_CLOSE_PERMISSION_REVOKED`; a failed role read is the same 1011. During shutdown a refusal is the shutdown's instead: an upgrade
867
877
  pending at the close-all was closed by it with `WS_CLOSE_GOING_AWAY` and its
868
878
  controller aborted, so the refusal after the re-read — even one the closing
869
879
  database failed — writes nothing more; an upgrade that registers after it is
@@ -878,13 +888,13 @@ revocation closes only after its commit — see
878
888
  ../../../docs/security.md §Connection Admission and §Closing on Revocation.
879
889
 
880
890
  `connection_closer: RealtimeCloser | null` is a required option: the endpoint's
881
- transport is added to it, so the revocation handlers' post-commit closes reach
891
+ registry is added to it, so the revocation handlers' post-commit closes reach
882
892
  the sockets opened here. The add is the mount's last step, so a mount that
883
893
  throws (a registry that fails to compile) adds nothing; the addition is
884
- permanent, its remover not returned. `null` is for a transport no revocation
894
+ permanent, its remover not returned. `null` is for a registry no revocation
885
895
  has to reach (a harness driving the dispatcher directly), or one the caller
886
896
  adds itself to hold the remover — `create_app_server` passes `null` and adds
887
- the transport after the mount returns, releasing it when assembly fails or
897
+ the registry after the mount returns, releasing it when assembly fails or
888
898
  the server closes.
889
899
 
890
900
  Because `onOpen` awaits, an adapter can deliver `onMessage` before admission
@@ -905,24 +915,24 @@ returns a promise that settles when the frame was dispatched or dropped.
905
915
 
906
916
  The queue holds **every** inbound frame, replies to server-initiated requests
907
917
  included — so an `on_socket_open` hook that awaits
908
- `transport.request_connection` on its own connection gets no reply until it
918
+ `registry.request_connection` on its own connection gets no reply until it
909
919
  returns (it times out); start such a request without awaiting it.
910
920
 
911
921
  **A server-closed socket dispatches nothing.** An adapter can keep delivering
912
922
  frames after the server calls `ws.close(…)`, until the close handshake
913
923
  completes — `@hono/node-ws` does, for up to the `ws` close timeout when the
914
924
  client withholds its close frame. So every server-side close removes the
915
- connection from the transport and aborts the socket's controller **at close
916
- time**: the transport does both for a revocation or a cap eviction, and
917
- `register_action_ws`'s `end_socket` does both — through
918
- `transport.close_connection` — for a heartbeat timeout, a credential
925
+ connection from the registry and aborts the socket's controller **at close
926
+ time**: the registry does both for a revocation or a cap eviction, and
927
+ `ws_socket_session.ts`'s `end_socket` does both — through
928
+ `registry.close_connection` — for a heartbeat timeout, a credential
919
929
  expiry, an oversized message, a failed `on_socket_open`, and a refused
920
930
  admission.
921
931
  `onMessage` then drops any frame whose socket has ended — no dispatch, no
922
- error reply. A connection the transport no longer holds though nothing closed
923
- its socket (a bare `transport.remove_connection`; `transport.is_registered` is
932
+ error reply. A connection the registry no longer holds though nothing closed
933
+ its socket (a bare `registry.remove_connection`; `registry.is_registered` is
924
934
  the twin of the Rust `is_registered`) is ended on its next frame with
925
- `WS_CLOSE_INTERNAL_ERROR` (`connection unregistered`), so it can't linger as a
935
+ `WS_CLOSE_INTERNAL_ERROR` (`WS_CLOSE_CONNECTION_UNREGISTERED_REASON`), so it can't linger as a
926
936
  socket that reads everything, answers nothing, and — being chatty — is never
927
937
  reaped by the heartbeat. Only a frame that is queued or dispatched counts as
928
938
  heartbeat activity.
@@ -932,18 +942,20 @@ heartbeat activity.
932
942
  changes during a connection lifetime are picked up on the next message —
933
943
  no in-place refresh. A revoked global grant of a role the endpoint's
934
944
  `required_roles` lists closes the socket (`WS_CLOSE_PERMISSION_REVOKED`,
935
- through `create_ws_auth_guard`), since nothing else re-checks what it
945
+ through the revocation guard), since nothing else re-checks what it
936
946
  receives. Authentication
937
947
  invalidation (a session or token revoke, `password_change`, a logout, an
938
948
  account delete, a cap eviction) still closes the socket — the revoking
939
- handler through `connection_closer`, `create_ws_auth_guard` again on the
949
+ handler through `connection_closer`, the revocation guard again on the
940
950
  audit row.
941
951
 
942
- Per-message side-effect queues: `pending_effects` (eager) drains via
943
- `flush_pending_effects`; `post_commit_effects` (deferred — pushed by
944
- handlers via `emit_after_commit`) drains via `flush_post_commit_effects`.
945
- Both flush in the same `try/finally` that releases the request controller,
946
- after the reply is sent, and every rejection is logged. Nothing orders that
952
+ Per-message side-effect queues: `pending_effects` (eager) and
953
+ `post_commit_effects` (deferred — pushed by handlers via
954
+ `emit_after_commit`) drain through `flush_request_effects`, the flush the
955
+ HTTP middleware shares. Both flush in the same `try/finally` that releases
956
+ the request controller, after the reply is sent; every rejection is logged
957
+ and reaches `on_effect_error` (`create_app_server` threads its own to the
958
+ endpoints it mounts) with `{transport: 'ws', method, path}`. Nothing orders that
947
959
  flush against other frames: frames on an admitted socket are not serialized
948
960
  (`handle_frame` calls aren't chained, and an adapter need not await
949
961
  `onMessage` — `@hono/node-ws` doesn't), so a message's effects can still be
@@ -973,21 +985,25 @@ held by the cross-backend WS suite.)
973
985
  **Lifecycle hooks.** `on_socket_open({ws, connection_id, identity, notify, signal})`
974
986
  fires once the connection is admitted and before the first message dispatches
975
987
  (frames sent meanwhile wait); awaited; throws log + an `internal_error` frame +
976
- close with `WS_CLOSE_INTERNAL_ERROR` `'socket bootstrap failed'`, unregistering
988
+ close with `WS_CLOSE_INTERNAL_ERROR` and `WS_CLOSE_SOCKET_OPEN_FAILED_REASON`, unregistering
977
989
  the connection.
978
990
  `on_socket_close({ws, connection_id, identity})` fires — only for a socket that
979
991
  was admitted — after
980
- `transport.remove_connection(connection_id)` — a slow hook never holds a dead
992
+ `registry.remove_connection(connection_id)` — a slow hook never holds a dead
981
993
  entry that broadcasts still target and the per-account cap still counts.
982
994
  `connection_id` and `identity` are the values captured at open, so the hook
983
995
  reads them the same way after a client close, a revocation, or a connection-cap
984
996
  eviction; its `ws` is the close event's context, which on some adapters is not
985
997
  the object `on_socket_open` received. Errors logged and swallowed.
986
998
 
987
- **Server-side heartbeat** (`heartbeat?: boolean | ServerHeartbeatOptions`):
988
- default-on, 60s silence timeout. Any inbound message resets
989
- `last_receive_time` — chatty clients never trip it. The timer starts at
990
- admission, and the first timeout window after it is exempt (cold-start grace).
999
+ **Receive timeout** (`receive_timeout?: number | null`, ms): default-on at
1000
+ `DEFAULT_WS_RECEIVE_TIMEOUT` (60s) — the twin of the Rust spine's
1001
+ `ActionWsOptions.receive_timeout` — `null` keeps silent sockets open, and a
1002
+ value that is not positive, or is past `WS_RECEIVE_TIMEOUT_MAX` (2³¹ − 1 ms,
1003
+ the longest delay a timer honors; TS-only), throws at registration. Any
1004
+ inbound message resets `last_receive_time` — chatty clients never trip it. The
1005
+ timer starts at admission, and the first timeout window after it is exempt
1006
+ (cold-start grace).
991
1007
  Tick interval is `timeout / 2`, so event-loop blockage pauses the timer itself.
992
1008
  A timeout unregisters the connection and aborts its signal along with the
993
1009
  `WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT` close.
@@ -1005,7 +1021,7 @@ socket ends. Twin of the Rust loop's `WsLoopOptions::credential_deadline`.
1005
1021
 
1006
1022
  Two abort signals composed via `AbortSignal.any`:
1007
1023
 
1008
- - `socket_abort_controller` — per-socket, fires when the socket ends: at the server's close (revocation, cap eviction, heartbeat timeout, …) or the client's. Registered with the transport, which aborts it on the closes it makes. Drives every handler's `ctx.signal`.
1024
+ - `socket_abort_controller` — per-socket, fires when the socket ends: at the server's close (revocation, cap eviction, heartbeat timeout, …) or the client's. Registered with the registry, which aborts it on the closes it makes. Drives every handler's `ctx.signal`.
1009
1025
  - `pending_controllers: Map<JsonrpcRequestId, AbortController>` — per-request. Registered before dispatch (one entry per running request — a duplicate live id is refused — so its size is the in-flight count the ceiling bounds), cleared in `finally` so late cancels for a completed id (or a reused id) can't null-abort the wrong handler. Unknown cancels no-op.
1010
1026
 
1011
1027
  ## Protocol actions (`actions/protocol.ts`)
@@ -1024,14 +1040,14 @@ Two const arrays:
1024
1040
  - `protocol_actions: ReadonlyArray<Action>` — for the server's `register_action_ws` `actions`. Spread before consumer-owned actions.
1025
1041
  - `protocol_action_specs: ReadonlyArray<ActionSpecUnion>` — derived via `.map(a => a.spec)` so the two arrays cannot drift. For the frontend `ActionRegistry`.
1026
1042
 
1027
- Asymmetry intentional — server runs handlers (heartbeat echo, cancel
1028
- stub, peer/ping round-trip), frontend registry only stores specs. Both
1043
+ Asymmetry intentional — server runs handlers (heartbeat echo, peer/ping
1044
+ round-trip; cancel is dispatcher-owned), frontend registry only stores specs. Both
1029
1045
  bundles plus the codegen `include_protocol_actions: false` default form a
1030
1046
  three-leg contract; `PROTOCOL_ACTION_METHODS` (in `actions/action_codegen.ts`)
1031
1047
  is the method-name set that drives both the codegen filter and the action-manifest
1032
1048
  exclusion.
1033
1049
 
1034
- **Not auto-spread by `create_frontend_rpc_client` or `register_ws_endpoint`** —
1050
+ **Not auto-spread by `create_frontend_rpc_client` or `register_action_ws`** —
1035
1051
  bundled helpers stay pure factories so the dispatch surface stays
1036
1052
  grep-traceable at every registration site and consumers can override
1037
1053
  individual protocol actions without an opt-out flag.
@@ -1039,8 +1055,8 @@ individual protocol actions without an opt-out flag.
1039
1055
  ### Individual actions
1040
1056
 
1041
1057
  - **`heartbeat_action`** — `request_response`, `initiator: 'frontend'`, `auth: 'authenticated'`, `side_effects: false`, parameterless `z.void()` input (absent / `null` / `{}` params — the Rust `require_void_params` shapes), empty-object output. Handler is a stateless no-op echo. Client's activity-aware heartbeat timer fires this whenever idle past `DEFAULT_HEARTBEAT_INTERVAL`; server's `register_action_ws` heartbeat tracker counts the incoming message as activity.
1042
- - **`cancel_action`** — `remote_notification`, `initiator: 'frontend'`, `auth: null`, `side_effects: true`. Params: `CancelNotificationParams = z.strictObject({request_id: JsonrpcRequestId})`. **Handler is an empty stub** — cancel semantics are dispatcher-owned (`register_action_ws` has the `{request_id → AbortController}` map). Wire format is snake_case `cancel` + `{request_id}`, not MCP's `$/cancelRequest` + `{requestId}` — MCP adoption would happen at an MCP adapter's translation layer, not in the base transport.
1043
- - **`peer_ping_action`** — `request_response`, `initiator: 'both'`, `auth: public`, `side_effects: false`. Input `PingActionInput = {nonce?, timeout_ms?}` (`.default({})`); output `PingResponse = {nonce, protocol_version}`. The client→server invocation drives the **server→client** direction: the handler calls `ctx.request_client('peer/ping', {nonce})`, awaits the echo, validates it against `PingResponse` + checks the nonce, and returns it. Over HTTP RPC (`ctx.request_client` absent) it refuses with `peer_no_transport`, so it's mounted on both the WS endpoint (via this bundle) and the HTTP RPC endpoint (the spine full mount). `timeout_ms` is clamped shorten-only. `data.reason` codes (`peer_timeout` / `peer_connection_gone` / `peer_no_transport` / `peer_too_many_in_flight` / `peer_ping_invalid_reply` / `peer_ping_nonce_mismatch`) + the `PingResponse` shape (whose `protocol_version` is `PEER_PROTOCOL_VERSION`) are the cross-impl wire contract (twins of the Rust `REASON_PEER_*`). The frontend half — `peer_ping_responder` (the echo a client sends back, wired into `FrontendWebsocketTransport`) — lives here too. `peer_ping_action` is a plain `RpcAction` literal (not `rpc_action(...)`), so the module stays free of the runtime `action_rpc.ts` import and `protocol_action_specs` doesn't drag the dispatch core into frontend bundles — same discipline as `heartbeat`/`cancel`. See `actions/peer_ping.ts`.
1058
+ - **`cancel_action`** — `remote_notification`, `initiator: 'frontend'`, `auth: null`, `side_effects: true`. Params: `CancelNotificationParams = z.strictObject({request_id: JsonrpcRequestId})`. **No handler** (`cancel_action = {spec}`) — cancel semantics are dispatcher-owned (`register_action_ws` has the `{request_id → AbortController}` map). Wire format is snake_case `cancel` + `{request_id}`, not MCP's `$/cancelRequest` + `{requestId}` — MCP adoption would happen at an MCP adapter's translation layer, not in the base transport.
1059
+ - **`peer_ping_action`** — `request_response`, `initiator: 'both'`, `auth: public`, `side_effects: false`. Input `PingActionInput = {nonce?, timeout_ms?}` (`.default({})`); output `PingResponse = {nonce, protocol_version}`. The client→server invocation drives the **server→client** direction: the handler calls `ctx.request_client('peer/ping', {nonce})`, awaits the echo, validates it against `PingResponse` + checks the nonce, and returns it. Over HTTP RPC (`ctx.request_client` absent) it refuses with `peer_no_transport`, so it's mounted on both the WS endpoint (via this bundle) and the HTTP RPC endpoint (the spine full mount). `timeout_ms` is clamped shorten-only. `data.reason` codes (`peer_timeout` / `peer_connection_gone` / `peer_no_transport` / `peer_too_many_in_flight` / `peer_ping_invalid_reply` / `peer_ping_nonce_mismatch`) + the `PingResponse` shape (whose `protocol_version` is `PEER_PROTOCOL_VERSION`) are the cross-impl wire contract (twins of the Rust `REASON_PEER_*`). The frontend half — `peer_ping_responder` (the echo a client sends back, wired into `FrontendWebsocketTransport`) — lives here too. `peer_ping_action` imports nothing from the dispatch core, so `protocol_action_specs` doesn't drag it into frontend bundles — same discipline as `heartbeat`/`cancel`. See `actions/peer_ping.ts`.
1044
1060
 
1045
1061
  ## Event state machine
1046
1062
 
@@ -1052,7 +1068,7 @@ high-level shapes that span modules:
1052
1068
 
1053
1069
  - **39-variant discriminated union** — `ActionEventDataUnion<TMethod, TInput, TOutput>` across `kind` + `phase` + `step` (28 for `request_response`, 6 for `remote_notification`, 5 for `local_call`). Narrows `input` / `output` / `error` / `request` / `response` / `notification` / `progress` at each lifecycle point.
1054
1070
  - **Step transitions** — `initial → parsed | failed`, `parsed → handling | failed`, `handling → handled | failed`, `handled`/`failed` terminal. `validate_step_transition(from, to)` throws on illegal moves.
1055
- - **Phase transitions** — chained: `send_request → receive_response`, `receive_request → send_response`; everything else terminal. `validate_phase_for_kind` + `validate_phase_transition` enforce.
1071
+ - **Phase transitions** — chained: `send_request → receive_response`, `receive_request → send_response`; everything else terminal. `validate_phase_transition` enforces.
1056
1072
  - **`ActionEvent.parse()`** — `initial → parsed` via `spec.input.safeParse`. Input validation failures **fail immediately** without routing through an error phase (client-side programming errors, not runtime conditions with handlers); their `invalid_params` `data` is `{validation_errors, reason?}`, `reason` the declared `invalid_reason` the server would answer. Handler errors DO route through `send_error` / `receive_error`. On `receive_response` with error response, transitions to `receive_error` instead of failing; a success response's `result` is validated against `spec.output` (always, not DEV-only — it's inbound data; undeclared keys are dropped rather than refused, so an older client survives an added response field) and `output` becomes the parsed value, or the event moves to `receive_error` with an `internal_error` carrying `data: {reason: ERROR_RESPONSE_OUTPUT_INVALID, validation_errors}` — a remote contract break, deliberately distinct from the `invalid_params` / `validation_error` of bad caller input.
1057
1073
  - **Handler throws** — `ThrownJsonrpcError` keeps code/message/data; any other throw becomes `internal_error` carrying the thrown message. When the error answers a remote caller (`receive_request` / `send_response`), the raw message goes through `dev_only` like the server dispatch core.
1058
1074
  - **Protocol message creation is automatic** — transitioning `parsed → handling` on `send_request` materializes the outgoing `JsonrpcRequest` with a fresh `create_uuid()` id; on `send` (notification) it materializes the `JsonrpcNotification`.
@@ -1075,7 +1091,7 @@ all-optional object input accepts a call that omits them).
1075
1091
  "ActionPeer" — unbackticked throughout the peer/ping + `request_client` docs — is
1076
1092
  the _capability_ it participates in: the bidirectional peer request/response
1077
1093
  feature. It's a concept, not a symbol. The server→client half of that capability
1078
- is `BackendWebsocketTransport.request_connection` + `PendingPeerRequests` (see
1094
+ is `ConnectionRegistry.request_connection` + `PendingPeerRequests` (see
1079
1095
  `actions/peer_request.ts`), not this class.
1080
1096
 
1081
1097
  ## Reactive frontend client
@@ -1176,7 +1192,7 @@ doesn't get probed as a thenable by `await`.
1176
1192
 
1177
1193
  ### Frontend factory (`actions/frontend_rpc_client.ts`)
1178
1194
 
1179
- `create_frontend_rpc_client<TApi>({specs, path?, transports?, transport_for_method?, on_action_event?, lookup_action_handler?, log?})`
1195
+ `create_frontend_rpc_client<TApi>({specs, path?, http_headers?, max_get_url_length?, ws?, transports?, transport_for_method?, on_action_event?, lookup_action_handler?, log?})`
1180
1196
  bundles `ActionRegistry + ActionEventEnvironment + Transports + ActionDispatcher +
1181
1197
  create_rpc_client + create_throwing_api` boilerplate every consumer
1182
1198
  repeats — plus the `lookup_action_handler: () => undefined` stub (frontend
@@ -1188,12 +1204,21 @@ Returns both Proxy shapes from one factory call:
1188
1204
  - `api: ThrowingApi<TApi>` — typed throwing Proxy. Default for hot-path call sites.
1189
1205
  - `api_result: TApi` — typed Result-shaped Proxy. For sites that inspect `error.data.reason` without try/catch.
1190
1206
  - `peer`, `environment` — exposed for advanced consumers.
1191
-
1192
- Default transport is `FrontendHttpTransport(path ?? '/api/rpc')`. Pass
1193
- `transports` for WS-first or mixed setups (the default HTTP transport is
1194
- **not** registered when `transports` is supplied). `local_call` specs in
1195
- `specs` silently no-op because `lookup_action_handler` always returns
1196
- `undefined`.
1207
+ - `socket` — the `ws.client`, or `null`.
1208
+
1209
+ Transports: a `FrontendHttpTransport` on `path ?? '/api/rpc'` over the
1210
+ registry's `lookup_action_spec` (a hand-built transport passes its own
1211
+ environment's), so a read goes as a GET; and, with `ws: {client, queue?, max_message_bytes?}`, a
1212
+ `FrontendWebsocketTransport` over the caller's client, registered after it,
1213
+ which every `request_response` method routes to unless `transport_for_method`
1214
+ says otherwise (HTTP stays the fallback while the socket is down). The caller
1215
+ builds and connects the client — `new
1216
+ FrontendWebsocketClient(to_same_origin_ws_url('/api/ws'))` — so the factory
1217
+ never imports `socket.svelte.ts` and an HTTP-only bundle stays socket-free.
1218
+ `ws.queue` sets the peer's default `queue` (Queue routing above). Pass
1219
+ `transports` to replace the built-ins (exclusive with `ws`, `http_headers`,
1220
+ `max_get_url_length`). `local_call` specs in `specs` silently no-op because
1221
+ `lookup_action_handler` always returns `undefined`.
1197
1222
 
1198
1223
  `all_standard_action_specs` (in `auth/standard_action_specs.ts`) is
1199
1224
  transport-agnostic — when a consumer spreads `create_standard_rpc_actions`
@@ -1204,24 +1229,23 @@ route per-call (e.g. return `'frontend_websocket_rpc'` for `account_*` /
1204
1229
 
1205
1230
  ## Broadcast API (`actions/broadcast_api.ts`)
1206
1231
 
1207
- `create_broadcast_api({peer, specs, log?, should_deliver?})` — builds a
1232
+ `create_broadcast_api({registry, specs, log?, should_deliver?})` — builds a
1208
1233
  typed `{method: (input) => Promise<void>}` object from a list of action
1209
1234
  specs. Counterpart to `register_action_ws`: that handles frontend-initiated
1210
1235
  request-scoped dispatch, this handles backend-initiated broadcast.
1211
1236
  Request-scoped streaming stays on `ctx.notify` inside a handler.
1212
1237
 
1213
1238
  Per-method call: validates input against `spec.input` (logs + returns on
1214
- failure), wraps in `JsonrpcNotification`, sends via the peer's resolved
1215
- transport. `transport_name` on `peer.default_send_options` pins the target
1216
- deterministically — no fallback, because broadcast is 1→N over a specific
1217
- primary transport and "any ready transport" could reach an unexpected
1218
- audience. Silently skips when none ready.
1239
+ failure), wraps in `JsonrpcNotification`, and sends it on `registry` — a
1240
+ `BroadcastTarget`, `Pick<ConnectionRegistry, 'broadcast' |
1241
+ 'broadcast_filtered'>`, typically `app_server.ws_endpoints[path]` or the
1242
+ registry a `WsEndpointSpec` supplies. No `Transports` collection and no fallback:
1243
+ broadcast is 1→N over one named registry. No connections reaches nobody.
1219
1244
 
1220
1245
  `should_deliver: (identity, method, input) => boolean` — optional
1221
1246
  per-connection ACL predicate. When set, fans out via
1222
- `transport.broadcast_filtered` (feature-detected via
1223
- `is_filterable_broadcast_transport`). Errors logged but never thrown —
1224
- broadcasts are fire-and-forget.
1247
+ `registry.broadcast_filtered`; otherwise `registry.broadcast`. Errors logged
1248
+ but never thrown — broadcasts are fire-and-forget.
1225
1249
 
1226
1250
  Typed surface: consumers declare an explicit `interface BackendActionsApi`
1227
1251
  and pin via `create_broadcast_api<BackendActionsApi>({...})` — unchecked
@@ -1234,5 +1258,6 @@ Sits above `action_spec.ts` (pure Zod) and below the dispatchers. Extracted
1234
1258
  so composable primitives (e.g. `heartbeat_action`) can name the types
1235
1259
  without pulling in server-only modules.
1236
1260
 
1237
- - `Action<TSpec>` — `{spec: TSpec, handler?: ActionHandler}`. Polymorphic on `kind`: `request_response` specs require a handler for dispatch; `remote_notification` specs may declare a stub for symmetry but are dispatcher-handled (e.g. `cancel`); `local_call` specs never reach a network dispatcher.
1238
- - `RpcAction = Action<RequestResponseActionSpec> & {handler: ActionHandler}` — narrowing the HTTP RPC dispatcher accepts (`create_rpc_endpoint`) and the `rpc_action` binder produces.
1261
+ - `Action<TSpec>` — `{spec: TSpec, handler?: ActionHandler}`. Polymorphic on `kind`: `request_response` specs require a handler for dispatch; `remote_notification` specs are dispatcher-handled (e.g. `cancel`, which has no handler); `local_call` specs never reach a network dispatcher.
1262
+ - `ActionContext` + its narrowed tiers (`ActionAuthContext`, `ActionActorContext`), the handler signatures (`ActionHandler`, `AuthActionHandler`, `ActorActionHandler`), `HandlerForSpec`, and the `rpc_action` binder — the handler-side surface every action factory names. `actions/action_rpc.ts` keeps only `create_rpc_endpoint` + its options.
1263
+ - `RpcAction` — `{spec: RequestResponseActionSpec, handler: ActionHandler}`, what the dispatchers accept (`create_rpc_endpoint`, `register_action_ws`) and the `rpc_action` binder produces.