@fuzdev/fuz_app 0.184.0 → 0.186.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 (174) hide show
  1. package/dist/actions/CLAUDE.md +18 -3
  2. package/dist/actions/perform_action.d.ts.map +1 -1
  3. package/dist/actions/perform_action.js +36 -5
  4. package/dist/actions/register_action_ws.d.ts +14 -7
  5. package/dist/actions/register_action_ws.d.ts.map +1 -1
  6. package/dist/actions/ws_socket_session.d.ts +17 -4
  7. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  8. package/dist/actions/ws_socket_session.js +41 -7
  9. package/dist/auth/CLAUDE.md +18 -9
  10. package/dist/auth/account_queries.d.ts +53 -40
  11. package/dist/auth/account_queries.d.ts.map +1 -1
  12. package/dist/auth/account_queries.js +57 -50
  13. package/dist/auth/account_routes.d.ts.map +1 -1
  14. package/dist/auth/account_routes.js +59 -25
  15. package/dist/auth/admin_actions.d.ts.map +1 -1
  16. package/dist/auth/admin_actions.js +26 -9
  17. package/dist/auth/audit_emitter.js +2 -2
  18. package/dist/auth/audit_log_queries.d.ts +11 -3
  19. package/dist/auth/audit_log_queries.d.ts.map +1 -1
  20. package/dist/auth/audit_log_queries.js +4 -4
  21. package/dist/auth/audit_log_routes.d.ts +1 -1
  22. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  23. package/dist/auth/audit_log_routes.js +3 -2
  24. package/dist/auth/audit_log_schema.js +1 -1
  25. package/dist/auth/auth_ddl.d.ts.map +1 -1
  26. package/dist/auth/auth_ddl.js +4 -0
  27. package/dist/auth/cleanup.d.ts +34 -3
  28. package/dist/auth/cleanup.d.ts.map +1 -1
  29. package/dist/auth/cleanup.js +12 -4
  30. package/dist/auth/migrations.d.ts.map +1 -1
  31. package/dist/auth/migrations.js +35 -0
  32. package/dist/auth/role_grant_offer_queries.d.ts +13 -13
  33. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  34. package/dist/auth/role_grant_offer_queries.js +12 -13
  35. package/dist/auth/role_grant_queries.d.ts +16 -9
  36. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  37. package/dist/auth/role_grant_queries.js +16 -9
  38. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  39. package/dist/auth/self_service_role_actions.js +15 -0
  40. package/dist/auth/session_queries.d.ts +24 -0
  41. package/dist/auth/session_queries.d.ts.map +1 -1
  42. package/dist/auth/session_queries.js +28 -0
  43. package/dist/db/CLAUDE.md +3 -3
  44. package/dist/db/cell_ddl.d.ts +8 -3
  45. package/dist/db/cell_ddl.d.ts.map +1 -1
  46. package/dist/db/cell_ddl.js +10 -5
  47. package/dist/http/CLAUDE.md +1 -1
  48. package/dist/http/body_limit.d.ts +4 -4
  49. package/dist/http/body_limit.js +4 -4
  50. package/dist/http/pending_effects.d.ts +8 -4
  51. package/dist/http/pending_effects.d.ts.map +1 -1
  52. package/dist/http/route_spec.d.ts +3 -3
  53. package/dist/http/route_spec.d.ts.map +1 -1
  54. package/dist/realtime/audit_log_sse.d.ts +1 -1
  55. package/dist/realtime/sse.d.ts +2 -2
  56. package/dist/realtime/sse.d.ts.map +1 -1
  57. package/dist/realtime/sse_constants.d.ts +1 -1
  58. package/dist/realtime/sse_constants.js +1 -1
  59. package/dist/server/app_server.d.ts +59 -71
  60. package/dist/server/app_server.d.ts.map +1 -1
  61. package/dist/server/app_server.js +52 -60
  62. package/dist/server/shutdown_drain.d.ts +69 -0
  63. package/dist/server/shutdown_drain.d.ts.map +1 -0
  64. package/dist/server/shutdown_drain.js +77 -0
  65. package/dist/testing/CLAUDE.md +197 -66
  66. package/dist/testing/admin_integration.d.ts +2 -2
  67. package/dist/testing/admin_integration.d.ts.map +1 -1
  68. package/dist/testing/admin_integration.js +36 -20
  69. package/dist/testing/app_server.d.ts +5 -7
  70. package/dist/testing/app_server.d.ts.map +1 -1
  71. package/dist/testing/app_server.js +5 -7
  72. package/dist/testing/auth_apps.d.ts +3 -1
  73. package/dist/testing/auth_apps.d.ts.map +1 -1
  74. package/dist/testing/auth_apps.js +22 -5
  75. package/dist/testing/cross_backend/backend_config.d.ts +8 -0
  76. package/dist/testing/cross_backend/backend_config.d.ts.map +1 -1
  77. package/dist/testing/cross_backend/backend_log.d.ts +71 -0
  78. package/dist/testing/cross_backend/backend_log.d.ts.map +1 -0
  79. package/dist/testing/cross_backend/backend_log.js +134 -0
  80. package/dist/testing/cross_backend/backend_swap.d.ts +41 -0
  81. package/dist/testing/cross_backend/backend_swap.d.ts.map +1 -0
  82. package/dist/testing/cross_backend/backend_swap.js +431 -0
  83. package/dist/testing/cross_backend/body_size_smuggling.js +3 -3
  84. package/dist/testing/cross_backend/bootstrap_backend.d.ts +3 -1
  85. package/dist/testing/cross_backend/bootstrap_backend.d.ts.map +1 -1
  86. package/dist/testing/cross_backend/bootstrap_backend.js +9 -5
  87. package/dist/testing/cross_backend/conformance_case.d.ts +11 -6
  88. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  89. package/dist/testing/cross_backend/conformance_case.js +4 -0
  90. package/dist/testing/cross_backend/conformance_principal.d.ts +2 -2
  91. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -1
  92. package/dist/testing/cross_backend/conformance_principal.js +27 -10
  93. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +10 -1
  94. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  95. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +33 -7
  96. package/dist/testing/cross_backend/default_backend_configs.d.ts +38 -5
  97. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  98. package/dist/testing/cross_backend/default_backend_configs.js +50 -15
  99. package/dist/testing/cross_backend/in_process_setup.d.ts +1 -1
  100. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  101. package/dist/testing/cross_backend/in_process_setup.js +53 -31
  102. package/dist/testing/cross_backend/revocation_drivers.d.ts +14 -2
  103. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/revocation_drivers.js +36 -8
  105. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  106. package/dist/testing/cross_backend/rpc_success_fixtures.js +2 -1
  107. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts +7 -0
  108. package/dist/testing/cross_backend/rust_spine_stub_backend_config.d.ts.map +1 -1
  109. package/dist/testing/cross_backend/rust_spine_stub_backend_config.js +4 -2
  110. package/dist/testing/cross_backend/setup.d.ts +44 -43
  111. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  112. package/dist/testing/cross_backend/setup.js +64 -62
  113. package/dist/testing/cross_backend/spawn_backend.d.ts +19 -1
  114. package/dist/testing/cross_backend/spawn_backend.d.ts.map +1 -1
  115. package/dist/testing/cross_backend/spawn_backend.js +138 -11
  116. package/dist/testing/cross_backend/spine_suites.d.ts +17 -14
  117. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  118. package/dist/testing/cross_backend/spine_suites.js +37 -15
  119. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  120. package/dist/testing/cross_backend/sse_round_trip.js +4 -2
  121. package/dist/testing/cross_backend/standard.d.ts +18 -82
  122. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  123. package/dist/testing/cross_backend/standard.js +6 -21
  124. package/dist/testing/cross_backend/standard_auth.d.ts +74 -0
  125. package/dist/testing/cross_backend/standard_auth.d.ts.map +1 -0
  126. package/dist/testing/cross_backend/standard_auth.js +28 -0
  127. package/dist/testing/cross_backend/standard_bundle.d.ts +48 -0
  128. package/dist/testing/cross_backend/standard_bundle.d.ts.map +1 -0
  129. package/dist/testing/cross_backend/standard_bundle.js +43 -0
  130. package/dist/testing/cross_backend/testing_reset_actions.d.ts +18 -6
  131. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  132. package/dist/testing/cross_backend/testing_reset_actions.js +23 -8
  133. package/dist/testing/cross_backend/testing_server_bun.d.ts.map +1 -1
  134. package/dist/testing/cross_backend/testing_server_bun.js +7 -30
  135. package/dist/testing/cross_backend/testing_server_core.d.ts +16 -3
  136. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  137. package/dist/testing/cross_backend/testing_server_core.js +20 -4
  138. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts +6 -2
  139. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  140. package/dist/testing/cross_backend/ts_spine_backend_config.js +7 -3
  141. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  142. package/dist/testing/cross_backend/ws_round_trip.js +4 -3
  143. package/dist/testing/data_exposure.d.ts +4 -1
  144. package/dist/testing/data_exposure.d.ts.map +1 -1
  145. package/dist/testing/data_exposure.js +93 -25
  146. package/dist/testing/db_invariants.d.ts +5 -5
  147. package/dist/testing/db_invariants.js +5 -5
  148. package/dist/testing/error_coverage.d.ts +5 -0
  149. package/dist/testing/error_coverage.d.ts.map +1 -1
  150. package/dist/testing/error_coverage.js +2 -1
  151. package/dist/testing/integration.d.ts +4 -20
  152. package/dist/testing/integration.d.ts.map +1 -1
  153. package/dist/testing/integration.js +49 -79
  154. package/dist/testing/integration_helpers.d.ts +16 -0
  155. package/dist/testing/integration_helpers.d.ts.map +1 -1
  156. package/dist/testing/integration_helpers.js +29 -1
  157. package/dist/testing/logged_errors.d.ts +61 -0
  158. package/dist/testing/logged_errors.d.ts.map +1 -0
  159. package/dist/testing/logged_errors.js +285 -0
  160. package/dist/testing/middleware_gate_probes.d.ts +55 -1
  161. package/dist/testing/middleware_gate_probes.d.ts.map +1 -1
  162. package/dist/testing/middleware_gate_probes.js +76 -3
  163. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  164. package/dist/testing/rpc_attack_surface.js +41 -16
  165. package/dist/testing/stubs.d.ts +5 -1
  166. package/dist/testing/stubs.d.ts.map +1 -1
  167. package/dist/testing/stubs.js +6 -3
  168. package/dist/testing/test_app.d.ts +39 -9
  169. package/dist/testing/test_app.d.ts.map +1 -1
  170. package/dist/testing/test_app.js +70 -12
  171. package/dist/testing/transports/fetch_transport.d.ts +10 -0
  172. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  173. package/dist/testing/transports/fetch_transport.js +13 -0
  174. package/package.json +4 -3
@@ -83,7 +83,11 @@
83
83
  * that, so the standard assembly is one option:
84
84
  *
85
85
  * ```ts
86
- * const server = await create_app_server({backend, auth_cleanup: true, ...});
86
+ * const server = await create_app_server({
87
+ * backend,
88
+ * auth_cleanup: {every_ms: DEFAULT_AUTH_CLEANUP_INTERVAL_MS},
89
+ * ...
90
+ * });
87
91
  * // on shutdown: stops the schedule, then closes the database
88
92
  * await server.close();
89
93
  * ```
@@ -103,7 +107,10 @@
103
107
  * token is cancelled; a promise cannot be dropped, so `stop` ends the schedule
104
108
  * at once and its promise resolves when the pass in progress — if there is
105
109
  * one — has finished. Awaiting it before closing the database lets that pass
106
- * end on a live pool rather than fail on a closed one.
110
+ * end on a live pool rather than fail on a closed one. `AppServer.close`
111
+ * waits for it within its drain bound, as the Rust shutdown joins its upkeep,
112
+ * and counts a pass still running at the bound as given up on
113
+ * (`ShutdownDrainGivenUp.upkeep`).
107
114
  *
108
115
  * @module
109
116
  */
@@ -218,7 +225,7 @@ export const cleanup_expired_role_grant_offers = async (deps) => {
218
225
  // Account-grain offers (no `to_actor_id`) never bound to a
219
226
  // specific actor and leave the field null. No request is behind a
220
227
  // sweep, so `ip` stays null.
221
- written.push(await query_audit_log({ db: tx }, {
228
+ written.push(await query_audit_log({ db: tx, log: deps.log }, {
222
229
  event_type: 'role_grant_offer_expire',
223
230
  actor_id: offer.from_actor_id,
224
231
  target_account_id: offer.to_account_id,
@@ -267,7 +274,8 @@ export const run_auth_cleanup = async (deps) => {
267
274
  *
268
275
  * The auth surface's upkeep in one call — start it once migrations have run
269
276
  * and stop it before the database closes (see the module doc's § Scheduling).
270
- * `create_app_server`'s `auth_cleanup` option does both.
277
+ * `create_app_server`'s `auth_cleanup` option (an `AuthCleanupSchedule`)
278
+ * does both.
271
279
  *
272
280
  * Built on `start_periodic`, which fixes the loop's rules: the startup pass
273
281
  * starts before this returns, passes never overlap, a slow pass delays the
@@ -1 +1 @@
1
- {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/lib/auth/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AA+BH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAC;AAkQ1B;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAG/B,CAAC"}
1
+ {"version":3,"file":"migrations.d.ts","sourceRoot":"","sources":["../../src/lib/auth/migrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AA+BH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,kBAAkB,CAAC;AAsS1B;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAG/B,CAAC"}
@@ -52,6 +52,19 @@ import { ROLE_GRANT_OFFER_SCHEMA, ROLE_GRANT_OFFER_PENDING_UNIQUE_INDEX, ROLE_GR
52
52
  import { create_spine_migration_namespace } from '../db/migrate.js';
53
53
  /** Namespace identifier for fuz_app auth migrations. */
54
54
  const AUTH_MIGRATION_NAMESPACE = 'fuz_auth';
55
+ /**
56
+ * The statements of the `drop_provenance_stamp_foreign_keys` migration: the
57
+ * foreign keys of the provenance stamps, by their default names
58
+ * (`<table>_<column>_fkey`, the same on both spines). Statement for statement
59
+ * the Rust spine's `drop_provenance_stamp_foreign_keys.sql`.
60
+ */
61
+ const DROP_PROVENANCE_STAMP_FOREIGN_KEYS = [
62
+ 'ALTER TABLE actor DROP CONSTRAINT IF EXISTS actor_updated_by_fkey',
63
+ 'ALTER TABLE actor DROP CONSTRAINT IF EXISTS actor_deleted_by_fkey',
64
+ 'ALTER TABLE role_grant DROP CONSTRAINT IF EXISTS role_grant_granted_by_fkey',
65
+ 'ALTER TABLE role_grant DROP CONSTRAINT IF EXISTS role_grant_revoked_by_fkey',
66
+ 'ALTER TABLE role_grant DROP CONSTRAINT IF EXISTS role_grant_source_offer_id_fkey'
67
+ ];
55
68
  /**
56
69
  * Auth schema migrations in order.
57
70
  *
@@ -284,6 +297,28 @@ const AUTH_MIGRATIONS = [
284
297
  CHECK (username = lower(username))`);
285
298
  }
286
299
  }
300
+ },
301
+ // The provenance stamps carry no foreign key: `actor.updated_by` /
302
+ // `deleted_by`, `role_grant.granted_by` / `revoked_by` and
303
+ // `role_grant.source_offer_id`.
304
+ //
305
+ // A stamp records who did a thing; nothing authorizes on it, so it keeps the
306
+ // id it was written with after its actor (or offer) is purged, as
307
+ // `audit_log`'s identity columns and `account`'s stamps do. With the foreign
308
+ // key, a purge's cascade wrote other accounts' rows (`ON DELETE SET NULL`)
309
+ // in whatever order its plan walked them, and a write stamping an actor
310
+ // being purged waited on that actor's row while holding the row the cascade
311
+ // needed next: a deadlock. Without it, the cascade never writes a stamp and
312
+ // a stamp write takes no lock on its actor. The references that carry
313
+ // meaning keep theirs: every `actor_id` and `account_id`, an offer's
314
+ // parties, an invite's issuer. `IF EXISTS`, so a re-run is a no-op.
315
+ {
316
+ name: 'drop_provenance_stamp_foreign_keys',
317
+ up: async (db) => {
318
+ for (const sql of DROP_PROVENANCE_STAMP_FOREIGN_KEYS) {
319
+ await db.query(sql);
320
+ }
321
+ }
287
322
  }
288
323
  ];
289
324
  /**
@@ -15,6 +15,7 @@ import type { Uuid } from '../primitive_schemas.js';
15
15
  import type { QueryDeps } from '../db/query_deps.js';
16
16
  import type { RoleGrant } from './account_schema.js';
17
17
  import type { CreateRoleGrantOfferInput, RoleGrantOffer, SupersededOffer } from './role_grant_offer_schema.js';
18
+ import { type AuditLogQueryDeps } from './audit_log_queries.js';
18
19
  import type { AuditLogEvent } from './audit_log_schema.js';
19
20
  /**
20
21
  * Error thrown by offer-lifecycle queries when the offer is in a non-pending
@@ -304,18 +305,17 @@ export interface AcceptOfferResult {
304
305
  * (`query_account_lock_for_offer_accept`), then the offer and the pending
305
306
  * siblings it supersedes in one id-ordered claim, then the grant insert. The
306
307
  * accounts first, as every removal of either account takes them first, so a
307
- * removal and an accept never meet at the offers, the actor, or a grant a
308
- * purge's cascade reaches; two accepts by one recipient take turns. The
309
- * offers in id order, as every transaction that writes several offer rows
310
- * locks them all first in one id-ordered statement (a delete, a purge, a
311
- * revoke, the expiry sweep). The grantor's authority is read unlocked after
312
- * the grantor's account lock — the invariant it rests on: every write that
313
- * ends a grantor's global `admin` takes the grantor's account row first (a
314
- * revoke of the grant through `query_account_lock_for_revoke`, whether or not
315
- * its last-admin guard ran; a delete through its write of the row; a purge
316
- * through `query_account_lock_admins_for_purge` and
317
- * `query_account_lock_for_purge`; the DB browser's delete, which takes none of
318
- * them, excepted).
308
+ * removal and an accept never meet at the offers or the actor; two accepts
309
+ * by one recipient take turns. The offers in id order, as every transaction
310
+ * that writes several offer rows locks them all first in one id-ordered
311
+ * statement (a delete, a purge, a revoke, the expiry sweep). The grantor's
312
+ * authority is read unlocked after the grantor's account lock — the invariant
313
+ * it rests on: every write that ends a grantor's global `admin` takes the
314
+ * grantor's account row first (a revoke of the grant through
315
+ * `query_account_lock_for_revoke`, whether or not its last-admin guard ran; a
316
+ * delete through its write of the row; a purge through its last-admin guard
317
+ * and `query_account_lock_for_purge`; the DB browser's delete, which takes
318
+ * none of them, excepted).
319
319
  *
320
320
  * Error map:
321
321
  * - `RoleGrantOfferNotFoundError` — offer does not exist, or belongs to a
@@ -348,7 +348,7 @@ export interface AcceptOfferResult {
348
348
  * @throws RoleGrantOfferBuiltinRefusedError if a builtin-role offer must not mint (see `BuiltinOfferRefusal`)
349
349
  * @throws Error if the accepting `actor_id` does not belong to `to_account_id`, or invariant assertions fail
350
350
  */
351
- export declare const query_accept_offer: (deps: QueryDeps, input: AcceptOfferInput) => Promise<AcceptOfferResult>;
351
+ export declare const query_accept_offer: (deps: AuditLogQueryDeps, input: AcceptOfferInput) => Promise<AcceptOfferResult>;
352
352
  /**
353
353
  * Supersede every pending offer **made by** one of `from_actor_ids` — the
354
354
  * grantor-side cascade.
@@ -1 +1 @@
1
- {"version":3,"file":"role_grant_offer_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_offer_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAcrD,OAAO,KAAK,EACX,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,MAAM,8BAA8B,CAAC;AAOtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D;;;;;GAKG;AACH,qBAAa,kCAAmC,SAAQ,KAAK;gBAChD,QAAQ,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;gBACxC,QAAQ,EAAE,MAAM;CAI5B;AAED;;;;;GAKG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;gBACzC,QAAQ,EAAE,MAAM;CAI5B;AAED;;;;;;;;GAQG;AACH,qBAAa,6BAA8B,SAAQ,KAAK;;CAKvD;AAED;;;;;;;GAOG;AACH,qBAAa,gCAAiC,SAAQ,KAAK;gBAC9C,QAAQ,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,GAAG,QAAQ,GAAG,wBAAwB,CAAC;AAEzF;;;;;GAKG;AACH,qBAAa,iCAAkC,SAAQ,KAAK;IAC3D,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,OAAO,EAAE,mBAAmB,CAAC;g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,IAAI,CAAC,KACjC,OAAO,CAAC,IAAI,CASd,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,sCAAsC,GAClD,MAAM,SAAS,EACf,UAAU,IAAI,EACd,MAAM,MAAM,EACZ,UAAU,IAAI,GAAG,IAAI,KACnB,OAAO,CAAC,IAAI,CAWd,CAAC;AAEF,mHAAmH;AACnH,MAAM,WAAW,qBAAqB;IACrC,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IACtB;;;;;;;;;OASG;IACH,iBAAiB,EAAE,KAAK,CAAC,eAAe,CAAC,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,SAAS,EACf,eAAe,IAAI,EACnB,UAAU,IAAI,EACd,YAAY,IAAI,GAAG,IAAI,EACvB,SAAS,MAAM,GAAG,IAAI,KACpB,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAmDtC,CAAC"}
1
+ {"version":3,"file":"role_grant_offer_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_offer_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAcrD,OAAO,KAAK,EACX,yBAAyB,EACzB,cAAc,EACd,eAAe,EACf,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAMjF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAG3D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f,eAAe,IAAI,EACnB,UAAU,IAAI,EACd,YAAY,IAAI,GAAG,IAAI,EACvB,SAAS,MAAM,GAAG,IAAI,KACpB,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAmDtC,CAAC"}
@@ -387,7 +387,7 @@ export const query_role_grant_offer_sweep_expired = async (deps) => {
387
387
  * the grantor's account row `FOR SHARE` in the accept's transaction: every
388
388
  * write that ends a grantor's global `admin` takes that row first — a revoke of
389
389
  * the grant through `query_account_lock_for_revoke`, a delete through its write
390
- * of the row, a purge through `query_account_lock_admins_for_purge` and
390
+ * of the row, a purge through its last-admin guard and
391
391
  * `query_account_lock_for_purge` — so one that committed first is
392
392
  * seen here (each statement reads afresh), and one that came later waits for
393
393
  * the accept to commit. Twin of the Rust `grantor_holds_global_admin`.
@@ -423,18 +423,17 @@ const query_grantor_holds_global_admin = async (deps, grantor_actor_id) => {
423
423
  * (`query_account_lock_for_offer_accept`), then the offer and the pending
424
424
  * siblings it supersedes in one id-ordered claim, then the grant insert. The
425
425
  * accounts first, as every removal of either account takes them first, so a
426
- * removal and an accept never meet at the offers, the actor, or a grant a
427
- * purge's cascade reaches; two accepts by one recipient take turns. The
428
- * offers in id order, as every transaction that writes several offer rows
429
- * locks them all first in one id-ordered statement (a delete, a purge, a
430
- * revoke, the expiry sweep). The grantor's authority is read unlocked after
431
- * the grantor's account lock — the invariant it rests on: every write that
432
- * ends a grantor's global `admin` takes the grantor's account row first (a
433
- * revoke of the grant through `query_account_lock_for_revoke`, whether or not
434
- * its last-admin guard ran; a delete through its write of the row; a purge
435
- * through `query_account_lock_admins_for_purge` and
436
- * `query_account_lock_for_purge`; the DB browser's delete, which takes none of
437
- * them, excepted).
426
+ * removal and an accept never meet at the offers or the actor; two accepts
427
+ * by one recipient take turns. The offers in id order, as every transaction
428
+ * that writes several offer rows locks them all first in one id-ordered
429
+ * statement (a delete, a purge, a revoke, the expiry sweep). The grantor's
430
+ * authority is read unlocked after the grantor's account lock — the invariant
431
+ * it rests on: every write that ends a grantor's global `admin` takes the
432
+ * grantor's account row first (a revoke of the grant through
433
+ * `query_account_lock_for_revoke`, whether or not its last-admin guard ran; a
434
+ * delete through its write of the row; a purge through its last-admin guard
435
+ * and `query_account_lock_for_purge`; the DB browser's delete, which takes
436
+ * none of them, excepted).
438
437
  *
439
438
  * Error map:
440
439
  * - `RoleGrantOfferNotFoundError` — offer does not exist, or belongs to a
@@ -179,19 +179,26 @@ export declare const query_actor_has_active_global_role: (deps: QueryDeps, actor
179
179
  * removal.
180
180
  *
181
181
  * It does not conflict with a foreign key's `FOR KEY SHARE` — the lock an
182
- * insert or update naming a counted row takes (an accept's new grant naming its
183
- * grantor, a cell's `created_by`). Such a write only adds a reference: it never
182
+ * insert or update naming a counted row takes (a new grant to a counted actor,
183
+ * a cell's `created_by`). Such a write only adds a reference: it never
184
184
  * lowers the count, so the guard fails closed — what it counted is at most what
185
185
  * will stand, and a removal it allows leaves an admin. A purge that deletes a
186
186
  * row such a write names still takes `FOR UPDATE` and waits for it.
187
187
  *
188
- * A purge's cascade writes admin rows too — it sets null the `granted_by` of
189
- * every grant the purged account's actors granted, admins' grants among them,
190
- * in the order its plan walks them — so a purge takes every admin's account
191
- * row first, with its own, in one id-ordered statement
192
- * (`query_account_lock_admins_for_purge`), and runs this count after it only
193
- * when its target is an admin: another guard then waits at its first account
194
- * holding nothing.
188
+ * Both removals, a purge and a delete, run this count when their target is an
189
+ * admin, before any row of the target's (a purge after its advisory lock,
190
+ * `query_account_purge_advisory_lock`), and again once they hold the target's
191
+ * row (a purge's `query_account_lock_for_purge`, a delete's
192
+ * `query_account_lock_live`): whether the target is an admin is read
193
+ * unlocked, and an accept making it one can commit in between, with a revoke
194
+ * it let pass ending every other admin. The second count re-locks only rows
195
+ * the first holds, unless an admin was made in between — the target or
196
+ * another — whose rows it then takes out of id order. A deadlock error then
197
+ * rolls one of the two transactions back whole, removing nothing: the
198
+ * removal, or the other — which may be a removal that would have committed,
199
+ * and answers 500. A purge's cascade writes no other account's admin rows —
200
+ * the provenance stamps a grant names its granter by carry no foreign key —
201
+ * so another guard meets it only at these counts.
195
202
  * Twin of the Rust `query_count_active_accounts_with_global_role_locked`.
196
203
  *
197
204
  * The rows are locked in id order — account, then actor, then grant — as the
@@ -1 +1 @@
1
- {"version":3,"file":"role_grant_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/role_grant_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAS3E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAGpE;;;;;;;GAOG;AACH,eAAO,MAAM,kBAAkB,0KAaoB,CAAC;AAcpD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,uBAAuB,GACnC,MAAM,SAAS,EACf,OAAO,oBAAoB,KACzB,OAAO,CAAC,SAAS,CA8CnB,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,SAAS,EACf,IAAI,IAAI,KACN,OAAO,CAAC,SAAS,GAAG,SAAS,CAI9B,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,2CAA2C,GACvD,MAAM,SAAS,EACf,eAAe,MAAM,EACrB,UAAU,MAAM,KACd,OAAO,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,IAAI,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,IAAI,CAAA;CAAE,GAAG,IAAI,CAS1E,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sCAAsC,GAClD,MAAM,SAAS,EACf,UAAU,MAAM,KACd,OAAO,CAAC,KAAK,CAAC,SAAS,CA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AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,eAAO,MAAM,iCAAiC,GAC7C,MAAM,SAAS,EACf,UAAU,IAAI,EACd,YAAY,IAAI,GAAG,IAAI,EACvB,SAAS,MAAM,GAAG,IAAI,KACpB,OAAO,CAAC,oBAAoB,CAkD9B,CAAC"}
@@ -283,19 +283,26 @@ export const query_actor_has_active_global_role = async (deps, actor_id, role) =
283
283
  * removal.
284
284
  *
285
285
  * It does not conflict with a foreign key's `FOR KEY SHARE` — the lock an
286
- * insert or update naming a counted row takes (an accept's new grant naming its
287
- * grantor, a cell's `created_by`). Such a write only adds a reference: it never
286
+ * insert or update naming a counted row takes (a new grant to a counted actor,
287
+ * a cell's `created_by`). Such a write only adds a reference: it never
288
288
  * lowers the count, so the guard fails closed — what it counted is at most what
289
289
  * will stand, and a removal it allows leaves an admin. A purge that deletes a
290
290
  * row such a write names still takes `FOR UPDATE` and waits for it.
291
291
  *
292
- * A purge's cascade writes admin rows too — it sets null the `granted_by` of
293
- * every grant the purged account's actors granted, admins' grants among them,
294
- * in the order its plan walks them — so a purge takes every admin's account
295
- * row first, with its own, in one id-ordered statement
296
- * (`query_account_lock_admins_for_purge`), and runs this count after it only
297
- * when its target is an admin: another guard then waits at its first account
298
- * holding nothing.
292
+ * Both removals, a purge and a delete, run this count when their target is an
293
+ * admin, before any row of the target's (a purge after its advisory lock,
294
+ * `query_account_purge_advisory_lock`), and again once they hold the target's
295
+ * row (a purge's `query_account_lock_for_purge`, a delete's
296
+ * `query_account_lock_live`): whether the target is an admin is read
297
+ * unlocked, and an accept making it one can commit in between, with a revoke
298
+ * it let pass ending every other admin. The second count re-locks only rows
299
+ * the first holds, unless an admin was made in between — the target or
300
+ * another — whose rows it then takes out of id order. A deadlock error then
301
+ * rolls one of the two transactions back whole, removing nothing: the
302
+ * removal, or the other — which may be a removal that would have committed,
303
+ * and answers 500. A purge's cascade writes no other account's admin rows —
304
+ * the provenance stamps a grant names its granter by carry no foreign key —
305
+ * so another guard meets it only at these counts.
299
306
  * Twin of the Rust `query_count_active_accounts_with_global_role_locked`.
300
307
  *
301
308
  * The rows are locked in id order — account, then actor, then grant — as the
@@ -1 +1 @@
1
- {"version":3,"file":"self_service_role_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/self_service_role_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGjG,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAiB3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oCAAoC,GAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAG,IAW9E,CAAC;AAEF,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC7C;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,yBAAyB,EAC/B,UAAS,6BAAkC,KACzC,KAAK,CAAC,SAAS,CAyJjB,CAAC"}
1
+ {"version":3,"file":"self_service_role_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/self_service_role_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAIH,OAAO,EAAuC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAGjG,OAAO,EAKN,KAAK,YAAY,EACjB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AAmB3D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,oCAAoC,GAAI,OAAO,QAAQ,CAAC,MAAM,CAAC,KAAG,IAW9E,CAAC;AAEF,sDAAsD;AACtD,MAAM,WAAW,6BAA6B;IAC7C;;;;;;;;;;;OAWG;IACH,cAAc,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACvC;;;;OAIG;IACH,KAAK,CAAC,EAAE,YAAY,CAAC;CACrB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gCAAgC,GAC5C,MAAM,yBAAyB,EAC/B,UAAS,6BAAkC,KACzC,KAAK,CAAC,SAAS,CAuKjB,CAAC"}
@@ -43,6 +43,8 @@ import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
43
43
  import { builtin_role_specs, is_builtin_role, list_roles_with_grant_path, RoleName } from './role_schema.js';
44
44
  import { GRANT_PATH_SELF_SERVICE } from './grant_path_schema.js';
45
45
  import { query_create_role_grant } from './role_grant_queries.js';
46
+ import { query_account_lock_live } from './account_queries.js';
47
+ import { ERROR_AUTHENTICATION_REQUIRED } from '../http/error_schemas.js';
46
48
  import { query_revoke_role_grant } from './role_grant_offer_queries.js';
47
49
  import { emit_supersede_audits } from './role_grant_offer_actions.js';
48
50
  import { is_role_grant_active } from './account_schema.js';
@@ -106,6 +108,19 @@ export const create_self_service_role_actions = (deps, options = {}) => {
106
108
  const handler = async (input, ctx) => {
107
109
  const auth = ctx.auth;
108
110
  reject_if_ineligible(input.role);
111
+ // The credential was resolved before the transaction, so a delete or a
112
+ // purge of the account can commit in between: a toggle after it would
113
+ // write a grant (or revoke one) on the tombstone, back on an undelete,
114
+ // or meet a purged actor's foreign key. The account row first — the
115
+ // class order's first row, which a delete's tombstone and a purge's
116
+ // `DELETE` write — refuses it as the dead credential it now is, or
117
+ // makes a removal still to commit wait for the toggle. Both branches,
118
+ // before the no-op answers: a removed account is told it is removed.
119
+ if (!(await query_account_lock_live(ctx, auth.account.id))) {
120
+ throw jsonrpc_errors.unauthenticated('unauthenticated', {
121
+ reason: ERROR_AUTHENTICATION_REQUIRED
122
+ });
123
+ }
109
124
  if (input.enabled) {
110
125
  // Pre-check for idempotent re-grant. `query_create_role_grant` is itself
111
126
  // idempotent (returns the existing role_grant instead of inserting), but
@@ -101,6 +101,30 @@ export declare const query_session_get_valid: (deps: QueryDeps, token_hash: stri
101
101
  * @returns `true` when the session exists, belongs to the account, and has not expired
102
102
  */
103
103
  export declare const query_session_is_live: (deps: QueryDeps, id: string, account_id: string) => Promise<boolean>;
104
+ /**
105
+ * The password hash of the account a live session belongs to — the hash a
106
+ * password change verifies `current_password` against.
107
+ *
108
+ * The change's credential was resolved before this read, and its account row
109
+ * with it in a separate statement, so a change, a delete or a purge can commit
110
+ * between the two reads or after them. Each revokes the account's sessions in
111
+ * the transaction of its write, so while the session lives, the stored hash is
112
+ * the one the session was resolved under; once it is gone, the credential died
113
+ * mid-request and there is no hash to verify. Bound to the session in one
114
+ * statement, the read answers one or the other, never a later change's hash
115
+ * beside a dead session. The read is no lock: a session that dies after it is
116
+ * caught by the change's transaction, which takes the account row and then
117
+ * reads the session again (`query_session_is_live`). No tombstone filter: a
118
+ * delete revokes the sessions, and the change's transaction refuses a
119
+ * tombstone itself. Twin of the Rust
120
+ * `fuz_auth::query_session_live_password_hash`.
121
+ *
122
+ * @param deps - query dependencies
123
+ * @param id - the session's id, its token hash
124
+ * @param account_id - the account the session must belong to
125
+ * @returns the account's password hash, or `undefined` when the session is no longer live
126
+ */
127
+ export declare const query_session_live_password_hash: (deps: QueryDeps, id: string, account_id: string) => Promise<string | undefined>;
104
128
  /**
105
129
  * Revoke (delete) a session by its token hash, with no account scoping.
106
130
  *
@@ -1 +1 @@
1
- {"version":3,"file":"session_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/session_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC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ACH,eAAO,MAAM,qBAAqB,GACjC,SAAS,0BAA0B,KACjC,OAAO,CAAC,aAAa,CAUvB,CAAC"}
@@ -123,6 +123,34 @@ export const query_session_is_live = async (deps, id, account_id) => {
123
123
  const row = await deps.db.query_one(`SELECT id FROM auth_session WHERE id = $1 AND account_id = $2 AND expires_at > NOW()`, [id, account_id]);
124
124
  return row !== undefined;
125
125
  };
126
+ /**
127
+ * The password hash of the account a live session belongs to — the hash a
128
+ * password change verifies `current_password` against.
129
+ *
130
+ * The change's credential was resolved before this read, and its account row
131
+ * with it in a separate statement, so a change, a delete or a purge can commit
132
+ * between the two reads or after them. Each revokes the account's sessions in
133
+ * the transaction of its write, so while the session lives, the stored hash is
134
+ * the one the session was resolved under; once it is gone, the credential died
135
+ * mid-request and there is no hash to verify. Bound to the session in one
136
+ * statement, the read answers one or the other, never a later change's hash
137
+ * beside a dead session. The read is no lock: a session that dies after it is
138
+ * caught by the change's transaction, which takes the account row and then
139
+ * reads the session again (`query_session_is_live`). No tombstone filter: a
140
+ * delete revokes the sessions, and the change's transaction refuses a
141
+ * tombstone itself. Twin of the Rust
142
+ * `fuz_auth::query_session_live_password_hash`.
143
+ *
144
+ * @param deps - query dependencies
145
+ * @param id - the session's id, its token hash
146
+ * @param account_id - the account the session must belong to
147
+ * @returns the account's password hash, or `undefined` when the session is no longer live
148
+ */
149
+ export const query_session_live_password_hash = async (deps, id, account_id) => {
150
+ const row = await deps.db.query_one(`SELECT a.password_hash FROM auth_session s JOIN account a ON a.id = s.account_id
151
+ WHERE s.id = $1 AND s.account_id = $2 AND s.expires_at > NOW()`, [id, account_id]);
152
+ return row?.password_hash;
153
+ };
126
154
  /**
127
155
  * Revoke (delete) a session by its token hash, with no account scoping.
128
156
  *
package/dist/db/CLAUDE.md CHANGED
@@ -120,9 +120,9 @@ The wire schemas + RPC handlers + authz predicates for this layer live in
120
120
  authorizer's verdict + the `cell_moderate` verb, never in `data`.
121
121
  `cell.policy jsonb` (nullable) is a root's contribution policy, opaque to the
122
122
  spine — a table CHECK holds it to roots and to JSON objects (`policy @> '{}'`,
123
- the object test pglet runs too). Nullable
124
- `created_by` / `updated_by` FKs to `actor` (NULL = system origin). GIN on `data`
125
- / `refs`; global partial-unique on `path`.
123
+ the object test pglet runs too). Nullable `created_by` FK to `actor` (NULL =
124
+ system origin); `updated_by` and `cell_grant.granted_by` are provenance stamps
125
+ with no FK. GIN on `data` / `refs`; global partial-unique on `path`.
126
126
  - **`cell_queries.ts`** — `query_cell_create / get / get_by_path / update /
127
127
  delete / set_moderation`, `_list_by_kind / _list_by_creator`, the
128
128
  generic `query_cell_list` (filter + SQL-side visibility predicate mirroring
@@ -19,10 +19,15 @@
19
19
  * doesn't block reuse of its path. Path writes are admin-only at the
20
20
  * action layer; user-namespaced paths are a future extension.
21
21
  *
22
- * **Ownership columns** (`created_by`, `updated_by`) are nullable FKs to
23
- * `actor`: NULL = system origin (well-known cells, daemon/agent cells).
22
+ * **Ownership columns**: `created_by` is a nullable FK to `actor`
23
+ * (`ON DELETE SET NULL`): NULL = system origin (well-known cells,
24
+ * daemon/agent cells), and the owner the edit and manage predicates read.
24
25
  * The non-admin authz path treats NULL `created_by` as admin-only via an
25
- * explicit equality check (`auth/cell_authorize.ts`).
26
+ * explicit equality check (`auth/cell_authorize.ts`). `updated_by` and
27
+ * `cell_grant.granted_by` are provenance stamps with no FK, as `fuz_auth`'s
28
+ * are (`drop_provenance_stamp_foreign_keys`): nothing authorizes on them, so
29
+ * they keep the id they were written with after a purge, and neither a
30
+ * purge's cascade nor a stamp write waits on the other.
26
31
  *
27
32
  * **Timestamp naming** (`created_at`, `updated_at`) aligns with fuz_app's
28
33
  * `_at`-everywhere convention used by `account`, `actor`, `audit_log`,
@@ -1 +1 @@
1
- {"version":3,"file":"cell_ddl.d.ts","sourceRoot":"","sources":["../../src/lib/db/cell_ddl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAGH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,cAAc,CAAC;AAuOtB,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,4DAA6D,CAAC;AA+B3F;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAG/B,CAAC"}
1
+ {"version":3,"file":"cell_ddl.d.ts","sourceRoot":"","sources":["../../src/lib/db/cell_ddl.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AAGH,OAAO,EAGN,KAAK,kBAAkB,EACvB,MAAM,cAAc,CAAC;AAuOtB,6EAA6E;AAC7E,eAAO,MAAM,gBAAgB,4DAA6D,CAAC;AA+B3F;;;GAGG;AACH,eAAO,MAAM,iBAAiB,EAAE,kBAG/B,CAAC"}
@@ -19,10 +19,15 @@
19
19
  * doesn't block reuse of its path. Path writes are admin-only at the
20
20
  * action layer; user-namespaced paths are a future extension.
21
21
  *
22
- * **Ownership columns** (`created_by`, `updated_by`) are nullable FKs to
23
- * `actor`: NULL = system origin (well-known cells, daemon/agent cells).
22
+ * **Ownership columns**: `created_by` is a nullable FK to `actor`
23
+ * (`ON DELETE SET NULL`): NULL = system origin (well-known cells,
24
+ * daemon/agent cells), and the owner the edit and manage predicates read.
24
25
  * The non-admin authz path treats NULL `created_by` as admin-only via an
25
- * explicit equality check (`auth/cell_authorize.ts`).
26
+ * explicit equality check (`auth/cell_authorize.ts`). `updated_by` and
27
+ * `cell_grant.granted_by` are provenance stamps with no FK, as `fuz_auth`'s
28
+ * are (`drop_provenance_stamp_foreign_keys`): nothing authorizes on them, so
29
+ * they keep the id they were written with after a purge, and neither a
30
+ * purge's cascade nor a stamp write waits on the other.
26
31
  *
27
32
  * **Timestamp naming** (`created_at`, `updated_at`) aligns with fuz_app's
28
33
  * `_at`-everywhere convention used by `account`, `actor`, `audit_log`,
@@ -107,7 +112,7 @@ CREATE TABLE IF NOT EXISTS cell (
107
112
  updated_at TIMESTAMPTZ,
108
113
  deleted_at TIMESTAMPTZ,
109
114
  created_by UUID REFERENCES actor(id) ON DELETE SET NULL,
110
- updated_by UUID REFERENCES actor(id) ON DELETE SET NULL,
115
+ updated_by UUID,
111
116
  CHECK (policy IS NULL OR (parent_id IS NULL AND policy @> '{}'::jsonb))
112
117
  )`;
113
118
  /**
@@ -166,7 +171,7 @@ CREATE TABLE IF NOT EXISTS cell_grant (
166
171
  actor_id UUID REFERENCES actor(id) ON DELETE CASCADE,
167
172
  role TEXT,
168
173
  scope_id UUID,
169
- granted_by UUID REFERENCES actor(id) ON DELETE SET NULL,
174
+ granted_by UUID,
170
175
  created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
171
176
  CHECK (
172
177
  (actor_id IS NOT NULL AND role IS NULL AND scope_id IS NULL) OR
@@ -378,7 +378,7 @@ The rules a caller would miss:
378
378
  - **Defer, never schedule.** A thunk, not `Promise.resolve().then(fn)`: a microtask would run before the wrapping `COMMIT` resumes and announce state that may roll back.
379
379
  - **Discard on rollback, at the dispatch site.** Both dispatch sites (`http/route_spec.ts`, `actions/perform_action.ts`) wrap the handler in `dispatch_with_post_commit_rollback`, which truncates the deferred queue on a throw. A `transaction: false` handler that opens its own transaction (`/login`, `/password`, signup, bootstrap) runs it through `transaction_with_post_commit_rollback`, which discards what that transaction queued even when the handler catches the failure and answers normally. The eager queue is never truncated.
380
380
  - **Drain at the outer flush.** `flush_request_effects` is the one flush: the HTTP middleware in `server/app_server.ts` (awaited before the response under `await_pending_effects: true`, else left running) and the per-message WS flush (awaited after the reply is sent). It invokes the deferred thunks before awaiting the eager writes, so a connection close never waits behind a slow audit INSERT, and wraps each thunk in its own `try/catch`, so one failure can't starve its siblings. Eager rejections go to the log and `on_effect_error` (`{transport, method, path}`).
381
- - **Held from acceptance.** Every HTTP request and every WS message accepted for dispatch is held on the backend's one `RequestTracker` (`AppDeps.request_tracker`; `register_action_ws`'s `request_tracker` for a hand mount) from acceptance until its handler has returned and its flush has settled (`accept()` → `AcceptedRequest.finish(flush)`). `AppServer.close` waits for every held request, then the audit emitter's writes, repeating until both are empty, within `shutdown_drain_timeout_ms` — a handler still running when the close starts is waited for, then its flush (a WS handler's `signal` is aborted by the socket close first). Once it starts draining, the server's view of the tracker (`create_request_tracker_view`, closed by `close()`) refuses what arrives: an HTTP request answers 503 `service_unavailable` (the failed-checkout shape), and a WS message — reachable only on a socket the close-all didn't end (a hand mount) — the `service_unavailable` JSON-RPC error (`WS_SHUTTING_DOWN_MESSAGE`); the backend's tracker stays open for a later server. `_testing_drain_effects` waits only for the flushes (`drain_flushes`) and the audit writes, never a running handler: its own request is one, and its flush starts only after it answers. Never await `drain_inflight` — or `AppServer.close` — from inside a request: it waits on its own caller (`AppServer.close` until its bound). **Twin difference:** the Rust spine also waits for an HTTP request already dispatched, but at shutdown drops a WS message's dispatch still in its handler with its socket loop — it rolls back — while one whose commit has started finishes, its post-commit effects included; here every accepted message runs to completion and its reply is refused.
381
+ - **Held from acceptance.** Every HTTP request and every WS message accepted for dispatch is held on the backend's one `RequestTracker` (`AppDeps.request_tracker`; `register_action_ws`'s `request_tracker` for a hand mount) from acceptance until its handler has returned and its flush has settled (`accept()` → `AcceptedRequest.finish(flush)`). A WebSocket's open is held too, with no flush — admission's credential re-read, `on_socket_open`, and the start of the queued frames' dispatch (`finish(null)` on every path) — so a shutdown landing in a re-read waits for it rather than closing the database under it, as the Rust spine's upgrade hold does. `AppServer.close` waits for every held request, then the audit emitter's writes, repeating until both are empty, within `shutdown_drain_timeout_ms` — a handler still running when the close starts is waited for, then its flush (a WS handler's `signal` is aborted by the socket close first). Once it starts draining, the server's view of the tracker (`create_request_tracker_view`, closed by `close()`) refuses what arrives: an HTTP request answers 503 `service_unavailable` (the failed-checkout shape), and a WS message — reachable only on a socket the close-all didn't end (a hand mount) — the `service_unavailable` JSON-RPC error (`WS_SHUTTING_DOWN_MESSAGE`); the backend's tracker stays open for a later server. `_testing_drain_effects` waits only for the flushes (`drain_flushes`) and the audit writes, never a running handler: its own request is one, and its flush starts only after it answers. Never await `drain_inflight` — or `AppServer.close` — from inside a request: it waits on its own caller (`AppServer.close` until its bound). **Twin difference:** the Rust spine also waits for an HTTP request already dispatched, but at shutdown drops a WS message's dispatch still in its handler with its socket loop — it rolls back — while one whose commit has started finishes, its post-commit effects included; here every accepted message runs to completion and its reply is refused. The Rust upgrade hold (`ConnectionRegistry::hold_upgrade`) lasts the whole upgraded future, so its shutdown also waits for each socket's close (a refusal's included) to be written; here the hold ends with the open, and the close-all's frames are not waited for.
382
382
 
383
383
  ```typescript
384
384
  emit_after_commit(ctx, () => ctx.notification_sender.send_to_account(account_id, msg));
@@ -50,10 +50,10 @@
50
50
  * holds the connection for a drain window and then closes or, the body
51
51
  * untouched and arriving within the window, reads it off and serves the
52
52
  * next request.
53
- * - **Bun** closes at once, the body unread, honouring the header. Bun 1.4.3
54
- * is the tested floor: an older Bun kept the connection after the `413` and
55
- * served the next request (correctly framed), so run Bun at the floor or
56
- * later.
53
+ * - **Bun** closes at once, the body unread, honouring the header. Bun 1.4.4
54
+ * is the tested floor (CI's pin); the close needs 1.4.3 — an older Bun kept
55
+ * the connection after the `413` and served the next request (correctly
56
+ * framed) — so run Bun at the floor or later.
57
57
  *
58
58
  * @module
59
59
  */
@@ -50,10 +50,10 @@
50
50
  * holds the connection for a drain window and then closes or, the body
51
51
  * untouched and arriving within the window, reads it off and serves the
52
52
  * next request.
53
- * - **Bun** closes at once, the body unread, honouring the header. Bun 1.4.3
54
- * is the tested floor: an older Bun kept the connection after the `413` and
55
- * served the next request (correctly framed), so run Bun at the floor or
56
- * later.
53
+ * - **Bun** closes at once, the body unread, honouring the header. Bun 1.4.4
54
+ * is the tested floor (CI's pin); the close needs 1.4.3 — an older Bun kept
55
+ * the connection after the `413` and served the next request (correctly
56
+ * framed) — so run Bun at the floor or later.
57
57
  *
58
58
  * @module
59
59
  */
@@ -199,10 +199,14 @@ export declare const flush_request_effects: (pending_effects: ReadonlyArray<Prom
199
199
  * Every request the server accepted — an HTTP request, a WS message accepted
200
200
  * for dispatch — held from acceptance until its handler has returned and its
201
201
  * effect flush has settled, so `AppServer.close` can wait for both before the
202
- * database closes. One tracker per backend (`AppDeps.request_tracker`), shared
203
- * by every transport, so a request is held the same way whichever transport
204
- * accepted it. Its `drain_inflight` / `inflight_count` match `AuditEmitter`'s,
205
- * the other set the shutdown drain waits on.
202
+ * database closes. A WebSocket's open is held the same way, with no flush:
203
+ * from before its pending registration until its admission re-read,
204
+ * `on_socket_open`, and the start of its queued frames' dispatch are done
205
+ * (`actions/ws_socket_session.ts`). One tracker per backend
206
+ * (`AppDeps.request_tracker`), shared by every transport, so a request is
207
+ * held the same way whichever transport accepted it. Its `drain_inflight` /
208
+ * `inflight_count` match `AuditEmitter`'s, the other set the shutdown drain
209
+ * waits on.
206
210
  *
207
211
  * The flushes are held apart as well, for a drain that must not wait on a
208
212
  * running handler — `_testing_drain_effects`, whose own request is one: a
@@ -1 +1 @@
1
- {"version":3,"file":"pending_effects.d.ts","sourceRoot":"","sources":["../../src/lib/http/pending_effects.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAClC,sDAAsD;IACtD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,qEAAqE;IACrE,IAAI,EAAE,MAAM,CAAC;CACb;AAED;;;;;GAKG;AACH,MAAM,WAAW,sBAAsB;IACtC,mBAAmB,EAAE,KAAK,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;CACvD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,iBAAiB,G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