@fuzdev/fuz_app 0.182.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 (191) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +4 -4
  3. package/dist/auth/CLAUDE.md +58 -34
  4. package/dist/auth/account_routes.d.ts +5 -3
  5. package/dist/auth/account_routes.d.ts.map +1 -1
  6. package/dist/auth/account_routes.js +71 -66
  7. package/dist/auth/admin_actions.d.ts.map +1 -1
  8. package/dist/auth/admin_actions.js +22 -17
  9. package/dist/auth/audit_emitter.d.ts +75 -84
  10. package/dist/auth/audit_emitter.d.ts.map +1 -1
  11. package/dist/auth/audit_emitter.js +83 -71
  12. package/dist/auth/audit_log_schema.d.ts +10 -5
  13. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  14. package/dist/auth/audit_log_schema.js +22 -6
  15. package/dist/auth/bootstrap_account.d.ts +31 -13
  16. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  17. package/dist/auth/bootstrap_account.js +34 -15
  18. package/dist/auth/bootstrap_routes.d.ts +1 -1
  19. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  20. package/dist/auth/bootstrap_routes.js +7 -14
  21. package/dist/auth/deps.d.ts +8 -5
  22. package/dist/auth/deps.d.ts.map +1 -1
  23. package/dist/auth/deps.js +3 -2
  24. package/dist/auth/resolved_auth.d.ts +7 -7
  25. package/dist/auth/resolved_auth.d.ts.map +1 -1
  26. package/dist/auth/resolved_auth.js +4 -4
  27. package/dist/auth/role_grant_offer_actions.d.ts +25 -1
  28. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  29. package/dist/auth/role_grant_offer_actions.js +40 -33
  30. package/dist/auth/role_grant_offer_queries.d.ts +60 -4
  31. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  32. package/dist/auth/role_grant_offer_queries.js +79 -5
  33. package/dist/auth/role_grant_queries.d.ts +3 -52
  34. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  35. package/dist/auth/role_grant_queries.js +5 -80
  36. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  37. package/dist/auth/self_service_role_actions.js +11 -22
  38. package/dist/auth/session_queries.d.ts +6 -3
  39. package/dist/auth/session_queries.d.ts.map +1 -1
  40. package/dist/auth/session_queries.js +20 -11
  41. package/dist/auth/signup_routes.d.ts.map +1 -1
  42. package/dist/auth/signup_routes.js +90 -38
  43. package/dist/db/sql_columns.d.ts +1 -1
  44. package/dist/db/sql_columns.js +1 -1
  45. package/dist/http/CLAUDE.md +15 -10
  46. package/dist/http/db_routes.d.ts +7 -22
  47. package/dist/http/db_routes.d.ts.map +1 -1
  48. package/dist/http/db_routes.js +72 -72
  49. package/dist/http/pending_effects.d.ts +42 -4
  50. package/dist/http/pending_effects.d.ts.map +1 -1
  51. package/dist/http/pending_effects.js +34 -4
  52. package/dist/server/app_server.d.ts +43 -2
  53. package/dist/server/app_server.d.ts.map +1 -1
  54. package/dist/server/app_server.js +57 -3
  55. package/dist/testing/CLAUDE.md +255 -786
  56. package/dist/testing/adversarial_404.d.ts +6 -1
  57. package/dist/testing/adversarial_404.d.ts.map +1 -1
  58. package/dist/testing/adversarial_404.js +38 -17
  59. package/dist/testing/app_server.d.ts +20 -140
  60. package/dist/testing/app_server.d.ts.map +1 -1
  61. package/dist/testing/app_server.js +45 -124
  62. package/dist/testing/audit_drift_guard.d.ts +11 -6
  63. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  64. package/dist/testing/audit_drift_guard.js +15 -8
  65. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  66. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  67. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  68. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  69. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  70. package/dist/testing/cross_backend/capabilities.js +11 -7
  71. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  72. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  73. package/dist/testing/cross_backend/capability_mounts.js +423 -0
  74. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  75. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  76. package/dist/testing/cross_backend/cell_relations.js +12 -11
  77. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  78. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  79. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  80. package/dist/testing/cross_backend/conformance_table.d.ts +2 -50
  81. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  82. package/dist/testing/cross_backend/conformance_table.js +2 -270
  83. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  84. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  85. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  86. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  87. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  88. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  89. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  90. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  91. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  92. package/dist/testing/cross_backend/declared_skips.js +132 -0
  93. package/dist/testing/cross_backend/differential.d.ts +11 -2
  94. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  95. package/dist/testing/cross_backend/differential.js +35 -11
  96. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  97. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  99. package/dist/testing/cross_backend/in_process_setup.d.ts +22 -12
  100. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  101. package/dist/testing/cross_backend/in_process_setup.js +151 -134
  102. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  103. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/login_security.js +21 -4
  105. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  106. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  107. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  108. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  109. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  110. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  111. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  112. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  113. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  114. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  115. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  116. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  117. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  118. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  119. package/dist/testing/cross_backend/session_cap.js +22 -11
  120. package/dist/testing/cross_backend/setup.d.ts +31 -1
  121. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  122. package/dist/testing/cross_backend/setup.js +32 -1
  123. package/dist/testing/cross_backend/spine_suites.d.ts +123 -12
  124. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  125. package/dist/testing/cross_backend/spine_suites.js +454 -57
  126. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  127. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  128. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  129. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  130. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  131. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  132. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  133. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  134. package/dist/testing/cross_backend/testing_reset_actions.d.ts +59 -27
  135. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  136. package/dist/testing/cross_backend/testing_reset_actions.js +66 -42
  137. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  138. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  139. package/dist/testing/cross_backend/transport_composition.js +7 -3
  140. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  141. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  143. package/dist/testing/data_exposure.d.ts.map +1 -1
  144. package/dist/testing/data_exposure.js +3 -0
  145. package/dist/testing/db.d.ts +0 -32
  146. package/dist/testing/db.d.ts.map +1 -1
  147. package/dist/testing/db.js +0 -86
  148. package/dist/testing/db_entities.d.ts +14 -0
  149. package/dist/testing/db_entities.d.ts.map +1 -1
  150. package/dist/testing/db_entities.js +17 -0
  151. package/dist/testing/db_invariant_queries.d.ts +259 -0
  152. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  153. package/dist/testing/db_invariant_queries.js +400 -0
  154. package/dist/testing/db_invariants.d.ts +106 -0
  155. package/dist/testing/db_invariants.d.ts.map +1 -0
  156. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  157. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  158. package/dist/testing/db_invariants.gen.sql.js +13 -0
  159. package/dist/testing/db_invariants.js +141 -0
  160. package/dist/testing/db_invariants.sql +152 -0
  161. package/dist/testing/describe_db.d.ts +36 -0
  162. package/dist/testing/describe_db.d.ts.map +1 -0
  163. package/dist/testing/describe_db.js +71 -0
  164. package/dist/testing/integration.d.ts +6 -9
  165. package/dist/testing/integration.d.ts.map +1 -1
  166. package/dist/testing/integration.js +9 -13
  167. package/dist/testing/integration_helpers.d.ts +1 -1
  168. package/dist/testing/integration_helpers.d.ts.map +1 -1
  169. package/dist/testing/rate_limiting.d.ts +1 -1
  170. package/dist/testing/rate_limiting.d.ts.map +1 -1
  171. package/dist/testing/rate_limiting.js +3 -2
  172. package/dist/testing/role_grant_helpers.d.ts +1 -1
  173. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  174. package/dist/testing/round_trip.d.ts.map +1 -1
  175. package/dist/testing/round_trip.js +3 -0
  176. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  177. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  178. package/dist/testing/rpc_attack_surface.js +69 -6
  179. package/dist/testing/rpc_round_trip.d.ts +1 -1
  180. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  181. package/dist/testing/rpc_round_trip.js +3 -0
  182. package/dist/testing/sse_round_trip.d.ts +1 -1
  183. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  184. package/dist/testing/sse_round_trip.js +13 -4
  185. package/dist/testing/stubs.d.ts +4 -2
  186. package/dist/testing/stubs.d.ts.map +1 -1
  187. package/dist/testing/stubs.js +10 -5
  188. package/dist/testing/test_app.d.ts +166 -0
  189. package/dist/testing/test_app.d.ts.map +1 -0
  190. package/dist/testing/test_app.js +124 -0
  191. package/package.json +1 -1
@@ -11,7 +11,9 @@ import '../assert_dev_env.js';
11
11
  * cross-impl parity diffing against a Rust backend's `fuz_db` snapshot),
12
12
  * **`_testing_migration_tracker`** (dump the `schema_version` tracker rows for
13
13
  * cross-impl migration-identity parity — the provenance half the snapshot gate
14
- * excludes by design), and **`_testing_flood_notifications`** (queue a burst
14
+ * excludes by design), **`_testing_db_invariants`** (run the database
15
+ * invariant statement for the per-test check), and
16
+ * **`_testing_flood_notifications`** (queue a burst
15
17
  * of notifications onto the caller's own WebSocket connection, to push its
16
18
  * outbound queue past its byte budget).
17
19
  *
@@ -89,11 +91,11 @@ import { protocol_action_specs } from '../../actions/protocol.js';
89
91
  import { RoomEvictReason, RoomId } from '../../actions/room_action_specs.js';
90
92
  import { query_put_fact } from '../../db/fact_queries.js';
91
93
  import { query_put_fact_holder } from '../../db/fact_holder_queries.js';
92
- import { ROLE_ADMIN, ROLE_KEEPER } from '../../auth/role_schema.js';
93
94
  import { query_schema_snapshot, SchemaSnapshot, query_migration_tracker, MigrationTracker } from '../schema_introspect.js';
94
95
  import { ActionManifest, build_action_manifest } from './action_manifest.js';
96
+ import { DbInvariantRows, query_db_invariant_rows } from '../db_invariant_queries.js';
95
97
  import { create_test_extra_actor } from '../db_entities.js';
96
- import { create_test_account_with_credentials, mint_test_session } from '../app_server.js';
98
+ import { create_test_account_with_credentials, DEFAULT_TEST_KEEPER_ROLES, mint_test_session } from '../app_server.js';
97
99
  import { DEFAULT_TEST_PASSWORD } from '../test_credentials.js';
98
100
  import { TESTING_ACTION_AUTH } from './spine_surface_constants.js';
99
101
  /** Output shape for an individual seeded account (keeper or extra). */
@@ -162,31 +164,26 @@ export const testing_reset_action_spec = {
162
164
  description: 'Test-binary only — wipe auth tables, re-bootstrap a fresh keeper (+ optional extras), fire the domain-state reset.'
163
165
  };
164
166
  /**
165
- * `_testing_drain_effects` — await in-flight fire-and-forget audit writes so
166
- * a following `audit_log_list` is authoritative. The deterministic barrier
167
- * the cross-backend conformance suite uses in place of a poll/sleep before
168
- * asserting on audit rows.
167
+ * `_testing_drain_effects` — await in-flight fire-and-forget writes so a
168
+ * following `audit_log_list` or database read is authoritative. The
169
+ * deterministic barrier the cross-backend conformance suite uses in place of
170
+ * a poll/sleep before asserting on audit rows.
169
171
  *
170
172
  * The handler awaits `AuditEmitter.drain_inflight`, which waits until no
171
- * tracked `emit` write is outstanding — so the binary's emitter must be built
172
- * with `track_inflight: true`, or the drain resolves at once and is no barrier.
173
- * Tracking is what makes it a barrier whatever the transport: an **HTTP**
174
- * mutation on a binary running `await_pending_effects: true` has its writes
175
- * settled by the time it responds, but a **WS** mutation is answered before
176
- * its effects flush (reply-then-close for a self-revocation), so its audit
177
- * write can still be in flight when the caller reads the reply. The Rust
178
- * spine does the same await in `AuditEmitter::drain_inflight`, over an
179
- * emitter built with `new_with_inflight_tracking`.
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
177
+ * `await_background_writes_layer`), but a **WS** mutation is answered
178
+ * 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`.
180
181
  *
181
182
  * Covered: every `emit` that ran before the drain was dispatched, and any
182
183
  * started while it waits. A write that starts after the drain resolves is
183
- * not — nor are eager writes outside `emit` (session touch, token usage),
184
- * which only the dispatching transport's own flush awaits.
185
- *
186
- * The output's `tracked` is `AuditEmitter.is_tracking_inflight` — whether the
187
- * drain could wait on anything. `cross_drain_effects` refuses `tracked: false`,
188
- * so a binary whose emitter was built without tracking fails its first audit
189
- * read instead of racing it. The Rust twin answers the same shape.
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.
190
187
  *
191
188
  * `auth` gates on the daemon-token credential, matching `_testing_reset`.
192
189
  */
@@ -197,15 +194,9 @@ export const testing_drain_effects_action_spec = {
197
194
  auth: TESTING_ACTION_AUTH,
198
195
  side_effects: false,
199
196
  input: fuz_void,
200
- output: object({
201
- ok: boolean,
202
- tracked: meta(boolean, {
203
- description: "Whether the backend's audit emitter tracks in-flight writes — false means the drain " +
204
- 'waited on nothing and is no barrier.'
205
- })
206
- }),
197
+ output: object({ ok: boolean }),
207
198
  async: true,
208
- description: 'Test-binary only — await in-flight fire-and-forget audit writes so a following audit_log_list read is authoritative.'
199
+ description: 'Test-binary only — await in-flight fire-and-forget writes so a following audit_log_list or database read is authoritative.'
209
200
  };
210
201
  /**
211
202
  * `_testing_mint_session` — mint an expired-by-construction server-side
@@ -258,17 +249,16 @@ export const testing_mint_session_action_spec = {
258
249
  };
259
250
  /**
260
251
  * Build the standalone `_testing_drain_effects` action over `audit` — the
261
- * emitter the backend's handlers emit through (`deps.audit`), built with
262
- * `track_inflight: true` (see the spec doc). Mount it on any test endpoint
252
+ * emitter the backend's handlers emit through (`deps.audit`). Mount it on any test endpoint
263
253
  * whose suite asserts on audit rows (the spine binary bundles it via
264
254
  * `create_testing_actions`; in-process suites mount it directly). Answers
265
- * `{ok: true, tracked}`, `tracked` read from `audit.is_tracking_inflight()`.
255
+ * `{ok: true}`.
266
256
  *
267
257
  * @param audit - the backend's emitter, whose in-flight writes the action awaits
268
258
  */
269
259
  export const create_testing_drain_effects_action = (audit) => rpc_action(testing_drain_effects_action_spec, async () => {
270
260
  await audit.drain_inflight();
271
- return { ok: true, tracked: audit.is_tracking_inflight() };
261
+ return { ok: true };
272
262
  });
273
263
  /**
274
264
  * `_testing_put_fact` — seed an **embedded** fact (`fact.bytes`) for the
@@ -514,6 +504,40 @@ export const testing_migration_tracker_action_spec = {
514
504
  * `create_testing_actions`; mount directly for in-process use.
515
505
  */
516
506
  export const create_testing_migration_tracker_action = () => rpc_action(testing_migration_tracker_action_spec, async (_input, ctx) => query_migration_tracker(ctx.db));
507
+ /**
508
+ * `_testing_db_invariants` — run the database invariant statement
509
+ * (`DB_INVARIANTS_SQL`, the one `db_invariants.sql` holds) and answer every
510
+ * violating row, `{rows: [{invariant, row}]}`, unfiltered: the harness drops
511
+ * the invariants its setup excludes. The per-test check of a cross-process
512
+ * setup reads it, so a backend whose database the test process can't reach
513
+ * (`memory://`) is checked like one it can. Read-only, writing no audit row.
514
+ * A row's key order is not part of the contract (the spines' JSON maps order
515
+ * keys differently); compare rows as objects.
516
+ *
517
+ * `auth` gates on the daemon-token credential, matching `_testing_reset`. The
518
+ * Rust mirror is `fuz_testing::create_testing_db_invariants_action_spec`,
519
+ * running the same statement from its byte-identical copy of the file.
520
+ */
521
+ export const testing_db_invariants_action_spec = {
522
+ method: '_testing_db_invariants',
523
+ kind: 'request_response',
524
+ initiator: 'frontend',
525
+ auth: TESTING_ACTION_AUTH,
526
+ side_effects: false,
527
+ input: fuz_void,
528
+ output: DbInvariantRows,
529
+ async: true,
530
+ description: 'Test-binary only — run the database invariant statement and answer every violating row ' +
531
+ 'for the per-test invariant check.'
532
+ };
533
+ /**
534
+ * Build the standalone `_testing_db_invariants` action. No deps — reads
535
+ * `ctx.db` via `query_db_invariant_rows`. Bundled by
536
+ * `create_testing_actions`; mount directly for in-process use.
537
+ */
538
+ export const create_testing_db_invariants_action = () => rpc_action(testing_db_invariants_action_spec, async (_input, ctx) => ({
539
+ rows: await query_db_invariant_rows({ db: ctx.db })
540
+ }));
517
541
  /** The shortest expiry `_testing_shorten_credential_expiry` sets, in seconds from now. */
518
542
  export const TESTING_SHORTEN_CREDENTIAL_EXPIRY_MIN_SECONDS = 1;
519
543
  /**
@@ -675,8 +699,7 @@ export const create_testing_action_manifest_action = (mounted, ws_only = []) =>
675
699
  *
676
700
  * Returns the bundled `_testing_*` actions (module doc). The test binary
677
701
  * calls this at server-assembly time and registers the result on its
678
- * dispatcher. `_testing_drain_effects` drains `deps.audit`, so the binary's
679
- * `audit_factory` builds the emitter with `track_inflight: true`.
702
+ * dispatcher. `_testing_drain_effects` drains `deps.audit`.
680
703
  *
681
704
  * The reset action's table-wipe list mirrors
682
705
  * `auth_integration_truncate_tables` from `testing/db.ts` — the
@@ -738,16 +761,16 @@ export const create_testing_actions = (deps, options) => {
738
761
  // parity — same hash, same account+actor+role_grants+
739
762
  // api_token+session_cookie shape.
740
763
  //
741
- // Roles default to `[ROLE_KEEPER, ROLE_ADMIN]` to match
742
- // production `bootstrap_account`. `extra_keeper_roles` adds
743
- // on top.
764
+ // Roles default to `DEFAULT_TEST_KEEPER_ROLES` (keeper and
765
+ // admin) to match production `bootstrap_account`.
766
+ // `extra_keeper_roles` adds on top.
744
767
  const keeper = await create_test_account_with_credentials({
745
768
  db: ctx.db,
746
769
  keyring: deps.keyring,
747
770
  session_options,
748
771
  password: deps.password,
749
772
  password_value: DEFAULT_TEST_PASSWORD,
750
- roles: [ROLE_KEEPER, ROLE_ADMIN, ...(input.extra_keeper_roles ?? [])]
773
+ roles: [...new Set([...DEFAULT_TEST_KEEPER_ROLES, ...(input.extra_keeper_roles ?? [])])]
751
774
  });
752
775
  // 6. Refresh the daemon-token cache so subsequent daemon-token
753
776
  // requests resolve to the freshly seeded keeper. The
@@ -822,6 +845,7 @@ export const create_testing_actions = (deps, options) => {
822
845
  create_testing_drain_effects_action(deps.audit),
823
846
  create_testing_flood_notifications_action(),
824
847
  create_testing_schema_snapshot_action(),
825
- create_testing_migration_tracker_action()
848
+ create_testing_migration_tracker_action(),
849
+ create_testing_db_invariants_action()
826
850
  ];
827
851
  };
@@ -60,7 +60,7 @@ export interface TransportCompositionCrossTestOptions extends RpcPathCapabilityG
60
60
  readonly ws_path?: string;
61
61
  /** Audit-log SSE path. Default `/api/admin/audit/stream`. */
62
62
  readonly sse_path?: string;
63
- /** Run the multi-actor rows (`transport_composition_multi_actor_cases`). */
63
+ /** Run the multi-actor rows (`transport_composition_multi_actor_cases`); omitted, they skip. */
64
64
  readonly multi_actor?: TransportCompositionMultiActorOptions;
65
65
  /**
66
66
  * The backend's request-body cap on `rpc_path`, in bytes; the RPC row's
@@ -1 +1 @@
1
- {"version":3,"file":"transport_composition.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/transport_composition.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAuG9B,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,uCAAuC,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AASlG,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,6DAA6D;AAC7D,MAAM,MAAM,2BAA2B,GACtC,WAAW,GAAG,eAAe,G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M,GAAG,IAAI,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IACzB,yFAAyF;IACzF,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,yFAAyF;IACzF,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,kDAAkD;IAClD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,WAAW,CAAC,EAAE,qCAAqC,CAAC;IAC7D;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACrC;AAqED;;;;;;;GAOG;AACH,eAAO,MAAM,0CAA0C,GACtD,SAAS,oCAAoC,KAC3C,IA6PF,CAAC"}
1
+ {"version":3,"file":"transport_composition.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/transport_composition.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAwG9B,OAAO,EAAW,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAEtE,OAAO,KAAK,EAAE,uCAAuC,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AASlG,OAAO,EAAe,KAAK,WAAW,EAAE,MAAM,YAAY,CAAC;AAE3D,6DAA6D;AAC7D,MAAM,MAAM,2BAA2B,GACtC,WAAW,GAAG,eAAe,GAAG,UAAU,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,CAAC;AAE/E,0DAA0D;AAC1D,MAAM,MAAM,yBAAyB,GAClC,gBAAgB,GAChB,mBAAmB,GACnB,mBAAmB,GACnB,yBAAyB,GACzB,eAAe,GACf,gBAAgB,GAChB,uBAAuB,CAAC;AAE3B,kCAAkC;AAClC,MAAM,WAAW,0BAA0B;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC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DAA6D;IAC7D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,gGAAgG;IAChG,QAAQ,CAAC,WAAW,CAAC,EAAE,qCAAqC,CAAC;IAC7D;;;;;OAKG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CACrC;AAqED;;;;;;;GAOG;AACH,eAAO,MAAM,0CAA0C,GACtD,SAAS,oCAAoC,KAC3C,IAiQF,CAAC"}
@@ -64,7 +64,8 @@ import '../assert_dev_env.js';
64
64
  * that ask for no upgrade gate on `capabilities.ws` alone.
65
65
  *
66
66
  * **Multi-actor upgrade.** One more WS row needs a keeper seeded with a
67
- * second actor (`extra_actors`), so it runs only given `multi_actor`: a
67
+ * second actor (`extra_actors`), so it runs only given `multi_actor` (without
68
+ * it the row registers as a gated skip): a
68
69
  * multi-actor keeper's session upgrading with no `?acting=` → 400
69
70
  * `actor_required`, the flat body both spines' upgrade-time actor resolution
70
71
  * answers. The upgrade resolves an actor there, and a multi-actor account
@@ -420,10 +421,13 @@ export const describe_transport_composition_cross_tests = (options) => {
420
421
  assert.strictEqual(raw_http_parse_json(res.text)?.error, 'route_not_found');
421
422
  });
422
423
  const { multi_actor } = options;
423
- if (!multi_actor)
424
- return;
425
424
  for (const c of transport_composition_multi_actor_cases) {
426
425
  const name = case_name(c);
426
+ // without the multi-actor setup the cases register as gated skips
427
+ if (!multi_actor) {
428
+ test_if(false, name, () => { });
429
+ continue;
430
+ }
427
431
  const body = () => run_case(c, multi_actor.setup_test);
428
432
  if (!is_runnable(c)) {
429
433
  test_if(false, name, body);
@@ -28,6 +28,11 @@ export interface CrossProcessWsTestOptions extends WsEndpointTarget {
28
28
  readonly max_message_bytes?: number;
29
29
  /** REST logout route path, for the logout close case. Default `/api/account/logout`. */
30
30
  readonly logout_path?: string;
31
+ /**
32
+ * REST login route path, for the logout case's second session of the
33
+ * account. Default `/api/account/login`.
34
+ */
35
+ readonly login_path?: string;
31
36
  /** REST password-change route path, for its close case. Default `/api/account/password`. */
32
37
  readonly password_path?: string;
33
38
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ws_round_trip.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/ws_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAwH9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AAItE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAKzD,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAK1B,2DAA2D;AAC3D,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAClE;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,wFAAwF;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B,4FAA4F;IAC5F,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAClD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,yBAAyB,KAAG,IA4epF,CAAC"}
1
+ {"version":3,"file":"ws_round_trip.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/ws_round_trip.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA2H9B,OAAO,EAAE,KAAK,mBAAmB,EAAW,MAAM,mBAAmB,CAAC;AAItE,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAOzD,OAAO,EAGN,KAAK,gBAAgB,EACrB,MAAM,kBAAkB,CAAC;AAK1B,2DAA2D;AAC3D,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;IAClE;;;;OAIG;IACH,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC;IAC/B,uEAAuE;IACvE,QAAQ,CAAC,YAAY,EAAE,mBAAmB,CAAC;IAC3C;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IACpC,wFAAwF;IACxF,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAC9B;;;OAGG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,4FAA4F;IAC5F,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC;;;;;;OAMG;IACH,QAAQ,CAAC,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAClD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,+BAA+B,GAAI,SAAS,yBAAyB,KAAG,IAmiBpF,CAAC"}
@@ -54,9 +54,12 @@ import '../assert_dev_env.js';
54
54
  * socket:
55
55
  * `account_token_revoke` closes the revoked token's bearer socket and leaves
56
56
  * a socket on the account's other token open; `admin_token_revoke_all`,
57
- * `POST /logout`, `POST /password`, and `account_purge` (also gated on
57
+ * `POST /password`, and `account_purge` (also gated on
58
58
  * `capabilities.account_lifecycle`) close the account's bearer and session
59
- * sockets — the rows `create_account_revocations` shares with the SSE suite;
59
+ * sockets, and `POST /logout` closes only the socket of the session it ends,
60
+ * the account's bearer socket and a second session's socket each answering a
61
+ * request after it — the rows `create_account_revocations` shares with the SSE
62
+ * suite;
60
63
  * and a token the per-account cap evicts (`max_tokens` further mints) has its
61
64
  * bearer socket closed. Omit `rpc_path` to skip them
62
65
  * (consumers without the standard account and admin actions on their RPC
@@ -97,7 +100,8 @@ import { list_audit_events } from './audit_cross_helpers.js';
97
100
  import { test_if } from './capabilities.js';
98
101
  import { cross_rpc_call, expect_output } from './cross_rpc.js';
99
102
  import { create_account_revocations } from './revocation_drivers.js';
100
- import { SPINE_ACCOUNT_LOGOUT_PATH, SPINE_ACCOUNT_PASSWORD_PATH } from './spine_surface_constants.js';
103
+ import { login_fresh_session } from './session_login.js';
104
+ import { SPINE_ACCOUNT_LOGIN_PATH, SPINE_ACCOUNT_LOGOUT_PATH, SPINE_ACCOUNT_PASSWORD_PATH } from './spine_surface_constants.js';
101
105
  import { assert_ws_upgrade_refused, open_session_ws } from './ws_endpoint.js';
102
106
  /** Origin guaranteed to fail the `http://localhost:*` allowlist the test backends run with. */
103
107
  const DISALLOWED_ORIGIN = 'http://disallowed.example';
@@ -113,7 +117,7 @@ const DISALLOWED_ORIGIN = 'http://disallowed.example';
113
117
  * audit row read back after `_testing_drain_effects`.
114
118
  */
115
119
  export const describe_cross_process_ws_tests = (options) => {
116
- const { setup_test, capabilities, base_url, ws_path, origin, rpc_path, max_message_bytes = DEFAULT_WS_MAX_MESSAGE_BYTES, logout_path = SPINE_ACCOUNT_LOGOUT_PATH, password_path = SPINE_ACCOUNT_PASSWORD_PATH, ws_account_roles = [] } = options;
120
+ const { setup_test, capabilities, base_url, ws_path, origin, rpc_path, max_message_bytes = DEFAULT_WS_MAX_MESSAGE_BYTES, logout_path = SPINE_ACCOUNT_LOGOUT_PATH, login_path = SPINE_ACCOUNT_LOGIN_PATH, password_path = SPINE_ACCOUNT_PASSWORD_PATH, ws_account_roles = [] } = options;
117
121
  const max_tokens = options.max_tokens === undefined ? DEFAULT_MAX_TOKENS : options.max_tokens;
118
122
  const open_authed = async () => {
119
123
  const fixture = await setup_test();
@@ -377,9 +381,12 @@ export const describe_cross_process_ws_tests = (options) => {
377
381
  assert.strictEqual(other.close_code, null);
378
382
  });
379
383
  });
380
- // The account-wide revocations (`revocation_drivers.ts`, shared with the
381
- // SSE suite) close the account's connections — its bearer socket, and its
382
- // session socket too.
384
+ // The revocations of `revocation_drivers.ts`, shared with the SSE suite.
385
+ // An account-wide one closes the account's connections — its bearer
386
+ // socket, and its session socket too. A session-scoped one (logout)
387
+ // closes the socket of the session it was sent on, and leaves the
388
+ // account's bearer socket and another session's socket open, each proven
389
+ // by a reply after the close.
383
390
  // Without `rpc_path` the rows still register, as skipped cases, and never
384
391
  // run — so the empty path is never sent.
385
392
  const revocations = create_account_revocations({
@@ -388,7 +395,46 @@ export const describe_cross_process_ws_tests = (options) => {
388
395
  logout_path,
389
396
  password_path
390
397
  });
391
- for (const { label, slug, gate, revoke } of revocations) {
398
+ for (const { label, slug, gate, closes, revoke } of revocations) {
399
+ if (closes === 'session') {
400
+ test_if(capabilities.ws && gate && rpc_path !== undefined, `${label} closes only its session's socket`, async () => {
401
+ const fixture = await setup_test();
402
+ const target = await fixture.create_account({
403
+ username: `ws_revoke_${slug}`,
404
+ password_value: DEFAULT_TEST_PASSWORD,
405
+ roles: [...ws_account_roles]
406
+ });
407
+ // a second login, a second session of the same account on its own jar
408
+ const second = await login_fresh_session(fixture, {
409
+ login_path,
410
+ username: target.account.username,
411
+ password: DEFAULT_TEST_PASSWORD,
412
+ label: 'the second login'
413
+ });
414
+ await with_sockets([
415
+ () => open_session(target),
416
+ () => open_bearer(target.api_token),
417
+ () => create_admitted_ws_transport({
418
+ base_url,
419
+ ws_path,
420
+ cookies: second.cookies(),
421
+ origin: origin ?? base_url
422
+ })
423
+ ], async (session, bearer, other_session) => {
424
+ await revoke(fixture, target);
425
+ await assert_revoked_close(session, `${label} (its session socket)`);
426
+ // the credentials it didn't end keep their sockets
427
+ for (const [what, client] of [
428
+ ['bearer socket', bearer],
429
+ ['other session socket', other_session]
430
+ ]) {
431
+ assert.deepStrictEqual(await client.request(2, heartbeat_action_spec.method, {}), {}, `${label}: the ${what} still answers`);
432
+ assert.strictEqual(client.close_code, null, `${label}: the ${what} stays open`);
433
+ }
434
+ });
435
+ });
436
+ continue;
437
+ }
392
438
  test_if(capabilities.ws && gate && rpc_path !== undefined, `${label} closes the account's bearer and session sockets`, async () => {
393
439
  const fixture = await setup_test();
394
440
  const target = await fixture.create_account({
@@ -1 +1 @@
1
- {"version":3,"file":"data_exposure.d.ts","sourceRoot":"","sources":["../../src/lib/testing/data_exposure.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAyB7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAKzD,OAAO,EAIN,KAAK,gBAAgB,EACrB,MAAM,wBAAwB,CAAC;AAehC,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,0BAA0B,CAAC;AAIvE;;;;;;;;GAQG;AACH,eAAO,MAAM,kCAAkC,GAAI,QAAQ,OAAO,KAAG,GAAG,CAAC,MAAM,CAmC9E,CAAC;AA0HF;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,yCAAyC,GACrD,gBAAgB,cAAc,EAC9B,mBAAkB,aAAa,CAAC,MAAM,CAA6B,EACnE,cAAc,aAAa,CAAC,MAAM,CAAC,KACjC,IAOF,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,wCAAwC,GACpD,gBAAgB,cAAc,EAC9B,oBAAmB,aAAa,CAAC,MAAM,CAA8B,EACrE,cAAc,aAAa,CAAC,MAAM,CAAC,KACjC,IAYF,CAAC;AAIF,kDAAkD;AAClD,MAAM,WAAW,uBAAuB;IACvC,kEAAkE;IAClE,UAAU,EAAE,SAAS,CAAC;IACtB;;;OAGG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,2FAA2F;IAC3F,gBAAgB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACzC,iGA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G,iBAAiB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C;;;;OAIG;IACH,WAAW,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B;;;;OAIG;IACH,YAAY,CAAC,EAAE,gBAAgB,CAAC;CAChC;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,4BAA4B,GAAI,SAAS,uBAAuB,KAAG,IAuM/E,CAAC"}
@@ -19,6 +19,7 @@ import './assert_dev_env.js';
19
19
  * @module
20
20
  */
21
21
  import { describe, test, beforeAll, assert } from 'vitest';
22
+ import { check_db_invariants_after_all } from './db_invariants.js';
22
23
  import { format_route_key } from '../http/surface_query.js';
23
24
  import { ROLE_ADMIN, ROLE_KEEPER } from '../auth/role_schema.js';
24
25
  import { create_test_request_headers } from './test_origin.js';
@@ -236,6 +237,8 @@ export const describe_data_exposure_tests = (options) => {
236
237
  });
237
238
  describe('data exposure — runtime', () => {
238
239
  let fixture;
240
+ // `fixture` is unassigned until `beforeAll` runs, which the check allows for
241
+ check_db_invariants_after_all(() => fixture);
239
242
  let authed_account;
240
243
  let admin_account;
241
244
  beforeAll(async () => {
@@ -111,40 +111,8 @@ export declare const auth_truncate_tables: string[];
111
111
  * touch audit logging don't need to truncate it.
112
112
  */
113
113
  export declare const auth_integration_truncate_tables: string[];
114
- /**
115
- * Create a `describe_db` function bound to specific factories and truncate tables.
116
- *
117
- * Returns a 2-arg `(name, fn)` function that runs the test suite against each
118
- * factory. Each factory gets its own `describe` block with a shared database
119
- * instance, automatic `beforeEach` truncation, and `afterAll` cleanup.
120
- * Skipped factories use `describe.skip`.
121
- *
122
- * @param factories - one or more database factories to run suites against
123
- * @param truncate_tables - tables to truncate between tests (children first for FK safety)
124
- * @mutates the underlying database between tests — `beforeEach` issues
125
- * `TRUNCATE <truncate_tables> CASCADE` against the shared instance.
126
- */
127
- export declare const create_describe_db: (factories: DbFactory | Array<DbFactory>, truncate_tables: Array<string>) => ((name: string, fn: (get_db: () => Db) => void) => void);
128
114
  /**
129
115
  * Log factory status to console.
130
116
  */
131
117
  export declare const log_db_factory_status: (factories: Array<DbFactory>) => void;
132
- /**
133
- * Assert a `*_COLUMNS` projection const names exactly the live columns of
134
- * `table` — the drift guard for an exported const (`ACCOUNT_COLUMNS`,
135
- * `CELL_COLUMNS`, a consumer's own).
136
- *
137
- * This is the reverse of the fail-loud read: a named projection makes a
138
- * *dropped* column fail loud at query time, but a column *added* to the table
139
- * and not to the projection would silently vanish from every row read. Both
140
- * directions are covered by the equality here. It guards one const; it can't
141
- * see a table that has *no* const — for that, keep a table → const registry
142
- * and assert its key set against `query_public_columns` (fuz_app's own is
143
- * `src/test/db/column_projections.db.test.ts`).
144
- *
145
- * @param db - a bootstrapped test database
146
- * @param table - the `public`-schema table the const projects
147
- * @param columns - the projection const's column names
148
- */
149
- export declare const assert_columns_match_live: (db: Db, table: string, columns: ReadonlyArray<string>) => Promise<void>;
150
118
  //# sourceMappingURL=db.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/lib/testing/db.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA8B7B,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAatC;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,OAAO,CAAC,EAAE,CAAC,CAAC;IAC1B,KAAK,EAAE,CAAC,EAAE,EAAE,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,mBAAmB,GAAU,IAAI,EAAE,KAAG,OAAO,CAAC,IAAI,CAG9D,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,WAAW,EAAE,CAAC,EAAE,EA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AM,qBAAqB,GAAI,WAAW,KAAK,CAAC,SAAS,CAAC,KAAG,IAQnE,CAAC"}
@@ -1,34 +1,7 @@
1
1
  import './assert_dev_env.js';
2
- /**
3
- * Test database fixtures for parameterized testing.
4
- *
5
- * Provides factory builders for creating test databases with pglet-wasm (the
6
- * in-memory default), PGlite (in-memory) and pg (PostgreSQL) drivers. Consumer
7
- * projects provide their own schema initialization via `run_migrations` and
8
- * compose factories into test suites.
9
- *
10
- * @example
11
- * ```ts
12
- * import {create_default_db_factory, create_pg_factory} from '@fuzdev/fuz_app/testing/db.ts';
13
- * import {run_migrations} from '@fuzdev/fuz_app/db/migrate.ts';
14
- * import {AUTH_MIGRATION_NS} from '@fuzdev/fuz_app/auth/migrations.ts';
15
- *
16
- * const init_schema = async (db) => {
17
- * await run_migrations(db, [AUTH_MIGRATION_NS]);
18
- * };
19
- * const default_factory = create_default_db_factory(init_schema);
20
- * const pg_factory = create_pg_factory(init_schema, process.env.TEST_DATABASE_URL);
21
- * export const db_factories = [default_factory, pg_factory];
22
- * ```
23
- *
24
- * @module
25
- */
26
- import { describe, beforeAll, beforeEach, afterAll, assert } from 'vitest';
27
2
  import { create_pglite_db } from '../db/db_pglite.js';
28
3
  import { create_pglet_db_driver, create_pglet_instance } from '../db/db_pglet.js';
29
- import { assert_valid_sql_identifier } from '../db/sql_identifier.js';
30
4
  import { create_pg_db, create_pg_pool, DEFAULT_DB_CHECKOUT_TIMEOUT_MS, register_pg_type_parsers } from '../db/db_pg.js';
31
- import { query_public_columns } from '../db/schema_ready.js';
32
5
  import { pg_error_code } from '../db/pg_error.js';
33
6
  /**
34
7
  * Reset a test database to a clean slate by dropping and recreating the `public` schema.
@@ -244,43 +217,6 @@ export const auth_truncate_tables = [
244
217
  * touch audit logging don't need to truncate it.
245
218
  */
246
219
  export const auth_integration_truncate_tables = [...auth_truncate_tables, 'audit_log'];
247
- /**
248
- * Create a `describe_db` function bound to specific factories and truncate tables.
249
- *
250
- * Returns a 2-arg `(name, fn)` function that runs the test suite against each
251
- * factory. Each factory gets its own `describe` block with a shared database
252
- * instance, automatic `beforeEach` truncation, and `afterAll` cleanup.
253
- * Skipped factories use `describe.skip`.
254
- *
255
- * @param factories - one or more database factories to run suites against
256
- * @param truncate_tables - tables to truncate between tests (children first for FK safety)
257
- * @mutates the underlying database between tests — `beforeEach` issues
258
- * `TRUNCATE <truncate_tables> CASCADE` against the shared instance.
259
- */
260
- export const create_describe_db = (factories, truncate_tables) => {
261
- const factory_list = Array.isArray(factories) ? factories : [factories];
262
- return (name, fn) => {
263
- for (const factory of factory_list) {
264
- const describe_fn = factory.skip ? describe.skip : describe;
265
- describe_fn(`${name} (${factory.name})`, () => {
266
- let db;
267
- beforeAll(async () => {
268
- db = await factory.create();
269
- });
270
- beforeEach(async () => {
271
- if (db && truncate_tables.length > 0) {
272
- await db.query(`TRUNCATE ${truncate_tables.map(assert_valid_sql_identifier).join(', ')} CASCADE`);
273
- }
274
- });
275
- afterAll(async () => {
276
- if (db)
277
- await factory.close(db);
278
- });
279
- fn(() => db);
280
- });
281
- }
282
- };
283
- };
284
220
  /**
285
221
  * Log factory status to console.
286
222
  */
@@ -289,25 +225,3 @@ export const log_db_factory_status = (factories) => {
289
225
  const skipped = factories.filter((f) => f.skip).map((f) => `${f.name} (${f.skip_reason})`);
290
226
  console.log(`[db tests] drivers: ${enabled.join(', ')}${skipped.length ? ` | skipped: ${skipped.join(', ')}` : ''}`);
291
227
  };
292
- /**
293
- * Assert a `*_COLUMNS` projection const names exactly the live columns of
294
- * `table` — the drift guard for an exported const (`ACCOUNT_COLUMNS`,
295
- * `CELL_COLUMNS`, a consumer's own).
296
- *
297
- * This is the reverse of the fail-loud read: a named projection makes a
298
- * *dropped* column fail loud at query time, but a column *added* to the table
299
- * and not to the projection would silently vanish from every row read. Both
300
- * directions are covered by the equality here. It guards one const; it can't
301
- * see a table that has *no* const — for that, keep a table → const registry
302
- * and assert its key set against `query_public_columns` (fuz_app's own is
303
- * `src/test/db/column_projections.db.test.ts`).
304
- *
305
- * @param db - a bootstrapped test database
306
- * @param table - the `public`-schema table the const projects
307
- * @param columns - the projection const's column names
308
- */
309
- export const assert_columns_match_live = async (db, table, columns) => {
310
- const live = await query_public_columns(db, { table });
311
- assert.ok(live[table], `table "${table}" is not in the live public schema`);
312
- assert.deepEqual([...columns].sort(), live[table]);
313
- };
@@ -70,4 +70,18 @@ export declare const create_test_extra_actor: (db: Db, account_id: string, name:
70
70
  * multi-actor tombstone state directly (no per-actor-delete RPC ships yet).
71
71
  */
72
72
  export declare const soft_delete_test_actor: (db: Db, actor_id: string) => Promise<boolean>;
73
+ /**
74
+ * Insert an `auth_session` row expiring `expires_in_seconds` after the
75
+ * database's `NOW()` — negative for a session already expired. For tests
76
+ * that need a session of a given lifetime, past or future, which
77
+ * `query_create_session` (always a full `AUTH_SESSION_LIFETIME_MS`) can't
78
+ * write. The same statement as the Rust `_testing_mint_session`.
79
+ *
80
+ * @param db - the database
81
+ * @param token_hash - the session's id, the token's hash (`hash_session_token`)
82
+ * @param account_id - the account the session belongs to
83
+ * @param expires_in_seconds - the expiry's offset from `NOW()`, in seconds
84
+ * @mutates `db` — inserts one `auth_session` row
85
+ */
86
+ export declare const create_test_session_row: (db: Db, token_hash: string, account_id: string, expires_in_seconds: number) => Promise<void>;
73
87
  //# sourceMappingURL=db_entities.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"db_entities.d.ts","sourceRoot":"","sources":["../../src/lib/testing/db_entities.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AA0B7B,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC,oFAAoF;AACpF,MAAM,WAAW,oBAAoB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;CACb;AAED;;;;;;;;;;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B,OAAO,CAAC,SAAS,CAA2C,CAAC;AAEhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,uBAAuB,GACnC,IAAI,EAAE,EACN,YAAY,MAAM,EAClB,MAAM,MAAM,KACV,OAAO,CAAC,KAAK,CAWf,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GAAU,IAAI,EAAE,EAAE,UAAU,MAAM,KAAG,OAAO,CAAC,OAAO,CACvC,CAAC;AAEjD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,uBAAuB,GACnC,IAAI,EAAE,EACN,YAAY,MAAM,EAClB,YAAY,MAAM,EAClB,oBAAoB,MAAM,KACxB,OAAO,CAAC,IAAI,CAMd,CAAC"}
@@ -89,3 +89,20 @@ export const create_test_extra_actor = async (db, account_id, name) => {
89
89
  * multi-actor tombstone state directly (no per-actor-delete RPC ships yet).
90
90
  */
91
91
  export const soft_delete_test_actor = async (db, actor_id) => query_actor_soft_delete({ db }, actor_id, null);
92
+ /**
93
+ * Insert an `auth_session` row expiring `expires_in_seconds` after the
94
+ * database's `NOW()` — negative for a session already expired. For tests
95
+ * that need a session of a given lifetime, past or future, which
96
+ * `query_create_session` (always a full `AUTH_SESSION_LIFETIME_MS`) can't
97
+ * write. The same statement as the Rust `_testing_mint_session`.
98
+ *
99
+ * @param db - the database
100
+ * @param token_hash - the session's id, the token's hash (`hash_session_token`)
101
+ * @param account_id - the account the session belongs to
102
+ * @param expires_in_seconds - the expiry's offset from `NOW()`, in seconds
103
+ * @mutates `db` — inserts one `auth_session` row
104
+ */
105
+ export const create_test_session_row = async (db, token_hash, account_id, expires_in_seconds) => {
106
+ await db.query(`INSERT INTO auth_session (id, account_id, expires_at)
107
+ VALUES ($1, $2, NOW() + ($3::double precision * INTERVAL '1 second'))`, [token_hash, account_id, expires_in_seconds]);
108
+ };