@fuzdev/fuz_app 0.182.0 → 0.184.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 (295) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +535 -1223
  3. package/dist/actions/action_codegen.d.ts +1 -1
  4. package/dist/actions/action_codegen.d.ts.map +1 -1
  5. package/dist/actions/action_codegen.js +3 -2
  6. package/dist/actions/connection_closer.d.ts +11 -9
  7. package/dist/actions/connection_closer.d.ts.map +1 -1
  8. package/dist/actions/connection_closer.js +11 -9
  9. package/dist/actions/frontend_rpc_client.d.ts +1 -1
  10. package/dist/actions/register_action_ws.d.ts +14 -1
  11. package/dist/actions/register_action_ws.d.ts.map +1 -1
  12. package/dist/actions/register_action_ws.js +2 -1
  13. package/dist/actions/ws_socket_session.d.ts +9 -1
  14. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  15. package/dist/actions/ws_socket_session.js +43 -19
  16. package/dist/auth/CLAUDE.md +430 -1024
  17. package/dist/auth/account_queries.d.ts +1 -1
  18. package/dist/auth/account_queries.js +1 -1
  19. package/dist/auth/account_routes.d.ts +9 -8
  20. package/dist/auth/account_routes.d.ts.map +1 -1
  21. package/dist/auth/account_routes.js +78 -75
  22. package/dist/auth/admin_actions.d.ts.map +1 -1
  23. package/dist/auth/admin_actions.js +32 -28
  24. package/dist/auth/api_token.d.ts +20 -3
  25. package/dist/auth/api_token.d.ts.map +1 -1
  26. package/dist/auth/api_token.js +28 -9
  27. package/dist/auth/api_token_queries.d.ts +2 -2
  28. package/dist/auth/api_token_queries.js +2 -2
  29. package/dist/auth/audit_emitter.d.ts +75 -84
  30. package/dist/auth/audit_emitter.d.ts.map +1 -1
  31. package/dist/auth/audit_emitter.js +83 -71
  32. package/dist/auth/audit_log_schema.d.ts +25 -14
  33. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  34. package/dist/auth/audit_log_schema.js +23 -8
  35. package/dist/auth/auth_guard_resolver.d.ts +1 -1
  36. package/dist/auth/auth_guard_resolver.js +1 -1
  37. package/dist/auth/bearer_auth.d.ts +2 -5
  38. package/dist/auth/bearer_auth.d.ts.map +1 -1
  39. package/dist/auth/bearer_auth.js +4 -13
  40. package/dist/auth/bootstrap_account.d.ts +42 -26
  41. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  42. package/dist/auth/bootstrap_account.js +36 -19
  43. package/dist/auth/bootstrap_routes.d.ts +20 -21
  44. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_routes.js +26 -31
  46. package/dist/auth/bootstrap_token_store.d.ts +3 -4
  47. package/dist/auth/bootstrap_token_store.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_token_store.js +1 -1
  49. package/dist/auth/daemon_token.d.ts +5 -1
  50. package/dist/auth/daemon_token.d.ts.map +1 -1
  51. package/dist/auth/daemon_token_middleware.d.ts +12 -8
  52. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  53. package/dist/auth/daemon_token_middleware.js +15 -21
  54. package/dist/auth/deps.d.ts +19 -5
  55. package/dist/auth/deps.d.ts.map +1 -1
  56. package/dist/auth/deps.js +3 -2
  57. package/dist/auth/invite_queries.d.ts +51 -3
  58. package/dist/auth/invite_queries.d.ts.map +1 -1
  59. package/dist/auth/invite_queries.js +81 -6
  60. package/dist/auth/invite_schema.d.ts +2 -1
  61. package/dist/auth/invite_schema.d.ts.map +1 -1
  62. package/dist/auth/middleware.d.ts +2 -3
  63. package/dist/auth/middleware.d.ts.map +1 -1
  64. package/dist/auth/middleware.js +3 -3
  65. package/dist/auth/request_context.d.ts +3 -3
  66. package/dist/auth/request_context.js +3 -3
  67. package/dist/auth/resolved_auth.d.ts +7 -7
  68. package/dist/auth/resolved_auth.d.ts.map +1 -1
  69. package/dist/auth/resolved_auth.js +4 -4
  70. package/dist/auth/role_grant_offer_actions.d.ts +27 -3
  71. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  72. package/dist/auth/role_grant_offer_actions.js +42 -35
  73. package/dist/auth/role_grant_offer_queries.d.ts +60 -4
  74. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  75. package/dist/auth/role_grant_offer_queries.js +79 -5
  76. package/dist/auth/role_grant_queries.d.ts +3 -52
  77. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  78. package/dist/auth/role_grant_queries.js +5 -80
  79. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  80. package/dist/auth/self_service_role_actions.js +11 -22
  81. package/dist/auth/session_cookie.d.ts +82 -174
  82. package/dist/auth/session_cookie.d.ts.map +1 -1
  83. package/dist/auth/session_cookie.js +80 -130
  84. package/dist/auth/session_middleware.d.ts +8 -17
  85. package/dist/auth/session_middleware.d.ts.map +1 -1
  86. package/dist/auth/session_middleware.js +14 -23
  87. package/dist/auth/session_queries.d.ts +15 -17
  88. package/dist/auth/session_queries.d.ts.map +1 -1
  89. package/dist/auth/session_queries.js +28 -20
  90. package/dist/auth/signup_routes.d.ts.map +1 -1
  91. package/dist/auth/signup_routes.js +93 -43
  92. package/dist/db/CLAUDE.md +5 -3
  93. package/dist/db/sql_columns.d.ts +1 -1
  94. package/dist/db/sql_columns.js +1 -1
  95. package/dist/dev/setup.d.ts +3 -1
  96. package/dist/dev/setup.d.ts.map +1 -1
  97. package/dist/dev/setup.js +3 -1
  98. package/dist/http/CLAUDE.md +315 -763
  99. package/dist/http/db_routes.d.ts +8 -23
  100. package/dist/http/db_routes.d.ts.map +1 -1
  101. package/dist/http/db_routes.js +73 -73
  102. package/dist/http/origin.d.ts +7 -8
  103. package/dist/http/origin.d.ts.map +1 -1
  104. package/dist/http/origin.js +7 -8
  105. package/dist/http/pending_effects.d.ts +118 -6
  106. package/dist/http/pending_effects.d.ts.map +1 -1
  107. package/dist/http/pending_effects.js +114 -6
  108. package/dist/http/route_result.d.ts +1 -1
  109. package/dist/http/route_spec.d.ts +14 -11
  110. package/dist/http/route_spec.d.ts.map +1 -1
  111. package/dist/realtime/sse.d.ts +4 -23
  112. package/dist/realtime/sse.d.ts.map +1 -1
  113. package/dist/realtime/sse.js +4 -25
  114. package/dist/server/app_backend.d.ts +4 -5
  115. package/dist/server/app_backend.d.ts.map +1 -1
  116. package/dist/server/app_backend.js +3 -1
  117. package/dist/server/app_server.d.ts +80 -16
  118. package/dist/server/app_server.d.ts.map +1 -1
  119. package/dist/server/app_server.js +113 -31
  120. package/dist/server/app_server_context.d.ts +1 -2
  121. package/dist/server/app_server_context.d.ts.map +1 -1
  122. package/dist/server/env.js +2 -2
  123. package/dist/testing/CLAUDE.md +265 -796
  124. package/dist/testing/admin_integration.d.ts +2 -3
  125. package/dist/testing/admin_integration.d.ts.map +1 -1
  126. package/dist/testing/admin_integration.js +3 -3
  127. package/dist/testing/adversarial_404.d.ts +6 -1
  128. package/dist/testing/adversarial_404.d.ts.map +1 -1
  129. package/dist/testing/adversarial_404.js +38 -17
  130. package/dist/testing/app_server.d.ts +23 -148
  131. package/dist/testing/app_server.d.ts.map +1 -1
  132. package/dist/testing/app_server.js +53 -131
  133. package/dist/testing/attack_surface.d.ts +1 -1
  134. package/dist/testing/attack_surface.d.ts.map +1 -1
  135. package/dist/testing/audit_completeness.d.ts +2 -3
  136. package/dist/testing/audit_completeness.d.ts.map +1 -1
  137. package/dist/testing/audit_completeness.js +1 -1
  138. package/dist/testing/audit_drift_guard.d.ts +11 -6
  139. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  140. package/dist/testing/audit_drift_guard.js +15 -8
  141. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  142. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  143. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  144. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  145. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  146. package/dist/testing/cross_backend/capabilities.js +11 -7
  147. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  148. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  149. package/dist/testing/cross_backend/capability_mounts.js +428 -0
  150. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  151. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  152. package/dist/testing/cross_backend/cell_relations.js +12 -11
  153. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  154. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  155. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  156. package/dist/testing/cross_backend/conformance_table.d.ts +7 -56
  157. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  158. package/dist/testing/cross_backend/conformance_table.js +6 -274
  159. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  160. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  161. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  162. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  163. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  164. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  165. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  166. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  167. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  168. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  169. package/dist/testing/cross_backend/declared_skips.js +132 -0
  170. package/dist/testing/cross_backend/default_backend_configs.d.ts +3 -3
  171. package/dist/testing/cross_backend/default_spine_surface.d.ts +0 -6
  172. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  173. package/dist/testing/cross_backend/default_spine_surface.js +4 -9
  174. package/dist/testing/cross_backend/differential.d.ts +13 -5
  175. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  176. package/dist/testing/cross_backend/differential.js +35 -11
  177. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  178. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  179. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  180. package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -42
  181. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  182. package/dist/testing/cross_backend/full_spine_mount.js +45 -4
  183. package/dist/testing/cross_backend/in_process_setup.d.ts +28 -19
  184. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  185. package/dist/testing/cross_backend/in_process_setup.js +156 -142
  186. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  187. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  188. package/dist/testing/cross_backend/login_security.js +21 -4
  189. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  190. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  191. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  192. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  193. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  194. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  195. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  196. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  198. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  199. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  200. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  201. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -4
  202. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  203. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +2 -2
  204. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  205. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  206. package/dist/testing/cross_backend/session_cap.js +22 -11
  207. package/dist/testing/cross_backend/setup.d.ts +32 -2
  208. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  209. package/dist/testing/cross_backend/setup.js +32 -1
  210. package/dist/testing/cross_backend/spine_suites.d.ts +125 -15
  211. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  212. package/dist/testing/cross_backend/spine_suites.js +459 -62
  213. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  214. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  215. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  216. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  217. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  218. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  219. package/dist/testing/cross_backend/standard.d.ts +2 -3
  220. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  221. package/dist/testing/cross_backend/standard.js +3 -3
  222. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  224. package/dist/testing/cross_backend/testing_credential_read.d.ts +10 -11
  225. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -1
  226. package/dist/testing/cross_backend/testing_credential_read.js +12 -12
  227. package/dist/testing/cross_backend/testing_reset_actions.d.ts +84 -47
  228. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  229. package/dist/testing/cross_backend/testing_reset_actions.js +95 -63
  230. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  231. package/dist/testing/cross_backend/testing_server_core.js +2 -3
  232. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  233. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  234. package/dist/testing/cross_backend/transport_composition.js +7 -3
  235. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  236. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  237. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  238. package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
  239. package/dist/testing/daemon_token_rotation.js +2 -3
  240. package/dist/testing/data_exposure.d.ts.map +1 -1
  241. package/dist/testing/data_exposure.js +3 -0
  242. package/dist/testing/db.d.ts +0 -32
  243. package/dist/testing/db.d.ts.map +1 -1
  244. package/dist/testing/db.js +0 -86
  245. package/dist/testing/db_entities.d.ts +14 -0
  246. package/dist/testing/db_entities.d.ts.map +1 -1
  247. package/dist/testing/db_entities.js +17 -0
  248. package/dist/testing/db_invariant_queries.d.ts +259 -0
  249. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  250. package/dist/testing/db_invariant_queries.js +400 -0
  251. package/dist/testing/db_invariants.d.ts +106 -0
  252. package/dist/testing/db_invariants.d.ts.map +1 -0
  253. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  254. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  255. package/dist/testing/db_invariants.gen.sql.js +13 -0
  256. package/dist/testing/db_invariants.js +141 -0
  257. package/dist/testing/db_invariants.sql +152 -0
  258. package/dist/testing/describe_db.d.ts +36 -0
  259. package/dist/testing/describe_db.d.ts.map +1 -0
  260. package/dist/testing/describe_db.js +71 -0
  261. package/dist/testing/integration.d.ts +8 -12
  262. package/dist/testing/integration.d.ts.map +1 -1
  263. package/dist/testing/integration.js +13 -17
  264. package/dist/testing/integration_helpers.d.ts +1 -1
  265. package/dist/testing/integration_helpers.d.ts.map +1 -1
  266. package/dist/testing/rate_limiting.d.ts +3 -4
  267. package/dist/testing/rate_limiting.d.ts.map +1 -1
  268. package/dist/testing/rate_limiting.js +6 -5
  269. package/dist/testing/role_grant_helpers.d.ts +1 -1
  270. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  271. package/dist/testing/round_trip.d.ts.map +1 -1
  272. package/dist/testing/round_trip.js +3 -0
  273. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  274. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  275. package/dist/testing/rpc_attack_surface.js +69 -6
  276. package/dist/testing/rpc_helpers.d.ts +1 -2
  277. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  278. package/dist/testing/rpc_helpers.js +3 -3
  279. package/dist/testing/rpc_round_trip.d.ts +3 -4
  280. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  281. package/dist/testing/rpc_round_trip.js +4 -1
  282. package/dist/testing/sse_round_trip.d.ts +3 -4
  283. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  284. package/dist/testing/sse_round_trip.js +15 -6
  285. package/dist/testing/stubs.d.ts +9 -8
  286. package/dist/testing/stubs.d.ts.map +1 -1
  287. package/dist/testing/stubs.js +20 -13
  288. package/dist/testing/test_app.d.ts +168 -0
  289. package/dist/testing/test_app.d.ts.map +1 -0
  290. package/dist/testing/test_app.js +123 -0
  291. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  292. package/dist/testing/ws_round_trip.js +3 -0
  293. package/dist/ui/ui_format.d.ts.map +1 -1
  294. package/dist/ui/ui_format.js +1 -2
  295. package/package.json +1 -1
@@ -0,0 +1,400 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * Database invariants of the auth schema — states no sequence of spine
4
+ * operations may leave behind, checked over the rows themselves.
5
+ *
6
+ * A wire-level test asserts what one request answers; these hold the
7
+ * database a whole test leaves, so a cascade that misses a row (a session
8
+ * outliving its account's tombstone, an offer still pending from a deleted
9
+ * grantor) fails even when no request ever reads the row. One SQL set serves
10
+ * both spines: schema parity keeps their DDL identical.
11
+ *
12
+ * Two kinds:
13
+ *
14
+ * - **State** — over the live rows: no credential of a tombstoned account, no
15
+ * pending offer or unclaimed invite with a dead party, a bootstrapped
16
+ * database keeps a live keeper and a live admin and an unbootstrapped one
17
+ * has no account, an actor's tombstone agrees with its account's, and the
18
+ * structural pairings the writes keep.
19
+ * - **History** — over `audit_log`, so an undelete can't hide a cascade that
20
+ * missed: no pending offer, unclaimed invite or live credential that a
21
+ * successful removal of its account should have ended.
22
+ *
23
+ * An invite's issuer is its `created_by` actor's account, or — once a purge's
24
+ * cascade has nulled `created_by` — the `account_id` of the invite's
25
+ * successful `invite_create` audit row (`metadata.invite_id`; both spines
26
+ * write it). `account_purge` counts as a removal only for invites: a purge's
27
+ * cascade deletes the account's offers, sessions and tokens with it, so for
28
+ * those a purge leaves nothing to check.
29
+ *
30
+ * **Order against a removal.** Where both spines audit the row's creation
31
+ * (`role_grant_offer_create` with `metadata.offer_id`, `invite_create` with
32
+ * `metadata.invite_id`, `token_create` with `metadata.token_id`), the
33
+ * removal's audit `seq` is compared with the creation row's — exact, whatever
34
+ * the clocks: the creation row is written under the account lock the removal
35
+ * takes, in the creating transaction. Otherwise (sessions, and rows written
36
+ * without the action, as the in-process fixture writes them) the timestamps
37
+ * are compared, and a removal in the same clock tick as the creation counts as
38
+ * after it: the database clock may tick in milliseconds (pglet), and a
39
+ * creation tied with the removal that should have ended it is the leak the
40
+ * check exists for, while the opposite order — a removal, an undelete, and a
41
+ * fresh creation in one tick — is not a sequence the tests drive.
42
+ *
43
+ * **The long-transaction walk.** A timestamp is its transaction's start
44
+ * (`created_at` defaults to `NOW()`), not when the row was written, so a
45
+ * timestamp comparison misflags one legal sequence: a login's transaction
46
+ * begins, a delete and then an undelete of its account commit, and only then
47
+ * does the login take the account lock, find the account live, and insert —
48
+ * a session minted after the undelete, its `created_at` before the delete.
49
+ * Nothing drives it: the login must stall between its transaction's start and
50
+ * the account lock while two admin actions commit, which only a test stalling
51
+ * the login's connection between its `BEGIN` and its lock statement could
52
+ * arrange, on Postgres, and none does. Sessions keep this false positive:
53
+ * their creation is audited by `login` (or `signup`, `bootstrap`), whose rows
54
+ * carry no `session_id` to order by, and adding one would change an audit
55
+ * shape on both spines — not taken. An API token minted by
56
+ * `account_token_create` is ordered by its `token_create` row, so the walk
57
+ * can't misflag one — nor could it reach one: that mint re-reads its
58
+ * authorizing session under the account lock, and a delete revokes every
59
+ * session. A token minted without that row (a fixture, a consumer's own mint)
60
+ * falls back to `created_at`.
61
+ *
62
+ * Not invariants, by design: the role grants of a tombstoned actor (kept
63
+ * through delete and undelete, inert while no credential authenticates) and
64
+ * expired credentials no sweep has removed.
65
+ *
66
+ * The whole set is one statement, `DB_INVARIANTS_SQL`, binding the role names
67
+ * as `$1` (keeper) and `$2` (admin). `db_invariants.gen.sql.ts` writes it to
68
+ * `db_invariants.sql`, which the Rust spine's `fuz_testing` embeds byte for
69
+ * byte: the `_testing_db_invariants` backdoor runs it on either spine, so a
70
+ * cross-process harness checks a database it can't reach. Each violation
71
+ * comes back as its invariant's name and the row as JSON text
72
+ * (`jsonb_build_object(...)::text`), parsed on the reading side; exclusions
73
+ * filter the parsed rows (`to_db_invariant_violations`).
74
+ *
75
+ * Vitest-free, so a test binary can mount the backdoor; the per-test hooks
76
+ * live in `db_invariants.ts`.
77
+ *
78
+ * @module
79
+ */
80
+ import { array, object, record, string, unknown } from '@fuzdev/fuz_schema/schema.ts';
81
+ import { offer_pending_predicate, role_grant_active_sql } from '../auth/role_grant_sql.js';
82
+ import { ROLE_ADMIN, ROLE_KEEPER } from '../auth/role_schema.js';
83
+ /**
84
+ * The CTEs every invariant may read, heading `DB_INVARIANTS_SQL`.
85
+ * `role_param` binds and types the role parameters (`$1` keeper, `$2` admin)
86
+ * in one place — an invariant reads them from it, never as `$n`.
87
+ */
88
+ const SHARED_CTES_SQL = `
89
+ role_param AS (SELECT $1::text AS keeper, $2::text AS admin),
90
+ removal AS (
91
+ SELECT target_account_id AS account_id, event_type, seq, created_at
92
+ FROM audit_log
93
+ WHERE outcome = 'success'
94
+ AND event_type IN ('account_delete', 'account_purge')
95
+ AND target_account_id IS NOT NULL
96
+ ),
97
+ offer_party AS (
98
+ SELECT o.id, o.from_actor_id, fa.account_id AS from_account_id, o.to_account_id,
99
+ o.to_actor_id, o.created_at,
100
+ (SELECT MIN(al.seq) FROM audit_log al
101
+ WHERE al.event_type = 'role_grant_offer_create' AND al.outcome = 'success'
102
+ AND al.metadata->>'offer_id' = o.id::text) AS create_seq
103
+ FROM role_grant_offer o
104
+ JOIN actor fa ON fa.id = o.from_actor_id
105
+ WHERE ${offer_pending_predicate('o')}
106
+ ),
107
+ invite_issuer AS (
108
+ SELECT i.id, i.created_by, i.created_at, a.deleted_at IS NOT NULL AS actor_dead,
109
+ COALESCE(a.account_id, (SELECT al.account_id FROM audit_log al
110
+ WHERE al.event_type = 'invite_create' AND al.outcome = 'success'
111
+ AND al.metadata->>'invite_id' = i.id::text
112
+ ORDER BY al.seq LIMIT 1)) AS issuer_account_id,
113
+ (SELECT MIN(al.seq) FROM audit_log al
114
+ WHERE al.event_type = 'invite_create' AND al.outcome = 'success'
115
+ AND al.metadata->>'invite_id' = i.id::text) AS create_seq
116
+ FROM invite i
117
+ LEFT JOIN actor a ON a.id = i.created_by
118
+ WHERE i.claimed_at IS NULL
119
+ ),
120
+ token_issued AS (
121
+ SELECT t.id, t.account_id, t.created_at,
122
+ (SELECT MIN(al.seq) FROM audit_log al
123
+ WHERE al.event_type = 'token_create' AND al.outcome = 'success'
124
+ AND al.metadata->>'token_id' = t.id) AS create_seq
125
+ FROM api_token t
126
+ )`;
127
+ /**
128
+ * A `removal` row of `account_sql`, of one of `events`, after the row created
129
+ * at `created_at_sql` (with audit creation `seq` `create_seq_sql`, or null) —
130
+ * see the module doc for the order.
131
+ */
132
+ const removed_after_sql = (account_sql, created_at_sql, create_seq_sql, events) => `EXISTS (
133
+ SELECT 1 FROM removal r
134
+ WHERE r.account_id = ${account_sql}
135
+ AND r.event_type IN (${events.map((e) => `'${e}'`).join(', ')})
136
+ AND ${create_seq_sql === null
137
+ ? `r.created_at >= ${created_at_sql}`
138
+ : `CASE WHEN ${create_seq_sql} IS NULL THEN r.created_at >= ${created_at_sql}
139
+ ELSE r.seq > ${create_seq_sql} END`}
140
+ )`;
141
+ /** A live actor of a live account holding an active global grant of `role_param`'s `column`. */
142
+ const live_global_holder_sql = (column) => `EXISTS (
143
+ SELECT 1 FROM role_grant rg
144
+ JOIN actor a ON a.id = rg.actor_id
145
+ JOIN account ac ON ac.id = a.account_id
146
+ WHERE rg.role = (SELECT ${column} FROM role_param)
147
+ AND rg.scope_id IS NULL
148
+ AND ${role_grant_active_sql('rg')}
149
+ AND a.deleted_at IS NULL
150
+ AND ac.deleted_at IS NULL
151
+ )`;
152
+ /**
153
+ * Every invariant, in report order. State invariants first, then the history
154
+ * ones over `audit_log`.
155
+ */
156
+ export const DB_INVARIANTS = [
157
+ {
158
+ name: 'credential_of_tombstoned_account',
159
+ columns: ['kind', 'id', 'account_id'],
160
+ description: 'no session or API token belongs to a tombstoned account',
161
+ sql: `SELECT 'auth_session' AS kind, LEFT(s.id, 12) AS id, s.account_id
162
+ FROM auth_session s JOIN account ac ON ac.id = s.account_id
163
+ WHERE ac.deleted_at IS NOT NULL
164
+ UNION ALL
165
+ SELECT 'api_token' AS kind, t.id, t.account_id
166
+ FROM api_token t JOIN account ac ON ac.id = t.account_id
167
+ WHERE ac.deleted_at IS NOT NULL`
168
+ },
169
+ {
170
+ name: 'pending_offer_with_dead_party',
171
+ columns: [
172
+ 'id',
173
+ 'from_actor_id',
174
+ 'from_account_id',
175
+ 'to_account_id',
176
+ 'to_actor_id',
177
+ 'from_actor_dead',
178
+ 'from_account_dead',
179
+ 'to_account_dead',
180
+ 'to_actor_dead'
181
+ ],
182
+ description: 'no pending role grant offer has a tombstoned grantor actor, grantor account, recipient account, or recipient actor',
183
+ sql: `SELECT op.id, op.from_actor_id, op.from_account_id, op.to_account_id, op.to_actor_id,
184
+ fa.deleted_at IS NOT NULL AS from_actor_dead,
185
+ fac.deleted_at IS NOT NULL AS from_account_dead,
186
+ ta.deleted_at IS NOT NULL AS to_account_dead,
187
+ COALESCE(tac.deleted_at IS NOT NULL, false) AS to_actor_dead
188
+ FROM offer_party op
189
+ JOIN actor fa ON fa.id = op.from_actor_id
190
+ JOIN account fac ON fac.id = op.from_account_id
191
+ JOIN account ta ON ta.id = op.to_account_id
192
+ LEFT JOIN actor tac ON tac.id = op.to_actor_id
193
+ WHERE fa.deleted_at IS NOT NULL OR fac.deleted_at IS NOT NULL
194
+ OR ta.deleted_at IS NOT NULL OR tac.deleted_at IS NOT NULL`
195
+ },
196
+ {
197
+ name: 'unclaimed_invite_of_dead_issuer',
198
+ columns: ['id', 'created_by', 'issuer_account_id', 'actor_dead', 'issuer_purged'],
199
+ description: 'no unclaimed invite was issued by a tombstoned actor, or by an account tombstoned or purged',
200
+ sql: `SELECT ii.id, ii.created_by, ii.issuer_account_id,
201
+ ii.actor_dead, ac.id IS NULL AS issuer_purged
202
+ FROM invite_issuer ii
203
+ LEFT JOIN account ac ON ac.id = ii.issuer_account_id
204
+ WHERE ii.issuer_account_id IS NOT NULL
205
+ AND (ii.actor_dead OR ac.id IS NULL OR ac.deleted_at IS NOT NULL)`
206
+ },
207
+ {
208
+ name: 'bootstrapped_without_live_keeper',
209
+ columns: ['bootstrapped'],
210
+ description: 'a bootstrapped database keeps a live actor of a live account holding an active global keeper grant — the keeper is never removable',
211
+ sql: `SELECT true AS bootstrapped FROM bootstrap_lock
212
+ WHERE bootstrapped AND NOT ${live_global_holder_sql('keeper')}`
213
+ },
214
+ {
215
+ name: 'bootstrapped_without_live_admin',
216
+ columns: ['bootstrapped'],
217
+ description: 'a bootstrapped database keeps a live actor of a live account holding an active global admin grant — bootstrap grants one and the last-admin guard keeps one',
218
+ sql: `SELECT true AS bootstrapped FROM bootstrap_lock
219
+ WHERE bootstrapped AND NOT ${live_global_holder_sql('admin')}`
220
+ },
221
+ {
222
+ name: 'account_without_bootstrap',
223
+ columns: ['account_id'],
224
+ description: 'an unbootstrapped database has no account — the bootstrap that writes the first one flips the lock in its transaction',
225
+ sql: `SELECT ac.id AS account_id FROM account ac
226
+ WHERE NOT EXISTS (SELECT 1 FROM bootstrap_lock WHERE bootstrapped)`
227
+ },
228
+ {
229
+ name: 'actor_tombstone_disagrees_with_account',
230
+ columns: ['actor_id', 'account_id', 'actor_dead', 'account_dead'],
231
+ description: 'an actor is tombstoned exactly when its account is — no wire path deletes one actor',
232
+ sql: `SELECT a.id AS actor_id, a.account_id,
233
+ a.deleted_at IS NOT NULL AS actor_dead, ac.deleted_at IS NOT NULL AS account_dead
234
+ FROM actor a JOIN account ac ON ac.id = a.account_id
235
+ WHERE (a.deleted_at IS NULL) <> (ac.deleted_at IS NULL)`
236
+ },
237
+ {
238
+ name: 'offer_to_actor_outside_to_account',
239
+ columns: ['id', 'to_account_id', 'to_actor_id', 'to_actor_account_id'],
240
+ description: "an offer's recipient actor belongs to its recipient account",
241
+ sql: `SELECT o.id, o.to_account_id, o.to_actor_id, a.account_id AS to_actor_account_id
242
+ FROM role_grant_offer o JOIN actor a ON a.id = o.to_actor_id
243
+ WHERE a.account_id <> o.to_account_id`
244
+ },
245
+ {
246
+ name: 'invite_claimed_by_without_claimed_at',
247
+ columns: ['id', 'claimed_by'],
248
+ description: 'an invite naming its claimant records when it was claimed',
249
+ sql: `SELECT i.id, i.claimed_by FROM invite i
250
+ WHERE i.claimed_by IS NOT NULL AND i.claimed_at IS NULL`
251
+ },
252
+ {
253
+ name: 'pending_offer_outlived_party_removal',
254
+ columns: ['id', 'from_actor_id', 'from_account_id', 'to_account_id'],
255
+ description: 'no pending offer is older than a successful delete of its grantor or recipient account',
256
+ sql: `SELECT op.id, op.from_actor_id, op.from_account_id, op.to_account_id
257
+ FROM offer_party op
258
+ WHERE ${removed_after_sql('op.from_account_id', 'op.created_at', 'op.create_seq', ['account_delete'])}
259
+ OR ${removed_after_sql('op.to_account_id', 'op.created_at', 'op.create_seq', ['account_delete'])}`
260
+ },
261
+ {
262
+ name: 'unclaimed_invite_outlived_issuer_removal',
263
+ columns: ['id', 'created_by', 'issuer_account_id'],
264
+ description: 'no unclaimed invite is older than a successful delete or purge of its issuer account',
265
+ sql: `SELECT ii.id, ii.created_by, ii.issuer_account_id
266
+ FROM invite_issuer ii
267
+ WHERE ${removed_after_sql('ii.issuer_account_id', 'ii.created_at', 'ii.create_seq', [
268
+ 'account_delete',
269
+ 'account_purge'
270
+ ])}`
271
+ },
272
+ // A token is ordered by its `token_create` row's `seq`, a session by its
273
+ // `created_at` — which misflags a login whose transaction began before a
274
+ // delete and an undelete it then waited out; the module doc's
275
+ // long-transaction walk says why that is legal, undriven, and kept.
276
+ {
277
+ name: 'credential_outlived_account_removal',
278
+ columns: ['kind', 'id', 'account_id'],
279
+ description: 'no session or API token was created before a successful delete of its account',
280
+ sql: `SELECT 'auth_session' AS kind, LEFT(s.id, 12) AS id, s.account_id
281
+ FROM auth_session s
282
+ WHERE ${removed_after_sql('s.account_id', 's.created_at', null, ['account_delete'])}
283
+ UNION ALL
284
+ SELECT 'api_token' AS kind, ti.id, ti.account_id
285
+ FROM token_issued ti
286
+ WHERE ${removed_after_sql('ti.account_id', 'ti.created_at', 'ti.create_seq', ['account_delete'])}`
287
+ }
288
+ ];
289
+ /** The `DbInvariantExclusions` key that excludes every invariant. */
290
+ export const DB_INVARIANTS_EXCLUDE_ALL = 'all';
291
+ /**
292
+ * Refuse an exclusion naming no invariant or carrying no reason.
293
+ *
294
+ * @param exclude - the exclusions to check
295
+ * @param label - names the caller in the error
296
+ * @throws Error naming the first unknown invariant or empty reason, or a
297
+ * named invariant beside `all`, which already excludes it
298
+ */
299
+ export const validate_db_invariant_exclusions = (exclude, label) => {
300
+ if (!exclude)
301
+ return;
302
+ const names = new Set([DB_INVARIANTS_EXCLUDE_ALL, ...DB_INVARIANTS.map((i) => i.name)]);
303
+ if (exclude[DB_INVARIANTS_EXCLUDE_ALL] !== undefined && Object.keys(exclude).length > 1) {
304
+ const named = Object.keys(exclude).filter((name) => name !== DB_INVARIANTS_EXCLUDE_ALL);
305
+ throw new Error(`${label}: exclude_db_invariants '${named[0]}' is redundant — '${DB_INVARIANTS_EXCLUDE_ALL}' excludes every invariant`);
306
+ }
307
+ for (const [name, reason] of Object.entries(exclude)) {
308
+ if (!names.has(name)) {
309
+ throw new Error(`${label}: exclude_db_invariants names unknown invariant '${name}'`);
310
+ }
311
+ if (typeof reason !== 'string' || reason.trim() === '') {
312
+ throw new Error(`${label}: exclude_db_invariants '${name}' needs a reason`);
313
+ }
314
+ }
315
+ };
316
+ /**
317
+ * Every invariant in one statement, `$1` the keeper role and `$2` the admin
318
+ * role: one `{invariant, row}` per violating row, `row` its columns as JSON
319
+ * text. What `db_invariants.sql` holds, and what `_testing_db_invariants` runs
320
+ * on both spines.
321
+ */
322
+ export const DB_INVARIANTS_SQL = `WITH${SHARED_CTES_SQL}
323
+ ${DB_INVARIANTS.map((invariant) => `SELECT '${invariant.name}' AS invariant, jsonb_build_object(${invariant.columns
324
+ .map((c) => `'${c}', v.${c}`)
325
+ .join(', ')})::text AS row FROM (${invariant.sql}) v`).join('\nUNION ALL\n')}`;
326
+ /** One violating row: its invariant's name and its columns. */
327
+ export const DbInvariantRow = object({
328
+ invariant: string,
329
+ row: record(unknown)
330
+ });
331
+ /** What `_testing_db_invariants` answers — every violating row, unfiltered. */
332
+ export const DbInvariantRows = object({
333
+ rows: array(DbInvariantRow)
334
+ });
335
+ /**
336
+ * Run `DB_INVARIANTS_SQL`, parsing each row's JSON text.
337
+ *
338
+ * @param deps - the database to read
339
+ * @returns every violating row, in no promised order
340
+ */
341
+ export const query_db_invariant_rows = async (deps) => {
342
+ const rows = await deps.db.query(DB_INVARIANTS_SQL, [
343
+ ROLE_KEEPER,
344
+ ROLE_ADMIN
345
+ ]);
346
+ return rows.map((r) => ({
347
+ invariant: r.invariant,
348
+ row: JSON.parse(r.row)
349
+ }));
350
+ };
351
+ /**
352
+ * Group violating rows by invariant, dropping the excluded ones.
353
+ *
354
+ * @param rows - what `query_db_invariant_rows` or `_testing_db_invariants` returned
355
+ * @param exclude - invariants to skip, each with its reason
356
+ * @returns one entry per broken invariant, in `DB_INVARIANTS` order; empty when all hold
357
+ * @throws Error on a row naming no invariant (a reader out of step with the statement)
358
+ */
359
+ export const to_db_invariant_violations = (rows, exclude) => {
360
+ const names = new Set(DB_INVARIANTS.map((i) => i.name));
361
+ for (const r of rows) {
362
+ if (!names.has(r.invariant)) {
363
+ throw new Error(`database invariant row names unknown invariant '${r.invariant}'`);
364
+ }
365
+ }
366
+ if (exclude?.[DB_INVARIANTS_EXCLUDE_ALL] !== undefined)
367
+ return [];
368
+ const violations = [];
369
+ for (const invariant of DB_INVARIANTS) {
370
+ if (exclude?.[invariant.name] !== undefined)
371
+ continue;
372
+ const broken = rows.filter((r) => r.invariant === invariant.name).map((r) => r.row);
373
+ if (broken.length > 0) {
374
+ violations.push({ name: invariant.name, description: invariant.description, rows: broken });
375
+ }
376
+ }
377
+ return violations;
378
+ };
379
+ /**
380
+ * Query every invariant not excluded, returning those with violating rows.
381
+ *
382
+ * @param deps - the database to read
383
+ * @param exclude - invariants to skip, each with its reason
384
+ * @returns one entry per broken invariant, in `DB_INVARIANTS` order; empty when all hold
385
+ */
386
+ export const query_db_invariant_violations = async (deps, exclude) => {
387
+ if (exclude?.[DB_INVARIANTS_EXCLUDE_ALL] !== undefined)
388
+ return [];
389
+ return to_db_invariant_violations(await query_db_invariant_rows(deps), exclude);
390
+ };
391
+ /**
392
+ * Render violations as one message, an invariant per paragraph with its rows.
393
+ *
394
+ * @param violations - what `query_db_invariant_violations` returned
395
+ * @param label - names the database (the backend, or the in-process leg)
396
+ */
397
+ export const format_db_invariant_violations = (violations, label) => `database invariants broken (${label}):\n` +
398
+ violations
399
+ .map((v) => `- ${v.name}: ${v.description}\n` + v.rows.map((r) => ` ${JSON.stringify(r)}`).join('\n'))
400
+ .join('\n');
@@ -0,0 +1,106 @@
1
+ import './assert_dev_env.js';
2
+ /**
3
+ * The per-test database invariant check — the hooks `create_test_app` and the
4
+ * cross-process setup register, over the invariants and their statement in
5
+ * `db_invariant_queries.ts`. In-process the check queries the test app's own
6
+ * `Db` (`assert_db_invariants`); cross-process it reads the backend's
7
+ * `_testing_db_invariants` backdoor (`assert_db_invariant_rows`).
8
+ *
9
+ * @module
10
+ */
11
+ import { type RunnerTask } from 'vitest';
12
+ import type { QueryDeps } from '../db/query_deps.js';
13
+ import { type DbInvariantExclusions, type DbInvariantRow } from './db_invariant_queries.js';
14
+ /**
15
+ * Validate a setup's exclusions and log them, one line naming each with its
16
+ * reason, so a run shows what it leaves unchecked. Validates on every call
17
+ * and logs a label's set once per module instance, since a direct
18
+ * `create_test_app` caller builds an app per test. Silent when there are none.
19
+ *
20
+ * @param exclude - the setup's exclusions
21
+ * @param label - names the setup
22
+ * @throws Error on an unknown invariant or an empty reason
23
+ */
24
+ export declare const announce_db_invariant_exclusions: (exclude: DbInvariantExclusions | undefined, label: string) => void;
25
+ /**
26
+ * Throw when any row not excluded breaks an invariant — the check over rows
27
+ * a backend's `_testing_db_invariants` answered.
28
+ *
29
+ * @param rows - every violating row
30
+ * @param label - names the database in the message
31
+ * @param exclude - invariants to skip, each with its reason
32
+ * @throws Error listing every broken invariant and its rows
33
+ */
34
+ export declare const assert_db_invariant_rows: (rows: ReadonlyArray<DbInvariantRow>, label: string, exclude?: DbInvariantExclusions) => void;
35
+ /**
36
+ * Throw when any invariant not excluded is broken.
37
+ *
38
+ * @param deps - the database to read
39
+ * @param label - names the database in the message
40
+ * @param exclude - invariants to skip, each with its reason
41
+ * @throws Error listing every broken invariant and its rows
42
+ */
43
+ export declare const assert_db_invariants: (deps: QueryDeps, label: string, exclude?: DbInvariantExclusions) => Promise<void>;
44
+ /**
45
+ * Run `check` when the current test finishes — the per-test hook
46
+ * `create_test_app` registers when it builds an app (in-process, and so every
47
+ * `default_in_process_setup` fixture) and the cross-process setup registers
48
+ * from `setup_test()`, with `check` the app's or fixture's
49
+ * `assert_db_invariants`.
50
+ *
51
+ * Runs after the test body and its `afterEach` hooks, before the next test's
52
+ * setup resets the database. A test that already failed is left as it
53
+ * failed: its state proves nothing more. Outside a test — an app or fixture built in
54
+ * `beforeAll`, shared by a describe's tests — nothing is registered, and the
55
+ * suite checks the fixture once its tests are done
56
+ * (`check_db_invariants_after_all`).
57
+ *
58
+ * Under `describe.concurrent` the hook attaches to whichever test vitest
59
+ * names current, and two tests' rows share one database, so a violation can
60
+ * fail a sibling of the test that left it; the shipped concurrent suite
61
+ * builds its fixture in `beforeAll` and is checked once after all its tests.
62
+ *
63
+ * @param check - throws on a violation
64
+ * @returns whether a hook was registered — `false` outside a test
65
+ */
66
+ export declare const register_db_invariants_check: (check: () => Promise<void>) => boolean;
67
+ /**
68
+ * Check a describe-scoped fixture's database now, unless a test of `suite`
69
+ * failed or no fixture was built — the body of the suite-level check, for a
70
+ * describe's own `afterAll` that runs it ahead of its cleanup (a
71
+ * `create_test_app` app the describe closes, a database its factory closes):
72
+ *
73
+ * ```ts
74
+ * afterAll(async ({}, suite) => {
75
+ * try {
76
+ * await check_db_invariants_after_suite(suite, test_app);
77
+ * } finally {
78
+ * await test_app.cleanup();
79
+ * }
80
+ * });
81
+ * ```
82
+ *
83
+ * @param suite - the describe's task, the `afterAll` hook's second argument
84
+ * @param fixture - the shared fixture or test app, `null` or `undefined` until built
85
+ * @throws Error listing every broken invariant and its rows
86
+ */
87
+ export declare const check_db_invariants_after_suite: (suite: RunnerTask, fixture: {
88
+ readonly assert_db_invariants: () => Promise<void>;
89
+ } | null | undefined) => Promise<void>;
90
+ /**
91
+ * Check a describe-scoped fixture's database once the describe's tests are
92
+ * done — the suite-level twin of the per-test hook, for a fixture built in
93
+ * `beforeAll` and shared by the describe (the per-describe round-trip and
94
+ * exposure suites), or a `create_test_app` app built there, which registers
95
+ * no per-test hook. Skipped when a test of the describe failed, or when no
96
+ * fixture was built. Call inside the `describe`, at collection. It registers
97
+ * an `afterAll` of its own, so it reads a fixture nothing closes in another
98
+ * `afterAll`; a describe that closes its app or database there calls
99
+ * `check_db_invariants_after_suite` in that hook, ahead of the close.
100
+ *
101
+ * @param get_fixture - the shared fixture, `null` or `undefined` until built
102
+ */
103
+ export declare const check_db_invariants_after_all: (get_fixture: () => {
104
+ readonly assert_db_invariants: () => Promise<void>;
105
+ } | null | undefined) => void;
106
+ //# sourceMappingURL=db_invariants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db_invariants.d.ts","sourceRoot":"","sources":["../../src/lib/testing/db_invariants.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B;;;;;;;;GAQG;AAEH,OAAO,EAAwC,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC;AAE/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAKN,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,MAAM,2BAA2B,CAAC;AAKnC;;;;;;;;;GASG;AACH,eAAO,MAAM,gCAAgC,GAC5C,SAAS,qBAAqB,GAAG,SAAS,EAC1C,OAAO,MAAM,KACX,IAUF,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,wBAAwB,GACpC,MAAM,aAAa,CAAC,cAAc,CAAC,EACnC,OAAO,MAAM,EACb,UAAU,qBAAqB,KAC7B,IAGF,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,SAAS,EACf,OAAO,MAAM,EACb,UAAU,qBAAqB,KAC7B,OAAO,CAAC,IAAI,CAGd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,4BAA4B,GAAI,OAAO,MAAM,OAAO,CAAC,IAAI,CAAC,KAAG,OAOzE,CAAC;AAMF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,+BAA+B,GAC3C,OAAO,UAAU,EACjB,SAAS;IAAE,QAAQ,CAAC,oBAAoB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KAChF,OAAO,CAAC,IAAI,CAGd,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,6BAA6B,GACzC,aAAa,MAAM;IAAE,QAAQ,CAAC,oBAAoB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,GAAG,IAAI,GAAG,SAAS,KAC1F,IAMF,CAAC"}
@@ -0,0 +1,11 @@
1
+ import './assert_dev_env.js';
2
+ import type { Gen } from '@fuzdev/gro/gen.ts';
3
+ /**
4
+ * Writes `db_invariants.sql`, the statement `DB_INVARIANTS_SQL` composes —
5
+ * the copy the Rust spine's `fuz_testing` embeds byte for byte for its
6
+ * `_testing_db_invariants` backdoor.
7
+ *
8
+ * @nodocs
9
+ */
10
+ export declare const gen: Gen;
11
+ //# sourceMappingURL=db_invariants.gen.sql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db_invariants.gen.sql.d.ts","sourceRoot":"","sources":["../../src/lib/testing/db_invariants.gen.sql.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAI9C;;;;;;GAMG;AACH,eAAO,MAAM,GAAG,EAAE,GAGhB,CAAC"}
@@ -0,0 +1,13 @@
1
+ import './assert_dev_env.js';
2
+ import { DB_INVARIANTS_SQL } from './db_invariant_queries.js';
3
+ /**
4
+ * Writes `db_invariants.sql`, the statement `DB_INVARIANTS_SQL` composes —
5
+ * the copy the Rust spine's `fuz_testing` embeds byte for byte for its
6
+ * `_testing_db_invariants` backdoor.
7
+ *
8
+ * @nodocs
9
+ */
10
+ export const gen = ({ origin_path }) => ({
11
+ content: `-- generated by ${origin_path}: the database invariants, $1 the keeper role and $2 the admin role\n${DB_INVARIANTS_SQL}\n`,
12
+ format: false
13
+ });