@fuzdev/fuz_app 0.149.0 → 0.151.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 (650) hide show
  1. package/README.md +1 -1
  2. package/dist/actions/CLAUDE.md +327 -300
  3. package/dist/actions/action_bridge.d.ts +5 -79
  4. package/dist/actions/action_bridge.d.ts.map +1 -1
  5. package/dist/actions/action_bridge.js +4 -74
  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_event_types.d.ts +1 -1
  19. package/dist/actions/action_event_types.d.ts.map +1 -1
  20. package/dist/actions/action_rpc.d.ts +10 -215
  21. package/dist/actions/action_rpc.d.ts.map +1 -1
  22. package/dist/actions/action_rpc.js +56 -111
  23. package/dist/actions/action_spec.d.ts +2 -2
  24. package/dist/actions/action_spec.js +2 -2
  25. package/dist/actions/action_types.d.ts +229 -8
  26. package/dist/actions/action_types.d.ts.map +1 -1
  27. package/dist/actions/action_types.js +56 -5
  28. package/dist/actions/broadcast_api.d.ts +22 -17
  29. package/dist/actions/broadcast_api.d.ts.map +1 -1
  30. package/dist/actions/broadcast_api.js +16 -27
  31. package/dist/actions/cancel.d.ts +4 -13
  32. package/dist/actions/cancel.d.ts.map +1 -1
  33. package/dist/actions/cancel.js +5 -17
  34. package/dist/actions/compile_action_registry.d.ts +1 -2
  35. package/dist/actions/compile_action_registry.d.ts.map +1 -1
  36. package/dist/actions/connection_closer.d.ts +120 -50
  37. package/dist/actions/connection_closer.d.ts.map +1 -1
  38. package/dist/actions/connection_closer.js +139 -31
  39. package/dist/actions/{transports_ws_backend.d.ts → connection_registry.d.ts} +120 -132
  40. package/dist/actions/connection_registry.d.ts.map +1 -0
  41. package/dist/actions/{transports_ws_backend.js → connection_registry.js} +149 -152
  42. package/dist/actions/frontend_rpc_client.d.ts +52 -2
  43. package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
  44. package/dist/actions/frontend_rpc_client.js +42 -4
  45. package/dist/actions/peer_ping.d.ts +7 -9
  46. package/dist/actions/peer_ping.d.ts.map +1 -1
  47. package/dist/actions/peer_ping.js +6 -8
  48. package/dist/actions/peer_request.d.ts +6 -5
  49. package/dist/actions/peer_request.d.ts.map +1 -1
  50. package/dist/actions/peer_request.js +6 -5
  51. package/dist/actions/perform_action.d.ts +36 -28
  52. package/dist/actions/perform_action.d.ts.map +1 -1
  53. package/dist/actions/perform_action.js +60 -31
  54. package/dist/actions/protocol.d.ts +14 -0
  55. package/dist/actions/protocol.d.ts.map +1 -1
  56. package/dist/actions/protocol.js +18 -0
  57. package/dist/actions/register_action_ws.d.ts +137 -292
  58. package/dist/actions/register_action_ws.d.ts.map +1 -1
  59. package/dist/actions/register_action_ws.js +155 -903
  60. package/dist/actions/socket.svelte.d.ts +9 -0
  61. package/dist/actions/socket.svelte.d.ts.map +1 -1
  62. package/dist/actions/socket.svelte.js +16 -5
  63. package/dist/actions/transports.d.ts +88 -34
  64. package/dist/actions/transports.d.ts.map +1 -1
  65. package/dist/actions/transports.js +76 -76
  66. package/dist/actions/transports_http.d.ts +48 -12
  67. package/dist/actions/transports_http.d.ts.map +1 -1
  68. package/dist/actions/transports_http.js +75 -44
  69. package/dist/actions/transports_ws.d.ts +29 -0
  70. package/dist/actions/transports_ws.d.ts.map +1 -1
  71. package/dist/actions/transports_ws.js +34 -8
  72. package/dist/actions/ws_endpoint_spec.d.ts +53 -76
  73. package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
  74. package/dist/actions/ws_endpoint_spec.js +27 -10
  75. package/dist/actions/ws_outbound_writer.d.ts +3 -3
  76. package/dist/actions/ws_outbound_writer.js +3 -3
  77. package/dist/actions/ws_socket_session.d.ts +321 -0
  78. package/dist/actions/ws_socket_session.d.ts.map +1 -0
  79. package/dist/actions/ws_socket_session.js +783 -0
  80. package/dist/auth/CLAUDE.md +132 -68
  81. package/dist/auth/account_action_specs.d.ts +2 -0
  82. package/dist/auth/account_action_specs.d.ts.map +1 -1
  83. package/dist/auth/account_actions.d.ts +1 -1
  84. package/dist/auth/account_actions.d.ts.map +1 -1
  85. package/dist/auth/account_actions.js +9 -3
  86. package/dist/auth/account_queries.d.ts +10 -0
  87. package/dist/auth/account_queries.d.ts.map +1 -1
  88. package/dist/auth/account_queries.js +27 -17
  89. package/dist/auth/account_routes.d.ts +2 -1
  90. package/dist/auth/account_routes.d.ts.map +1 -1
  91. package/dist/auth/account_routes.js +14 -17
  92. package/dist/auth/account_schema.d.ts +5 -5
  93. package/dist/auth/account_schema.d.ts.map +1 -1
  94. package/dist/auth/account_schema.js +5 -2
  95. package/dist/auth/actor_lookup_actions.d.ts +1 -1
  96. package/dist/auth/actor_lookup_actions.d.ts.map +1 -1
  97. package/dist/auth/actor_lookup_actions.js +1 -1
  98. package/dist/auth/actor_lookup_queries.d.ts +3 -2
  99. package/dist/auth/actor_lookup_queries.d.ts.map +1 -1
  100. package/dist/auth/actor_lookup_queries.js +6 -3
  101. package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
  102. package/dist/auth/actor_search_action_specs.js +2 -1
  103. package/dist/auth/actor_search_actions.d.ts +1 -1
  104. package/dist/auth/actor_search_actions.d.ts.map +1 -1
  105. package/dist/auth/actor_search_actions.js +1 -1
  106. package/dist/auth/actor_search_queries.d.ts +10 -7
  107. package/dist/auth/actor_search_queries.d.ts.map +1 -1
  108. package/dist/auth/actor_search_queries.js +18 -11
  109. package/dist/auth/admin_action_specs.d.ts +4 -4
  110. package/dist/auth/admin_action_specs.d.ts.map +1 -1
  111. package/dist/auth/admin_action_specs.js +7 -5
  112. package/dist/auth/admin_actions.d.ts +1 -1
  113. package/dist/auth/admin_actions.d.ts.map +1 -1
  114. package/dist/auth/admin_actions.js +47 -48
  115. package/dist/auth/all_cell_actions.d.ts +14 -3
  116. package/dist/auth/all_cell_actions.d.ts.map +1 -1
  117. package/dist/auth/all_cell_actions.js +2 -1
  118. package/dist/auth/api_token_queries.d.ts +1 -0
  119. package/dist/auth/api_token_queries.d.ts.map +1 -1
  120. package/dist/auth/api_token_queries.js +1 -0
  121. package/dist/auth/audit_emitter.d.ts +12 -6
  122. package/dist/auth/audit_emitter.d.ts.map +1 -1
  123. package/dist/auth/audit_emitter.js +11 -5
  124. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  125. package/dist/auth/audit_log_route_schema.js +3 -2
  126. package/dist/auth/audit_log_routes.d.ts +20 -11
  127. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  128. package/dist/auth/audit_log_routes.js +49 -29
  129. package/dist/auth/audit_log_schema.d.ts +14 -21
  130. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  131. package/dist/auth/audit_log_schema.js +19 -23
  132. package/dist/auth/bearer_auth.d.ts +7 -4
  133. package/dist/auth/bearer_auth.d.ts.map +1 -1
  134. package/dist/auth/bearer_auth.js +21 -15
  135. package/dist/auth/bootstrap_account.d.ts +25 -1
  136. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  137. package/dist/auth/bootstrap_account.js +37 -4
  138. package/dist/auth/bootstrap_routes.d.ts +3 -2
  139. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  140. package/dist/auth/bootstrap_routes.js +5 -4
  141. package/dist/auth/cell_action_helpers.d.ts +89 -0
  142. package/dist/auth/cell_action_helpers.d.ts.map +1 -0
  143. package/dist/auth/cell_action_helpers.js +113 -0
  144. package/dist/auth/cell_action_specs.d.ts +215 -15
  145. package/dist/auth/cell_action_specs.d.ts.map +1 -1
  146. package/dist/auth/cell_action_specs.js +103 -16
  147. package/dist/auth/cell_actions.d.ts +58 -27
  148. package/dist/auth/cell_actions.d.ts.map +1 -1
  149. package/dist/auth/cell_actions.js +206 -161
  150. package/dist/auth/cell_audit_actions.d.ts +1 -1
  151. package/dist/auth/cell_audit_actions.d.ts.map +1 -1
  152. package/dist/auth/cell_audit_actions.js +3 -12
  153. package/dist/auth/cell_audit_events.d.ts +1 -1
  154. package/dist/auth/cell_audit_events.d.ts.map +1 -1
  155. package/dist/auth/cell_audit_events.js +3 -2
  156. package/dist/auth/cell_audit_metadata.d.ts +12 -1
  157. package/dist/auth/cell_audit_metadata.d.ts.map +1 -1
  158. package/dist/auth/cell_audit_metadata.js +11 -1
  159. package/dist/auth/cell_field_actions.d.ts +1 -1
  160. package/dist/auth/cell_field_actions.d.ts.map +1 -1
  161. package/dist/auth/cell_field_actions.js +16 -66
  162. package/dist/auth/cell_grant_action_specs.d.ts +9 -2
  163. package/dist/auth/cell_grant_action_specs.d.ts.map +1 -1
  164. package/dist/auth/cell_grant_action_specs.js +10 -3
  165. package/dist/auth/cell_grant_actions.d.ts +105 -11
  166. package/dist/auth/cell_grant_actions.d.ts.map +1 -1
  167. package/dist/auth/cell_grant_actions.js +81 -56
  168. package/dist/auth/cell_grant_audit_metadata.d.ts +6 -3
  169. package/dist/auth/cell_grant_audit_metadata.d.ts.map +1 -1
  170. package/dist/auth/cell_grant_audit_metadata.js +7 -4
  171. package/dist/auth/cell_item_actions.d.ts +1 -1
  172. package/dist/auth/cell_item_actions.d.ts.map +1 -1
  173. package/dist/auth/cell_item_actions.js +21 -82
  174. package/dist/auth/cleanup.d.ts +1 -1
  175. package/dist/auth/cleanup.d.ts.map +1 -1
  176. package/dist/auth/cleanup.js +6 -3
  177. package/dist/auth/credential_deadline.d.ts +3 -3
  178. package/dist/auth/credential_deadline.js +3 -3
  179. package/dist/auth/credential_type_schema.d.ts +8 -7
  180. package/dist/auth/credential_type_schema.d.ts.map +1 -1
  181. package/dist/auth/credential_type_schema.js +8 -7
  182. package/dist/auth/daemon_token_middleware.d.ts +12 -6
  183. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  184. package/dist/auth/daemon_token_middleware.js +28 -17
  185. package/dist/auth/deps.d.ts +4 -4
  186. package/dist/auth/fail_floor.d.ts +55 -0
  187. package/dist/auth/fail_floor.d.ts.map +1 -0
  188. package/dist/auth/fail_floor.js +63 -0
  189. package/dist/auth/invite_queries.d.ts +3 -15
  190. package/dist/auth/invite_queries.d.ts.map +1 -1
  191. package/dist/auth/invite_queries.js +3 -21
  192. package/dist/auth/middleware.d.ts +12 -7
  193. package/dist/auth/middleware.d.ts.map +1 -1
  194. package/dist/auth/middleware.js +42 -29
  195. package/dist/auth/migrations.d.ts +5 -33
  196. package/dist/auth/migrations.d.ts.map +1 -1
  197. package/dist/auth/migrations.js +9 -16
  198. package/dist/auth/request_context.d.ts +101 -71
  199. package/dist/auth/request_context.d.ts.map +1 -1
  200. package/dist/auth/request_context.js +137 -140
  201. package/dist/auth/resolved_auth.d.ts +122 -36
  202. package/dist/auth/resolved_auth.d.ts.map +1 -1
  203. package/dist/auth/resolved_auth.js +89 -38
  204. package/dist/auth/role_grant_offer_action_specs.d.ts +117 -16
  205. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  206. package/dist/auth/role_grant_offer_action_specs.js +51 -16
  207. package/dist/auth/role_grant_offer_actions.d.ts +22 -11
  208. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  209. package/dist/auth/role_grant_offer_actions.js +72 -19
  210. package/dist/auth/role_grant_offer_notifications.d.ts +6 -5
  211. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  212. package/dist/auth/role_grant_offer_notifications.js +4 -3
  213. package/dist/auth/role_grant_offer_queries.d.ts +20 -5
  214. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  215. package/dist/auth/role_grant_offer_queries.js +40 -37
  216. package/dist/auth/role_grant_queries.d.ts +44 -76
  217. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  218. package/dist/auth/role_grant_queries.js +73 -118
  219. package/dist/auth/role_grant_sql.d.ts +42 -0
  220. package/dist/auth/role_grant_sql.d.ts.map +1 -0
  221. package/dist/auth/role_grant_sql.js +54 -0
  222. package/dist/auth/role_schema.d.ts +14 -8
  223. package/dist/auth/role_schema.d.ts.map +1 -1
  224. package/dist/auth/role_schema.js +6 -3
  225. package/dist/auth/scope_kind_schema.d.ts +1 -1
  226. package/dist/auth/scope_kind_schema.js +1 -1
  227. package/dist/auth/self_service_role_actions.d.ts +1 -1
  228. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  229. package/dist/auth/self_service_role_actions.js +21 -1
  230. package/dist/auth/session_queries.d.ts +2 -1
  231. package/dist/auth/session_queries.d.ts.map +1 -1
  232. package/dist/auth/session_queries.js +2 -1
  233. package/dist/auth/signup_routes.d.ts +2 -1
  234. package/dist/auth/signup_routes.d.ts.map +1 -1
  235. package/dist/auth/signup_routes.js +14 -13
  236. package/dist/auth/standard_rpc_actions.d.ts +1 -1
  237. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  238. package/dist/auth/token_scope.d.ts +19 -46
  239. package/dist/auth/token_scope.d.ts.map +1 -1
  240. package/dist/auth/token_scope.js +23 -41
  241. package/dist/db/CLAUDE.md +18 -6
  242. package/dist/db/cell_ddl.d.ts +5 -134
  243. package/dist/db/cell_ddl.d.ts.map +1 -1
  244. package/dist/db/cell_ddl.js +28 -17
  245. package/dist/db/cell_field_queries.d.ts +0 -13
  246. package/dist/db/cell_field_queries.d.ts.map +1 -1
  247. package/dist/db/cell_field_queries.js +0 -16
  248. package/dist/db/cell_grant_queries.d.ts +10 -5
  249. package/dist/db/cell_grant_queries.d.ts.map +1 -1
  250. package/dist/db/cell_grant_queries.js +13 -7
  251. package/dist/db/cell_item_queries.d.ts +0 -7
  252. package/dist/db/cell_item_queries.d.ts.map +1 -1
  253. package/dist/db/cell_item_queries.js +0 -10
  254. package/dist/db/cell_queries.d.ts +65 -55
  255. package/dist/db/cell_queries.d.ts.map +1 -1
  256. package/dist/db/cell_queries.js +85 -62
  257. package/dist/db/cell_view_sql.d.ts +1 -6
  258. package/dist/db/cell_view_sql.d.ts.map +1 -1
  259. package/dist/db/cell_view_sql.js +1 -2
  260. package/dist/db/fact_ddl.d.ts +5 -30
  261. package/dist/db/fact_ddl.d.ts.map +1 -1
  262. package/dist/db/fact_ddl.js +14 -13
  263. package/dist/db/fact_store.d.ts +11 -0
  264. package/dist/db/fact_store.d.ts.map +1 -1
  265. package/dist/db/fact_store.js +4 -1
  266. package/dist/db/migrate.d.ts +44 -6
  267. package/dist/db/migrate.d.ts.map +1 -1
  268. package/dist/db/migrate.js +63 -4
  269. package/dist/dev/setup.d.ts +18 -14
  270. package/dist/dev/setup.d.ts.map +1 -1
  271. package/dist/dev/setup.js +42 -39
  272. package/dist/env/dotenv.d.ts +2 -2
  273. package/dist/env/dotenv.js +2 -2
  274. package/dist/env/update_env_variable.d.ts +33 -21
  275. package/dist/env/update_env_variable.d.ts.map +1 -1
  276. package/dist/env/update_env_variable.js +54 -35
  277. package/dist/hono_context.d.ts +15 -90
  278. package/dist/hono_context.d.ts.map +1 -1
  279. package/dist/hono_context.js +9 -56
  280. package/dist/http/CLAUDE.md +35 -20
  281. package/dist/http/auth_shape.d.ts +1 -8
  282. package/dist/http/auth_shape.d.ts.map +1 -1
  283. package/dist/http/auth_shape.js +6 -12
  284. package/dist/http/body_limit.d.ts +3 -1
  285. package/dist/http/body_limit.d.ts.map +1 -1
  286. package/dist/http/body_limit.js +6 -1
  287. package/dist/http/common_routes.d.ts.map +1 -1
  288. package/dist/http/common_routes.js +3 -2
  289. package/dist/http/db_routes.d.ts +3 -3
  290. package/dist/http/db_routes.js +3 -3
  291. package/dist/http/error_schemas.d.ts +1 -2
  292. package/dist/http/error_schemas.d.ts.map +1 -1
  293. package/dist/http/error_schemas.js +1 -2
  294. package/dist/http/health_schema.d.ts +16 -0
  295. package/dist/http/health_schema.d.ts.map +1 -0
  296. package/dist/http/health_schema.js +12 -0
  297. package/dist/http/jsonrpc.d.ts +9 -0
  298. package/dist/http/jsonrpc.d.ts.map +1 -1
  299. package/dist/http/jsonrpc.js +17 -0
  300. package/dist/http/jsonrpc_errors.d.ts +22 -2
  301. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  302. package/dist/http/jsonrpc_errors.js +70 -23
  303. package/dist/http/jsonrpc_helpers.d.ts +60 -17
  304. package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
  305. package/dist/http/jsonrpc_helpers.js +67 -25
  306. package/dist/http/origin.d.ts +30 -1
  307. package/dist/http/origin.d.ts.map +1 -1
  308. package/dist/http/origin.js +46 -9
  309. package/dist/http/origin_wildcard.d.ts +97 -0
  310. package/dist/http/origin_wildcard.d.ts.map +1 -0
  311. package/dist/http/origin_wildcard.js +142 -0
  312. package/dist/http/pending_effects.d.ts +28 -0
  313. package/dist/http/pending_effects.d.ts.map +1 -1
  314. package/dist/http/pending_effects.js +32 -1
  315. package/dist/http/proxy.d.ts +4 -2
  316. package/dist/http/proxy.d.ts.map +1 -1
  317. package/dist/http/proxy.js +7 -2
  318. package/dist/http/route_spec.d.ts +4 -3
  319. package/dist/http/route_spec.d.ts.map +1 -1
  320. package/dist/http/route_spec.js +54 -45
  321. package/dist/http/surface.d.ts +4 -2
  322. package/dist/http/surface.d.ts.map +1 -1
  323. package/dist/http/surface.js +7 -4
  324. package/dist/http/surface_query.d.ts +9 -50
  325. package/dist/http/surface_query.d.ts.map +1 -1
  326. package/dist/http/surface_query.js +48 -94
  327. package/dist/realtime/audit_log_sse.d.ts +180 -0
  328. package/dist/realtime/audit_log_sse.d.ts.map +1 -0
  329. package/dist/realtime/audit_log_sse.js +154 -0
  330. package/dist/realtime/sse.d.ts +21 -6
  331. package/dist/realtime/sse.d.ts.map +1 -1
  332. package/dist/realtime/sse.js +33 -10
  333. package/dist/realtime/sse_constants.d.ts +29 -2
  334. package/dist/realtime/sse_constants.d.ts.map +1 -1
  335. package/dist/realtime/sse_constants.js +35 -2
  336. package/dist/realtime/{subscriber_registry.d.ts → sse_registry.d.ts} +12 -12
  337. package/dist/realtime/sse_registry.d.ts.map +1 -0
  338. package/dist/realtime/{subscriber_registry.js → sse_registry.js} +4 -4
  339. package/dist/schema_meta.d.ts +52 -1
  340. package/dist/schema_meta.d.ts.map +1 -1
  341. package/dist/schema_meta.js +123 -6
  342. package/dist/sensitivity.d.ts +9 -3
  343. package/dist/sensitivity.d.ts.map +1 -1
  344. package/dist/sensitivity.js +3 -2
  345. package/dist/server/app_backend.d.ts +8 -5
  346. package/dist/server/app_backend.d.ts.map +1 -1
  347. package/dist/server/app_backend.js +6 -12
  348. package/dist/server/app_server.d.ts +73 -54
  349. package/dist/server/app_server.d.ts.map +1 -1
  350. package/dist/server/app_server.js +115 -78
  351. package/dist/server/app_server_context.d.ts +1 -1
  352. package/dist/server/app_server_context.d.ts.map +1 -1
  353. package/dist/server/env.d.ts +24 -20
  354. package/dist/server/env.d.ts.map +1 -1
  355. package/dist/server/env.js +24 -34
  356. package/dist/server/serve_fact_route.d.ts +12 -16
  357. package/dist/server/serve_fact_route.d.ts.map +1 -1
  358. package/dist/server/serve_fact_route.js +59 -34
  359. package/dist/server/static.d.ts.map +1 -1
  360. package/dist/server/static.js +2 -2
  361. package/dist/testing/CLAUDE.md +213 -179
  362. package/dist/testing/admin_integration.d.ts.map +1 -1
  363. package/dist/testing/admin_integration.js +10 -19
  364. package/dist/testing/adversarial_headers.d.ts.map +1 -1
  365. package/dist/testing/adversarial_headers.js +8 -0
  366. package/dist/testing/app_server.d.ts +9 -75
  367. package/dist/testing/app_server.d.ts.map +1 -1
  368. package/dist/testing/app_server.js +31 -112
  369. package/dist/testing/attack_surface.d.ts.map +1 -1
  370. package/dist/testing/attack_surface.js +3 -4
  371. package/dist/testing/audit_completeness.d.ts.map +1 -1
  372. package/dist/testing/audit_completeness.js +4 -5
  373. package/dist/testing/auth_apps.d.ts +3 -3
  374. package/dist/testing/auth_apps.d.ts.map +1 -1
  375. package/dist/testing/auth_apps.js +9 -6
  376. package/dist/testing/connection_closer_helpers.d.ts +8 -16
  377. package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
  378. package/dist/testing/connection_closer_helpers.js +7 -20
  379. package/dist/testing/cross_backend/action_manifest.d.ts +15 -4
  380. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  381. package/dist/testing/cross_backend/action_manifest.js +13 -3
  382. package/dist/testing/cross_backend/action_manifest_parity.d.ts +15 -7
  383. package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
  384. package/dist/testing/cross_backend/action_manifest_parity.js +8 -1
  385. package/dist/testing/cross_backend/actor_lookup.d.ts.map +1 -1
  386. package/dist/testing/cross_backend/actor_lookup.js +27 -0
  387. package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
  388. package/dist/testing/cross_backend/body_size.js +25 -22
  389. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +22 -3
  390. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  391. package/dist/testing/cross_backend/build_test_backend_paths.js +34 -11
  392. package/dist/testing/cross_backend/capabilities.d.ts +15 -8
  393. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  394. package/dist/testing/cross_backend/cell_gated_create.d.ts.map +1 -1
  395. package/dist/testing/cross_backend/cell_gated_create.js +109 -13
  396. package/dist/testing/cross_backend/cell_grant_role.js +2 -2
  397. package/dist/testing/cross_backend/cell_grant_steward.d.ts +4 -0
  398. package/dist/testing/cross_backend/cell_grant_steward.d.ts.map +1 -0
  399. package/dist/testing/cross_backend/cell_grant_steward.js +120 -0
  400. package/dist/testing/cross_backend/cell_moderate.d.ts +7 -1
  401. package/dist/testing/cross_backend/cell_moderate.d.ts.map +1 -1
  402. package/dist/testing/cross_backend/cell_moderate.js +68 -4
  403. package/dist/testing/cross_backend/cell_ref_admission.d.ts.map +1 -1
  404. package/dist/testing/cross_backend/cell_ref_admission.js +18 -9
  405. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  406. package/dist/testing/cross_backend/cell_relations.js +21 -0
  407. package/dist/testing/cross_backend/conformance_table.d.ts +6 -1
  408. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  409. package/dist/testing/cross_backend/conformance_table.js +12 -10
  410. package/dist/testing/cross_backend/default_backend_configs.d.ts +18 -4
  411. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  412. package/dist/testing/cross_backend/default_backend_configs.js +29 -9
  413. package/dist/testing/cross_backend/default_spine_surface.d.ts +7 -7
  414. package/dist/testing/cross_backend/default_spine_surface.js +2 -2
  415. package/dist/testing/cross_backend/differential.d.ts +7 -0
  416. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  417. package/dist/testing/cross_backend/differential.js +17 -0
  418. package/dist/testing/cross_backend/expected_schema.json +1 -0
  419. package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
  420. package/dist/testing/cross_backend/fact_serving.js +48 -0
  421. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -4
  422. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  423. package/dist/testing/cross_backend/full_spine_mount.js +13 -5
  424. package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -1
  425. package/dist/testing/cross_backend/origin_scope.js +5 -13
  426. package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
  427. package/dist/testing/cross_backend/peer_ping_ws.js +29 -4
  428. package/dist/testing/cross_backend/postgres_database.d.ts +32 -0
  429. package/dist/testing/cross_backend/postgres_database.d.ts.map +1 -1
  430. package/dist/testing/cross_backend/postgres_database.js +56 -1
  431. package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
  432. package/dist/testing/cross_backend/query_shape.js +18 -1
  433. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  434. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +96 -2
  435. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -2
  436. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
  437. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  438. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +17 -5
  439. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  440. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +5 -4
  441. package/dist/testing/cross_backend/session_cap.d.ts +8 -0
  442. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  443. package/dist/testing/cross_backend/session_cap.js +66 -2
  444. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  445. package/dist/testing/cross_backend/setup.js +5 -4
  446. package/dist/testing/cross_backend/spine_suites.d.ts +4 -1
  447. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  448. package/dist/testing/cross_backend/spine_suites.js +21 -0
  449. package/dist/testing/cross_backend/spine_surface_constants.d.ts +22 -7
  450. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  451. package/dist/testing/cross_backend/spine_surface_constants.js +22 -7
  452. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  453. package/dist/testing/cross_backend/sse_round_trip.js +4 -3
  454. package/dist/testing/cross_backend/standard.d.ts +6 -12
  455. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  456. package/dist/testing/cross_backend/test_cell_gated_create_authorize.d.ts +18 -19
  457. package/dist/testing/cross_backend/test_cell_gated_create_authorize.d.ts.map +1 -1
  458. package/dist/testing/cross_backend/test_cell_gated_create_authorize.js +66 -42
  459. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts +8 -0
  460. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts.map +1 -0
  461. package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.js +22 -0
  462. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  463. package/dist/testing/cross_backend/testing_backdoor.js +4 -6
  464. package/dist/testing/cross_backend/testing_origin_check.d.ts +1 -1
  465. package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
  466. package/dist/testing/cross_backend/testing_origin_check.js +1 -1
  467. package/dist/testing/cross_backend/testing_reset_actions.d.ts +10 -5
  468. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  469. package/dist/testing/cross_backend/testing_reset_actions.js +7 -6
  470. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  471. package/dist/testing/cross_backend/testing_server_bun.js +5 -4
  472. package/dist/testing/cross_backend/testing_server_core.d.ts +6 -7
  473. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  474. package/dist/testing/cross_backend/testing_server_core.js +1 -1
  475. package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
  476. package/dist/testing/cross_backend/testing_server_node.js +13 -2
  477. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  478. package/dist/testing/cross_backend/token_lifetime.js +68 -0
  479. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  480. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  481. package/dist/testing/cross_backend/transport_composition.js +48 -6
  482. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +16 -2
  483. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  484. package/dist/testing/cross_backend/ts_spine_backend_config.js +11 -8
  485. package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
  486. package/dist/testing/cross_backend/ws_action_rate_limit.js +30 -12
  487. package/dist/testing/cross_backend/ws_connection_cap.d.ts.map +1 -1
  488. package/dist/testing/cross_backend/ws_connection_cap.js +5 -7
  489. package/dist/testing/cross_backend/ws_endpoint.d.ts +2 -3
  490. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  491. package/dist/testing/cross_backend/ws_envelope.d.ts +17 -0
  492. package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -0
  493. package/dist/testing/cross_backend/ws_envelope.js +172 -0
  494. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts +16 -0
  495. package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts.map +1 -1
  496. package/dist/testing/cross_backend/ws_inbound_dispatch.js +8 -4
  497. package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
  498. package/dist/testing/cross_backend/ws_outbound_overflow.js +5 -8
  499. package/dist/testing/cross_backend/ws_role_gated.js +2 -2
  500. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  501. package/dist/testing/cross_backend/ws_round_trip.js +6 -4
  502. package/dist/{cli/daemon.d.ts → testing/daemon_info.d.ts} +15 -47
  503. package/dist/testing/daemon_info.d.ts.map +1 -0
  504. package/dist/testing/daemon_info.js +108 -0
  505. package/dist/testing/daemon_token_rotation.js +1 -1
  506. package/dist/testing/data_exposure.d.ts.map +1 -1
  507. package/dist/testing/data_exposure.js +3 -4
  508. package/dist/testing/db.js +2 -2
  509. package/dist/testing/integration.d.ts.map +1 -1
  510. package/dist/testing/integration.js +35 -65
  511. package/dist/testing/integration_helpers.d.ts +0 -15
  512. package/dist/testing/integration_helpers.d.ts.map +1 -1
  513. package/dist/testing/integration_helpers.js +2 -42
  514. package/dist/testing/middleware.d.ts +20 -12
  515. package/dist/testing/middleware.d.ts.map +1 -1
  516. package/dist/testing/middleware.js +49 -40
  517. package/dist/testing/rate_limiting.d.ts.map +1 -1
  518. package/dist/testing/rate_limiting.js +13 -22
  519. package/dist/testing/resolved_auth.d.ts +30 -0
  520. package/dist/testing/resolved_auth.d.ts.map +1 -0
  521. package/dist/testing/resolved_auth.js +41 -0
  522. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  523. package/dist/testing/rpc_envelope_cases.js +3 -0
  524. package/dist/testing/rpc_helpers.d.ts +1 -1
  525. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  526. package/dist/testing/rpc_helpers.js +2 -1
  527. package/dist/testing/sse_round_trip.d.ts +5 -4
  528. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  529. package/dist/testing/sse_round_trip.js +2 -2
  530. package/dist/testing/stubs.d.ts +2 -2
  531. package/dist/testing/stubs.d.ts.map +1 -1
  532. package/dist/testing/stubs.js +24 -21
  533. package/dist/testing/test_origin.d.ts +25 -0
  534. package/dist/testing/test_origin.d.ts.map +1 -0
  535. package/dist/testing/test_origin.js +28 -0
  536. package/dist/testing/transports/raw_http.d.ts +54 -0
  537. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  538. package/dist/testing/transports/raw_http.js +58 -0
  539. package/dist/testing/transports/ws_raw_client.d.ts +8 -0
  540. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  541. package/dist/testing/transports/ws_raw_client.js +13 -0
  542. package/dist/testing/transports/ws_transport.d.ts +15 -2
  543. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  544. package/dist/testing/transports/ws_transport.js +4 -2
  545. package/dist/testing/ws_round_trip.d.ts +27 -25
  546. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  547. package/dist/testing/ws_round_trip.js +34 -26
  548. package/dist/ui/AccountSessions.svelte +48 -19
  549. package/dist/ui/AccountSessions.svelte.d.ts +2 -17
  550. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
  551. package/dist/ui/AdminAccounts.svelte +6 -1
  552. package/dist/ui/AdminAuditLog.svelte +61 -22
  553. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
  554. package/dist/ui/AdminInvites.svelte +1 -1
  555. package/dist/ui/AdminOverview.svelte +76 -37
  556. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  557. package/dist/ui/AdminRoleGrantHistory.svelte +6 -1
  558. package/dist/ui/AdminSessions.svelte +1 -1
  559. package/dist/ui/AppShell.svelte +3 -2
  560. package/dist/ui/AppShell.svelte.d.ts +3 -2
  561. package/dist/ui/AppShell.svelte.d.ts.map +1 -1
  562. package/dist/ui/CLAUDE.md +121 -35
  563. package/dist/ui/Datatable.svelte +33 -18
  564. package/dist/ui/Datatable.svelte.d.ts +2 -14
  565. package/dist/ui/Datatable.svelte.d.ts.map +1 -1
  566. package/dist/ui/OpenSignupToggle.svelte +10 -1
  567. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
  568. package/dist/ui/PopoverButton.svelte +13 -8
  569. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
  570. package/dist/ui/RoleGrantOfferForm.svelte +3 -2
  571. package/dist/ui/RoleGrantOfferForm.svelte.d.ts +3 -2
  572. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
  573. package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
  574. package/dist/ui/RoleGrantOfferInbox.svelte +19 -15
  575. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
  576. package/dist/ui/SurfaceExplorer.svelte +66 -27
  577. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  578. package/dist/ui/account_sessions_state.svelte.d.ts +7 -14
  579. package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
  580. package/dist/ui/admin_accounts_state.svelte.d.ts +14 -9
  581. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  582. package/dist/ui/admin_accounts_state.svelte.js +6 -4
  583. package/dist/ui/admin_invites_state.svelte.d.ts +2 -2
  584. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
  585. package/dist/ui/admin_rpc_adapters.d.ts +9 -9
  586. package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
  587. package/dist/ui/admin_rpc_adapters.js +9 -9
  588. package/dist/ui/app_settings_state.svelte.d.ts +2 -2
  589. package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
  590. package/dist/ui/audit_log_state.svelte.d.ts +70 -13
  591. package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
  592. package/dist/ui/audit_log_state.svelte.js +239 -47
  593. package/dist/ui/backend_probe.svelte.d.ts +93 -0
  594. package/dist/ui/backend_probe.svelte.d.ts.map +1 -0
  595. package/dist/ui/backend_probe.svelte.js +140 -0
  596. package/dist/ui/format_scope.d.ts +7 -7
  597. package/dist/ui/format_scope.d.ts.map +1 -1
  598. package/dist/ui/format_scope.js +4 -4
  599. package/dist/ui/keyed_async_slot.svelte.d.ts +2 -2
  600. package/dist/ui/keyed_async_slot.svelte.js +2 -2
  601. package/dist/ui/popover.svelte.d.ts +18 -19
  602. package/dist/ui/popover.svelte.d.ts.map +1 -1
  603. package/dist/ui/popover.svelte.js +103 -16
  604. package/dist/ui/role_grant_offers_state.svelte.d.ts +41 -46
  605. package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
  606. package/dist/ui/role_grant_offers_state.svelte.js +37 -19
  607. package/dist/ui/ui_format.d.ts +17 -0
  608. package/dist/ui/ui_format.d.ts.map +1 -1
  609. package/dist/ui/ui_format.js +20 -0
  610. package/package.json +2 -1
  611. package/dist/actions/register_ws_endpoint.d.ts +0 -79
  612. package/dist/actions/register_ws_endpoint.d.ts.map +0 -1
  613. package/dist/actions/register_ws_endpoint.js +0 -109
  614. package/dist/actions/transports_ws_auth_guard.d.ts +0 -94
  615. package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
  616. package/dist/actions/transports_ws_auth_guard.js +0 -138
  617. package/dist/actions/transports_ws_backend.d.ts.map +0 -1
  618. package/dist/cli/args.d.ts +0 -55
  619. package/dist/cli/args.d.ts.map +0 -1
  620. package/dist/cli/args.js +0 -100
  621. package/dist/cli/config.d.ts +0 -47
  622. package/dist/cli/config.d.ts.map +0 -1
  623. package/dist/cli/config.js +0 -77
  624. package/dist/cli/daemon.d.ts.map +0 -1
  625. package/dist/cli/daemon.js +0 -181
  626. package/dist/cli/help.d.ts +0 -124
  627. package/dist/cli/help.d.ts.map +0 -1
  628. package/dist/cli/help.js +0 -215
  629. package/dist/cli/logger.d.ts +0 -46
  630. package/dist/cli/logger.d.ts.map +0 -1
  631. package/dist/cli/logger.js +0 -48
  632. package/dist/cli/util.d.ts +0 -36
  633. package/dist/cli/util.d.ts.map +0 -1
  634. package/dist/cli/util.js +0 -50
  635. package/dist/realtime/sse_auth_guard.d.ts +0 -197
  636. package/dist/realtime/sse_auth_guard.d.ts.map +0 -1
  637. package/dist/realtime/sse_auth_guard.js +0 -238
  638. package/dist/realtime/subscriber_registry.d.ts.map +0 -1
  639. package/dist/testing/bootstrap_success.d.ts +0 -29
  640. package/dist/testing/bootstrap_success.d.ts.map +0 -1
  641. package/dist/testing/bootstrap_success.js +0 -144
  642. package/dist/testing/mock_fs.d.ts +0 -20
  643. package/dist/testing/mock_fs.d.ts.map +0 -1
  644. package/dist/testing/mock_fs.js +0 -28
  645. package/dist/testing/standard.d.ts +0 -122
  646. package/dist/testing/standard.d.ts.map +0 -1
  647. package/dist/testing/standard.js +0 -73
  648. package/dist/testing/testing_rate_limiter.d.ts +0 -65
  649. package/dist/testing/testing_rate_limiter.d.ts.map +0 -1
  650. package/dist/testing/testing_rate_limiter.js +0 -80
@@ -1,268 +1,86 @@
1
1
  /**
2
- * WebSocket JSON-RPC dispatch — the low-level WS transport binding.
2
+ * WebSocket JSON-RPC endpoint — the WS transport binding.
3
3
  *
4
4
  * Consumers declare WS endpoints on `create_app_server`'s `ws_endpoints`,
5
- * which mounts each through `register_ws_endpoint`
6
- * (`actions/register_ws_endpoint.ts`) — this function wrapped in the
7
- * standard upgrade stack (origin check + auth + token scope + actor
8
- * resolution + optional role). This module stays exported as the
9
- * lower-level entry point for tests that drive the dispatcher directly via
10
- * `create_ws_test_harness`.
5
+ * which mounts each through `register_action_ws`; call it directly only to
6
+ * mount an endpoint outside that assembly. Tests drive the dispatcher
7
+ * directly via `create_ws_test_harness`.
11
8
  *
12
- * Symmetric to `create_rpc_endpoint` (from `actions/action_rpc.ts`):
13
- * both transports parse their wire envelope, then call the shared
14
- * `perform_action` core (`actions/perform_action.ts`) for the post-parse
15
- * pipeline. WS-specific concerns — connection lifecycle, heartbeat,
16
- * cancel-notification interception, socket-scoped notify — stay in this
17
- * module; everything else (auth gates, input validation, authorization
18
- * phase, rate limiting, transactional dispatch, DEV output validation,
19
- * thrown-error normalization) is shared.
20
- *
21
- * ## Auth expectations
22
- *
23
- * The consumer is responsible for rejecting unauthenticated upgrades
24
- * *before* routing to this handler (fuz_app's `require_auth` middleware,
25
- * or `register_ws_endpoint` which wires it for you). Per-action auth
26
- * runs inside `perform_action` on every message via the same gates HTTP
27
- * RPC uses.
28
- *
29
- * ## Admission: the revocation race
9
+ * ## The upgrade route
30
10
  *
31
- * The auth middleware resolves the credential before the handshake, and the
32
- * socket exists only once `onOpen` fires. Every revocation (session revoke,
33
- * logout, password change, token revoke, account delete) closes the sockets
34
- * *registered* under what it revoked, so one landing in that gap would close
35
- * nothing, and the socket would then be admitted on the dead credential and
36
- * keep it: per-message dispatch re-authorizes the *actor*, never the session
37
- * or token — and its admission could evict a live socket of the same account
38
- * past the cap.
11
+ * One `GET path` route, its guards in coarse-to-fine order — the route-spec
12
+ * pipeline's, from `fuz_auth_guard_resolver`:
39
13
  *
40
- * `onOpen` closes the gap in three steps: register the connection **pending**
41
- * (`BackendWebsocketTransport.register_pending` — closeable by every
42
- * revocation, inert otherwise), re-read the credential
43
- * (`revalidate_resolved_auth`), then `BackendWebsocketTransport.admit`. A
44
- * revocation whose close ran after the registration found the pending entry,
45
- * so `admit` refuses; one that committed before the re-read is seen by it. The
46
- * cap is enforced only by `admit`, so a refused upgrade evicts nothing, and
47
- * pending registrations never count toward it.
14
+ * 1. `verify_request_source(allowed_origins)` — a disallowed origin is
15
+ * refused before the upgrade handshake runs (403).
16
+ * 2. `require_auth` — an unauthenticated upgrade is refused (401).
17
+ * 3. `require_token_scope('surface:ws_upgrade')` — rule 3: a narrowed token
18
+ * cannot hold a socket (403 `token_scope_required`). Server-initiated
19
+ * pushes (broadcasts, role-grant-offer notifications, peer requests)
20
+ * reach whatever the account's connection reaches, with no per-recipient
21
+ * filter to narrow them by, so a scoped token that could upgrade would
22
+ * observe far more than it was granted.
23
+ * 4. **Authorization phase** (`run_authorization_phase`) — the acting actor
24
+ * from the `?acting=<uuid>` query string (`parse_acting`; malformed reads
25
+ * as omitted), against the authenticated account, building the
26
+ * `RequestContext` per-message dispatch reads (400s on actor selection).
27
+ * Multi-actor accounts must supply `?acting`; single-actor accounts work
28
+ * without it.
29
+ * 5. `require_role(required_roles)`, for a gated endpoint (403).
48
30
  *
49
- * That argument needs every revocation to close only after its commit —
50
- * otherwise a close could miss the registration while the re-read still sees
51
- * the credential alive. Every one does: the revocation handlers queue their
52
- * close behind the commit (`queue_connection_close`), and the audit emitter
53
- * announces a success row to the listeners behind it too. So no interleaving
54
- * admits a revoked credential; `docs/security.md` §Connection Admission says
55
- * what that rests on.
31
+ * Only `GET` is mounted (Hono serves `HEAD` through it), so any other method
32
+ * on the path is a 404. The guards run as middleware ahead of
33
+ * `upgradeWebSocket`, whose callback must return `WSEvents` and so cannot
34
+ * produce a refusal.
56
35
  *
57
- * An endpoint gated on `required_roles` re-reads them beside the credential:
58
- * its upgrade passed the role gate before the socket registered, so a role
59
- * revocation landing in between would close nothing (`close_sockets_for_role`
60
- * matches registrations), and the socket would be admitted without the role
61
- * for its lifetime. The re-read reads the acting actor's grants afresh and
62
- * admits on a global grant of any listed role, as the gate did.
63
- *
64
- * A refused upgrade is closed with `WS_CLOSE_SESSION_REVOKED` (4001, the
65
- * reason a revoked socket gets) for a dead credential,
66
- * `WS_CLOSE_PERMISSION_REVOKED` (4006) for a lost role, or
67
- * `WS_CLOSE_INTERNAL_ERROR` (1011) when either re-read itself failed — fail
68
- * closed, never admitted unchecked. The handshake has already answered `101`,
69
- * so a refusal can only be a close frame.
70
- *
71
- * Once the server is shutting down (`AppServer.close` ran the transport's
72
- * `close_all_sockets`) a refusal is `WS_CLOSE_GOING_AWAY` instead, so the
73
- * client reconnects rather than treating its credential as revoked: an upgrade
74
- * pending at the close-all is closed by it — and its abort makes the refusal
75
- * that follows the re-read send nothing more, even when the database closed
76
- * under that re-read — and one that registers after it is born closed and
77
- * skips the re-read (`BackendWebsocketTransport` module doc, "Shutdown").
78
- *
79
- * Frames that arrive before admission are queued, not dispatched: nothing runs
80
- * on a credential that has not been re-read. They dispatch in arrival order
81
- * once the socket is admitted and `on_socket_open` has completed, and are
82
- * dropped unread on a refusal. The queue holds at most
83
- * `MAX_PRE_ADMISSION_FRAMES` frames and
84
- * `PRE_ADMISSION_QUEUE_BYTES_FACTOR` × `max_message_bytes` bytes; past either
85
- * the socket is closed.
36
+ * Symmetric to `create_rpc_endpoint` (from `actions/action_rpc.ts`):
37
+ * both transports parse their wire envelope, then call the shared
38
+ * `perform_action` core (`actions/perform_action.ts`) for the post-parse
39
+ * pipeline. WS-specific concerns — connection lifecycle, heartbeat,
40
+ * cancel-notification interception, socket-scoped notify — live in
41
+ * `actions/ws_socket_session.ts`; everything else (auth gates, input
42
+ * validation, authorization phase, rate limiting, transactional dispatch, DEV
43
+ * output validation, thrown-error normalization) is shared.
86
44
  *
87
- * ## Credential deadline
45
+ * ## Per-message auth
88
46
  *
89
- * Expiry writes nothing a revocation listener could hear, so the socket
90
- * watches its own credential's expiry (`ResolvedAuth.credential_deadline`,
91
- * the earlier of a session's cookie and row, an API token's row, none for a
92
- * daemon token or an eternal token). From admission, a timer closes it at the
93
- * deadline with `WS_CLOSE_SESSION_REVOKED` (4001) and
94
- * `WS_CLOSE_CREDENTIAL_EXPIRED_REASON`. The wait is a chain of timers of at
95
- * most an hour (`schedule_credential_deadline`), so a session's 30 days — past
96
- * `setTimeout`'s ceiling — does not fire at once, and each wake-up checks the
97
- * wall clock too, so a host suspend does not extend the deadline.
47
+ * Per-action auth runs inside `perform_action` on every message via the same
48
+ * gates HTTP RPC uses.
98
49
  *
99
- * ## A server-closed socket dispatches nothing
50
+ * ## Per-socket lifecycle
100
51
  *
101
- * A runtime adapter can keep delivering inbound frames after the server calls
102
- * `ws.close(…)`, until the close handshake completes (`@hono/node-ws` does —
103
- * up to the `ws` close timeout when the client withholds its close frame).
104
- * So every server-side close — revocation, cap eviction, heartbeat timeout,
105
- * an oversized message, a refused admission — removes the connection from the
106
- * transport and aborts the socket's signal *at close time*, and `onMessage`
107
- * drops any frame on a socket that has ended. A connection the transport no
108
- * longer holds though nothing closed its socket (a bare `remove_connection`)
109
- * is ended on its next frame (`BackendWebsocketTransport.is_registered`), with
110
- * `WS_CLOSE_INTERNAL_ERROR` — it must not linger as a socket that reads
111
- * everything and answers nothing.
52
+ * Admission (the revocation race), the credential deadline, and the rule that a
53
+ * server-closed socket dispatches nothing are the per-socket half, in
54
+ * `actions/ws_socket_session.ts`.
112
55
  *
113
56
  * @module
114
57
  */
115
58
  import type { Hono } from 'hono';
116
- import type { UpgradeWebSocket, WSContext } from 'hono/ws';
59
+ import type { UpgradeWebSocket } from 'hono/ws';
117
60
  import { type Logger as LoggerType } from '@fuzdev/fuz_util/log.ts';
118
- import type { Uuid } from '../primitive_schemas.js';
119
61
  import type { RoleName } from '../auth/role_schema.js';
62
+ import type { EffectErrorContext } from '../http/pending_effects.js';
120
63
  import type { RateLimiter } from '../rate_limiter.js';
121
64
  import type { Db } from '../db/db.js';
122
65
  import { type Action } from './action_types.js';
123
66
  import type { RealtimeCloser } from './connection_closer.js';
124
- import { BackendWebsocketTransport, type ConnectionIdentity } from './transports_ws_backend.js';
125
- /** Default inactivity window before the server closes a silent socket. */
126
- export declare const DEFAULT_SERVER_HEARTBEAT_TIMEOUT = 60000;
67
+ import { ConnectionRegistry } from './connection_registry.js';
68
+ import { type SocketCloseContext, type SocketOpenContext } from './ws_socket_session.js';
127
69
  /**
128
- * Max inbound frames one socket may have queued while it is still opening —
129
- * between the handshake and the end of the credential re-check plus
130
- * `on_socket_open`. One more closes the socket with
131
- * `WS_CLOSE_POLICY_VIOLATION`.
132
- *
133
- * Frames sent before the socket is open wait rather than dispatch (nothing
134
- * runs on a credential that has not been re-read), and a runtime adapter hands
135
- * them over with no backpressure, so the wait needs a bound. This is the count
136
- * half; `PRE_ADMISSION_QUEUE_BYTES_FACTOR` is the byte half.
137
- *
138
- * Sized so a client flushing its durable queue on reopen never meets it at the
139
- * default `DEFAULT_QUEUE_MAX_SIZE` (`actions/socket.svelte.ts`). A consumer
140
- * that raises the client's queue above this cap makes a full flush overflow
141
- * it: the socket closes with `WS_CLOSE_POLICY_VIOLATION`, the flushed requests
142
- * fail, and the client reconnects.
70
+ * Default receive silence (ms) past which the server closes a socket with
71
+ * `WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT` — the `receive_timeout` of
72
+ * `register_action_ws`. Twin of the Rust spine's `DEFAULT_WS_RECEIVE_TIMEOUT`.
143
73
  */
144
- export declare const MAX_PRE_ADMISSION_FRAMES = 256;
74
+ export declare const DEFAULT_WS_RECEIVE_TIMEOUT = 60000;
145
75
  /**
146
- * The byte budget of one socket's pre-admission queue, as a multiple of the
147
- * endpoint's `max_message_bytes`: the frames queued while the socket is still
148
- * opening may total at most this many maximum-size messages. The frame that
149
- * would pass it closes the socket with `WS_CLOSE_POLICY_VIOLATION`.
150
- *
151
- * The count cap alone (`MAX_PRE_ADMISSION_FRAMES`) would let each pending
152
- * socket hold that many full-size messages, and pending sockets are not
153
- * capped per account — a registration that is never admitted must not be able
154
- * to pin that much memory. Small requests, which is what a client flushes on
155
- * reopen, meet the count cap long before this one.
156
- *
157
- * A client whose queued requests total more than this budget and flushes
158
- * them all on reopen overflows it: the socket closes, the flushed requests
159
- * fail, and the client reconnects.
76
+ * The longest `receive_timeout` `register_action_ws` accepts — 2³¹ − 1 ms,
77
+ * about 24.8 days, the longest delay a timer honors (the same bound as the
78
+ * SSE keep-alive). It keeps the receive check's half-timeout tick well inside
79
+ * that delay; `Infinity`, or a timeout of about 2³² ms and up, would make the
80
+ * tick fire every millisecond on every socket. TS-only: the Rust spine's
81
+ * `Duration` takes any length.
160
82
  */
161
- export declare const PRE_ADMISSION_QUEUE_BYTES_FACTOR = 4;
162
- /**
163
- * The close reason sent with `WS_CLOSE_POLICY_VIOLATION` when a socket
164
- * overflows its pre-admission queue, by count or by bytes.
165
- */
166
- export declare const WS_CLOSE_PRE_ADMISSION_OVERFLOW_REASON = "too much sent before the socket opened";
167
- /**
168
- * Max requests one socket may have dispatching at once. A request that
169
- * arrives past it is answered `queue_overflow` with its id
170
- * (`WS_INBOUND_DISPATCH_OVERFLOW_MESSAGE`) and not dispatched; the socket
171
- * stays open, and the requests already running keep answering.
172
- *
173
- * A runtime adapter can hand frames over without awaiting the previous one's
174
- * dispatch (`@hono/node-ws` does not await `onMessage`), so without a ceiling
175
- * one socket could hold any number of handlers — and their pooled database
176
- * work — at once. Shedding rather than queueing keeps the socket reading, so a
177
- * reply to a server-initiated request still reaches the handler awaiting it.
178
- * Generous, so ordinary pipelining never meets it. Same value as the Rust
179
- * spine's `MAX_INBOUND_DISPATCHES_PER_CONN`.
180
- *
181
- * Counted are the requests that passed envelope validation and are not yet
182
- * answered — the entries of the socket's cancellation map. Notifications,
183
- * replies to server-initiated requests, and refused frames never count.
184
- */
185
- export declare const MAX_INBOUND_DISPATCHES_PER_CONNECTION = 128;
186
- /**
187
- * The `queue_overflow` message a request gets past
188
- * `MAX_INBOUND_DISPATCHES_PER_CONNECTION`. Same text as the Rust spine's.
189
- */
190
- export declare const WS_INBOUND_DISPATCH_OVERFLOW_MESSAGE = "too many concurrent requests on this connection";
191
- /**
192
- * The `data.reason` of the `invalid_request` a WebSocket request gets when its
193
- * id names a request still running on the same socket. The duplicate is not
194
- * dispatched; the running request keeps its id, so its reply, and a `cancel`
195
- * naming that id, stay its own. An id is free again once its request has been
196
- * answered.
197
- */
198
- export declare const ERROR_DUPLICATE_REQUEST_ID = "duplicate_request_id";
199
- /**
200
- * Context passed to the `on_socket_open` hook.
201
- *
202
- * Fires once the connection is **admitted** — registered in the transport and
203
- * its credential re-checked (so `connection_id` is valid, and broadcasts reach
204
- * it) — and before any client message dispatches. A socket refused at
205
- * admission never reaches it. Consumers use this to bootstrap per-socket
206
- * domain state — e.g. spawning a per-account unit and pushing an initial state
207
- * snapshot.
208
- */
209
- export interface SocketOpenContext {
210
- /**
211
- * The raw WebSocket context — exposed for edge cases; prefer `notify` for
212
- * sends. A frame sent on it directly bypasses the connection's outbound
213
- * budget and its ordering with queued frames.
214
- */
215
- ws: WSContext;
216
- /** Connection id assigned by `BackendWebsocketTransport.register_pending`. */
217
- connection_id: Uuid;
218
- /** Auth identity registered for this connection. */
219
- identity: ConnectionIdentity;
220
- /**
221
- * Send a JSON-RPC notification to just this socket. Mirrors `ctx.notify`
222
- * on per-message handler contexts — same socket-scoped semantics.
223
- */
224
- notify: (method: string, params: unknown) => void;
225
- /**
226
- * Fires when this socket ends — the client closed it, or the server did
227
- * (revocation, cap eviction, heartbeat timeout), at the moment the server
228
- * closes rather than when the close handshake lands. Threaded through to
229
- * every handler's `ctx.signal`.
230
- */
231
- signal: AbortSignal;
232
- }
233
- /**
234
- * Context passed to the `on_socket_close` hook.
235
- *
236
- * Fires after the transport has removed the connection — `connection_id` and
237
- * `identity` are the values captured at open, so consumer cleanup reads them
238
- * from here, not from the transport. Fires for both client-initiated closes
239
- * (Hono onClose) and server-initiated closes — a revocation, the per-account
240
- * connection cap's eviction, and a heartbeat timeout all call `ws.close()`,
241
- * which triggers Hono's onClose. Fires only for a socket that was admitted: one
242
- * refused at admission never ran `on_socket_open`, so it has no close hook
243
- * either.
244
- */
245
- export interface SocketCloseContext {
246
- /**
247
- * The WebSocket context the close event carried. Not necessarily the object
248
- * `on_socket_open` received — an adapter may build one per event — so key
249
- * per-socket state on `connection_id`.
250
- */
251
- ws: WSContext;
252
- /** Connection id captured at open time. */
253
- connection_id: Uuid;
254
- /** Auth identity captured at open time — the transport no longer holds it. */
255
- identity: ConnectionIdentity;
256
- }
257
- export interface ServerHeartbeatOptions {
258
- /**
259
- * Receive-silence (ms) past which the server closes the socket with
260
- * `WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT`. Any incoming message resets
261
- * the counter — chatty clients never trip it. First `timeout`
262
- * window after socket open is exempt (cold-start grace).
263
- */
264
- timeout?: number;
265
- }
83
+ export declare const WS_RECEIVE_TIMEOUT_MAX = 2147483647;
266
84
  /** Options for `register_action_ws`. */
267
85
  export interface RegisterActionWsOptions {
268
86
  /** Mount path (e.g., `/api/ws`). */
@@ -271,6 +89,13 @@ export interface RegisterActionWsOptions {
271
89
  app: Hono;
272
90
  /** Hono's `upgradeWebSocket` helper from the runtime adapter. */
273
91
  upgradeWebSocket: UpgradeWebSocket;
92
+ /**
93
+ * Origin allowlist regexes for the upgrade — passed straight to
94
+ * `verify_request_source`, the route's first guard. `create_app_server`
95
+ * passes the server's `allowed_origins` unless the `WsEndpointSpec` narrows
96
+ * them.
97
+ */
98
+ allowed_origins: ReadonlyArray<RegExp>;
274
99
  /**
275
100
  * The actions registered on this endpoint — each carries a spec (drives
276
101
  * method lookup, per-action auth, input/output validation) and an
@@ -292,46 +117,48 @@ export interface RegisterActionWsOptions {
292
117
  */
293
118
  db: Db;
294
119
  /**
295
- * The roles the endpoint's upgrade gate requires (any-of) — what
296
- * `register_ws_endpoint` mounts as `require_role(required_roles)` ahead of
297
- * this handler. Recorded on every registration
120
+ * Roles permitted to upgrade — any-of disjunction, global grants only,
121
+ * mounted as the route's `require_role` gate (403). Omit (or pass `[]`)
122
+ * for any authenticated account. The per-action `auth` in each spec still
123
+ * applies at dispatch time — this is a coarse upgrade-time gate on who may
124
+ * hold a socket, and so on who receives the endpoint's server pushes.
125
+ *
126
+ * It holds for the socket's life: recorded on every registration
298
127
  * (`ConnectionIdentity.required_roles`), so a revoked global grant of a
299
- * listed role closes the socket (`close_sockets_for_role`), and re-read at
300
- * admission against the acting actor's grants, so a revocation that landed
301
- * between the gate and the registration refuses the upgrade with
302
- * `WS_CLOSE_PERMISSION_REVOKED`. This handler does not gate on it before
303
- * the upgrade; mount the 403 gate in front (`register_ws_endpoint` does).
304
- * Omit, or pass `[]`, for an ungated endpoint.
128
+ * listed role closes the socket (a `role` close target, any listed role
129
+ * — see its over-close), and re-read at admission against the acting
130
+ * actor's grants, so a revocation that landed between the gate and the
131
+ * registration refuses the upgrade with `WS_CLOSE_PERMISSION_REVOKED`.
305
132
  */
306
133
  required_roles?: ReadonlyArray<RoleName>;
307
134
  /**
308
- * Existing transport to register connections with. When omitted, a fresh
135
+ * Existing registry to register connections with. When omitted, a fresh
309
136
  * one is created and returned in the result. Pass your own to keep a
310
- * handle for `create_ws_auth_guard` and `send_to`/`broadcast`.
137
+ * handle for `send_to` / `broadcast` before the mount.
311
138
  */
312
- transport?: BackendWebsocketTransport;
139
+ registry?: ConnectionRegistry;
313
140
  /**
314
141
  * The backend's closer — `deps.connection_closer`. This endpoint's
315
- * transport is added to it, so every revocation handler's close reaches
142
+ * registry is added to it, so every revocation handler's close reaches
316
143
  * the sockets opened here. Required so it can't be forgotten: left out of
317
- * the closer, a transport's sockets close only through the audit listener,
318
- * which a failed audit write or a session / token cap eviction never
319
- * reaches. Pass `null` only when no revocation has to reach this transport
320
- * (a harness driving the dispatcher directly), or when the transport was
144
+ * the closer, no revocation closes a registry's sockets — neither the
145
+ * handlers' closes nor the revocation guard, which closes through the same
146
+ * closer. Pass `null` only when no revocation has to reach this registry
147
+ * (a harness driving the dispatcher directly), or when the registry was
321
148
  * added by hand.
322
149
  *
323
- * The transport is added once the mount succeeds, so a mount that throws
150
+ * The registry is added once the mount succeeds, so a mount that throws
324
151
  * adds nothing. The addition is permanent — its remover is not returned.
325
152
  * A caller that must release the membership (as `create_app_server` does
326
- * on close) passes `null` and adds the transport itself, holding the
153
+ * on close) passes `null` and adds the registry itself, holding the
327
154
  * remover `RealtimeCloser.add` returns.
328
155
  */
329
156
  connection_closer: RealtimeCloser | null;
330
157
  /**
331
- * Per-account connection cap for the transport this call creates — see
332
- * `BackendWebsocketTransportOptions.max_connections_per_account`
158
+ * Per-account connection cap for the registry this call creates — see
159
+ * `ConnectionRegistryOptions.max_connections_per_account`
333
160
  * (evict-oldest, closing with `WS_CLOSE_CONNECTION_LIMIT`; `null`
334
- * disables). Rejected alongside `transport`: a supplied transport carries
161
+ * disables). Rejected alongside `registry`: a supplied registry carries
335
162
  * its own cap, set where it was constructed.
336
163
  *
337
164
  * @default DEFAULT_MAX_CONNECTIONS_PER_ACCOUNT
@@ -339,32 +166,41 @@ export interface RegisterActionWsOptions {
339
166
  max_connections_per_account?: number | null;
340
167
  /**
341
168
  * Byte budget of the frames waiting to be written to one connection, for
342
- * the transport this call creates — see
343
- * `BackendWebsocketTransportOptions.outbound_queue_bytes` (a frame that does
169
+ * the registry this call creates — see
170
+ * `ConnectionRegistryOptions.outbound_queue_bytes` (a frame that does
344
171
  * not fit closes the socket with `WS_CLOSE_OUTBOUND_OVERFLOW`). Not derived
345
- * from `max_message_bytes`. Rejected alongside `transport`: a supplied
346
- * transport carries its own budget, set where it was constructed.
172
+ * from `max_message_bytes`. Rejected alongside `registry`: a supplied
173
+ * registry carries its own budget, set where it was constructed.
347
174
  *
348
175
  * @default DEFAULT_WS_OUTBOUND_QUEUE_BYTES
349
176
  */
350
177
  outbound_queue_bytes?: number;
351
178
  /**
352
- * Server-side heartbeat policy. Default-on (receive-silence detection,
353
- * 60s timeout). `false` disables the timer entirely — only do this if
354
- * the upstream stack (TCP keepalive, Cloudflare idle timeout, etc.)
355
- * already owns disconnect detection. Pass an object to tune the timeout.
179
+ * Receive silence (ms) past which the server closes a socket with
180
+ * `WS_CLOSE_SERVER_HEARTBEAT_TIMEOUT`. Any incoming message resets the
181
+ * count — chatty clients never trip it — and the first window after
182
+ * admission is exempt (cold-start grace). `null` keeps silent sockets open:
183
+ * only do this if the upstream stack (TCP keepalive, a proxy's idle
184
+ * timeout) already owns disconnect detection. Must be positive and at most
185
+ * `WS_RECEIVE_TIMEOUT_MAX` — registration throws otherwise. Twin of the
186
+ * Rust spine's `ActionWsOptions.receive_timeout`.
187
+ *
188
+ * @default DEFAULT_WS_RECEIVE_TIMEOUT
356
189
  */
357
- heartbeat?: boolean | ServerHeartbeatOptions;
358
- /** Optional per-message delay for testing loading states. Ignored when `0`. */
359
- artificial_delay?: number;
190
+ receive_timeout?: number | null;
360
191
  /**
361
192
  * Cap on one inbound message, in bytes (UTF-8 for text frames). A larger
362
193
  * message closes the socket with `WS_CLOSE_MESSAGE_TOO_BIG` before it's
363
194
  * parsed — there's no per-message error reply, matching the Rust spine.
364
195
  * The cap is checked after the runtime adapter has buffered the message,
365
196
  * so it bounds dispatch work, not memory; bound the adapter's own frame
366
- * limit too (e.g. `ws`'s `maxPayload`) where memory matters. A consumer
367
- * that raises it passes the same value to the client's
197
+ * limit too (e.g. `ws`'s `maxPayload`) where memory matters, set above this
198
+ * cap — twice it, as the cross-backend test adapters do. A message past the
199
+ * frame limit is refused by the adapter without
200
+ * `WS_CLOSE_MESSAGE_TOO_BIG_REASON` (`ws` closes with the code and an empty
201
+ * reason, Bun drops the socket), so a frame limit equal to this cap loses
202
+ * the reason a message just over it gets. A consumer that raises it passes
203
+ * the same value to the client's
368
204
  * `FrontendWebsocketTransportOptions.max_message_bytes`.
369
205
  *
370
206
  * @default DEFAULT_WS_MAX_MESSAGE_BYTES
@@ -373,11 +209,12 @@ export interface RegisterActionWsOptions {
373
209
  /** Optional logger; defaults to `[ws]` namespace. */
374
210
  log?: LoggerType;
375
211
  /**
376
- * Called once per socket, after the connection is admitted (module doc,
377
- * "Admission"). Awaited before any inbound frame is dispatched — every
212
+ * Called once per socket, after the connection is admitted
213
+ * (`actions/ws_socket_session.ts`, "Admission: the revocation race").
214
+ * Awaited before any inbound frame is dispatched — every
378
215
  * frame the client sends meanwhile waits in arrival order, replies to
379
216
  * server-initiated requests included: a hook that awaits
380
- * `transport.request_connection` on its own connection gets no reply until
217
+ * `registry.request_connection` on its own connection gets no reply until
381
218
  * it returns, so start such a request without awaiting it. Throwing logs an
382
219
  * error and closes the socket with an `internal_error` frame and
383
220
  * `WS_CLOSE_INTERNAL_ERROR` — a failing bootstrap should not leave a
@@ -385,7 +222,7 @@ export interface RegisterActionWsOptions {
385
222
  */
386
223
  on_socket_open?: (ctx: SocketOpenContext) => void | Promise<void>;
387
224
  /**
388
- * Called once per admitted socket on close, *after* the transport has
225
+ * Called once per admitted socket on close, *after* the registry has
389
226
  * removed the connection — a slow hook never holds a dead entry that
390
227
  * broadcasts still target and the per-account cap still counts. Receives
391
228
  * `connection_id` and `identity` captured at open time, the same whether the
@@ -411,15 +248,23 @@ export interface RegisterActionWsOptions {
411
248
  * dispatcher.
412
249
  */
413
250
  action_account_rate_limiter: RateLimiter | null;
251
+ /**
252
+ * Called when an eager pending effect of a frame's action rejects, after
253
+ * the rejection is logged — the WS half of `create_app_server`'s
254
+ * `on_effect_error`, which threads it here for the endpoints it mounts.
255
+ * The context carries `transport: 'ws'`, the action method, and `path`.
256
+ */
257
+ on_effect_error?: (error: unknown, context: EffectErrorContext) => void;
414
258
  }
415
259
  /** Result of `register_action_ws`. */
416
260
  export interface RegisterActionWsResult {
417
- /** The transport bound to the endpoint — supplied or freshly created. */
418
- transport: BackendWebsocketTransport;
261
+ /** The registry bound to the endpoint — supplied or freshly created. */
262
+ registry: ConnectionRegistry;
419
263
  }
420
264
  /**
421
- * Mount a JSON-RPC WebSocket endpoint that dispatches via the shared
422
- * `perform_action` core.
265
+ * Mount a JSON-RPC WebSocket endpoint — the upgrade route with its origin,
266
+ * auth, token-scope, acting-actor, and role guards (module doc, "The upgrade
267
+ * route") — that dispatches via the shared `perform_action` core.
423
268
  *
424
269
  * Wire behavior:
425
270
  * - Batch JSON-RPC is rejected (single-message only).
@@ -439,8 +284,8 @@ export interface RegisterActionWsResult {
439
284
  * - Authorization phase runs **per message** — role_grant changes during a
440
285
  * connection lifetime are picked up on the next message without any
441
286
  * in-place refresh. Authentication invalidation closes the socket: the
442
- * revocation handlers through `connection_closer`, and `create_ws_auth_guard`
443
- * on the audit row.
287
+ * revocation handlers through `connection_closer`, and the revocation guard
288
+ * (`create_revocation_guard`) on the audit row.
444
289
  * - Admission re-reads the credential once, after the handshake: a socket
445
290
  * whose session or token was revoked while it was upgrading closes with
446
291
  * `WS_CLOSE_SESSION_REVOKED`, one that lost a role `required_roles` lists
@@ -448,23 +293,23 @@ export interface RegisterActionWsResult {
448
293
  * `WS_CLOSE_INTERNAL_ERROR`. Frames sent before admission wait for it.
449
294
  * - A revoked global grant of a role `required_roles` lists closes the
450
295
  * account's sockets on this endpoint with `WS_CLOSE_PERMISSION_REVOKED`,
451
- * through `create_ws_auth_guard`; nothing more is sent on them.
296
+ * through the revocation guard; nothing more is sent on them.
452
297
  * - A socket the server has closed dispatches nothing more, whether or not
453
298
  * its client answers the close.
454
299
  * - Every frame sent — responses, error frames, notifications — goes through
455
- * the transport's outbound queue. A connection with more waiting than its
300
+ * the registry's outbound queue. A connection with more waiting than its
456
301
  * `outbound_queue_bytes` budget closes with `WS_CLOSE_OUTBOUND_OVERFLOW`, and
457
302
  * the response of the request whose handler overflowed it is not sent.
458
303
  *
459
- * @returns the transport (supplied or freshly created) — retain it to wire
460
- * `create_ws_auth_guard` or broadcast on audit events.
461
- * @mutates options.app - registers a `GET path` route via `upgradeWebSocket`
462
- * @mutates options.transport - per socket, registers, admits, and removes a
304
+ * @returns the registry (supplied or freshly created) — retain it to broadcast
305
+ * @mutates options.app - registers the `GET path` upgrade route, its guards
306
+ * ahead of `upgradeWebSocket`
307
+ * @mutates options.registry - per socket, registers, admits, and removes a
463
308
  * connection via `register_pending` / `admit` / `remove_connection`
464
- * @mutates options.connection_closer - adds the endpoint's transport, once the
309
+ * @mutates options.connection_closer - adds the endpoint's registry, once the
465
310
  * mount has succeeded
466
311
  * @throws Error when `max_connections_per_account` or `outbound_queue_bytes`
467
- * is passed alongside `transport`, when the cap is neither `null` nor a
312
+ * is passed alongside `registry`, when the cap is neither `null` nor a
468
313
  * positive integer, when the budget is not a positive integer, or when
469
314
  * `actions` fails to compile (`compile_action_registry`)
470
315
  */
@@ -1 +1 @@
1
- {"version":3,"file":"register_action_ws.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/actions/register_action_ws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