@fuzdev/fuz_app 0.177.0 → 0.179.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/dist/actions/CLAUDE.md +117 -12
  2. package/dist/actions/connection_registry.d.ts +18 -0
  3. package/dist/actions/connection_registry.d.ts.map +1 -1
  4. package/dist/actions/connection_registry.js +23 -0
  5. package/dist/actions/room_action_specs.d.ts +733 -0
  6. package/dist/actions/room_action_specs.d.ts.map +1 -0
  7. package/dist/actions/room_action_specs.js +506 -0
  8. package/dist/actions/room_actions.d.ts +276 -0
  9. package/dist/actions/room_actions.d.ts.map +1 -0
  10. package/dist/actions/room_actions.js +394 -0
  11. package/dist/actions/room_client.svelte.d.ts +399 -0
  12. package/dist/actions/room_client.svelte.d.ts.map +1 -0
  13. package/dist/actions/room_client.svelte.js +942 -0
  14. package/dist/actions/room_registry.d.ts +454 -0
  15. package/dist/actions/room_registry.d.ts.map +1 -0
  16. package/dist/actions/room_registry.js +927 -0
  17. package/dist/actions/ws_socket_session.d.ts +2 -2
  18. package/dist/actions/ws_socket_session.js +3 -3
  19. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  20. package/dist/auth/role_grant_queries.d.ts +17 -0
  21. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  22. package/dist/auth/role_grant_queries.js +30 -0
  23. package/dist/rtc/rtc_mesh.svelte.d.ts +102 -0
  24. package/dist/rtc/rtc_mesh.svelte.d.ts.map +1 -0
  25. package/dist/rtc/rtc_mesh.svelte.js +232 -0
  26. package/dist/rtc/rtc_peer.svelte.d.ts +180 -0
  27. package/dist/rtc/rtc_peer.svelte.d.ts.map +1 -0
  28. package/dist/rtc/rtc_peer.svelte.js +397 -0
  29. package/dist/rtc/rtc_signal.d.ts +74 -0
  30. package/dist/rtc/rtc_signal.d.ts.map +1 -0
  31. package/dist/rtc/rtc_signal.js +87 -0
  32. package/dist/server/app_server.d.ts +16 -27
  33. package/dist/server/app_server.d.ts.map +1 -1
  34. package/dist/server/app_server.js +7 -9
  35. package/dist/testing/CLAUDE.md +72 -18
  36. package/dist/testing/cross_backend/action_manifest.d.ts +34 -2
  37. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  38. package/dist/testing/cross_backend/action_manifest.js +33 -6
  39. package/dist/testing/cross_backend/capabilities.d.ts +23 -5
  40. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  41. package/dist/testing/cross_backend/capabilities.js +4 -1
  42. package/dist/testing/cross_backend/default_backend_configs.js +1 -1
  43. package/dist/testing/cross_backend/full_spine_mount.d.ts +31 -6
  44. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  45. package/dist/testing/cross_backend/full_spine_mount.js +45 -13
  46. package/dist/testing/cross_backend/rooms_ws.d.ts +20 -0
  47. package/dist/testing/cross_backend/rooms_ws.d.ts.map +1 -0
  48. package/dist/testing/cross_backend/rooms_ws.js +534 -0
  49. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  50. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -1
  51. package/dist/testing/cross_backend/spine_suites.d.ts +5 -2
  52. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  53. package/dist/testing/cross_backend/spine_suites.js +24 -5
  54. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  55. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  56. package/dist/testing/cross_backend/spine_surface_constants.js +2 -1
  57. package/dist/testing/cross_backend/test_room_authorize.d.ts +47 -0
  58. package/dist/testing/cross_backend/test_room_authorize.d.ts.map +1 -0
  59. package/dist/testing/cross_backend/test_room_authorize.js +58 -0
  60. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  61. package/dist/testing/cross_backend/testing_backdoor.js +10 -4
  62. package/dist/testing/cross_backend/testing_reset_actions.d.ts +85 -1
  63. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  64. package/dist/testing/cross_backend/testing_reset_actions.js +57 -3
  65. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  66. package/dist/testing/cross_backend/testing_server_bun.js +6 -7
  67. package/dist/testing/cross_backend/testing_server_core.d.ts +23 -37
  68. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  69. package/dist/testing/cross_backend/testing_server_core.js +1 -8
  70. package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
  71. package/dist/testing/cross_backend/testing_server_node.js +35 -46
  72. package/dist/testing/cross_backend/transport_composition.js +2 -2
  73. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  74. package/dist/testing/cross_backend/ts_spine_backend_config.js +6 -3
  75. package/dist/testing/stubs.d.ts +1 -1
  76. package/dist/testing/stubs.js +1 -1
  77. package/dist/ui/AccountSessions.svelte.d.ts.map +1 -1
  78. package/dist/ui/AdminAccounts.svelte.d.ts.map +1 -1
  79. package/dist/ui/AdminAuditLog.svelte.d.ts.map +1 -1
  80. package/dist/ui/AdminInvites.svelte.d.ts.map +1 -1
  81. package/dist/ui/AdminOverview.svelte.d.ts.map +1 -1
  82. package/dist/ui/AdminRoleGrantHistory.svelte.d.ts.map +1 -1
  83. package/dist/ui/AdminSessions.svelte.d.ts.map +1 -1
  84. package/dist/ui/AdminSettings.svelte.d.ts.map +1 -1
  85. package/dist/ui/AdminSurface.svelte.d.ts.map +1 -1
  86. package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
  87. package/dist/ui/ConfirmButton.svelte.d.ts.map +1 -1
  88. package/dist/ui/Datatable.svelte.d.ts.map +1 -1
  89. package/dist/ui/LoginForm.svelte.d.ts.map +1 -1
  90. package/dist/ui/LogoutButton.svelte.d.ts.map +1 -1
  91. package/dist/ui/OpenSignupToggle.svelte.d.ts.map +1 -1
  92. package/dist/ui/PopoverButton.svelte.d.ts.map +1 -1
  93. package/dist/ui/RoleGrantOfferForm.svelte.d.ts.map +1 -1
  94. package/dist/ui/RoleGrantOfferHistory.svelte.d.ts.map +1 -1
  95. package/dist/ui/RoleGrantOfferInbox.svelte.d.ts.map +1 -1
  96. package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
  97. package/dist/ui/SurfaceExplorer.svelte.d.ts.map +1 -1
  98. package/package.json +21 -26
@@ -53,10 +53,11 @@ import '../assert_dev_env.js';
53
53
  *
54
54
  * **Backdoors.** The backend's `capabilities.testing_backdoors` must declare
55
55
  * `SPINE_SUITES_REQUIRED_BACKDOORS` (the per-test reset and the audit
56
- * barrier), and `_testing_put_fact` when it declares `fact_serving`; the call
57
- * throws otherwise. A suite every case of which drives another backdoor
58
- * (`credential_deadline`, `origin_conformance`, `ws_outbound_overflow`) skips
59
- * itself on a backend not declaring it, shown like an exclude with a reason
56
+ * barrier), `_testing_put_fact` when it declares `fact_serving`, and
57
+ * `_testing_room_evict` when it declares `rooms`; the call throws otherwise. A
58
+ * suite every case of which drives another backdoor (`credential_deadline`,
59
+ * `origin_conformance`, `ws_outbound_overflow`) skips itself on a backend not
60
+ * declaring it, shown like an exclude with a reason
60
61
  * naming the backdoor — so an exclude, override or `exclude_cases` entry for
61
62
  * it is refused as dead.
62
63
  *
@@ -104,6 +105,7 @@ import { describe_role_grant_offer_lifecycle_cross_tests } from './role_grant_of
104
105
  import { describe_role_grant_offer_notification_ws_tests } from './role_grant_offer_notification_ws.js';
105
106
  import { describe_role_grant_participation_cross_tests } from './role_grant_participation.js';
106
107
  import { describe_role_grant_role_grammar_cross_tests } from './role_grant_role_grammar.js';
108
+ import { describe_rooms_ws_cross_tests } from './rooms_ws.js';
107
109
  import { describe_rpc_adversarial_cross_tests } from './rpc_adversarial.js';
108
110
  import { describe_session_cap_cross_tests } from './session_cap.js';
109
111
  import { describe_session_cookie_codec_cross_tests } from './session_cookie_codec.js';
@@ -158,6 +160,7 @@ export const SUITE_NAMES = [
158
160
  'role_grant_offer_notification_ws',
159
161
  'role_grant_participation',
160
162
  'role_grant_role_grammar',
163
+ 'rooms_ws',
161
164
  'rpc_adversarial',
162
165
  'session_cap',
163
166
  'session_cookie_codec',
@@ -422,6 +425,17 @@ const SUITE_ENTRIES = {
422
425
  describe: describe_role_grant_role_grammar_cross_tests,
423
426
  required: { setup_test: true }
424
427
  },
428
+ rooms_ws: {
429
+ derive: (c) => ({
430
+ setup_test: c.setup(),
431
+ capabilities: c.config.capabilities,
432
+ base_url: c.config.base_url,
433
+ ws_path: c.config.ws_path,
434
+ rpc_path: c.config.rpc_path
435
+ }),
436
+ describe: describe_rooms_ws_cross_tests,
437
+ required: { setup_test: true, capabilities: true, base_url: true, ws_path: true }
438
+ },
425
439
  rpc_adversarial: {
426
440
  derive: (c) => ({
427
441
  setup_test: c.setup(),
@@ -732,6 +746,10 @@ const validate_spine_cross_suites_options = (options, declared, backdoor_skips,
732
746
  throw new Error('describe_spine_cross_suites: capabilities.fact_serving needs _testing_put_fact in ' +
733
747
  'capabilities.testing_backdoors — the fact suites seed through it');
734
748
  }
749
+ if (capabilities.rooms && !declared.includes('_testing_room_evict')) {
750
+ throw new Error('describe_spine_cross_suites: capabilities.rooms needs _testing_room_evict in ' +
751
+ 'capabilities.testing_backdoors — the rooms suite evicts through it');
752
+ }
735
753
  };
736
754
  const run_suite = (name, context) => {
737
755
  const entry = SUITE_ENTRIES[name];
@@ -878,7 +896,8 @@ export const register_spine_case_exclusions = (exclude_cases, ranges) => {
878
896
  * its cases, or an override changing its `capabilities.testing_backdoors`), an exclude,
879
897
  * override or `exclude_cases` entry for a suite that skips itself or isn't
880
898
  * run, a backend not declaring `SPINE_SUITES_REQUIRED_BACKDOORS` (or
881
- * `_testing_put_fact` with `fact_serving`), or a suite missing an input the
899
+ * `_testing_put_fact` with `fact_serving`, or `_testing_room_evict` with
900
+ * `rooms`), or a suite missing an input the
882
901
  * handle doesn't carry
883
902
  */
884
903
  export const describe_spine_cross_suites = (handle, options) => {
@@ -25,7 +25,7 @@ export declare const TESTING_ACTION_AUTH: {
25
25
  * fuz_app's spine binary mounts, so an action added there fails until it is
26
26
  * listed here.
27
27
  */
28
- export declare const TESTING_BACKDOOR_METHODS: readonly ["_testing_reset", "_testing_drain_effects", "_testing_mint_session", "_testing_put_fact", "_testing_flood_notifications", "_testing_schema_snapshot", "_testing_migration_tracker", "_testing_action_manifest", "_testing_origin_check", "_testing_shorten_credential_expiry"];
28
+ export declare const TESTING_BACKDOOR_METHODS: readonly ["_testing_reset", "_testing_drain_effects", "_testing_mint_session", "_testing_put_fact", "_testing_flood_notifications", "_testing_schema_snapshot", "_testing_migration_tracker", "_testing_action_manifest", "_testing_origin_check", "_testing_shorten_credential_expiry", "_testing_room_evict"];
29
29
  /** A `_testing_*` backdoor the shipped cross suites know — see `TESTING_BACKDOOR_METHODS`. */
30
30
  export type TestingBackdoorMethod = (typeof TESTING_BACKDOOR_METHODS)[number];
31
31
  /** RPC endpoint mount path — matches the binary's `/api/rpc`. */
@@ -1 +1 @@
1
- {"version":3,"file":"spine_surface_constants.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/spine_surface_constants.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4B9B;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB;;;;CAIF,CAAC;AAE/B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,0RAW3B,CAAC;AAEX,8FAA8F;AAC9F,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9E,iEAAiE;AACjE,eAAO,MAAM,cAAc,aAAa,CAAC;AAEzC,+EAA+E;AAC/E,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AAExD,wBAAwB;AACxB,eAAO,MAAM,wBAAwB,uBAAuB,CAAC;AAE7D,yBAAyB;AACzB,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D,kCAAkC;AAClC,eAAO,MAAM,2BAA2B,0BAA0B,CAAC;AAEnE,iCAAiC;AACjC,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D,yBAAyB;AACzB,eAAO,MAAM,yBAAyB,wBAAwB,CAAC;AAE/D,yEAAyE;AACzE,eAAO,MAAM,4BAA4B,2BAA2B,CAAC;AAErE;;;;;;GAMG;AACH,eAAO,MAAM,cAAc,4BAA4B,CAAC;AAExD;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,QAAc,CAAC;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AAEpD;;;;;;;;;GASG;AACH,eAAO,MAAM,sBAAsB,gBAAgB,CAAC;AAEpD;;;;;;;;;GASG;AACH,eAAO,MAAM,wBAAwB,kBAAkB,CAAC;AAExD;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,EAAE,aAAa,CAAC,MAAM,CAG1D,CAAC;AAEH;;;;;;;;;;GAUG;AACH,eAAO,MAAM,yBAAyB,EAAE,GAAwD,CAAC;AAEjG;;;;;;;GAOG;AACH,eAAO,MAAM,4BAA4B,iCAAiC,CAAC;AAE3E;;;;;;;GAOG;AACH,eAAO,MAAM,6BAA6B,kCAAkC,CAAC;AAE7E;;;;;;GAMG;AACH,eAAO,MAAM,kCAAkC,uCAAuC,CAAC;AAEvF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,6BAA6B,CAAC"}
1
+ {"version":3,"file":"spine_surface_constants.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/spine_surface_constants.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4B9B;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB;;;;CAIF,CAAC;AAE/B;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,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C;AAEvF;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AAEzE;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,8BAA8B,CAAC;AAErE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,6BAA6B,CAAC"}
@@ -35,7 +35,8 @@ export const TESTING_BACKDOOR_METHODS = [
35
35
  '_testing_migration_tracker',
36
36
  '_testing_action_manifest',
37
37
  '_testing_origin_check',
38
- '_testing_shorten_credential_expiry'
38
+ '_testing_shorten_credential_expiry',
39
+ '_testing_room_evict'
39
40
  ];
40
41
  /** RPC endpoint mount path — matches the binary's `/api/rpc`. */
41
42
  export const SPINE_RPC_PATH = '/api/rpc';
@@ -0,0 +1,47 @@
1
+ import '../assert_dev_env.js';
2
+ /**
3
+ * Test `RoomAuthorize` policy mounted on **both** reference spines — the TS
4
+ * spine binary's full mount (`full_spine_mount.ts`) and the Rust
5
+ * `testing_spine_stub` — so the `rooms_ws` cross suite drives the room verbs
6
+ * with one rule set on both. The twin of the Rust `TestRoomAuthorize`, rule
7
+ * for rule.
8
+ *
9
+ * The room id's prefix decides, so a case picks its rule by naming its room:
10
+ *
11
+ * - `open:<rest>` — join and watch, no scope, the registry's cap;
12
+ * - `scoped:<scope>:<rest>` — join and watch under the scope `<scope>`
13
+ * (non-empty);
14
+ * - `pair:<rest>` — join and watch, at most two members;
15
+ * - `watch:<rest>` — watch only; a join is denied;
16
+ * - `admin:<rest>` — join and watch for an actor holding the global `admin`
17
+ * role, denied to anyone else;
18
+ * - anything else — denied (`room_not_found`).
19
+ *
20
+ * A test policy, not a model. The `admin:` rule reads the grant live through
21
+ * the request's database, inside the reserve window, as every authorizer must
22
+ * (`RoomAuthorize`); no other rule reads the database. A cross-language test
23
+ * contract.
24
+ *
25
+ * @module
26
+ */
27
+ import type { RoomAccess, RoomAuthorize, RoomVerdict } from '../../actions/room_actions.js';
28
+ /**
29
+ * Whether `room_id`'s rule reads the actor's global `admin` grant.
30
+ *
31
+ * @param room_id - the room the request names
32
+ * @returns `true` for an `admin:` room
33
+ */
34
+ export declare const test_room_rule_reads_admin: (room_id: string) => boolean;
35
+ /**
36
+ * The verdict for `room_id`, as the module doc lists — pure, so the rule table
37
+ * is checked without a database. Twin of the Rust `TestRoomAuthorize::verdict`.
38
+ *
39
+ * @param room_id - the room the request names
40
+ * @param access - join or watch
41
+ * @param holds_admin - the live read, consulted only by the `admin:` rule
42
+ * @returns the verdict
43
+ */
44
+ export declare const test_room_verdict: (room_id: string, access: RoomAccess, holds_admin: boolean) => RoomVerdict;
45
+ /** The test policy (module doc), reading the `admin:` rule's grant live through the request's `db`. */
46
+ export declare const test_room_authorize: RoomAuthorize;
47
+ //# sourceMappingURL=test_room_authorize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test_room_authorize.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/test_room_authorize.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAI5F;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GAAI,SAAS,MAAM,KAAG,OAG5D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,iBAAiB,GAC7B,SAAS,MAAM,EACf,QAAQ,UAAU,EAClB,aAAa,OAAO,KAClB,WAwBF,CAAC;AAEF,uGAAuG;AACvG,eAAO,MAAM,mBAAmB,EAAE,aAOjC,CAAC"}
@@ -0,0 +1,58 @@
1
+ import '../assert_dev_env.js';
2
+ import { query_actor_has_active_global_role } from '../../auth/role_grant_queries.js';
3
+ import { ROLE_ADMIN } from '../../auth/role_schema.js';
4
+ /**
5
+ * Whether `room_id`'s rule reads the actor's global `admin` grant.
6
+ *
7
+ * @param room_id - the room the request names
8
+ * @returns `true` for an `admin:` room
9
+ */
10
+ export const test_room_rule_reads_admin = (room_id) => {
11
+ const colon = room_id.indexOf(':');
12
+ return colon !== -1 && room_id.slice(0, colon) === 'admin';
13
+ };
14
+ /**
15
+ * The verdict for `room_id`, as the module doc lists — pure, so the rule table
16
+ * is checked without a database. Twin of the Rust `TestRoomAuthorize::verdict`.
17
+ *
18
+ * @param room_id - the room the request names
19
+ * @param access - join or watch
20
+ * @param holds_admin - the live read, consulted only by the `admin:` rule
21
+ * @returns the verdict
22
+ */
23
+ export const test_room_verdict = (room_id, access, holds_admin) => {
24
+ const colon = room_id.indexOf(':');
25
+ if (colon === -1)
26
+ return { allow: false };
27
+ const kind = room_id.slice(0, colon);
28
+ const rest = room_id.slice(colon + 1);
29
+ switch (kind) {
30
+ case 'open':
31
+ return { allow: true, scope: null, max_members: null };
32
+ case 'scoped': {
33
+ const scope_end = rest.indexOf(':');
34
+ if (scope_end <= 0)
35
+ return { allow: false };
36
+ return { allow: true, scope: rest.slice(0, scope_end), max_members: null };
37
+ }
38
+ case 'pair':
39
+ return { allow: true, scope: null, max_members: 2 };
40
+ case 'watch':
41
+ return access === 'watch'
42
+ ? { allow: true, scope: null, max_members: null }
43
+ : { allow: false };
44
+ case 'admin':
45
+ return holds_admin ? { allow: true, scope: null, max_members: null } : { allow: false };
46
+ default:
47
+ return { allow: false };
48
+ }
49
+ };
50
+ /** The test policy (module doc), reading the `admin:` rule's grant live through the request's `db`. */
51
+ export const test_room_authorize = {
52
+ authorize: async (input, db) => {
53
+ const holds_admin = test_room_rule_reads_admin(input.room_id)
54
+ ? await query_actor_has_active_global_role({ db }, input.actor_id, ROLE_ADMIN)
55
+ : false;
56
+ return test_room_verdict(input.room_id, input.access, holds_admin);
57
+ }
58
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"testing_backdoor.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_backdoor.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA2F9B,OAAO,KAAK,EAAE,uCAAuC,EAAe,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+7,14 @@ import '../assert_dev_env.js';
7
7
  * `_testing_mint_session`, `_testing_put_fact`,
8
8
  * `_testing_flood_notifications`, `_testing_schema_snapshot`,
9
9
  * `_testing_migration_tracker`, `_testing_action_manifest`,
10
- * `_testing_origin_check`, `_testing_shorten_credential_expiry`) are
11
- * privileged test-binary actions the production
10
+ * `_testing_origin_check`, `_testing_shorten_credential_expiry`,
11
+ * `_testing_room_evict`) are privileged test-binary actions the production
12
12
  * wire never exposes — direct DB writes (full auth wipe, forged session row,
13
13
  * raw fact insert), the audit barrier, a flood of the caller's own connection,
14
14
  * introspection reads (the live schema, the `schema_version` migration
15
15
  * tracker, and the live RPC registry — the highest info-leak of the set were
16
- * the gate to break), a probe of the origin allowlist parser, and a rewrite of
17
- * an account's credential expiries. Their only structural fence
16
+ * the gate to break), a probe of the origin allowlist parser, a rewrite of
17
+ * an account's credential expiries, and an eviction from the room registry. Their only structural fence
18
18
  * is the **daemon-token** credential gate on
19
19
  * each spec's `auth` axis. A test binary live-mounts them on its RPC
20
20
  * endpoint (and, on fuz_app's spine binary and the Rust stub, its WS
@@ -121,6 +121,12 @@ const BACKDOOR_PARAMS = {
121
121
  _testing_shorten_credential_expiry: {
122
122
  account_id: '00000000-0000-4000-8000-000000000000',
123
123
  seconds: 30
124
+ },
125
+ // A room eviction — a valid `{target, reason}` pair naming a room no case
126
+ // holds, so it clears the 400 phase like the rest.
127
+ _testing_room_evict: {
128
+ target: { kind: 'room', room_id: 'open:backdoor-probe' },
129
+ reason: 'room_closed'
124
130
  }
125
131
  };
126
132
  const principals = [
@@ -1,5 +1,7 @@
1
1
  import '../assert_dev_env.js';
2
+ import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
2
3
  import { type RpcAction } from '../../actions/action_types.js';
4
+ import type { RoomRegistry } from '../../actions/room_registry.js';
3
5
  import type { AppDeps } from '../../auth/deps.js';
4
6
  import type { AuditEmitter } from '../../auth/audit_emitter.js';
5
7
  import type { SessionOptions } from '../../auth/session_cookie.js';
@@ -316,6 +318,81 @@ export declare const testing_flood_notifications_action_spec: {
316
318
  * overflow.
317
319
  */
318
320
  export declare const create_testing_flood_notifications_action: () => RpcAction;
321
+ /**
322
+ * What `_testing_room_evict` evicts — `RoomEvictTarget` on the wire, a
323
+ * `variant` on `kind` of strict objects.
324
+ */
325
+ export declare const TestingRoomEvictTarget: import("@fuzdev/fuz_schema/schema.ts").VariantSchema<"kind", readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
326
+ kind: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"actor">;
327
+ actor_id: import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">;
328
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
329
+ kind: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"actor_in_scope">;
330
+ actor_id: import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">;
331
+ scope: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
332
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
333
+ kind: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"room">;
334
+ room_id: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
335
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
336
+ kind: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"scope">;
337
+ scope: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
338
+ }>]>;
339
+ export type TestingRoomEvictTarget = Infer<typeof TestingRoomEvictTarget>;
340
+ /**
341
+ * `_testing_room_evict` — call the backend's room registry's `evict`, as a
342
+ * consumer does after its own authority change commits, so the cross suites
343
+ * pin eviction on both spines without a consumer's domain to drive it. The
344
+ * answer is the registry's `RoomEvicted` count: the seats and watches it
345
+ * removed and the joins and watches in flight it reached.
346
+ *
347
+ * Without side effects, like the room verbs: the registry is memory, so no
348
+ * transaction opens. `auth` gates on the daemon-token credential, matching
349
+ * `_testing_reset`. The Rust mirror is
350
+ * `fuz_testing::create_testing_room_evict_action_spec`.
351
+ */
352
+ export declare const testing_room_evict_action_spec: {
353
+ readonly method: "_testing_room_evict";
354
+ readonly kind: "request_response";
355
+ readonly initiator: "frontend";
356
+ readonly auth: {
357
+ readonly account: "required";
358
+ readonly actor: "none";
359
+ readonly credential_types: readonly ["daemon_token"];
360
+ };
361
+ readonly side_effects: false;
362
+ readonly input: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
363
+ target: import("@fuzdev/fuz_schema/schema.ts").VariantSchema<"kind", readonly [import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
364
+ kind: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"actor">;
365
+ actor_id: import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">;
366
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
367
+ kind: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"actor_in_scope">;
368
+ actor_id: import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">;
369
+ scope: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
370
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
371
+ kind: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"room">;
372
+ room_id: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
373
+ }>, import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
374
+ kind: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"scope">;
375
+ scope: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
376
+ }>]>;
377
+ reason: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["evicted", "room_closed"]>;
378
+ }>;
379
+ readonly output: import("@fuzdev/fuz_schema/schema.ts").ObjectSchema<{
380
+ seats: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").NumberSchema>;
381
+ watches: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").NumberSchema>;
382
+ pending: import("@fuzdev/fuz_schema/schema.ts").PipeSchema<number, import("@fuzdev/fuz_schema/schema.ts").NumberSchema>;
383
+ }>;
384
+ readonly async: true;
385
+ readonly description: string;
386
+ };
387
+ /**
388
+ * Build the `_testing_room_evict` action over the registry the backend's room
389
+ * verbs run on (see the spec doc). Not bundled by `create_testing_actions`: a
390
+ * backend without rooms has no registry to evict from, so the full-mount layer
391
+ * (`build_full_spine_rpc_actions`) appends it beside its room verbs.
392
+ *
393
+ * @param registry - the backend's room registry
394
+ */
395
+ export declare const create_testing_room_evict_action: (registry: RoomRegistry) => RpcAction;
319
396
  /**
320
397
  * `_testing_schema_snapshot` — introspect the live database into a normalized
321
398
  * `SchemaSnapshot` for cross-impl parity diffing. The cross-backend harness
@@ -520,6 +597,7 @@ export declare const testing_action_manifest_action_spec: {
520
597
  roles: import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
521
598
  credential_types: import("@fuzdev/fuz_schema/schema.ts").ArraySchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
522
599
  rate_limit: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["ip", "account", "both"]>>;
600
+ transport: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<"ws">>;
523
601
  }>>;
524
602
  }>;
525
603
  readonly async: true;
@@ -535,9 +613,15 @@ export declare const testing_action_manifest_action_spec: {
535
613
  * `build_full_spine_rpc_actions`), so its static spec is folded in here; the
536
614
  * Rust mirror folds in its own descriptor the same way.
537
615
  *
616
+ * `ws_only` are the domain actions the backend serves on its WebSocket
617
+ * endpoint alone (the room verbs), listed with `transport: 'ws'`
618
+ * (`action_manifest.ts`) — the Rust stub's `ws_only` specs, which its one
619
+ * registry carries on both transports and its RPC dispatcher refuses.
620
+ *
538
621
  * @param mounted - every other action on the backend's live RPC mount
622
+ * @param ws_only - the actions only its WebSocket endpoint serves
539
623
  */
540
- export declare const create_testing_action_manifest_action: (mounted: ReadonlyArray<RpcAction>) => RpcAction;
624
+ export declare const create_testing_action_manifest_action: (mounted: ReadonlyArray<RpcAction>, ws_only?: ReadonlyArray<RpcAction>) => RpcAction;
541
625
  /** Options for `create_testing_actions`. */
542
626
  export interface CreateTestingActionsOptions {
543
627
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"testing_reset_actions.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_reset_actions.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAmG9B,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAO3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAsBzC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;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CAAC,SAAS,CAAC,EACjC,UAAS,aAAa,CAAC,SAAS,CAAM,KACpC,SASF,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,2BAA2B;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACjD;;;;;;OAMG;IACH,QAAQ,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;IAC9C;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACxD;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,OAAO,EACb,SAAS,2BAA2B,KAClC,KAAK,CAAC,SAAS,CAwJjB,CAAC"}
@@ -79,13 +79,14 @@ import '../assert_dev_env.js';
79
79
  * @module
80
80
  */
81
81
  import { meta } from '@fuzdev/fuz_schema/meta.ts';
82
- import { array, boolean, max_value, min_value, number, object, optional, pipe, safe_integer, string, void as fuz_void } from '@fuzdev/fuz_schema/schema.ts';
82
+ import { array, boolean, literal, max_value, min_value, number, object, optional, pipe, safe_integer, string, variant, void as fuz_void } from '@fuzdev/fuz_schema/schema.ts';
83
83
  import { Uuid, FactHashSchema } from '../../primitive_schemas.js';
84
84
  import { fact_hash_bytes } from '@fuzdev/fuz_util/fact_hash.ts';
85
85
  import { rpc_action } from '../../actions/action_types.js';
86
86
  import { jsonrpc_errors } from '../../http/jsonrpc_errors.js';
87
87
  import { emit_after_commit } from '../../http/pending_effects.js';
88
88
  import { protocol_action_specs } from '../../actions/protocol.js';
89
+ import { RoomEvictReason, RoomId } from '../../actions/room_action_specs.js';
89
90
  import { query_put_fact } from '../../db/fact_queries.js';
90
91
  import { query_put_fact_holder } from '../../db/fact_holder_queries.js';
91
92
  import { ROLE_ADMIN, ROLE_KEEPER } from '../../auth/role_schema.js';
@@ -402,6 +403,53 @@ rpc_action(testing_flood_notifications_action_spec, ({ count, size }, ctx) => {
402
403
  }
403
404
  return { queued: count };
404
405
  });
406
+ /**
407
+ * What `_testing_room_evict` evicts — `RoomEvictTarget` on the wire, a
408
+ * `variant` on `kind` of strict objects.
409
+ */
410
+ export const TestingRoomEvictTarget = variant('kind', [
411
+ object({ kind: literal('actor'), actor_id: Uuid }),
412
+ object({ kind: literal('actor_in_scope'), actor_id: Uuid, scope: string }),
413
+ object({ kind: literal('room'), room_id: RoomId }),
414
+ object({ kind: literal('scope'), scope: string })
415
+ ]);
416
+ /**
417
+ * `_testing_room_evict` — call the backend's room registry's `evict`, as a
418
+ * consumer does after its own authority change commits, so the cross suites
419
+ * pin eviction on both spines without a consumer's domain to drive it. The
420
+ * answer is the registry's `RoomEvicted` count: the seats and watches it
421
+ * removed and the joins and watches in flight it reached.
422
+ *
423
+ * Without side effects, like the room verbs: the registry is memory, so no
424
+ * transaction opens. `auth` gates on the daemon-token credential, matching
425
+ * `_testing_reset`. The Rust mirror is
426
+ * `fuz_testing::create_testing_room_evict_action_spec`.
427
+ */
428
+ export const testing_room_evict_action_spec = {
429
+ method: '_testing_room_evict',
430
+ kind: 'request_response',
431
+ initiator: 'frontend',
432
+ auth: TESTING_ACTION_AUTH,
433
+ side_effects: false,
434
+ input: object({ target: TestingRoomEvictTarget, reason: RoomEvictReason }),
435
+ output: object({
436
+ seats: pipe(number, safe_integer, min_value(0)),
437
+ watches: pipe(number, safe_integer, min_value(0)),
438
+ pending: pipe(number, safe_integer, min_value(0))
439
+ }),
440
+ async: true,
441
+ description: "Test-binary only — evict seats, watches, and joins in flight from the backend's room " +
442
+ 'registry, as a consumer does after an authority change commits.'
443
+ };
444
+ /**
445
+ * Build the `_testing_room_evict` action over the registry the backend's room
446
+ * verbs run on (see the spec doc). Not bundled by `create_testing_actions`: a
447
+ * backend without rooms has no registry to evict from, so the full-mount layer
448
+ * (`build_full_spine_rpc_actions`) appends it beside its room verbs.
449
+ *
450
+ * @param registry - the backend's room registry
451
+ */
452
+ export const create_testing_room_evict_action = (registry) => rpc_action(testing_room_evict_action_spec, ({ target, reason }) => registry.evict(target, reason));
405
453
  /**
406
454
  * `_testing_schema_snapshot` — introspect the live database into a normalized
407
455
  * `SchemaSnapshot` for cross-impl parity diffing. The cross-backend harness
@@ -591,13 +639,19 @@ const PROTOCOL_METHODS = new Set(protocol_action_specs.map((spec) => spec.method
591
639
  * `build_full_spine_rpc_actions`), so its static spec is folded in here; the
592
640
  * Rust mirror folds in its own descriptor the same way.
593
641
  *
642
+ * `ws_only` are the domain actions the backend serves on its WebSocket
643
+ * endpoint alone (the room verbs), listed with `transport: 'ws'`
644
+ * (`action_manifest.ts`) — the Rust stub's `ws_only` specs, which its one
645
+ * registry carries on both transports and its RPC dispatcher refuses.
646
+ *
594
647
  * @param mounted - every other action on the backend's live RPC mount
648
+ * @param ws_only - the actions only its WebSocket endpoint serves
595
649
  */
596
- export const create_testing_action_manifest_action = (mounted) => {
650
+ export const create_testing_action_manifest_action = (mounted, ws_only = []) => {
597
651
  const manifest = build_action_manifest([
598
652
  ...mounted.map((action) => action.spec).filter((spec) => !PROTOCOL_METHODS.has(spec.method)),
599
653
  testing_action_manifest_action_spec
600
- ]);
654
+ ], ws_only.map((action) => action.spec));
601
655
  return rpc_action(testing_action_manifest_action_spec, async () => manifest);
602
656
  };
603
657
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"testing_server_bun.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_server_bun.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA0BlF,4CAA4C;AAC5C,eAAO,MAAM,0BAA0B,QAAO,oBAoE7C,CAAC"}
1
+ {"version":3,"file":"testing_server_bun.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_server_bun.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA0BlF,4CAA4C;AAC5C,eAAO,MAAM,0BAA0B,QAAO,oBAmE7C,CAAC"}
@@ -9,7 +9,7 @@ import '../assert_dev_env.js';
9
9
  * and the Rust spine binary covers the cross-language axis.
10
10
  *
11
11
  * Needs the optional `@hono/bun` peer dep (the Bun counterpart to Node's
12
- * `@hono/node-server` + `@hono/node-ws`); `Bun.serve` is built in.
12
+ * `@hono/node-server` + `ws`); `Bun.serve` is built in.
13
13
  * `RuntimeDeps` reuse `create_node_runtime` — Bun
14
14
  * implements the `node:fs` / `node:process` surface `RuntimeDeps` +
15
15
  * `testing/daemon_info.ts` touch.
@@ -41,12 +41,12 @@ export const create_bun_testing_adapter = () => {
41
41
  runtime_label: 'Bun',
42
42
  runtime: create_node_runtime(),
43
43
  get_connection_ip: (c) => getConnInfo(c).remote.address,
44
- // Bun's WS upgrade is module-level and stateless — no post-serve
45
- // attach. The `websocket` handler is threaded into `serve`
46
- // below, where `Bun.serve` wants it, carrying the frame cap.
44
+ // Bun's WS upgrade is module-level and stateless. The `websocket`
45
+ // handler is threaded into `serve` below, where `Bun.serve` wants it,
46
+ // carrying the frame cap.
47
47
  prepare_websocket: (options) => {
48
48
  max_message_bytes = options?.max_message_bytes ?? DEFAULT_WS_MAX_MESSAGE_BYTES;
49
- return { create_upgrade_websocket: () => upgradeWebSocket };
49
+ return upgradeWebSocket;
50
50
  },
51
51
  serve: ({ fetch, port, hostname }) => {
52
52
  const server = Bun.serve({
@@ -90,8 +90,7 @@ export const create_bun_testing_adapter = () => {
90
90
  shutdown: () => {
91
91
  void Promise.resolve(server.stop(true)).catch(() => { });
92
92
  return Promise.resolve();
93
- },
94
- native: server
93
+ }
95
94
  };
96
95
  return handle;
97
96
  },
@@ -6,26 +6,24 @@ import '../assert_dev_env.js';
6
6
  * A test binary mounts a fuz_app-derived surface over a real HTTP socket so
7
7
  * the `cross_backend/*` suites (and the cross-impl bench) can drive it the
8
8
  * same way they drive the Rust spine. This module owns the runtime-neutral
9
- * orchestration — stale-daemon check, daemon-info write, serve, post-serve
10
- * WS attach, graceful shutdown — and delegates the runtime-boundary
11
- * primitives (HTTP serve, WS upgrade construction, signals, pid, exit) to a
12
- * `TestingServerAdapter`. The shipped adapters are
13
- * `testing/cross_backend/testing_server_node.ts` (`@hono/node-server` + `@hono/node-ws`)
9
+ * orchestration — stale-daemon check, daemon-info write, serve, graceful
10
+ * shutdown — and delegates the runtime-boundary primitives (HTTP serve, WS
11
+ * upgrade, signals, pid, exit) to a `TestingServerAdapter`. The shipped
12
+ * adapters are `testing/cross_backend/testing_server_node.ts` (`@hono/node-server` + `ws`)
14
13
  * and `testing/cross_backend/testing_server_bun.ts` (`Bun.serve` + `@hono/bun`).
15
14
  *
16
15
  * The app itself — routes, RPC, DB, `_testing_reset`, WS endpoints — is the
17
16
  * caller's `StartTestingServerOptions.build_app` seam, so this core
18
17
  * stays domain-free. WebSocket endpoints mount through `create_app_server`'s
19
18
  * `ws_endpoints`: `build_app` asks its context to prepare the runtime's
20
- * upgrade helper and passes the resulting factory as
21
- * `create_upgrade_websocket`; the core attaches it to the server once
22
- * `serve` returns (Node's `injectWebSocket`). fuz_app's own `testing_spine_server` passes a
19
+ * upgrade helper and passes it as `upgrade_websocket`; the adapter threads
20
+ * the prepared frame cap into `serve`. fuz_app's own `testing_spine_server` passes a
23
21
  * no-domain build; consumers (fuz_forge) pass their domain build.
24
22
  *
25
23
  * **NEVER ships in a release.** This module lives under `cross_backend/` and
26
24
  * opens with `import '../assert_dev_env.js';`, which throws on
27
25
  * production-bundle load. The runtime adapters reach for the optional
28
- * `@hono/node-server` / `@hono/node-ws` / `@hono/bun` peer deps; only test
26
+ * `@hono/node-server` / `ws` / `@hono/bun` peer deps; only test
29
27
  * binaries import them.
30
28
  *
31
29
  * @module
@@ -39,14 +37,10 @@ import type { RuntimeDeps } from '../../runtime/deps.js';
39
37
  *
40
38
  * `shutdown` stops accepting new connections at once and settles when the
41
39
  * in-flight ones have drained — the core starts it, closes the app (which
42
- * ends live WebSockets), then awaits it. `native` is an adapter-specific
43
- * server reference — used by Node's `@hono/node-ws` `injectWebSocket(server)`
44
- * post-serve hook.
40
+ * ends live WebSockets), then awaits it.
45
41
  */
46
42
  export interface ServeHandle {
47
43
  shutdown: () => Promise<void>;
48
- /** Adapter-specific server ref for post-serve hooks. Type-erased at the seam. */
49
- native?: unknown;
50
44
  }
51
45
  /** Options for `TestingServerAdapter.prepare_websocket`. */
52
46
  export interface PrepareWebsocketOptions {
@@ -67,19 +61,6 @@ export interface PrepareWebsocketOptions {
67
61
  */
68
62
  max_message_bytes?: number;
69
63
  }
70
- /**
71
- * Result of an adapter's WS preparation step.
72
- *
73
- * `create_upgrade_websocket` is the factory a build passes to
74
- * `create_app_server` as `AppServerOptions.create_upgrade_websocket`.
75
- * `attach_to_server` runs after `serve()` returns a `ServeHandle` —
76
- * Node uses it for `injectWebSocket(server)`, and it does nothing when the
77
- * factory was never called (no `ws_endpoints`); Bun leaves it undefined.
78
- */
79
- export interface PreparedWebsocket {
80
- create_upgrade_websocket: (app: Hono) => UpgradeWebSocket;
81
- attach_to_server?: (handle: ServeHandle) => void;
82
- }
83
64
  /**
84
65
  * Runtime adapter contract for the test-binary entry. Each adapter
85
66
  * (`testing/cross_backend/testing_server_node.ts`,
@@ -93,8 +74,12 @@ export interface TestingServerAdapter {
93
74
  runtime: RuntimeDeps;
94
75
  /** Extract the raw TCP connection IP from a Hono context. */
95
76
  get_connection_ip: (c: Context) => string | undefined;
96
- /** Prepare the runtime's WS upgrade helper and its post-serve attach step. */
97
- prepare_websocket: (options?: PrepareWebsocketOptions) => PreparedWebsocket;
77
+ /**
78
+ * Prepare WebSocket support for the next `serve` — the frame cap, and on
79
+ * Node the `ws` server — and return the runtime's `upgradeWebSocket`
80
+ * helper. Called before `serve`, at most once.
81
+ */
82
+ prepare_websocket: (options?: PrepareWebsocketOptions) => UpgradeWebSocket;
98
83
  /** Bind `app.fetch` to `port` on `hostname`; return a `ServeHandle`. */
99
84
  serve: (options: {
100
85
  fetch: Hono['fetch'];
@@ -111,15 +96,16 @@ export interface TestingServerAdapter {
111
96
  /** What the core hands a `StartTestingServerOptions.build_app` seam. */
112
97
  export interface BuildTestingAppContext {
113
98
  /**
114
- * Prepare the runtime adapter's WS upgrade helper and return the factory
115
- * to pass to `create_app_server` as `create_upgrade_websocket`. The core
116
- * runs the adapter's attach step once the server is bound, so a build
117
- * that mounts `ws_endpoints` needs nothing else. An HTTP-only build
118
- * doesn't call it. Call it at most once per build: the Node adapter
119
- * attaches one upgrade listener per preparation, and two would race on
120
- * the shared socket.
99
+ * Prepare the runtime adapter's WebSocket support and return its
100
+ * `upgradeWebSocket` helper, to pass to `create_app_server` as
101
+ * `upgrade_websocket`; the adapter threads what it prepared into `serve`,
102
+ * so a build that mounts `ws_endpoints` needs nothing else. Call it only
103
+ * when mounting: on Node a prepared server routes every `Upgrade:
104
+ * websocket` request through the upgrade path, refusing one to a plain
105
+ * HTTP route with a bodiless status. Call it at most once per build: the server takes
106
+ * one frame cap, the last preparation's.
121
107
  */
122
- prepare_websocket: (options?: PrepareWebsocketOptions) => (app: Hono) => UpgradeWebSocket;
108
+ prepare_websocket: (options?: PrepareWebsocketOptions) => UpgradeWebSocket;
123
109
  }
124
110
  /** The assembled app a `StartTestingServerOptions.build_app` seam returns. */
125
111
  export interface BuiltTestingApp {