@fuzdev/fuz_app 0.185.0 → 0.187.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 (131) hide show
  1. package/dist/actions/CLAUDE.md +14 -2
  2. package/dist/actions/perform_action.d.ts.map +1 -1
  3. package/dist/actions/perform_action.js +36 -5
  4. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  5. package/dist/actions/ws_socket_session.js +3 -1
  6. package/dist/auth/CLAUDE.md +17 -6
  7. package/dist/auth/account_queries.d.ts +60 -44
  8. package/dist/auth/account_queries.d.ts.map +1 -1
  9. package/dist/auth/account_queries.js +64 -54
  10. package/dist/auth/account_routes.d.ts.map +1 -1
  11. package/dist/auth/account_routes.js +59 -25
  12. package/dist/auth/admin_actions.d.ts.map +1 -1
  13. package/dist/auth/admin_actions.js +26 -9
  14. package/dist/auth/audit_emitter.js +2 -2
  15. package/dist/auth/audit_log_queries.d.ts +11 -3
  16. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  17. package/dist/auth/audit_log_queries.js +4 -4
  18. package/dist/auth/audit_log_schema.js +1 -1
  19. package/dist/auth/auth_ddl.d.ts.map +1 -1
  20. package/dist/auth/auth_ddl.js +4 -0
  21. package/dist/auth/cleanup.js +1 -1
  22. package/dist/auth/migrations.d.ts.map +1 -1
  23. package/dist/auth/migrations.js +35 -0
  24. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  25. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  26. package/dist/auth/role_grant_offer_action_specs.js +2 -1
  27. package/dist/auth/role_grant_offer_actions.d.ts +12 -0
  28. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  29. package/dist/auth/role_grant_offer_actions.js +48 -20
  30. package/dist/auth/role_grant_offer_queries.d.ts +28 -15
  31. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  32. package/dist/auth/role_grant_offer_queries.js +35 -16
  33. package/dist/auth/role_grant_queries.d.ts +118 -20
  34. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  35. package/dist/auth/role_grant_queries.js +145 -24
  36. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  37. package/dist/auth/self_service_role_actions.js +15 -0
  38. package/dist/auth/session_queries.d.ts +24 -0
  39. package/dist/auth/session_queries.d.ts.map +1 -1
  40. package/dist/auth/session_queries.js +28 -0
  41. package/dist/db/CLAUDE.md +3 -3
  42. package/dist/db/cell_ddl.d.ts +8 -3
  43. package/dist/db/cell_ddl.d.ts.map +1 -1
  44. package/dist/db/cell_ddl.js +10 -5
  45. package/dist/db/migrate.d.ts +46 -22
  46. package/dist/db/migrate.d.ts.map +1 -1
  47. package/dist/db/migrate.js +103 -85
  48. package/dist/http/body_limit.d.ts +4 -4
  49. package/dist/http/body_limit.js +4 -4
  50. package/dist/server/app_backend.d.ts.map +1 -1
  51. package/dist/server/app_backend.js +1 -4
  52. package/dist/testing/CLAUDE.md +161 -27
  53. package/dist/testing/app_server.d.ts +5 -7
  54. package/dist/testing/app_server.d.ts.map +1 -1
  55. package/dist/testing/app_server.js +5 -7
  56. package/dist/testing/auth_apps.d.ts +3 -1
  57. package/dist/testing/auth_apps.d.ts.map +1 -1
  58. package/dist/testing/auth_apps.js +22 -5
  59. package/dist/testing/cross_backend/backend_both_live.d.ts +47 -0
  60. package/dist/testing/cross_backend/backend_both_live.d.ts.map +1 -0
  61. package/dist/testing/cross_backend/backend_both_live.js +566 -0
  62. package/dist/testing/cross_backend/backend_config.d.ts +8 -0
  63. package/dist/testing/cross_backend/backend_config.d.ts.map +1 -1
  64. package/dist/testing/cross_backend/backend_log.d.ts +71 -0
  65. package/dist/testing/cross_backend/backend_log.d.ts.map +1 -0
  66. package/dist/testing/cross_backend/backend_log.js +134 -0
  67. package/dist/testing/cross_backend/backend_swap.d.ts +41 -0
  68. package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -0
  69. package/dist/testing/cross_backend/backend_swap.js +267 -0
  70. package/dist/testing/cross_backend/body_size_smuggling.js +3 -3
  71. package/dist/testing/cross_backend/bootstrap_backend.js +4 -4
  72. package/dist/testing/cross_backend/conformance_case.d.ts +11 -6
  73. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  74. package/dist/testing/cross_backend/conformance_case.js +4 -0
  75. package/dist/testing/cross_backend/conformance_principal.d.ts +2 -2
  76. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -1
  77. package/dist/testing/cross_backend/conformance_principal.js +27 -10
  78. package/dist/testing/cross_backend/default_backend_configs.d.ts +38 -5
  79. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  80. package/dist/testing/cross_backend/default_backend_configs.js +50 -15
  81. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  82. package/dist/testing/cross_backend/in_process_setup.js +52 -30
  83. package/dist/testing/cross_backend/revocation_drivers.d.ts +14 -2
  84. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  85. package/dist/testing/cross_backend/revocation_drivers.js +36 -8
  86. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +7 -0
  87. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  88. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -2
  89. package/dist/testing/cross_backend/setup.d.ts +44 -43
  90. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  91. package/dist/testing/cross_backend/setup.js +64 -62
  92. package/dist/testing/cross_backend/shared_database_backends.d.ts +175 -0
  93. package/dist/testing/cross_backend/shared_database_backends.d.ts.map +1 -0
  94. package/dist/testing/cross_backend/shared_database_backends.js +298 -0
  95. package/dist/testing/cross_backend/spawn_backend.d.ts +7 -3
  96. package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
  97. package/dist/testing/cross_backend/spawn_backend.js +86 -7
  98. package/dist/testing/cross_backend/spine_suites.d.ts +1 -1
  99. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  100. package/dist/testing/cross_backend/spine_suites.js +5 -2
  101. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  102. package/dist/testing/cross_backend/sse_round_trip.js +4 -2
  103. package/dist/testing/cross_backend/testing_reset_actions.d.ts +7 -6
  104. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  105. package/dist/testing/cross_backend/testing_reset_actions.js +10 -8
  106. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  107. package/dist/testing/cross_backend/testing_server_bun.js +7 -31
  108. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  109. package/dist/testing/cross_backend/ws_round_trip.js +4 -3
  110. package/dist/testing/data_exposure.d.ts +4 -1
  111. package/dist/testing/data_exposure.d.ts.map +1 -1
  112. package/dist/testing/data_exposure.js +93 -25
  113. package/dist/testing/db_invariants.d.ts +5 -5
  114. package/dist/testing/db_invariants.js +5 -5
  115. package/dist/testing/logged_errors.d.ts +61 -0
  116. package/dist/testing/logged_errors.d.ts.map +1 -0
  117. package/dist/testing/logged_errors.js +285 -0
  118. package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
  119. package/dist/testing/middleware_gate_probes.js +15 -8
  120. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  121. package/dist/testing/rpc_attack_surface.js +41 -16
  122. package/dist/testing/stubs.d.ts +5 -1
  123. package/dist/testing/stubs.d.ts.map +1 -1
  124. package/dist/testing/stubs.js +6 -3
  125. package/dist/testing/test_app.d.ts +40 -11
  126. package/dist/testing/test_app.d.ts.map +1 -1
  127. package/dist/testing/test_app.js +66 -9
  128. package/dist/testing/transports/fetch_transport.d.ts +10 -0
  129. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  130. package/dist/testing/transports/fetch_transport.js +13 -0
  131. package/package.json +5 -3
@@ -50,10 +50,10 @@
50
50
  * holds the connection for a drain window and then closes or, the body
51
51
  * untouched and arriving within the window, reads it off and serves the
52
52
  * next request.
53
- * - **Bun** closes at once, the body unread, honouring the header. Bun 1.4.3
54
- * is the tested floor: an older Bun kept the connection after the `413` and
55
- * served the next request (correctly framed), so run Bun at the floor or
56
- * later.
53
+ * - **Bun** closes at once, the body unread, honouring the header. Bun 1.4.4
54
+ * is the tested floor (CI's pin); the close needs 1.4.3 — an older Bun kept
55
+ * the connection after the `413` and served the next request (correctly
56
+ * framed) — so run Bun at the floor or later.
57
57
  *
58
58
  * @module
59
59
  */
@@ -1 +1 @@
1
- {"version":3,"file":"app_backend.d.ts","sourceRoot":"","sources":["../../src/lib/server/app_backend.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACnF,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAE9F,OAAO,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAkB,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAMjG;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,oIAAoI;IACpI,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAC3D,iEAAiE;IACjE,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EA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4BAA4B,CAAC,EAAE,MAAM,CAAC;CACtC;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,kBAAkB,GAAU,SAAS,uBAAuB,KAAG,OAAO,CAAC,UAAU,CA0D7F,CAAC"}
@@ -63,10 +63,7 @@ export const create_app_backend = async (options) => {
63
63
  // on the success path. Cleanup errors are logged and swallowed so the
64
64
  // caller sees the original failure, not a teardown-shaped one.
65
65
  try {
66
- const migration_results = await run_migrations(db, [
67
- AUTH_MIGRATION_NS,
68
- ...(options.migration_namespaces ?? [])
69
- ]);
66
+ const migration_results = await run_migrations(db, [AUTH_MIGRATION_NS, ...(options.migration_namespaces ?? [])], { log });
70
67
  const audit = audit_factory({
71
68
  db: db.with_checkout_timeout(options.db_audit_checkout_timeout_ms ?? DEFAULT_DB_AUDIT_CHECKOUT_TIMEOUT_MS),
72
69
  log
@@ -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.
@@ -132,6 +132,37 @@ mismatch.
132
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.
133
133
  - `RecordingAuditEmitter` — `{emitter: AuditEmitter; calls: Array<AuditLogInput>}`.
134
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
+
135
166
  ### `token_scope_fixtures.ts` — scope documents built to a size
136
167
 
137
168
  `token_scope_methods_at_bytes(bytes, filler)` — method names whose `methods`
@@ -197,11 +228,12 @@ which the Rust `fuz_testing` embeds byte for byte
197
228
  rows a backend answered), `register_db_invariants_check`,
198
229
  `check_db_invariants_after_all`, `check_db_invariants_after_suite`.
199
230
 
200
- `create_test_app` registers its `assert_db_invariants` to run when the test
201
- that built it finishes (`register_db_invariants_check` — only inside a running
202
- test; skipped when the test already failed), so a direct caller is checked
203
- too; `default_in_process_setup` uses the test app's check, and the
204
- 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
205
237
  own database;
206
238
  cross-process it calls the backend's `_testing_db_invariants` on the keeper's
207
239
  daemon-token channel (unrecorded by a transcript), so `memory://` spawns are
@@ -265,16 +297,32 @@ rate limiter `null` — a limiter passed through `app_options` wins over the
265
297
  mode, so a rate-limit test enables just the one it pins; the mode's stderr
266
298
  banner prints once per module instance — once per test file in an isolated
267
299
  vitest project, once per run under `isolate: false`, ../../../docs/usage.md §Rate limiters), static daemon token state (no rotation, keeper already set),
268
- `await_pending_effects: true` (§Cross-cutting conventions), and a silent
269
- logger. Override via `app_options`. `cleanup()` is the assembled server's idempotent
270
- `close` — it also closes the server's live connections, disposes the
271
- limiters it built, and removes the audit listeners and closer members it
272
- added.
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`.
273
322
 
274
323
  `auth_cleanup` is `'off'` here: a background pass would delete rows and
275
324
  write audit rows mid-test. A suite that opts in through `app_options` has the
276
- schedule stopped by `cleanup()`, which is the assembled server's `close` and
277
- resolves its `ShutdownDrainGivenUp` report.
325
+ schedule stopped by `cleanup()`.
278
326
 
279
327
  A fresh Hono app is created on every call because middleware closures bind
280
328
  to the server's deps (db, keyring). Hono assembly is cheap;
@@ -393,6 +441,66 @@ fuz_app's wiring (TS vs Rust under `cross_backend_parity`, Node vs Bun under
393
441
  `describe_spine_differential_suites`): ../../test/CLAUDE.md §Cross-backend
394
442
  self-tests.
395
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
+
469
+ ## Both spines live
470
+
471
+ `cross_backend/backend_both_live.ts` — `describe_backend_both_live_tests({orders,
472
+ database_url, empty_database, offer_role?, gated_ws_path?})`: two backends over
473
+ one Postgres database at once. Per order, over an emptied database (never
474
+ `_testing_reset`, which would drop what the other spine holds): a boot-state
475
+ phase spawns the second before the first's bootstrap and pins what it keeps
476
+ from its boot — `/status` still advertising bootstrap and its daemon token
477
+ resolving no keeper; a `POST /bootstrap` on it refused by the lock, which
478
+ closes its window but leaves the keeper unresolved — then both stop; the
479
+ boot spawns the first, bootstraps it, then spawns the second, so its daemon
480
+ leg resolves the keeper at assembly. The live cases mint on the first,
481
+ prove the credential on both, revoke on the second and assert the refusal on
482
+ the first at once (logout, session revoke by id, token revoke, password
483
+ change, account delete; an offer accepted on the second conferring on the
484
+ first), each revoke bracketed by drained per-table digests
485
+ (`to_changed_tables`) and followed by both backends' invariant check. The
486
+ declared limits (`docs/security.md` §Single-Process Architecture) are pinned
487
+ by test name: a socket on the first outlives the second's password change,
488
+ logout and token revoke and still answers `account_verify`; a role-gated socket
489
+ outlives the second's role revoke, refused a per-message call needing the role
490
+ and still receiving the account's offer push; an offer made on either spine
491
+ reaches its own socket and no socket on the other. A closing test drains,
492
+ checks and tears down both. Config requirements are the swap's. A standalone
493
+ suite (`STANDALONE_CROSS_SUITES`); fuz_app's wiring is the
494
+ `cross_backend_both_live` project.
495
+
496
+ `cross_backend/shared_database_backends.ts` holds what the two share:
497
+ `to_shared_database_problems` (the config checks), `read_shared_database_snapshot`
498
+ and `to_changed_tables` (per-table content digests), `with_live_backend` /
499
+ `teardown_live_backend` over a `LiveBackend` holder, the transport and RPC
500
+ helpers (`backend_transport`, `backend_rpc`, `backend_rpc_as`,
501
+ `backend_daemon_rpc`, `backend_post_json`), `drain_backend_effects`,
502
+ `assert_backend_invariants`, `verified_account_id` and `passes_admin_gate`.
503
+
396
504
  ## Assertions, coverage, helpers
397
505
 
398
506
  ### `assertions.ts` — surface + error-schema assertions
@@ -508,7 +616,7 @@ adversarial/round-trip tests. A value that is no schema throws, naming it.
508
616
  - `admin_only_field_blocklist` — `['updated_by', 'created_by']`; never in non-admin response bodies.
509
617
  - `collect_json_keys_recursive(value)` — deep walk; returns `Set<string>` of every key at every nesting depth.
510
618
  - `assert_no_sensitive_fields_in_json(body, blocklist, context)` — rejects any key in the blocklist at any depth.
511
- - `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()`.
619
+ - `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()`.
512
620
  - `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.
513
621
 
514
622
  ## Attack surface suites
@@ -761,7 +869,7 @@ The groups:
761
869
  2. **runtime** (DB-backed via `create_test_app`):
762
870
  - `unauthenticated error responses contain no sensitive fields`
763
871
  - `admin routes return 403 for non-admin user` — cross-privilege check
764
- - `all 2xx responses pass field blocklists` — GETs sorted before POSTs so data-returning routes fire before destructive ones (logout, revoke-all) invalidate sessions
872
+ - `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
765
873
 
766
874
  Support functions: `collect_json_schema_property_names(schema)` (walks
767
875
  `properties`/`patternProperties`/`additionalProperties`/`items`/`prefixItems`/`contains`,
@@ -871,8 +979,9 @@ in-process only, an unreadable `Content-Length` → 400 `invalid_content_length`
871
979
  (over a socket Node's parser and hyper answer that one themselves with a
872
980
  bodiless 400, and `fetch` can't send it). Each probe is a request head with no
873
981
  body and no credential, refused before auth, rate limiting and body parsing;
874
- in-process the probes share one fixture. A route whose path has a param or
875
- wildcard segment throws rather than be probed at its literal template.
982
+ in-process the probes share one fixture, built in `beforeAll` and checked
983
+ against the database invariants once they are done. A route whose path has a
984
+ param or wildcard segment throws rather than be probed at its literal template.
876
985
  `send_middleware_gate_probe(probe, base_url, transport)` writes it to the socket
877
986
  with `raw_http_send_head` (`fetch` replaces a caller's `Host` and
878
987
  `Content-Length`), or in-process through the transport, whose `Request` keeps
@@ -1006,7 +1115,7 @@ The groups:
1006
1115
  - wrong role → `forbidden` (-32002)
1007
1116
  - authenticated without role → `forbidden`
1008
1117
  - **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).
1009
- - correct auth passes — valid params (`input_overrides` or generated) reach the method's handler, a recording stub, at 200
1118
+ - 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
1010
1119
  - GET unauthenticated for `side_effects: false` reads
1011
1120
  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.
1012
1121
  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.
@@ -1051,7 +1160,7 @@ have files of their own.
1051
1160
 
1052
1161
  ### Fixture protocol + capabilities
1053
1162
 
1054
- - `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).
1163
+ - `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).
1055
1164
 
1056
1165
  **Keeper ≠ admin.** `fixture.account` holds `[ROLE_KEEPER, ROLE_ADMIN]` as two
1057
1166
  grants, as a production bootstrap does (in-process,
@@ -1079,7 +1188,7 @@ have files of their own.
1079
1188
  host gate off, `host_gate: false`.
1080
1189
 
1081
1190
  No flag covers the body-size smuggling probe (`body_size_smuggling.ts`): every
1082
- backend closes the connection after an oversized-body 413. Bun 1.4.3 is the
1191
+ backend closes the connection after an oversized-body 413. Bun 1.4.4 is the
1083
1192
  tested floor.
1084
1193
 
1085
1194
  ### `cross_backend/standard_bundle.ts` — `describe_standard_cross_process_tests`
@@ -1365,7 +1474,7 @@ without.
1365
1474
  | `actor_lookup` | the keeper resolves its own actor in the leak-safe wire shape (the refusals are table rows) | — |
1366
1475
  | `app_settings` | an anonymous signup reads `open_signup` fresh after `app_settings_update` | — |
1367
1476
  | `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 | — |
1368
- | `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) | — |
1477
+ | `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) | — |
1369
1478
  | `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) |
1370
1479
  | `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`) |
1371
1480
  | `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` |
@@ -1440,7 +1549,8 @@ What the suites share:
1440
1549
  → `AccountRevocation` rows, the account-wide revocations the WS and SSE
1441
1550
  suites each close a live connection on, so a row added there is covered on
1442
1551
  both. The drivers stand alone too (`cross_post_as`,
1443
- `cross_admin_token_revoke_all`, `cross_account_purge`).
1552
+ `cross_admin_token_revoke_all`, `cross_account_purge`,
1553
+ `cross_session_revoke_current`).
1444
1554
  - **`cross_backend/ws_endpoint.ts`** — `WsEndpointTarget` and
1445
1555
  `open_session_ws` (see §Cross-process plumbing), and
1446
1556
  `assert_ws_upgrade_refused(open, status)`, which holds a refused upgrade to
@@ -1531,7 +1641,12 @@ Conventions that hold across them:
1531
1641
  family builders a consumer config composes: the env baseline (`HOST` bound
1532
1642
  to `DEFAULT_TEST_BACKEND_HOST`, `127.0.0.1`; the port under
1533
1643
  `port_env_var`; cookie keys; allowed origins; the bootstrap token path; the
1534
- Rust startup self-wipe), the default paths, and the required `capabilities`.
1644
+ TS family's `PUBLIC_LOG_LEVEL`, `TS_BACKEND_LOG_LEVEL` — the spawned binary
1645
+ inherits `VITEST`, which turns every fuz_util `Logger` off; the Rust startup
1646
+ self-wipe, off with `reset_db_on_startup: false`), the default paths, the
1647
+ `log` (`backend.log` under the temp root,
1648
+ `SPINE_CROSS_SUITE_BACKEND_ERRORS` plus `log_allow_errors` allowed;
1649
+ `log_path: null` for none), and the required `capabilities`.
1535
1650
  `daemon_token_dir_env` names the env var the binary reads its daemon-token
1536
1651
  directory from, set to the `{dir}` whose `{dir}/run/daemon_token` is the
1537
1652
  bootstrap's `daemon_token_path` (`to_daemon_token_dir`, which throws for a
@@ -1597,13 +1712,32 @@ Conventions that hold across them:
1597
1712
  exit during the run, or a group teardown gave up on — naming the backend,
1598
1713
  the exit and the stderr tail, so every global setup that awaits it fails
1599
1714
  the run on an unclean shutdown; the dual-spawn setup tears both down before
1600
- it throws.
1715
+ it throws. With `config.log` it tees stdout and stderr, whole lines per
1716
+ stream, into `log.path`, and teardown also rejects on each error-level line
1717
+ there no `log.allow_errors` entry names (`backend_log.ts`).
1718
+ - `testing/cross_backend/backend_log.ts` — `BackendLogConfig` (`{path,
1719
+ allow_errors}`), `BackendLogAllowance` (`{pattern, reason}`, a substring:
1720
+ configs cross to the workers through `provide`), `is_backend_error_line`
1721
+ (a `Logger` `🞩error🞩` line, a `tracing` `ERROR` event, or a Rust panic's
1722
+ first line, ANSI stripped; a
1723
+ bare `console.error` has no marker and is not seen),
1724
+ `find_unexpected_backend_errors`, `format_unexpected_backend_errors`,
1725
+ `with_backend_log_allowances(config, allow)`, and
1726
+ `SPINE_CROSS_SUITE_BACKEND_ERRORS` — what the shipped suites provoke on
1727
+ purpose (`fact_serving`'s masked 404 on both spines), which both family
1728
+ builders allow. `create_log_line_splitter` is how each stream is written
1729
+ whole lines at a time, decoding across chunks. A failed log write fails
1730
+ teardown. A line is not attributed to its test; a per-test check would need
1731
+ a log backdoor on both spines.
1601
1732
  - `testing/transports/fetch_transport.ts` — cookie-threading HTTP transport
1602
1733
  satisfying `RpcTestTransport`. Carries a name-keyed cookie jar that
1603
1734
  updates on every response's `Set-Cookie` and re-sends on every request;
1604
1735
  `Origin` defaults to `base_url` (`origin: null` disables for bearer-only
1605
1736
  paths). A cookie cleared with `Max-Age` of zero or less leaves the jar, as
1606
- it leaves a browser's. Exposes `cookies()` so `ws_transport` can thread the session
1737
+ it leaves a browser's. A request naming `Authorization` or `X-Daemon-Token`
1738
+ and no `Cookie` throws while the jar is non-empty, since the jar's cookie
1739
+ would authenticate beside a dead token; send it over a cookie-free
1740
+ transport, or pass `Cookie` to send both on purpose. Exposes `cookies()` so `ws_transport` can thread the session
1607
1741
  cookie onto the WS upgrade.
1608
1742
  - `testing/transports/bootstrap.ts` — stateless `bootstrap({transport, config})`
1609
1743
  POSTs `/api/account/bootstrap` against the running binary, parses the
@@ -1718,7 +1852,7 @@ Conventions that hold across them:
1718
1852
  | `_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 |
1719
1853
  | `_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) |
1720
1854
  | `_testing_db_invariants` | yes | every row breaking a `DB_INVARIANTS` check, read after each test |
1721
- | `_testing_mint_session` | yes | a backdated session row behind a valid cookie (the `expired_session` principal) |
1855
+ | `_testing_mint_session` | yes | a backdated session row behind a valid cookie, on any account (a dead session no wire path leaves) |
1722
1856
  | `_testing_put_fact` | yes | seeds a fact, with an optional holder or external URL |
1723
1857
  | `_testing_flood_notifications` | yes | queues notifications onto the caller's socket past its outbound budget (`invalid_params` past its caps, `no_connection` over HTTP) |
1724
1858
  | `_testing_schema_snapshot`, `_testing_migration_tracker` | yes | the parity gates' reads |
@@ -1797,7 +1931,7 @@ re-roll the serve / daemon-info / drain boilerplate:
1797
1931
  - `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).
1798
1932
  - `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()`.
1799
1933
 
1800
- 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).
1934
+ 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).
1801
1935
 
1802
1936
  `capabilities.sse` is a mount flag, so each config states it; a consumer
1803
1937
  binary that doesn't wire `audit_log_sse` states `false`. The real-HTTP
@@ -87,13 +87,11 @@ export interface MintTestSessionOptions {
87
87
  /**
88
88
  * Mint a real `auth_session` row for an existing account and return a
89
89
  * validly-signed session cookie value referencing it, with the row's id (the
90
- * token's hash) for a caller that revokes it. Test-only — the
91
- * forge behind the cross-backend expiry conformance cases (the
92
- * `expired_session` principal): pass a negative `expires_in_seconds` to
93
- * produce an *expired server-side session* whose signed cookie envelope is
94
- * still well-formed. Both the TS `_testing_mint_session` action and the
95
- * in-process `fixture.mint_expired_session()` seam call this so the write
96
- * semantics match across transports.
90
+ * token's hash) for a caller that revokes it. Test-only: pass a negative
91
+ * `expires_in_seconds` to produce an *expired server-side session* whose
92
+ * signed cookie envelope is still well-formed — what the TS
93
+ * `_testing_mint_session` action writes through, so its rows match the Rust
94
+ * twin's.
97
95
  *
98
96
  * @mutates `options.db` — inserts one `auth_session` row.
99
97
  */
@@ -1 +1 @@
1
- {"version":3,"file":"app_server.d.ts","sourceRoot":"","sources":["../../src/lib/testing/app_server.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAsB7B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAIpD,OAAO,EAAkB,KAAK,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAElE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAW5D,OAAO,EAAkB,KAAK,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAI3E,OAAO,EAEN,K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G;AACH,eAAO,MAAM,kCAAkC,QAAO,IAAI,CACzD,gBAAgB,EAChB,iBAAiB,GAAG,OAAO,GAAG,YAAY,CAa1C,CAAC"}
@@ -143,13 +143,11 @@ export const create_test_account_with_credentials = async (options) => {
143
143
  /**
144
144
  * Mint a real `auth_session` row for an existing account and return a
145
145
  * validly-signed session cookie value referencing it, with the row's id (the
146
- * token's hash) for a caller that revokes it. Test-only — the
147
- * forge behind the cross-backend expiry conformance cases (the
148
- * `expired_session` principal): pass a negative `expires_in_seconds` to
149
- * produce an *expired server-side session* whose signed cookie envelope is
150
- * still well-formed. Both the TS `_testing_mint_session` action and the
151
- * in-process `fixture.mint_expired_session()` seam call this so the write
152
- * semantics match across transports.
146
+ * token's hash) for a caller that revokes it. Test-only: pass a negative
147
+ * `expires_in_seconds` to produce an *expired server-side session* whose
148
+ * signed cookie envelope is still well-formed — what the TS
149
+ * `_testing_mint_session` action writes through, so its rows match the Rust
150
+ * twin's.
153
151
  *
154
152
  * @mutates `options.db` — inserts one `auth_session` row.
155
153
  */
@@ -17,7 +17,9 @@ import { type RequestContext } from '../auth/request_context.js';
17
17
  */
18
18
  export declare const create_test_request_context: (role?: string) => RequestContext;
19
19
  /**
20
- * Create a Hono test app from route specs with optional auth context.
20
+ * Create a Hono test app from route specs with optional auth context. Each
21
+ * request's pending and post-commit effects are flushed before its response
22
+ * returns, as `create_test_app` awaits them.
21
23
  *
22
24
  * @param route_specs - the route specs to register
23
25
  * @param auth_ctx - optional request context to inject via middleware
@@ -1 +1 @@
1
- {"version":3,"file":"auth_apps.d.ts","sourceRoot":"","sources":["../../src/lib/testing/auth_apps.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;GAOG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,uBAAu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-20,6 +20,7 @@ import { RESOLVED_AUTH_KEY, TEST_CONTEXT_PRESET, TEST_CONTEXT_PRESET_KEY } from
20
20
  import { create_test_resolved_auth } from './resolved_auth.js';
21
21
  import { create_stub_db } from './stubs.js';
22
22
  import { create_sse_stream } from '../realtime/sse.js';
23
+ import { flush_request_effects } from '../http/pending_effects.js';
23
24
  import { create_test_account, create_test_actor, create_test_role_grant } from './entities.js';
24
25
  /**
25
26
  * Create a mock `RequestContext` with optional role role_grant.
@@ -30,7 +31,9 @@ export const create_test_request_context = (role) => ({
30
31
  role_grants: role ? [create_test_role_grant({ id: 'perm_1', actor_id: 'act_1', role })] : []
31
32
  });
32
33
  /**
33
- * Create a Hono test app from route specs with optional auth context.
34
+ * Create a Hono test app from route specs with optional auth context. Each
35
+ * request's pending and post-commit effects are flushed before its response
36
+ * returns, as `create_test_app` awaits them.
34
37
  *
35
38
  * @param route_specs - the route specs to register
36
39
  * @param auth_ctx - optional request context to inject via middleware
@@ -39,9 +42,12 @@ export const create_test_request_context = (role) => ({
39
42
  export const create_test_app_from_specs = (route_specs, auth_ctx, credential_type) => {
40
43
  const app = new Hono();
41
44
  const db = create_stub_db();
45
+ const log = new Logger('test', { level: 'off' });
42
46
  app.use('/*', async (c, next) => {
43
- c.set('pending_effects', []);
44
- c.set('post_commit_effects', []);
47
+ const pending_effects = [];
48
+ const post_commit_effects = [];
49
+ c.set('pending_effects', pending_effects);
50
+ c.set('post_commit_effects', post_commit_effects);
45
51
  if (auth_ctx) {
46
52
  c.set(RESOLVED_AUTH_KEY, create_test_resolved_auth({
47
53
  credential_type: credential_type ?? CREDENTIAL_TYPE_SESSION,
@@ -50,9 +56,20 @@ export const create_test_app_from_specs = (route_specs, auth_ctx, credential_typ
50
56
  c.set(REQUEST_CONTEXT_KEY, auth_ctx);
51
57
  c.set(TEST_CONTEXT_PRESET_KEY, TEST_CONTEXT_PRESET);
52
58
  }
53
- await next();
59
+ // flushed as the server's pending-effects layer flushes them, and awaited
60
+ // as `await_pending_effects: true` awaits them, so a handler's effects
61
+ // run within the request that queued them
62
+ try {
63
+ await next();
64
+ }
65
+ finally {
66
+ await flush_request_effects(pending_effects, post_commit_effects, log);
67
+ }
68
+ });
69
+ apply_route_specs(app, route_specs, fuz_auth_guard_resolver, log, db, {
70
+ authorize: create_fuz_authorization_handler({ db }),
71
+ open_sse: create_sse_stream
54
72
  });
55
- apply_route_specs(app, route_specs, fuz_auth_guard_resolver, new Logger('test', { level: 'off' }), db, { authorize: create_fuz_authorization_handler({ db }), open_sse: create_sse_stream });
56
73
  return app;
57
74
  };
58
75
  /**
@@ -0,0 +1,47 @@
1
+ import '../assert_dev_env.js';
2
+ import type { BackendConfig } from './backend_config.js';
3
+ /** One order: `first` boots and bootstraps, `second` boots over it; both then run at once. */
4
+ export interface BackendBothLiveOrder {
5
+ /** Names the order's `describe`. */
6
+ readonly label: string;
7
+ readonly first: BackendConfig;
8
+ readonly second: BackendConfig;
9
+ }
10
+ /** Options for `describe_backend_both_live_tests`. */
11
+ export interface BackendBothLiveTestOptions {
12
+ /** The orders to run, one after another over the one database. */
13
+ readonly orders: ReadonlyArray<BackendBothLiveOrder>;
14
+ /**
15
+ * The `postgres://` database both configs run over, read directly for the
16
+ * snapshots — each config's `DATABASE_URL` env must be this exact string.
17
+ */
18
+ readonly database_url: string;
19
+ /**
20
+ * Empty the database — each order calls it before each of its two spawn
21
+ * sequences, so the keeper bootstrap finds no account. The caller owns the
22
+ * guard on which database it drops (`empty_owned_database`).
23
+ */
24
+ readonly empty_database: () => Promise<void>;
25
+ /**
26
+ * The role of the offer the notification case makes on the first — one the
27
+ * keeper may offer, other than `admin`, which the gated socket's grant, the
28
+ * accepted offer and the reverse notification offer use. Default
29
+ * `SPINE_PARTICIPANT_ROLE`, which the reference spines register.
30
+ */
31
+ readonly offer_role?: string;
32
+ /**
33
+ * The first backend's role-gated WebSocket endpoint, which must admit a
34
+ * global `admin` grant. Default `SPINE_ROLE_GATED_WS_PATH`.
35
+ */
36
+ readonly gated_ws_path?: string;
37
+ }
38
+ /**
39
+ * Describe both spines live over each order (§module doc): per order, the
40
+ * boot-state limits, the boot, the live cross-spine credential cases, the
41
+ * declared per-process limits, and the close, run in turn. Each test after the
42
+ * boot fails naming it when the boot did not complete.
43
+ *
44
+ * @param options - the orders, the shared database, and how to empty it
45
+ */
46
+ export declare const describe_backend_both_live_tests: (options: BackendBothLiveTestOptions) => void;
47
+ //# sourceMappingURL=backend_both_live.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"backend_both_live.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/backend_both_live.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAuF9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA+BzD,8FAA8F;AAC9F,MAAM,WAAW,oBAAoB;IACpC,oCAAoC;IACpC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;CAC/B;AAED,sDAAsD;AACtD,MAAM,WAAW,0BAA0B;IAC1C,kEAAkE;IAClE,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;IACrD;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;OAGG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CAChC;AAsPD;;;;;;;GAOG;AACH,eAAO,MAAM,gCAAgC,GAAI,SAAS,0BAA0B,KAAG,IAkqBtF,CAAC"}