@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.
- package/README.md +1 -1
- package/dist/actions/CLAUDE.md +324 -299
- package/dist/actions/action_bridge.d.ts +5 -86
- package/dist/actions/action_bridge.d.ts.map +1 -1
- package/dist/actions/action_bridge.js +4 -84
- package/dist/actions/action_codegen.d.ts +8 -166
- package/dist/actions/action_codegen.d.ts.map +1 -1
- package/dist/actions/action_codegen.js +19 -95
- package/dist/actions/action_dispatcher.d.ts +10 -0
- package/dist/actions/action_dispatcher.d.ts.map +1 -1
- package/dist/actions/action_dispatcher.js +9 -6
- package/dist/actions/action_event.d.ts +1 -2
- package/dist/actions/action_event.d.ts.map +1 -1
- package/dist/actions/action_event.js +7 -13
- package/dist/actions/action_event_helpers.d.ts +1 -40
- package/dist/actions/action_event_helpers.d.ts.map +1 -1
- package/dist/actions/action_event_helpers.js +1 -25
- package/dist/actions/action_rpc.d.ts +10 -215
- package/dist/actions/action_rpc.d.ts.map +1 -1
- package/dist/actions/action_rpc.js +56 -111
- package/dist/actions/action_spec.d.ts +2 -2
- package/dist/actions/action_spec.js +2 -2
- package/dist/actions/action_types.d.ts +229 -8
- package/dist/actions/action_types.d.ts.map +1 -1
- package/dist/actions/action_types.js +56 -5
- package/dist/actions/broadcast_api.d.ts +22 -17
- package/dist/actions/broadcast_api.d.ts.map +1 -1
- package/dist/actions/broadcast_api.js +16 -27
- package/dist/actions/cancel.d.ts +4 -13
- package/dist/actions/cancel.d.ts.map +1 -1
- package/dist/actions/cancel.js +5 -17
- package/dist/actions/compile_action_registry.d.ts +1 -2
- package/dist/actions/compile_action_registry.d.ts.map +1 -1
- package/dist/actions/connection_closer.d.ts +120 -50
- package/dist/actions/connection_closer.d.ts.map +1 -1
- package/dist/actions/connection_closer.js +139 -31
- package/dist/actions/{transports_ws_backend.d.ts → connection_registry.d.ts} +120 -132
- package/dist/actions/connection_registry.d.ts.map +1 -0
- package/dist/actions/{transports_ws_backend.js → connection_registry.js} +149 -152
- package/dist/actions/frontend_rpc_client.d.ts +52 -2
- package/dist/actions/frontend_rpc_client.d.ts.map +1 -1
- package/dist/actions/frontend_rpc_client.js +42 -4
- package/dist/actions/peer_ping.d.ts +7 -9
- package/dist/actions/peer_ping.d.ts.map +1 -1
- package/dist/actions/peer_ping.js +6 -8
- package/dist/actions/peer_request.d.ts +6 -5
- package/dist/actions/peer_request.d.ts.map +1 -1
- package/dist/actions/peer_request.js +6 -5
- package/dist/actions/perform_action.d.ts +36 -28
- package/dist/actions/perform_action.d.ts.map +1 -1
- package/dist/actions/perform_action.js +60 -34
- package/dist/actions/protocol.d.ts +14 -0
- package/dist/actions/protocol.d.ts.map +1 -1
- package/dist/actions/protocol.js +18 -0
- package/dist/actions/register_action_ws.d.ts +137 -298
- package/dist/actions/register_action_ws.d.ts.map +1 -1
- package/dist/actions/register_action_ws.js +155 -923
- package/dist/actions/socket.svelte.d.ts +9 -0
- package/dist/actions/socket.svelte.d.ts.map +1 -1
- package/dist/actions/socket.svelte.js +16 -5
- package/dist/actions/transports.d.ts +88 -34
- package/dist/actions/transports.d.ts.map +1 -1
- package/dist/actions/transports.js +76 -76
- package/dist/actions/transports_http.d.ts +48 -12
- package/dist/actions/transports_http.d.ts.map +1 -1
- package/dist/actions/transports_http.js +75 -44
- package/dist/actions/transports_ws.d.ts +29 -0
- package/dist/actions/transports_ws.d.ts.map +1 -1
- package/dist/actions/transports_ws.js +34 -8
- package/dist/actions/ws_endpoint_spec.d.ts +52 -75
- package/dist/actions/ws_endpoint_spec.d.ts.map +1 -1
- package/dist/actions/ws_endpoint_spec.js +27 -10
- package/dist/actions/ws_outbound_writer.d.ts +3 -3
- package/dist/actions/ws_outbound_writer.js +3 -3
- package/dist/actions/ws_socket_session.d.ts +321 -0
- package/dist/actions/ws_socket_session.d.ts.map +1 -0
- package/dist/actions/ws_socket_session.js +783 -0
- package/dist/auth/CLAUDE.md +70 -44
- package/dist/auth/account_action_specs.d.ts +2 -0
- package/dist/auth/account_action_specs.d.ts.map +1 -1
- package/dist/auth/account_actions.d.ts +1 -1
- package/dist/auth/account_actions.d.ts.map +1 -1
- package/dist/auth/account_actions.js +9 -3
- package/dist/auth/account_queries.d.ts +10 -0
- package/dist/auth/account_queries.d.ts.map +1 -1
- package/dist/auth/account_queries.js +27 -17
- package/dist/auth/account_routes.d.ts +2 -1
- package/dist/auth/account_routes.d.ts.map +1 -1
- package/dist/auth/account_routes.js +14 -17
- package/dist/auth/account_schema.d.ts +5 -5
- package/dist/auth/account_schema.d.ts.map +1 -1
- package/dist/auth/account_schema.js +5 -2
- package/dist/auth/actor_lookup_actions.d.ts +1 -1
- package/dist/auth/actor_lookup_actions.d.ts.map +1 -1
- package/dist/auth/actor_lookup_actions.js +1 -1
- package/dist/auth/actor_search_action_specs.d.ts.map +1 -1
- package/dist/auth/actor_search_action_specs.js +2 -1
- package/dist/auth/actor_search_actions.d.ts +1 -1
- package/dist/auth/actor_search_actions.d.ts.map +1 -1
- package/dist/auth/actor_search_actions.js +1 -1
- package/dist/auth/actor_search_queries.d.ts +5 -5
- package/dist/auth/actor_search_queries.d.ts.map +1 -1
- package/dist/auth/actor_search_queries.js +7 -7
- package/dist/auth/admin_action_specs.d.ts.map +1 -1
- package/dist/auth/admin_action_specs.js +3 -1
- package/dist/auth/admin_actions.d.ts +1 -1
- package/dist/auth/admin_actions.d.ts.map +1 -1
- package/dist/auth/admin_actions.js +12 -42
- package/dist/auth/all_cell_actions.d.ts +6 -4
- package/dist/auth/all_cell_actions.d.ts.map +1 -1
- package/dist/auth/all_cell_actions.js +1 -1
- package/dist/auth/api_token_queries.d.ts +1 -0
- package/dist/auth/api_token_queries.d.ts.map +1 -1
- package/dist/auth/api_token_queries.js +1 -0
- package/dist/auth/audit_emitter.d.ts +3 -3
- package/dist/auth/audit_emitter.js +2 -2
- package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_route_schema.js +3 -2
- package/dist/auth/audit_log_routes.d.ts +20 -11
- package/dist/auth/audit_log_routes.d.ts.map +1 -1
- package/dist/auth/audit_log_routes.js +49 -29
- package/dist/auth/audit_log_schema.d.ts +13 -21
- package/dist/auth/audit_log_schema.d.ts.map +1 -1
- package/dist/auth/audit_log_schema.js +10 -18
- package/dist/auth/bearer_auth.d.ts +7 -4
- package/dist/auth/bearer_auth.d.ts.map +1 -1
- package/dist/auth/bearer_auth.js +21 -15
- package/dist/auth/cell_action_helpers.d.ts +89 -0
- package/dist/auth/cell_action_helpers.d.ts.map +1 -0
- package/dist/auth/cell_action_helpers.js +113 -0
- package/dist/auth/cell_actions.d.ts +22 -13
- package/dist/auth/cell_actions.d.ts.map +1 -1
- package/dist/auth/cell_actions.js +105 -167
- package/dist/auth/cell_audit_actions.d.ts +1 -1
- package/dist/auth/cell_audit_actions.d.ts.map +1 -1
- package/dist/auth/cell_audit_actions.js +3 -12
- package/dist/auth/cell_audit_metadata.d.ts +1 -1
- package/dist/auth/cell_audit_metadata.js +1 -1
- package/dist/auth/cell_field_actions.d.ts +1 -1
- package/dist/auth/cell_field_actions.d.ts.map +1 -1
- package/dist/auth/cell_field_actions.js +16 -66
- package/dist/auth/cell_grant_action_specs.d.ts +2 -2
- package/dist/auth/cell_grant_action_specs.js +3 -3
- package/dist/auth/cell_grant_actions.d.ts +73 -11
- package/dist/auth/cell_grant_actions.d.ts.map +1 -1
- package/dist/auth/cell_grant_actions.js +63 -55
- package/dist/auth/cell_grant_audit_metadata.d.ts +6 -3
- package/dist/auth/cell_grant_audit_metadata.d.ts.map +1 -1
- package/dist/auth/cell_grant_audit_metadata.js +7 -4
- package/dist/auth/cell_item_actions.d.ts +1 -1
- package/dist/auth/cell_item_actions.d.ts.map +1 -1
- package/dist/auth/cell_item_actions.js +21 -82
- package/dist/auth/cleanup.d.ts +1 -1
- package/dist/auth/cleanup.d.ts.map +1 -1
- package/dist/auth/cleanup.js +6 -3
- package/dist/auth/credential_deadline.d.ts +3 -3
- package/dist/auth/credential_deadline.js +3 -3
- package/dist/auth/credential_type_schema.d.ts +5 -5
- package/dist/auth/credential_type_schema.js +5 -5
- package/dist/auth/daemon_token_middleware.d.ts +12 -6
- package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
- package/dist/auth/daemon_token_middleware.js +28 -17
- package/dist/auth/deps.d.ts +4 -4
- package/dist/auth/fail_floor.d.ts +55 -0
- package/dist/auth/fail_floor.d.ts.map +1 -0
- package/dist/auth/fail_floor.js +63 -0
- package/dist/auth/invite_queries.d.ts +3 -15
- package/dist/auth/invite_queries.d.ts.map +1 -1
- package/dist/auth/invite_queries.js +3 -21
- package/dist/auth/middleware.d.ts +12 -7
- package/dist/auth/middleware.d.ts.map +1 -1
- package/dist/auth/middleware.js +42 -29
- package/dist/auth/migrations.d.ts +5 -33
- package/dist/auth/migrations.d.ts.map +1 -1
- package/dist/auth/migrations.js +9 -16
- package/dist/auth/request_context.d.ts +101 -71
- package/dist/auth/request_context.d.ts.map +1 -1
- package/dist/auth/request_context.js +137 -140
- package/dist/auth/resolved_auth.d.ts +122 -36
- package/dist/auth/resolved_auth.d.ts.map +1 -1
- package/dist/auth/resolved_auth.js +89 -38
- package/dist/auth/role_grant_offer_action_specs.d.ts +99 -14
- package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_action_specs.js +26 -13
- package/dist/auth/role_grant_offer_actions.d.ts +13 -7
- package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_actions.js +14 -12
- package/dist/auth/role_grant_offer_notifications.d.ts +3 -3
- package/dist/auth/role_grant_offer_notifications.js +1 -1
- package/dist/auth/role_grant_offer_queries.d.ts +0 -5
- package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_offer_queries.js +9 -41
- package/dist/auth/role_grant_queries.d.ts +17 -67
- package/dist/auth/role_grant_queries.d.ts.map +1 -1
- package/dist/auth/role_grant_queries.js +34 -106
- package/dist/auth/role_grant_sql.d.ts +42 -0
- package/dist/auth/role_grant_sql.d.ts.map +1 -0
- package/dist/auth/role_grant_sql.js +54 -0
- package/dist/auth/scope_kind_schema.d.ts +1 -1
- package/dist/auth/scope_kind_schema.js +1 -1
- package/dist/auth/self_service_role_actions.d.ts +1 -1
- package/dist/auth/self_service_role_actions.d.ts.map +1 -1
- package/dist/auth/self_service_role_actions.js +1 -1
- package/dist/auth/session_queries.d.ts +2 -1
- package/dist/auth/session_queries.d.ts.map +1 -1
- package/dist/auth/session_queries.js +2 -1
- package/dist/auth/signup_routes.d.ts +2 -1
- package/dist/auth/signup_routes.d.ts.map +1 -1
- package/dist/auth/signup_routes.js +14 -13
- package/dist/auth/standard_rpc_actions.d.ts +1 -1
- package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
- package/dist/auth/token_scope.d.ts +19 -46
- package/dist/auth/token_scope.d.ts.map +1 -1
- package/dist/auth/token_scope.js +23 -41
- package/dist/db/CLAUDE.md +9 -4
- package/dist/db/cell_ddl.d.ts +5 -142
- package/dist/db/cell_ddl.d.ts.map +1 -1
- package/dist/db/cell_ddl.js +17 -16
- package/dist/db/cell_field_queries.d.ts +0 -13
- package/dist/db/cell_field_queries.d.ts.map +1 -1
- package/dist/db/cell_field_queries.js +0 -16
- package/dist/db/cell_grant_queries.d.ts +10 -5
- package/dist/db/cell_grant_queries.d.ts.map +1 -1
- package/dist/db/cell_grant_queries.js +13 -7
- package/dist/db/cell_item_queries.d.ts +0 -7
- package/dist/db/cell_item_queries.d.ts.map +1 -1
- package/dist/db/cell_item_queries.js +0 -10
- package/dist/db/cell_queries.d.ts +12 -48
- package/dist/db/cell_queries.d.ts.map +1 -1
- package/dist/db/cell_queries.js +24 -55
- package/dist/db/cell_view_sql.d.ts +1 -6
- package/dist/db/cell_view_sql.d.ts.map +1 -1
- package/dist/db/cell_view_sql.js +1 -2
- package/dist/db/fact_ddl.d.ts +5 -30
- package/dist/db/fact_ddl.d.ts.map +1 -1
- package/dist/db/fact_ddl.js +14 -13
- package/dist/db/fact_store.d.ts +11 -0
- package/dist/db/fact_store.d.ts.map +1 -1
- package/dist/db/fact_store.js +4 -1
- package/dist/db/migrate.d.ts +44 -6
- package/dist/db/migrate.d.ts.map +1 -1
- package/dist/db/migrate.js +63 -4
- package/dist/dev/setup.d.ts +18 -14
- package/dist/dev/setup.d.ts.map +1 -1
- package/dist/dev/setup.js +42 -39
- package/dist/env/dotenv.d.ts +2 -2
- package/dist/env/dotenv.js +2 -2
- package/dist/env/update_env_variable.d.ts +33 -21
- package/dist/env/update_env_variable.d.ts.map +1 -1
- package/dist/env/update_env_variable.js +54 -35
- package/dist/hono_context.d.ts +15 -90
- package/dist/hono_context.d.ts.map +1 -1
- package/dist/hono_context.js +9 -56
- package/dist/http/CLAUDE.md +35 -20
- package/dist/http/auth_shape.d.ts +1 -8
- package/dist/http/auth_shape.d.ts.map +1 -1
- package/dist/http/auth_shape.js +6 -12
- package/dist/http/common_routes.d.ts.map +1 -1
- package/dist/http/common_routes.js +3 -2
- package/dist/http/db_routes.d.ts +3 -3
- package/dist/http/db_routes.js +3 -3
- package/dist/http/error_schemas.d.ts +1 -2
- package/dist/http/error_schemas.d.ts.map +1 -1
- package/dist/http/error_schemas.js +1 -2
- package/dist/http/health_schema.d.ts +16 -0
- package/dist/http/health_schema.d.ts.map +1 -0
- package/dist/http/health_schema.js +12 -0
- package/dist/http/jsonrpc_errors.d.ts +22 -2
- package/dist/http/jsonrpc_errors.d.ts.map +1 -1
- package/dist/http/jsonrpc_errors.js +41 -3
- package/dist/http/jsonrpc_helpers.d.ts +60 -17
- package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
- package/dist/http/jsonrpc_helpers.js +67 -25
- package/dist/http/origin.d.ts +30 -1
- package/dist/http/origin.d.ts.map +1 -1
- package/dist/http/origin.js +46 -9
- package/dist/http/origin_wildcard.d.ts +97 -0
- package/dist/http/origin_wildcard.d.ts.map +1 -0
- package/dist/http/origin_wildcard.js +142 -0
- package/dist/http/pending_effects.d.ts +28 -0
- package/dist/http/pending_effects.d.ts.map +1 -1
- package/dist/http/pending_effects.js +32 -1
- package/dist/http/route_spec.d.ts +4 -3
- package/dist/http/route_spec.d.ts.map +1 -1
- package/dist/http/route_spec.js +54 -45
- package/dist/http/surface.d.ts +1 -1
- package/dist/http/surface.d.ts.map +1 -1
- package/dist/http/surface_query.d.ts +9 -50
- package/dist/http/surface_query.d.ts.map +1 -1
- package/dist/http/surface_query.js +48 -94
- package/dist/realtime/audit_log_sse.d.ts +180 -0
- package/dist/realtime/audit_log_sse.d.ts.map +1 -0
- package/dist/realtime/audit_log_sse.js +154 -0
- package/dist/realtime/sse.d.ts +21 -6
- package/dist/realtime/sse.d.ts.map +1 -1
- package/dist/realtime/sse.js +33 -10
- package/dist/realtime/sse_constants.d.ts +29 -2
- package/dist/realtime/sse_constants.d.ts.map +1 -1
- package/dist/realtime/sse_constants.js +35 -2
- package/dist/realtime/{subscriber_registry.d.ts → sse_registry.d.ts} +12 -12
- package/dist/realtime/sse_registry.d.ts.map +1 -0
- package/dist/realtime/{subscriber_registry.js → sse_registry.js} +4 -4
- package/dist/schema_meta.d.ts +30 -10
- package/dist/schema_meta.d.ts.map +1 -1
- package/dist/schema_meta.js +85 -21
- package/dist/sensitivity.d.ts +9 -3
- package/dist/sensitivity.d.ts.map +1 -1
- package/dist/sensitivity.js +3 -2
- package/dist/server/app_backend.d.ts +8 -5
- package/dist/server/app_backend.d.ts.map +1 -1
- package/dist/server/app_backend.js +6 -12
- package/dist/server/app_server.d.ts +62 -51
- package/dist/server/app_server.d.ts.map +1 -1
- package/dist/server/app_server.js +84 -71
- package/dist/server/app_server_context.d.ts +1 -1
- package/dist/server/app_server_context.d.ts.map +1 -1
- package/dist/server/env.d.ts +24 -20
- package/dist/server/env.d.ts.map +1 -1
- package/dist/server/env.js +24 -34
- package/dist/server/serve_fact_route.d.ts +12 -16
- package/dist/server/serve_fact_route.d.ts.map +1 -1
- package/dist/server/serve_fact_route.js +59 -34
- package/dist/server/static.d.ts.map +1 -1
- package/dist/server/static.js +2 -2
- package/dist/testing/CLAUDE.md +179 -158
- package/dist/testing/admin_integration.d.ts.map +1 -1
- package/dist/testing/admin_integration.js +10 -19
- package/dist/testing/adversarial_headers.d.ts.map +1 -1
- package/dist/testing/adversarial_headers.js +8 -0
- package/dist/testing/app_server.d.ts +9 -77
- package/dist/testing/app_server.d.ts.map +1 -1
- package/dist/testing/app_server.js +31 -112
- package/dist/testing/attack_surface.d.ts.map +1 -1
- package/dist/testing/attack_surface.js +3 -4
- package/dist/testing/audit_completeness.d.ts.map +1 -1
- package/dist/testing/audit_completeness.js +4 -5
- package/dist/testing/auth_apps.d.ts +3 -3
- package/dist/testing/auth_apps.d.ts.map +1 -1
- package/dist/testing/auth_apps.js +9 -6
- package/dist/testing/connection_closer_helpers.d.ts +8 -16
- package/dist/testing/connection_closer_helpers.d.ts.map +1 -1
- package/dist/testing/connection_closer_helpers.js +7 -20
- package/dist/testing/cross_backend/action_manifest.d.ts +15 -4
- package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest.js +13 -3
- package/dist/testing/cross_backend/action_manifest_parity.d.ts +15 -7
- package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
- package/dist/testing/cross_backend/action_manifest_parity.js +8 -1
- package/dist/testing/cross_backend/body_size.d.ts.map +1 -1
- package/dist/testing/cross_backend/body_size.js +25 -22
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts +22 -3
- package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
- package/dist/testing/cross_backend/build_test_backend_paths.js +34 -11
- package/dist/testing/cross_backend/capabilities.d.ts +13 -7
- package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_grant_role.js +2 -2
- package/dist/testing/cross_backend/cell_grant_steward.d.ts +4 -0
- package/dist/testing/cross_backend/cell_grant_steward.d.ts.map +1 -0
- package/dist/testing/cross_backend/cell_grant_steward.js +120 -0
- package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
- package/dist/testing/cross_backend/cell_relations.js +21 -0
- package/dist/testing/cross_backend/conformance_table.d.ts +1 -1
- package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.d.ts +18 -4
- package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
- package/dist/testing/cross_backend/default_backend_configs.js +29 -9
- package/dist/testing/cross_backend/default_spine_surface.d.ts +7 -7
- package/dist/testing/cross_backend/default_spine_surface.js +2 -2
- package/dist/testing/cross_backend/fact_serving.d.ts.map +1 -1
- package/dist/testing/cross_backend/fact_serving.js +48 -0
- package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -4
- package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
- package/dist/testing/cross_backend/full_spine_mount.js +9 -2
- package/dist/testing/cross_backend/origin_scope.d.ts.map +1 -1
- package/dist/testing/cross_backend/origin_scope.js +5 -13
- package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
- package/dist/testing/cross_backend/peer_ping_ws.js +29 -4
- package/dist/testing/cross_backend/postgres_database.d.ts +32 -0
- package/dist/testing/cross_backend/postgres_database.d.ts.map +1 -1
- package/dist/testing/cross_backend/postgres_database.js +56 -1
- package/dist/testing/cross_backend/query_shape.d.ts.map +1 -1
- package/dist/testing/cross_backend/query_shape.js +18 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
- package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +23 -1
- package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -2
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +1 -1
- package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +17 -5
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +5 -4
- package/dist/testing/cross_backend/session_cap.d.ts +8 -0
- package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/session_cap.js +66 -2
- package/dist/testing/cross_backend/setup.d.ts.map +1 -1
- package/dist/testing/cross_backend/setup.js +5 -4
- package/dist/testing/cross_backend/spine_suites.d.ts +4 -1
- package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_suites.js +21 -0
- package/dist/testing/cross_backend/spine_surface_constants.d.ts +22 -7
- package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
- package/dist/testing/cross_backend/spine_surface_constants.js +22 -7
- package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/sse_round_trip.js +4 -3
- package/dist/testing/cross_backend/standard.d.ts +6 -12
- package/dist/testing/cross_backend/standard.d.ts.map +1 -1
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts +8 -0
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.d.ts.map +1 -0
- package/dist/testing/cross_backend/test_cell_grant_steward_revoke_authorize.js +22 -0
- package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_backdoor.js +4 -6
- package/dist/testing/cross_backend/testing_origin_check.d.ts +1 -1
- package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_origin_check.js +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.d.ts +10 -5
- package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_reset_actions.js +7 -6
- package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_bun.js +5 -4
- package/dist/testing/cross_backend/testing_server_core.d.ts +6 -7
- package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_core.js +1 -1
- package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
- package/dist/testing/cross_backend/testing_server_node.js +13 -2
- package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
- package/dist/testing/cross_backend/token_lifetime.js +68 -0
- package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
- package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
- package/dist/testing/cross_backend/transport_composition.js +45 -3
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +16 -2
- package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
- package/dist/testing/cross_backend/ts_spine_backend_config.js +11 -8
- package/dist/testing/cross_backend/ws_action_rate_limit.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_action_rate_limit.js +30 -12
- package/dist/testing/cross_backend/ws_connection_cap.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_connection_cap.js +5 -7
- package/dist/testing/cross_backend/ws_endpoint.d.ts +2 -3
- package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_envelope.d.ts +17 -0
- package/dist/testing/cross_backend/ws_envelope.d.ts.map +1 -0
- package/dist/testing/cross_backend/ws_envelope.js +172 -0
- package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts +16 -0
- package/dist/testing/cross_backend/ws_inbound_dispatch.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_inbound_dispatch.js +8 -4
- package/dist/testing/cross_backend/ws_outbound_overflow.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_outbound_overflow.js +5 -8
- package/dist/testing/cross_backend/ws_role_gated.js +2 -2
- package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/cross_backend/ws_round_trip.js +6 -4
- package/dist/{cli/daemon.d.ts → testing/daemon_info.d.ts} +15 -47
- package/dist/testing/daemon_info.d.ts.map +1 -0
- package/dist/testing/daemon_info.js +108 -0
- package/dist/testing/daemon_token_rotation.js +1 -1
- package/dist/testing/data_exposure.d.ts.map +1 -1
- package/dist/testing/data_exposure.js +3 -4
- package/dist/testing/db.js +2 -2
- package/dist/testing/integration.d.ts.map +1 -1
- package/dist/testing/integration.js +35 -65
- package/dist/testing/integration_helpers.d.ts +0 -15
- package/dist/testing/integration_helpers.d.ts.map +1 -1
- package/dist/testing/integration_helpers.js +2 -42
- package/dist/testing/middleware.d.ts +20 -12
- package/dist/testing/middleware.d.ts.map +1 -1
- package/dist/testing/middleware.js +49 -40
- package/dist/testing/rate_limiting.d.ts.map +1 -1
- package/dist/testing/rate_limiting.js +13 -22
- package/dist/testing/resolved_auth.d.ts +30 -0
- package/dist/testing/resolved_auth.d.ts.map +1 -0
- package/dist/testing/resolved_auth.js +41 -0
- package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
- package/dist/testing/rpc_envelope_cases.js +3 -0
- package/dist/testing/rpc_helpers.d.ts +1 -1
- package/dist/testing/rpc_helpers.d.ts.map +1 -1
- package/dist/testing/rpc_helpers.js +2 -1
- package/dist/testing/sse_round_trip.d.ts +5 -4
- package/dist/testing/sse_round_trip.d.ts.map +1 -1
- package/dist/testing/sse_round_trip.js +2 -2
- package/dist/testing/stubs.d.ts +2 -2
- package/dist/testing/stubs.d.ts.map +1 -1
- package/dist/testing/stubs.js +24 -21
- package/dist/testing/test_origin.d.ts +25 -0
- package/dist/testing/test_origin.d.ts.map +1 -0
- package/dist/testing/test_origin.js +28 -0
- package/dist/testing/transports/raw_http.d.ts +54 -0
- package/dist/testing/transports/raw_http.d.ts.map +1 -1
- package/dist/testing/transports/raw_http.js +58 -0
- package/dist/testing/transports/ws_raw_client.d.ts +8 -0
- package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
- package/dist/testing/transports/ws_raw_client.js +13 -0
- package/dist/testing/transports/ws_transport.d.ts +15 -2
- package/dist/testing/transports/ws_transport.d.ts.map +1 -1
- package/dist/testing/transports/ws_transport.js +4 -2
- package/dist/testing/ws_round_trip.d.ts +27 -25
- package/dist/testing/ws_round_trip.d.ts.map +1 -1
- package/dist/testing/ws_round_trip.js +34 -26
- package/dist/ui/AccountSessions.svelte +48 -19
- package/dist/ui/AccountSessions.svelte.d.ts +2 -17
- package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
- package/dist/ui/AdminAccounts.svelte +6 -1
- package/dist/ui/AdminAuditLog.svelte +61 -22
- package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
- package/dist/ui/AdminInvites.svelte +1 -1
- package/dist/ui/AdminOverview.svelte +76 -37
- package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
- package/dist/ui/AdminRoleGrantHistory.svelte +6 -1
- package/dist/ui/AdminSessions.svelte +1 -1
- package/dist/ui/AppShell.svelte +3 -2
- package/dist/ui/AppShell.svelte.d.ts +3 -2
- package/dist/ui/AppShell.svelte.d.ts.map +1 -1
- package/dist/ui/CLAUDE.md +121 -35
- package/dist/ui/Datatable.svelte +33 -18
- package/dist/ui/Datatable.svelte.d.ts +2 -14
- package/dist/ui/Datatable.svelte.d.ts.map +1 -1
- package/dist/ui/OpenSignupToggle.svelte +10 -1
- package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
- package/dist/ui/PopoverButton.svelte +13 -8
- package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferForm.svelte +3 -2
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts +3 -2
- package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
- package/dist/ui/RoleGrantOfferHistory.svelte +3 -3
- package/dist/ui/RoleGrantOfferInbox.svelte +19 -15
- package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
- package/dist/ui/SurfaceExplorer.svelte +66 -27
- package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
- package/dist/ui/account_sessions_state.svelte.d.ts +7 -14
- package/dist/ui/account_sessions_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.d.ts +14 -9
- package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_accounts_state.svelte.js +6 -4
- package/dist/ui/admin_invites_state.svelte.d.ts +2 -2
- package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.d.ts +9 -9
- package/dist/ui/admin_rpc_adapters.d.ts.map +1 -1
- package/dist/ui/admin_rpc_adapters.js +9 -9
- package/dist/ui/app_settings_state.svelte.d.ts +2 -2
- package/dist/ui/app_settings_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.d.ts +70 -13
- package/dist/ui/audit_log_state.svelte.d.ts.map +1 -1
- package/dist/ui/audit_log_state.svelte.js +239 -47
- package/dist/ui/backend_probe.svelte.d.ts +93 -0
- package/dist/ui/backend_probe.svelte.d.ts.map +1 -0
- package/dist/ui/backend_probe.svelte.js +140 -0
- package/dist/ui/format_scope.d.ts +7 -7
- package/dist/ui/format_scope.d.ts.map +1 -1
- package/dist/ui/format_scope.js +4 -4
- package/dist/ui/keyed_async_slot.svelte.d.ts +2 -2
- package/dist/ui/keyed_async_slot.svelte.js +2 -2
- package/dist/ui/popover.svelte.d.ts +18 -19
- package/dist/ui/popover.svelte.d.ts.map +1 -1
- package/dist/ui/popover.svelte.js +103 -16
- package/dist/ui/role_grant_offers_state.svelte.d.ts +41 -46
- package/dist/ui/role_grant_offers_state.svelte.d.ts.map +1 -1
- package/dist/ui/role_grant_offers_state.svelte.js +37 -19
- package/dist/ui/ui_format.d.ts +17 -0
- package/dist/ui/ui_format.d.ts.map +1 -1
- package/dist/ui/ui_format.js +20 -0
- package/package.json +9 -8
- package/dist/actions/register_ws_endpoint.d.ts +0 -79
- package/dist/actions/register_ws_endpoint.d.ts.map +0 -1
- package/dist/actions/register_ws_endpoint.js +0 -109
- package/dist/actions/transports_ws_auth_guard.d.ts +0 -96
- package/dist/actions/transports_ws_auth_guard.d.ts.map +0 -1
- package/dist/actions/transports_ws_auth_guard.js +0 -141
- package/dist/actions/transports_ws_backend.d.ts.map +0 -1
- package/dist/cli/args.d.ts +0 -55
- package/dist/cli/args.d.ts.map +0 -1
- package/dist/cli/args.js +0 -100
- package/dist/cli/config.d.ts +0 -47
- package/dist/cli/config.d.ts.map +0 -1
- package/dist/cli/config.js +0 -77
- package/dist/cli/daemon.d.ts.map +0 -1
- package/dist/cli/daemon.js +0 -181
- package/dist/cli/help.d.ts +0 -124
- package/dist/cli/help.d.ts.map +0 -1
- package/dist/cli/help.js +0 -215
- package/dist/cli/logger.d.ts +0 -46
- package/dist/cli/logger.d.ts.map +0 -1
- package/dist/cli/logger.js +0 -48
- package/dist/cli/util.d.ts +0 -36
- package/dist/cli/util.d.ts.map +0 -1
- package/dist/cli/util.js +0 -50
- package/dist/realtime/sse_auth_guard.d.ts +0 -197
- package/dist/realtime/sse_auth_guard.d.ts.map +0 -1
- package/dist/realtime/sse_auth_guard.js +0 -239
- package/dist/realtime/subscriber_registry.d.ts.map +0 -1
- package/dist/testing/bootstrap_success.d.ts +0 -29
- package/dist/testing/bootstrap_success.d.ts.map +0 -1
- package/dist/testing/bootstrap_success.js +0 -144
- package/dist/testing/mock_fs.d.ts +0 -20
- package/dist/testing/mock_fs.d.ts.map +0 -1
- package/dist/testing/mock_fs.js +0 -28
- package/dist/testing/standard.d.ts +0 -122
- package/dist/testing/standard.d.ts.map +0 -1
- package/dist/testing/standard.js +0 -73
- package/dist/testing/testing_rate_limiter.d.ts +0 -65
- package/dist/testing/testing_rate_limiter.d.ts.map +0 -1
- package/dist/testing/testing_rate_limiter.js +0 -80
package/dist/actions/CLAUDE.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# actions/ — SAES (Symmetric Action Event System)
|
|
2
2
|
|
|
3
|
-
> One declarative `ActionSpec` binds to
|
|
4
|
-
>
|
|
5
|
-
>
|
|
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
|
-
|
|
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
|
|
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` —
|
|
69
|
-
- `remote_notification` — no
|
|
70
|
-
- `local_call` — none (no
|
|
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
|
-
`
|
|
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
|
-
- `
|
|
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: `
|
|
146
|
-
`
|
|
147
|
-
`
|
|
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
|
|
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
|
|
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 `
|
|
237
|
-
|
|
238
|
-
Error paths: `ThrownJsonrpcError` (
|
|
239
|
-
|
|
240
|
-
e.g.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
`internal_error` 500
|
|
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:
|
|
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 `
|
|
317
|
-
|
|
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**
|
|
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
|
-
|
|
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
|
|
357
|
-
|
|
358
|
-
`Transports`
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
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 `
|
|
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`): `
|
|
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 (
|
|
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
|
|
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/
|
|
381
|
-
- `actions/ws_outbound_writer.ts` — `WsOutboundWriter`, the outbound queue and write pump of one connection, which every frame the
|
|
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 `
|
|
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
|
-
### `
|
|
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
|
-
`{
|
|
418
|
-
`
|
|
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
|
|
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
|
|
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,
|
|
437
|
-
|
|
438
|
-
|
|
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; `
|
|
441
|
-
|
|
442
|
-
(`
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
-
|
|
486
|
-
`register_action_ws` passes its own to the
|
|
487
|
-
endpoints sharing one
|
|
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
|
|
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 (
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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
|
-
`
|
|
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
|
|
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
|
|
586
|
-
|
|
587
|
-
predicate
|
|
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).
|
|
590
|
-
|
|
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
|
|
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
|
-
`
|
|
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
|
-
`
|
|
617
|
+
`ConnectionCloser`:
|
|
622
618
|
|
|
623
619
|
```ts
|
|
624
620
|
interface ConnectionCloser {
|
|
625
|
-
|
|
626
|
-
|
|
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
|
-
`
|
|
634
|
-
`create_sse_connection_closer(registry, required_role)` (`realtime/
|
|
635
|
-
|
|
636
|
-
`
|
|
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
|
|
639
|
-
Closing is idempotent and synchronous. `
|
|
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
|
-
|
|
644
|
-
closed) — so a closed
|
|
645
|
-
counterpart is `ShutdownCloser::
|
|
646
|
-
`
|
|
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`
|
|
655
|
-
|
|
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 `
|
|
662
|
-
`
|
|
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
|
-
|
|
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
|
|
682
|
-
`connection_closer: null` to the mount functions so it holds the removers),
|
|
683
|
-
removes them when its assembly fails
|
|
684
|
-
`
|
|
685
|
-
`
|
|
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
|
-
`
|
|
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
|
-
`
|
|
701
|
-
(`null` is the explicit opt-out, or for a caller that adds the
|
|
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
|
-
|
|
700
|
+
### Revocation guard (`create_revocation_guard`)
|
|
705
701
|
|
|
706
|
-
The audit-listener half of revocation: `
|
|
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
|
-
|
|
715
|
-
`
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
`
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
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
|
-
`
|
|
730
|
-
- `role` (`role_grant_revoke`) → `
|
|
731
|
-
account_id, metadata.role
|
|
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
|
|
735
|
-
endpoint sends — so
|
|
736
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
`
|
|
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
|
|
771
|
-
both the mount and the
|
|
772
|
-
`post_route_middleware` and `static_serving`,
|
|
773
|
-
|
|
774
|
-
middleware's scope (`AUTH_MIDDLEWARE_PATH`, `'/api/*'`,
|
|
775
|
-
`auth/middleware.ts` — matched with `middleware_applies`, so `/api` itself
|
|
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
|
-
`
|
|
783
|
-
`
|
|
784
|
-
`
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
`
|
|
789
|
-
|
|
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
|
-
|
|
793
|
-
It throws alongside `
|
|
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
|
-
|
|
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
|
-
`
|
|
800
|
+
`registry`).
|
|
799
801
|
|
|
800
|
-
Mounted
|
|
801
|
-
(`Readonly<Record<string,
|
|
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
|
-
### `
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
`
|
|
832
|
-
|
|
833
|
-
`create_app_server`'s
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
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.
|
|
850
|
+
HTTP RPC also calls. The socket session owns only WS-specific concerns:
|
|
842
851
|
|
|
843
|
-
- **Wire envelope parsing** — JSON.parse → batch rejection →
|
|
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 `
|
|
847
|
-
- **Socket-scoped notify** — `(method, params) =>
|
|
848
|
-
- **Every send through the
|
|
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 (`
|
|
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
|
|
855
|
-
(`
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
`
|
|
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.
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
`
|
|
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
|
|
916
|
-
time**: the
|
|
917
|
-
`
|
|
918
|
-
`
|
|
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
|
|
923
|
-
its socket (a bare `
|
|
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` (`
|
|
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
|
|
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`,
|
|
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)
|
|
943
|
-
`
|
|
944
|
-
|
|
945
|
-
Both flush in the same `try/finally` that releases
|
|
946
|
-
after the reply is sent
|
|
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` `
|
|
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
|
-
`
|
|
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
|
-
**
|
|
988
|
-
|
|
989
|
-
`
|
|
990
|
-
|
|
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
|
|
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,
|
|
1028
|
-
|
|
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 `
|
|
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})`. **
|
|
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`
|
|
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. `
|
|
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 `
|
|
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
|
-
|
|
1193
|
-
`
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
`
|
|
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({
|
|
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
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
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
|
-
`
|
|
1223
|
-
|
|
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
|
|
1238
|
-
- `
|
|
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.
|