@fuzdev/fuz_app 0.183.0 → 0.185.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 (223) hide show
  1. package/dist/actions/CLAUDE.md +538 -1223
  2. package/dist/actions/action_codegen.d.ts +1 -1
  3. package/dist/actions/action_codegen.d.ts.map +1 -1
  4. package/dist/actions/action_codegen.js +3 -2
  5. package/dist/actions/connection_closer.d.ts +11 -9
  6. package/dist/actions/connection_closer.d.ts.map +1 -1
  7. package/dist/actions/connection_closer.js +11 -9
  8. package/dist/actions/frontend_rpc_client.d.ts +1 -1
  9. package/dist/actions/register_action_ws.d.ts +21 -1
  10. package/dist/actions/register_action_ws.d.ts.map +1 -1
  11. package/dist/actions/register_action_ws.js +2 -1
  12. package/dist/actions/ws_socket_session.d.ts +25 -4
  13. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  14. package/dist/actions/ws_socket_session.js +81 -25
  15. package/dist/auth/CLAUDE.md +433 -1048
  16. package/dist/auth/account_queries.d.ts +1 -1
  17. package/dist/auth/account_queries.js +1 -1
  18. package/dist/auth/account_routes.d.ts +4 -5
  19. package/dist/auth/account_routes.d.ts.map +1 -1
  20. package/dist/auth/account_routes.js +8 -10
  21. package/dist/auth/admin_actions.d.ts.map +1 -1
  22. package/dist/auth/admin_actions.js +10 -11
  23. package/dist/auth/api_token.d.ts +20 -3
  24. package/dist/auth/api_token.d.ts.map +1 -1
  25. package/dist/auth/api_token.js +28 -9
  26. package/dist/auth/api_token_queries.d.ts +2 -2
  27. package/dist/auth/api_token_queries.js +2 -2
  28. package/dist/auth/audit_log_routes.d.ts +1 -1
  29. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  30. package/dist/auth/audit_log_routes.js +3 -2
  31. package/dist/auth/audit_log_schema.d.ts +15 -9
  32. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  33. package/dist/auth/audit_log_schema.js +1 -2
  34. package/dist/auth/auth_guard_resolver.d.ts +1 -1
  35. package/dist/auth/auth_guard_resolver.js +1 -1
  36. package/dist/auth/bearer_auth.d.ts +2 -5
  37. package/dist/auth/bearer_auth.d.ts.map +1 -1
  38. package/dist/auth/bearer_auth.js +4 -13
  39. package/dist/auth/bootstrap_account.d.ts +13 -15
  40. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  41. package/dist/auth/bootstrap_account.js +9 -11
  42. package/dist/auth/bootstrap_routes.d.ts +20 -21
  43. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  44. package/dist/auth/bootstrap_routes.js +21 -19
  45. package/dist/auth/bootstrap_token_store.d.ts +3 -4
  46. package/dist/auth/bootstrap_token_store.d.ts.map +1 -1
  47. package/dist/auth/bootstrap_token_store.js +1 -1
  48. package/dist/auth/cleanup.d.ts +34 -3
  49. package/dist/auth/cleanup.d.ts.map +1 -1
  50. package/dist/auth/cleanup.js +11 -3
  51. package/dist/auth/daemon_token.d.ts +5 -1
  52. package/dist/auth/daemon_token.d.ts.map +1 -1
  53. package/dist/auth/daemon_token_middleware.d.ts +12 -8
  54. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  55. package/dist/auth/daemon_token_middleware.js +15 -21
  56. package/dist/auth/deps.d.ts +11 -0
  57. package/dist/auth/deps.d.ts.map +1 -1
  58. package/dist/auth/invite_queries.d.ts +51 -3
  59. package/dist/auth/invite_queries.d.ts.map +1 -1
  60. package/dist/auth/invite_queries.js +81 -6
  61. package/dist/auth/invite_schema.d.ts +2 -1
  62. package/dist/auth/invite_schema.d.ts.map +1 -1
  63. package/dist/auth/middleware.d.ts +2 -3
  64. package/dist/auth/middleware.d.ts.map +1 -1
  65. package/dist/auth/middleware.js +3 -3
  66. package/dist/auth/request_context.d.ts +3 -3
  67. package/dist/auth/request_context.js +3 -3
  68. package/dist/auth/role_grant_offer_actions.d.ts +2 -2
  69. package/dist/auth/role_grant_offer_actions.js +2 -2
  70. package/dist/auth/session_cookie.d.ts +82 -174
  71. package/dist/auth/session_cookie.d.ts.map +1 -1
  72. package/dist/auth/session_cookie.js +80 -130
  73. package/dist/auth/session_middleware.d.ts +8 -17
  74. package/dist/auth/session_middleware.d.ts.map +1 -1
  75. package/dist/auth/session_middleware.js +14 -23
  76. package/dist/auth/session_queries.d.ts +9 -14
  77. package/dist/auth/session_queries.d.ts.map +1 -1
  78. package/dist/auth/session_queries.js +8 -9
  79. package/dist/auth/signup_routes.d.ts.map +1 -1
  80. package/dist/auth/signup_routes.js +4 -6
  81. package/dist/db/CLAUDE.md +5 -3
  82. package/dist/dev/setup.d.ts +3 -1
  83. package/dist/dev/setup.d.ts.map +1 -1
  84. package/dist/dev/setup.js +3 -1
  85. package/dist/http/CLAUDE.md +315 -768
  86. package/dist/http/db_routes.d.ts +1 -1
  87. package/dist/http/db_routes.js +1 -1
  88. package/dist/http/origin.d.ts +7 -8
  89. package/dist/http/origin.d.ts.map +1 -1
  90. package/dist/http/origin.js +7 -8
  91. package/dist/http/pending_effects.d.ts +82 -4
  92. package/dist/http/pending_effects.d.ts.map +1 -1
  93. package/dist/http/pending_effects.js +82 -4
  94. package/dist/http/route_result.d.ts +1 -1
  95. package/dist/http/route_spec.d.ts +17 -14
  96. package/dist/http/route_spec.d.ts.map +1 -1
  97. package/dist/realtime/audit_log_sse.d.ts +1 -1
  98. package/dist/realtime/sse.d.ts +6 -25
  99. package/dist/realtime/sse.d.ts.map +1 -1
  100. package/dist/realtime/sse.js +4 -25
  101. package/dist/realtime/sse_constants.d.ts +1 -1
  102. package/dist/realtime/sse_constants.js +1 -1
  103. package/dist/server/app_backend.d.ts +4 -5
  104. package/dist/server/app_backend.d.ts.map +1 -1
  105. package/dist/server/app_backend.js +3 -1
  106. package/dist/server/app_server.d.ts +87 -76
  107. package/dist/server/app_server.d.ts.map +1 -1
  108. package/dist/server/app_server.js +111 -91
  109. package/dist/server/app_server_context.d.ts +1 -2
  110. package/dist/server/app_server_context.d.ts.map +1 -1
  111. package/dist/server/env.js +2 -2
  112. package/dist/server/shutdown_drain.d.ts +69 -0
  113. package/dist/server/shutdown_drain.d.ts.map +1 -0
  114. package/dist/server/shutdown_drain.js +77 -0
  115. package/dist/testing/CLAUDE.md +89 -57
  116. package/dist/testing/admin_integration.d.ts +4 -5
  117. package/dist/testing/admin_integration.d.ts.map +1 -1
  118. package/dist/testing/admin_integration.js +39 -23
  119. package/dist/testing/app_server.d.ts +3 -8
  120. package/dist/testing/app_server.d.ts.map +1 -1
  121. package/dist/testing/app_server.js +10 -9
  122. package/dist/testing/attack_surface.d.ts +1 -1
  123. package/dist/testing/attack_surface.d.ts.map +1 -1
  124. package/dist/testing/audit_completeness.d.ts +2 -3
  125. package/dist/testing/audit_completeness.d.ts.map +1 -1
  126. package/dist/testing/audit_completeness.js +1 -1
  127. package/dist/testing/cross_backend/bootstrap_backend.d.ts +3 -1
  128. package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -1
  129. package/dist/testing/cross_backend/bootstrap_backend.js +5 -1
  130. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -1
  131. package/dist/testing/cross_backend/capability_mounts.js +16 -11
  132. package/dist/testing/cross_backend/conformance_table.d.ts +5 -6
  133. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  134. package/dist/testing/cross_backend/conformance_table.js +4 -4
  135. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  136. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +10 -1
  137. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  138. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +33 -7
  139. package/dist/testing/cross_backend/default_backend_configs.d.ts +3 -3
  140. package/dist/testing/cross_backend/default_spine_surface.d.ts +0 -6
  141. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/default_spine_surface.js +4 -9
  143. package/dist/testing/cross_backend/differential.d.ts +2 -3
  144. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  145. package/dist/testing/cross_backend/differential.js +1 -1
  146. package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -42
  147. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  148. package/dist/testing/cross_backend/full_spine_mount.js +45 -4
  149. package/dist/testing/cross_backend/in_process_setup.d.ts +7 -8
  150. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  151. package/dist/testing/cross_backend/in_process_setup.js +10 -13
  152. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  153. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -1
  154. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -4
  155. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  156. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +2 -2
  157. package/dist/testing/cross_backend/setup.d.ts +1 -1
  158. package/dist/testing/cross_backend/spawn_backend.d.ts +14 -0
  159. package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
  160. package/dist/testing/cross_backend/spawn_backend.js +56 -8
  161. package/dist/testing/cross_backend/spine_suites.d.ts +18 -16
  162. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  163. package/dist/testing/cross_backend/spine_suites.js +38 -18
  164. package/dist/testing/cross_backend/standard.d.ts +19 -84
  165. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  166. package/dist/testing/cross_backend/standard.js +8 -23
  167. package/dist/testing/cross_backend/standard_auth.d.ts +74 -0
  168. package/dist/testing/cross_backend/standard_auth.d.ts.map +1 -0
  169. package/dist/testing/cross_backend/standard_auth.js +28 -0
  170. package/dist/testing/cross_backend/standard_bundle.d.ts +48 -0
  171. package/dist/testing/cross_backend/standard_bundle.d.ts.map +1 -0
  172. package/dist/testing/cross_backend/standard_bundle.js +43 -0
  173. package/dist/testing/cross_backend/testing_credential_read.d.ts +10 -11
  174. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -1
  175. package/dist/testing/cross_backend/testing_credential_read.js +12 -12
  176. package/dist/testing/cross_backend/testing_reset_actions.d.ts +46 -30
  177. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  178. package/dist/testing/cross_backend/testing_reset_actions.js +52 -31
  179. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  180. package/dist/testing/cross_backend/testing_server_bun.js +5 -4
  181. package/dist/testing/cross_backend/testing_server_core.d.ts +16 -3
  182. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  183. package/dist/testing/cross_backend/testing_server_core.js +22 -7
  184. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +6 -2
  185. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  186. package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -3
  187. package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
  188. package/dist/testing/daemon_token_rotation.js +2 -3
  189. package/dist/testing/error_coverage.d.ts +5 -0
  190. package/dist/testing/error_coverage.d.ts.map +1 -1
  191. package/dist/testing/error_coverage.js +2 -1
  192. package/dist/testing/integration.d.ts +6 -23
  193. package/dist/testing/integration.d.ts.map +1 -1
  194. package/dist/testing/integration.js +53 -83
  195. package/dist/testing/integration_helpers.d.ts +16 -0
  196. package/dist/testing/integration_helpers.d.ts.map +1 -1
  197. package/dist/testing/integration_helpers.js +29 -1
  198. package/dist/testing/middleware_gate_probes.d.ts +55 -1
  199. package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
  200. package/dist/testing/middleware_gate_probes.js +69 -3
  201. package/dist/testing/rate_limiting.d.ts +2 -3
  202. package/dist/testing/rate_limiting.d.ts.map +1 -1
  203. package/dist/testing/rate_limiting.js +3 -3
  204. package/dist/testing/rpc_helpers.d.ts +1 -2
  205. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  206. package/dist/testing/rpc_helpers.js +3 -3
  207. package/dist/testing/rpc_round_trip.d.ts +2 -3
  208. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  209. package/dist/testing/rpc_round_trip.js +1 -1
  210. package/dist/testing/sse_round_trip.d.ts +2 -3
  211. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  212. package/dist/testing/sse_round_trip.js +2 -2
  213. package/dist/testing/stubs.d.ts +5 -6
  214. package/dist/testing/stubs.d.ts.map +1 -1
  215. package/dist/testing/stubs.js +10 -8
  216. package/dist/testing/test_app.d.ts +8 -5
  217. package/dist/testing/test_app.d.ts.map +1 -1
  218. package/dist/testing/test_app.js +7 -7
  219. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  220. package/dist/testing/ws_round_trip.js +3 -0
  221. package/dist/ui/ui_format.d.ts.map +1 -1
  222. package/dist/ui/ui_format.js +1 -2
  223. package/package.json +1 -1
@@ -0,0 +1,48 @@
1
+ import '../assert_dev_env.js';
2
+ /**
3
+ * One call wiring the standard suites that run against a spawned backend —
4
+ * the ones whose option shape is `{setup_test, surface_source, capabilities, ...}`
5
+ * and whose bodies fire requests through `fixture.transport` rather than
6
+ * touching the in-process `Backend`, for a consumer wiring them outside
7
+ * `describe_spine_cross_suites`, which registers the two halves apart:
8
+ *
9
+ * - `describe_standard_auth_cross_tests` (`standard_auth.ts`) —
10
+ * `describe_standard_integration_tests`, and
11
+ * `describe_standard_admin_integration_tests` when the consumer supplies a
12
+ * `RoleRegistry`
13
+ * - `describe_standard_cross_tests` (`standard.ts`) —
14
+ * `describe_middleware_gate_tests`, `describe_round_trip_validation`,
15
+ * `describe_rpc_round_trip_tests` and `describe_data_exposure_tests`
16
+ *
17
+ * **Suites omitted** — the ones that don't survive a process boundary,
18
+ * documented here so per-consumer files don't have to repeat the
19
+ * bookkeeping:
20
+ *
21
+ * - `describe_rate_limiting_tests` — builds a fresh `TestApp` per test to
22
+ * inject tight per-test rate-limiter overrides. That path requires
23
+ * in-process construction of `Backend` + rate limiter; the spawned
24
+ * binary has neither knob nor restart-per-test budget.
25
+ * - `describe_audit_completeness_tests` — reaches into FK-structural
26
+ * introspection that only the in-process backend exposes. Wire-level
27
+ * audit observability lives in the consumer's own audit `.cross.test.ts`
28
+ * driving `audit_log_list` / `audit_log_role_grant_history`.
29
+ *
30
+ * @module
31
+ */
32
+ import { type StandardCrossTestOptions } from './standard.js';
33
+ import { type StandardAuthCrossTestOptions } from './standard_auth.js';
34
+ /**
35
+ * Configuration for `describe_standard_cross_process_tests`: both halves'
36
+ * options — the in-process suites' shared options minus their
37
+ * in-process-only knobs (`create_route_specs`, `rate_limiting_app_options`).
38
+ */
39
+ export interface StandardCrossProcessTestOptions extends StandardAuthCrossTestOptions, StandardCrossTestOptions {
40
+ }
41
+ /**
42
+ * Run the cross-process standard test bundle — the auth suites (integration,
43
+ * admin when `roles` is provided), then the middleware-gate probes, round
44
+ * trip, RPC round trip and data exposure. See the module doc for the suites
45
+ * omitted and why.
46
+ */
47
+ export declare const describe_standard_cross_process_tests: (options: StandardCrossProcessTestOptions) => void;
48
+ //# sourceMappingURL=standard_bundle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"standard_bundle.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/standard_bundle.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAiC,KAAK,wBAAwB,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAEN,KAAK,4BAA4B,EACjC,MAAM,oBAAoB,CAAC;AAE5B;;;;GAIG;AACH,MAAM,WAAW,+BAChB,SAAQ,4BAA4B,EAAE,wBAAwB;CAAG;AAElE;;;;;GAKG;AACH,eAAO,MAAM,qCAAqC,GACjD,SAAS,+BAA+B,KACtC,IAGF,CAAC"}
@@ -0,0 +1,43 @@
1
+ import '../assert_dev_env.js';
2
+ /**
3
+ * One call wiring the standard suites that run against a spawned backend —
4
+ * the ones whose option shape is `{setup_test, surface_source, capabilities, ...}`
5
+ * and whose bodies fire requests through `fixture.transport` rather than
6
+ * touching the in-process `Backend`, for a consumer wiring them outside
7
+ * `describe_spine_cross_suites`, which registers the two halves apart:
8
+ *
9
+ * - `describe_standard_auth_cross_tests` (`standard_auth.ts`) —
10
+ * `describe_standard_integration_tests`, and
11
+ * `describe_standard_admin_integration_tests` when the consumer supplies a
12
+ * `RoleRegistry`
13
+ * - `describe_standard_cross_tests` (`standard.ts`) —
14
+ * `describe_middleware_gate_tests`, `describe_round_trip_validation`,
15
+ * `describe_rpc_round_trip_tests` and `describe_data_exposure_tests`
16
+ *
17
+ * **Suites omitted** — the ones that don't survive a process boundary,
18
+ * documented here so per-consumer files don't have to repeat the
19
+ * bookkeeping:
20
+ *
21
+ * - `describe_rate_limiting_tests` — builds a fresh `TestApp` per test to
22
+ * inject tight per-test rate-limiter overrides. That path requires
23
+ * in-process construction of `Backend` + rate limiter; the spawned
24
+ * binary has neither knob nor restart-per-test budget.
25
+ * - `describe_audit_completeness_tests` — reaches into FK-structural
26
+ * introspection that only the in-process backend exposes. Wire-level
27
+ * audit observability lives in the consumer's own audit `.cross.test.ts`
28
+ * driving `audit_log_list` / `audit_log_role_grant_history`.
29
+ *
30
+ * @module
31
+ */
32
+ import { describe_standard_cross_tests } from './standard.js';
33
+ import { describe_standard_auth_cross_tests } from './standard_auth.js';
34
+ /**
35
+ * Run the cross-process standard test bundle — the auth suites (integration,
36
+ * admin when `roles` is provided), then the middleware-gate probes, round
37
+ * trip, RPC round trip and data exposure. See the module doc for the suites
38
+ * omitted and why.
39
+ */
40
+ export const describe_standard_cross_process_tests = (options) => {
41
+ describe_standard_auth_cross_tests(options);
42
+ describe_standard_cross_tests(options);
43
+ };
@@ -14,7 +14,6 @@ import '../assert_dev_env.js';
14
14
  import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
15
15
  import { type RpcAction } from '../../actions/action_types.js';
16
16
  import type { Keyring } from '../../auth/keyring.js';
17
- import { type SessionOptions } from '../../auth/session_cookie.js';
18
17
  /**
19
18
  * The `data.reason` of every refusal `_testing_credential_read` gives its
20
19
  * `lines`: a value that is no list of strings, a list or a line over its cap
@@ -48,12 +47,12 @@ export declare const TestingCredentialReadInput: import("@fuzdev/fuz_schema/sche
48
47
  }>;
49
48
  export type TestingCredentialReadInput = Infer<typeof TestingCredentialReadInput>;
50
49
  /**
51
- * What a request's `Cookie` lines hold of the session cookie — the wire form
52
- * of the Rust spine's `fuz_auth::SessionCookieRead`, its variants in
53
- * lowercase.
50
+ * What a request's `Cookie` lines hold of the session cookie — the `kind` of
51
+ * a `SessionCookieRead` (`parse_session_from_cookies`), the wire form of the
52
+ * Rust spine's `fuz_auth::SessionCookieRead`, its variants in lowercase.
54
53
  */
55
- export declare const SessionCookieRead: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["absent", "invalid", "valid"]>;
56
- export type SessionCookieRead = Infer<typeof SessionCookieRead>;
54
+ export declare const SessionCookieReadKind: import("@fuzdev/fuz_schema/schema.ts").OneOfSchema<readonly ["absent", "invalid", "valid"]>;
55
+ export type SessionCookieReadKind = Infer<typeof SessionCookieReadKind>;
57
56
  /**
58
57
  * Output of `_testing_credential_read`, a `@fuzdev/fuz_schema` `object`: how
59
58
  * each credential leg reads the lines, before any database work.
@@ -76,8 +75,8 @@ export type TestingCredentialReadOutput = Infer<typeof TestingCredentialReadOutp
76
75
  export interface TestingCredentialReadDeps {
77
76
  /** The server's cookie keyring. */
78
77
  readonly keyring: Keyring;
79
- /** The server's session options — the cookie name and identity decoder. */
80
- readonly session_options: SessionOptions<string>;
78
+ /** The server's session cookie name. */
79
+ readonly session_cookie_name: string;
81
80
  }
82
81
  /**
83
82
  * Split `Name: value` lines into the per-name lines the credential readers
@@ -93,13 +92,13 @@ export declare const parse_testing_header_lines: (lines: ReadonlyArray<string>)
93
92
  /**
94
93
  * Answer one `_testing_credential_read` input: read each credential out of
95
94
  * the lines with the readers the auth middleware legs call
96
- * (`read_session_cookie_value` then `process_session_cookie`,
95
+ * (`parse_session_from_cookies`,
97
96
  * `read_bearer_token`, `read_daemon_token`). The action handler and the
98
97
  * conformance table's unit test both call this, so the table checks the same
99
98
  * functions the wire serves.
100
99
  *
101
100
  * @param input - the header lines
102
- * @param deps - the keyring and session options the cookie is verified with
101
+ * @param deps - the keyring the cookie is verified with, and its name
103
102
  * @returns the reading the Rust twin returns for the same lines
104
103
  * @throws ThrownJsonrpcError `invalid_params` for a line `parse_testing_header_lines` refuses
105
104
  */
@@ -159,7 +158,7 @@ export declare const testing_credential_read_action_spec: {
159
158
  /**
160
159
  * Build the standalone `_testing_credential_read` action (see the spec doc).
161
160
  *
162
- * @param deps - the server's keyring and session options
161
+ * @param deps - the server's keyring and session cookie name
163
162
  */
164
163
  export declare const create_testing_credential_read_action: (deps: TestingCredentialReadDeps) => RpcAction;
165
164
  //# sourceMappingURL=testing_credential_read.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"testing_credential_read.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_credential_read.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;GAWG;AAEH,OAAO,EAQN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAQ3E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAA0B,KAAK,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAM3F;;;;;;;;;GASG;AACH,eAAO,MAAM,kCAAkC,wBAAwB,CAAC;AAExE;;;;;GAKG;AACH,eAAO,MAAM,uCAAuC,OAAO,CAAC;AAE5D,iFAAiF;AACjF,eAAO,MAAM,iCAAiC,KAAK,CAAC;AAEpD,4EAA4E;AAC5E,eAAO,MAAM,0BAA0B;IACtC;;;;;;OAMG;;EAQF,CAAC;AACH,MAAM,MAAM,0BAA0B,GAAG,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAElF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,6FAAyC,CAAC;AACxE,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,2BAA2B;IACvC;;;;;OAKG;;IAEH,gFAAgF;;IAEhF,mFAAmF;;EAElF,CAAC;AACH,MAAM,MAAM,2BAA2B,GAAG,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEpF,2EAA2E;AAC3E,MAAM,WAAW,yBAAyB;IACzC,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,2EAA2E;IAC3E,QAAQ,CAAC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;CACjD;AAiBD;;;;;;;;;GASG;AACH,eAAO,MAAM,0BAA0B,GACtC,OAAO,aAAa,CAAC,MAAM,CAAC,KAC1B,CAAC,CAAC,UAAU,EAAE,MAAM,KAAK,aAAa,CAAC,MAAM,CAAC,CAgBhD,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,2BAA2B,GACvC,OAAO,0BAA0B,EACjC,MAAM,yBAAyB,KAC7B,OAAO,CAAC,2BAA2B,CAYrC,CAAC;AAEF;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;QA9I/C;;;;;;WAMG;;;;QAwBH;;;;;WAKG;;QAEH,gFAAgF;;QAEhF,mFAAmF;;;;;;CAoHtC,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,GAAI,MAAM,yBAAyB,KAAG,SAGtF,CAAC"}
1
+ {"version":3,"file":"testing_credential_read.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_credential_read.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAE9B;;;;;;;;;;;GAWG;AAEH,OAAO,EAQN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAGtC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,+BAA+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;;QAwBH;;;;;WAKG;;QAEH,gFAAgF;;QAEhF,mFAAmF;;;;;;CAoHtC,CAAC;AAE/C;;;;GAIG;AACH,eAAO,MAAM,qCAAqC,GAAI,MAAM,yBAAyB,KAAG,SAGtF,CAAC"}
@@ -14,9 +14,9 @@ import '../assert_dev_env.js';
14
14
  import { array, max_length, nullable, object, one_of, pipe, string } from '@fuzdev/fuz_schema/schema.ts';
15
15
  import { meta } from '@fuzdev/fuz_schema/meta.ts';
16
16
  import { rpc_action } from '../../actions/action_types.js';
17
- import { read_bearer_token, read_daemon_token, read_session_cookie_value } from '../../auth/credential_headers.js';
17
+ import { read_bearer_token, read_daemon_token } from '../../auth/credential_headers.js';
18
18
  import { DAEMON_TOKEN_HEADER } from '../../auth/daemon_token.js';
19
- import { process_session_cookie } from '../../auth/session_cookie.js';
19
+ import { parse_session_from_cookies } from '../../auth/session_cookie.js';
20
20
  import { trim_optional_whitespace } from '../../http/header_lines.js';
21
21
  import { jsonrpc_errors } from '../../http/jsonrpc_errors.js';
22
22
  import { bounded_string } from '../../primitive_schemas.js';
@@ -53,11 +53,11 @@ export const TestingCredentialReadInput = object({
53
53
  lines: meta(pipe(array(bounded_string({ max: TESTING_CREDENTIAL_READ_LINE_LENGTH_MAX })), max_length(TESTING_CREDENTIAL_READ_LINES_MAX)), { invalid_reason: ERROR_TESTING_CREDENTIAL_READ_LINE })
54
54
  });
55
55
  /**
56
- * What a request's `Cookie` lines hold of the session cookie — the wire form
57
- * of the Rust spine's `fuz_auth::SessionCookieRead`, its variants in
58
- * lowercase.
56
+ * What a request's `Cookie` lines hold of the session cookie — the `kind` of
57
+ * a `SessionCookieRead` (`parse_session_from_cookies`), the wire form of the
58
+ * Rust spine's `fuz_auth::SessionCookieRead`, its variants in lowercase.
59
59
  */
60
- export const SessionCookieRead = one_of(['absent', 'invalid', 'valid']);
60
+ export const SessionCookieReadKind = one_of(['absent', 'invalid', 'valid']);
61
61
  /**
62
62
  * Output of `_testing_credential_read`, a `@fuzdev/fuz_schema` `object`: how
63
63
  * each credential leg reads the lines, before any database work.
@@ -69,7 +69,7 @@ export const TestingCredentialReadOutput = object({
69
69
  * the server's keyring and its signed expiry is ahead. Says nothing about
70
70
  * the `auth_session` row.
71
71
  */
72
- session_cookie: SessionCookieRead,
72
+ session_cookie: SessionCookieReadKind,
73
73
  /** The API token the bearer leg would look up, or `null` when it reads none. */
74
74
  bearer_token: nullable(string),
75
75
  /** The daemon token the daemon leg would compare, or `null` when it reads none. */
@@ -120,21 +120,21 @@ export const parse_testing_header_lines = (lines) => {
120
120
  /**
121
121
  * Answer one `_testing_credential_read` input: read each credential out of
122
122
  * the lines with the readers the auth middleware legs call
123
- * (`read_session_cookie_value` then `process_session_cookie`,
123
+ * (`parse_session_from_cookies`,
124
124
  * `read_bearer_token`, `read_daemon_token`). The action handler and the
125
125
  * conformance table's unit test both call this, so the table checks the same
126
126
  * functions the wire serves.
127
127
  *
128
128
  * @param input - the header lines
129
- * @param deps - the keyring and session options the cookie is verified with
129
+ * @param deps - the keyring the cookie is verified with, and its name
130
130
  * @returns the reading the Rust twin returns for the same lines
131
131
  * @throws ThrownJsonrpcError `invalid_params` for a line `parse_testing_header_lines` refuses
132
132
  */
133
133
  export const run_testing_credential_read = async (input, deps) => {
134
134
  const header = parse_testing_header_lines(input.lines);
135
- const session = await process_session_cookie(read_session_cookie_value(header('cookie'), deps.session_options.cookie_name), deps.keyring, deps.session_options);
135
+ const session = await parse_session_from_cookies(header('cookie'), deps.keyring, deps.session_cookie_name);
136
136
  return {
137
- session_cookie: session.valid ? 'valid' : session.action === 'clear' ? 'invalid' : 'absent',
137
+ session_cookie: session.kind,
138
138
  bearer_token: read_bearer_token(header('authorization')),
139
139
  daemon_token: read_daemon_token(header(DAEMON_TOKEN_HEADER.toLowerCase()))
140
140
  };
@@ -170,6 +170,6 @@ export const testing_credential_read_action_spec = {
170
170
  /**
171
171
  * Build the standalone `_testing_credential_read` action (see the spec doc).
172
172
  *
173
- * @param deps - the server's keyring and session options
173
+ * @param deps - the server's keyring and session cookie name
174
174
  */
175
175
  export const create_testing_credential_read_action = (deps) => rpc_action(testing_credential_read_action_spec, (input) => run_testing_credential_read(input, deps));
@@ -1,12 +1,23 @@
1
1
  import '../assert_dev_env.js';
2
2
  import { type Infer } from '@fuzdev/fuz_schema/schema.ts';
3
3
  import { type RpcAction } from '../../actions/action_types.js';
4
+ import { type RequestTracker } from '../../http/pending_effects.js';
4
5
  import type { RoomRegistry } from '../../actions/room_registry.js';
5
6
  import type { AppDeps } from '../../auth/deps.js';
6
7
  import type { AuditEmitter } from '../../auth/audit_emitter.js';
7
- import type { SessionOptions } from '../../auth/session_cookie.js';
8
8
  import type { DaemonTokenState } from '../../auth/daemon_token.js';
9
9
  import type { Db } from '../../db/db.js';
10
+ /**
11
+ * Restamps a seeded account's session at the wall clock, run right after the
12
+ * account is seeded. The reset seeds every account in one transaction, where
13
+ * `NOW()` is one instant, so the seeded sessions would tie on `created_at` and
14
+ * a list ordered by it (`admin_session_list`) would break the tie by the
15
+ * random session hash — a different order per run and per spine. Stamped in
16
+ * seed order, they list the same on both. The Rust reset runs this statement
17
+ * byte for byte (`fuz_testing::testing_reset`); the actor twin is
18
+ * `create_test_extra_actor`.
19
+ */
20
+ export declare const RESET_SESSION_CLOCK_STAMP_SQL = "UPDATE auth_session SET created_at = clock_timestamp() WHERE account_id = $1";
10
21
  /**
11
22
  * The `_testing_reset` action spec.
12
23
  *
@@ -91,26 +102,30 @@ export declare const testing_reset_action_spec: {
91
102
  readonly description: "Test-binary only — wipe auth tables, re-bootstrap a fresh keeper (+ optional extras), fire the domain-state reset.";
92
103
  };
93
104
  /**
94
- * `_testing_drain_effects` — await in-flight fire-and-forget writes so a
105
+ * `_testing_drain_effects` — await in-flight fire-and-forget work so a
95
106
  * following `audit_log_list` or database read is authoritative. The
96
107
  * deterministic barrier the cross-backend conformance suite uses in place of
97
108
  * a poll/sleep before asserting on audit rows.
98
109
  *
99
- * The handler awaits `AuditEmitter.drain_inflight`, which waits until no
100
- * pool write of the emitter's is outstanding — every emitter counts them, so
101
- * the drain is always a barrier. It matters whatever the transport: both
102
- * test binaries settle an **HTTP** answer's writes before it responds (the
103
- * TS binary through `await_pending_effects: true`, the Rust stub through its
110
+ * The handler waits, repeating until both are empty, for the effect flushes
111
+ * on `AppDeps.request_tracker` (`RequestTracker.drain_flushes`: each
112
+ * request's eager `pending_effects` — the bearer leg's token touch among
113
+ * them — and its post-commit thunks) and for the pool writes of
114
+ * `AppDeps.audit` (`AuditEmitter.drain_inflight`) — a thunk can start an
115
+ * audit write, and a write's listener fan-out runs in a thunk. It matters
116
+ * whatever the transport: both test binaries settle an **HTTP** answer's
117
+ * effects before it responds (the TS binary through
118
+ * `await_pending_effects: true`, the Rust stub through its
104
119
  * `await_background_writes_layer`), but a **WS** mutation is answered
105
120
  * before its effects flush (reply-then-close for a self-revocation), so its
106
- * audit write can still be in flight when the caller reads the reply. The
107
- * Rust spine does the same await in `AuditEmitter::drain_inflight`.
121
+ * audit write or post-commit effect can still be running when the caller
122
+ * reads the reply. The Rust spine awaits the same work on its one tracker,
123
+ * `BackgroundWrites`.
108
124
  *
109
- * Covered: every `emit` that ran before the drain was dispatched, and any
110
- * started while it waits. A write that starts after the drain resolves is
111
- * not — nor, on TS, the bearer leg's token touch, which rides its request's
112
- * `pending_effects`. The Rust spine spawns its touch on the same tracker as
113
- * its audit writes, so its drain awaits that too.
125
+ * Covered: every flush and `emit` that started before the drain was
126
+ * dispatched, and any started while it waits. Not a handler still running —
127
+ * the drain's own request is one, and its flush starts only after it answers
128
+ * — nor work that starts after the drain resolves.
114
129
  *
115
130
  * `auth` gates on the daemon-token credential, matching `_testing_reset`.
116
131
  */
@@ -147,7 +162,7 @@ export declare const testing_drain_effects_action_spec: {
147
162
  * The minted `auth_session` row's `expires_at` is backdated while the
148
163
  * returned cookie's own signed payload stays valid (future). Cross-process
149
164
  * auth resolution therefore passes the
150
- * cookie-payload gate (`parse_session`) and is refused by the authoritative
165
+ * cookie-payload gate (`parse_session_from_cookies`) and is refused by the authoritative
151
166
  * DB-row gate (`query_session_get_valid` — `WHERE expires_at > NOW()`) —
152
167
  * the gate the in-process payload-expiry tests never reach and the one that
153
168
  * structurally needs a server-side mint (the cross-process driver has no
@@ -181,16 +196,23 @@ export declare const testing_mint_session_action_spec: {
181
196
  readonly async: true;
182
197
  readonly description: string;
183
198
  };
199
+ /** What `_testing_drain_effects` waits on — `AppDeps` satisfies it. */
200
+ export interface TestingDrainEffectsDeps {
201
+ /** The backend's request tracker, whose effect flushes the action awaits. */
202
+ request_tracker: Pick<RequestTracker, 'drain_flushes' | 'flush_count'>;
203
+ /** The backend's emitter, whose in-flight pool writes the action awaits. */
204
+ audit: Pick<AuditEmitter, 'drain_inflight' | 'inflight_count'>;
205
+ }
184
206
  /**
185
- * Build the standalone `_testing_drain_effects` action over `audit` — the
186
- * emitter the backend's handlers emit through (`deps.audit`). Mount it on any test endpoint
187
- * whose suite asserts on audit rows (the spine binary bundles it via
188
- * `create_testing_actions`; in-process suites mount it directly). Answers
189
- * `{ok: true}`.
207
+ * Build the standalone `_testing_drain_effects` action over the backend's
208
+ * deps — the tracker its requests are held on and the emitter its handlers
209
+ * emit through. Mount it on any test endpoint whose suite asserts on audit
210
+ * rows or effects (the spine binary bundles it via `create_testing_actions`;
211
+ * in-process suites mount it directly). Answers `{ok: true}`.
190
212
  *
191
- * @param audit - the backend's emitter, whose in-flight writes the action awaits
213
+ * @param deps - the backend's `request_tracker` and `audit`
192
214
  */
193
- export declare const create_testing_drain_effects_action: (audit: AuditEmitter) => RpcAction;
215
+ export declare const create_testing_drain_effects_action: (deps: TestingDrainEffectsDeps) => RpcAction;
194
216
  /**
195
217
  * `_testing_put_fact` — seed an **embedded** fact (`fact.bytes`) for the
196
218
  * cross-process fact-serving suite, which drives over real HTTP and has no
@@ -676,13 +698,6 @@ export declare const testing_action_manifest_action_spec: {
676
698
  export declare const create_testing_action_manifest_action: (mounted: ReadonlyArray<RpcAction>, ws_only?: ReadonlyArray<RpcAction>) => RpcAction;
677
699
  /** Options for `create_testing_actions`. */
678
700
  export interface CreateTestingActionsOptions {
679
- /**
680
- * Session cookie options — the reset action uses these when signing
681
- * the fresh keeper's (and any extra accounts') session cookies.
682
- * Pass the same `SessionOptions` the live `create_app_server` call
683
- * was wired with.
684
- */
685
- readonly session_options: SessionOptions<string>;
686
701
  /**
687
702
  * Daemon-token runtime state — the reset action points
688
703
  * `state.keeper_account_id` at the freshly seeded keeper once its
@@ -716,7 +731,8 @@ export interface CreateTestingActionsOptions {
716
731
  *
717
732
  * Returns the bundled `_testing_*` actions (module doc). The test binary
718
733
  * calls this at server-assembly time and registers the result on its
719
- * dispatcher. `_testing_drain_effects` drains `deps.audit`.
734
+ * dispatcher. `_testing_drain_effects` drains `deps.request_tracker` and
735
+ * `deps.audit`.
720
736
  *
721
737
  * The reset action's table-wipe list mirrors
722
738
  * `auth_integration_truncate_tables` from `testing/db.ts` — the
@@ -1 +1 @@
1
- {"version":3,"file":"testing_reset_actions.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_reset_actions.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqF9B,OAAO,EAcN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAK3E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAInE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AA0BzC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG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Aa,CAAC,SAAS,CAAM,KACpC,SASF,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,2BAA2B;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACjD;;;;;;OAMG;IACH,QAAQ,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;IAC9C;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACxD;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,OAAO,EACb,SAAS,2BAA2B,KAClC,KAAK,CAAC,SAAS,CAyJjB,CAAC"}
1
+ {"version":3,"file":"testing_reset_actions.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_reset_actions.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAqF9B,OAAO,EAcN,KAAK,KAAK,EACV,MAAM,8BAA8B,CAAC;AAItC,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,EAAqB,KAAK,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAGvF,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAInE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AA0BzC;;;;;;;;;GASG;AACH,eAAO,MAAM,6BAA6B,iFACqC,CAAC;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;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;;;;GAqBG;AACH,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;CAaF,CAAC;AAkB/C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,qCAAqC,GACjD,SAAS,aAAa,CAAC,SAAS,CAAC,EACjC,UAAS,aAAa,CAAC,SAAS,CAAM,KACpC,SASF,CAAC;AAEF,4CAA4C;AAC5C,MAAM,WAAW,2BAA2B;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,kBAAkB,EAAE,gBAAgB,CAAC;IAC9C;;;;;;;;;;;;;;;;;OAiBG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACxD;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,OAAO,EACb,SAAS,2BAA2B,KAClC,KAAK,CAAC,SAAS,CAwJjB,CAAC"}
@@ -4,7 +4,7 @@ import '../assert_dev_env.js';
4
4
  *
5
5
  * The daemon-token-authed actions bundled by `create_testing_actions`:
6
6
  * **`_testing_reset`** (DB wipe + keeper re-seed), **`_testing_drain_effects`**
7
- * (audit barrier), **`_testing_mint_session`** (forge an
7
+ * (effects barrier), **`_testing_mint_session`** (forge an
8
8
  * expired-by-construction server-side session for the expiry conformance
9
9
  * cases), **`_testing_put_fact`** (seed an embedded fact for the fact-serving
10
10
  * suite), **`_testing_schema_snapshot`** (introspect the live schema for
@@ -105,6 +105,17 @@ const SeededAccountShape = object({
105
105
  api_token: string,
106
106
  session_cookie: string
107
107
  });
108
+ /**
109
+ * Restamps a seeded account's session at the wall clock, run right after the
110
+ * account is seeded. The reset seeds every account in one transaction, where
111
+ * `NOW()` is one instant, so the seeded sessions would tie on `created_at` and
112
+ * a list ordered by it (`admin_session_list`) would break the tie by the
113
+ * random session hash — a different order per run and per spine. Stamped in
114
+ * seed order, they list the same on both. The Rust reset runs this statement
115
+ * byte for byte (`fuz_testing::testing_reset`); the actor twin is
116
+ * `create_test_extra_actor`.
117
+ */
118
+ export const RESET_SESSION_CLOCK_STAMP_SQL = 'UPDATE auth_session SET created_at = clock_timestamp() WHERE account_id = $1';
108
119
  /**
109
120
  * The `_testing_reset` action spec.
110
121
  *
@@ -164,26 +175,30 @@ export const testing_reset_action_spec = {
164
175
  description: 'Test-binary only — wipe auth tables, re-bootstrap a fresh keeper (+ optional extras), fire the domain-state reset.'
165
176
  };
166
177
  /**
167
- * `_testing_drain_effects` — await in-flight fire-and-forget writes so a
178
+ * `_testing_drain_effects` — await in-flight fire-and-forget work so a
168
179
  * following `audit_log_list` or database read is authoritative. The
169
180
  * deterministic barrier the cross-backend conformance suite uses in place of
170
181
  * a poll/sleep before asserting on audit rows.
171
182
  *
172
- * The handler awaits `AuditEmitter.drain_inflight`, which waits until no
173
- * pool write of the emitter's is outstanding — every emitter counts them, so
174
- * the drain is always a barrier. It matters whatever the transport: both
175
- * test binaries settle an **HTTP** answer's writes before it responds (the
176
- * TS binary through `await_pending_effects: true`, the Rust stub through its
183
+ * The handler waits, repeating until both are empty, for the effect flushes
184
+ * on `AppDeps.request_tracker` (`RequestTracker.drain_flushes`: each
185
+ * request's eager `pending_effects` — the bearer leg's token touch among
186
+ * them — and its post-commit thunks) and for the pool writes of
187
+ * `AppDeps.audit` (`AuditEmitter.drain_inflight`) — a thunk can start an
188
+ * audit write, and a write's listener fan-out runs in a thunk. It matters
189
+ * whatever the transport: both test binaries settle an **HTTP** answer's
190
+ * effects before it responds (the TS binary through
191
+ * `await_pending_effects: true`, the Rust stub through its
177
192
  * `await_background_writes_layer`), but a **WS** mutation is answered
178
193
  * before its effects flush (reply-then-close for a self-revocation), so its
179
- * audit write can still be in flight when the caller reads the reply. The
180
- * Rust spine does the same await in `AuditEmitter::drain_inflight`.
194
+ * audit write or post-commit effect can still be running when the caller
195
+ * reads the reply. The Rust spine awaits the same work on its one tracker,
196
+ * `BackgroundWrites`.
181
197
  *
182
- * Covered: every `emit` that ran before the drain was dispatched, and any
183
- * started while it waits. A write that starts after the drain resolves is
184
- * not — nor, on TS, the bearer leg's token touch, which rides its request's
185
- * `pending_effects`. The Rust spine spawns its touch on the same tracker as
186
- * its audit writes, so its drain awaits that too.
198
+ * Covered: every flush and `emit` that started before the drain was
199
+ * dispatched, and any started while it waits. Not a handler still running —
200
+ * the drain's own request is one, and its flush starts only after it answers
201
+ * — nor work that starts after the drain resolves.
187
202
  *
188
203
  * `auth` gates on the daemon-token credential, matching `_testing_reset`.
189
204
  */
@@ -214,7 +229,7 @@ export const testing_drain_effects_action_spec = {
214
229
  * The minted `auth_session` row's `expires_at` is backdated while the
215
230
  * returned cookie's own signed payload stays valid (future). Cross-process
216
231
  * auth resolution therefore passes the
217
- * cookie-payload gate (`parse_session`) and is refused by the authoritative
232
+ * cookie-payload gate (`parse_session_from_cookies`) and is refused by the authoritative
218
233
  * DB-row gate (`query_session_get_valid` — `WHERE expires_at > NOW()`) —
219
234
  * the gate the in-process payload-expiry tests never reach and the one that
220
235
  * structurally needs a server-side mint (the cross-process driver has no
@@ -248,16 +263,22 @@ export const testing_mint_session_action_spec = {
248
263
  'signed cookie value (exercises the authoritative server-side DB-row expiry gate).'
249
264
  };
250
265
  /**
251
- * Build the standalone `_testing_drain_effects` action over `audit` — the
252
- * emitter the backend's handlers emit through (`deps.audit`). Mount it on any test endpoint
253
- * whose suite asserts on audit rows (the spine binary bundles it via
254
- * `create_testing_actions`; in-process suites mount it directly). Answers
255
- * `{ok: true}`.
266
+ * Build the standalone `_testing_drain_effects` action over the backend's
267
+ * deps — the tracker its requests are held on and the emitter its handlers
268
+ * emit through. Mount it on any test endpoint whose suite asserts on audit
269
+ * rows or effects (the spine binary bundles it via `create_testing_actions`;
270
+ * in-process suites mount it directly). Answers `{ok: true}`.
256
271
  *
257
- * @param audit - the backend's emitter, whose in-flight writes the action awaits
272
+ * @param deps - the backend's `request_tracker` and `audit`
258
273
  */
259
- export const create_testing_drain_effects_action = (audit) => rpc_action(testing_drain_effects_action_spec, async () => {
260
- await audit.drain_inflight();
274
+ export const create_testing_drain_effects_action = (deps) => rpc_action(testing_drain_effects_action_spec, async () => {
275
+ const { request_tracker, audit } = deps;
276
+ // until both are empty: a flush's post-commit thunk can start an audit
277
+ // write, and a flush that starts meanwhile is waited for too
278
+ do {
279
+ await request_tracker.drain_flushes();
280
+ await audit.drain_inflight();
281
+ } while (request_tracker.flush_count() > 0 || audit.inflight_count() > 0);
261
282
  return { ok: true };
262
283
  });
263
284
  /**
@@ -699,7 +720,8 @@ export const create_testing_action_manifest_action = (mounted, ws_only = []) =>
699
720
  *
700
721
  * Returns the bundled `_testing_*` actions (module doc). The test binary
701
722
  * calls this at server-assembly time and registers the result on its
702
- * dispatcher. `_testing_drain_effects` drains `deps.audit`.
723
+ * dispatcher. `_testing_drain_effects` drains `deps.request_tracker` and
724
+ * `deps.audit`.
703
725
  *
704
726
  * The reset action's table-wipe list mirrors
705
727
  * `auth_integration_truncate_tables` from `testing/db.ts` — the
@@ -709,7 +731,7 @@ export const create_testing_action_manifest_action = (mounted, ws_only = []) =>
709
731
  * without updating this handler fails CI.
710
732
  */
711
733
  export const create_testing_actions = (deps, options) => {
712
- const { session_options, daemon_token_state, reset_state } = options;
734
+ const { daemon_token_state, reset_state } = options;
713
735
  const log = deps.log;
714
736
  return [
715
737
  rpc_action(testing_reset_action_spec, async (input, ctx) => {
@@ -767,15 +789,15 @@ export const create_testing_actions = (deps, options) => {
767
789
  const keeper = await create_test_account_with_credentials({
768
790
  db: ctx.db,
769
791
  keyring: deps.keyring,
770
- session_options,
771
792
  password: deps.password,
772
793
  password_value: DEFAULT_TEST_PASSWORD,
773
794
  roles: [...new Set([...DEFAULT_TEST_KEEPER_ROLES, ...(input.extra_keeper_roles ?? [])])]
774
795
  });
796
+ await ctx.db.query(RESET_SESSION_CLOCK_STAMP_SQL, [keeper.account.id]);
775
797
  // 6. Refresh the daemon-token cache so subsequent daemon-token
776
798
  // requests resolve to the freshly seeded keeper. The
777
- // middleware's lazy-refresh path only fires when the cached
778
- // id is null, so the reset sets it — after the commit, queued as
799
+ // middleware never re-reads the keeper, so the reset sets it —
800
+ // after the commit, queued as
779
801
  // soon as the keeper exists, so a reset that rolls back after it
780
802
  // (a failing extra seed, a failed COMMIT) leaves the cache on the
781
803
  // keeper still in the database rather than one that never
@@ -792,12 +814,12 @@ export const create_testing_actions = (deps, options) => {
792
814
  const seeded = await create_test_account_with_credentials({
793
815
  db: ctx.db,
794
816
  keyring: deps.keyring,
795
- session_options,
796
817
  password: deps.password,
797
818
  username: spec.username,
798
819
  password_value: spec.password_value ?? DEFAULT_TEST_PASSWORD,
799
820
  roles: spec.roles
800
821
  });
822
+ await ctx.db.query(RESET_SESSION_CLOCK_STAMP_SQL, [seeded.account.id]);
801
823
  extras.push(seeded);
802
824
  }
803
825
  // 8. Seed any additional keeper actors. Same bootstrap-cradle
@@ -819,7 +841,6 @@ export const create_testing_actions = (deps, options) => {
819
841
  const { session_cookie } = await mint_test_session({
820
842
  db: ctx.db,
821
843
  keyring: deps.keyring,
822
- session_options,
823
844
  account_id: input.account_id,
824
845
  expires_in_seconds: input.expires_in_seconds
825
846
  });
@@ -842,7 +863,7 @@ export const create_testing_actions = (deps, options) => {
842
863
  }
843
864
  return { hash };
844
865
  }),
845
- create_testing_drain_effects_action(deps.audit),
866
+ create_testing_drain_effects_action(deps),
846
867
  create_testing_flood_notifications_action(),
847
868
  create_testing_schema_snapshot_action(),
848
869
  create_testing_migration_tracker_action(),
@@ -1 +1 @@
1
- {"version":3,"file":"testing_server_bun.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_server_bun.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA0BlF,4CAA4C;AAC5C,eAAO,MAAM,0BAA0B,QAAO,oBAmE7C,CAAC"}
1
+ {"version":3,"file":"testing_server_bun.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/testing_server_bun.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA4B9B,OAAO,KAAK,EAAe,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AA0BlF,4CAA4C;AAC5C,eAAO,MAAM,0BAA0B,QAAO,oBAoE7C,CAAC"}
@@ -78,11 +78,12 @@ export const create_bun_testing_adapter = () => {
78
78
  //
79
79
  // So initiate a force-close (`true` drops active connections, no
80
80
  // drain) but DON'T await it: awaiting hangs `start_testing_server`'s
81
- // shutdown forever — `built.close()` and `exit(0)` never run, and the
82
- // spawning harness blocks on a child that never exits (observed as a
81
+ // shutdown forever — the core's exit never runs, and the spawning
82
+ // harness blocks on a child that never exits (observed as a
83
83
  // multi-minute hang needing SIGKILL). The force-close still tears the
84
- // live sockets down; the `exit(0)` the core fires immediately after
85
- // does the real teardown a few ms later. Node doesn't need this — its
84
+ // live sockets down; the exit the core fires once `built.close()`
85
+ // returns (`0`, or `1` when it gave up) does the real teardown. Node
86
+ // doesn't need this — its
86
87
  // `close()` resolves normally. The `.catch` guards a
87
88
  // future Bun that rejects rather than hangs; if a future Bun resolves
88
89
  // the promise after a server-initiated close, revert to