@fuzdev/fuz_app 0.184.0 → 0.186.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 (174) hide show
  1. package/dist/actions/CLAUDE.md +18 -3
  2. package/dist/actions/perform_action.d.ts.map +1 -1
  3. package/dist/actions/perform_action.js +36 -5
  4. package/dist/actions/register_action_ws.d.ts +14 -7
  5. package/dist/actions/register_action_ws.d.ts.map +1 -1
  6. package/dist/actions/ws_socket_session.d.ts +17 -4
  7. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  8. package/dist/actions/ws_socket_session.js +41 -7
  9. package/dist/auth/CLAUDE.md +18 -9
  10. package/dist/auth/account_queries.d.ts +53 -40
  11. package/dist/auth/account_queries.d.ts.map +1 -1
  12. package/dist/auth/account_queries.js +57 -50
  13. package/dist/auth/account_routes.d.ts.map +1 -1
  14. package/dist/auth/account_routes.js +59 -25
  15. package/dist/auth/admin_actions.d.ts.map +1 -1
  16. package/dist/auth/admin_actions.js +26 -9
  17. package/dist/auth/audit_emitter.js +2 -2
  18. package/dist/auth/audit_log_queries.d.ts +11 -3
  19. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  20. package/dist/auth/audit_log_queries.js +4 -4
  21. package/dist/auth/audit_log_routes.d.ts +1 -1
  22. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  23. package/dist/auth/audit_log_routes.js +3 -2
  24. package/dist/auth/audit_log_schema.js +1 -1
  25. package/dist/auth/auth_ddl.d.ts.map +1 -1
  26. package/dist/auth/auth_ddl.js +4 -0
  27. package/dist/auth/cleanup.d.ts +34 -3
  28. package/dist/auth/cleanup.d.ts.map +1 -1
  29. package/dist/auth/cleanup.js +12 -4
  30. package/dist/auth/migrations.d.ts.map +1 -1
  31. package/dist/auth/migrations.js +35 -0
  32. package/dist/auth/role_grant_offer_queries.d.ts +13 -13
  33. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  34. package/dist/auth/role_grant_offer_queries.js +12 -13
  35. package/dist/auth/role_grant_queries.d.ts +16 -9
  36. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  37. package/dist/auth/role_grant_queries.js +16 -9
  38. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  39. package/dist/auth/self_service_role_actions.js +15 -0
  40. package/dist/auth/session_queries.d.ts +24 -0
  41. package/dist/auth/session_queries.d.ts.map +1 -1
  42. package/dist/auth/session_queries.js +28 -0
  43. package/dist/db/CLAUDE.md +3 -3
  44. package/dist/db/cell_ddl.d.ts +8 -3
  45. package/dist/db/cell_ddl.d.ts.map +1 -1
  46. package/dist/db/cell_ddl.js +10 -5
  47. package/dist/http/CLAUDE.md +1 -1
  48. package/dist/http/body_limit.d.ts +4 -4
  49. package/dist/http/body_limit.js +4 -4
  50. package/dist/http/pending_effects.d.ts +8 -4
  51. package/dist/http/pending_effects.d.ts.map +1 -1
  52. package/dist/http/route_spec.d.ts +3 -3
  53. package/dist/http/route_spec.d.ts.map +1 -1
  54. package/dist/realtime/audit_log_sse.d.ts +1 -1
  55. package/dist/realtime/sse.d.ts +2 -2
  56. package/dist/realtime/sse.d.ts.map +1 -1
  57. package/dist/realtime/sse_constants.d.ts +1 -1
  58. package/dist/realtime/sse_constants.js +1 -1
  59. package/dist/server/app_server.d.ts +59 -71
  60. package/dist/server/app_server.d.ts.map +1 -1
  61. package/dist/server/app_server.js +52 -60
  62. package/dist/server/shutdown_drain.d.ts +69 -0
  63. package/dist/server/shutdown_drain.d.ts.map +1 -0
  64. package/dist/server/shutdown_drain.js +77 -0
  65. package/dist/testing/CLAUDE.md +197 -66
  66. package/dist/testing/admin_integration.d.ts +2 -2
  67. package/dist/testing/admin_integration.d.ts.map +1 -1
  68. package/dist/testing/admin_integration.js +36 -20
  69. package/dist/testing/app_server.d.ts +5 -7
  70. package/dist/testing/app_server.d.ts.map +1 -1
  71. package/dist/testing/app_server.js +5 -7
  72. package/dist/testing/auth_apps.d.ts +3 -1
  73. package/dist/testing/auth_apps.d.ts.map +1 -1
  74. package/dist/testing/auth_apps.js +22 -5
  75. package/dist/testing/cross_backend/backend_config.d.ts +8 -0
  76. package/dist/testing/cross_backend/backend_config.d.ts.map +1 -1
  77. package/dist/testing/cross_backend/backend_log.d.ts +71 -0
  78. package/dist/testing/cross_backend/backend_log.d.ts.map +1 -0
  79. package/dist/testing/cross_backend/backend_log.js +134 -0
  80. package/dist/testing/cross_backend/backend_swap.d.ts +41 -0
  81. package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -0
  82. package/dist/testing/cross_backend/backend_swap.js +431 -0
  83. package/dist/testing/cross_backend/body_size_smuggling.js +3 -3
  84. package/dist/testing/cross_backend/bootstrap_backend.d.ts +3 -1
  85. package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -1
  86. package/dist/testing/cross_backend/bootstrap_backend.js +9 -5
  87. package/dist/testing/cross_backend/conformance_case.d.ts +11 -6
  88. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  89. package/dist/testing/cross_backend/conformance_case.js +4 -0
  90. package/dist/testing/cross_backend/conformance_principal.d.ts +2 -2
  91. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -1
  92. package/dist/testing/cross_backend/conformance_principal.js +27 -10
  93. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +10 -1
  94. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  95. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +33 -7
  96. package/dist/testing/cross_backend/default_backend_configs.d.ts +38 -5
  97. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/default_backend_configs.js +50 -15
  99. package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
  100. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  101. package/dist/testing/cross_backend/in_process_setup.js +53 -31
  102. package/dist/testing/cross_backend/revocation_drivers.d.ts +14 -2
  103. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/revocation_drivers.js +36 -8
  105. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  106. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -1
  107. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +7 -0
  108. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  109. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -2
  110. package/dist/testing/cross_backend/setup.d.ts +44 -43
  111. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  112. package/dist/testing/cross_backend/setup.js +64 -62
  113. package/dist/testing/cross_backend/spawn_backend.d.ts +19 -1
  114. package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
  115. package/dist/testing/cross_backend/spawn_backend.js +138 -11
  116. package/dist/testing/cross_backend/spine_suites.d.ts +17 -14
  117. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  118. package/dist/testing/cross_backend/spine_suites.js +37 -15
  119. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  120. package/dist/testing/cross_backend/sse_round_trip.js +4 -2
  121. package/dist/testing/cross_backend/standard.d.ts +18 -82
  122. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  123. package/dist/testing/cross_backend/standard.js +6 -21
  124. package/dist/testing/cross_backend/standard_auth.d.ts +74 -0
  125. package/dist/testing/cross_backend/standard_auth.d.ts.map +1 -0
  126. package/dist/testing/cross_backend/standard_auth.js +28 -0
  127. package/dist/testing/cross_backend/standard_bundle.d.ts +48 -0
  128. package/dist/testing/cross_backend/standard_bundle.d.ts.map +1 -0
  129. package/dist/testing/cross_backend/standard_bundle.js +43 -0
  130. package/dist/testing/cross_backend/testing_reset_actions.d.ts +18 -6
  131. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  132. package/dist/testing/cross_backend/testing_reset_actions.js +23 -8
  133. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  134. package/dist/testing/cross_backend/testing_server_bun.js +7 -30
  135. package/dist/testing/cross_backend/testing_server_core.d.ts +16 -3
  136. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  137. package/dist/testing/cross_backend/testing_server_core.js +20 -4
  138. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +6 -2
  139. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  140. package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -3
  141. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/ws_round_trip.js +4 -3
  143. package/dist/testing/data_exposure.d.ts +4 -1
  144. package/dist/testing/data_exposure.d.ts.map +1 -1
  145. package/dist/testing/data_exposure.js +93 -25
  146. package/dist/testing/db_invariants.d.ts +5 -5
  147. package/dist/testing/db_invariants.js +5 -5
  148. package/dist/testing/error_coverage.d.ts +5 -0
  149. package/dist/testing/error_coverage.d.ts.map +1 -1
  150. package/dist/testing/error_coverage.js +2 -1
  151. package/dist/testing/integration.d.ts +4 -20
  152. package/dist/testing/integration.d.ts.map +1 -1
  153. package/dist/testing/integration.js +49 -79
  154. package/dist/testing/integration_helpers.d.ts +16 -0
  155. package/dist/testing/integration_helpers.d.ts.map +1 -1
  156. package/dist/testing/integration_helpers.js +29 -1
  157. package/dist/testing/logged_errors.d.ts +61 -0
  158. package/dist/testing/logged_errors.d.ts.map +1 -0
  159. package/dist/testing/logged_errors.js +285 -0
  160. package/dist/testing/middleware_gate_probes.d.ts +55 -1
  161. package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
  162. package/dist/testing/middleware_gate_probes.js +76 -3
  163. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  164. package/dist/testing/rpc_attack_surface.js +41 -16
  165. package/dist/testing/stubs.d.ts +5 -1
  166. package/dist/testing/stubs.d.ts.map +1 -1
  167. package/dist/testing/stubs.js +6 -3
  168. package/dist/testing/test_app.d.ts +39 -9
  169. package/dist/testing/test_app.d.ts.map +1 -1
  170. package/dist/testing/test_app.js +70 -12
  171. package/dist/testing/transports/fetch_transport.d.ts +10 -0
  172. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  173. package/dist/testing/transports/fetch_transport.js +13 -0
  174. package/package.json +4 -3
@@ -33,7 +33,7 @@ time (never runtime), where a throwing guard would break `vite build`.
33
33
  - `stub_handler()` — a `route_raw` text answer (`stub`), a handler that fits any route (`attach_route_handler(shape, stub_handler)`).
34
34
  - `stub_route_spec(shape)` — a spec for a surface that is described and never served: `shape` with a handler that throws when run (the spine routes of `create_rust_spine_consumer_surface_spec`).
35
35
  - `stub_mw` — pass-through middleware (`async (_c, next) => next()`).
36
- - `create_stub_app_deps()` — factory: fresh `AppDeps` with a stub keyring (`sign` answers `<value>.stub_signature`, so a session cookie signed on stub deps is a line; nothing else of it does anything), no-op password, a `create_noop_stub` DB, silent `Logger`, no-op `audit`, an empty `connection_closer` and `notification_sender`.
36
+ - `create_stub_app_deps()` — factory: fresh `AppDeps` with a stub keyring (`sign` answers `<value>.stub_signature`, so a session cookie signed on stub deps is a line; nothing else of it does anything), no-op password, a fresh `create_stub_db()` (transactions run their callbacks), silent `Logger`, no-op `audit`, an empty `connection_closer` and `notification_sender`.
37
37
  - `create_test_audit_emitter()` — no-op `AuditEmitter`; `emit` / `emit_role_grant_target` / `emit_pool` resolve immediately, `notify` no-op, `add_listener` throws (use `create_recording_audit_emitter` for a listener-accepting emitter), `listener_count` returns 0, `drain_inflight` resolves immediately, `inflight_count` returns 0.
38
38
  - `create_stub_audit_sse()` — no-op `AuditLogSse` for surface-test wiring without booting real SSE. `on_audit_event` no-op (nothing is broadcast); `required_role` is `admin`; `registry` is a fresh `SseRegistry` (live `.count` / `.close_*` for registry-state tests, isolated per call). For real SSE plumbing build via `create_audit_log_sse` against `create_test_app`.
39
39
  - `create_stub_api_middleware({include_daemon_token?, origin_carve_outs?})` — stub `MiddlewareSpec[]` with `create_auth_middleware_specs`'s names, paths, order and declared `errors` (pinned against it by `auth/middleware.mounted.test.ts`), each layer its own pass-through handler so `assert_middleware_stack_mounted` tells them apart. A stub declaring more errors than the real layer would widen every route's error map under its path. The real stack: `auth/CLAUDE.md` §Middleware.
@@ -92,6 +92,10 @@ in insert order (lists sort `created_at, id`). The in-process seed and
92
92
  `query_create_actor_with_clock_timestamp`, so both spines list them alike.
93
93
  `query_admin_account_list` is the exception: it sorts `created_at, name, id`
94
94
  to keep one actor per account the same on both backends.
95
+ `_testing_reset` stamps each seeded account's session the same way
96
+ (`RESET_SESSION_CLOCK_STAMP_SQL`, `cross_backend/testing_reset_actions.ts`,
97
+ byte for byte the Rust reset's), so the seeded sessions list in seed order on
98
+ both spines rather than tying on one transaction's `NOW()`.
95
99
 
96
100
  `create_test_session_row(db, token_hash, account_id, expires_in_seconds)`
97
101
  inserts an `auth_session` row expiring that many seconds past the database's
@@ -128,6 +132,37 @@ mismatch.
128
132
  - `create_recording_audit_emitter(calls_ref?)` — no-op `AuditEmitter` pushing every `emit` and `emit_pool` call into `calls`. Pass `calls_ref` to write into a caller-owned array; omit to let the helper allocate. Returns `{emitter, calls}` — destructure `emitter` as the `audit` dep and read `calls` to assert. `add_listener` records (never fires) and returns a remover with the production semantics, so `listener_count` tracks what a server registered and released.
129
133
  - `RecordingAuditEmitter` — `{emitter: AuditEmitter; calls: Array<AuditLogInput>}`.
130
134
 
135
+ ### `logged_errors.ts` — fail a test on an error it logs
136
+
137
+ `install_logged_error_gate(options?)` — call at the top level of a vitest
138
+ `setupFiles` module (fuz_app's: `src/test/logged_error_gate.ts`, on the `unit`
139
+ and `db` projects). Wraps `Logger.prototype.error` and `console.error` once per
140
+ process (state on `globalThis`, since an isolated project re-evaluates the
141
+ module per file), buffers what each test logs, and fails the test in its last
142
+ `onTestFinished` hook — after its `afterEach` hooks and a `create_test_app`
143
+ close — on any error not declared; a test that already failed is skipped. A
144
+ call counts whatever the logger's level. Errors logged outside a test fail the
145
+ file in its last `afterAll`. Errors only.
146
+
147
+ - `expect_logged_error(pattern)` — inside a test: the test must log a match,
148
+ and every match is allowed. Throws outside a test, in a concurrent test, or
149
+ without the gate.
150
+ - `allow_logged_error(pattern, reason)` — reason required; in a test for that
151
+ test, at collection for the enclosing `describe` (the file at top level) and
152
+ for what the file logs outside its tests or in its concurrent tests; throws
153
+ in a concurrent test; a no-op without the gate.
154
+ - `LOGGED_ERROR_BANNERS` — the designed test-mode banners
155
+ (`RATE_LIMITERS_DISABLED_BANNER`, the two fail-floor banners), allowed
156
+ everywhere; `options.allow` adds a consumer's own.
157
+ - `LoggedErrorPattern` (substring or `RegExp`), `LoggedErrorAllowance`,
158
+ `InstallLoggedErrorGateOptions`.
159
+
160
+ Late errors (an effect nothing awaited) land on the next test. A concurrent
161
+ test's errors go to the file's bucket — no buffer can say whose they are — so
162
+ both `expect_logged_error` and `allow_logged_error` throw in one; allow them
163
+ on its `describe`, at collection. The gate's own tests are `test.fails` cases
164
+ (`src/test/testing/logged_errors.test.ts`).
165
+
131
166
  ### `token_scope_fixtures.ts` — scope documents built to a size
132
167
 
133
168
  `token_scope_methods_at_bytes(bytes, filler)` — method names whose `methods`
@@ -193,11 +228,12 @@ which the Rust `fuz_testing` embeds byte for byte
193
228
  rows a backend answered), `register_db_invariants_check`,
194
229
  `check_db_invariants_after_all`, `check_db_invariants_after_suite`.
195
230
 
196
- `create_test_app` registers its `assert_db_invariants` to run when the test
197
- that built it finishes (`register_db_invariants_check` — only inside a running
198
- test; skipped when the test already failed), so a direct caller is checked
199
- too; `default_in_process_setup` uses the test app's check, and the
200
- cross-process setup registers its fixture's. In-process it queries the app's
231
+ `create_test_app` runs its `assert_db_invariants` when the test that built it
232
+ finishes (only inside a running test — its body or a `beforeEach`; skipped
233
+ when the test already failed), so a direct caller is checked too, and then
234
+ closes the app (§`app_server.ts` and `test_app.ts`);
235
+ `default_in_process_setup` uses the test app's check, and the cross-process
236
+ setup registers its fixture's. In-process it queries the app's
201
237
  own database;
202
238
  cross-process it calls the backend's `_testing_db_invariants` on the keeper's
203
239
  daemon-token channel (unrecorded by a transcript), so `memory://` spawns are
@@ -261,15 +297,32 @@ rate limiter `null` — a limiter passed through `app_options` wins over the
261
297
  mode, so a rate-limit test enables just the one it pins; the mode's stderr
262
298
  banner prints once per module instance — once per test file in an isolated
263
299
  vitest project, once per run under `isolate: false`, ../../../docs/usage.md §Rate limiters), static daemon token state (no rotation, keeper already set),
264
- `await_pending_effects: true` (§Cross-cutting conventions), and a silent
265
- logger. Override via `app_options`. `cleanup()` is the assembled server's idempotent
266
- `close` — it also closes the server's live connections, disposes the
267
- limiters it built, and removes the audit listeners and closer members it
268
- added.
269
-
270
- `auth_cleanup` is left at its default, **off**, here: a background pass would delete rows and
300
+ `await_pending_effects: true` (§Cross-cutting conventions), the shutdown
301
+ drain bound `TEST_SHUTDOWN_DRAIN_TIMEOUT_MS` (under vitest's
302
+ per-test timeout, so a give-up fails as one rather than as a timeout), and a
303
+ silent logger. Override via `app_options`. `cleanup()` runs the assembled
304
+ server's idempotent `close` — it also closes the server's live connections,
305
+ disposes the limiters it built, and removes the audit listeners and closer
306
+ members it added — and resolves `void`, throwing with the
307
+ `ShutdownDrainGivenUp` report when the drain gave up on work still in flight.
308
+ A test that gives up on purpose calls `server.close()`, which resolves the
309
+ report.
310
+
311
+ An app built inside a test (its body or a `beforeEach`) is closed when the
312
+ test finishes, after its invariant check, in one `onTestFinished` hook. That
313
+ close fails the test on a give-up, unless the test failed or closed the app
314
+ itself (`cleanup` or `server.close()`; `TestApp.server` is the assembled
315
+ server with its `close` marking that). An app built in `beforeAll` registers
316
+ nothing and is its suite's to close, so a fixture shared across tests is
317
+ built there — `describe_middleware_gate_tests`' in-process fixture is built
318
+ in `beforeAll` and checked once after its probes (a `TestFixture` has no
319
+ close). Inside a concurrent test `create_test_app` throws: vitest names
320
+ whichever concurrent test started last as current, so the close would land
321
+ on a sibling's app — build the app in `beforeAll` and close it in `afterAll`.
322
+
323
+ `auth_cleanup` is `'off'` here: a background pass would delete rows and
271
324
  write audit rows mid-test. A suite that opts in through `app_options` has the
272
- schedule stopped by `cleanup()`, which is the assembled server's `close`.
325
+ schedule stopped by `cleanup()`.
273
326
 
274
327
  A fresh Hono app is created on every call because middleware closures bind
275
328
  to the server's deps (db, keyring). Hono assembly is cheap;
@@ -388,6 +441,31 @@ fuz_app's wiring (TS vs Rust under `cross_backend_parity`, Node vs Bun under
388
441
  `describe_spine_differential_suites`): ../../test/CLAUDE.md §Cross-backend
389
442
  self-tests.
390
443
 
444
+ ## Backend swap
445
+
446
+ `cross_backend/backend_swap.ts` — `describe_backend_swap_tests({orders,
447
+ database_url, empty_database, declined_role?})`: two backends over one
448
+ Postgres database, one at a time. Per order the first mints through its real
449
+ routes (bootstrap, a second keeper session and a keeper API token, invite,
450
+ signup, login, a member API token, two pending offers); the second boots over
451
+ that database — its migrations and every table's content digest unchanged —
452
+ honors each credential, the password hash and the offers, accepting one and
453
+ declining the other, logs the second keeper session out, revokes the keeper
454
+ token and changes the member's password; and the first boots again and
455
+ honors what it wrote: the keeper session and token refused (nothing else
456
+ ended them) beside the keeper's first cookie, the member's sessions and token
457
+ ended by the password change. Each phase spawns, drains and tears down its
458
+ own backend, and an `afterEach` tears down one a timed-out phase left
459
+ running. The configs must share the database (`DATABASE_URL`, compared as
460
+ exact strings), the cookie name and a set `SECRET_FUZ_COOKIE_KEYS`, keep a
461
+ startup reset off (`FUZ_TESTING_RESET_DB_ON_STARTUP` unset or a false
462
+ stringbool, as the Rust spine parses it; `reset_db_on_startup: false` on the
463
+ Rust family builder) and declare `_testing_drain_effects` and
464
+ `_testing_db_invariants`, and `declined_role` must not be `admin` — all
465
+ checked before the first spawn. A standalone suite
466
+ (`STANDALONE_CROSS_SUITES`). fuz_app's wiring is the `cross_backend_swap`
467
+ project (../../test/CLAUDE.md §Cross-backend self-tests).
468
+
391
469
  ## Assertions, coverage, helpers
392
470
 
393
471
  ### `assertions.ts` — surface + error-schema assertions
@@ -503,7 +581,7 @@ adversarial/round-trip tests. A value that is no schema throws, naming it.
503
581
  - `admin_only_field_blocklist` — `['updated_by', 'created_by']`; never in non-admin response bodies.
504
582
  - `collect_json_keys_recursive(value)` — deep walk; returns `Set<string>` of every key at every nesting depth.
505
583
  - `assert_no_sensitive_fields_in_json(body, blocklist, context)` — rejects any key in the blocklist at any depth.
506
- - `to_principal_transport(principal, fixture)` — the transport a principal's request goes through, so it carries that principal's credential and nothing else: cookie-free with no `Origin` for the daemon token, cookie-free for a public call, the fixture's own for a session principal (whose `Cookie` header replaces the jar's). A bearer or anonymous probe over the fixture's transport authenticates as the keeper, whose cookie its jar carries — send those through `fixture.fresh_transport()`.
584
+ - `to_principal_transport(principal, fixture)` — the transport a principal's request goes through, so it carries that principal's credential and nothing else: cookie-free with no `Origin` for the daemon token, cookie-free for a public call, the fixture's own for a session principal (whose `Cookie` header replaces the jar's). An anonymous probe over the fixture's transport authenticates as the keeper, whose cookie its jar carries, and a bearer one throws (`fetch_transport.ts`) — send those through `fixture.fresh_transport()`.
507
585
  - `pick_auth_headers(spec, test_app, authed_account, admin_account)` — `RouteAuth` → appropriate test credentials; role `admin` uses `admin_account`, other roles use bootstrapped keeper, `keeper` uses daemon token.
508
586
 
509
587
  ## Attack surface suites
@@ -686,7 +764,7 @@ actions and the builtin `ROLE_ADMIN` only, each factory on fresh accounts
686
764
  and calling as one of them, so any consumer mounting
687
765
  `create_standard_rpc_actions` can pass it. The fixtures run last on the
688
766
  describe's fixture, since they mutate.
689
- fuz_app wires it through the standard bundle and in the in-process
767
+ fuz_app wires it through the `standard` suite and in the in-process
690
768
  `cross_backend/rpc_round_trip_spine.db.test.ts`.
691
769
 
692
770
  ### `sse_round_trip.ts` — `describe_sse_route_tests`
@@ -756,7 +834,7 @@ The groups:
756
834
  2. **runtime** (DB-backed via `create_test_app`):
757
835
  - `unauthenticated error responses contain no sensitive fields`
758
836
  - `admin routes return 403 for non-admin user` — cross-privilege check
759
- - `all 2xx responses pass field blocklists` — GETs sorted before POSTs so data-returning routes fire before destructive ones (logout, revoke-all) invalidate sessions
837
+ - `all 2xx responses pass field blocklists` — GETs sorted before POSTs so data-returning routes fire before destructive ones (logout, revoke-all) invalidate sessions; a mutation sent as the authed account runs on a fresh one (`round_trip_uses_fresh_account`); a public route is sent anonymously and again as an authenticated account (a fresh one for a mutation), since it may answer a caller with more; fails when a route that requires a credential refuses the one sent as unauthenticated (`is_unauthenticated_refusal`), naming the route — a public route's 401 is its own answer — and when no 2xx JSON response carried a key besides `ok` at any depth, so a sweep that checked nothing never passes
760
838
 
761
839
  Support functions: `collect_json_schema_property_names(schema)` (walks
762
840
  `properties`/`patternProperties`/`additionalProperties`/`items`/`prefixItems`/`contains`,
@@ -815,35 +893,46 @@ cookies + bearer tokens. Its `describe` blocks, by theme:
815
893
  9. Token revocation + cross-account isolation
816
894
  10. Response body schema validation + error-response information leakage
817
895
  11. Signup invite edge cases + expired credential rejection + error-coverage breadth
818
- 12. Middleware gates — one test per gate each counted route's error map declares (`middleware_gate_probes.ts`, below)
819
896
 
820
897
  An `ErrorCoverageCollector` runs across groups; `afterAll` filters to
821
898
  the routes it counts — login, logout, password, signup (when wired) and the
822
- RPC path — and asserts `DEFAULT_INTEGRATION_ERROR_COVERAGE` (20%). Bootstrap is
899
+ RPC path (`is_standard_integration_route`, `integration_helpers.ts`) — and asserts `DEFAULT_INTEGRATION_ERROR_COVERAGE` (20%). Bootstrap is
823
900
  excluded because no describe block in this suite drives it — its declared
824
901
  codes would always be uncovered. Consumer-specific routes aren't exercised
825
902
  here either — they don't count against the baseline. The declared paths are
826
903
  the route error maps of `surface_source`, middleware included (the origin
827
904
  check's 403, the body limit's 413 and 400, and the host gate's 403 where the
828
905
  surface declares it), counted per (route, status, code), so
829
- every error response a test asserts is recorded, and the middleware-gate group
830
- probes each gate on each counted route. Override with
906
+ every error response a test asserts is recorded. The gates' own refusals
907
+ (`MIDDLEWARE_GATE_ERROR_CODES`, `integration_helpers.ts`) are left out of the
908
+ count: `describe_middleware_gate_tests` (below) probes them. Override with
831
909
  `error_coverage_min?: number` (set to `0` to skip the assertion — useful for
832
910
  minimal route sets whose declared error codes outpace the suite's
833
911
  denial-path drivers).
834
912
 
835
- Options: `{setup_test, surface_source, session_cookie_name, rpc_endpoints, base_url,
836
- max_body_bytes?, rpc_max_body_bytes?, error_coverage_min?,
837
- check_uncovered_errors?}`; the last is called with the declared paths left
838
- uncovered before the floor is asserted, which fuz_app's own wirings hold to an
839
- exact set. `base_url` is the
840
- backend's socket, `null` in-process (`default_in_process_suite_options` gives
841
- `null`, and `max_body_bytes` from `app_options.max_body_size`); the caps
913
+ Options: `{setup_test, surface_source, capabilities, session_cookie_name,
914
+ rpc_endpoints, error_coverage_min?, check_uncovered_errors?}`; the last is
915
+ called with the declared paths left uncovered before the floor is asserted,
916
+ which fuz_app's own wirings hold to an exact set.
917
+
918
+ ### `middleware_gate_probes.ts` — `describe_middleware_gate_tests`
919
+
920
+ `describe_middleware_gate_tests({setup_test, surface_source,
921
+ session_cookie_name, rpc_endpoints, base_url, max_body_bytes?,
922
+ rpc_max_body_bytes?})` — one test per gate each route the integration suite
923
+ counts declares, each refusal's body held to the route's map. Every gate
924
+ refusal (`MIDDLEWARE_GATE_ERROR_CODES`) a counted route declares must have a
925
+ planned probe — the unreadable length aside over a socket — or the call
926
+ throws at collection, so a planner that drops one fails whatever a run
927
+ filters or excludes. A suite of its
928
+ own, beside the integration suite rather than a group of it, because over a
929
+ socket it writes raw heads: the integration suite sends only through the
930
+ fixture transports, so the transcript differential can run it. `base_url` is
931
+ the backend's socket, `null` in-process (`default_in_process_suite_options`
932
+ gives `null`, and `max_body_bytes` from `app_options.max_body_size`); the caps
842
933
  default to `SPINE_BODY_LIMIT_DEFAULT_BYTES`, the RPC endpoint's to
843
934
  `max_body_bytes`.
844
935
 
845
- ### `middleware_gate_probes.ts` — the integration suite's gate probes
846
-
847
936
  `plan_middleware_gate_probes({route_specs, route_error_maps, base_url,
848
937
  max_body_bytes?, rpc_path, rpc_max_body_bytes?})` plans one
849
938
  `MiddlewareGateProbe` per gate a route's error map declares, so a carved-out
@@ -855,8 +944,9 @@ in-process only, an unreadable `Content-Length` → 400 `invalid_content_length`
855
944
  (over a socket Node's parser and hyper answer that one themselves with a
856
945
  bodiless 400, and `fetch` can't send it). Each probe is a request head with no
857
946
  body and no credential, refused before auth, rate limiting and body parsing;
858
- in-process the probes share one fixture. A route whose path has a param or
859
- wildcard segment throws rather than be probed at its literal template.
947
+ in-process the probes share one fixture, built in `beforeAll` and checked
948
+ against the database invariants once they are done. A route whose path has a
949
+ param or wildcard segment throws rather than be probed at its literal template.
860
950
  `send_middleware_gate_probe(probe, base_url, transport)` writes it to the socket
861
951
  with `raw_http_send_head` (`fetch` replaces a caller's `Host` and
862
952
  `Content-Length`), or in-process through the transport, whose `Request` keeps
@@ -883,7 +973,7 @@ from `db_entities.ts`.
883
973
 
884
974
  Required options: `{setup_test, surface_source, session_cookie_name, rpc_endpoints: RpcEndpointsSuiteOption, roles: RoleRegistry, admin_prefix?}`.
885
975
 
886
- fuz_app runs it cross-process through the standard bundle
976
+ fuz_app runs it cross-process through `standard_auth`
887
977
  and in-process as a consumer wires it
888
978
  (`cross_backend/admin_integration_spine.db.test.ts`) — the in-process fixture's
889
979
  `create_account` inserts rows directly, writing no `invite_create` or `signup`
@@ -990,7 +1080,7 @@ The groups:
990
1080
  - wrong role → `forbidden` (-32002)
991
1081
  - authenticated without role → `forbidden`
992
1082
  - **keeper rejects non-daemon credentials** — session and api_token credentials are rejected even when the account has the keeper role (only `daemon_token` passes). The credential-type gate fires before the role gate (see `auth/CLAUDE.md` §Keeper auth shape).
993
- - correct auth passes — valid params (`input_overrides` or generated) reach the method's handler, a recording stub, at 200
1083
+ - correct auth passes — valid params (`input_overrides` or generated) reach the method's handler, a recording stub answering a generated schema-valid output, at 200
994
1084
  - GET unauthenticated for `side_effects: false` reads
995
1085
  2. **RPC adversarial envelopes** — the fixed cases of `create_rpc_envelope_cases(endpoint, {skip_methods?})` (hono-free `rpc_envelope_cases.ts`, shared with the cross-process `describe_rpc_adversarial_cross_tests`): malformed and response-shaped envelopes, batches, unknown methods, the GET read restriction and its query parsing, and anonymous ordering cases (an anonymous GET mutation or batch is `invalid_request`, never 401; params validation runs after authorization). Each is sent by an app its method admits and pinned — status, code, echoed `id`, `data.reason` — by `assert_rpc_envelope_refusal`. The case list is the module's TSDoc.
996
1086
  3. **RPC adversarial params** — `generate_rpc_params_test_cases(input, options?)` (`rpc_envelope_cases.ts`): `generate_input_test_cases` minus its structural cases (a non-object `params` is refused at the envelope, not at params validation), taking the same `{base?, label?}`. Every case expects 400 `invalid_params` with `data.reason` the broken field's declared `invalid_reason` (`expected_invalid_reason`), absent for an undeclared field. Shared with the cross-process suite. `input_overrides` (method name → valid params) seeds a method's cases from that base; an override its schema refuses throws at collection, naming the method.
@@ -1035,7 +1125,7 @@ have files of their own.
1035
1125
 
1036
1126
  ### Fixture protocol + capabilities
1037
1127
 
1038
- - `testing/cross_backend/setup.ts` — the fixture protocol: `SetupTest` / `TestFixture` / `CreateTestAccountOptions`, and `default_cross_process_setup(handle, options?)` over a `BootstrappedBackendHandle`; the in-process `default_in_process_setup` (over `create_test_app`; `migration_namespaces` for tables beyond auth) and `default_in_process_suite_options` (the `{setup_test, surface_source, capabilities}` triple plus pass-through options) are `in_process_setup.ts`. Every test starts from a freshly bootstrapped keeper: cross-process by `_testing_reset` over the daemon-token channel (every auth row wiped, the keeper and any `extra_accounts` seeded, the answered seeds matched by `match_testing_reset_seeds`), in-process by a fresh `create_test_app`. `fixture.create_account({roles?, email?})` goes through the production surface — invite, signup, login, `account_token_create`, an offer and accept per role — so a role whose `grant_paths` lacks `'admin'` is seeded through `extra_accounts` instead; an `email` must be per-test unique. The fixture also carries `fresh_transport({origin?})` (no cookie jar; `{origin: null}` for bearer-only paths) and the dead-credential mints the conformance principals use, each proving its credential live before killing it (in-process they need `account_verify` on the setup's `rpc_endpoints`; cross-process `mint_expired_token` needs `_testing_shorten_credential_expiry` mounted).
1128
+ - `testing/cross_backend/setup.ts` — the fixture protocol: `SetupTest` / `TestFixture` / `CreateTestAccountOptions`, and `default_cross_process_setup(handle, options?)` over a `BootstrappedBackendHandle`; the in-process `default_in_process_setup` (over `create_test_app`; `migration_namespaces` for tables beyond auth) and `default_in_process_suite_options` (the `{setup_test, surface_source, capabilities}` triple plus pass-through options) are `in_process_setup.ts`. Every test starts from a freshly bootstrapped keeper: cross-process by `_testing_reset` over the daemon-token channel (every auth row wiped, the keeper and any `extra_accounts` seeded, the answered seeds matched by `match_testing_reset_seeds`), in-process by a fresh `create_test_app`. `fixture.create_account({roles?, email?})` goes through the production surface — invite, signup, login, `account_token_create`, an offer and accept per role — so a role whose `grant_paths` lacks `'admin'` is seeded through `extra_accounts` instead; an `email` must be per-test unique. The fixture also carries `fresh_transport({origin?})` (no cookie jar; `{origin: null}` for bearer-only paths) and the dead-credential mints the conformance principals use, each proving its credential live before killing it (in-process they need `account_verify` on the setup's `rpc_endpoints`; cross-process `mint_expired_token` and `mint_expired_session` need `_testing_shorten_credential_expiry` mounted).
1039
1129
 
1040
1130
  **Keeper ≠ admin.** `fixture.account` holds `[ROLE_KEEPER, ROLE_ADMIN]` as two
1041
1131
  grants, as a production bootstrap does (in-process,
@@ -1063,18 +1153,26 @@ have files of their own.
1063
1153
  host gate off, `host_gate: false`.
1064
1154
 
1065
1155
  No flag covers the body-size smuggling probe (`body_size_smuggling.ts`): every
1066
- backend closes the connection after an oversized-body 413. Bun 1.4.3 is the
1156
+ backend closes the connection after an oversized-body 413. Bun 1.4.4 is the
1067
1157
  tested floor.
1068
1158
 
1069
- ### `cross_backend/standard.ts` — `describe_standard_cross_process_tests`
1159
+ ### `cross_backend/standard_bundle.ts` — `describe_standard_cross_process_tests`
1160
+
1161
+ Wires the standard suites that run against a spawned backend in one call, in
1162
+ two halves, each a registered suite of its own module:
1070
1163
 
1071
- Wires the standard suites that run against a spawned backend in one call:
1164
+ - `standard_auth.ts` — `describe_standard_auth_cross_tests`: `integration`
1165
+ always, `admin` when `roles` is provided. Every send goes through the
1166
+ fixture transports, so the transcript differential runs it.
1167
+ - `standard.ts` — `describe_standard_cross_tests`: the middleware gates
1168
+ (`describe_middleware_gate_tests`), `round_trip`, `rpc_round_trip`,
1169
+ `data_exposure`. The gate probes write raw request heads and the round
1170
+ trips and data exposure build fixtures in `beforeAll`, which keeps it out of
1171
+ the transcript.
1072
1172
 
1073
- - `integration` — always
1074
- - `admin` — `roles` provided
1075
- - `round_trip` — always
1076
- - `rpc_round_trip` — always
1077
- - `data_exposure` — always
1173
+ `describe_spine_cross_suites` registers the halves apart (`standard_auth`,
1174
+ `standard`); the bundle is for a consumer wiring them outside it, and
1175
+ `STANDALONE_CROSS_SUITES` names it.
1078
1176
 
1079
1177
  Two in-process suites are omitted by design: `rate_limiting` (needs a fresh
1080
1178
  per-test `TestApp` for tight rate-limiter overrides; the spawned binary has no
@@ -1083,9 +1181,8 @@ the in-process backend exposes; wire-level audit observability lives in the
1083
1181
  consumer's own audit `.cross.test.ts`). The omission rationale lives in the
1084
1182
  module doc once instead of repeating in each consumer's `*.cross.test.ts`.
1085
1183
 
1086
- `base_url` (required — the integration suite's middleware-gate probes write
1087
- to the socket), `max_body_bytes` and `rpc_max_body_bytes` forward to the
1088
- integration suite;
1184
+ `base_url` (required — the middleware-gate probes write to the socket),
1185
+ `max_body_bytes` and `rpc_max_body_bytes` forward to the gate suite;
1089
1186
  `rpc_success_fixtures`, `rpc_skip_methods` and `rpc_input_overrides`
1090
1187
  forward to the RPC round-trip's `success_fixtures`, `skip_methods` and
1091
1188
  `input_overrides` (`describe_spine_cross_suites` also forwards
@@ -1096,9 +1193,10 @@ round-trip and data exposure, the two that resolve route paths.
1096
1193
 
1097
1194
  Hard-codes the cross-process-safe set with no `skip` knob; if a future
1098
1195
  consumer needs partial opt-out, add the knob then.
1099
- `StandardCrossProcessTestOptions` is the in-process suites' shared options
1100
- minus their in-process-only knobs (`create_route_specs`,
1101
- `rate_limiting_app_options`).
1196
+ `StandardCrossProcessTestOptions` is both halves' options
1197
+ (`StandardAuthCrossTestOptions`, `StandardCrossTestOptions`): the in-process
1198
+ suites' shared options minus their in-process-only knobs
1199
+ (`create_route_specs`, `rate_limiting_app_options`).
1102
1200
 
1103
1201
  ### `cross_backend/spine_suites.ts` — `describe_spine_cross_suites`
1104
1202
 
@@ -1109,7 +1207,7 @@ exclude_cases?, expected_skips?, overrides?, suite_roles?, ws_required_roles?, r
1109
1207
  rpc_skip_methods?, rpc_input_overrides?, rpc_max_body_bytes?, ws_max_message_bytes?})`.
1110
1208
  `live_rpc_endpoints` is the backend's whole live mount; given, `rpc_adversarial`
1111
1209
  also walks the methods it keeps off the declared surface. `rpc_input_overrides`
1112
- reaches the standard bundle's RPC round-trip and `rpc_adversarial`'s
1210
+ reaches the `standard` suite's RPC round-trip and `rpc_adversarial`'s
1113
1211
  `input_overrides`, so one valid body per method serves both; a key naming a
1114
1212
  method on neither the declared surface nor `live_rpc_endpoints` throws at
1115
1213
  collection. Without it a consumer writes a file per suite, and a suite added
@@ -1117,12 +1215,14 @@ here never reaches it.
1117
1215
 
1118
1216
  - **The registry.** `SUITE_NAMES` / `SuiteName` — the closed set of suites the
1119
1217
  call runs, each named by its module (`ws_round_trip` is
1120
- `describe_cross_process_ws_tests`, `standard` the standard bundle).
1218
+ `describe_cross_process_ws_tests`; `standard_auth` and `standard` the two
1219
+ halves of the standard bundle).
1121
1220
  `STANDALONE_CROSS_SUITES` (keyed by the closed `StandaloneSuiteName`) names
1122
1221
  the modules left out, each with why: the
1123
1222
  `differential` (two handles), `login_security` and `ws_action_rate_limit`
1124
1223
  (a backend spawned with live limiters, which the standard suites would
1125
- exhaust), and the `conformance_table` runner (the consumer's own cases).
1224
+ exhaust), the `conformance_table` runner (the consumer's own cases), and
1225
+ `standard_bundle` (the two standard halves in one call).
1126
1226
  `src/test/testing/cross_backend/spine_suites.test.ts` imports every module
1127
1227
  under `cross_backend/` and holds the two lists to the ones exporting a
1128
1228
  `describe_*` function, whatever the export form (the Bun adapter,
@@ -1138,7 +1238,7 @@ here never reaches it.
1138
1238
  called on its own — the daemon token from the handle, and each suite's
1139
1239
  `setup_test` from `default_cross_process_setup` over the `setup` options
1140
1240
  plus the seeding the suite needs (concatenated): a keeper-only
1141
- `non_admin_keeper` for the standard bundle's keeper ≠ admin probe, the
1241
+ `non_admin_keeper` for `standard_auth`'s keeper ≠ admin probe, the
1142
1242
  multi-actor keepers of `fact_serving` and `transport_composition`, the
1143
1243
  offer grantor of `role_grant_offer_enumeration`, the `cell_editor` holder of
1144
1244
  `cell_grant_role`. Suites are registered without a wrapping `describe`, so
@@ -1154,7 +1254,7 @@ here never reaches it.
1154
1254
  aren't the spine defaults (`SPINE_BODY_LIMIT_DEFAULT_BYTES`,
1155
1255
  `DEFAULT_WS_MAX_MESSAGE_BYTES`). The first reaches `body_size`,
1156
1256
  `body_size_smuggling`, `transport_composition`'s RPC over-cap row and the
1157
- standard bundle's middleware-gate probes of the RPC endpoint (each
1257
+ `standard` suite's middleware-gate probes of the RPC endpoint (each
1158
1258
  takes it as `rpc_max_body_bytes`), the second `ws_round_trip`'s
1159
1259
  `max_message_bytes` — one value per limit for every suite probing it.
1160
1260
  - **`exclude`** — `{[suite]: reason}`; the reason is required and shows in the
@@ -1317,8 +1417,7 @@ fixture). fuz_app's own case files and wiring are
1317
1417
  ### Suite modules
1318
1418
 
1319
1419
  Each `SUITE_NAMES` module in `cross_backend/` exports one
1320
- `describe_<module>_cross_tests(options)`. The exceptions are `standard`
1321
- (`describe_standard_cross_process_tests`), `ws_round_trip`
1420
+ `describe_<module>_cross_tests(options)`. The exceptions are `ws_round_trip`
1322
1421
  (`describe_cross_process_ws_tests`), `sse_round_trip`
1323
1422
  (`describe_cross_process_sse_tests`), `peer_ping_ws`
1324
1423
  (`describe_peer_ping_ws_tests`) and `role_grant_offer_notification_ws`
@@ -1340,7 +1439,7 @@ without.
1340
1439
  | `actor_lookup` | the keeper resolves its own actor in the leak-safe wire shape (the refusals are table rows) | — |
1341
1440
  | `app_settings` | an anonymous signup reads `open_signup` fresh after `app_settings_update` | — |
1342
1441
  | `body_size` | the 1 MiB body cap: cap+1 → 413 `payload_too_large`, exactly the cap not size-rejected, an over-cap chunked body → 413, no upload racing the close | — |
1343
- | `body_size_smuggling` | raw socket: an oversized `POST` + a pipelined `GET` → at most one response; `Content-Length` beside `Transfer-Encoding` → close (Bun 1.4.3 is the tested floor) | — |
1442
+ | `body_size_smuggling` | raw socket: an oversized `POST` + a pipelined `GET` → at most one response; `Content-Length` beside `Transfer-Encoding` → close (Bun 1.4.4 is the tested floor) | — |
1344
1443
  | `capability_mounts` | each mount flag a request observes (`ws`, `sse`, `cell_crud`, `cell_relations`, `fact_serving`, `fact_serving_admin_hash`, `ready`, `account_status`, `ws_account_actions`, `ws_role_gated`) probed once and held to its declaration both ways — `true` answers as mounted, `false` as unmounted; each flag's probe again as an unmounted control (its surface moved under `CAPABILITY_MOUNTS_ABSENT`) read as unmounted on every backend; every other flag a skipped test naming why (`UNPROBED_CAPABILITIES`); can't be excluded or overridden; probes the paths the gated suites send to; cross-process only | every probed flag (the declaration) |
1345
1444
  | `cell_crud` | the CRUD lifecycle + authz matrix, each response parsed against its output schema, `cell_list` paging past hidden rows, mistyped `data` | `cell_crud` (clone cases also `cell_relations`) |
1346
1445
  | `cell_gated_create` | the parent-aware `CellCreateAuthorize`: admin-only `space` root, contributions gated by the root's `policy[kind]`, 404 on a hidden parent vs 403 on a visible one, `cell_policy_set` | `cell_gated_create` |
@@ -1375,7 +1474,8 @@ without.
1375
1474
  | `session_cookie_codec` | exactly one accepted spelling of a signed cookie: non-canonical signature or `expires_at` spellings refused | — |
1376
1475
  | `simple_request` | an untyped, CORS-safelisted, or non-JSON `POST` to a JSON route → 415 `unsupported_content_type` | — |
1377
1476
  | `sse_round_trip` | the audit stream: connect, a data frame, a close on each revocation of a stream proven admitted, a session-scoped revoke leaving a sibling session's stream open, a revoke of the gating role's global grant closing the stream and a global revoke of another role leaving it open (scope matching is `ws_role_gated`'s), the per-session stream cap | `sse` (delete and purge also `account_lifecycle`) |
1378
- | `standard` | the `describe_standard_cross_process_tests` bundle: integration, admin, round trip, RPC round trip, data exposure | `account_status` (the status wire-shape case) |
1477
+ | `standard` | the standard bundle less its auth suites: the middleware-gate probes of each counted route, round trip, RPC round trip, data exposure | — |
1478
+ | `standard_auth` | the standard auth suites: integration, and admin when `roles` is given; run by the transcript differential | `account_status` (the status wire-shape case) |
1379
1479
  | `testing_backdoor` | the backdoor declaration, and every declared `_testing_*` action refusing anonymous, session, and bearer callers | `testing_backdoors` (the declaration) |
1380
1480
  | `token_lifetime` | the API token `lifetime` round trip: ttl mint → `expires_at` on create and list, an eternal control, bad lifetimes → 400, a bearer beside a winning daemon token or a winning session never touched, the request acting as the winner's account; an invalid daemon token falls through to the bearer beside it | — |
1381
1481
  | `token_scope_surface` | the `surface:<name>` half of token scoping: a narrowed bearer refused the audit stream and the bare-hash fact read, anonymous on the status read; scope outranks role | `sse`, `fact_serving_admin_hash`, `account_status` (per case) |
@@ -1414,7 +1514,8 @@ What the suites share:
1414
1514
  → `AccountRevocation` rows, the account-wide revocations the WS and SSE
1415
1515
  suites each close a live connection on, so a row added there is covered on
1416
1516
  both. The drivers stand alone too (`cross_post_as`,
1417
- `cross_admin_token_revoke_all`, `cross_account_purge`).
1517
+ `cross_admin_token_revoke_all`, `cross_account_purge`,
1518
+ `cross_session_revoke_current`).
1418
1519
  - **`cross_backend/ws_endpoint.ts`** — `WsEndpointTarget` and
1419
1520
  `open_session_ws` (see §Cross-process plumbing), and
1420
1521
  `assert_ws_upgrade_refused(open, status)`, which holds a refused upgrade to
@@ -1505,7 +1606,12 @@ Conventions that hold across them:
1505
1606
  family builders a consumer config composes: the env baseline (`HOST` bound
1506
1607
  to `DEFAULT_TEST_BACKEND_HOST`, `127.0.0.1`; the port under
1507
1608
  `port_env_var`; cookie keys; allowed origins; the bootstrap token path; the
1508
- Rust startup self-wipe), the default paths, and the required `capabilities`.
1609
+ TS family's `PUBLIC_LOG_LEVEL`, `TS_BACKEND_LOG_LEVEL` — the spawned binary
1610
+ inherits `VITEST`, which turns every fuz_util `Logger` off; the Rust startup
1611
+ self-wipe, off with `reset_db_on_startup: false`), the default paths, the
1612
+ `log` (`backend.log` under the temp root,
1613
+ `SPINE_CROSS_SUITE_BACKEND_ERRORS` plus `log_allow_errors` allowed;
1614
+ `log_path: null` for none), and the required `capabilities`.
1509
1615
  `daemon_token_dir_env` names the env var the binary reads its daemon-token
1510
1616
  directory from, set to the `{dir}` whose `{dir}/run/daemon_token` is the
1511
1617
  bootstrap's `daemon_token_path` (`to_daemon_token_dir`, which throws for a
@@ -1526,7 +1632,7 @@ Conventions that hold across them:
1526
1632
  (`ensure_database_for_url`), then the spawn. A second argument
1527
1633
  (`CrossBackendGlobalSetupDeps`) swaps the database creator and the spawn,
1528
1634
  for testing the setup itself.
1529
- - `testing/cross_backend/bootstrap_backend.ts` / `create_dual_spawn_global_setup.ts` — spawn and bootstrap one backend, or two (`provide_keys`); `before_bootstrap(config)` runs once the backend is healthy and before its keeper bootstrap, for a probe of the pre-bootstrap window, and a throw from it tears the backend down and fails the setup.
1635
+ - `testing/cross_backend/bootstrap_backend.ts` / `create_dual_spawn_global_setup.ts` — spawn and bootstrap one backend, or two (`provide_keys`); `before_bootstrap(config)` runs once the backend is healthy and before its keeper bootstrap, for a probe of the pre-bootstrap window, and a throw from it tears the backend down and fails the setup. The dual spawn's `after_bootstrap(handle, side)` runs once a backend's bootstrap has succeeded, before any test, for a read of what the bootstrap wrote; a throw tears down every backend spawned so far.
1530
1636
  - `testing/cross_backend/cargo_binary.ts` — `prepare_cargo_binary({workspace_dir,
1531
1637
  package, bin?, profile?})` builds a Cargo binary (`cargo build -p --bin
1532
1638
  --profile`, output inherited, a failed build throws) unless
@@ -1565,13 +1671,38 @@ Conventions that hold across them:
1565
1671
  (`create_output_tail`) for an early exit's error — with its exit code or
1566
1672
  signal — and for the log line an unexpected exit after startup writes.
1567
1673
  Registers exit-time + signal cleanup so vitest worker death or
1568
- Ctrl+C kills children before they strand ports.
1674
+ Ctrl+C kills children before they strand ports. `teardown` rejects unless
1675
+ the child exits `0` on its SIGTERM — a non-zero code (a spine whose
1676
+ shutdown gave up or failed), an exit by signal (the SIGKILL escalation), an
1677
+ exit during the run, or a group teardown gave up on — naming the backend,
1678
+ the exit and the stderr tail, so every global setup that awaits it fails
1679
+ the run on an unclean shutdown; the dual-spawn setup tears both down before
1680
+ it throws. With `config.log` it tees stdout and stderr, whole lines per
1681
+ stream, into `log.path`, and teardown also rejects on each error-level line
1682
+ there no `log.allow_errors` entry names (`backend_log.ts`).
1683
+ - `testing/cross_backend/backend_log.ts` — `BackendLogConfig` (`{path,
1684
+ allow_errors}`), `BackendLogAllowance` (`{pattern, reason}`, a substring:
1685
+ configs cross to the workers through `provide`), `is_backend_error_line`
1686
+ (a `Logger` `🞩error🞩` line, a `tracing` `ERROR` event, or a Rust panic's
1687
+ first line, ANSI stripped; a
1688
+ bare `console.error` has no marker and is not seen),
1689
+ `find_unexpected_backend_errors`, `format_unexpected_backend_errors`,
1690
+ `with_backend_log_allowances(config, allow)`, and
1691
+ `SPINE_CROSS_SUITE_BACKEND_ERRORS` — what the shipped suites provoke on
1692
+ purpose (`fact_serving`'s masked 404 on both spines), which both family
1693
+ builders allow. `create_log_line_splitter` is how each stream is written
1694
+ whole lines at a time, decoding across chunks. A failed log write fails
1695
+ teardown. A line is not attributed to its test; a per-test check would need
1696
+ a log backdoor on both spines.
1569
1697
  - `testing/transports/fetch_transport.ts` — cookie-threading HTTP transport
1570
1698
  satisfying `RpcTestTransport`. Carries a name-keyed cookie jar that
1571
1699
  updates on every response's `Set-Cookie` and re-sends on every request;
1572
1700
  `Origin` defaults to `base_url` (`origin: null` disables for bearer-only
1573
1701
  paths). A cookie cleared with `Max-Age` of zero or less leaves the jar, as
1574
- it leaves a browser's. Exposes `cookies()` so `ws_transport` can thread the session
1702
+ it leaves a browser's. A request naming `Authorization` or `X-Daemon-Token`
1703
+ and no `Cookie` throws while the jar is non-empty, since the jar's cookie
1704
+ would authenticate beside a dead token; send it over a cookie-free
1705
+ transport, or pass `Cookie` to send both on purpose. Exposes `cookies()` so `ws_transport` can thread the session
1575
1706
  cookie onto the WS upgrade.
1576
1707
  - `testing/transports/bootstrap.ts` — stateless `bootstrap({transport, config})`
1577
1708
  POSTs `/api/account/bootstrap` against the running binary, parses the
@@ -1686,7 +1817,7 @@ Conventions that hold across them:
1686
1817
  | `_testing_reset` | yes | the consumer's `reset_state(db)` first, on the same transaction (domain rows depend on auth rows); then every auth row wiped, `app_settings` and `bootstrap_lock` reset, a fresh keeper and any `extra_accounts` seeded through the in-process primitives |
1687
1818
  | `_testing_drain_effects` | yes | answers `{ok: true}` once no request's effect flush (`deps.request_tracker`) and no audit pool write is in flight, those started while it waits included — never a handler still running, its own among them; the barrier before an audit or effect read (WS replies before its effects flush) |
1688
1819
  | `_testing_db_invariants` | yes | every row breaking a `DB_INVARIANTS` check, read after each test |
1689
- | `_testing_mint_session` | yes | a backdated session row behind a valid cookie (the `expired_session` principal) |
1820
+ | `_testing_mint_session` | yes | a backdated session row behind a valid cookie, on any account (a dead session no wire path leaves) |
1690
1821
  | `_testing_put_fact` | yes | seeds a fact, with an optional holder or external URL |
1691
1822
  | `_testing_flood_notifications` | yes | queues notifications onto the caller's socket past its outbound budget (`invalid_params` past its caps, `no_connection` over HTTP) |
1692
1823
  | `_testing_schema_snapshot`, `_testing_migration_tracker` | yes | the parity gates' reads |
@@ -1757,7 +1888,7 @@ The reusable shape for standing up a **spawnable TS** cross-process test
1757
1888
  binary (the TS analog of the Rust `testing_spine_stub`), so consumers don't
1758
1889
  re-roll the serve / daemon-info / drain boilerplate:
1759
1890
 
1760
- - `testing/cross_backend/testing_server_core.ts` — `start_testing_server({adapter, daemon_name, host, port, app_version?, build_app})`. Owns the runtime-neutral orchestration: open-host refusal, stale-daemon check, daemon-info write, `serve`, graceful shutdown. Domain-free — the app is the caller's `build_app(context: BuildTestingAppContext): Promise<BuiltTestingApp>` seam (`{app, close}`). WebSocket endpoints mount through `create_app_server`'s `ws_endpoints` on every runtime: the build calls `context.prepare_websocket({max_message_bytes?})`, which has the adapter prepare its WebSocket support for `serve` and returns the runtime's `upgradeWebSocket`, to pass as `upgrade_websocket`. Shutdown starts the listener's `shutdown` (stop accepting), runs `close` — which must end live WebSockets, as `AppServer.close` does — then awaits the drain, since open sockets would otherwise hold it. Exports the `TestingServerAdapter` (`prepare_websocket: (options?: PrepareWebsocketOptions) => UpgradeWebSocket`) / `ServeHandle` / `PrepareWebsocketOptions` / `BuildTestingAppContext` interfaces.
1891
+ - `testing/cross_backend/testing_server_core.ts` — `start_testing_server({adapter, daemon_name, host, port, app_version?, build_app})`. Owns the runtime-neutral orchestration: open-host refusal, stale-daemon check, daemon-info write, `serve`, graceful shutdown. Domain-free — the app is the caller's `build_app(context: BuildTestingAppContext): Promise<BuiltTestingApp>` seam (`{app, close}`). WebSocket endpoints mount through `create_app_server`'s `ws_endpoints` on every runtime: the build calls `context.prepare_websocket({max_message_bytes?})`, which has the adapter prepare its WebSocket support for `serve` and returns the runtime's `upgradeWebSocket`, to pass as `upgrade_websocket`. Shutdown starts the listener's `shutdown` (stop accepting), runs `close` — which must end live WebSockets, as `AppServer.close` does, and resolve its `ShutdownDrainGivenUp` report — then, on a clean close, awaits the drain, since open sockets would otherwise hold it, and exits `0`; it exits `1` without that wait when the report gave up on anything (`shutdown_gave_up`) — a given-up request still holds its connection — or the close threw, twin of the Rust spine's `StartupError::ShutdownGivenUp`. On `pg` a give-up's `close` can still wait on `pool.end()` for a client a wedged handler holds; the harness defaults to pglet and PGlite. Exports the `TestingServerAdapter` (`prepare_websocket: (options?: PrepareWebsocketOptions) => UpgradeWebSocket`) / `ServeHandle` / `PrepareWebsocketOptions` / `BuildTestingAppContext` interfaces.
1761
1892
  - `testing/daemon_info.ts` — the `~/.{name}/run/daemon.json` plumbing the core's stale-daemon check and daemon-info write use: `DaemonInfo` (a strict `@fuzdev/fuz_schema` object), `get_app_dir`, `get_daemon_info_path`, `write_daemon_info` (atomic), `read_daemon_info`, `is_daemon_running` (`probe_process`, signal 0 with no program spawned; another user's process or a pid naming no single process reads as not running).
1762
1893
  - `testing/cross_backend/testing_server_node.ts` — `create_node_testing_adapter()` (`@hono/node-server`'s `serve` and module-level `upgradeWebSocket`, over a `ws` `WebSocketServer`). Optional peer deps; only test binaries import them. `prepare_websocket` builds the `ws` server (`noServer: true`) with `maxPayload` at twice `max_message_bytes` (default `DEFAULT_WS_MAX_MESSAGE_BYTES`; `ws`'s own default is 100 MiB), and `serve` hands it to `@hono/node-server`, so a grossly oversized message is refused at the frame layer (`WS_CLOSE_MESSAGE_TOO_BIG` with no reason) before it is buffered whole, while one just over the limit reaches the per-message check, which sends `WS_CLOSE_MESSAGE_TOO_BIG_REASON` as every other backend does. Bun's adapter sets the same multiple as its frame cap (see below).
1763
1894
  - `testing/cross_backend/testing_server_bun.ts` — `create_bun_testing_adapter()` (`Bun.serve` + `@hono/bun`'s module-level `getConnInfo`, `upgradeWebSocket`, and `websocket`; `Bun.serve` declared locally so it typechecks under the Node toolchain). Needs the optional `@hono/bun` peer dep (the counterpart to Node's `@hono/node-server` + `ws`; `Bun.serve` is built in). Reuses `create_node_runtime` (Bun implements the `node:fs`/`node:process` surface). WS is module-level + stateless — the `websocket` handler is threaded into `serve`, where `Bun.serve` wants it. It carries `maxPayloadLength` at twice `max_message_bytes` rather than Bun's 16 MiB default: past its cap Bun drops the socket without a close frame (1006), so the headroom leaves a message just over the limit to the per-message check (`WS_CLOSE_MESSAGE_TOO_BIG`, as on Node), while a grossly oversized one is refused before Bun buffers it whole.
@@ -1765,7 +1896,7 @@ re-roll the serve / daemon-info / drain boilerplate:
1765
1896
  - `testing/cross_backend/full_spine_mount.ts` — `build_full_spine_rpc_actions(deps, options)` — the **full** live RPC mount: the declared bundle **plus** the off-declared-surface families the binary live-mounts (`_testing_*` backdoors, the cell verb set, the opt-in `actor_lookup` / `actor_search` resolvers). `build_full_spine_mount(deps, options)` builds it once for both of the binary's endpoints, returning `FullSpineMount` (`{rpc_actions, ws_actions}`): the WS list is `protocol_actions` plus every RPC action not already among them, then the WS-only room verbs and `room_notification_actions`, twinning the Rust `testing_spine_stub`, which serves one registry on RPC and WS (the one difference is `cancel` — a registered protocol action on TS, owned by the read loop on Rust — and the stub's RPC dispatcher refuses its `ws_only` room verbs). `options.room_registry` is the registry the room verbs, `_testing_room_evict`, and `_testing_reset` (which clears it) share — the binary builds it with `create_spine_room_registry(connections)` (exclusive, the default bounds; the twin of the stub's `stub_room_registry`) over its WS endpoints' connection registry; omitted, one over a fresh connection registry serves enumeration. Single-sources the mount so the binary and the `spine_method_coverage` reconciliation test build the same list. `create_spine_live_rpc_endpoints()` wraps the list, built on stub deps, as one endpoint at `SPINE_RPC_PATH` — the `live_rpc_endpoints` value the conformance table, the differential and the auth-row generator resolve off-surface methods from (no handler built there runs).
1766
1897
  - `testing/cross_backend/ts_spine_backend_config.ts` — `ts_spine_node_backend_config()` / `ts_spine_bun_backend_config()` presets (in-memory pglet, no external infra), the TS analog of `rust_spine_stub_backend_config()`.
1767
1898
 
1768
- fuz_app's own binary (`src/test/cross_backend/testing_spine_server{,_node,_bun}.ts`) is the worked example: one runtime-agnostic `build_spine_app` over `create_app_backend` + `create_app_server`, `build_full_spine_mount`'s lists on one RPC endpoint and two WS endpoints (`/api/ws` and `SPINE_ROLE_GATED_WS_PATH`) sharing one registry, so each socket hears a notification once; `_node` and `_bun` differ only in their adapter. It leaves `auth_cleanup` off, as the Rust stub does — a background pass would delete rows under a running suite; a consumer's binary may schedule it only when nothing its suites seed is already expired (the `expired_session` principal seeds a backdated session row).
1899
+ fuz_app's own binary (`src/test/cross_backend/testing_spine_server{,_node,_bun}.ts`) is the worked example: one runtime-agnostic `build_spine_app` over `create_app_backend` + `create_app_server`, `build_full_spine_mount`'s lists on one RPC endpoint and two WS endpoints (`/api/ws` and `SPINE_ROLE_GATED_WS_PATH`) sharing one registry, so each socket hears a notification once; `_node` and `_bun` differ only in their adapter. It leaves `auth_cleanup` off, as the Rust stub does — a background pass would delete rows under a running suite; a consumer's binary may schedule it only when nothing its suites seed is already expired (the `expired_session` and `expired_token` principals leave expired credential rows).
1769
1900
 
1770
1901
  `capabilities.sse` is a mount flag, so each config states it; a consumer
1771
1902
  binary that doesn't wire `audit_log_sse` states `false`. The real-HTTP
@@ -30,7 +30,7 @@ export interface StandardAdminIntegrationTestOptions {
30
30
  rpc_endpoints: RpcEndpointsSuiteOption;
31
31
  /**
32
32
  * Path prefix where admin routes are mounted (e.g., `'/api/admin'`).
33
- * Used by the 401/403 error-coverage probe to scope to fuz_app admin
33
+ * Used by the 401 error-coverage probe to scope to fuz_app admin
34
34
  * routes only, avoiding app-specific admin-gated routes that may use
35
35
  * stub deps. Default `'/api/admin'`.
36
36
  */
@@ -41,7 +41,7 @@ export interface StandardAdminIntegrationTestOptions {
41
41
  *
42
42
  * Exercises account listing, role_grant grant/revoke (via RPC), session
43
43
  * management, token management, audit log reads, admin-to-admin
44
- * isolation, and 401/403 error-coverage on the admin REST surface.
44
+ * isolation, and 401 error-coverage on the admin REST surface.
45
45
  * Output-schema conformance is not in scope — see the module docstring
46
46
  * for the suites that cover it.
47
47
  *
@@ -1 +1 @@
1
- {"version":3,"file":"admin_integration.d.ts","sourceRoot":"","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAgC7B,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAYvE,OAAO,EAMN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AA4B1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAC;AAavE;;GAEG;AACH,MAAM,WAAW,mCAAmC;IACnD;;;;OAIG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,+GAA+G;IAC/G,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yGAAyG;IACzG,KAAK,EAAE,YAAY,CAAC;IACpB;;;OAGG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAiBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yCAAyC,GACrD,SAAS,mCAAmC,KAC1C,IAg+BF,CAAC"}
1
+ {"version":3,"file":"admin_integration.d.ts","sourceRoot":"","sources":["../../src/lib/testing/admin_integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAiC7B,OAAO,EAAc,KAAK,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAYvE,OAAO,EAMN,KAAK,uBAAuB,EAC5B,MAAM,kBAAkB,CAAC;AA4B1B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAC;AAavE;;GAEG;AACH,MAAM,WAAW,mCAAmC;IACnD;;;;OAIG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;OAIG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,+GAA+G;IAC/G,mBAAmB,EAAE,MAAM,CAAC;IAC5B,yGAAyG;IACzG,KAAK,EAAE,YAAY,CAAC;IACpB;;;OAGG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAiBD;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,yCAAyC,GACrD,SAAS,mCAAmC,KAC1C,IAg/BF,CAAC"}