@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
@@ -12,46 +12,52 @@
12
12
  * These methods cover every fan-out shape the auth domain needs
13
13
  * (`add_listener` and `listener_count` manage the listener chain):
14
14
  *
15
- * - `emit(ctx, input)` — the request-scoped emit. A success row inside a
16
- * request transaction is written in it and the promise rejects when the
17
- * INSERT fails; every other row is a fire-and-forget pool write whose
18
- * in-flight promise goes on `ctx.pending_effects`, and the returned promise
19
- * resolves at once.
15
+ * - `emit(ctx, input)` — the request-scoped emit. A success row is written
16
+ * in the request's transaction and the promise rejects when the INSERT
17
+ * fails — or when no transaction is open; a failure row is a
18
+ * fire-and-forget pool write whose in-flight promise goes on
19
+ * `ctx.pending_effects`, and the returned promise resolves at once.
20
20
  * - `emit_role_grant_target(ctx, auth, input)` — wrapper that lifts the
21
21
  * `actor_id` / `account_id` / `ip` boilerplate every role-grant-shape audit
22
22
  * site repeated. Delegates to `emit`.
23
23
  * - `emit_pool(input)` — awaitable pool write for code paths without a
24
- * request transaction (maintenance scripts, a post-commit thunk). Writes,
25
- * then notifies.
24
+ * request (maintenance scripts). Writes, then notifies.
26
25
  * - `notify(event)` — fan out an already-written audit row (e.g. rows
27
26
  * returned by `query_accept_offer` that were inserted in-transaction by
28
27
  * the query layer, or the offer-expiry rows `auth/cleanup.ts` writes in
29
28
  * its sweep transaction). Runs every registered listener; per-listener
30
29
  * throws are isolated.
31
- * - `drain_inflight()` — test-binary barrier: await every in-flight `emit`
32
- * write, on an emitter built with `track_inflight: true`.
33
- * - `is_tracking_inflight()` — whether that barrier can wait on anything, so a
34
- * test binary built without tracking is caught rather than racing.
30
+ * - `drain_inflight()` — await every pool write in flight: what
31
+ * `AppServer.close` waits on (bounded) before the database closes, and the
32
+ * barrier behind the `_testing_drain_effects` test action.
33
+ * - `inflight_count()` — how many pool writes are in flight now.
35
34
  *
36
35
  * ## Where a row is written
37
36
  *
38
- * The routing reads two things: the row's outcome and whether `ctx.db` is a
39
- * transaction (`Db.in_transaction`).
37
+ * The routing reads the row's outcome, and for a success row whether `ctx.db`
38
+ * is a transaction (`Db.in_transaction`).
40
39
  *
41
- * - A **success** row emitted inside a request transaction (an action with
42
- * `side_effects`, a route with `transaction: true`) is written **in that
43
- * transaction**: the change and the row that reports it commit together or
44
- * not at all. The INSERT is awaited, and a failed one rejects `emit`, so the
45
- * handler throws and its transaction rolls back — a committed change is
46
- * never left unaudited.
40
+ * - A **success** row is written **in the request's transaction** — an action
41
+ * with `side_effects`, a route with `transaction: true`, or the transaction a
42
+ * `transaction: false` route opens around just its writes (`/login`,
43
+ * `/password`, signup, bootstrap, through
44
+ * `http/pending_effects.ts`'s `transaction_with_post_commit_rollback`),
45
+ * last before its commit. The change and the row that reports it commit
46
+ * together or not at all. The INSERT is awaited, and a failed one rejects
47
+ * `emit`, so the handler throws and its transaction rolls back — a
48
+ * committed change is never left unaudited, and a response, once sent, has
49
+ * its row committed. With no transaction open, `emit` refuses a success row
50
+ * by throwing, writing nothing (counted for `install_audit_drift_guard`,
51
+ * `get_audit_success_outside_transaction`).
47
52
  * - A **failure** row is written on the pool, outside the request's
48
53
  * transaction, so it survives the rollback that usually follows it — the
49
- * forensic record of a refused attempt.
50
- * - A success row emitted with no request transaction open (a `GET`, or a
51
- * route that runs `transaction: false` and opens its own around just its
52
- * writes, like `/login` and `/password`, which emit once that transaction
53
- * has committed) is written on the pool too — there is no transaction to
54
- * join.
54
+ * forensic record of a refused attempt. No response waits for it;
55
+ * `AppServer.close` does, bounded (`drain_inflight`).
56
+ *
57
+ * `seq` is a `BIGSERIAL`, taken at INSERT: rows are numbered in INSERT order,
58
+ * not commit order, so a reader paging by `seq` can see a gap fill in when a
59
+ * transaction that inserted earlier commits later. What holds is that a
60
+ * success row is visible exactly when its change is.
55
61
  *
56
62
  * A pool write is fail-open: a failed one is counted
57
63
  * (`get_audit_write_failures`) and logged as one `error` line carrying the
@@ -62,24 +68,18 @@
62
68
  * than a request's, so a pool saturated enough to shed requests with a 503
63
69
  * does not also drop the failure rows recording them.
64
70
  *
65
- * This is the Rust spine's split: `fuz_auth`'s `route_audit_emit` writes an
66
- * action's success row in the request transaction (`emit_in_tx`) and every
67
- * failure row on the pool (`emit`), and its REST handlers (`/login`,
68
- * `/password`, signup, bootstrap) emit on the pool. Two rows differ in
69
- * routing between the twins, visible on the wire only when the audit INSERT
70
- * fails: the TS `/logout` runs in a route transaction, so its success row is
71
- * written in it (Rust writes it on the pool), and `db_admin_row_delete` is
72
- * written on the pool after the commit on both (`http/db_routes.ts`, through
73
- * `emit_pool`).
71
+ * This is the Rust spine's split: `fuz_auth`'s `route_audit_emit` writes a
72
+ * success row in the request transaction (`emit_in_tx`) — its REST handlers'
73
+ * and the db-admin row delete's included — and every failure row on the pool
74
+ * (`emit`).
74
75
  *
75
76
  * ## When listeners hear about a row
76
77
  *
77
78
  * - A **failure** row is announced as soon as it is written. It records an
78
79
  * attempt, which happened whether or not the request's transaction commits.
79
80
  * - A **success** row is announced only after the request's transaction
80
- * commits (after the handler returns, on a route without one), and never
81
- * when the handler throws: the fan-out is queued on
82
- * `ctx.post_commit_effects`. A success row reports a state change, and the
81
+ * commits, and never when it rolls back: the fan-out is queued on
82
+ * `ctx.post_commit_effects`, discarded on a rollback. A success row reports a state change, and the
83
83
  * listeners act on it — the revocation listeners close connections, the
84
84
  * audit stream broadcasts it. Announced before the commit, a close could run
85
85
  * while the revoked credential still reads as valid, and a rolled-back
@@ -108,16 +108,17 @@ import { type AuditLogConfig, type AuditLogEvent, type AuditLogInput } from './a
108
108
  * and its two side-effect queues. The bound emitter carries its own `log`
109
109
  * reference inside the closure, so per-call contexts don't need one.
110
110
  *
111
- * `db` decides where a success row is written: inside the request's
112
- * transaction when `db.in_transaction`, else on the pool (module doc, "Where a
113
- * row is written"). A pool write is eager — the emitter fires it immediately
114
- * and pushes the in-flight `Promise<void>` onto `pending_effects`. A success
115
- * row's listener fan-out goes on `post_commit_effects` (module doc, "When
116
- * listeners hear about a row").
111
+ * `db` is where a success row is written — it must be a transaction
112
+ * (`db.in_transaction`), or `emit` refuses the row (module doc, "Where a row
113
+ * is written"). A failure row's pool write is eager — the emitter fires it
114
+ * immediately and pushes the in-flight `Promise<void>` onto
115
+ * `pending_effects`. A success row's listener fan-out goes on
116
+ * `post_commit_effects` (module doc, "When listeners hear about a row").
117
117
  *
118
118
  * Both `RouteContext` and `ActionContext` structurally satisfy this
119
- * shape, so handlers pass `route` / `ctx` directly. Never pass one from a
120
- * post-commit thunk: its transaction has ended — use `emit_pool` there.
119
+ * shape, so handlers pass `route` / `ctx` directly, and so does the context
120
+ * `transaction_with_post_commit_rollback` hands its callback. Never pass one
121
+ * from a post-commit thunk: its transaction has ended.
121
122
  */
122
123
  export interface AuditEmitterContext extends EmitAfterCommitContext, QueryDeps {
123
124
  pending_effects: Array<Promise<void>>;
@@ -154,10 +155,10 @@ export interface AuditEmitter {
154
155
  * Write an audit row for a request, routed by outcome and `ctx.db` (module
155
156
  * doc, "Where a row is written").
156
157
  *
157
- * A success row inside a request transaction is written in it: the
158
- * promise settles once the INSERT has run, and rejects when it fails, so
159
- * the handler throws and the change rolls back with its row. Any other row
160
- * is a fire-and-forget pool write: its in-flight promise goes on
158
+ * A success row is written in the request's transaction: the promise
159
+ * settles once the INSERT has run, and rejects when it fails — or when
160
+ * `ctx.db` is no transaction — so the handler throws and the change rolls
161
+ * back with its row. A failure row is a fire-and-forget pool write: its in-flight promise goes on
161
162
  * `ctx.pending_effects` (so tests with `await_pending_effects: true` can
162
163
  * assert it inline), its errors are logged and counted, never thrown, and
163
164
  * the returned promise resolves at once.
@@ -172,7 +173,7 @@ export interface AuditEmitter {
172
173
  * @mutates `audit_log` table - inserts the row in `ctx.db`'s transaction or via the captured pool
173
174
  * @mutates `ctx.pending_effects` - appends a pool write's in-flight settled promise
174
175
  * @mutates `ctx.post_commit_effects` - appends a success row's listener fan-out
175
- * @throws Error when an in-transaction INSERT fails
176
+ * @throws Error when an in-transaction INSERT fails, or a success row is emitted with no transaction open
176
177
  */
177
178
  emit<T extends string>(ctx: AuditEmitterContext, input: AuditLogInput<T>): Promise<void>;
178
179
  /**
@@ -185,9 +186,8 @@ export interface AuditEmitter {
185
186
  */
186
187
  emit_role_grant_target<T extends string>(ctx: AuditEmitRoleGrantContext, auth: RequestActorContext, input: AuditEmitRoleGrantInput<T>): Promise<void>;
187
188
  /**
188
- * Awaitable pool write for code paths without a request transaction — a
189
- * maintenance script, or a post-commit thunk whose transaction has ended
190
- * (`db_admin_row_delete`, `http/db_routes.ts`).
189
+ * Awaitable pool write for code paths without a request — a maintenance
190
+ * script.
191
191
  *
192
192
  * Writes, then notifies the listeners, whatever the outcome — there is no
193
193
  * request transaction to order the fan-out against. Tracked by
@@ -197,9 +197,11 @@ export interface AuditEmitter {
197
197
  *
198
198
  * Not for a success audit paired with a state mutation: the pool write
199
199
  * can't roll back with the state, and a swallowed error leaves the
200
- * mutation unaudited. Write those in the mutation's transaction
201
- * (`query_audit_log` against the tx) and `notify` after the commit — the
202
- * shape `auth/cleanup.ts`'s offer sweep and `query_accept_offer` use.
200
+ * mutation unaudited. Write those in the mutation's transaction — `emit`
201
+ * with a transaction context, or `query_audit_log` against the tx and
202
+ * `notify` after the commit, the shape `auth/cleanup.ts`'s offer sweep and
203
+ * `query_accept_offer` use. A success row written here is counted for
204
+ * `install_audit_drift_guard` (`get_audit_success_outside_transaction`).
203
205
  *
204
206
  * @mutates `audit_log` table - inserts the row via the captured pool
205
207
  */
@@ -246,35 +248,31 @@ export interface AuditEmitter {
246
248
  */
247
249
  listener_count(): number;
248
250
  /**
249
- * Await every fire-and-forget `emit` write in flight — the deterministic
250
- * barrier behind the `_testing_drain_effects` test action.
251
+ * Await every pool write in flight — `emit`'s failure rows and every
252
+ * `emit_pool` — which no handler awaits. `AppServer.close` waits on it,
253
+ * bounded, before the database closes, so a row a request just started is
254
+ * not lost to the shutdown; it is also the deterministic barrier behind
255
+ * the `_testing_drain_effects` test action.
251
256
  *
252
- * Waits until no tracked write is outstanding, so a write that starts
257
+ * Waits until no pool write is outstanding, so a write that starts
253
258
  * while the drain is waiting (an emit from a post-commit thunk) is awaited
254
259
  * too. Once it resolves, a following `audit_log_list` read sees every row
255
260
  * whose `emit` ran before the drain was called. A write that starts after
256
261
  * the drain resolves is not covered. A success row's listener fan-out runs
257
262
  * as a post-commit effect and is not tracked, so an SSE broadcast or an
258
263
  * auth-guard close driven by one isn't guaranteed done when the drain
259
- * resolves — the row itself is.
264
+ * resolves — the row itself is. A success row is written in its request's
265
+ * transaction, which the request awaits, so it is never in flight here.
260
266
  *
261
- * Resolves at once unless the emitter was built with
262
- * `track_inflight: true` — production never tracks, so there is nothing
263
- * to wait for. Twin of the Rust `fuz_auth` `AuditEmitter::drain_inflight`.
267
+ * Twin of the Rust `fuz_auth` `AuditEmitter::drain_inflight`.
264
268
  */
265
269
  drain_inflight(): Promise<void>;
266
270
  /**
267
- * Whether this emitter tracks its in-flight `emit` writes — `true` only
268
- * when built with `track_inflight: true`. When `false`, `drain_inflight`
269
- * resolves at once and waits on nothing.
270
- *
271
- * The `_testing_drain_effects` action reports it as `tracked`, and the
272
- * `list_audit_events` reads refuse `false`: a test binary whose emitter was
273
- * built without tracking would otherwise answer the drain at once and its
274
- * audit reads would race the writes. Twin of the Rust `fuz_auth`
275
- * `AuditEmitter::is_tracking_inflight`.
271
+ * How many pool writes are in flight now — what a shutdown that gives up
272
+ * on `drain_inflight` at its bound reports as lost. Twin of the Rust
273
+ * `fuz_auth` `AuditEmitter::inflight_count`.
276
274
  */
277
- is_tracking_inflight(): boolean;
275
+ inflight_count(): number;
278
276
  }
279
277
  /**
280
278
  * Signature of `AuditEmitter.emit` — captured by the inner closure so
@@ -321,17 +319,6 @@ export interface CreateAuditEmitterOptions {
321
319
  * Leave unset in production — it is a test instrumentation seam.
322
320
  */
323
321
  emit_decorator?: EmitDecorator;
324
- /**
325
- * Track every in-flight `emit` write so `drain_inflight` can await it.
326
- * Defaults to `false`, which makes `drain_inflight` resolve at once.
327
- *
328
- * Test binaries only. A transport can reply before a request's writes
329
- * settle — a WebSocket message is answered before its effects flush — so
330
- * a test reading the audit log after a reply needs this barrier. In
331
- * production the tracking is pure overhead and nothing drains it. Twin of
332
- * the Rust `fuz_auth` `AuditEmitter::new_with_inflight_tracking`.
333
- */
334
- track_inflight?: boolean;
335
322
  }
336
323
  /**
337
324
  * The whole row a dropped pool write would have inserted, as the one JSON
@@ -356,6 +343,10 @@ export interface CreateAuditEmitterOptions {
356
343
  * @returns the row, ready to `JSON.stringify`
357
344
  */
358
345
  export declare const to_dropped_audit_row: <T extends string>(input: AuditLogInput<T>, config: AuditLogConfig) => Record<string, unknown>;
346
+ /** Number of success rows emitted outside a transaction since process start. */
347
+ export declare const get_audit_success_outside_transaction: () => number;
348
+ /** Reset the counter — for tests only. */
349
+ export declare const reset_audit_success_outside_transaction: () => void;
359
350
  /** Number of audit rows an emitter failed to write since process start. */
360
351
  export declare const get_audit_write_failures: () => number;
361
352
  /** Reset the counter — for tests only. */
@@ -1 +1 @@
1
- {"version":3,"file":"audit_emitter.d.ts","sourceR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AAc,KACpB,MAAM,CAAC,MAAM,EAAE,OAAO,CAqBxB,CAAC;AAYF,gFAAgF;AAChF,eAAO,MAAM,qCAAqC,QAAO,MACvB,CAAC;AAEnC,0CAA0C;AAC1C,eAAO,MAAM,uCAAuC,QAAO,IAE1D,CAAC;AAEF,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,QAAO,MAA8B,CAAC;AAE3E,0CAA0C;AAC1C,eAAO,MAAM,0BAA0B,QAAO,IAE7C,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,oBAAoB,GAAI,SAAS,yBAAyB,KAAG,YAuJzE,CAAC"}
@@ -12,46 +12,52 @@
12
12
  * These methods cover every fan-out shape the auth domain needs
13
13
  * (`add_listener` and `listener_count` manage the listener chain):
14
14
  *
15
- * - `emit(ctx, input)` — the request-scoped emit. A success row inside a
16
- * request transaction is written in it and the promise rejects when the
17
- * INSERT fails; every other row is a fire-and-forget pool write whose
18
- * in-flight promise goes on `ctx.pending_effects`, and the returned promise
19
- * resolves at once.
15
+ * - `emit(ctx, input)` — the request-scoped emit. A success row is written
16
+ * in the request's transaction and the promise rejects when the INSERT
17
+ * fails — or when no transaction is open; a failure row is a
18
+ * fire-and-forget pool write whose in-flight promise goes on
19
+ * `ctx.pending_effects`, and the returned promise resolves at once.
20
20
  * - `emit_role_grant_target(ctx, auth, input)` — wrapper that lifts the
21
21
  * `actor_id` / `account_id` / `ip` boilerplate every role-grant-shape audit
22
22
  * site repeated. Delegates to `emit`.
23
23
  * - `emit_pool(input)` — awaitable pool write for code paths without a
24
- * request transaction (maintenance scripts, a post-commit thunk). Writes,
25
- * then notifies.
24
+ * request (maintenance scripts). Writes, then notifies.
26
25
  * - `notify(event)` — fan out an already-written audit row (e.g. rows
27
26
  * returned by `query_accept_offer` that were inserted in-transaction by
28
27
  * the query layer, or the offer-expiry rows `auth/cleanup.ts` writes in
29
28
  * its sweep transaction). Runs every registered listener; per-listener
30
29
  * throws are isolated.
31
- * - `drain_inflight()` — test-binary barrier: await every in-flight `emit`
32
- * write, on an emitter built with `track_inflight: true`.
33
- * - `is_tracking_inflight()` — whether that barrier can wait on anything, so a
34
- * test binary built without tracking is caught rather than racing.
30
+ * - `drain_inflight()` — await every pool write in flight: what
31
+ * `AppServer.close` waits on (bounded) before the database closes, and the
32
+ * barrier behind the `_testing_drain_effects` test action.
33
+ * - `inflight_count()` — how many pool writes are in flight now.
35
34
  *
36
35
  * ## Where a row is written
37
36
  *
38
- * The routing reads two things: the row's outcome and whether `ctx.db` is a
39
- * transaction (`Db.in_transaction`).
37
+ * The routing reads the row's outcome, and for a success row whether `ctx.db`
38
+ * is a transaction (`Db.in_transaction`).
40
39
  *
41
- * - A **success** row emitted inside a request transaction (an action with
42
- * `side_effects`, a route with `transaction: true`) is written **in that
43
- * transaction**: the change and the row that reports it commit together or
44
- * not at all. The INSERT is awaited, and a failed one rejects `emit`, so the
45
- * handler throws and its transaction rolls back — a committed change is
46
- * never left unaudited.
40
+ * - A **success** row is written **in the request's transaction** — an action
41
+ * with `side_effects`, a route with `transaction: true`, or the transaction a
42
+ * `transaction: false` route opens around just its writes (`/login`,
43
+ * `/password`, signup, bootstrap, through
44
+ * `http/pending_effects.ts`'s `transaction_with_post_commit_rollback`),
45
+ * last before its commit. The change and the row that reports it commit
46
+ * together or not at all. The INSERT is awaited, and a failed one rejects
47
+ * `emit`, so the handler throws and its transaction rolls back — a
48
+ * committed change is never left unaudited, and a response, once sent, has
49
+ * its row committed. With no transaction open, `emit` refuses a success row
50
+ * by throwing, writing nothing (counted for `install_audit_drift_guard`,
51
+ * `get_audit_success_outside_transaction`).
47
52
  * - A **failure** row is written on the pool, outside the request's
48
53
  * transaction, so it survives the rollback that usually follows it — the
49
- * forensic record of a refused attempt.
50
- * - A success row emitted with no request transaction open (a `GET`, or a
51
- * route that runs `transaction: false` and opens its own around just its
52
- * writes, like `/login` and `/password`, which emit once that transaction
53
- * has committed) is written on the pool too — there is no transaction to
54
- * join.
54
+ * forensic record of a refused attempt. No response waits for it;
55
+ * `AppServer.close` does, bounded (`drain_inflight`).
56
+ *
57
+ * `seq` is a `BIGSERIAL`, taken at INSERT: rows are numbered in INSERT order,
58
+ * not commit order, so a reader paging by `seq` can see a gap fill in when a
59
+ * transaction that inserted earlier commits later. What holds is that a
60
+ * success row is visible exactly when its change is.
55
61
  *
56
62
  * A pool write is fail-open: a failed one is counted
57
63
  * (`get_audit_write_failures`) and logged as one `error` line carrying the
@@ -62,24 +68,18 @@
62
68
  * than a request's, so a pool saturated enough to shed requests with a 503
63
69
  * does not also drop the failure rows recording them.
64
70
  *
65
- * This is the Rust spine's split: `fuz_auth`'s `route_audit_emit` writes an
66
- * action's success row in the request transaction (`emit_in_tx`) and every
67
- * failure row on the pool (`emit`), and its REST handlers (`/login`,
68
- * `/password`, signup, bootstrap) emit on the pool. Two rows differ in
69
- * routing between the twins, visible on the wire only when the audit INSERT
70
- * fails: the TS `/logout` runs in a route transaction, so its success row is
71
- * written in it (Rust writes it on the pool), and `db_admin_row_delete` is
72
- * written on the pool after the commit on both (`http/db_routes.ts`, through
73
- * `emit_pool`).
71
+ * This is the Rust spine's split: `fuz_auth`'s `route_audit_emit` writes a
72
+ * success row in the request transaction (`emit_in_tx`) — its REST handlers'
73
+ * and the db-admin row delete's included — and every failure row on the pool
74
+ * (`emit`).
74
75
  *
75
76
  * ## When listeners hear about a row
76
77
  *
77
78
  * - A **failure** row is announced as soon as it is written. It records an
78
79
  * attempt, which happened whether or not the request's transaction commits.
79
80
  * - A **success** row is announced only after the request's transaction
80
- * commits (after the handler returns, on a route without one), and never
81
- * when the handler throws: the fan-out is queued on
82
- * `ctx.post_commit_effects`. A success row reports a state change, and the
81
+ * commits, and never when it rolls back: the fan-out is queued on
82
+ * `ctx.post_commit_effects`, discarded on a rollback. A success row reports a state change, and the
83
83
  * listeners act on it — the revocation listeners close connections, the
84
84
  * audit stream broadcasts it. Announced before the commit, a close could run
85
85
  * while the revoked credential still reads as valid, and a rolled-back
@@ -165,6 +165,21 @@ export const to_dropped_audit_row = (input, config) => {
165
165
  metadata
166
166
  };
167
167
  };
168
+ /**
169
+ * Process-wide counter for success rows written outside a transaction: an
170
+ * `emit` of one with no transaction open (which throws as well), and every
171
+ * `emit_pool` of one. A success row reports a change and belongs in that
172
+ * change's transaction; `install_audit_drift_guard` asserts this zero per
173
+ * test, so a pool-written success row fails the test that wrote it even when
174
+ * its caller swallowed the throw. Same lifetime as `audit_write_failures`.
175
+ */
176
+ let audit_success_outside_transaction = 0;
177
+ /** Number of success rows emitted outside a transaction since process start. */
178
+ export const get_audit_success_outside_transaction = () => audit_success_outside_transaction;
179
+ /** Reset the counter — for tests only. */
180
+ export const reset_audit_success_outside_transaction = () => {
181
+ audit_success_outside_transaction = 0;
182
+ };
168
183
  /** Number of audit rows an emitter failed to write since process start. */
169
184
  export const get_audit_write_failures = () => audit_write_failures;
170
185
  /** Reset the counter — for tests only. */
@@ -181,7 +196,7 @@ export const reset_audit_write_failures = () => {
181
196
  * @returns the bound emitter; closes over the pool + config + listener chain
182
197
  */
183
198
  export const create_audit_emitter = (options) => {
184
- const { db, log, audit_log_config = builtin_audit_log_config, emit_decorator, track_inflight = false } = options;
199
+ const { db, log, audit_log_config = builtin_audit_log_config, emit_decorator } = options;
185
200
  // Closure-private listener list — no mutable array is exposed on the
186
201
  // returned (frozen) emitter; registration goes through `add_listener`.
187
202
  // One entry object per registration, so a remover takes out its own
@@ -221,23 +236,19 @@ export const create_audit_emitter = (options) => {
221
236
  if (event)
222
237
  notify(event);
223
238
  };
224
- // In-flight `emit` writes, when tracked — each removed as it settles, so
225
- // the set is empty exactly when nothing is outstanding. Neither tracked
226
- // promise rejects (`write` and `notify` log their failures).
227
- const inflight = track_inflight ? new Set() : null;
239
+ // Pool writes in flight — each removed as it settles, so the set is empty
240
+ // exactly when nothing is outstanding. No tracked promise rejects (`write`
241
+ // and `notify` log their failures).
242
+ const inflight = new Set();
228
243
  const track = (promise) => {
229
- if (inflight) {
230
- inflight.add(promise);
231
- const remove = () => {
232
- inflight.delete(promise);
233
- };
234
- void promise.then(remove, remove);
235
- }
244
+ inflight.add(promise);
245
+ const remove = () => {
246
+ inflight.delete(promise);
247
+ };
248
+ void promise.then(remove, remove);
236
249
  return promise;
237
250
  };
238
251
  const drain_inflight = async () => {
239
- if (!inflight)
240
- return;
241
252
  // Wait for zero, not for a snapshot: a write started while waiting —
242
253
  // an emit from a post-commit thunk — joins the set and is awaited on
243
254
  // the next pass. The removal reactions were registered before these,
@@ -246,32 +257,33 @@ export const create_audit_emitter = (options) => {
246
257
  await Promise.allSettled(inflight);
247
258
  }
248
259
  };
249
- const is_tracking_inflight = () => inflight !== null;
250
- const emit_pool = (input) => track(write_and_notify(input));
260
+ const inflight_count = () => inflight.size;
261
+ const emit_pool = (input) => {
262
+ if (input.outcome !== 'failure')
263
+ audit_success_outside_transaction++;
264
+ return track(write_and_notify(input));
265
+ };
266
+ // the routed failure write, which is not counted
267
+ const emit_failure_pool = (input) => track(write_and_notify(input));
251
268
  // The routing — see the module doc, "Where a row is written".
252
269
  const base_emit = async (ctx, input) => {
253
270
  if (input.outcome === 'failure') {
254
271
  // an attempt happened whether or not the transaction commits
255
- ctx.pending_effects.push(emit_pool(input));
272
+ ctx.pending_effects.push(emit_failure_pool(input));
256
273
  return;
257
274
  }
258
- if (ctx.db.in_transaction) {
259
- // Written in the request's transaction, so it commits or rolls back
260
- // with the change it reports; a throw here fails the handler. The
261
- // fan-out waits for the commit and is discarded on rollback.
262
- const event = await query_audit_log({ db: ctx.db }, input, audit_log_config);
263
- emit_after_commit(ctx, () => notify(event));
264
- return;
275
+ if (!ctx.db.in_transaction) {
276
+ // a success row reports a change, and is written with it — a row on
277
+ // the pool could land for a change that rolls back, or be lost for
278
+ // one that commits
279
+ audit_success_outside_transaction++;
280
+ throw new Error(`audit: a '${input.event_type}' success row was emitted with no transaction open — write it in the transaction of the change it reports`);
265
281
  }
266
- // No transaction to join: written on the pool now, announced once the
267
- // handler has returned — and not at all if it throws.
268
- const written = track(write(input));
269
- ctx.pending_effects.push(written.then(() => undefined));
270
- emit_after_commit(ctx, async () => {
271
- const event = await written;
272
- if (event)
273
- notify(event);
274
- });
282
+ // Written in the request's transaction, so it commits or rolls back
283
+ // with the change it reports; a throw here fails the handler. The
284
+ // fan-out waits for the commit and is discarded on rollback.
285
+ const event = await query_audit_log({ db: ctx.db }, input, audit_log_config);
286
+ emit_after_commit(ctx, () => notify(event));
275
287
  };
276
288
  // The decorated `emit` is what `emit_role_grant_target` captures below
277
289
  // and what gets exposed on the returned object — both call shapes
@@ -315,6 +327,6 @@ export const create_audit_emitter = (options) => {
315
327
  add_listener,
316
328
  listener_count,
317
329
  drain_inflight,
318
- is_tracking_inflight
330
+ inflight_count
319
331
  });
320
332
  };
@@ -51,10 +51,11 @@ export type RevocationScope = 'none' | 'session' | 'token' | 'account' | 'role';
51
51
  * until it declares its scope here.
52
52
  *
53
53
  * A scope other than `none` marks an event whose success invalidates a live
54
- * connection's credential or access: `logout`, `password_change`,
54
+ * connection's credential or access: `password_change`,
55
55
  * `session_revoke_all`, `token_revoke_all`, `account_delete`, and
56
- * `account_purge` are account-wide, `session_revoke` and `token_revoke` name
57
- * the one credential they ended, and `role_grant_revoke` names the lost role.
56
+ * `account_purge` are account-wide, `session_revoke`, `logout` and
57
+ * `token_revoke` name the one credential they ended, and `role_grant_revoke`
58
+ * names the lost role.
58
59
  * Granting access revokes nothing, and neither does an event about a subject
59
60
  * other than a connection's identity.
60
61
  *
@@ -129,7 +130,9 @@ export declare const audit_metadata_schemas: Readonly<{
129
130
  login: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").LooseObjectSchema<{
130
131
  username: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
131
132
  }>>;
132
- logout: import("@fuzdev/fuz_schema/schema.ts").LiteralSchema<null>;
133
+ logout: import("@fuzdev/fuz_schema/schema.ts").LooseObjectSchema<{
134
+ session_id: import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "SessionId">;
135
+ }>;
133
136
  bootstrap: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").LooseObjectSchema<{
134
137
  error: import("@fuzdev/fuz_schema/schema.ts").StringSchema;
135
138
  }>>;
@@ -227,7 +230,9 @@ export declare const audit_metadata_schemas: Readonly<{
227
230
  username: import("@fuzdev/fuz_schema/schema.ts").NullableSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
228
231
  }>;
229
232
  invite_delete: import("@fuzdev/fuz_schema/schema.ts").LooseObjectSchema<{
230
- invite_id: import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">;
233
+ invite_id: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">>;
234
+ reason: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
235
+ attempted_invite_id: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").BrandSchema<import("@fuzdev/fuz_schema/schema.ts").PipeSchema<string, import("@fuzdev/fuz_schema/schema.ts").StringSchema>, "Uuid">>;
231
236
  }>;
232
237
  account_delete: import("@fuzdev/fuz_schema/schema.ts").LooseObjectSchema<{
233
238
  username: import("@fuzdev/fuz_schema/schema.ts").OptionalSchema<import("@fuzdev/fuz_schema/schema.ts").StringSchema>;
@@ -286,10 +291,11 @@ export interface AuditLogEvent {
286
291
  * declares `acting?: ActingActor` or its auth requires role_grants
287
292
  * (`role` / `keeper`). Account-grain operations declare neither,
288
293
  * so no actor is resolved and `actor_id` is null: login (also
289
- * pre-credential), logout, signup, bootstrap, password_change,
290
- * session/token revoke, app_settings_update, invite events.
291
- * Role grant events, admin actions, and actor-targeted offers
292
- * populate this with the initiator's actor.
294
+ * pre-credential), logout, password_change, session/token revoke,
295
+ * app_settings_update. Signup and bootstrap name the actor they
296
+ * create. Role grant events, offer events a request initiates, and
297
+ * the other admin actions (the invite events included) populate this
298
+ * with the initiator's actor.
293
299
  */
294
300
  actor_id: Uuid | null;
295
301
  account_id: Uuid | null;
@@ -311,8 +317,11 @@ export interface AuditLogEvent {
311
317
  * carry the actor when the offer was actor-targeted at create time
312
318
  * (`role_grant_offer.to_actor_id` set), null when the offer was
313
319
  * account-grain (any actor on `to_account_id` may accept).
314
- * - Not populated: admin actions, account-shape events (login,
315
- * logout, signup, bootstrap, password_change, session/token
320
+ * - Populated with the removed actor: the per-actor `actor_delete` /
321
+ * `actor_purge` / `actor_undelete` rows an account removal or
322
+ * reactivation writes.
323
+ * - Not populated: other admin actions and account-shape events
324
+ * (login, logout, signup, bootstrap, password_change, session/token
316
325
  * revoke, app_settings_update, invite events) — subject is the
317
326
  * account or no specific resource, not an actor-bound role_grant.
318
327
  * - Not populated: events whose principal isn't an actor-bound
@@ -325,9 +334,11 @@ export interface AuditLogEvent {
325
334
  * holds uniformly across every populated event including decline
326
335
  * (the grantor's account is joined into the decline RETURNING) and
327
336
  * the supersede cascade (the recipient account is known on
328
- * `role_grant_offer.to_account_id`). `target_account_id` stays the
329
- * SSE/WS socket-close key because sessions remain account-grain
330
- * after multi-actor lands.
337
+ * `role_grant_offer.to_account_id`). An `account`- or
338
+ * `role`-scoped connection close keys on `target_account_id ??
339
+ * account_id`, since sessions are account-grain; a `session` or `token`
340
+ * close keys on the row's metadata (`to_connection_close_target` in
341
+ * `actions/connection_closer.ts`).
331
342
  */
332
343
  target_actor_id: Uuid | null;
333
344
  ip: string | null;
@@ -1 +1 @@
1
- {"version":3,"file":"audit_log_schema.d.ts","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