@fuzdev/fuz_app 0.128.0 → 0.129.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 (87) hide show
  1. package/dist/actions/register_action_ws.d.ts +0 -1
  2. package/dist/actions/register_action_ws.d.ts.map +1 -1
  3. package/dist/auth/CLAUDE.md +1 -1
  4. package/dist/auth/actor_lookup_action_specs.d.ts +2 -2
  5. package/dist/auth/actor_lookup_action_specs.js +2 -2
  6. package/dist/auth/audit_emitter.d.ts +14 -7
  7. package/dist/auth/audit_emitter.d.ts.map +1 -1
  8. package/dist/auth/audit_emitter.js +6 -8
  9. package/dist/auth/bearer_auth.d.ts +3 -2
  10. package/dist/auth/bearer_auth.d.ts.map +1 -1
  11. package/dist/auth/bearer_auth.js +3 -2
  12. package/dist/auth/request_context.d.ts +1 -1
  13. package/dist/auth/request_context.js +1 -1
  14. package/dist/auth/token_scope.d.ts +4 -2
  15. package/dist/auth/token_scope.d.ts.map +1 -1
  16. package/dist/auth/token_scope.js +10 -2
  17. package/dist/http/CLAUDE.md +3 -4
  18. package/dist/http/auth_shape.d.ts +3 -2
  19. package/dist/http/auth_shape.d.ts.map +1 -1
  20. package/dist/http/auth_shape.js +3 -2
  21. package/dist/http/common_routes.d.ts +1 -14
  22. package/dist/http/common_routes.d.ts.map +1 -1
  23. package/dist/http/common_routes.js +1 -19
  24. package/dist/http/ip_canonical.d.ts +1 -1
  25. package/dist/http/ip_canonical.js +1 -1
  26. package/dist/realtime/sse_auth_guard.d.ts +3 -1
  27. package/dist/realtime/sse_auth_guard.d.ts.map +1 -1
  28. package/dist/realtime/sse_auth_guard.js +3 -1
  29. package/dist/server/app_server.d.ts +118 -7
  30. package/dist/server/app_server.d.ts.map +1 -1
  31. package/dist/server/app_server.js +136 -91
  32. package/dist/server/surface_route.d.ts +32 -0
  33. package/dist/server/surface_route.d.ts.map +1 -0
  34. package/dist/server/surface_route.js +46 -0
  35. package/dist/testing/CLAUDE.md +17 -12
  36. package/dist/testing/app_server.d.ts +39 -4
  37. package/dist/testing/app_server.d.ts.map +1 -1
  38. package/dist/testing/app_server.js +84 -68
  39. package/dist/testing/audit_completeness.js +1 -1
  40. package/dist/testing/audit_drift_guard.d.ts +1 -1
  41. package/dist/testing/cross_backend/default_spine_surface.d.ts +2 -2
  42. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  43. package/dist/testing/cross_backend/default_spine_surface.js +5 -2
  44. package/dist/testing/cross_backend/identity_parity.js +1 -1
  45. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  46. package/dist/testing/cross_backend/in_process_setup.js +4 -1
  47. package/dist/testing/cross_backend/method_coverage.d.ts +1 -1
  48. package/dist/testing/cross_backend/method_coverage.d.ts.map +1 -1
  49. package/dist/testing/cross_backend/method_coverage.js +2 -2
  50. package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
  51. package/dist/testing/cross_backend/peer_ping_ws.d.ts.map +1 -1
  52. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +1 -1
  53. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  54. package/dist/testing/cross_backend/setup.d.ts +4 -4
  55. package/dist/testing/cross_backend/setup.js +1 -1
  56. package/dist/testing/cross_backend/sse_round_trip.d.ts +1 -1
  57. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  58. package/dist/testing/cross_backend/testing_reset_actions.d.ts +24 -14
  59. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  60. package/dist/testing/cross_backend/testing_reset_actions.js +40 -32
  61. package/dist/testing/cross_backend/testing_server_bun.d.ts +1 -1
  62. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  63. package/dist/testing/cross_backend/testing_server_bun.js +80 -64
  64. package/dist/testing/cross_backend/testing_server_core.d.ts +10 -4
  65. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  66. package/dist/testing/cross_backend/testing_server_deno.d.ts +1 -1
  67. package/dist/testing/cross_backend/testing_server_deno.d.ts.map +1 -1
  68. package/dist/testing/cross_backend/testing_server_deno.js +1 -1
  69. package/dist/testing/cross_backend/testing_server_node.d.ts +1 -1
  70. package/dist/testing/cross_backend/testing_server_node.d.ts.map +1 -1
  71. package/dist/testing/cross_backend/testing_server_node.js +2 -2
  72. package/dist/testing/cross_backend/ws_round_trip.d.ts +1 -1
  73. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  74. package/dist/testing/cross_backend/ws_round_trip.js +11 -9
  75. package/dist/testing/stubs.d.ts +45 -7
  76. package/dist/testing/stubs.d.ts.map +1 -1
  77. package/dist/testing/stubs.js +60 -31
  78. package/dist/testing/ws_round_trip.d.ts +1 -3
  79. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  80. package/dist/ui/AdminSurface.svelte +3 -1
  81. package/dist/ui/AdminSurface.svelte.d.ts.map +1 -1
  82. package/dist/ui/CLAUDE.md +3 -1
  83. package/dist/ui/async_slot.svelte.d.ts +4 -4
  84. package/dist/ui/async_slot.svelte.js +4 -4
  85. package/dist/ui/keyed_async_slot.svelte.d.ts +4 -4
  86. package/dist/ui/keyed_async_slot.svelte.js +3 -3
  87. package/package.json +1 -1
@@ -2,7 +2,7 @@ import '../assert_dev_env.js';
2
2
  /**
3
3
  * Test-binary RPC actions for cross-process integration tests.
4
4
  *
5
- * Six daemon-token-authed actions, bundled by `create_testing_actions`:
5
+ * The daemon-token-authed actions bundled by `create_testing_actions`:
6
6
  * **`_testing_reset`** (DB wipe + keeper re-seed), **`_testing_drain_effects`**
7
7
  * (audit barrier), **`_testing_mint_session`** (forge an
8
8
  * expired-by-construction server-side session for the expiry conformance
@@ -31,11 +31,11 @@ import '../assert_dev_env.js';
31
31
  * new keeper + secondary credentials return as the action output so
32
32
  * the per-test fixture closes over them.
33
33
  *
34
- * The redesign converges in-process and cross-process keeper
35
- * lifetimes: both modes now run against a freshly bootstrapped keeper
36
- * per test. Mutation-cascade tests (password change, revoke-all,
37
- * hardcoded-username signup uniqueness) and direct keeper-vs-admin
38
- * probes work uniformly cross-process.
34
+ * In-process and cross-process keeper lifetimes match: both modes run
35
+ * against a freshly bootstrapped keeper per test, so mutation-cascade
36
+ * tests (password change, revoke-all, hardcoded-username signup
37
+ * uniqueness) and direct keeper-vs-admin probes work uniformly
38
+ * cross-process.
39
39
  *
40
40
  * **Keeper ≠ admin.** The `keeper` and `admin` roles are independent.
41
41
  * Keeper authorizes daemon-token / bootstrap paths; admin authorizes
@@ -47,9 +47,8 @@ import '../assert_dev_env.js';
47
47
  * via `extra_accounts: [{username, roles: [ROLE_KEEPER]}]` so the
48
48
  * account is seeded at this same bootstrap-equivalent step.
49
49
  *
50
- * **No free-form runtime bypass.** Earlier drafts considered a separate
51
- * `_testing_seed_role_grant` action for arbitrary direct grants; that
52
- * was rejected because a runtime bypass would let tests skip the
50
+ * **No free-form runtime bypass.** There is no action for arbitrary
51
+ * direct role grants: a runtime bypass would let tests skip the
53
52
  * production consent flow's side-effects (audit emit, WS fan-out) and
54
53
  * silently mask bugs in those paths. The bypass that does exist —
55
54
  * `extra_accounts` — is framed as bootstrap-time seeding, the same
@@ -73,10 +72,10 @@ import { Uuid } from '@fuzdev/fuz_util/id.ts';
73
72
  import { fact_hash_bytes } from '@fuzdev/fuz_util/fact_hash.ts';
74
73
  import { FactHashSchema } from '@fuzdev/fuz_util/hash_schemas.ts';
75
74
  import { rpc_action } from '../../actions/action_rpc.js';
75
+ import { emit_after_commit } from '../../http/pending_effects.js';
76
76
  import { protocol_action_specs } from '../../actions/protocol.js';
77
77
  import { query_put_fact } from '../../db/fact_queries.js';
78
78
  import { ROLE_ADMIN, ROLE_KEEPER } from '../../auth/role_schema.js';
79
- import { auth_integration_truncate_tables } from '../db.js';
80
79
  import { query_schema_snapshot, SchemaSnapshot, query_migration_tracker, MigrationTracker } from '../schema_introspect.js';
81
80
  import { ActionManifest, build_action_manifest } from './action_manifest.js';
82
81
  import { query_create_actor } from '../../auth/account_queries.js';
@@ -86,8 +85,8 @@ import { DEFAULT_TEST_PASSWORD } from '../test_credentials.js';
86
85
  * Shared `auth` axis for every `_testing_*` action: keeper-only via the
87
86
  * daemon-token credential, no acting actor. This is the entire structural
88
87
  * fence on the backdoor surface (these actions run direct DB writes the
89
- * production wire never exposes), so all five specs reference this one const
90
- * rather than re-declaring it — a single source of truth the gate test
88
+ * production wire never exposes), so every `_testing_*` spec references this
89
+ * one const rather than re-declaring it — a single source of truth the gate test
91
90
  * (`testing_actions_auth.test.ts`) pins. Mirrors the Rust `DAEMON_TOKEN_ONLY`
92
91
  * / shared `AuthSpec` in `fuz_testing`.
93
92
  */
@@ -385,26 +384,31 @@ export const testing_action_manifest_action_spec = {
385
384
  '{method, auth, side_effects, rate_limit} manifest for cross-impl method-set + ' +
386
385
  'auth-shape parity diffing.'
387
386
  };
387
+ /**
388
+ * The protocol methods (`heartbeat` / `cancel` / `peer/ping`) the
389
+ * `_testing_action_manifest` dump leaves out, so the cross-impl diff stays
390
+ * apples-to-apples: the two impls organize them differently (`peer/ping` is
391
+ * on the TS spine's WS **and** HTTP-RPC endpoints; heartbeat/cancel WS-only;
392
+ * the Rust stub compiles one shared registry serving both transports), so
393
+ * including them would be a spurious divergence (see `action_manifest.ts`
394
+ * §Scope). The exclusion set is the live `protocol_action_specs` bundle —
395
+ * kept in lockstep with the static `PROTOCOL_ACTION_METHODS` by a drift-guard
396
+ * test — so this stays off the heavyweight `action_codegen` module the spawned
397
+ * binary would otherwise pull in.
398
+ */
399
+ const PROTOCOL_METHODS = new Set(protocol_action_specs.map((spec) => spec.method));
388
400
  /**
389
401
  * Build the `_testing_action_manifest` action over a backend's full live RPC
390
402
  * mount. The handler closes over a manifest computed once at assembly time
391
- * from every `mounted` spec **plus this action's own spec** — the manifest
392
- * action is itself a live method, so it must appear in the dump it serves.
393
- * `mounted` excludes it (it's appended to the mount *after* the rest is
394
- * assembled, in `build_full_spine_rpc_actions`), so its static spec is folded
395
- * in here; the Rust mirror folds in its own descriptor the same way.
403
+ * from every `mounted` spec except the protocol methods (`PROTOCOL_METHODS`)
404
+ * **plus this action's own spec** — the manifest action is itself a live
405
+ * method, so it must appear in the dump it serves. `mounted` excludes it
406
+ * (it's appended to the mount *after* the rest is assembled, in
407
+ * `build_full_spine_rpc_actions`), so its static spec is folded in here; the
408
+ * Rust mirror folds in its own descriptor the same way.
396
409
  *
397
- * Protocol actions (`heartbeat` / `cancel` / `peer/ping`) are filtered out of
398
- * the manifest here so the cross-impl diff stays apples-to-apples: the two
399
- * impls organize them differently (`peer/ping` is on the TS spine's WS **and**
400
- * HTTP-RPC endpoints; heartbeat/cancel WS-only; the Rust stub compiles one
401
- * shared registry serving both transports), so including them would be a
402
- * spurious divergence (see `action_manifest.ts` §Scope). The exclusion set is
403
- * the live `protocol_action_specs` bundle — kept in lockstep with the static
404
- * `PROTOCOL_ACTION_METHODS` by a drift-guard test — so this stays off the
405
- * heavyweight `action_codegen` module the spawned binary would otherwise pull in.
410
+ * @param mounted - every other action on the backend's live RPC mount
406
411
  */
407
- const PROTOCOL_METHODS = new Set(protocol_action_specs.map((spec) => spec.method));
408
412
  export const create_testing_action_manifest_action = (mounted) => {
409
413
  const manifest = build_action_manifest([
410
414
  ...mounted.map((action) => action.spec).filter((spec) => !PROTOCOL_METHODS.has(spec.method)),
@@ -510,9 +514,15 @@ export const create_testing_actions = (deps, options) => {
510
514
  // 6. Refresh the daemon-token cache so subsequent daemon-token
511
515
  // requests resolve to the freshly seeded keeper. The
512
516
  // middleware's lazy-refresh path only fires when the cached
513
- // id is null; setting it directly here avoids one round-trip
514
- // of stale-id-then-refresh on the next call.
515
- daemon_token_state.keeper_account_id = keeper.account.id;
517
+ // id is null, so the reset sets it — after the commit, so a
518
+ // reset that rolls back (a throwing `reset_state`, a failed
519
+ // COMMIT) leaves the cache on the keeper still in the database
520
+ // rather than one that never landed, and the next reset can
521
+ // still authenticate.
522
+ const keeper_account_id = keeper.account.id;
523
+ emit_after_commit(ctx, () => {
524
+ daemon_token_state.keeper_account_id = keeper_account_id;
525
+ });
516
526
  // 7. Fire domain-state reset (zzz workspaces/terminals/scratch,
517
527
  // fuz_forge cell/fact/file truncation, or no-op for spine_stub).
518
528
  // Pass the transactional `ctx.db` so DB-domain truncation runs
@@ -549,5 +559,3 @@ export const create_testing_actions = (deps, options) => {
549
559
  create_testing_migration_tracker_action()
550
560
  ];
551
561
  };
552
- /** Set of auth-namespace tables `_testing_reset` wipes. Mirrored by the coverage test. */
553
- export const testing_reset_wiped_tables = auth_integration_truncate_tables;
@@ -1,5 +1,5 @@
1
1
  import '../assert_dev_env.js';
2
2
  import type { TestingServerAdapter } from './testing_server_core.js';
3
- /** Build the Bun {@link TestingServerAdapter}. */
3
+ /** Build the Bun `TestingServerAdapter`. */
4
4
  export declare const create_bun_testing_adapter: () => TestingServerAdapter;
5
5
  //# sourceMappingURL=testing_server_bun.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing_server_bun.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_server_bun.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA6B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAelF,kDAAkD;AAClD,eAAO,MAAM,0BAA0B,QAAO,oBA8D5C,CAAC"}
1
+ {"version":3,"file":"testing_server_bun.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_server_bun.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA8B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAyBlF,4CAA4C;AAC5C,eAAO,MAAM,0BAA0B,QAAO,oBAoE7C,CAAC"}
@@ -23,68 +23,84 @@ import '../assert_dev_env.js';
23
23
  */
24
24
  import process from 'node:process';
25
25
  import { getConnInfo, upgradeWebSocket, websocket } from '@hono/bun';
26
+ import { DEFAULT_WS_MAX_MESSAGE_BYTES } from '../../actions/transports.js';
26
27
  import { create_node_runtime } from '../../runtime/node.js';
27
- /** Build the Bun {@link TestingServerAdapter}. */
28
- export const create_bun_testing_adapter = () => ({
29
- runtime_label: 'Bun',
30
- runtime: create_node_runtime(),
31
- get_connection_ip: (c) => getConnInfo(c).remote.address,
32
- // Bun's WS upgrade is module-level and stateless (like Deno) — no
33
- // post-serve attach. The `websocket` handler is threaded into `serve`
34
- // below, where `Bun.serve` wants it.
35
- // TODO: `Bun.serve({websocket: {maxPayloadLength}})` (default 16 MiB) could
36
- // carry the endpoint's `max_message_bytes` as a frame cap, like Node's
37
- // `maxPayload`; until then the per-message check in `register_ws_endpoint`
38
- // closes an oversized message with `WS_CLOSE_MESSAGE_TOO_BIG` (1009).
39
- prepare_websocket: () => ({ create_upgrade_websocket: () => upgradeWebSocket }),
40
- serve: ({ fetch, port, hostname }) => {
41
- const server = Bun.serve({
42
- fetch: fetch,
43
- port,
44
- hostname,
45
- // Harmless for HTTP-only binaries — Bun only invokes it for sockets
46
- // upgraded via `upgradeWebSocket`.
47
- websocket
48
- });
49
- const handle = {
50
- // Bun bug (1.3.14): after a *server-initiated* WebSocket close
51
- // (`ServerWebSocket.close()` / `@hono/bun`'s `WSContext.close()`),
52
- // `server.stop()` never resolves — Bun doesn't decrement its
53
- // active-connection count for a server-closed socket, so the stop
54
- // waits forever for a connection it already closed. The trigger is
55
- // orthogonal to HTTP load, hono-vs-raw `Bun.serve`, in-vs-cross
56
- // process, the force flag (`stop()`/`stop(false)`/`stop(true)` all
57
- // hang), and the client runtime — a single server-closed WS is
58
- // necessary and sufficient. Client-initiated close or leaving the
59
- // socket open both stop cleanly in ~0ms. In this suite the trigger is
60
- // any server-initiated WS close — a revocation's (the `ws.cross.test.ts`
61
- // close-on-revoke cases), a cap eviction's, an oversized message's —
62
- // which is why teardown hangs after those and not under HTTP-only or
63
- // client-closed WS traffic.
64
- //
65
- // So initiate a force-close (`true` drops active connections, no
66
- // drain) but DON'T await it: awaiting hangs `start_testing_server`'s
67
- // shutdown forever — `built.close()` and `exit(0)` never run, and the
68
- // spawning harness blocks on a child that never exits (observed as a
69
- // multi-minute hang needing SIGKILL). The force-close still tears the
70
- // live sockets down; the `exit(0)` the core fires immediately after
71
- // does the real teardown a few ms later. Node/Deno don't need this —
72
- // their `shutdown()`/`close()` resolve normally. The `.catch` guards a
73
- // future Bun that rejects rather than hangs; if a future Bun resolves
74
- // the promise after a server-initiated close, revert to
75
- // `await server.stop(true)` to mirror the Node/Deno adapters.
76
- shutdown: () => {
77
- void Promise.resolve(server.stop(true)).catch(() => { });
78
- return Promise.resolve();
79
- },
80
- native: server
81
- };
82
- return handle;
83
- },
84
- pid: process.pid,
85
- register_shutdown_signals: (handler) => {
86
- process.on('SIGINT', () => void handler());
87
- process.on('SIGTERM', () => void handler());
88
- },
89
- exit: (code) => process.exit(code)
90
- });
28
+ /**
29
+ * How far above the endpoint's message limit Bun's own frame cap sits. Bun
30
+ * drops a socket past `maxPayloadLength` without a close frame (the client sees
31
+ * 1006), unlike Node's `ws`, which closes with `WS_CLOSE_MESSAGE_TOO_BIG` — so
32
+ * the cap leaves headroom for the per-message check in `register_ws_endpoint`
33
+ * to answer a message just over the limit with that code, and still refuses a
34
+ * grossly oversized one before buffering it toward Bun's 16 MiB default.
35
+ */
36
+ const BUN_WS_MAX_PAYLOAD_MULTIPLIER = 2;
37
+ /** Build the Bun `TestingServerAdapter`. */
38
+ export const create_bun_testing_adapter = () => {
39
+ // set by `prepare_websocket`, read by `serve` — the core prepares before it serves
40
+ let max_message_bytes = DEFAULT_WS_MAX_MESSAGE_BYTES;
41
+ return {
42
+ runtime_label: 'Bun',
43
+ runtime: create_node_runtime(),
44
+ get_connection_ip: (c) => getConnInfo(c).remote.address,
45
+ // Bun's WS upgrade is module-level and stateless (like Deno) — no
46
+ // post-serve attach. The `websocket` handler is threaded into `serve`
47
+ // below, where `Bun.serve` wants it, carrying the frame cap.
48
+ prepare_websocket: (options) => {
49
+ max_message_bytes = options?.max_message_bytes ?? DEFAULT_WS_MAX_MESSAGE_BYTES;
50
+ return { create_upgrade_websocket: () => upgradeWebSocket };
51
+ },
52
+ serve: ({ fetch, port, hostname }) => {
53
+ const server = Bun.serve({
54
+ fetch: fetch,
55
+ port,
56
+ hostname,
57
+ // Harmless for HTTP-only binaries — Bun only invokes it for sockets
58
+ // upgraded via `upgradeWebSocket`.
59
+ websocket: {
60
+ ...websocket,
61
+ maxPayloadLength: BUN_WS_MAX_PAYLOAD_MULTIPLIER * max_message_bytes
62
+ }
63
+ });
64
+ const handle = {
65
+ // Bun bug (1.3.14): after a *server-initiated* WebSocket close
66
+ // (`ServerWebSocket.close()` / `@hono/bun`'s `WSContext.close()`),
67
+ // `server.stop()` never resolves — Bun doesn't decrement its
68
+ // active-connection count for a server-closed socket, so the stop
69
+ // waits forever for a connection it already closed. The trigger is
70
+ // orthogonal to HTTP load, hono-vs-raw `Bun.serve`, in-vs-cross
71
+ // process, the force flag (`stop()`/`stop(false)`/`stop(true)` all
72
+ // hang), and the client runtime — a single server-closed WS is
73
+ // necessary and sufficient. Client-initiated close or leaving the
74
+ // socket open both stop cleanly in ~0ms. In this suite the trigger is
75
+ // any server-initiated WS close — a revocation's (the `ws.cross.test.ts`
76
+ // close-on-revoke cases), a cap eviction's, an oversized message's —
77
+ // which is why teardown hangs after those and not under HTTP-only or
78
+ // client-closed WS traffic.
79
+ //
80
+ // So initiate a force-close (`true` drops active connections, no
81
+ // drain) but DON'T await it: awaiting hangs `start_testing_server`'s
82
+ // shutdown forever — `built.close()` and `exit(0)` never run, and the
83
+ // spawning harness blocks on a child that never exits (observed as a
84
+ // multi-minute hang needing SIGKILL). The force-close still tears the
85
+ // live sockets down; the `exit(0)` the core fires immediately after
86
+ // does the real teardown a few ms later. Node/Deno don't need this —
87
+ // their `shutdown()`/`close()` resolve normally. The `.catch` guards a
88
+ // future Bun that rejects rather than hangs; if a future Bun resolves
89
+ // the promise after a server-initiated close, revert to
90
+ // `await server.stop(true)` to mirror the Node/Deno adapters.
91
+ shutdown: () => {
92
+ void Promise.resolve(server.stop(true)).catch(() => { });
93
+ return Promise.resolve();
94
+ },
95
+ native: server
96
+ };
97
+ return handle;
98
+ },
99
+ pid: process.pid,
100
+ register_shutdown_signals: (handler) => {
101
+ process.on('SIGINT', () => void handler());
102
+ process.on('SIGTERM', () => void handler());
103
+ },
104
+ exit: (code) => process.exit(code)
105
+ };
106
+ };
@@ -56,10 +56,16 @@ export interface PrepareWebsocketOptions {
56
56
  * `WsEndpointSpec.max_message_bytes` of the mounted endpoints; a smaller
57
57
  * value refuses messages the endpoint would accept. Node's `ws` server takes
58
58
  * it as its frame cap (`maxPayload`), so an oversized message is refused
59
- * before it is buffered whole; Deno and Bun ignore it, leaving the
60
- * per-message check `register_ws_endpoint` makes (both close with
61
- * `WS_CLOSE_MESSAGE_TOO_BIG`). The default sits far below `ws`'s own
62
- * 100 MiB, so a build raising an endpoint's cap must pass it here too.
59
+ * before it is buffered whole. Bun takes twice it as its frame cap
60
+ * (`maxPayloadLength`): past its cap Bun drops the socket without a close
61
+ * frame, so the headroom leaves a message just over the limit to the
62
+ * per-message check `register_ws_endpoint` makes, while a grossly oversized
63
+ * one is still refused before it is buffered whole. Deno ignores it — its
64
+ * upgrade takes no frame cap — leaving that per-message check alone. Every
65
+ * runtime closes a message just over the limit with
66
+ * `WS_CLOSE_MESSAGE_TOO_BIG`. The default sits far below `ws`'s own 100 MiB
67
+ * and Bun's 16 MiB, so a build raising an endpoint's cap must pass it here
68
+ * too.
63
69
  *
64
70
  * @default DEFAULT_WS_MAX_MESSAGE_BYTES
65
71
  */
@@ -1 +1 @@
1
- {"version":3,"file":"testing_server_core.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_server_core.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,OAAO,EA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zE,yBAAyB,EAAE,CAAC,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC;IAClE,oEAAoE;IACpE,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,KAAK,CAAC;CAC9B;AAED,wEAAwE;AACxE,MAAM,WAAW,sBAAsB;IACtC;;;;;;;;OAQG;IACH,iBAAiB,EAAE,CAAC,OAAO,CAAC,EAAE,uBAAuB,KAAK,CAAC,GAAG,EAAE,IAAI,KAAK,gBAAgB,CAAC;CAC1F;AAED,8EAA8E;AAC9E,MAAM,WAAW,eAAe;IAC/B,mFAAmF;IACnF,GAAG,EAAE,IAAI,CAAC;IACV;;;;OAIG;IACH,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED,0CAA0C;AAC1C,MAAM,WAAW,yBAAyB;IACzC,+CAA+C;IAC/C,OAAO,EAAE,oBAAoB,CAAC;IAC9B;;;;;;OAMG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,sCAAsC;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,6CAA6C;IAC7C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,SAAS,EAAE,CAAC,OAAO,EAAE,sBAAsB,KAAK,OAAO,CAAC,eAAe,CAAC,CAAC;IACzE,0EAA0E;IAC1E,GAAG,CAAC,EAAE,UAAU,CAAC;CACjB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,gBAAgB,GAAI,MAAM,MAAM,KAAG,OAG/C,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,GAAU,SAAS,yBAAyB,KAAG,OAAO,CAAC,IAAI,CAkE3F,CAAC"}
1
+ {"version":3,"file":"testing_server_core.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_server_core.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB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1
  import '../assert_dev_env.js';
2
2
  import type { TestingServerAdapter } from './testing_server_core.js';
3
- /** Build the Deno {@link TestingServerAdapter}. */
3
+ /** Build the Deno `TestingServerAdapter`. */
4
4
  export declare const create_deno_testing_adapter: () => TestingServerAdapter;
5
5
  //# sourceMappingURL=testing_server_deno.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing_server_deno.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_server_deno.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAsB9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAelF,mDAAmD;AACnD,eAAO,MAAM,2BAA2B,QAAO,oBAkB7C,CAAC"}
1
+ {"version":3,"file":"testing_server_deno.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_server_deno.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAsB9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAelF,6CAA6C;AAC7C,eAAO,MAAM,2BAA2B,QAAO,oBAkB7C,CAAC"}
@@ -17,7 +17,7 @@ import '../assert_dev_env.js';
17
17
  */
18
18
  import { upgradeWebSocket } from '@hono/deno';
19
19
  import { create_deno_runtime } from '../../runtime/deno.js';
20
- /** Build the Deno {@link TestingServerAdapter}. */
20
+ /** Build the Deno `TestingServerAdapter`. */
21
21
  export const create_deno_testing_adapter = () => ({
22
22
  runtime_label: 'Deno',
23
23
  runtime: create_deno_runtime([]),
@@ -1,5 +1,5 @@
1
1
  import '../assert_dev_env.js';
2
2
  import type { TestingServerAdapter } from './testing_server_core.js';
3
- /** Build the Node {@link TestingServerAdapter}. */
3
+ /** Build the Node `TestingServerAdapter`. */
4
4
  export declare const create_node_testing_adapter: () => TestingServerAdapter;
5
5
  //# sourceMappingURL=testing_server_node.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing_server_node.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_server_node.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA2B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAUlF,mDAAmD;AACnD,eAAO,MAAM,2BAA2B,QAAO,oBA+B7C,CAAC"}
1
+ {"version":3,"file":"testing_server_node.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/testing_server_node.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA2B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAUlF,6CAA6C;AAC7C,eAAO,MAAM,2BAA2B,QAAO,oBA+B7C,CAAC"}
@@ -28,7 +28,7 @@ const node_serve_handle = (server) => ({
28
28
  }),
29
29
  native: server
30
30
  });
31
- /** Build the Node {@link TestingServerAdapter}. */
31
+ /** Build the Node `TestingServerAdapter`. */
32
32
  export const create_node_testing_adapter = () => ({
33
33
  runtime_label: 'Node',
34
34
  runtime: create_node_runtime(),
@@ -48,7 +48,7 @@ export const create_node_testing_adapter = () => ({
48
48
  },
49
49
  attach_to_server: (handle) => {
50
50
  // `handle.native` is the `ServerType` from `serve()` —
51
- // type-erased at the {@link ServeHandle} seam, so it downcasts here.
51
+ // type-erased at the `ServeHandle` seam, so it downcasts here.
52
52
  node_ws?.injectWebSocket(handle.native);
53
53
  }
54
54
  };
@@ -1,7 +1,7 @@
1
1
  import '../assert_dev_env.js';
2
2
  import { type BackendCapabilities } from './capabilities.js';
3
3
  import type { SetupTest } from './setup.js';
4
- /** Configuration for {@link describe_cross_process_ws_tests}. */
4
+ /** Configuration for `describe_cross_process_ws_tests`. */
5
5
  export interface CrossProcessWsTestOptions {
6
6
  /**
7
7
  * Per-test fixture producer (`default_cross_process_setup(handle)`).
@@ -1 +1 @@
1
- {"version":3,"file":"ws_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAwG9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,iEAAiE;AACjE,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,yBAAyB,KAAG,IAkVpF,CAAC"}
1
+ {"version":3,"file":"ws_round_trip.d.ts","sourceRoot":"../src/lib/","sources":["../../../src/lib/testing/cross_backend/ws_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA0G9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAK5C,2DAA2D;AAC3D,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C,2EAA2E;IAC3E,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,oEAAoE;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,yBAAyB,KAAG,IAkVpF,CAAC"}
@@ -19,14 +19,15 @@ import '../assert_dev_env.js';
19
19
  * every WS endpoint — so the suite needs no knowledge of a consumer's domain
20
20
  * WS methods. It validates the transport, not the domain.
21
21
  *
22
- * The first three cases mirror the upgrade stack `register_ws_endpoint` wires
23
- * (origin check → `require_auth` → dispatch): an authenticated upgrade
24
- * round-trips `heartbeat`; an anonymous upgrade is refused; a
25
- * disallowed-origin upgrade is refused. Per-connection auth is enforced at
26
- * upgrade time (not per message), so the negative cases assert the upgrade
27
- * itself rejects rather than a per-message error frame.
22
+ * Three cases mirror the upgrade stack `register_ws_endpoint` wires (origin
23
+ * check → `require_auth` → dispatch): an authenticated upgrade round-trips
24
+ * `heartbeat` (the first case), and an anonymous upgrade and a
25
+ * disallowed-origin upgrade are refused (after the spine-parity cases).
26
+ * Per-connection auth is enforced at upgrade time (not per message), so the
27
+ * negative cases assert the upgrade itself rejects rather than a per-message
28
+ * error frame.
28
29
  *
29
- * Spine-parity cases follow. Both spines admit a connection only after
30
+ * Spine-parity cases follow the first. Both spines admit a connection only after
30
31
  * re-reading its credential, and requests that arrive first wait for that
31
32
  * rather than being dropped: requests sent the moment the socket opens are all
32
33
  * answered, and — gated on `capabilities.ws_handshake_pipelining`, with the
@@ -38,7 +39,8 @@ import '../assert_dev_env.js';
38
39
  * `DEFAULT_WS_MAX_MESSAGE_BYTES`) closes the socket with
39
40
  * `WS_CLOSE_MESSAGE_TOO_BIG`.
40
41
  *
41
- * The final cases (gated on `rpc_path`) cover server-initiated close.
42
+ * The cases after the refused upgrades (gated on `rpc_path`) cover
43
+ * server-initiated close.
42
44
  * Per-message dispatch never re-checks credential validity, so an open socket
43
45
  * ends only when a revocation closes it — which every revocation does, once
44
46
  * its transaction commits. An authenticated socket is dropped when the
@@ -48,7 +50,7 @@ import '../assert_dev_env.js';
48
50
  * `rpc_path` to skip them (consumers without the standard account and admin
49
51
  * actions on their RPC endpoint).
50
52
  *
51
- * One more case is gated on `capabilities.ws_account_actions` — the backend's
53
+ * The last cases are gated on `capabilities.ws_account_actions` — the backend's
52
54
  * WS endpoint mounts the self-service account actions: a socket that revokes
53
55
  * its own sessions *over that socket* is closed with
54
56
  * `WS_CLOSE_SESSION_REVOKED`, and — on a backend declaring
@@ -6,6 +6,7 @@ import type { AppDeps } from '../auth/deps.js';
6
6
  import type { AuditEmitter } from '../auth/audit_emitter.js';
7
7
  import type { BootstrapServerOptions } from '../server/app_server.js';
8
8
  import type { AppServerContext } from '../server/app_server_context.js';
9
+ import type { AppBackend } from '../server/app_backend.js';
9
10
  import { Db } from '../db/db.js';
10
11
  import { type RouteSpec } from '../http/route_spec.js';
11
12
  import { type AppSurfaceSpec, type RpcEndpointSpec } from '../http/surface.js';
@@ -79,16 +80,33 @@ export declare const create_test_audit_emitter: () => AuditEmitter;
79
80
  * `create_audit_log_sse` against `create_test_app`.
80
81
  */
81
82
  export declare const create_stub_audit_sse: () => AuditLogSse;
82
- /** Stub `AppDeps` for auth surface tests — throws on any method access. */
83
- export declare const stub_app_deps: AppDeps;
84
83
  /**
85
84
  * Create no-op `AppDeps` for auth surface testing.
86
85
  */
87
86
  export declare const create_stub_app_deps: () => AppDeps;
87
+ /** Options for `create_stub_app_backend`. */
88
+ export interface CreateStubAppBackendOptions {
89
+ /** The backend's deps. Default a fresh `create_stub_app_deps()`. */
90
+ deps?: AppDeps;
91
+ /** The backend's `close`. Default one that does nothing. */
92
+ close?: () => Promise<void>;
93
+ }
94
+ /**
95
+ * Create a stub `AppBackend` with no database behind it — no migration
96
+ * results, and a `close` that does nothing unless one is passed. For
97
+ * assembling a server (`create_app_server`) in tests that never reach the
98
+ * database; one whose `close` does nothing can host server after server.
99
+ *
100
+ * @param options - the deps and `close` to use in place of the defaults
101
+ */
102
+ export declare const create_stub_app_backend: (options?: CreateStubAppBackendOptions) => AppBackend;
88
103
  /**
89
104
  * Create the API middleware stub array matching `create_auth_middleware_specs`
90
- * output. Like the real factory's, each spec gets its own pass-through handler,
91
- * so `assert_middleware_stack_mounted` can tell the layers apart by identity.
105
+ * output — the same names, paths, order, and declared `errors` (the surface
106
+ * merges middleware errors into every route under the path, so a stub that
107
+ * declared more than the real stack would widen the test surface). Like the
108
+ * real factory's, each spec gets its own pass-through handler, so
109
+ * `assert_middleware_stack_mounted` can tell the layers apart by identity.
92
110
  */
93
111
  export declare const create_stub_api_middleware: (options?: {
94
112
  /** Include the daemon_token middleware layer. */
@@ -161,6 +179,23 @@ export interface CreateTestAppSurfaceSpecOptions {
161
179
  * Surface assembly only reads `route_prefix` (default `'/api/account'`).
162
180
  */
163
181
  bootstrap?: BootstrapServerOptions;
182
+ /**
183
+ * Symmetric with `AppServerOptions.surface_route` — `true` lists the
184
+ * admin-only `GET /api/surface`, which `create_app_server` mounts only when
185
+ * opted in. Pass the same value to both entry points so the surface tests
186
+ * probe the route exactly when the live server serves it.
187
+ *
188
+ * @default false
189
+ */
190
+ surface_route?: boolean;
191
+ /**
192
+ * List the `daemon_token` middleware layer, as `create_app_server` mounts
193
+ * it when given a `daemon_token_state`. Pass `true` exactly when the live
194
+ * server gets one — `create_test_app` always passes one.
195
+ *
196
+ * @default false
197
+ */
198
+ daemon_token?: boolean;
164
199
  }
165
200
  /**
166
201
  * Create an `AppSurfaceSpec` for the standard testing suites.
@@ -172,13 +207,16 @@ export interface CreateTestAppSurfaceSpecOptions {
172
207
  * suites consume the spec object this function returns, not the JSON
173
208
  * file.
174
209
  *
175
- * Mirrors `create_app_server`'s route assembly: consumer routes +
176
- * factory-managed bootstrap routes + surface generation — including its
210
+ * Mirrors `create_app_server`'s route assembly, in its order: consumer
211
+ * routes, then the factory-managed bootstrap routes, RPC endpoint routes, and
212
+ * `GET /api/surface` (with `surface_route: true`), then surface
213
+ * generation — including its
177
214
  * refusal of an `rpc_endpoints` or `ws_endpoints` path outside the auth
178
215
  * middleware's scope (`assert_endpoint_in_auth_scope`) and of a
179
216
  * `transform_middleware` that doesn't keep the proxy and auth stack mounted
180
217
  * (`assert_middleware_stack_mounted`). The middleware list mirrors the real
181
- * one: a stub `trusted_proxy` spec at `'*'`, then the stub auth stack. If
218
+ * one: a stub `trusted_proxy` spec at `'*'`, then the stub auth stack (with
219
+ * `daemon_token` when `options.daemon_token` is set). If
182
220
  * `create_app_server` changes how it wires routes, update this helper
183
221
  * to stay in sync (single source of truth for all consumers).
184
222
  *
@@ -1 +1 @@
1
- {"version":3,"file":"stubs.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/stubs.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAa7B,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAE7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAsB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAG3E,OAAO,EAEN,KAAK,cAAc,EACnB,KAAK,eAAe,E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