@fuzdev/fuz_app 0.181.0 → 0.183.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 (267) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +28 -10
  3. package/dist/actions/action_rpc.d.ts +11 -1
  4. package/dist/actions/action_rpc.d.ts.map +1 -1
  5. package/dist/actions/action_rpc.js +3 -2
  6. package/dist/actions/action_types.d.ts +16 -1
  7. package/dist/actions/action_types.d.ts.map +1 -1
  8. package/dist/actions/action_types.js +1 -1
  9. package/dist/actions/notification_sender.d.ts +83 -0
  10. package/dist/actions/notification_sender.d.ts.map +1 -0
  11. package/dist/actions/notification_sender.js +85 -0
  12. package/dist/actions/perform_action.d.ts +9 -0
  13. package/dist/actions/perform_action.d.ts.map +1 -1
  14. package/dist/actions/perform_action.js +22 -13
  15. package/dist/actions/register_action_ws.d.ts +14 -0
  16. package/dist/actions/register_action_ws.d.ts.map +1 -1
  17. package/dist/actions/register_action_ws.js +3 -2
  18. package/dist/actions/ws_socket_session.d.ts +3 -0
  19. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  20. package/dist/actions/ws_socket_session.js +2 -1
  21. package/dist/auth/CLAUDE.md +113 -70
  22. package/dist/auth/account_actions.d.ts.map +1 -1
  23. package/dist/auth/account_actions.js +13 -3
  24. package/dist/auth/account_queries.d.ts +158 -16
  25. package/dist/auth/account_queries.d.ts.map +1 -1
  26. package/dist/auth/account_queries.js +189 -18
  27. package/dist/auth/account_routes.d.ts +6 -4
  28. package/dist/auth/account_routes.d.ts.map +1 -1
  29. package/dist/auth/account_routes.js +98 -92
  30. package/dist/auth/admin_actions.d.ts.map +1 -1
  31. package/dist/auth/admin_actions.js +93 -45
  32. package/dist/auth/api_token_queries.d.ts +13 -5
  33. package/dist/auth/api_token_queries.d.ts.map +1 -1
  34. package/dist/auth/api_token_queries.js +24 -9
  35. package/dist/auth/audit_emitter.d.ts +75 -84
  36. package/dist/auth/audit_emitter.d.ts.map +1 -1
  37. package/dist/auth/audit_emitter.js +83 -71
  38. package/dist/auth/audit_log_schema.d.ts +10 -5
  39. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  40. package/dist/auth/audit_log_schema.js +22 -6
  41. package/dist/auth/bearer_auth.d.ts.map +1 -1
  42. package/dist/auth/bearer_auth.js +3 -2
  43. package/dist/auth/bootstrap_account.d.ts +31 -13
  44. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_account.js +34 -15
  46. package/dist/auth/bootstrap_routes.d.ts +1 -1
  47. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_routes.js +7 -14
  49. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  50. package/dist/auth/daemon_token_middleware.js +12 -1
  51. package/dist/auth/deps.d.ts +18 -5
  52. package/dist/auth/deps.d.ts.map +1 -1
  53. package/dist/auth/deps.js +3 -2
  54. package/dist/auth/request_context.d.ts +73 -73
  55. package/dist/auth/request_context.d.ts.map +1 -1
  56. package/dist/auth/request_context.js +78 -96
  57. package/dist/auth/resolved_auth.d.ts +16 -11
  58. package/dist/auth/resolved_auth.d.ts.map +1 -1
  59. package/dist/auth/resolved_auth.js +6 -6
  60. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  61. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  62. package/dist/auth/role_grant_offer_action_specs.js +2 -1
  63. package/dist/auth/role_grant_offer_actions.d.ts +32 -12
  64. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  65. package/dist/auth/role_grant_offer_actions.js +91 -116
  66. package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
  67. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  68. package/dist/auth/role_grant_offer_notifications.js +75 -22
  69. package/dist/auth/role_grant_offer_queries.d.ts +155 -18
  70. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  71. package/dist/auth/role_grant_offer_queries.js +262 -73
  72. package/dist/auth/role_grant_offer_schema.js +1 -1
  73. package/dist/auth/role_grant_queries.d.ts +43 -52
  74. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  75. package/dist/auth/role_grant_queries.js +50 -74
  76. package/dist/auth/role_grant_sql.d.ts +21 -0
  77. package/dist/auth/role_grant_sql.d.ts.map +1 -1
  78. package/dist/auth/role_grant_sql.js +21 -0
  79. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  80. package/dist/auth/self_service_role_actions.js +17 -21
  81. package/dist/auth/session_queries.d.ts +40 -16
  82. package/dist/auth/session_queries.d.ts.map +1 -1
  83. package/dist/auth/session_queries.js +68 -29
  84. package/dist/auth/signup_routes.d.ts.map +1 -1
  85. package/dist/auth/signup_routes.js +90 -38
  86. package/dist/auth/standard_rpc_actions.d.ts +6 -19
  87. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  88. package/dist/auth/standard_rpc_actions.js +5 -6
  89. package/dist/auth/token_scope.d.ts +1 -1
  90. package/dist/auth/token_scope.js +1 -1
  91. package/dist/db/sql_columns.d.ts +1 -1
  92. package/dist/db/sql_columns.js +1 -1
  93. package/dist/http/CLAUDE.md +22 -16
  94. package/dist/http/auth_shape.d.ts +1 -1
  95. package/dist/http/db_routes.d.ts +7 -22
  96. package/dist/http/db_routes.d.ts.map +1 -1
  97. package/dist/http/db_routes.js +72 -72
  98. package/dist/http/error_schemas.d.ts +9 -21
  99. package/dist/http/error_schemas.d.ts.map +1 -1
  100. package/dist/http/error_schemas.js +14 -24
  101. package/dist/http/pending_effects.d.ts +42 -4
  102. package/dist/http/pending_effects.d.ts.map +1 -1
  103. package/dist/http/pending_effects.js +34 -4
  104. package/dist/http/route_spec.d.ts +2 -2
  105. package/dist/server/app_backend.d.ts.map +1 -1
  106. package/dist/server/app_backend.js +3 -1
  107. package/dist/server/app_server.d.ts +69 -18
  108. package/dist/server/app_server.d.ts.map +1 -1
  109. package/dist/server/app_server.js +74 -10
  110. package/dist/server/serve_fact_route.d.ts +3 -3
  111. package/dist/server/serve_fact_route.js +12 -12
  112. package/dist/testing/CLAUDE.md +259 -790
  113. package/dist/testing/adversarial_404.d.ts +6 -1
  114. package/dist/testing/adversarial_404.d.ts.map +1 -1
  115. package/dist/testing/adversarial_404.js +38 -17
  116. package/dist/testing/app_server.d.ts +20 -140
  117. package/dist/testing/app_server.d.ts.map +1 -1
  118. package/dist/testing/app_server.js +48 -125
  119. package/dist/testing/audit_drift_guard.d.ts +11 -6
  120. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  121. package/dist/testing/audit_drift_guard.js +15 -8
  122. package/dist/testing/auth_apps.js +1 -1
  123. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  124. package/dist/testing/cross_backend/account_lifecycle.js +43 -0
  125. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  126. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  127. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  128. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  129. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  130. package/dist/testing/cross_backend/capabilities.js +11 -7
  131. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  132. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  133. package/dist/testing/cross_backend/capability_mounts.js +423 -0
  134. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  135. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  136. package/dist/testing/cross_backend/cell_relations.js +12 -11
  137. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  138. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  139. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  140. package/dist/testing/cross_backend/conformance_table.d.ts +2 -50
  141. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/conformance_table.js +2 -270
  143. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  144. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  145. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  146. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  147. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  148. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  149. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  150. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  151. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  152. package/dist/testing/cross_backend/declared_skips.js +132 -0
  153. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
  154. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  155. package/dist/testing/cross_backend/default_spine_surface.js +2 -6
  156. package/dist/testing/cross_backend/differential.d.ts +11 -2
  157. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  158. package/dist/testing/cross_backend/differential.js +35 -11
  159. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  160. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  161. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  162. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -10
  163. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  164. package/dist/testing/cross_backend/full_spine_mount.js +4 -4
  165. package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
  166. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  167. package/dist/testing/cross_backend/in_process_setup.js +151 -134
  168. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  169. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  170. package/dist/testing/cross_backend/login_security.js +21 -4
  171. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  172. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  173. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  174. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  175. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  176. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  177. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  178. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  179. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  180. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  181. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
  182. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  183. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +183 -30
  184. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  185. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  186. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  187. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  188. package/dist/testing/cross_backend/session_cap.js +48 -16
  189. package/dist/testing/cross_backend/setup.d.ts +31 -1
  190. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  191. package/dist/testing/cross_backend/setup.js +32 -1
  192. package/dist/testing/cross_backend/spine_suites.d.ts +123 -12
  193. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  194. package/dist/testing/cross_backend/spine_suites.js +454 -57
  195. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  196. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  198. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  199. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  200. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  201. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  202. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  203. package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
  204. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  205. package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
  206. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  207. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  208. package/dist/testing/cross_backend/transport_composition.js +7 -3
  209. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  210. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  211. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  212. package/dist/testing/data_exposure.d.ts.map +1 -1
  213. package/dist/testing/data_exposure.js +3 -0
  214. package/dist/testing/db.d.ts +0 -32
  215. package/dist/testing/db.d.ts.map +1 -1
  216. package/dist/testing/db.js +0 -86
  217. package/dist/testing/db_entities.d.ts +14 -0
  218. package/dist/testing/db_entities.d.ts.map +1 -1
  219. package/dist/testing/db_entities.js +17 -0
  220. package/dist/testing/db_invariant_queries.d.ts +259 -0
  221. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  222. package/dist/testing/db_invariant_queries.js +400 -0
  223. package/dist/testing/db_invariants.d.ts +106 -0
  224. package/dist/testing/db_invariants.d.ts.map +1 -0
  225. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  226. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  227. package/dist/testing/db_invariants.gen.sql.js +13 -0
  228. package/dist/testing/db_invariants.js +141 -0
  229. package/dist/testing/db_invariants.sql +152 -0
  230. package/dist/testing/describe_db.d.ts +36 -0
  231. package/dist/testing/describe_db.d.ts.map +1 -0
  232. package/dist/testing/describe_db.js +71 -0
  233. package/dist/testing/integration.d.ts +6 -9
  234. package/dist/testing/integration.d.ts.map +1 -1
  235. package/dist/testing/integration.js +9 -13
  236. package/dist/testing/integration_helpers.d.ts +1 -1
  237. package/dist/testing/integration_helpers.d.ts.map +1 -1
  238. package/dist/testing/middleware.d.ts +1 -1
  239. package/dist/testing/middleware.js +5 -5
  240. package/dist/testing/rate_limiting.d.ts +1 -1
  241. package/dist/testing/rate_limiting.d.ts.map +1 -1
  242. package/dist/testing/rate_limiting.js +3 -2
  243. package/dist/testing/resolved_auth.d.ts +3 -1
  244. package/dist/testing/resolved_auth.d.ts.map +1 -1
  245. package/dist/testing/resolved_auth.js +4 -4
  246. package/dist/testing/role_grant_helpers.d.ts +1 -1
  247. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  248. package/dist/testing/round_trip.d.ts.map +1 -1
  249. package/dist/testing/round_trip.js +3 -0
  250. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  251. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  252. package/dist/testing/rpc_attack_surface.js +69 -6
  253. package/dist/testing/rpc_round_trip.d.ts +1 -1
  254. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  255. package/dist/testing/rpc_round_trip.js +3 -0
  256. package/dist/testing/sse_round_trip.d.ts +1 -1
  257. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  258. package/dist/testing/sse_round_trip.js +13 -4
  259. package/dist/testing/stubs.d.ts +4 -2
  260. package/dist/testing/stubs.d.ts.map +1 -1
  261. package/dist/testing/stubs.js +15 -7
  262. package/dist/testing/test_app.d.ts +166 -0
  263. package/dist/testing/test_app.d.ts.map +1 -0
  264. package/dist/testing/test_app.js +124 -0
  265. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  266. package/dist/testing/ws_round_trip.js +8 -4
  267. package/package.json +1 -1
@@ -33,13 +33,13 @@ 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 an assembly's sample cookie mint runs; nothing else of it does anything), no-op password, a `create_noop_stub` DB, silent `Logger`, no-op `audit`, an empty `connection_closer`.
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, `is_tracking_inflight` returns `false`.
36
+ - `create_stub_app_deps()` — factory: fresh `AppDeps` with a stub keyring (`sign` answers `<value>.stub_signature`, so an assembly's sample cookie mint runs; 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`.
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
- - `create_stub_api_middleware({include_daemon_token?, origin_carve_outs?})` — stub `MiddlewareSpec[]` matching `create_auth_middleware_specs`'s output (origin, optional daemon_token, session, request_context, bearer_auth) for surface generation without booting real auth — the same names, paths, order, and declared `errors` (`origin` declares a 403; `bearer_auth` and `daemon_token` declare none, since both soft-fail through `next()`), pinned against the real factory by `auth/middleware.mounted.test.ts`. The surface merges middleware errors into every route under the path, so a stub declaring more would widen the test surface with statuses the live server never returns. Each spec gets its own pass-through handler (not the shared `stub_mw`), so `assert_middleware_stack_mounted` tells the layers apart. See `auth/CLAUDE.md` §Middleware for the real stack.
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. See `auth/CLAUDE.md` §Middleware for the real stack.
40
40
  - `create_stub_app_backend(options?)` — stub `AppBackend` with no database: `create_stub_app_deps()` (or `options.deps`), no migration results, a `close` that does nothing (or `options.close`). For assembling a server in tests that never reach the database.
41
41
  - `create_stub_app_server_context(session_options)` — stub `AppServerContext` over `create_stub_app_backend()`; rate limiters null, `bootstrap_status.available: false`.
42
- - `create_test_app_surface_spec(options)` — builds an `AppSurfaceSpec` mirroring `create_app_server`'s route assembly, in its order (consumer routes, then bootstrap routes, RPC endpoint routes, and `GET /api/surface`, + stub middleware + surface generation). `GET /api/surface` is listed only with `surface_route: true`, as `create_app_server` mounts it only when opted in — pass the same value to both so the surface-derived suites probe it exactly when the live server serves it. `daemon_token: true` lists the `daemon_token` layer `create_app_server` mounts when given a `daemon_token_state` (`create_test_app` always passes one, and `default_in_process_suite_options` sets it, along with `app_options.surface_route`); `testing/test_app_server.db.test.ts` pins the stub's routes (order, auth, error schemas, applicable middleware) and middleware names against `create_test_app`'s for every `surface_route` setting. Its middleware list mirrors the real one — the body limit's shape at `'*'` (`body_limit_middleware_shape` with a stub handler, left out with `max_body_size: null`), the host gate's (`host_gate_middleware_shape`, left out with `host_gate: false`), a stub `trusted_proxy` spec at `'*'`, then the stub auth stack — so every route's `applicable_middleware` starts with `body_limit`, `host`, `trusted_proxy` (a route outside `/api/*` lists `['body_limit', 'host', 'trusted_proxy', 'origin']`, since the origin check covers every path, and a route under an origin carve-out drops `origin`), as on the live server, and every route's error map carries the limit's 413 and 400, the host gate's 403 `forbidden_host` and the origin check's 403 `forbidden_origin`. `CreateTestAppSurfaceSpecOptions`: `session_options`, `create_route_specs`, `env_schema?`, `event_specs?`, `rpc_endpoints?`, `ws_endpoints?`, `allowed_origins?`, `origin_carve_outs?`, `transform_middleware?`, `bootstrap?`, `surface_route?`, `daemon_token?`, `max_body_size?`, `host_gate?`. Throws, like `create_app_server`, on an endpoint path outside `AUTH_MIDDLEWARE_PATH` (`assert_endpoint_in_auth_scope`), on a route that reads or mints a credential outside it (`assert_credential_routes_in_auth_scope`), on an origin carve-out that overlaps that scope (`assert_origin_carve_outs_valid`), and on a `transform_middleware` that moves, drops, duplicates, reorders, wraps, or replaces the stub host gate, proxy or auth spec (`assert_middleware_stack_mounted`); the transform receives shallow copies in a fresh array, so an in-place mutation can't slip past the check. Throws on a `ws_endpoints` spec with no `allowed_origins` of its own when no `allowed_origins` option is given (there is no server list to default from). Bootstrap is opt-in (symmetric with `create_app_server` — omit to skip; pass the same value as prod to mount routes at `bootstrap.route_prefix ?? '/api/account'`). Single source of truth for attack-surface tests — track `create_app_server` wiring changes here.
42
+ - `create_test_app_surface_spec(options)` — the `AppSurfaceSpec` `create_app_server` would build, in its order (consumer routes, bootstrap, RPC endpoints, `GET /api/surface` when `surface_route: true` — pass both the same value), over a stub middleware list mirroring the real one (body limit, host gate, `trusted_proxy`, the stub auth stack). Single source of truth for attack-surface tests — track `create_app_server` wiring changes here; `testing/test_app_server.db.test.ts` pins it against `create_test_app`. It throws where `create_app_server` throws (the assembly asserts of `auth/CLAUDE.md` §Middleware, and a `ws_endpoints` spec with no `allowed_origins` when none is given). Options: `CreateTestAppSurfaceSpecOptions` TSDoc.
43
43
 
44
44
  Throwing stubs surface mock escape: a test that accidentally reaches into
45
45
  stub territory breaks immediately with a label-scoped error rather than
@@ -66,7 +66,7 @@ casts — the factory brands internally. Exported as `TestAccountOverrides` /
66
66
 
67
67
  ### `resolved_auth.ts` — `ResolvedAuth` factory
68
68
 
69
- `create_test_resolved_auth({credential_type, account_id, session_id?,
69
+ `create_test_resolved_auth({credential_type, account, session_id?,
70
70
  api_token_id?, scope?, credential_deadline?})` — the `ResolvedAuth` arm for a
71
71
  credential type, as the auth middleware builds it: a session's `session_hash`
72
72
  is `hash_session_token(session_id)` (default a fresh uuid), an API token's id
@@ -81,23 +81,23 @@ harness's `connect`, `create_bearer_auth_test_app`'s `pre_context`.
81
81
  `query_create_account_with_actor` with default `password_hash` (`'hash'`),
82
82
  storing the username lowercased, as every production creation path does and
83
83
  the `account_username_lowercase` CHECK requires.
84
- Returns `{account, actor}`. Replaces the per-file `create_user` /
85
- `create_test_actor` / `create_test_account` helpers that had accumulated
86
- across the auth test suite. Use for query-level tests needing real DB rows
84
+ Returns `{account, actor}`. Use for query-level tests needing real DB rows
87
85
  but not a full session/token bundle. For tests also needing an API token +
88
86
  session cookie + role_grants, use `bootstrap_test_keeper` from `app_server.ts`.
89
87
 
90
- `create_test_extra_actor(db, account_id, name)` adds an actor to an
91
- account — the multi-actor edge — with `created_at` read from the wall clock
92
- (`clock_timestamp()`), not the transaction-fixed `NOW()` default. Actor lists
93
- sort `created_at, id`, so a shared `created_at` would order them by random id;
94
- seeded through it, the account's first actor sorts first and the extras in
95
- insert order. `_testing_reset` and the in-process setup seed `extra_actors`
96
- with it, as the Rust reset does with `query_create_actor_with_clock_timestamp`,
97
- so both spines list a multi-actor keeper's actors in one order. The exception
98
- is `query_admin_account_list`, whose actors sort `created_at, name, id`: it
99
- keeps one actor per account, and a data key ahead of the random id picks the
100
- same one on two backends holding the same rows (under the same text collation).
88
+ `create_test_extra_actor(db, account_id, name)` adds an actor with
89
+ `created_at` from `clock_timestamp()`, so a multi-actor account's actors list
90
+ in insert order (lists sort `created_at, id`). The in-process seed and
91
+ `_testing_reset` use it, as the Rust reset uses
92
+ `query_create_actor_with_clock_timestamp`, so both spines list them alike.
93
+ `query_admin_account_list` is the exception: it sorts `created_at, name, id`
94
+ to keep one actor per account the same on both backends.
95
+
96
+ `create_test_session_row(db, token_hash, account_id, expires_in_seconds)`
97
+ inserts an `auth_session` row expiring that many seconds past the database's
98
+ `NOW()` — negative for one already expired — the statement the Rust
99
+ `_testing_mint_session` runs; `mint_test_session` writes through it. For a
100
+ test needing a lifetime other than `query_create_session`'s full one.
101
101
 
102
102
  `create_test_role_grant_direct(db, input)` wraps `query_create_role_grant`
103
103
  for tests needing an active role_grant seeded directly, bypassing the
@@ -122,10 +122,10 @@ mismatch.
122
122
 
123
123
  ### `audit_drift_guard.ts` — audit-emission validation
124
124
 
125
- - `install_audit_drift_guard()` — `beforeEach` resets + `afterEach` zero-checks the `audit_metadata_validation_failures` + `audit_unknown_event_type_failures` counters from `auth/audit_log_queries.ts` and the emitter's write-failure counter (`get_audit_write_failures` in `auth/audit_emitter.ts`). Call once at the top of any `describe_db` block firing audit emits — production validation and the emitter's write are fail-open, so without this any regression shipping a typo'd `event_type` or undeclared metadata field, or losing a row the database refused, is silent. A test that fails a write on purpose resets the counter (`reset_audit_write_failures`) once it has asserted it.
125
+ - `install_audit_drift_guard()` — `beforeEach` resets + `afterEach` zero-checks the `audit_metadata_validation_failures` + `audit_unknown_event_type_failures` counters from `auth/audit_log_queries.ts` and the emitter's write-failure counter (`get_audit_write_failures` in `auth/audit_emitter.ts`). Call once at the top of any `describe_db` block firing audit emits — production validation and the emitter's write are fail-open, so without this any regression shipping a typo'd `event_type` or undeclared metadata field, or losing a row the database refused, is silent. A test that fails a write on purpose resets the counter (`reset_audit_write_failures`) once it has asserted it. It also zero-checks the success-outside-a-transaction counter (`get_audit_success_outside_transaction`; `reset_audit_success_outside_transaction` for a test that writes one on purpose).
126
126
  - `assert_audit_event_metadata(event, {reject_unknown_keys?})` — the wire-side twin: parses a read audit row's `metadata` against its builtin event type's `audit_metadata_schemas` entry as declared, so a mistyped, `null`, or missing field fails while a consumer-added key passes (the schemas are fuz_schema `loose_object`s, and a builtin's schema can't be overridden, so added keys are a consumer's only extension path). `reject_unknown_keys` closes the world, each `loose_object`'s `def` spread into an `object`: an undeclared key fails too, for a suite whose backend adds none. The wire schema leaves `metadata` a loose record and only the TS spine validates it, at insert and fail-open, so this is what holds every spine's rows to their event's contract. A consumer-registered event type passes unexamined. `list_audit_events` and the admin suite run it on every row they read, with `reject_unknown_keys` from the fixture's `reject_unknown_audit_metadata_keys` (a setup option on `default_cross_process_setup`, `default_in_process_setup` and `default_in_process_suite_options`); fuz_app's own spine wiring turns it on.
127
- - `assert_no_audit_drift()` — the zero-check itself, for a test that manages the counters. Pair with `await_pending_effects: true` (the `create_test_app` default) so fire-and-forget audit writes complete by response time.
128
- - `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. Replaces per-file capturing emitters previously duplicated across `password_change.test.ts`, `audit_log.test.ts`, etc.
127
+ - `assert_no_audit_drift()` — the zero-check itself, for a test that manages the counters. Pair with `await_pending_effects: true`.
128
+ - `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
129
  - `RecordingAuditEmitter` — `{emitter: AuditEmitter; calls: Array<AuditLogInput>}`.
130
130
 
131
131
  ### `token_scope_fixtures.ts` — scope documents built to a size
@@ -140,12 +140,12 @@ measures one. Hono-free, imported by the cross-process token suite.
140
140
 
141
141
  ### `connection_closer_helpers.ts` — `ConnectionCloser` test doubles
142
142
 
143
- - `create_recording_closer()` — `{closer, calls}`; `closer.close_connections(target)` records the `target` and `close_all_connections()` records `{kind: 'all'}` into `calls`, closing nothing. To see a handler's closes, add it to the backend's closer (`ctx.deps.connection_closer.add(closer)`) or build the factory's deps with it. The closes are queued post-commit, so they have run by the time a `create_test_app` response is in hand (`await_pending_effects: true` flushes both queues).
143
+ - `create_recording_closer()` — `{closer, calls}`; `closer.close_connections(target)` records the `target` and `close_all_connections()` records `{kind: 'all'}` into `calls`, closing nothing. To see a handler's closes, add it to the backend's closer (`ctx.deps.connection_closer.add(closer)`) or build the factory's deps with it. The closes are queued post-commit, so they have run by the time a `create_test_app` response is in hand (`await_pending_effects: true`).
144
144
  - `assert_close_call(call, expected)` — pins a recorded close call to `expected` (`assert.deepEqual`); handles the missing-element case.
145
145
  - `RecordedClose` — `ConnectionCloseTarget | {kind: 'all'}`.
146
146
  - `RecordingCloser` — `{closer, calls}`.
147
147
 
148
- ## Database — `db.ts`
148
+ ## Database — `db.ts` + `describe_db.ts`
149
149
 
150
150
  Factory builders for parameterized DB tests. Consumer projects pass their
151
151
  `init_schema` callback (which calls `run_migrations(db, [AUTH_MIGRATION_NS, ...app_migrations])`);
@@ -159,8 +159,12 @@ factories accept any migration namespace set.
159
159
  - `create_pg_factory(init_schema, test_url?)` — PostgreSQL; `skip: true` when `test_url` missing. Each `create()` opens a pool and resets the `public` schema before `init_schema`, like every other factory, so a persistent test database carries no stale DDL; a missing database (`3D000`) gets a `createdb` hint. Pool reused + cleaned up across `create()` calls.
160
160
  - `auth_truncate_tables` — `['invite', 'api_token', 'auth_session', 'role_grant', 'role_grant_offer', 'actor', 'account']` in FK-safe order. Excludes `audit_log` — unit DB tests don't need to truncate it.
161
161
  - `auth_integration_truncate_tables` — `auth_truncate_tables + ['audit_log']` for integration suites that exercise the audit path.
162
- - `create_describe_db(factories, truncate_tables)` — returns `describe_db(name, fn)` running `fn(get_db)` once per factory inside a `describe` with shared `beforeAll(create)` + `beforeEach(TRUNCATE)` + `afterAll(close)`. Skipped factories use `describe.skip`.
163
162
  - `log_db_factory_status(factories)` — console summary of enabled / skipped factories.
163
+
164
+ `db.ts` is vitest-free (`app_server.ts` reaches it, and with it the spawned
165
+ spine binary); the two helpers that call vitest live in `describe_db.ts`:
166
+
167
+ - `create_describe_db(factories, truncate_tables)` — returns `describe_db(name, fn)` running `fn(get_db)` once per factory inside a `describe` with shared `beforeAll(create)` + `beforeEach(TRUNCATE)` + `afterAll(close)`. Skipped factories use `describe.skip`.
164
168
  - `assert_columns_match_live(db, table, columns)` — the named-projection drift guard: asserts a `*_COLUMNS` const (`ACCOUNT_COLUMNS`, `CELL_COLUMNS`, a consumer's own) names exactly the live `public`-schema columns of `table`, via `query_public_columns(db, {table})`. Per module, or iterated from a table → const registry (fuz_app's own: `src/test/db/column_projections.db.test.ts`).
165
169
 
166
170
  **WASM caching.** `create_pglite_factory` and `create_pglet_wasm_factory` each
@@ -172,14 +176,55 @@ with `isolate: false` + `fileParallelism: false` to amortize WASM boot across
172
176
  every DB test file — which also makes that one instance the whole run's; a
173
177
  project that isolates its files gets one per worker instead.
174
178
 
179
+ ### `db_invariant_queries.ts` + `db_invariants.ts` — auth-schema invariants after every test
180
+
181
+ `db_invariant_queries.ts` (vitest-free, so a test binary mounts it) —
182
+ `DB_INVARIANTS`, named SQL checks over the auth tables and `audit_log`, one
183
+ set for both spines; the list, what each holds and how a creation is ordered
184
+ against a removal are the module's TSDoc. `DB_INVARIANTS_SQL` is the whole
185
+ set as one statement (`$1` keeper role, `$2` admin role, each row's columns
186
+ as JSON text); `db_invariants.gen.sql.ts` writes it to `db_invariants.sql`,
187
+ which the Rust `fuz_testing` embeds byte for byte
188
+ (`conformance_table_copies.cross.test.ts` holds the pair).
189
+ `query_db_invariant_rows` / `DbInvariantRows` (the backdoor's answer) /
190
+ `to_db_invariant_violations` / `query_db_invariant_violations` /
191
+ `format_db_invariant_violations`. `db_invariants.ts` holds the hooks:
192
+ `assert_db_invariants` (over a `Db`), `assert_db_invariant_rows` (over
193
+ rows a backend answered), `register_db_invariants_check`,
194
+ `check_db_invariants_after_all`, `check_db_invariants_after_suite`.
195
+
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
201
+ own database;
202
+ cross-process it calls the backend's `_testing_db_invariants` on the keeper's
203
+ daemon-token channel (unrecorded by a transcript), so `memory://` spawns are
204
+ checked too. A backend not declaring `_testing_db_invariants` in
205
+ `capabilities.testing_backdoors` throws at setup unless the setup passes
206
+ `exclude_db_invariants: {all: reason}`. An app or fixture built in `beforeAll` is
207
+ checked once its describe's tests are done (`check_db_invariants_after_all`,
208
+ or `check_db_invariants_after_suite` inside a describe's own closing
209
+ `afterAll`, ahead of the close). Opt out per invariant with `exclude_db_invariants: {[name]:
210
+ reason}` on `create_test_app` or the setup — reason required, validated on
211
+ every call, logged once per distinct set, merged by name in `describe_spine_cross_suites` — for
212
+ tests that write rows by hand without the cascade, or a gap an
213
+ `xfail_until` marker tracks; `all` excludes every one.
214
+
175
215
  ## Test app assembly
176
216
 
177
- ### `app_server.ts`
217
+ ### `app_server.ts` and `test_app.ts`
178
218
 
179
- `create_test_app_server(options)` bootstraps a minimal `AppBackend` with a
180
- keeper account, API token, session cookie, and signed `Keyring`.
219
+ `app_server.ts` is vitest-free (the spawned spine binary, the reset actions
220
+ and fuz_forge's server build import it; `src/test/vitest_free_modules.test.ts`
221
+ holds its import graph to that): `create_test_app_server(options)`
222
+ bootstraps a minimal `AppBackend` with a keeper account, API token, session
223
+ cookie, and signed `Keyring`. `test_app.ts` holds the test-app layer:
181
224
  `create_test_app(options)` layers `create_app_server` on top, returning a
182
- fully assembled Hono app + the backend + helpers.
225
+ fully assembled Hono app + the backend + helpers (and `TestApp`,
226
+ `TestAccount`, `CreateTestAppOptions`, `CreateTestAppAccountArgs`,
227
+ `SuiteAppOptions`, the session/bearer header builders).
183
228
 
184
229
  Key module-scope values:
185
230
 
@@ -203,10 +248,10 @@ do, so the returned `account.username` is its lowercase.
203
248
  Types:
204
249
 
205
250
  - `TestAppServer extends AppBackend` — adds `account`, `actor`, `api_token`, `session_cookie`, `keyring`, `cleanup()`.
206
- - `TestAppServerOptions` — `session_options` (required), optional `db`, `db_type`, `migration_namespaces`, `password`, `username`, `password_value`, `roles`, `audit_factory`. `migration_namespaces` runs extra namespaces after auth in the auto-created in-memory database (mirrors `create_app_backend`); mutually exclusive with `db` (caller-migrated) — passing both throws. The optional `audit_factory` defaults to `default_audit_factory` (no-listener `create_audit_emitter` over the test backend's `{db, log}`); pass a custom factory to compose `on_audit_event` / `audit_log_config`, instrument `emit` with `emit_decorator`, or otherwise replace the emitter. Mirrors `CreateAppBackendOptions` end-to-end — the previous `on_audit_event` / `audit_log_config` sugar was removed alongside the production rename.
207
- - `CreateTestAppOptions extends TestAppServerOptions` — adds `create_route_specs` (required), `rpc_endpoints?: RpcEndpointsSuiteOption` (top-level only — single source of truth, symmetric with the suite-level option), `bootstrap?: BootstrapServerOptions` (top-level only — same precedent as `rpc_endpoints`), and `app_options?: SuiteAppOptions` (`Partial<AppServerOptions>` excluding the five fields the helper manages: `backend`, `session_options`, `create_route_specs`, `rpc_endpoints`, `bootstrap`).
251
+ - `TestAppServerOptions` — `session_options` (required), optional `db`, `db_type`, `migration_namespaces`, `password`, `username`, `password_value`, `roles` (default `DEFAULT_TEST_KEEPER_ROLES`, keeper and admin, as a production bootstrap grants), `audit_factory`. `migration_namespaces` runs extra namespaces after auth in the auto-created in-memory database (mirrors `create_app_backend`); mutually exclusive with `db` (caller-migrated) — passing both throws. The optional `audit_factory` defaults to `default_audit_factory` (no-listener `create_audit_emitter` over the test backend's `{db, log}`); pass a custom factory to compose `on_audit_event` / `audit_log_config`, instrument `emit` with `emit_decorator`, or otherwise replace the emitter. Mirrors `CreateAppBackendOptions`.
252
+ - `CreateTestAppOptions extends TestAppServerOptions` (`test_app.ts`, as `TestAccount`, `TestApp` and `SuiteAppOptions`) — adds `create_route_specs` (required), `rpc_endpoints?: RpcEndpointsSuiteOption` (top-level only — single source of truth, symmetric with the suite-level option), `bootstrap?: BootstrapServerOptions` (top-level only — same precedent as `rpc_endpoints`), and `app_options?: SuiteAppOptions` (`Partial<AppServerOptions>` excluding the five fields the helper manages: `backend`, `session_options`, `create_route_specs`, `rpc_endpoints`, `bootstrap`), and `exclude_db_invariants?` (§`db_invariant_queries.ts` + `db_invariants.ts`).
208
253
  - `TestAccount` — `{account, actor, session_cookie, api_token, create_session_headers, create_bearer_headers}`.
209
- - `TestApp` — `{app, backend, server, surface_spec, surface, route_specs, create_session_headers, create_bearer_headers, create_daemon_token_headers, create_account, cleanup}`. `server` is the assembled `AppServer`, for what `create_app_server` built beyond the lifted fields — `require_audit_sse(test_app.server)` with `audit_log_sse` in `app_options`, `test_app.server.ws_endpoints[path]` — instead of capturing them from a `create_route_specs` closure.
254
+ - `TestApp` — `{app, backend, server, surface_spec, surface, route_specs, create_session_headers, create_bearer_headers, create_daemon_token_headers, create_account, assert_db_invariants, cleanup}`. `server` is the assembled `AppServer`, for what `create_app_server` built beyond the lifted fields — `require_audit_sse(test_app.server)` with `audit_log_sse` in `app_options`, `test_app.server.ws_endpoints[path]` — instead of capturing them from a `create_route_specs` closure.
210
255
 
211
256
  `create_test_app` hard-codes the test-friendly `AppServerOptions`:
212
257
  `allowed_origins` exactly `TEST_ORIGIN` (built by
@@ -216,8 +261,7 @@ rate limiter `null` — a limiter passed through `app_options` wins over the
216
261
  mode, so a rate-limit test enables just the one it pins; the mode's stderr
217
262
  banner prints once per module instance — once per test file in an isolated
218
263
  vitest project, once per run under `isolate: false`, ../../../docs/usage.md §Rate limiters), static daemon token state (no rotation, keeper already set),
219
- **`await_pending_effects: true`** (fire-and-forget effects complete before
220
- the response returns so tests can assert on side effects inline), and silent
264
+ `await_pending_effects: true` (§Cross-cutting conventions), and a silent
221
265
  logger. Override via `app_options`. `cleanup()` is the assembled server's idempotent
222
266
  `close` — it also closes the server's live connections, disposes the
223
267
  limiters it built, and removes the audit listeners and closer members it
@@ -228,7 +272,7 @@ write audit rows mid-test. A suite that opts in through `app_options` has the
228
272
  schedule stopped by `cleanup()`, which is the assembled server's `close`.
229
273
 
230
274
  A fresh Hono app is created on every call because middleware closures bind
231
- to the server's deps (db, keyring). Hono assembly is cheap (~10–50ms);
275
+ to the server's deps (db, keyring). Hono assembly is cheap;
232
276
  the WASM caching in `db.ts` is where the real savings are.
233
277
 
234
278
  ### `auth_apps.ts` — adversarial-auth app factories
@@ -335,87 +379,14 @@ declarations (DDL, the method set), this compares answers. Each impl is the
335
379
  oracle for the other — a case the table pins by status alone, or an extra
336
380
  field a loose output schema passes on one spine, shows up as a difference.
337
381
 
338
- - `cross_backend/differential_normalize.ts` — `normalize_differential_response({status, headers, set_cookies, body}, session_cookie_name)`
339
- → `DifferentialResponse` `{status, body, header_names, session_cookie}`.
340
- `session_cookie` is the response's `SessionCookieEffect`, read by the
341
- classifier the conformance runner uses (`'unrecognized'` for lines in no
342
- known shape), so one spine clearing where the other doesn't, or minting
343
- where the other clears, differs at the path `session_cookie` — header
344
- names alone can't tell a clear from a mint. Volatile values
345
- become positional placeholders per kind (`VOLATILE_VALUE_PATTERNS`: API
346
- tokens, `tok_` token ids, lowercase UUIDs, `ISO8601_SECONDS` timestamps,
347
- bare 64-hex digests — matched inside any string, object keys included): the
348
- first UUID is `<uuid:1>`, a repeat of it `<uuid:1>` again, so identity
349
- relations within one response survive while the values differ across
350
- backends. Placeholders are positional, not tied to fixture identity, so two
351
- ids that appear once each and trade places normalize equal. Only the
352
- canonical spelling is placeholdered — an uppercase UUID or a millisecond
353
- timestamp stays raw and differs — and a `blake3:` content address is
354
- compared verbatim (equal bytes hash equal on both spines). Keys are sorted (and visited
355
- in that order when numbering); array order is kept. `header_names` is the
356
- sorted name set minus `VOLATILE_HEADER_NAMES` (framing and per-request
357
- headers each server sets its own way); values are never compared —
358
- `set-cookie` carries a fresh credential, and the contract header values are
359
- the conformance table's `expect.headers` + no-fingerprint floor.
360
- `diff_differential_responses(a, b)` → `DifferentialDiff[]`, one per leaf
361
- path (`status`, `headers.<name>`, `session_cookie`, `body.error.data.reason`; an object one
362
- side lacks diffs key by key, and an empty one against a missing one at its
363
- own path), `differential_path_covers(covered, path)`,
364
- `format_differential_diffs(diffs, labels)`.
365
- - `cross_backend/differential.ts` —
366
- `describe_differential_conformance_tests({cases, backends: [a, b],
367
- surface_source, rpc_endpoints, live_rpc_endpoints?, session_options,
368
- principals?, known_divergences?, suite_name?})`, each backend `{name,
369
- setup_test, ws?}`; methods resolve as the table resolves them
370
- (`resolve_conformance_rpc_endpoints`).
371
- `ws` on both runs the cases over their WebSocket endpoints, filtered by
372
- `is_ws_conformance_case`, with the ledger checked against what is left; on
373
- one alone, registration throws. Per case, each backend's own `setup_test`
374
- (separate databases and keepers), the principal resolved and the request
375
- sent through `send_conformance_case` (`conformance_table.ts`), both answers
376
- normalized and diffed. Every HTTP request carries
377
- `DIFFERENTIAL_REQUEST_HEADERS` (`accept-encoding: identity`), so a runtime's
378
- own compression (for a request accepting gzip, as Node's `fetch` sends by
379
- default) never reads as a `content-encoding` / `vary`
380
- difference. The per-case `expect` is not asserted —
381
- each backend's conformance leg holds it. `KnownDivergence` is the ledger
382
- row: `{case_name | method, tracking_id, reason, what_differs}`, the names a
383
- string or a list, `what_differs` the diff paths covered (a path covers everything under it; a cookie difference where one side sends no `Set-Cookie` also differs at `headers.set-cookie`, so its entry names both), each a string or a `KnownDivergencePath`
384
- `{path, a?, b?}` pinning the value a side shows there (`undefined` for
385
- nothing). A pin is compared with the normalized leaf value at the differing
386
- path, so a placeholdered value never matches the raw one, an object pin
387
- must list its keys sorted, and a parent-path pin never matches. A case may
388
- differ at the paths of the entries it matches, with their values, and
389
- nowhere else. `xfail_until`'s turns-red semantics clean
390
- the ledger: a case a `case_name` entry names must still show it (checked in
391
- that case's test), a `method` entry must still show on one of its cases
392
- (checked by a closing test once they all ran — a filtered or failed run
393
- leaves it unjudged, and the test skips when nothing was judged), and an
394
- entry matching no case, or listing a case name that doesn't exist or a
395
- method no case sends, fails —
396
- the static half is `check_known_divergence_ledger(cases, ledger)`, exported
397
- for checking a ledger without a backend. No other ignore path exists.
398
-
399
- fuz_app runs it under the `cross_backend_parity` project
400
- (`differential.cross.test.ts`, its ledger `differential_known_divergences.ts`
401
- in `src/test/cross_backend/`): every `conformance_*_cases.ts` array plus the
402
- generated auth rows (over the live mount too, so the cell verbs, the actor
403
- resolvers and the `_testing_*` backdoors are compared), TS spine vs
404
- `testing_spine_stub`, both on Postgres so no engine difference reads as a body
405
- difference. The same cases run again over
406
- WS, against `differential_ws_known_divergences` (the HTTP ledger without its
407
- header row). The multi-actor `conformance_acting_cases.ts` rows run with the
408
- generated rows on a keeper seeded with `extra_actors`, over both transports.
409
- The TS spine runs under `DEV` there, so its DEV-only diagnostics (the
410
- `issues` on `invalid_params`, the `X-Fuz-Auth-Debug` header) are ledger rows.
411
- The suite composition is `describe_spine_differential_suites`
412
- (`src/test/cross_backend/spine_differential.ts`), which takes the two
413
- backends and their ledgers. fuz_app also holds two TS runtimes to each other
414
- with it: the `cross_backend_ts_differential` project
415
- (`differential_ts.cross.test.ts`) dual-spawns the TS spine binary on Node and
416
- on Bun, both on `memory://`, against an empty ledger — both run under `DEV`,
417
- so the DEV-only rows show on both sides and differ nowhere. It needs no Rust
418
- or Postgres and runs in the `cross-ts` CI job.
382
+ - `cross_backend/differential_normalize.ts` — `normalize_differential_response` → `DifferentialResponse` `{status, body, header_names, session_cookie}`: volatile values in their canonical spelling (`VOLATILE_VALUE_PATTERNS`) become positional placeholders, so identity relations inside one response survive; header values are never compared, and the cookie compares as its `SessionCookieEffect`. `diff_differential_responses` → one `DifferentialDiff` per leaf path. The rules are the module's TSDoc.
383
+ - `cross_backend/differential.ts` — `describe_differential_conformance_tests({cases, backends: [a, b], …})`: per case, each backend's own fixture, the request sent through `send_conformance_case`, both answers normalized and diffed (each case's `expect` is its conformance leg's, not asserted here). `ws` on both re-runs the WS-eligible cases over sockets; `db_state` on both also compares the database each case leaves (either on one backend alone throws at registration). The `KnownDivergence` ledger is the only ignore path and turns red like `xfail_until` when an entry stops matching (`check_known_divergence_ledger` is the static half); a pin compares against the normalized value, so it never matches a raw one.
384
+ - `cross_backend/db_state_diff.ts` — `create_db_state_probe(handle)` reads every `public` table but `schema_version` from the backend's own Postgres after draining its audit writes; `normalize_db_state` makes ids, tokens and timestamps comparable; `diff_db_states` names differences `db.<table>[i].<column>`. The normalization rules are the module's TSDoc.
385
+
386
+ fuz_app's wiring (TS vs Rust under `cross_backend_parity`, Node vs Bun under
387
+ `cross_backend_ts_differential`, both through
388
+ `describe_spine_differential_suites`): ../../test/CLAUDE.md §Cross-backend
389
+ self-tests.
419
390
 
420
391
  ## Assertions, coverage, helpers
421
392
 
@@ -515,7 +486,7 @@ adversarial/round-trip tests. A value that is no schema throws, naming it.
515
486
  - `detect_format(field_schema)` — `detect_json_schema_format` over `to_field_json_schema`: the `format`, `'pattern'` for a regex, or `null`.
516
487
  - `generate_valid_value(field, field_schema)` — base-type switch producing a valid sample (UUIDs → nil UUID, strings → `'xxxxxxxxxx'`, numbers → `1`, objects → `generate_valid_object` against the field schema, so a nested refinement is satisfied too, enums → first entry, records → `{}`, a void field → `undefined`, etc.). For branded-string refinements, walks a fallback chain synthesized from the `pattern` string the JSON Schema representation exposes: fixed-length hex (`^[0-9a-f]{N}$` — blake3 / sha256 / md5 digests; `0`.repeat(N)), prefix-lengthed slug (`^<prefix>_[A-Za-z0-9_-]{N}$` — `ApiTokenId`-style ids; `<prefix>_` + `x`.repeat(N)), absolute path prefix, URL prefix, two `/`-joined segments (an `owner/name` slug). First candidate the field accepts is used.
517
488
  - `generate_valid_string_param(field, field_schema)` — a string a URL-sourced field (route param, query value) accepts: the nil UUID for a UUID field, else the first of `test_value`, the generated valid value as a string, `1`, `0`, `true`, `false`, the field's JSON Schema `default` or lower bound as a string, each `min_value` / `max_value` bound anywhere in the schema as an integer (a string parsed into an integer whose range excludes the small candidates, as `db_routes`' `query_int` — bounds past a `transform`, which JSON Schema can't say) and a synthesized string the field accepts; `null` when none does. The params and query case generators build their base from it.
518
- - `resolve_valid_path(path, params_schema?, param_values?)` — swaps each whole param segment (`:name`, `:name{re}`, optional or not, read as Hono reads a template: `split_route_template` / `parse_route_param`) for a value the params schema accepts; a `:` inside a literal segment (`files:upload`) stays. Prefers `test_<name>` wherever the field schema admits it (the param name keeps failure messages readable); otherwise a UUID param takes the nil UUID and anything else is synthesized from the schema, percent-encoded. A synthesized value containing `/` is refused (it would route elsewhere) and falls back to `test_<name>`. A value in `param_values` (the route's entry of `RouteParamValues`, `'METHOD /path'` → param name → value, the option the path-resolving suites take) comes first, percent-encoded like the rest. A `:name{re}` param's value, supplied or generated, must match its pattern grouped and anchored, `^(?:re)$` (`compile_route_param_pattern`, over the percent-encoded value the router matches) — Hono's RegExpRouter reading, the stricter of its routers', as TrieRouter leaves a top-level alternation ungrouped — else it throws naming the route and the param and pointing at `param_values`: no value is guessed from the pattern, and no route is skipped silently. A `param_values` entry naming no param of the path throws too, and so does a supplied `''`, `.` or `..` (the URL normalizes it away) or a lone surrogate. Supplied values are always encoded, so a `{re}` needing a literal `/` can't be met by one.
489
+ - `resolve_valid_path(path, params_schema?, param_values?)` — swaps each whole param segment (as Hono reads a template) for a value the params schema accepts: a `param_values` entry (`RouteParamValues`) first, else `test_<name>` where the schema admits it, the nil UUID for a UUID param, or a synthesized value, always percent-encoded. A `:name{re}` param's value must match its pattern (RegExpRouter's reading), else it throws naming the route and pointing at `param_values` — no guess, no silent skip. The other refusals are its TSDoc.
519
490
  - `to_route_content_type(route)` — the `Content-Type` a well-formed request to the route sends: `application/json`, or `application/octet-stream` for a `raw_body` route. Every `POST` route refuses anything else with 415 before its other gates, so every probe in the harnesses (auth, params and query fuzz, 404, data exposure, round trip) sends it, body or not.
520
491
  - `generate_valid_object(object_schema, schema) => {value, result}` — required and defaulted fields; when `schema` (refinements included) refuses those, each optional field alone in declaration order, the first that parses; failing that, the optional fields added cumulatively until it parses. Covers a `check` over optional fields (at least one of, exactly one of, both of) at any depth, and, where one optional field suffices, keeps the others (an `acting` declared first) out. Returns the last `parse` result (`GeneratedObject`) and leaves the throw to the caller, which renders its issues with `format_issues` (`schema_issues.ts`).
521
492
  - `generate_valid_object_with_field(object_schema, schema, base, field)` — a valid object carrying `field`, built from the valid `base`: `base` itself when it carries the field; else the field joins `base`, with the optional fields `base` omits filled as `generate_valid_object` fills them (a pair rule: `scope_kind` needs `scope_id`); failing that, the field replaces `base`'s optional fields, refilled around it (exactly one of: adding `slug` drops `id`). `null` when no object the generator builds carries the field. The body a single-fault case on a field the base omits changes.
@@ -524,7 +495,7 @@ adversarial/round-trip tests. A value that is no schema throws, naming it.
524
495
  ### `integration_helpers.ts` — route lookup + body checks
525
496
 
526
497
  - `find_route_spec(specs, method, path)` — the first spec in list (mount) order whose method and path template match, as Hono dispatches (the hono-free `find_mounted_route`; the DEV check reads Hono's own router), `HEAD` read as `GET`, the path read as the router reads it (the raw pathname, nothing decoded); a template passed as the path (a segment that is `*` or starts with `:`) finds its own spec first, outranking mount order.
527
- - `find_auth_route(specs, suffix, method)` — suffix-ending match for REST auth routes; decouples tests from consumer prefix. `suffix` is typed as `RestAuthRouteSuffix` and throws at runtime on unknown values (only login/logout/password/signup/bootstrap remain on REST).
498
+ - `find_auth_route(specs, suffix, method)` — suffix-ending match for REST auth routes; decouples tests from consumer prefix. `suffix` is typed as `RestAuthRouteSuffix` (`rest_auth_route_suffixes`: login, logout, password, signup, bootstrap) and throws at runtime on unknown values.
528
499
  - `assert_response_matches_spec(specs, method, path, response, route_error_maps?)` — 2xx → validates against `spec.output`; an error status (400 and up) → `assert_error_response_declared` against the route's error map — the one in `route_error_maps` (`AppSurfaceSpec.route_error_maps`, middleware included), else the route's own: a status the map lacks throws (`Undeclared error status (S): METHOD path: …`), as does a body off its schema, with the DEV error check's exemptions (500 `internal_error`, 503 `service_unavailable`, a JSON-RPC envelope on a `jsonrpc` route). Non-JSON responses allowed only when no schema applies. The round trips and `ErrorCoverageCollector.assert_and_record` run through it. An answer no route gave — the app's 405 `method_not_allowed`, its JSON `route_not_found` 404, the plain-text `404 Not Found` — fails outright, even where the route declares a 404: a route on the surface that the backend doesn't mount is never a pass.
529
500
  - `assert_no_error_info_leakage(body, context)` — rejects field-name patterns (`stack`, `trace`, `sql`, …) + value patterns (`node_modules`, stack-like `at …`, `.ts:NN`).
530
501
  - `assert_rate_limit_retry_after_header(response, body)` — `Retry-After` numeric header equals `Math.ceil(body.retry_after)`.
@@ -539,8 +510,7 @@ adversarial/round-trip tests. A value that is no schema throws, naming it.
539
510
 
540
511
  ### `attack_surface.ts` — `describe_standard_attack_surface_tests`
541
512
 
542
- Single-call bundle of 5 top-level groups (10 named tests + every adversarial
543
- case per route):
513
+ Single-call bundle, every adversarial case per route included. The groups:
544
514
 
545
515
  1. **attack surface snapshot** — `matches committed snapshot`, `is deterministic`.
546
516
  2. **attack surface structure** — `only expected public routes`, `full middleware stack on API routes`, `surface invariants`, `rpc/ws surface invariants`, `security policy`.
@@ -576,7 +546,7 @@ accepts (`assert_error_schema_valid`).
576
546
  The generators live in the hono-free `adversarial_input_cases.ts`, so the
577
547
  cross-process suites reuse them:
578
548
 
579
- - `generate_input_test_cases(input_schema, options?)` → `InputTestCase[]` — whole-body structural (non-object, extra key when the input refuses unknown keys — a fuz_schema `object`), missing required fields, one wrong-type per field, null for required non-nullable, one format violation per constrained field, and boundary cases read from the field's input-side JSON Schema (`to_field_json_schema` — through a transform or pipe, and under a nullable's `anyOf`): the empty string, one under `minLength` (above one; a prefix of the valid value) and one over `maxLength`; below `minimum`, above `maximum`, zero and negative for a positive-only field, and a non-integer for an integer field (half a step from the valid value, inside the range); the empty array, one under `minItems` (above one; the valid value's own items) and one over `maxItems`. A per-field case is emitted only when the field refuses its value (a field whose transform accepts the wrong type, a pattern admitting the violation string, a preprocess that repairs the value: dropped), so no generated case is accidentally valid. Each per-field case is single-fault — valid but for the field it breaks: it changes one field of a valid base (`generate_valid_object`'s, or `options.base` (`InputTestCaseOptions`) for an input whose valid shape the generator can't reach), or, for a field that base omits, of the body `generate_valid_object_with_field` builds around it, so a case can't also break an object-level rule. A field no valid body carries keeps its wrong-type and null cases on the base and gets no format or boundary cases. Either base failing the schema throws, naming `options.label` (the method or route) when given. A per-field case names the field it breaks (`InputTestCase.field`; absent on the whole-body cases). A void or null input gets no cases; any other input that is no object schema throws (`to_body_input`).
549
+ - `generate_input_test_cases(input_schema, options?)` → `InputTestCase[]` — whole-body structural cases, missing required fields, and per field a wrong type, `null`, a format violation and boundary cases read from its input-side JSON Schema (`to_field_json_schema`). Every per-field case is **single-fault** — a valid base (`generate_valid_object`, or `options.base`) with only that field broken — emitted only when the schema refuses it, and names its field (`InputTestCase.field`). A void or null input gets none; any other non-object input throws. The case list is the module's TSDoc.
580
550
  - `expected_invalid_reason(input_schema, test_case)` → `string | undefined` — the `data.reason` an RPC refusal of the case owes: the broken field's `invalid_reason` (`schema_meta.ts`), resolved by the same `resolve_invalid_reason` the dispatcher resolves through, or none for an undeclared field or a whole-body case.
581
551
  - `generate_params_test_cases(params_schema)` → `ParamsTestCase[]` — format violations only (unconstrained string params accept anything), each one the field refuses.
582
552
  - `generate_query_test_cases(query_schema)` → `QueryTestCase[]` — missing required fields the field refuses to go without (a preprocessed field with a default accepts its absence) + format violations the field refuses.
@@ -591,7 +561,9 @@ rather than `ERROR_INVALID_JSON_BODY`.
591
561
 
592
562
  `describe_adversarial_404({build, roles})` — for every route with `params` and
593
563
  a 404 definition of its own in `errors`, replaces the handler with a stub
594
- returning `{error: <code>}` (the first 404 definition's code), fires with
564
+ returning the first 404 definition's code with its fields generated from its
565
+ schema (`generate_valid_object`; fields it can't generate throw at collection,
566
+ naming the route), fires with
595
567
  nil-UUID params, asserts 404, a code the route error map declares at 404, and a body its 404
596
568
  accepts (`assert_error_schema_valid`, `AppSurfaceSpec.route_error_maps`). No DB needed.
597
569
 
@@ -669,40 +641,22 @@ picks them up separately.
669
641
 
670
642
  ### `rpc_round_trip.ts` — `describe_rpc_round_trip_tests`
671
643
 
672
- DB-backed round-trip for RPC: one POST test for all methods, one GET test
673
- for `side_effects: false` methods. Successful responses validate against
674
- `action.spec.output`; error responses validate as well-formed JSON-RPC error
675
- envelopes. Three refusals fail instead of passing as an envelope: `method not
676
- found` (the backend lacks a method the surface declares), a crash — HTTP
677
- 500, the `internal_error` code (-32603), or a ≥500 whose body is no JSON-RPC
678
- envelope — and a 401 to a non-public call (`assert_rpc_authenticated`): the
679
- call carried a credential its auth admits, so a 401 means it stopped working.
680
- A public method may still answer 401 (a wrong-password login), and so may a
681
- handler naming its own reason (below). A ≥500 carrying a declared code
682
- (`service_unavailable` 503, `timeout` 504, a consumer code declared with
683
- `register_jsonrpc_error_code`) is a server condition and passes like a
684
- 4xx. The failure names the method, status, code and message; a non-JSON body
685
- is reported as text. Options: `{setup_test, surface_source, session_options,
686
- rpc_endpoints, skip_methods?, input_overrides?, success_fixtures?}`.
687
- `pick_rpc_auth` picks the principal from `method.auth` through
688
- `pick_auth_principal` (`integration_helpers.ts`, shared with the REST
689
- round-trip; `AuthPrincipal`): none for a public method, the keeper's daemon
690
- token when `credential_types` names it, the admin account's session for an
691
- admin-gated method, the keeper's session for another role, else the authed
692
- account's session. The request goes through `to_principal_transport`, so a
693
- spawned backend sees only the picked credential — over the fixture's own
694
- transport it would discard a daemon token as browser context and answer for
695
- the keeper's session cookie. A 403 `credential_type_required` therefore fails
696
- (`is_credential_type_refusal`): the principal was picked because the method
697
- admits its credential type, so a method no picked principal can reach goes in
698
- `skip_methods`. The 401 check is `is_unauthenticated_refusal`: a 401
699
- reading `authentication_required` or naming no reason fails; a handler's own
700
- 401 reason on an authenticated call (`invalid_credentials` for a wrong current
701
- password) passes. So a handler that answers 401 to a valid credential must name
702
- its reason — `data.reason` over RPC, the flat `error` over REST: a reason-less
703
- 401 reads as unauthenticated and fails the round-trip. TS's
704
- `jsonrpc_errors.unauthenticated(message)` sends no `data` unless given one, so
705
- pass `{reason}` as its second argument.
644
+ DB-backed round trip for RPC: every method over POST, the `side_effects:
645
+ false` ones over GET too; a success parses against `output`, an error must be
646
+ a well-formed envelope. It fails on `method not found`, a crash (500,
647
+ `internal_error`, or a ≥500 that is no envelope), a 403
648
+ `credential_type_required`, and a 401 to a non-public call that reads
649
+ `authentication_required` or names no reason: the principal
650
+ (`pick_auth_principal`, shared with the REST round trip, sent through
651
+ `to_principal_transport` so it carries that credential alone) was picked
652
+ because the method admits its credential. So **a handler answering 401 to a
653
+ valid credential must name its reason** — `data.reason` over RPC (pass
654
+ `{reason}` to `jsonrpc_errors.unauthenticated`), the flat `error` over REST. A
655
+ ≥500 carrying a declared code (503 `service_unavailable`, 504 `timeout`, a
656
+ consumer's `register_jsonrpc_error_code`) passes. Options: `{setup_test,
657
+ surface_source, session_options, rpc_endpoints, skip_methods?,
658
+ input_overrides?, success_fixtures?}`; a method no picked principal can reach
659
+ goes in `skip_methods`.
706
660
 
707
661
  A side-effecting method picked for the authed account runs on a fresh account
708
662
  of its own (`round_trip_uses_fresh_account`, keyed on the spec's
@@ -766,8 +720,8 @@ cover real sockets.
766
720
 
767
721
  Three layers:
768
722
 
769
- 1. **Primitives** — `create_fake_ws(options?)` (a real `WSContext` over capture arrays `sends` / `closes`, plus `socket` — the fake runtime socket behind `ws.raw`, shaped like Node's `ws`: a `bufferedAmount` the registry's outbound writer reads for backpressure, `stalled` (start it with `{stalled: true}`) to model a client that stopped reading, and `terminate` / `terminated` for the frameless cut; `readyState` reads open until closed or terminated), `create_fake_hono_context(opts)`, `create_stub_upgrade()`, `MinimalActionEnvironment`, `dispatch_ws_message(on_message, event, ws)`. The fake context sets the `ResolvedAuth` the production auth middleware sets (`RESOLVED_AUTH_KEY`, built by `create_test_resolved_auth` — a session's hash as `hash_session_token(auth_session_id)`), because the dispatcher reads the credential through `get_resolved_auth(c)`; a hand-built upgrade context must do the same. `create_stub_upgrade()` stands in for a runtime adapter's `upgradeWebSocket`: it passes a request without `Upgrade: websocket` to `next()`, and records an upgrade request — its real `Context` and the endpoint's events factory — in `upgrades`, answering `200`. So a test can send `app.request('/api/ws', {headers: {upgrade: 'websocket', cookie | authorization, origin, 'x-forwarded-for'}})` through an assembled app's whole middleware chain and build the socket's events from the `Context` that chain produced (`src/test/server/create_app_server_ws_endpoints.dispatch.db.test.ts`); `get_create_events()` still returns the last mounted factory, for a hand-built context.
770
- 2. **Harness** — `create_ws_test_harness({actions, registry?, receive_timeout?, log?, on_socket_open?, on_socket_close?})` → `WsTestHarness`. `connect(identity?)` is async and resolves after the connection is admitted and `on_socket_open` completes, so broadcasts sent immediately after `await harness.connect()` reach the client. The harness pre-bakes its `RequestContext` (`TEST_CONTEXT_PRESET_KEY`), which also skips the admission credential re-read — there are no session or token rows behind a harness identity — so tests of the re-read itself drive `register_action_ws` with a real database and no preset (`src/test/actions/register_action_ws.admission.db.test.ts`). The harness threads its own `create_stub_db()` into the dispatcher's `db` slot so handlers declaring `side_effects: true` execute under the same transaction wrap they would in production (the stub's `transaction(fn)` synchronously calls `fn(stub_db)`); domain deps reach handlers via factory closures, the same way HTTP RPC factories already wire them. Audit fan-out runs through whatever `audit` emitter the consumer supplied to its action factory closure (typically `create_test_audit_emitter()` for unit harnesses).
723
+ 1. **Primitives** — `create_fake_ws(options?)` (a real `WSContext` recording `sends` / `closes` over a fake Node-`ws`-shaped `socket` with `bufferedAmount`, `stalled` and `terminate`, for backpressure and frameless-cut tests), `create_fake_hono_context(opts)` (sets the `ResolvedAuth` the auth middleware would — the dispatcher reads it, so a hand-built upgrade context must too), `create_stub_upgrade()` (a stand-in for the runtime's `upgradeWebSocket` that records each upgrade's real `Context`, so an upgrade can run through an assembled app's whole middleware chain — `src/test/server/create_app_server_ws_endpoints.dispatch.db.test.ts`), `MinimalActionEnvironment`, `dispatch_ws_message`.
724
+ 2. **Harness** — `create_ws_test_harness({actions, registry?, receive_timeout?, log?, on_socket_open?, on_socket_close?})` → `WsTestHarness`; `await harness.connect(identity?)` resolves once the connection is admitted and `on_socket_open` has run. Identities are preset (`TEST_CONTEXT_PRESET_KEY`), which also skips the admission credential re-read, so tests of the re-read drive `register_action_ws` over a real database (`src/test/actions/register_action_ws.admission.db.test.ts`). Handlers run under the stub db's transaction wrap; domain deps and the audit emitter reach them through the action factory's closure.
771
725
  3. **Round-trip helpers** — predicates + wire-frame types live in `transports/ws_client.ts` (shared with the cross-process `ws_transport.ts` impl): `is_notification(method)`, `is_notification_with<P>(method, match)` (type-guard combinator — narrows `wait_for` return type), `is_response_for(id)`, `JsonrpcNotificationFrame<P>` / `JsonrpcSuccessResponseFrame<R>` / `JsonrpcErrorResponseFrame<D>` (typed wire-frame shapes distinct from the runtime schemas in `http/jsonrpc.ts` — generic over `params` / `result` / `data` so tests narrow without casts).
772
726
 
773
727
  `WsClient` (in `transports/ws_client.ts`):
@@ -793,13 +747,13 @@ waiter on timeout so the `waiters` array doesn't grow.
793
747
 
794
748
  ### `data_exposure.ts` — `describe_data_exposure_tests`
795
749
 
796
- Six tests in two top-level groups:
750
+ The groups:
797
751
 
798
- 1. **schema-level** (3 tests, no DB) — walks JSON Schema representations:
752
+ 1. **schema-level** (no DB) — walks JSON Schema representations:
799
753
  - `no sensitive fields in any output schema` — `sensitive_field_blocklist`, over every route, RPC method and WS method output, and the params the server pushes over WS (a `remote_notification`'s payload, whose `output` is `s.void`, and the request of a `request_response` with `initiator` `'backend'` or `'both'`)
800
754
  - `no admin-only fields in non-admin output schemas` — `admin_only_field_blocklist`, over the route outputs a non-admin reaches; routes only, since the blocklist matches by name and domain RPC/WS outputs carry `created_by`/`updated_by` legitimately. Admin-gated means every role in an any-of `roles` (or a WS endpoint's `required_roles`) is `admin` or `keeper`, or the daemon token is required
801
755
  - `no sensitive fields in any error schema`
802
- 2. **runtime** (3 tests, DB-backed via `create_test_app`):
756
+ 2. **runtime** (DB-backed via `create_test_app`):
803
757
  - `unauthenticated error responses contain no sensitive fields`
804
758
  - `admin routes return 403 for non-admin user` — cross-privilege check
805
759
  - `all 2xx responses pass field blocklists` — GETs sorted before POSTs so data-returning routes fire before destructive ones (logout, revoke-all) invalidate sessions
@@ -823,7 +777,7 @@ as `'/path method_name'`, and pushed WS params as `'/path method_name params'`
823
777
 
824
778
  ### `rate_limiting.ts` — `describe_rate_limiting_tests`
825
779
 
826
- Two test groups:
780
+ The groups:
827
781
 
828
782
  1. IP rate limiting on login — fires `max_attempts + 1` requests; last should be 429 with a `REST_RATE_LIMIT_EXCEEDED` body + valid `Retry-After` header.
829
783
  2. Per-account rate limiting on login — same username exhausts the bucket; a different username is not blocked.
@@ -848,8 +802,7 @@ the spread are ignored by the suite.
848
802
  ### `integration.ts` — `describe_standard_integration_tests`
849
803
 
850
804
  Exercises the full stack against a real in-memory database + auth middleware + session
851
- cookies + bearer tokens. The suite has ~19 `describe` blocks grouped under
852
- these thematic areas:
805
+ cookies + bearer tokens. Its `describe` blocks, by theme:
853
806
 
854
807
  1. Login/logout lifecycle
855
808
  2. Login response body (strict schema)
@@ -913,18 +866,12 @@ asserts the declared status and code, then `assert_and_record`s it.
913
866
 
914
867
  ### `admin_integration.ts` — `describe_standard_admin_integration_tests`
915
868
 
916
- 7 test groups covering admin surface: account listing, role_grant grant
917
- lifecycle (via `role_grant_offer_create` + `role_grant_offer_accept` +
918
- `role_grant_revoke` RPC flows — **not** REST, **not** direct
919
- `query_accept_offer`; see `auth/CLAUDE.md` for
920
- `role_grant_offer_action_specs.ts` + `role_grant_offer_actions.ts`),
921
- session / token management, audit log reads (RPC — every row read is
922
- parsed by `assert_audit_event_metadata`, closed to undeclared keys when the
923
- fixture asks, and the completeness test drives login, logout, the offer flow,
924
- grant + revoke, token create, password change, and — each where the surface
925
- mounts its actions — token revoke, session revoke, invite create + delete and
926
- `app_settings_update`), admin-to-admin
927
- isolation, error coverage, response schema validation.
869
+ Groups: account listing, session and token management, audit log reads (every
870
+ row parsed by `assert_audit_event_metadata`, closed to undeclared keys when the
871
+ fixture asks), the admin audit trail and audit completeness (an optional
872
+ action's case only where the surface mounts it), admin-to-admin isolation,
873
+ error coverage. Role grants go through the RPC offer flow
874
+ (`role_grant_offer_and_accept`), never a direct insert.
928
875
 
929
876
  The shared `role_grant_offer_and_accept` helper (`role_grant_helpers.ts`)
930
877
  composes both RPCs end-to-end and takes
@@ -965,15 +912,9 @@ actions alongside admin / role-grant-offer — easiest is
965
912
  `create_standard_rpc_actions`, which bundles all three. Consumers that only
966
913
  wire admin will hit `method not found: account_token_create` on first run.
967
914
 
968
- Error-coverage scope is narrowed to the REST suffixes still on the admin
969
- surface (`/audit/stream`); the RPC surface is covered by
970
- `describe_rpc_round_trip_tests`. The scoped REST surface is 0–1 routes —
971
- when the scoped count is ≤1, the `afterAll` hook logs
972
- `[error coverage] skipped admin REST coverage assertion — …` and does not
973
- fail. The 20% `DEFAULT_INTEGRATION_ERROR_COVERAGE` baseline is a REST-era
974
- threshold; the RPC surface has its own coverage via
975
- `describe_rpc_round_trip_tests`. TODO: move this error-coverage collector
976
- to the RPC round-trip suite entirely and delete this skip branch.
915
+ Error coverage counts the admin surface's REST routes alone (`/audit/stream`);
916
+ with one route or none in scope, the floor is skipped with a log line. The RPC
917
+ surface's coverage is `describe_rpc_round_trip_tests`'.
977
918
 
978
919
  ### `audit_completeness.ts` — `describe_audit_completeness_tests`
979
920
 
@@ -1042,16 +983,16 @@ Registry lookups:
1042
983
 
1043
984
  ### `rpc_attack_surface.ts` + `rpc_envelope_cases.ts` — `describe_rpc_attack_surface_tests`
1044
985
 
1045
- 3 test groups for JSON-RPC endpoints:
986
+ The groups:
1046
987
 
1047
988
  1. **RPC auth enforcement** — per-endpoint, per-method:
1048
989
  - unauthenticated → `unauthenticated` (code -32001)
1049
990
  - wrong role → `forbidden` (-32002)
1050
991
  - authenticated without role → `forbidden`
1051
992
  - **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).
1052
- - correct auth passes (not 401/403)
993
+ - correct auth passes — valid params (`input_overrides` or generated) reach the method's handler, a recording stub, at 200
1053
994
  - GET unauthenticated for `side_effects: false` reads
1054
- 2. **RPC adversarial envelopes** — the fixed set `create_rpc_envelope_cases(endpoint, {skip_methods?})` builds, exercising the envelope parse, method lookup, and GET read restriction: non-JSON body → `parse_error`, wrong `jsonrpc` version, missing `jsonrpc` / `method` / `id`, a response-shaped body (`{jsonrpc, id, result}`) → `invalid_request` on `id: null`, batch array, non-object POST `params` → `invalid_request`, unknown method → `method_not_found`, GET missing `method`/`id` → `invalid_request`, a GET query holding an escape that doesn't decode → `invalid_request` on `id: null`, GET invalid-JSON params → `invalid_params`, GET non-object params on **every** read (each of `RPC_NON_OBJECT_PARAMS`: a number, an array, a string, a boolean) → `invalid_params`, GET mutation method → `invalid_request`, plus three ordering cases sent with no credential (an anonymous GET mutation and an anonymous batch, both `invalid_request`, never 401; an anonymous GET with non-object params on a read requiring an identity, the 401 — params validation runs after authorization). Each case is sent by the app its method's auth admits (`select_auth_app`) and pins status, code, echoed `id`, and `data.reason` (exact where the dispatcher sets one, absent otherwise) via `assert_rpc_envelope_refusal`. The cases are data (`RpcEnvelopeCase`) in the hono-free `rpc_envelope_cases.ts`, shared with the cross-process `describe_rpc_adversarial_cross_tests`; `to_rpc_envelope_request` builds a case's request, and `rpc_get_side_effects_reason(method)` is the GET read restriction's reason.
995
+ 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.
1055
996
  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.
1056
997
 
1057
998
  Skips silently when `surface.rpc_endpoints` is empty. Uses stub deps — no
@@ -1059,15 +1000,10 @@ DB needed.
1059
1000
 
1060
1001
  Options: `{build: () => AppSurfaceSpec, roles: Array<string>, input_overrides?}`.
1061
1002
 
1062
- **Opt-in bundles need their own per-bundle suite file.** Action bundles not
1063
- folded into `create_standard_rpc_actions` (today `self_service_role_actions`,
1064
- `actor_lookup_actions`, and `actor_search_actions`) get zero adversarial /
1065
- round-trip coverage from `describe_rpc_attack_surface_tests` +
1066
- `describe_rpc_round_trip_tests` unless the consumer ships a
1067
- `<module>.rpc_suites.db.test.ts` mounting the opt-in factory on the RPC
1068
- endpoint and calling both suites. See ../../test/CLAUDE.md §Composable
1069
- Test Suites for the obligation note; existing
1070
- `src/test/auth/*.rpc_suites.db.test.ts` files are templates.
1003
+ **Opt-in bundles need their own per-bundle suite file** — an action bundle
1004
+ outside `create_standard_rpc_actions` gets no adversarial or round-trip
1005
+ coverage until a `<module>.rpc_suites.db.test.ts` mounts it (../../test/CLAUDE.md
1006
+ §Composable Test Suites).
1071
1007
 
1072
1008
  ## Cross-cutting conventions
1073
1009
 
@@ -1099,172 +1035,36 @@ have files of their own.
1099
1035
 
1100
1036
  ### Fixture protocol + capabilities
1101
1037
 
1102
- - `testing/cross_backend/setup.ts` — `SetupTest` / `TestFixture` /
1103
- `CreateTestAccountOptions` types (`fixture.create_account` and
1104
- `fixture.extra_accounts` hand out `TestAccount`s from `app_server.ts`, built
1105
- by `to_test_account`); the in-process setups live beside it in
1106
- `testing/cross_backend/in_process_setup.ts`:
1107
- `default_in_process_setup(options)` (wraps `create_test_app`; pass
1108
- `migration_namespaces` for suites needing tables beyond the auth-only
1109
- default — the cell parity suite passes `[CELL_MIGRATION_NS]`, and
1110
- `create_test_app` provisions a per-test fresh db migrating
1111
- `[AUTH_MIGRATION_NS, ...migration_namespaces]`), and
1112
- `default_in_process_suite_options(options)` (emits the full Tier 1 suite
1113
- options bag: the `{setup_test, surface_source, capabilities}` triple plus
1114
- `session_options` / `create_route_specs` / `rpc_endpoints` pass-through;
1115
- call sites pass the output directly or spread it alongside
1116
- suite-specific extras like `roles`, `skip_routes`, `input_overrides`,
1117
- `db_factories`). `setup.ts` also exports `BootstrappedBackendHandle` (a
1118
- `BackendHandle` enriched with the keeper's captured credentials) and
1119
- `default_cross_process_setup(handle, options?)` — full runtime body.
1120
- Every per-test invocation unconditionally fires `_testing_reset` over the
1121
- keeper's daemon-token channel: wipes every auth-namespace row (no
1122
- keeper-preserve filter), resets `app_settings` + `bootstrap_lock`, and
1123
- inline-seeds a fresh keeper (`[ROLE_KEEPER, ROLE_ADMIN, ...extra_keeper_roles]`)
1124
- plus any declared `extra_accounts`; the seeds a backend answers with are
1125
- matched to the request by username and actor name
1126
- (`match_testing_reset_seeds`), and a missing, extra, or duplicated one
1127
- throws naming the backend. The fixture's `account` / `actor` /
1128
- cookies refresh to the new keeper on every call — in-process and
1129
- cross-process both run against a freshly bootstrapped keeper per test.
1130
- `fixture.create_account()` keeps a separate path: keeper-driven
1131
- `invite_create` (username-scoped) → signup → login → `account_token_create`
1132
- over the production RPC surface, so the invite-gated mint keeps
1133
- `open_signup` at its production default (`false`) and the per-test
1134
- secondary holds real session + bearer credentials.
1135
- `create_account({roles: [...]})` then drives `role_grant_offer_create`
1136
- (keeper) + `role_grant_offer_accept` (per-test) for each role — roles
1137
- whose `RoleSpec.grant_paths` don't include `'admin'` reject loudly at
1138
- offer-create time (`ERROR_ROLE_GRANT_OFFER_ROLE_NOT_GRANTABLE`); those
1139
- roles must be seeded via `extra_accounts` at bootstrap-equivalent time
1140
- instead. `create_account({email})` threads an email onto the signup body
1141
- (the username-scoped invite matches regardless of email), so the account
1142
- lands with an email set — the hook the username-or-email login parity suite
1143
- uses; the in-process path sets it directly on the inserted row. Must be a
1144
- valid, per-test-unique `Email` (the `LOWER(email)` partial-unique index
1145
- rejects collisions). The signup and login it drives go to the setup's
1146
- `signup_path` / `login_path` (default `SPINE_ACCOUNT_SIGNUP_PATH` /
1147
- `SPINE_ACCOUNT_LOGIN_PATH`, from `spine_surface_constants.ts`, which also
1148
- carries the other account routes, `SPINE_WS_PATH`, and the prefix).
1149
- Caller-supplied `username`s pass through as given — the database is wiped
1150
- between tests, so a hardcoded name like `'user_two'` never collides. Every
1151
- `TestFixture` also exposes
1152
- `fresh_transport({origin?: string | null})` — cookie-jar-free probe;
1153
- pass `{origin: null}` for bearer-only paths. It also carries the conformance principals' mints — `mint_expired_session()`, and `mint_revoked_session()` / `mint_revoked_token()` / `mint_expired_token()` for the dead credentials, each proving its credential live through `assert_credential_authenticates` over a cookie-free transport before killing it; in-process they need `account_verify` on the setup's `rpc_endpoints`, and cross-process `mint_expired_token` needs `_testing_shorten_credential_expiry` mounted.
1154
-
1155
- **Keeper ≠ admin.** `fixture.account` is the keeper account holding
1156
- `[ROLE_KEEPER, ROLE_ADMIN]` — the role split mirrors production
1157
- `bootstrap_account`. `ROLE_KEEPER` does not grant admin reach; bootstrap
1158
- just happens to land both as separate grants. Probing the separation (a
1159
- keeper-only account must 403 on admin RPCs) requires declaring
1160
- `extra_accounts: [{username, roles: [ROLE_KEEPER]}]` — `ROLE_KEEPER`'s
1161
- `grant_paths` is bootstrap-only, so a post-bootstrap offer/accept can't
1162
- deliver it.
1163
-
1164
- - `testing/cross_backend/capabilities.ts` — `BackendCapabilities` vocabulary
1165
- (the **gating** flags `ws` / `sse` / `cell_crud` / `cell_relations` /
1166
- `cell_gated_create` / `account_lifecycle` / `fact_serving` /
1167
- `fact_serving_admin_hash` / `ready` /
1168
- `account_status` / `spine_fallback` / `host_gate` / `peer_request` /
1169
- `ws_handshake_pipelining` / `ws_account_actions` /
1170
- `ws_role_gated` / `rooms` — each read by `test_if` or a row's `requires` —
1171
- the non-gating `ws_refusal_body` and `runtime_resolves_dot_segments`, which
1172
- pick how a case reads its answer, and the list
1173
- `ws_upgrade_runtime_refusals`, the upgrades the backend's runtime answers
1174
- before the app runs (`['empty_host']` on `@hono/node-server`, `[]` on Bun
1175
- and the Rust spine), which the request-header wire suite holds to exactly
1176
- that answer; `peer_request` (server-initiated requests — the ActionPeer
1177
- `peer/ping` round-trip) is `true` on fuz_app's Rust and TS spine presets
1178
- (`ConnectionRegistry.request_connection`); a backend states it
1179
- `true` once it wires the `peer/ping` HTTP + WS mount), `test_if(cond, name, fn)`
1180
- for capability-gated cases, and `in_process_capabilities` preset. Only
1181
- flags a suite reads are capabilities — a wiring fact that gates nothing is
1182
- not recorded. **Mount flags have no family default**: `MountFlag` names the
1183
- flags that describe a backend's own mounts (`ws`, `sse`, `cell_crud`,
1184
- `cell_relations`, `cell_gated_create`, `fact_serving`,
1185
- `fact_serving_admin_hash`, `ready`,
1186
- `peer_request`, `ws_account_actions`, `ws_role_gated`, `rooms`), and the family
1187
- defaults (`ts_default_capabilities` / `rust_default_capabilities`, typed
1188
- `FamilyDefaultCapabilities`) omit them and the `testing_backdoors` list (the
1189
- `_testing_*` backdoors the backend mounts, from `TESTING_BACKDOOR_METHODS` —
1190
- §Testing-backdoor declaration below; `[]` in-process, every one on fuz_app's
1191
- spine presets), with `capabilities` required on
1192
- `make_default_{ts,rust}_backend_config` — so a config that leaves one out
1193
- fails typecheck naming it, rather than silently skipping its suites. The
1194
- family defaults carry the declared surface's mounts (`account_lifecycle`,
1195
- `account_status`, and `spine_fallback` — an unmatched path outside the auth
1196
- scope answered by the spine's own fallback, which a backend serving a static
1197
- or SPA fallback of its own states `false`; and `host_gate`, the DNS-rebinding
1198
- gate on, which a backend running with it off states `false`) and the
1199
- runtime-behavior flags
1200
- (`ws_handshake_pipelining`, `ws_refusal_body`, `ws_upgrade_runtime_refusals`,
1201
- `runtime_resolves_dot_segments`) of the family's reference runtime — Node for TS, hyper
1202
- for Rust; a backend on another runtime (Bun) overrides them. `cell_crud`
1203
- gates the CRUD parity suite, `cell_relations` the relation / ACL / audit
1204
- parity suite — both `true` on every backend that live-mounts the full cell
1205
- surface (TS spine binary, in-process app, Rust stub). A backend mounting only
1206
- plain CRUD would declare `cell_crud: true, cell_relations: false`.
1207
- `cell_gated_create` gates `describe_cell_gated_create_cross_tests` +
1208
- `describe_cell_moderate_cross_tests` (the parent-aware-creation-authorizer +
1209
- `cell_moderate` parity proofs) and, with `cell_relations`,
1210
- `describe_cell_grant_steward_cross_tests` (the steward-revoke seam: a scoped
1211
- `participant` grant stewards its scope under the
1212
- `test_cell_grant_steward_revoke_authorize` policy mounted beside the create
1213
- one); unlike `cell_crud`/`cell_relations`
1214
- it is **cross-only** (`false` in-process) — `true` only on the reference
1215
- spine binaries that live-mount the `test_cell_gated_create_authorize` policy
1216
- (the TS spine `full_spine_mount` + the Rust `testing_spine_stub`), since the
1217
- authorizer _behavior_ adds no method/wire shape and so the schema + manifest
1218
- parity gates are blind to an authorizer divergence (the `cell_moderate`
1219
- _verb_ it pairs with is on the manifest, separately gated).
1220
- `rooms` gates `describe_rooms_ws_cross_tests` — **cross-only** too, and for
1221
- the same reason: its rooms run on the `test_room_authorize` policy, so it is
1222
- `true` only on a backend mounting the room verbs over that policy and an
1223
- exclusive registry (the reference spine binaries); a consumer mounting rooms
1224
- over its own authorizer states `false`.
1225
- `account_lifecycle` gates `describe_account_lifecycle_cross_tests` (the
1226
- `account_delete` / `account_undelete` / `account_purge` parity suite); unlike
1227
- cells those verbs **are** on the declared surface (in `create_admin_actions`,
1228
- auto-enumerated for shape/auth) — the flag gates the behavioral parity the
1229
- generic round-trip can't drive (it can't delete the subject). `true` on every
1230
- spine. `fact_serving`
1231
- gates `describe_fact_serving_cross_tests` (the cell-scoped per-reference
1232
- fact-serving parity suite, incl. the served fact's hardening headers and
1233
- bodyless masked 404s); like cells it stays off the declared surface and is
1234
- `true` on every spine that mounts the cell-gated serve route +
1235
- the `_testing_put_fact` seeder (whose optional `holder` records a
1236
- `fact_holder` row, so a non-admin can reference what it seeds, and whose
1237
- optional `external_url` writes a bare external row naming that URL, so the
1238
- suite can pin that a URL naming another hash's file is refused) — it also
1239
- gates `describe_cell_ref_admission_cross_tests` (its grant, item, and clone
1240
- cases with `cell_relations`). `fact_serving_admin_hash`
1241
- is the admin-only bare-hash route (`GET /api/facts/:hash`), its own flag
1242
- because a backend can serve the cell-gated route alone: it gates the
1243
- fact-serving suite's bare-hash cases (with `fact_serving`) and the bare-hash
1244
- cases of the query-shape and token-scope-surface suites. `ready` gates `describe_ready_cross_tests`
1245
- (anonymous `GET /ready` → `200 {ready: true}` on a clean spine bootstrap);
1246
- like cells/sse the `/ready` deploy gate stays off the declared surface, `true`
1247
- on every spine that live-mounts it over the shared `expected_schema.json`.
1248
- `account_status` gates the integration suite's `account status response body`
1249
- case — `GET /api/account/status` is bundled into `create_account_route_specs`,
1250
- so every spine serves it (`true`); the gate fails loud if a declaring backend
1251
- doesn't mount it.
1252
- No flag covers the body-size smuggling probe: every backend closes the
1253
- connection after an oversized-body 413 (at once on Node, Bun and the Rust
1254
- spine), so the pipelined request
1255
- goes unanswered. Bun 1.4.3 is the tested floor — an older Bun kept the
1256
- connection and served the next request, correctly framed, and fails the probe.
1257
- `ws_handshake_pipelining` gates the WS round-trip suite's
1258
- frames-with-the-handshake case (`true` Node/Rust — frames written in the
1259
- same TCP write as the upgrade request reach the socket; `false` Bun, which
1260
- answers such a request `400` when the upgrade follows an asynchronous check,
1261
- as it does behind auth, and `false` in-process, where there is no socket to
1262
- write raw bytes to).
1263
- `ws_account_actions` (the WS endpoint mounts the account actions — `true` on
1264
- fuz_app's own spine presets; a consumer states it like every mount flag) gates the WS
1265
- round-trip suite's self-revocation case (which requires the reply ahead of
1266
- the close on every backend) and, with `rpc_path`, its WS-mutation audit case
1267
- (which calls `_testing_drain_effects`).
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).
1039
+
1040
+ **Keeper ≠ admin.** `fixture.account` holds `[ROLE_KEEPER, ROLE_ADMIN]` as two
1041
+ grants, as a production bootstrap does (in-process,
1042
+ `DEFAULT_TEST_KEEPER_ROLES`); keeper reach is not admin reach. To probe the
1043
+ split, seed `extra_accounts: [{username, roles: [ROLE_KEEPER]}]`
1044
+ (`ROLE_KEEPER` is bootstrap-only).
1045
+
1046
+ - `testing/cross_backend/capabilities.ts` — `BackendCapabilities`, `test_if(cond, name, fn)` (a skipped case registered through `test_skip_gated`, so `check_declared_skips` holds it to a declaration), `in_process_capabilities`. A flag exists only if a suite reads it. `MountFlag`s and `testing_backdoors` have no family default (`FamilyDefaultCapabilities` omits them, and `capabilities` is required on `make_default_{ts,rust}_backend_config`), so a config leaving one out fails typecheck by name, and `capability_mounts` probes each mount a request observes, so a `false` beside a mounted surface fails too. Each field's TSDoc carries its meaning and what it gates; the table is the map.
1047
+
1048
+ | flags | kind | TS / Rust default | in-process |
1049
+ | --- | --- | --- | --- |
1050
+ | `ws`, `sse`, `cell_crud`, `cell_relations`, `fact_serving`, `fact_serving_admin_hash`, `ready` | mount | none (stated per config) | `true` |
1051
+ | `peer_request`, `ws_account_actions`, `cell_gated_create`, `ws_role_gated`, `rooms` | mount, cross-process only | none | `false` |
1052
+ | `account_lifecycle`, `account_status`, `spine_fallback`, `host_gate` | declared spine surface / config | `true` / `true` | `true` |
1053
+ | `ws_handshake_pipelining` | runtime | `true` (Bun `false`) / `true` | `false` |
1054
+ | `ws_refusal_body` | runtime, not a gate | `false` (Bun `true`) / `true` | `true` |
1055
+ | `ws_upgrade_runtime_refusals` | runtime list | `['empty_host']` (Bun `[]`) / `[]` | `[]` |
1056
+ | `runtime_resolves_dot_segments` | runtime, not a gate | `true` / `false` | `true` |
1057
+ | `testing_backdoors` | list (§Testing-backdoor declaration) | none | `[]` |
1058
+
1059
+ `cell_gated_create` and `rooms` are `true` only on a backend mounting the test
1060
+ policies (`test_cell_gated_create_authorize`, `test_room_authorize`) — the
1061
+ parity gates are blind to an authorizer's behavior. A backend serving its own
1062
+ static or SPA fallback states `spine_fallback: false`; one running with the
1063
+ host gate off, `host_gate: false`.
1064
+
1065
+ 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
1067
+ tested floor.
1268
1068
 
1269
1069
  ### `cross_backend/standard.ts` — `describe_standard_cross_process_tests`
1270
1070
 
@@ -1305,7 +1105,7 @@ minus their in-process-only knobs (`create_route_specs`,
1305
1105
  One call that runs every shipped single-backend cross suite against one
1306
1106
  spawned backend: `describe_spine_cross_suites(handle, {surface_source,
1307
1107
  session_options, rpc_endpoints, live_rpc_endpoints?, roles?, setup?, exclude?,
1308
- exclude_cases?, overrides?, suite_roles?, ws_required_roles?, rpc_success_fixtures?,
1108
+ exclude_cases?, expected_skips?, overrides?, suite_roles?, ws_required_roles?, rpc_success_fixtures?,
1309
1109
  rpc_skip_methods?, rpc_input_overrides?, rpc_max_body_bytes?, ws_max_message_bytes?})`.
1310
1110
  `live_rpc_endpoints` is the backend's whole live mount; given, `rpc_adversarial`
1311
1111
  also walks the methods it keeps off the declared surface. `rpc_input_overrides`
@@ -1330,7 +1130,9 @@ here never reaches it.
1330
1130
  all), so a new suite fails until it is registered or stated standalone; the
1331
1131
  dispatch table
1332
1132
  is a `Record<SuiteName, …>`, so a registered name without an entry fails
1333
- typecheck.
1133
+ typecheck. The same file holds §Suite modules' table to one row per suite
1134
+ in `SUITE_NAMES` order.
1135
+ - **Other runners.** `register_spine_suites(handle, options, {names?, wrap_setup_test?})` (`@internal`) runs the listed suites in `SUITE_NAMES` order, each `setup_test` wrapped (after the override merge); `describe_spine_cross_suites` is it over every suite, unwrapped. Each entry's required `transcript` (`SpineSuiteTranscript`) is `'http'` when every send goes through the recorded fixture transports, else `{excluded: {kind, reason}}` (`websocket`, `raw_socket`, `sse`, `embedded_secrets`), each kind held to the module's imports by fuz_app's census (../../test/CLAUDE.md §Cross-backend self-tests).
1334
1136
  - **Options from the handle.** Paths, cookie name and capabilities come from
1335
1137
  `handle.config` — `to_cross_suite_options(handle)`, exported for a suite
1336
1138
  called on its own — the daemon token from the handle, and each suite's
@@ -1357,57 +1159,22 @@ here never reaches it.
1357
1159
  `max_message_bytes` — one value per limit for every suite probing it.
1358
1160
  - **`exclude`** — `{[suite]: reason}`; the reason is required and shows in the
1359
1161
  run as a skipped test. An empty reason, an unknown suite name, a suite
1360
- both excluded and overridden, `testing_backdoor` (it checks the backdoor
1361
- declaration the gating reads), or a suite already skipping itself for an
1362
- undeclared backdoor throws before anything registers.
1363
- - **Backdoors.** `capabilities.testing_backdoors` must declare
1364
- `SPINE_SUITES_REQUIRED_BACKDOORS` (`_testing_reset`, every setup's per-test
1365
- reset, and `_testing_drain_effects`, the audit-read barrier),
1366
- `_testing_put_fact` when `fact_serving` is declared, and
1367
- `_testing_room_evict` when `rooms` is; the call throws otherwise. A suite
1368
- every case of which drives another backdoor (`SuiteEntry.backdoors`:
1369
- `credential_deadline` → `_testing_shorten_credential_expiry`,
1370
- `credential_conformance` → `_testing_credential_read`,
1371
- `origin_conformance` → `_testing_origin_check`, `ws_outbound_overflow` →
1372
- `_testing_flood_notifications`) skips itself on a backend not declaring it,
1373
- as a skipped test beside the excludes whose reason names the backdoor; an
1374
- exclude, override or `exclude_cases` entry for it throws as dead.
1375
- `spine_suites.test.ts` holds the backdoors each suite module names — quoted
1376
- `_testing_*` names, `testing_*_action_spec` references, and the
1377
- `cross_put_fact` / `cross_drain_effects` seeders — to its entry's
1378
- `backdoors`, the required pair, `_testing_put_fact` under
1379
- `capabilities.fact_serving`, or `_testing_room_evict` under
1380
- `capabilities.rooms`; a helper module the suite calls isn't read.
1381
- - **`exclude_cases`** — `SuiteCaseExclusions`, `{[suite]: {[name path]:
1382
- reason}}`: single tests of a suite that runs, each by its name path (the
1383
- describe titles and the test name joined with `' > '` — what the reporter
1384
- prints after the file and any `describe` wrapping the call; a full path, not
1385
- a leaf name, so a title repeated under two describes names one test). One
1386
- `beforeEach` on the calling suite (`register_spine_case_exclusions`) skips
1387
- them at run time with `ctx.skip(reason)`, so the suite files stay as they
1388
- are and each shows as skipped with its reason; it finds a test's suite
1389
- from the top-level task ranges each suite registered (read through
1390
- `TestRunner.getCurrentSuite()` at collection), so an entry matches only
1391
- below its own suite. A reasonless entry, an empty suite map, or an entry for
1392
- an unknown, excluded or self-skipping suite, or for `testing_backdoor`,
1393
- throws at collection; an entry
1394
- naming no test its suite collected fails the closing test
1395
- (`check_spine_case_exclusions`, which reads the collected paths, so a
1396
- filtered run still checks them) — the dead-name check, as the known-divergence
1397
- ledger has.
1398
- - **`overrides`** — `SuiteOverrides`, per suite a `Partial` of its own options
1399
- (`SuiteOptionsMap`), shallow-merged over the derived ones: a role list, an
1400
- `xfail`, a narrower capability set, `ws: undefined` to drop optional socket
1401
- cases (`session_cap` and `testing_backdoor` gate no case on `capabilities.ws`,
1402
- so `ws` is their only socket switch), `extra_methods` to fire a consumer's own
1403
- daemon-token seams through `testing_backdoor` (whose
1404
- `capabilities.testing_backdoors` an override can't change — the call throws
1405
- unless the merge keeps the backend's list). An entry can instead be a function of the derived
1406
- options returning the patch (`SuiteOverride`), for a change built on a
1407
- derived value — an `xfail` added to the derived multi-actor setup — so the
1408
- seeding isn't restated. After the merge, every option the suite's type
1409
- requires (each entry's `required` set, exhaustive by type) must be neither
1410
- `undefined` nor `''`, or the call throws at collection naming suite and key.
1162
+ both excluded and overridden, a suite in `UNEXCLUDABLE_SPINE_SUITES`
1163
+ (`testing_backdoor`, which checks the backdoor declaration the gating reads,
1164
+ and `capability_mounts`, which checks the mount flags), or a suite already
1165
+ skipping itself for an undeclared backdoor throws before anything registers.
1166
+ - **Backdoors.** `capabilities.testing_backdoors` must declare `SPINE_SUITES_REQUIRED_BACKDOORS` (`_testing_reset`, `_testing_drain_effects`), plus `_testing_put_fact` with `fact_serving` and `_testing_room_evict` with `rooms`, or the call throws. A suite whose every case drives another backdoor (`SuiteEntry.backdoors`) skips itself, with the reason, on a backend not declaring it — an exclude, override or `exclude_cases` entry for it throws as dead; `spine_suites.test.ts` holds each entry's `backdoors` to the names its module uses.
1167
+ - **`exclude_cases`** — `SuiteCaseExclusions`, `{[suite]: {[name path]: reason}}`: single tests of a running suite by full name path (describe titles and test name joined with `' > '`, below the calling suite), skipped at run time with the reason. An entry for an unknown, excluded, self-skipping or unexcludable suite throws at collection; one naming no collected test fails the closing test (`check_spine_case_exclusions`).
1168
+ - **`expected_skips`** — `{[name path]: reason}`: the gated skips the backend
1169
+ owes — the cases a suite skips because the backend lacks what they gate on
1170
+ (`test_if`) and the suites skipped for an undeclared backdoor (their line
1171
+ under `SPINE_SUITES_SKIPPED_TITLE`), each by its name path below the calling
1172
+ suite with a required reason. Given, the call ends with
1173
+ `check_declared_skips` over them, an `exclude`d suite's line declared by its
1174
+ `exclude` entry; omitted, no skip is checked. fuz_app's own call keys the
1175
+ list by backend name, so a capability flipped by mistake fails rather than
1176
+ declaring its own skip.
1177
+ - **`overrides`** — `SuiteOverrides`: per suite a `Partial` of its options, or a function of the derived options returning one (`SuiteOverride`), shallow-merged over the derived ones — a role list, an `xfail`, `ws: undefined` to drop optional socket cases. Every option a suite requires must survive the merge non-empty, or the call throws naming suite and key. The unexcludable suites take only what `check_unexcludable_override` allows, so an option added later is refused until classified.
1411
1178
  - **Inputs the handle doesn't carry.** The declared surface is a required
1412
1179
  option. Paths and roles that name the reference spines' mounts (the
1413
1180
  role-gated WS endpoint and its roles) default to the `SPINE_*` constants —
@@ -1431,7 +1198,7 @@ reach, so every `cell_grant_role` arm still turns on the grant, while an admin
1431
1198
  views and edits every cell — `describe_cell_grant_role_cross_tests` refuses
1432
1199
  `ROLE_ADMIN` — and the scoped-assign case of `role_grant_participation` and
1433
1200
  the scoped-revoke case of `role_grant_offer_notification_ws` skip for a
1434
- builtin. fuz_app's own wiring is
1201
+ builtin, and `sse_round_trip`'s other-role keep case for `ROLE_ADMIN`. fuz_app's own wiring is
1435
1202
  `src/test/cross_backend/spine_suites.cross.test.ts`.
1436
1203
 
1437
1204
  ### `cross_backend/rust_spine_consumer_surface.ts` — `create_rust_spine_consumer_surface_spec`
@@ -1478,155 +1245,8 @@ conformance cases assert _expected behavior_ — the security negatives
1478
1245
  (must be refused / must not leak / found-vs-not-found same shape) a
1479
1246
  wire-shape check passes green on even when behavior is wrong.
1480
1247
 
1481
- - `conformance_case.ts` — the `ConformanceCase` type (types only; nothing parses a case):
1482
- `{name, request: {method, params?, params_json?, as, acting?, verb?}, expect: {status,
1483
- error_reason?, error_code?, fields?, headers?, set_cookie?, equivalence_group?}, note?, xfail?}`. A case is **data** — `method`
1484
- resolves its `input`/`output` from the live registry (RPC) or `RouteSpec`
1485
- (the REST auth routes), so the case never carries a schema. `as` is the
1486
- closed `ConformancePrincipal` enum (`keeper` / `daemon` / `invalid_daemon` /
1487
- `daemon_browser` / `token` / `bearer_browser` / `malformed_bearer` / `scoped_token` / `anonymous` /
1488
- `fresh_non_admin` / `role_holder` / `wrong_role` / `expired_session`, and
1489
- the dead credentials `tampered_cookie` / `wrong_daemon` / `unknown_bearer` /
1490
- `revoked_session` / `revoked_token` / `expired_token`) —
1491
- fixture accessors, never inline credential minting.
1492
- The dead credentials each ride a transport carrying nothing else, and each
1493
- is well-formed, so the leg that refuses it is the one named:
1494
- `tampered_cookie` is the keeper's cookie with its MAC changed (present and
1495
- invalid — refused as anonymous and cleared); `wrong_daemon` a token-shaped
1496
- `X-Daemon-Token` that is not the server's; `unknown_bearer` a token-shaped
1497
- bearer no row matches; `revoked_session` a session that verified and was
1498
- revoked (`fixture.mint_revoked_session()` — its cookie still verifies, so it
1499
- is not cleared); `revoked_token` (`fixture.mint_revoked_token()`);
1500
- `expired_token` a token past its `expires_at`
1501
- (`fixture.mint_expired_token()` — on an account of its own, its expiry
1502
- pulled in to `EXPIRED_TOKEN_SHORTEN_SECONDS` by the statement
1503
- `_testing_shorten_credential_expiry` runs, `query_shorten_credential_expiry`,
1504
- then one wait of `EXPIRED_TOKEN_WAIT_MS`, on both fixtures, so the row is
1505
- one production could hold). Each of the three mints proves its credential
1506
- live first — `assert_credential_authenticates`, an `account_verify` over a
1507
- transport carrying only it — and that its revoke removed a row or its expiry rewrote one, and throws
1508
- otherwise: revocation is a row delete, so without that a credential that
1509
- never worked would pass as revoked. Each answers as `anonymous` does, row
1510
- for row.
1511
- `invalid_daemon` sends a malformed `X-Daemon-Token` alongside the keeper
1512
- session cookie over a no-Origin transport: the middleware soft-fail-discards
1513
- the daemon token (matching the Rust spine's `None`), auth falls through to the
1514
- session leg, and a daemon-gated action then refuses the session credential
1515
- with `credential_type_required` — not a hard invalid-token 401 (the session
1516
- base credential is what makes the credential-type gate, not the auth gate, the
1517
- refusing layer).
1518
- `daemon_browser` sends a _valid_ `X-Daemon-Token` in a browser context
1519
- (default `Origin` present) alongside the keeper session cookie: the middleware
1520
- discards the header-bearing token as browser context (mirroring the bearer
1521
- guard + the Rust spine's `is_browser_context`), so auth falls through to the
1522
- session leg → `credential_type_required`. Unlike `daemon` (no Origin → token
1523
- honored → 400 confirm guard), the 403 proves a valid token is _dropped_, not
1524
- honored, when an `Origin` is present.
1525
- `bearer_browser` is the bearer twin: a _valid_ bearer api-token in a browser
1526
- context (default `Origin` present), fresh jar (no session) — the bearer
1527
- middleware discards it, so an authed action 401s, wire-indistinguishable from
1528
- `anonymous` (pinned by the `bearer_soft_fail` equivalence group). The
1529
- `token` principal is the honored counterpart (suppresses `Origin`).
1530
- `malformed_bearer` is the keeper's token minus its last character over a
1531
- no-Origin, empty-jar transport — refused by the shape precheck before any
1532
- database work, so it joins `bearer_soft_fail` too.
1533
- `expired_session` is the keeper behind an expired server-side session
1534
- (`fixture.mint_expired_session()`: a backdated `auth_session` row behind a
1535
- still-valid signed cookie, so the DB-row expiry gate is what refuses it).
1536
- `acting` (`ConformanceActingBinding`) has the runner fill `params.acting`
1537
- with a real actor id: `principal` (the actor of the account the
1538
- principal's credential names), `extra_actor` (`fixture.extra_actors[0]`),
1539
- `keeper_actor` (`fixture.actor`, foreign to every non-keeper principal);
1540
- params must then be an object or omitted, without an `acting` of their own,
1541
- and a principal presenting no account throws.
1542
- `error_reason` is the imported
1543
- `ERROR_*` constant (asserted against the RPC `error.data.reason` or the
1544
- REST flat-body `error`; the dispatcher's 401 carries
1545
- `authentication_required`). `error_reason: null` pins a denial with no
1546
- reason — a handler's bare `forbidden` — as carrying no `data.reason` (RPC
1547
- only: a REST error body always names its code). On every RPC error row the
1548
- runner also asserts the JSON-RPC `error.code`: `error_code` when the row
1549
- names one, else the code the status maps to
1550
- (`http_status_to_jsonrpc_error_code`) — several codes share a status, so a
1551
- refusal under another one (`invalid_request` at 400) states it.
1552
- `check_conformance_cases(cases)` (exported) runs when the table is
1553
- described and throws on a row that can't mean anything: `error_reason: null`
1554
- or `error_code` on a REST row, and a status outside 2xx beside a
1555
- `set_cookie` that mints. `equivalence_group` is the
1556
- **negative-space** axis: every case tagged with the same group string must
1557
- produce a **byte-identical** normalized response (`{status, body}`),
1558
- asserted per impl after the case loop. It promotes a masked pair
1559
- (wrong-password ≡ account-not-found, found-but-unauthorized ≡ not-found)
1560
- from "same status + reason" to "wire-indistinguishable", so a prober
1561
- hitting either spine can't tell the members apart — the twin of the
1562
- positive `output`-schema parity the runner already enforces. The
1563
- per-case status/reason assertions stay the non-vacuous positive control
1564
- (a both-paths-identically-broken group still fails the per-case checks).
1565
- `headers` is the **header** negative-space axis: a string value pins a
1566
- header present-and-equal (case-insensitive name), `null` pins it absent.
1567
- Independent of it, the runner enforces an always-on **no-fingerprint**
1568
- invariant on _every_ response (`conformance_table.ts` `FINGERPRINT_HEADERS`
1569
- — `Server` / `X-Powered-By` / `WWW-Authenticate` must stay absent on both
1570
- spines, so a framework upgrade adding one can't become a silent
1571
- backend-fingerprinting oracle).
1572
- `set_cookie` is the **session cookie** axis, a `SessionCookieEffect`
1573
- (`session_cookie_effect.ts`): `'none'`, `'clear'` (exactly the clearing
1574
- line), `'set'` (exactly one minting line), `'clear_then_set'` (a login
1575
- carrying a stale cookie). **Omitted means `'none'`**, so every row asserts
1576
- it mints and clears nothing unless it says otherwise. The lines are compared
1577
- byte for byte with the spine's own formatters
1578
- (`classify_session_cookie_effect`; lines in no recognised shape fail the
1579
- row) — so a drift in the TS formatter itself is caught by the Rust legs,
1580
- `cookie_attributes` and the credential wire suite, which spell the lines
1581
- themselves. Behind it sits a floor: a response that is not 2xx never mints
1582
- a session cookie (`assert_session_cookie`, HTTP legs) — a backstop, since a
1583
- row can't be written expecting a mint on a refusal. Headers are deliberately kept out of the
1584
- `equivalence_group` `{status, body}` comparison (`Set-Cookie` / `Date` vary).
1585
- - `conformance_table.ts` — `describe_conformance_table_tests({cases,
1586
- setup_test, surface_source, capabilities, rpc_endpoints, live_rpc_endpoints?,
1587
- session_options, principals?, ws?, suite_name?})`. A case's RPC method
1588
- resolves from `rpc_endpoints` first, then from `live_rpc_endpoints` — the
1589
- endpoints the backend live-mounts, for methods kept off the declared surface
1590
- (cell verbs, opt-in resolvers, `_testing_*` backdoors); a backend's whole
1591
- live mount is a fine value, since a declared method still resolves from the
1592
- declared surface. `resolve_conformance_rpc_endpoints({rpc_endpoints,
1593
- live_rpc_endpoints?, session_options})` (exported) builds that lookup list,
1594
- for the table and the differential alike. fuz_app's spine value is
1595
- `create_spine_live_rpc_endpoints()` (`full_spine_mount.ts`), the binary's
1596
- whole mount built on stub deps for resolution only. Same `{setup_test, surface_source,
1597
- capabilities}` protocol every Tier 1 suite uses, so **one case array runs
1598
- both transports** — in-process (`gro test`) and cross-process (the gate,
1599
- each backend's real auth resolution). `resolve_conformance_principal` (exported) maps the
1600
- always-available principals to fixture accessors; `role_holder` /
1601
- `wrong_role` read a seeded `extra_accounts` username named via
1602
- `options.principals`. `send_conformance_case(c, {fixture, surface_source, principals?,
1603
- resolved_rpc_endpoints, request_headers?})` (exported) is the send half — principal resolved,
1604
- request sent, the raw `{target, status, headers, set_cookies, body}` back
1605
- unasserted (`set_cookies` every `Set-Cookie` line in order — a headers
1606
- record folds them; `[]` on the WS leg); the
1607
- table asserts on it, and the cross-backend differential compares two.
1608
- `request_headers` go on the HTTP request beneath the principal's (the
1609
- differential's identity encoding); the WS leg sends none.
1610
- **WS leg:** `ws: WsEndpointTarget` (`{base_url, ws_path, origin?}`) on
1611
- either sends each case as one frame on an admitted socket the principal
1612
- opens — its headers on the upgrade, no `Origin` where the HTTP leg
1613
- suppresses it, its own actor as `?acting=`. Both spines resolve an actor at
1614
- the upgrade, refusing a multi-actor account's upgrade without `?acting=`
1615
- (400 `actor_required`), and per-frame dispatch resolves each frame's
1616
- `acting` on both. The leg always sends `?acting=`, so it does not cover that
1617
- upgrade refusal; the front-door table's multi-actor row does. The frame is the envelope the HTTP
1618
- body is (`serialize_action_result` on TS), so the response reads
1619
- `{status, headers: {}, body: frame}` with `status` the code's
1620
- `jsonrpc_error_code_to_http_status` (200 for a result) and every row holds
1621
- unchanged. What WS loses is headers — the TS DEV-only `X-Fuz-Auth-Debug`
1622
- among them. `is_ws_conformance_case(c)` (exported) is the filter: RPC, sent
1623
- `POST`, no header value pinned, a session cookie effect of `'none'`, a
1624
- principal that can hold a socket — not
1625
- `anonymous` / `bearer_browser` / `malformed_bearer` / `expired_session` or
1626
- a dead credential, refused at the upgrade, nor `scoped_token`, refused `surface:ws_upgrade`
1627
- there (a narrowed bearer can never send a frame, so no per-frame scope row
1628
- exists; the front-door table pins the upgrade refusal). An equivalence
1629
- group left with one member on the WS leg is dropped. Cross-process only.
1248
+ - `conformance_case.ts` — the `ConformanceCase` type (data, never parsed): `{name, request: {method, params?, params_json?, as, acting?, verb?}, expect: {status, error_reason?, error_code?, fields?, headers?, set_cookie?, equivalence_group?}, note?, xfail?}`. `method` resolves its schemas from the live registry (RPC) or the REST auth routes. `as` is a closed `ConformancePrincipal` — fixture accessors, never inline minting; what each principal sends and which leg refuses it is on the type. `acting` (`ConformanceActingBinding`) has the runner fill `params.acting` with a real actor id. Beyond status and reason (`error_reason: null` pins an RPC denial carrying no `data.reason`): `error_code` (else the status's default JSON-RPC code), `equivalence_group` (members answer byte-identical `{status, body}`), `headers` (present-and-equal, or `null` for absent), `set_cookie` (a `SessionCookieEffect`; **omitted means `'none'`**). Always checked: no fingerprint header (`FINGERPRINT_HEADERS`), and no session cookie minted outside 2xx. `check_conformance_cases` refuses a row that can't mean anything.
1249
+ - `conformance_table.ts` — `describe_conformance_table_tests({cases, setup_test, surface_source, capabilities, rpc_endpoints, live_rpc_endpoints?, session_options, principals?, ws?, suite_name?})`, on the Tier 1 fixture protocol, so **one case array runs in-process and cross-process**. Methods resolve from `rpc_endpoints`, then `live_rpc_endpoints` (methods kept off the declared surface; fuz_app's is `create_spine_live_rpc_endpoints()`) — `resolve_conformance_rpc_endpoints`; `send_conformance_case` is the send half the differential shares; `role_holder` / `wrong_role` read an `extra_accounts` username named in `principals`. `ws` (cross-process only) re-sends each case `is_ws_conformance_case` admits as one frame on a socket the principal opens, under the same expectations; an equivalence group left with one member there is dropped.
1630
1250
  - `conformance_rpc_auth.ts` — `generate_rpc_auth_conformance_cases({surface_source,
1631
1251
  live_rpc_endpoints?, skip_methods?})` → `ConformanceCase[]` from each declared RPC method's
1632
1252
  `RouteAuth`, then each live-mounted one the declared surface lacks
@@ -1657,6 +1277,25 @@ capabilities}` protocol every Tier 1 suite uses, so **one case array runs
1657
1277
  live gates, and the Rust spine dispatches its own. Input-dependent handler
1658
1278
  checks stay hand-written rows. fuz_app spreads it into both conformance
1659
1279
  legs.
1280
+ - `declared_skips.ts` — gated skips and the check over them.
1281
+ `test_skip_gated(name, fn)` registers a skipped test tagged
1282
+ `TaskMeta.fuz_gated_skip` (`is_gated_skip` reads it) — what `test_if`,
1283
+ `describe_spine_cross_suites`' skipped-suite lines and `capability_mounts`'
1284
+ rows with no WebSocket endpoint to probe (`gated_skip`) register; every skip a
1285
+ backend's declarations cause goes through it, and only the informational
1286
+ `UNPROBED_CAPABILITIES` rows stay plain skips. The tag is set at
1287
+ registration, so a `-t` filter or `.only` never changes it.
1288
+ `check_declared_skips(expected)` registers a closing test (named
1289
+ `DECLARED_SKIPS_CHECK_NAME`) that reads every test under its suite — the
1290
+ enclosing `describe`, or the file — and holds the tagged ones to
1291
+ `expected`, name path below that suite → required reason
1292
+ (`find_declared_skip_problems`, the pure half): an undeclared skip fails, so
1293
+ does an entry whose test was registered to run (stale) or that names no
1294
+ test. A nested suite with a check of its own owns its subtree: an outer
1295
+ check neither collects nor needs declared what sits below it. fuz_app calls it in every single-backend cross file with a gated case,
1296
+ and per backend in the security and timing projects; the transcript
1297
+ differential holds both sides to its `expected_skips` the same way and
1298
+ leaves the declared skips out of its whole-run count.
1660
1299
  - `xfail.ts` — `xfail_until(marker, name, fn)` for deferred-by-design rows,
1661
1300
  `marker` an `XfailMarker` `{tracking_id, reason, fails_with}`. `fails_with`
1662
1301
  is required — a `RegExp` over the thrown message or a predicate over the
@@ -1697,11 +1336,12 @@ without.
1697
1336
 
1698
1337
  | suite | pins | gate |
1699
1338
  | --- | --- | --- |
1700
- | `account_lifecycle` | soft delete → undelete, keeper-confirmed purge, the `cannot_delete_keeper` guard, session-only self-delete, a deleted account's credentials refused — and still refused after the undelete, a fresh login working; role grants kept through the delete and conferring again after the undelete, offers made to the account staying superseded, its unclaimed invites void (a claimed one untouched) — each audit row, the `include_deleted` listing; and, ungated, a password change ending every session and API token of the account while another account's stay live | `account_lifecycle` (all but the password case) |
1339
+ | `account_lifecycle` | soft delete → undelete, keeper-confirmed purge, the `cannot_delete_keeper` guard, session-only self-delete, a deleted account's credentials refused — and still refused after the undelete, a fresh login working; role grants kept through the delete and conferring again after the undelete, offers made to the account staying superseded (and, on a purge, superseded and audited before the cascade), its unclaimed invites void (a claimed one untouched) — each audit row, the `include_deleted` listing; and, ungated, a password change ending every session and API token of the account while another account's stay live | `account_lifecycle` (all but the password case) |
1701
1340
  | `actor_lookup` | the keeper resolves its own actor in the leak-safe wire shape (the refusals are table rows) | — |
1702
1341
  | `app_settings` | an anonymous signup reads `open_signup` fresh after `app_settings_update` | — |
1703
1342
  | `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 | — |
1704
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) | — |
1344
+ | `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) |
1705
1345
  | `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`) |
1706
1346
  | `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` |
1707
1347
  | `cell_grant_role` | role-shaped `cell_grant`: holder admitted, non-holder excluded, unregistered role refused, the `cell_list shared_with:'me'` role arm | `cell_relations` |
@@ -1710,11 +1350,9 @@ without.
1710
1350
  | `cell_ref_admission` | possession-gated fact refs: one refusal for stored and unstored hashes, holders by upload, clones per row, the admin bypass, the ref grammar | `fact_serving` (grant, item, clone cases also `cell_relations`) |
1711
1351
  | `cell_relations` | grant / field / item / clone / audit verbs, the relation-read visibility filter (a child the reader can't view is absent, never an edge), a clone dropping children its cloner can't view | `cell_relations` |
1712
1352
  | `cookie_attributes` | the session `Set-Cookie`: `HttpOnly; Secure; SameSite=Strict; Path=/` + `Max-Age` on login, none on a failed login, `Max-Age=0` with the same flags on logout | — |
1713
- | `credential_deadline` | a socket on a session or an API token closes with `WS_CLOSE_SESSION_REVOKED` "Credential expired" at its credential's expiry; an audit stream on a session ends there | `ws`, `sse`; `_testing_shorten_credential_expiry` |
1714
1353
  | `credential_conformance` | every row of `credential_conformance.json` through `_testing_credential_read`: how the backend reads the session cookie, the bearer and the daemon token out of a request's header lines, and the lines it refuses as no header lines | `_testing_credential_read` |
1715
1354
  | `credential_conformance_wire` | raw socket: each row's header lines sent as an RPC `POST` and as a WebSocket upgrade — which credential authenticated (the account `account_verify` answers) and the exact clearing `Set-Cookie`, or none; the clear's scope, its order ahead of a login's new cookie, and a minted cookie authenticating as sent | `ws` (the upgrade leg; with `ws_account_actions` an accepted upgrade also answers `account_verify` on the socket, naming the credential) |
1716
- | `request_header_conformance_wire` | raw socket: each row of `request_header_conformance.json` sent as an RPC `POST` and as a WebSocket upgrade — an empty, repeated or off-grammar `Origin`, `Host` or `Content-Type` refused with its code, any `Origin` or `Referer` line discarding a bearer or daemon token, the gates' order; the accounts and raw sends shared with the credential wire suite (`credential_wire.ts`). Assumes the backend's own origin allowed (`overrides` names another) | `ws` (the upgrade leg), `ws_refusal_body`, `ws_upgrade_runtime_refusals` (per row), `host_gate` (the rows the host gate refuses) |
1717
- | `request_target_conformance_wire` | raw socket: each `wire` row of `request_target_conformance.json` sent as written — an escape that doesn't decode refused in each surface's shape (the RPC `GET`'s `invalid_request` envelope, 400 `invalid_query_params` on a REST query and the WS upgrade, 400 `invalid_route_params` on a path param, always JSON), the decodable controls echoed exactly, a route that reads no query refusing nothing in it; and the routing rows — a method a routed path doesn't serve → 405 with `Allow` (compared as a set, absent on a gate's refusal) and `method_not_allowed`, an unmatched path → `route_not_found` under `/api/` and the plain-text 404 elsewhere, an encoded or doubled-slash spelling of a routed path unrouted, dot segments per `runtime_resolves_dot_segments`. A row's `requires` is a list of capabilities and each requirement set is its own test, skipped when the backend doesn't declare it | `ws`, `sse`, `account_status`, `fact_serving`, `fact_serving_admin_hash`, `spine_fallback` (per row), `ws_refusal_body`, `runtime_resolves_dot_segments` |
1355
+ | `credential_deadline` | a socket on a session or an API token closes with `WS_CLOSE_SESSION_REVOKED` "Credential expired" at its credential's expiry; an audit stream on a session ends there | `ws`, `sse`; `_testing_shorten_credential_expiry` |
1718
1356
  | `credential_header_robustness` | raw socket: an oversized or control-character credential header never escalates, smuggles a request, desyncs, or wedges the server (a duplicated one is `credential_conformance_wire`'s) | — |
1719
1357
  | `fact_serving` | `GET /api/cells/:cell_id/facts/:hash` per reference, the hardening headers, bodyless masked 404s; the admin-only `GET /api/facts/:hash` | `fact_serving` (bare-hash cases also `fact_serving_admin_hash`) |
1720
1358
  | `identity_parity` | `Username` / `UsernameProvided` / `Email` end to end: login canonicalization, username-or-email login, login input validation, ASCII-only creation, the `USERNAME_LENGTH_MIN`..`USERNAME_LENGTH_MAX` edges, email format — each by error reason | — |
@@ -1724,9 +1362,11 @@ without.
1724
1362
  | `peer_ping_ws` | the server→client `peer/ping` round trip and its negatives (unsolicited response, id isolation, timeout, wrong shape, client error, no transport over HTTP) | `peer_request` |
1725
1363
  | `query_shape` | duplicate-key, unknown-key, and phase-order query semantics on the status route, the RPC `GET`, and the bare-hash fact route | `account_status`, `fact_serving_admin_hash` (per case) |
1726
1364
  | `ready` | anonymous `GET /ready` → `200 {ready: true}` over the committed `expected_schema.json` | `ready` |
1365
+ | `request_header_conformance_wire` | raw socket: each row of `request_header_conformance.json` sent as an RPC `POST` and as a WebSocket upgrade — an empty, repeated or off-grammar `Origin`, `Host` or `Content-Type` refused with its code, any `Origin` or `Referer` line discarding a bearer or daemon token, the gates' order; the accounts and raw sends shared with the credential wire suite (`credential_wire.ts`). Assumes the backend's own origin allowed (`overrides` names another) | `ws` (the upgrade leg), `ws_refusal_body`, `ws_upgrade_runtime_refusals` (per row), `host_gate` (the rows the host gate refuses) |
1366
+ | `request_target_conformance_wire` | raw socket: each `wire` row of `request_target_conformance.json` sent as written — an escape that doesn't decode refused in each surface's shape (the RPC `GET`'s `invalid_request` envelope, 400 `invalid_query_params` on a REST query and the WS upgrade, 400 `invalid_route_params` on a path param, always JSON), the decodable controls echoed exactly, a route that reads no query refusing nothing in it; and the routing rows — a method a routed path doesn't serve → 405 with `Allow` (compared as a set, absent on a gate's refusal) and `method_not_allowed`, an unmatched path → `route_not_found` under `/api/` and the plain-text 404 elsewhere, an encoded or doubled-slash spelling of a routed path unrouted, dot segments per `runtime_resolves_dot_segments`. A row's `requires` is a list of capabilities and each requirement set is its own test, skipped when the backend doesn't declare it | `ws`, `sse`, `account_status`, `fact_serving`, `fact_serving_admin_hash`, `spine_fallback` (per row), `ws_refusal_body`, `runtime_resolves_dot_segments` |
1727
1367
  | `role_grant_offer_enumeration` | `role_grant_offer_accept`'s deliberate split: a nonexistent offer → 404 `role_grant_offer_not_found`, a sibling actor's on the caller's own account → 403 `role_grant_offer_actor_mismatch` | — |
1728
- | `role_grant_offer_lifecycle` | a decline or retract by a non-party → 404 identical to a missing offer; of a decided offer → 400 `role_grant_offer_terminal`; an accept after a decline or a retract the same, granting nothing, and a replayed accept answering the first grant; one audit row per success, none per refusal; lost grantor authority supersedes pending offers; a recipient's delete supersedes every pending offer to it, and an offer to a deleted account or actor answers as one to a missing one | — |
1729
- | `role_grant_offer_notification_ws` | each offer and role-grant notification strict-parsed against its params schema, with a bystander socket that must receive nothing behind a `heartbeat` barrier | `ws` |
1368
+ | `role_grant_offer_lifecycle` | a decline or retract by a non-party → 404 identical to a missing offer; of a decided offer → 400 `role_grant_offer_terminal`; a re-offer while pending answering the same offer, its `to_actor_id` narrowed or widened to the request's, and a new offer once decided; an accept after a decline or a retract the same, granting nothing, and a replayed accept answering the first grant; one audit row per success, none per refusal; lost grantor authority supersedes pending offers; a recipient's delete supersedes every pending offer to it, and an offer to a deleted account or actor answers as one to a missing one | — |
1369
+ | `role_grant_offer_notification_ws` | each offer and role-grant notification strict-parsed against its params schema — a revoke's supersedes reaching every party's socket, and (with `account_lifecycle`) a delete's and a purge's reaching the live parties while the removed account's socket closes having heard nothing — the target socket hearing exactly the expected notifications once each, in order, and a bystander socket that must receive nothing, both behind a `heartbeat` barrier | `ws` |
1730
1370
  | `role_grant_participation` | the success paths of app-role conferral: assign + idempotency, a scoped assign, offer → accept, offer replay | — |
1731
1371
  | `role_grant_role_grammar` | an off-grammar `role` or scope kind on the grant verbs → `invalid_params` with no reason and no audit row | — |
1732
1372
  | `rooms_ws` | the room verbs and their notifications in `seq` order, the refusals' codes and reasons, exclusivity, eviction, disconnect, the per-connection limiter | `ws` + `rooms` |
@@ -1734,7 +1374,7 @@ without.
1734
1374
  | `session_cap` | a login past the per-account session cap evicts the oldest session and only it, closing its socket with the revoked reason while a kept session's socket stays open; the session list marks the caller's own | — (the socket case runs when given a `ws` target) |
1735
1375
  | `session_cookie_codec` | exactly one accepted spelling of a signed cookie: non-canonical signature or `expires_at` spellings refused | — |
1736
1376
  | `simple_request` | an untyped, CORS-safelisted, or non-JSON `POST` to a JSON route → 415 `unsupported_content_type` | — |
1737
- | `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, the per-session stream cap | `sse` (delete and purge also `account_lifecycle`) |
1377
+ | `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`) |
1738
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) |
1739
1379
  | `testing_backdoor` | the backdoor declaration, and every declared `_testing_*` action refusing anonymous, session, and bearer callers | `testing_backdoors` (the declaration) |
1740
1380
  | `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 | — |
@@ -1760,8 +1400,8 @@ What the suites share:
1760
1400
  `RpcResult` carries the HTTP `status` beside the envelope; a reply that is no
1761
1401
  JSON object throws naming the method, the status and the body's head.
1762
1402
  - **`cross_backend/audit_cross_helpers.ts`** — `list_audit_events(fixture,
1763
- params, rpc_path?)` drains first (`cross_drain_effects`, which refuses an
1764
- answer without `tracked: true`), then lists and parses every row's metadata
1403
+ params, rpc_path?)` drains first (`cross_drain_effects`, which refuses any
1404
+ answer but exactly `{ok: true}`), then lists and parses every row's metadata
1765
1405
  (`assert_audit_event_metadata`), so no reader skips the barrier.
1766
1406
  `assert_audit_metadata_fields(fixture, metadata, expected, absent?)` compares
1767
1407
  field by field, so a consumer's added key passes unless the fixture closed
@@ -1950,7 +1590,7 @@ Conventions that hold across them:
1950
1590
  types for the **`on_request`** seam: a responder answers a server-initiated
1951
1591
  request (`{result}` / `{error}` / `undefined` to swallow), the path
1952
1592
  `describe_peer_ping_ws_tests` drives. With no `on_request` the seam is inert
1953
- (a server-initiated request flows to `messages` as before).
1593
+ (a server-initiated request flows to `messages`).
1954
1594
  - `testing/transports/ws_transport.ts` — `create_ws_transport({base_url, ws_path, cookies, origin?, on_request?, headers?})` (`origin: null` sends no `Origin`, which a daemon-token upgrade needs; a refused upgrade rejects with `WsUpgradeRefusedError`, carrying the refusal's `status` and `body`), returning a `WsTransportClient` — a `WsClient` plus `send_text(text)`, which writes one frame verbatim (a frame that is not JSON).
1955
1595
  It builds a real-upgrade WS client using the `ws` npm package (optional
1956
1596
  peerDep; consumers wiring cross-process tests `npm install --save-dev ws`).
@@ -2039,192 +1679,41 @@ Conventions that hold across them:
2039
1679
  `*_attack_surface.json` snapshot is an observability artifact for human
2040
1680
  inspection + gen-time drift detection
2041
1681
  (`assert_surface_matches_snapshot`); it is not consumed at test runtime.
2042
- - `testing/cross_backend/testing_reset_actions.ts` —
2043
- `create_testing_actions(deps, options)` factory returning the
2044
- `_testing_*` backdoor actions, `_testing_reset` among them. Test binaries
2045
- register them on their RPC endpoint; `default_cross_process_setup` fires
2046
- `_testing_reset` unconditionally per test. Its handler first fires the consumer-supplied `reset_state(db)`
2047
- callback for domain-state reset — before the auth wipe, because domain
2048
- rows depend on auth rows (a domain table with a restricting FK to `actor`
2049
- must empty before the actor delete) — then DELETEs every auth-namespace
2050
- row (no keeper-preserve filter), resets `app_settings` to production
2051
- defaults, flips `bootstrap_lock.bootstrapped = true`, inline-seeds a fresh
2052
- keeper via `create_test_account_with_credentials` (same primitive
2053
- in-process uses, keeping write semantics in parity), queues the refresh
2054
- of `DaemonTokenState.keeper_account_id` to the new row as a post-commit
2055
- effect as soon as the keeper exists (so a reset that rolls back — a
2056
- failing extra seed, a failed commit — leaves the cache on the keeper
2057
- still in the database, and the next reset can still authenticate), then
2058
- seeds any `extra_accounts` at the same bootstrap-equivalent step (the
2059
- only path for roles like `ROLE_KEEPER` whose `grant_paths` is
2060
- bootstrap-only). `reset_state` is passed the **transactional** `Db` the
2061
- auth wipe then runs on, so DB-domain consumers (e.g. fuz_forge truncating
2062
- its cell / fact / file tables) reset on the same connection rather than a
2063
- separately-pooled one that would deadlock against this open transaction
2064
- under the in-memory drivers. Auth
2065
- gates on `credential_types: ['daemon_token']` — effectively keeper-only
2066
- without forcing the `actor: 'required'` ⟺ `acting?: ActingActor`
2067
- biconditional. No free-form runtime grant action exists — see the
2068
- `testing_reset_actions.ts` TSDoc for the audit + WS fan-out rationale
2069
- that rejected a `_testing_seed_role_grant` shape.
2070
-
2071
- Same module also exports `create_testing_drain_effects_action(audit)` — the
2072
- `_testing_drain_effects` RPC action (daemon-token-gated, like
2073
- `_testing_reset`). It awaits `audit.drain_inflight()` so a following
2074
- `audit_log_list` is authoritative — the deterministic barrier a
2075
- cross-process audit assertion fires before reading (no poll/sleep). The
2076
- emitter must be built with `create_audit_emitter({track_inflight: true})`
2077
- (the spine binary's `audit_factory` does — pinned by
2078
- `cross_backend/testing_spine_server.audit.test.ts`), or the drain resolves at once.
2079
- The action answers `{ok: true, tracked}`, `tracked` read from
2080
- `audit.is_tracking_inflight()`, and `cross_drain_effects` refuses anything but
2081
- `tracked: true` — so a binary built over an untracked emitter fails its first
2082
- audit read rather than racing it. The Rust twin answers the same shape.
2083
- The barrier is needed whatever the transport: HTTP on a binary running
2084
- `await_pending_effects: true` settles a mutation's writes before
2085
- responding, but WS replies before its effects flush, so a WS mutation's
2086
- audit write can still be in flight when its reply arrives. The drain waits
2087
- until no tracked `emit` write is outstanding — writes started while it
2088
- waits included — the same wait-for-zero as the Rust spine's
2089
- `AuditEmitter::drain_inflight` over `new_with_inflight_tracking`.
2090
- `create_testing_actions` bundles it over `deps.audit`; suites that mount
2091
- their own endpoint (e.g. the in-process
2092
- `account_lifecycle_parity.db.test.ts`) add it directly, over a tracked
2093
- emitter, so the shared suite body can call the barrier on every backend
2094
- uniformly.
2095
-
2096
- Also bundled: `_testing_flood_notifications`
2097
- (`create_testing_flood_notifications_action()`) — queues `count`
2098
- notifications of `size` payload bytes each (method `_testing_flood`, params
2099
- `{index, payload}`) onto the caller's own WebSocket connection in one
2100
- synchronous run and answers `{queued: count}`, so a suite can push a
2101
- connection's outbound queue past its byte budget from outside. Refused with
2102
- `invalid_params` past `TESTING_FLOOD_MAX_COUNT`, `TESTING_FLOOD_MAX_SIZE`, or
2103
- `TESTING_FLOOD_MAX_TOTAL_BYTES` (`count` × `size`), and over HTTP (reason
2104
- `no_connection` — there is no connection to queue onto). The Rust mirror is
2105
- `fuz_testing::create_testing_flood_notifications_action_spec`.
2106
-
2107
- Also bundled: `_testing_mint_session` — mints a backdated-expiry
2108
- `auth_session` row for an account (via `mint_test_session` in `app_server.ts`)
2109
- and returns its signed cookie value (future-dated payload). Backs the
2110
- `expired_session` conformance principal: the backdated DB row + valid cookie
2111
- payload isolate the authoritative server-side DB-row expiry gate
2112
- (`query_session_get_valid` — `expires_at > NOW()`), the gate the in-process
2113
- payload-expiry tests never reached. Daemon-token-gated like its siblings; the
2114
- Rust mirror is `fuz_testing::create_testing_mint_session_action_spec`.
2115
-
2116
- In the hono-free sibling `testing/cross_backend/testing_origin_check.ts`,
2117
- **not** bundled: `_testing_origin_check`
2118
- (`create_testing_origin_check_action()`, `run_testing_origin_check(input)`,
2119
- `TestingOriginCheckInput` / `TestingOriginCheckOutput`) — answers the origin
2120
- allowlist's parse and request check for one `{patterns, origin}` pair:
2121
- `{ok: true, allowed}` or `{ok: false, errors: [{index?, kind}]}`. Pure, no
2122
- database. Kept out of the bundle so a consumer whose Rust binary doesn't
2123
- mount the mirror (`fuz_testing::create_testing_origin_check_action_spec`)
2124
- keeps an exact action-manifest gate; the spine binary appends it in
2125
- `build_full_spine_rpc_actions`.
2126
-
2127
- In the hono-free sibling `testing/cross_backend/testing_credential_read.ts`,
2128
- also **not** bundled: `_testing_credential_read`
2129
- (`create_testing_credential_read_action(deps)`,
2130
- `run_testing_credential_read(input, deps)`, `TestingCredentialReadInput` /
2131
- `TestingCredentialReadOutput`) — reads a list of raw header lines as the
2132
- credential legs would: `{session_cookie: 'absent' | 'invalid' | 'valid',
2133
- bearer_token, daemon_token}`, the tokens as read or `null`. Pure: it runs
2134
- the readers of `auth/credential_headers.ts` and the cookie verify, no
2135
- database, and never the request's own headers. `lines` is capped
2136
- (`TESTING_CREDENTIAL_READ_LINES_MAX` lines of at most
2137
- `TESTING_CREDENTIAL_READ_LINE_LENGTH_MAX` characters, the same bounds on
2138
- the Rust mirror), and every refusal of it — over a cap, or a line that is no
2139
- header line: a control byte, DEL, a character above U+00FF, no `:` — is
2140
- `invalid_params` with `ERROR_TESTING_CREDENTIAL_READ_LINE`. Appended in
2141
- `build_full_spine_rpc_actions`; the Rust mirror is
2142
- `fuz_testing::create_testing_credential_read_action_spec`.
2143
-
2144
- Back in `testing_reset_actions.ts`, also **not** bundled:
2145
- `_testing_shorten_credential_expiry`
2146
- (`create_testing_shorten_credential_expiry_action()`) — pulls an account's
2147
- `auth_session` and `api_token` expiries in to `seconds` (1–60) from now,
2148
- shorten-only (`LEAST`, an eternal token gaining one), answering
2149
- `{sessions, api_tokens}` counts. Applied before a connection opens, since
2150
- the deadline is read when the credential resolves. Backs
2151
- `describe_credential_deadline_cross_tests`; appended in
2152
- `build_full_spine_rpc_actions` for the same manifest reason as
2153
- `_testing_origin_check`. The Rust mirror is
2154
- `fuz_testing::create_testing_shorten_credential_expiry_action_spec`.
2155
-
2156
- Also not bundled: `_testing_room_evict`
2157
- (`create_testing_room_evict_action(registry)`, input
2158
- `{target: TestingRoomEvictTarget, reason}`) — calls the room registry's
2159
- `evict` and answers its `{seats, watches, pending}` count, so the rooms suite
2160
- pins eviction without a consumer's domain. It needs the registry the room
2161
- verbs run on, so the full-mount layer appends it beside them. The Rust mirror
2162
- is `fuz_testing::create_testing_room_evict_action_spec`.
2163
-
2164
- Also in `testing_reset_actions.ts` — but **not** bundled by
2165
- `create_testing_actions` — `_testing_action_manifest` (+ `create_testing_action_manifest_action(mounted, ws_only?)`, `ws_only` the WebSocket-only actions it lists as `transport: 'ws'`):
2166
- dumps the live RPC registry as a normalized `ActionManifest` for the
2167
- cross-impl manifest-parity gate (see §Cross-impl RPC-manifest parity). It must
2168
- enumerate _every_ mounted method, which `create_testing_actions` (one
2169
- sub-factory) can't see, so it's appended at the full-mount layer
2170
- (`full_spine_mount.ts` `build_full_spine_rpc_actions`), closing over the
2171
- complete action list plus its own spec. Daemon-token-gated like its siblings;
2172
- the Rust mirror is `fuz_testing::create_testing_action_manifest_action_spec`.
1682
+ - `testing/cross_backend/testing_reset_actions.ts` (+ the hono-free `testing_origin_check.ts`, `testing_credential_read.ts`) — the `_testing_*` backdoors, each daemon-token-gated (`credential_types: ['daemon_token']`) and mirrored by a `fuz_testing` spec on the Rust spine. `create_testing_actions(deps, options)` bundles what every test binary mounts; the rest are appended at the full-mount layer (`build_full_spine_rpc_actions`), so a consumer whose Rust binary lacks a mirror keeps an exact action-manifest gate:
1683
+
1684
+ | action | bundled | does |
1685
+ | --- | --- | --- |
1686
+ | `_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
+ | `_testing_drain_effects` | yes | answers `{ok: true}` once no audit pool write is in flight, writes started while it waits included — the barrier before an audit read (WS replies before its effects flush) |
1688
+ | `_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) |
1690
+ | `_testing_put_fact` | yes | seeds a fact, with an optional holder or external URL |
1691
+ | `_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
+ | `_testing_schema_snapshot`, `_testing_migration_tracker` | yes | the parity gates' reads |
1693
+ | `_testing_origin_check`, `_testing_credential_read` | no | the origin matcher and the credential header readers, pure |
1694
+ | `_testing_shorten_credential_expiry` | no | pulls an account's session and token expiries in (shorten-only) |
1695
+ | `_testing_room_evict` | no | the room registry's `evict` |
1696
+ | `_testing_action_manifest` | no | the live registry as an `ActionManifest` |
1697
+
1698
+ No free-form grant backdoor exists (the module doc says why). The keeper's
1699
+ cached id (`DaemonTokenState.keeper_account_id`) moves to a reset's new keeper
1700
+ only after its commit, so a rolled-back reset leaves the next one able to
1701
+ authenticate.
2173
1702
 
2174
1703
  ### Testing-backdoor declaration + credential gate — `cross_backend/testing_backdoor.ts`
2175
1704
 
2176
1705
  `describe_testing_backdoor_cross_tests({setup_test, capabilities, rpc_path?,
2177
- ws?, extra_methods?})` — the backend's backdoor declaration, then the
2178
- negative-credential parity suite for the `_testing_*` backdoor actions.
2179
-
2180
- **Declaration.** `capabilities.testing_backdoors` lists the backdoors the
2181
- backend mounts, from `TESTING_BACKDOOR_METHODS` (`spine_surface_constants.ts`,
2182
- the one list; `spine_surface_constants.testing_backdoors.test.ts` holds it to
2183
- the `_testing_*` actions fuz_app's spine binary mounts). Each known backdoor
2184
- the list leaves out is sent anonymously and must answer `method_not_found`
2185
- (404): both spines look the method up before they authenticate (the TS
2186
- dispatcher's lookup step, the Rust `perform_action`'s), so an unmounted method
2187
- answers that whatever the credential, and a mounted one a 401. Each declared
2188
- one gets the rows below, whose anonymous row fails as "declared but not
2189
- mounted" on a `method_not_found`. So the declaration can't lie in either
2190
- direction, and the suites gated on it skip only what the backend lacks. A
2191
- declared name outside the known list, or a duplicate, throws at collection.
2192
- The suite runs on every backend, one declaring only the required backdoors
2193
- included — `describe_spine_cross_suites` refuses to exclude it, skip any of
2194
- its cases, or hand it other `capabilities` through `overrides`.
2195
-
2196
- **Credential gate.** For each declared backdoor (the privileged writes, the
2197
- audit barrier, the connection flood, and the introspection reads), and each
2198
- `extra_methods` entry (`TestingBackdoorProbe` `{method, params?}` — a
2199
- consumer's own daemon-token seam, which must start with `_testing_` and not be
2200
- a known backdoor), it fires three principals over real HTTP: **anonymous** →
2201
- 401 `unauthenticated`, **session** → 403 `forbidden` `credential_type_required`,
2202
- **bearer** → 403 `forbidden` `credential_type_required` — and, when `ws`
2203
- (`{base_url, ws_path, origin?}`) is passed, sends each on a socket opened with
2204
- the keeper's session cookie, which answers the same `forbidden`
2205
- `credential_type_required` (a socket is no way around the daemon-token channel) —
2206
- proving the daemon-token gate that fences each backdoor action holds end-to-end
2207
- on the real dispatcher (the spec-derived `describe_rpc_attack_surface_tests`
2208
- never enumerates them because they're off the declared surface). Each method is
2209
- sent with **valid** params so each case varies only the credential (validation
2210
- runs after the gates — order is 401 → authz → 403 → 429 → 400); the handler never
2211
- runs. The known backdoors' params are a `Record<TestingBackdoorMethod, …>`, so a
2212
- backdoor added to the list fails typecheck until it has them. Cited property:
2213
- `docs/security.md` §Test Backdoor Actions. The credential rows run
2214
- cross-process only (the `_testing_*` actions are mounted on the spawned binary,
2215
- not the in-process app — like the ws/sse suites); in-process, an app mounting
2216
- none declares none and gets the declaration rows alone, one per known backdoor
2217
- — fuz_app's in-process leg is `cross_backend/testing_backdoor_parity.db.test.ts`,
2218
- while its cross legs declare every backdoor, so they run no declaration row.
2219
- The complement is the
2220
- in-process spec-level gate test (`src/test/testing/testing_actions_auth.test.ts`,
2221
- asserting each spec declares `credential_types: ['daemon_token']`) + the
2222
- `assert_no_testing_methods` surface invariant. fuz_app's conformance table
2223
- also covers the same gates, through the auth rows it generates over the live
2224
- mount (`live_rpc_endpoints`), which the differential compares across spines;
2225
- this suite stays for consumers whose backends mount the `_testing_*` actions
2226
- without a conformance table over their live mount, and for the declaration
2227
- check.
1706
+ ws?, extra_methods?})` holds `capabilities.testing_backdoors` to the backend
1707
+ both ways — a known backdoor (`TESTING_BACKDOOR_METHODS`) left out must
1708
+ answer `method_not_found` anonymously, a declared one must be mounted — then
1709
+ sends every declared backdoor and `extra_methods` probe (each starting
1710
+ `_testing_`, never a known backdoor) as anonymous (401), session and bearer
1711
+ (403 `credential_type_required`), and on a session socket when `ws` is given,
1712
+ with valid params so only the credential varies. It runs on every backend and
1713
+ can't be excluded; in-process, an app mounting none gets the declaration rows
1714
+ alone. Property: ../../../docs/security.md §Test Backdoor Actions; the
1715
+ spec-level complement is `assert_no_testing_methods` and
1716
+ `src/test/testing/testing_actions_auth.test.ts`.
2228
1717
 
2229
1718
  ### Limiter-enabled backends — `login_security.ts` + `ws_action_rate_limit.ts`
2230
1719
 
@@ -2243,10 +1732,8 @@ to boot on a cap without the flag.
2243
1732
  Neither suite resets a limiter: each case isolates itself with its own
2244
1733
  forwarded IP or the fresh keeper `_testing_reset` seeds. The IP cases'
2245
1734
  addresses are fixed per process and their buckets outlive the reset, so a
2246
- vitest retry of one fails. fuz_app runs both under the dual-spawn
2247
- `cross_backend_security` project (`npm run test:cross:security`); the
2248
- in-process limiter and proxy paths are `describe_rate_limiting_tests` and the
2249
- proxy middleware tests.
1735
+ vitest retry of one fails. fuz_app's wiring: ../../test/CLAUDE.md
1736
+ §Cross-backend self-tests.
2250
1737
 
2251
1738
  ### Timing overrides — `timing_env`
2252
1739
 
@@ -2259,16 +1746,10 @@ through `timing_env` (`default_backend_configs.ts`), which sets
2259
1746
  `spine_surface_constants.ts`. Both spine binaries read them as a positive
2260
1747
  integer of ms up to 2³¹ − 1 and refuse to boot on anything else; unset keeps
2261
1748
  the defaults (`SSE_KEEP_ALIVE_INTERVAL_MS`, `DEFAULT_WS_RECEIVE_TIMEOUT`).
2262
- fuz_app's `cross_backend_timing` project shortens both, so its suites watch
2263
- each spine's timers fire within seconds. `db_checkout_timeout_ms` and
2264
- `db_audit_checkout_timeout_ms` set the production pool checkout bounds
2265
- (`FUZ_DB_CHECKOUT_TIMEOUT_MS`, `FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS`) the same
2266
- way; the timing project boots both spines with them shortened.
2267
- Cross-process only; fuz_app's own wiring is
2268
- `src/test/cross_backend/sse_keep_alive.cross.test.ts`,
2269
- `src/test/cross_backend/ws_receive_timeout.cross.test.ts` and
2270
- `src/test/cross_backend/db_checkout_timeout.cross.test.ts`, under the
2271
- `cross_backend_timing` project.
1749
+ `db_checkout_timeout_ms` and `db_audit_checkout_timeout_ms` set the production
1750
+ pool checkout bounds (`FUZ_DB_CHECKOUT_TIMEOUT_MS`,
1751
+ `FUZ_DB_AUDIT_CHECKOUT_TIMEOUT_MS`) the same way. Cross-process only;
1752
+ fuz_app's wiring: ../../test/CLAUDE.md §Cross-backend self-tests.
2272
1753
 
2273
1754
  ### Building a TS test-server binary — `testing_server_core.ts` + adapters
2274
1755
 
@@ -2284,16 +1765,11 @@ re-roll the serve / daemon-info / drain boilerplate:
2284
1765
  - `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).
2285
1766
  - `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()`.
2286
1767
 
2287
- fuz_app's own binary wiring (`src/test/cross_backend/testing_spine_server{,_node,_bun}.ts`) is the worked example: ~one `build_app` over `create_app_backend` + `create_app_server` (`rate_limiters: 'disabled_for_testing'` plus whichever login / action limiters its env toggles built, `build_full_spine_mount`'s two lists on one `rpc_endpoints` entry and two `ws_endpoints` entries — `/api/ws` and the role-gated `SPINE_ROLE_GATED_WS_PATH` — sharing one `registry`, which is also the role-grant-offer `notification_sender`), reusing `default_spine_surface`. `src/test/cross_backend/testing_spine_server.db.test.ts` builds it with the Node adapter in-process and asserts its surface lists both WS endpoints (the gated one with its `required_roles`) and passes the surface invariants. The `_node`/`_bun` entries differ only in which adapter they wire — `build_spine_app` is runtime-agnostic. It leaves `create_app_server`'s `auth_cleanup` off, as the Rust `testing_spine_stub` leaves its twin unscheduled: a background pass would delete rows and write audit rows under a running suite. A consumer's cross-process test binary may schedule it when nothing its suites seed is already expired (the conformance table's `expired_session` principal seeds a backdated session row); an in-process harness leaves it off.
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).
2288
1769
 
2289
- The TS spine binary serves the audit stream, `GET /api/admin/audit/stream`:
2290
- `build_spine_app` passes `audit_log_sse: true` and `create_spine_route_specs`
2291
- mounts `create_audit_log_route_specs({stream: ctx.audit_sse})` when
2292
- `ctx.audit_sse` is set (keeps the shared surface snapshot SSE-free, since the surface stub ctx has
2293
- `audit_sse: null`). `capabilities.sse` is a mount flag, so each config states
2294
- it (`ts_spine_backend_config.ts` for the TS spines) and a consumer that doesn't
2295
- wire `audit_log_sse` states `false`. The
2296
- real-HTTP `transports/sse_transport.ts` feeds `describe_cross_process_sse_tests`.
1770
+ `capabilities.sse` is a mount flag, so each config states it; a consumer
1771
+ binary that doesn't wire `audit_log_sse` states `false`. The real-HTTP
1772
+ `transports/sse_transport.ts` feeds `describe_cross_process_sse_tests`.
2297
1773
 
2298
1774
  The auth-cost handling for cross-process testing is consumer-side: each
2299
1775
  consumer ships a separate test binary wiring a fast-params
@@ -2336,13 +1812,7 @@ scenario→task→report adapter over `@fuzdev/fuz_util`'s benchmark library
2336
1812
  (`Benchmark`, `benchmark_stats_compare`, `benchmark_format_markdown`) —
2337
1813
  no stats engine reinvented. fuz_app ships the primitive; consumers wire
2338
1814
  scenarios + the run.
2339
- fuz_app also ships its **own** `npm run benchmark:cross-impl`
2340
- (`src/benchmarks/cross_impl.bench.ts`) on the back of its TS spine binary —
2341
- ts-node + ts-bun (+ the Rust `spine_stub` when `FUZ_TESTING_RUST_SPINE_STUB_BIN`
2342
- is set). The two TS runtimes are apples-to-apples with each other (same
2343
- in-memory pglet driver); TS-vs-Rust carries the pglet-vs-Postgres DB-layer caveat
2344
- (documented in the run). The artifact (`*.latest.json`) is gitignored.
2345
-
1815
+ fuz_app's own run: ../../test/CLAUDE.md §Cross-backend self-tests.
2346
1816
  - `bench/scenario.ts` — `BenchScenario` (`{name, requires?, run}`) +
2347
1817
  `BenchScenarioContext` (pre-authed `transport`, `rpc_path`,
2348
1818
  `capabilities`). The `run` body is the timed task; it `throw`s on a
@@ -2357,8 +1827,7 @@ in-memory pglet driver); TS-vs-Rust carries the pglet-vs-Postgres DB-layer cavea
2357
1827
  bootstraps each backend once (uses `handle.keeper_transport`; **no reset
2358
1828
  in the hot loop**), runs each scenario as a one-task `Benchmark` named by
2359
1829
  the backend, returns `CrossImplBenchResult` (`{backends, scenarios, entries}`).
2360
- Network-tuned defaults override fuz_util's micro defaults
2361
- (warmup 20 / min 100 / duration 3000ms).
1830
+ Network-tuned defaults override fuz_util's micro defaults (its TSDoc).
2362
1831
  - `bench/bench_report.ts` — `format_cross_impl_markdown` (per-scenario
2363
1832
  table, backend rows), `compare_cross_impl` (Welch verdict per scenario
2364
1833
  vs a reference backend) + `format_cross_impl_comparison`, and