@fuzdev/fuz_app 0.181.0 → 0.182.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 (114) hide show
  1. package/dist/actions/CLAUDE.md +24 -6
  2. package/dist/actions/action_rpc.d.ts +11 -1
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +3 -2
  5. package/dist/actions/action_types.d.ts +16 -1
  6. package/dist/actions/action_types.d.ts.map +1 -1
  7. package/dist/actions/action_types.js +1 -1
  8. package/dist/actions/notification_sender.d.ts +83 -0
  9. package/dist/actions/notification_sender.d.ts.map +1 -0
  10. package/dist/actions/notification_sender.js +85 -0
  11. package/dist/actions/perform_action.d.ts +9 -0
  12. package/dist/actions/perform_action.d.ts.map +1 -1
  13. package/dist/actions/perform_action.js +22 -13
  14. package/dist/actions/register_action_ws.d.ts +14 -0
  15. package/dist/actions/register_action_ws.d.ts.map +1 -1
  16. package/dist/actions/register_action_ws.js +3 -2
  17. package/dist/actions/ws_socket_session.d.ts +3 -0
  18. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  19. package/dist/actions/ws_socket_session.js +2 -1
  20. package/dist/auth/CLAUDE.md +60 -41
  21. package/dist/auth/account_actions.d.ts.map +1 -1
  22. package/dist/auth/account_actions.js +13 -3
  23. package/dist/auth/account_queries.d.ts +158 -16
  24. package/dist/auth/account_queries.d.ts.map +1 -1
  25. package/dist/auth/account_queries.js +189 -18
  26. package/dist/auth/account_routes.d.ts +1 -1
  27. package/dist/auth/account_routes.d.ts.map +1 -1
  28. package/dist/auth/account_routes.js +27 -26
  29. package/dist/auth/admin_actions.d.ts.map +1 -1
  30. package/dist/auth/admin_actions.js +71 -28
  31. package/dist/auth/api_token_queries.d.ts +13 -5
  32. package/dist/auth/api_token_queries.d.ts.map +1 -1
  33. package/dist/auth/api_token_queries.js +24 -9
  34. package/dist/auth/bearer_auth.d.ts.map +1 -1
  35. package/dist/auth/bearer_auth.js +3 -2
  36. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  37. package/dist/auth/daemon_token_middleware.js +12 -1
  38. package/dist/auth/deps.d.ts +10 -0
  39. package/dist/auth/deps.d.ts.map +1 -1
  40. package/dist/auth/request_context.d.ts +73 -73
  41. package/dist/auth/request_context.d.ts.map +1 -1
  42. package/dist/auth/request_context.js +78 -96
  43. package/dist/auth/resolved_auth.d.ts +10 -5
  44. package/dist/auth/resolved_auth.d.ts.map +1 -1
  45. package/dist/auth/resolved_auth.js +2 -2
  46. package/dist/auth/role_grant_offer_action_specs.d.ts +1 -1
  47. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  48. package/dist/auth/role_grant_offer_action_specs.js +2 -1
  49. package/dist/auth/role_grant_offer_actions.d.ts +7 -11
  50. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  51. package/dist/auth/role_grant_offer_actions.js +61 -93
  52. package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
  53. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  54. package/dist/auth/role_grant_offer_notifications.js +75 -22
  55. package/dist/auth/role_grant_offer_queries.d.ts +96 -15
  56. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  57. package/dist/auth/role_grant_offer_queries.js +185 -70
  58. package/dist/auth/role_grant_offer_schema.js +1 -1
  59. package/dist/auth/role_grant_queries.d.ts +52 -12
  60. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  61. package/dist/auth/role_grant_queries.js +75 -24
  62. package/dist/auth/role_grant_sql.d.ts +21 -0
  63. package/dist/auth/role_grant_sql.d.ts.map +1 -1
  64. package/dist/auth/role_grant_sql.js +21 -0
  65. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  66. package/dist/auth/self_service_role_actions.js +9 -2
  67. package/dist/auth/session_queries.d.ts +34 -13
  68. package/dist/auth/session_queries.d.ts.map +1 -1
  69. package/dist/auth/session_queries.js +48 -18
  70. package/dist/auth/standard_rpc_actions.d.ts +6 -19
  71. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  72. package/dist/auth/standard_rpc_actions.js +5 -6
  73. package/dist/auth/token_scope.d.ts +1 -1
  74. package/dist/auth/token_scope.js +1 -1
  75. package/dist/http/CLAUDE.md +7 -6
  76. package/dist/http/auth_shape.d.ts +1 -1
  77. package/dist/http/error_schemas.d.ts +9 -21
  78. package/dist/http/error_schemas.d.ts.map +1 -1
  79. package/dist/http/error_schemas.js +14 -24
  80. package/dist/http/route_spec.d.ts +2 -2
  81. package/dist/server/app_backend.d.ts.map +1 -1
  82. package/dist/server/app_backend.js +3 -1
  83. package/dist/server/app_server.d.ts +26 -16
  84. package/dist/server/app_server.d.ts.map +1 -1
  85. package/dist/server/app_server.js +17 -7
  86. package/dist/server/serve_fact_route.d.ts +3 -3
  87. package/dist/server/serve_fact_route.js +12 -12
  88. package/dist/testing/CLAUDE.md +5 -5
  89. package/dist/testing/app_server.d.ts.map +1 -1
  90. package/dist/testing/app_server.js +3 -1
  91. package/dist/testing/auth_apps.js +1 -1
  92. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  93. package/dist/testing/cross_backend/account_lifecycle.js +43 -0
  94. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
  95. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  96. package/dist/testing/cross_backend/default_spine_surface.js +2 -6
  97. package/dist/testing/cross_backend/full_spine_mount.d.ts +3 -10
  98. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  99. package/dist/testing/cross_backend/full_spine_mount.js +4 -4
  100. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
  101. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  102. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +183 -30
  103. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  104. package/dist/testing/cross_backend/session_cap.js +26 -5
  105. package/dist/testing/middleware.d.ts +1 -1
  106. package/dist/testing/middleware.js +5 -5
  107. package/dist/testing/resolved_auth.d.ts +3 -1
  108. package/dist/testing/resolved_auth.d.ts.map +1 -1
  109. package/dist/testing/resolved_auth.js +4 -4
  110. package/dist/testing/stubs.d.ts.map +1 -1
  111. package/dist/testing/stubs.js +5 -2
  112. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  113. package/dist/testing/ws_round_trip.js +8 -4
  114. package/package.json +1 -1
@@ -16,9 +16,9 @@ documents the cross-cutting invariants that don't fit on any single symbol.
16
16
 
17
17
  ## AppDeps split
18
18
 
19
- - **Capabilities** — `AppDeps` — stateless, injectable per env: `keyring`, `password`, `db`, `log`, `audit`, `connection_closer` (the `RealtimeCloser` every revocation handler closes live connections through — `actions/CLAUDE.md` §Connection closer).
19
+ - **Capabilities** — `AppDeps` — stateless, injectable per env: `keyring`, `password`, `db`, `log`, `audit`, `connection_closer` (the `RealtimeCloser` every revocation handler closes live connections through — `actions/CLAUDE.md` §Connection closer), `notification_sender` (the `RealtimeNotificationSender` the dispatchers put on every `ActionContext` — `actions/CLAUDE.md` §Notification sender).
20
20
  - **Route caps** — `RouteFactoryDeps` — `Omit<AppDeps, 'db'>`; handlers get `db` via `RouteContext`.
21
- - **Action caps** — `ActionFactoryDeps` (`auth/deps.ts`) — the `{log, audit}` shape action factories take; `RouteFactoryDeps`/`AppDeps` satisfy it structurally (role-grant-offer adds `notification_sender?`). The factories whose handlers end credentials or revoke roles (`create_account_actions`, `create_admin_actions`, `create_role_grant_offer_actions`, `create_self_service_role_actions`, and the standard bundle) take `RevokingActionFactoryDeps` — `ActionFactoryDeps` plus a required `connection_closer`. The two pure-read actor factories (`actor_lookup`/`actor_search`) take only `{log: Logger}`.
21
+ - **Action caps** — `ActionFactoryDeps` (`auth/deps.ts`) — the `{log, audit}` shape action factories take; `RouteFactoryDeps`/`AppDeps` satisfy it structurally. The factories whose handlers end credentials or revoke roles (`create_account_actions`, `create_admin_actions`, `create_role_grant_offer_actions`, `create_self_service_role_actions`, and the standard bundle) take `RevokingActionFactoryDeps` — `ActionFactoryDeps` plus a required `connection_closer`. The two pure-read actor factories (`actor_lookup`/`actor_search`) take only `{log: Logger}`.
22
22
  - **Parameters** — `*Options` — static startup values, per-factory.
23
23
  - **Runtime state** — inline ref — mutable values: `bootstrap_status`, `DaemonTokenState`. NOT in deps or options.
24
24
 
@@ -74,17 +74,17 @@ Convention — `*_schema.ts` holds a domain's `@fuzdev/fuz_schema` schemas; `*_d
74
74
  - `auth/role_grant_offer_schema.ts` — `RoleGrantOffer`, `RoleGrantOfferJson` (a `@fuzdev/fuz_schema` `object`: `role` a `RoleName`, `scope_kind` a `ScopeKindName` or `null`, so an offer row holding a name off either grammar fails it), `to_role_grant_offer_json`.
75
75
  - `auth/role_grant_offer_ddl.ts` — `role_grant_offer` table + indexes + `ROLE_GRANT_OFFER_SCOPE_SENTINEL_UUID` / `_GLOBAL_TOKEN` + `ROLE_GRANT_OFFER_COLUMNS` and the shared `ROLE_GRANT_OFFER_WITH_GRANTOR_SELECT` CTE tail (homed here per the placement rule in `db/sql_columns.ts`).
76
76
  - `auth/role_grant_sql.ts` — the liveness predicates every grant and offer read shares: `role_grant_active_sql(alias)` (not revoked, not expired) and `offer_pending_predicate(alias)` (every `OFFER_TERMINAL_COLUMNS` entry null), twins of the Rust spine's. The frozen partial-index DDL keeps its literal text.
77
- - `auth/role_grant_offer_notifications.ts` — the WS notification specs for the consentful-grant lifecycle, their `@fuzdev/fuz_schema` params, builders, `role_grant_offer_notification_actions`, `role_grant_offer_notification_specs`, and `create_validated_notification_sender`.
77
+ - `auth/role_grant_offer_notifications.ts` — the WS notification specs for the consentful-grant lifecycle, their `@fuzdev/fuz_schema` params, builders, `role_grant_offer_notification_actions`, `role_grant_offer_notification_specs`, the post-commit send helpers `queue_offer_notification` / `queue_supersede_notifications` (`SupersedeAudience`, `SupersedeCause`), and `create_validated_notification_sender`.
78
78
 
79
79
  ### Queries
80
80
 
81
81
  All take `deps: QueryDeps = {db}` first; `query_validate_api_token` adds `log` and returns a `ValidatedApiToken` — the row with `scope` parsed, refusing (returning `undefined` for) a row whose stored scope is unreadable.
82
82
 
83
- - `auth/account_queries.ts` — account CRUD, actor resolution, password update with verify-write race guard, paged `query_admin_account_list`. Also the two locked re-checks a credential mint runs first in its transaction: `query_account_lock_verified(id, password_hash)` (login: the account is live and still holds the hash that was verified) and `query_account_lock_live(id)` (token create), each `FOR SHARE` on the account row — the lock a password change's or a delete's write to that row waits on, and waits for, so a mint in flight across either is refused or revoked, never left standing. `query_account_lock_live` is also what `invite_create` takes on its issuer before its insert, and `query_account_lock_live_many(ids)` locks several accounts in one statement in id order — what `query_role_grant_offer_create` takes on its recipient and its grantor. Every multi-account locker takes account rows in id order (the last-admin guard too), so none waits on another in the opposite order.
83
+ - `auth/account_queries.ts` — account CRUD, actor resolution, password update with verify-write race guard, paged `query_admin_account_list`, and the account-row locks every writer of an account takes first (§Row locks): `query_account_lock_verified` (login) and `query_account_lock_live` (token create), `query_account_lock_live_many` (offer and invite create), `query_account_lock_for_offer_accept`, `query_account_lock_for_revoke`, and the purge's `query_account_lock_admins_for_purge` then `query_account_lock_for_purge`.
84
84
  - `auth/actor_lookup_queries.ts` — batched `actor` ⨝ `account` for the labels arc; active actors of active accounts only.
85
85
  - `auth/actor_search_queries.ts` — case-insensitive prefix search on `actor.name`, scope-filtered when not admin; active actors of active accounts only.
86
86
  - `auth/role_grant_queries.ts` — idempotent create, IDOR-guarded revoke (with in-tx supersede), scope-aware lookup, role/account predicates, `query_role_grant_revoke_for_scope` parent-scope cascade.
87
- - `auth/role_grant_offer_queries.ts` — offer create/decline/retract/list/history/sweep, atomic `query_accept_offer` with sibling supersede; error classes `RoleGrantOfferSelfTargetError` / `_AlreadyTerminalError` / `_ExpiredError` / `_NotFoundError` / `_ActorAccountMismatchError` / `_ActorMismatchError`.
87
+ - `auth/role_grant_offer_queries.ts` — offer create/decline/retract/list/history/sweep, atomic `query_accept_offer` with sibling supersede (a recipient deleted in flight answers the dead credential's 401), and the offer-row lockers `query_role_grant_offer_lock_for_account_removal` / `_for_revoke` over `offer_rows_locked_in_id_order` (`role_grant_sql.ts`; §Row locks); error classes `RoleGrantOfferSelfTargetError` / `_AlreadyTerminalError` / `_ExpiredError` / `_NotFoundError` / `_ActorAccountMismatchError` / `_ActorMismatchError`.
88
88
  - `auth/session_queries.ts` — server-side sessions (blake3-hashed), `create_capped_session` (the one session minter: the row, the cap's evictions, and the signed cookie value — Hono-free, so the bootstrap transaction mints through it; twin of the Rust `create_capped_session`), `query_session_revoke_by_hash_unscoped` (logout only), `query_session_enforce_limit` (transaction-required; returns the evicted sessions' ids — their token hashes — so the caller closes their connections after the commit), `query_session_cleanup_expired` (returns the swept sessions' ids for the same close — `cleanup_expired_sessions` is its caller). No touch/renewal query — `expires_at` is an absolute cap set at mint (`AUTH_SESSION_LIFETIME_MS`). `query_session_is_live(id, account_id)` is the re-read `account_token_create` runs after the account lock: the session that authorized the mint must still exist.
89
89
  - `auth/api_token_queries.ts` — token validation (`query_validate_api_token`, which records nothing) and the separate fire-and-forget usage record (`query_api_token_touch`, which the bearer leg runs only once the token's account is found live), `query_api_token_live_account` (the by-id, no-touch re-check read; shares the `API_TOKEN_IS_LIVE` predicate with the validate query so the two can't drift), IDOR-guarded revoke, `query_api_token_enforce_limit` (transaction-required; returns the evicted tokens' ids for the same post-commit close).
90
90
  - `auth/invite_queries.ts` — invite create/find/claim/list/delete; `query_invite_claim_unscoped` (scoping enforced upstream by `_find_unclaimed_match_for_update`, which runs inside the signup tx with `FOR UPDATE` so find + claim are atomic).
@@ -254,9 +254,9 @@ Everything else listed under §RPC action surfaces.
254
254
  ### Middleware
255
255
 
256
256
  - `auth/middleware.ts` — `create_auth_middleware_specs(deps, options)` assembles `[origin, daemon_token?, session, request_context, bearer_auth]`, the `daemon_token` layer only when given a `daemon_token_state` — the credential legs in the Rust spine's `resolve_auth_from_headers` order, daemon token → session cookie → bearer, the first that authenticates setting `ResolvedAuth` and the later ones skipping. The chain starts from a clean slate: the first leg composed — the daemon token's, else the session's (`create_request_context_middleware`'s `starts_chain`, which the stack sets `false` behind the daemon leg) — clears `RESOLVED_AUTH_KEY` on entry, so a layer mounted before the stack can't pre-set an identity every leg would skip past, and debug-logs a clear that finds one — the trace of a hand-built chain whose session leg sits behind its own earlier leg without `starts_chain: false` (the content-type refusal isn't a middleware: `apply_route_specs` checks every `POST` route, see `http/simple_request.ts`). The origin check mounts on every path (`ORIGIN_MIDDLEWARE_PATH`, `'*'`), less its `origin_carve_outs` — each a `MiddlewareCarveOut` (`{path, reason}`, copied and frozen at assembly by `freeze_origin_carve_outs`, refused by `assert_origin_carve_outs_valid` without a reason or when it overlaps the auth scope — `middleware_paths_overlap` against `AUTH_MIDDLEWARE_PATH`, which holds every credential-reading and credential-minting route — and recorded on the origin spec so the surface leaves its `403` off the carved routes); `AUTH_MIDDLEWARE_PATH` (`'/api/*'`) is where `create_app_server` mounts the rest of the stack; assembly asserts lean on it: `assert_endpoint_in_auth_scope` (an `rpc_endpoints` / `ws_endpoints` path, or the bootstrap route under `bootstrap.route_prefix`, must sit inside it — so no carve-out can reach one), `assert_credential_routes_in_auth_scope(route_specs)` (every registered route that reads a credential — `auth.account` not `'none'`, or marked `reads_credential`, as account status is — or is marked `mints_credential` — login, signup, bootstrap — must sit inside it too, so a consumer prefixing the relative account or signup specs outside `/api/` is refused), and `assert_middleware_stack_mounted(stack_specs, middleware_specs)`, run on a `transform_middleware` result against the pre-transform stack (`[host?, proxy, ...auth]`) — each stack spec, matched by its `handler` closure (not its spoofable `name`), mounted exactly once at its original path (`'*'` for the host gate, the trusted proxy and the origin check, `AUTH_MIDDLEWARE_PATH` for the rest of auth), in its original order; other specs may sit anywhere, including before the proxy and between the auth layers. The proxy is in the stack because dropping it turns every `get_client_ip` into `'unknown'`, one shared bucket for every IP-keyed limiter. The transform receives shallow copies in a fresh array, so an in-place mutation can't rewrite the originals the check reads. The check pins where those layers sit, not what added layers do — a layer you add runs with full context access. Both run in `create_test_app_surface_spec` too.
257
- - `auth/request_context.ts` — `RequestContext`, `resolve_acting_actor`, `build_request_context`, predicates (`has_scoped_role`, `has_any_scoped_role` — the dispatcher's role gate and every builtin-role check read the **global** grant via `has_scoped_role(_, role, null)` / `has_any_scoped_role(_, roles, null)`), guards (`require_auth`, `require_role`, `require_credential_types`, `require_token_scope`), `token_scope_surface_denial` (the direct-call form, for surfaces that aren't route specs), `get_public_account_id(route)` (the account id a `reads_credential` route may read, off the route context's `credential` — `null` for a scope-narrowed token, which such a route answers as anonymous; twin of the Rust `AuthGate::public_request_context` downgrade), `RequestContextForAuth` (the request context a spec's `auth` promises its handler — the one narrowing a route handler's `route.auth` and an action handler's `ctx.auth` share), `refresh_role_grants`.
257
+ - `auth/request_context.ts` — `RequestContext`, `resolve_acting_actor`, `build_request_context`, predicates (`has_scoped_role`, `has_any_scoped_role` — the dispatcher's role gate and every builtin-role check read the **global** grant via `has_scoped_role(_, role, null)` / `has_any_scoped_role(_, roles, null)`), guards (`require_auth`, `require_role`, `require_credential_types`, `require_token_scope`), `token_scope_surface_denial` (the direct-call form, for surfaces that aren't route specs), `get_public_account(route)` (the account a `reads_credential` route may read, off the route context's `credential` — `null` for a scope-narrowed token, which such a route answers as anonymous; twin of the Rust `AuthGate::public_request_context` downgrade), `RequestContextForAuth` (the request context a spec's `auth` promises its handler — the one narrowing a route handler's `route.auth` and an action handler's `ctx.auth` share), `refresh_role_grants`.
258
258
  - `auth/session_middleware.ts` — `create_session_middleware` (reads the cookie through `read_session_cookie_value`, never a framework cookie parser; puts the clear for a cookie that is present and invalid on the context's prepared headers before the handler runs, so every response built through the context carries it once — every route result, which the spine emits there after the commit, ahead of the success's own cookie lines, and the middleware's and error handlers' answers. It never reads or rewrites a response: doing so changes framing and content type on the runtimes' own `Response` classes. What still carries no clear is what the route system doesn't build — a consumer's own middleware or raw Hono route answering with a `Response` it made or replacing the context's `Set-Cookie`, and an accepted WebSocket upgrade's placeholder — where the Rust stack's cookie-clear layer clears every non-`101`. The middleware records the clear line it wrote (`EXPECTED_FIRST_SET_COOKIE_KEY`), and in DEV an answer that doesn't lead with it is logged (`http/dev_set_cookie_check.ts`), the upgrade excepted), `get_session_cookie`. A route sets or clears the session cookie on its success result (`route_ok(value, {set_cookie})`) with `session_cookie_header` / `clear_session_cookie_header` of `auth/session_cookie.ts`; nothing in fuz_app writes a cookie on the context but the middleware's clear. Login, signup and bootstrap each mint through `create_capped_session` (`auth/session_queries.ts`) inside a transaction of their own.
259
- - `auth/resolved_auth.ts` — `ResolvedAuth`, the resolved credential as one value — a union on `credential_type`, each arm carrying only its own fields: `session` (`account_id`, `session_hash`, `credential_deadline`), `api_token` (`account_id`, `api_token_id`, `scope`, `credential_deadline`), `daemon_token` (`account_id`, `credential_deadline: null`); `get_resolved_auth(c)` (reads it off `RESOLVED_AUTH_KEY`, the one context key every auth leg writes); the accessors `resolved_auth_scope` (an API token's scope, `full` for a session or daemon token, `null` for anonymous — every token-scope gate reads it), `resolved_auth_session_hash`, and `resolved_auth_api_token_id`; and `revalidate_resolved_auth(deps, resolved)`, the no-touch re-read a long-lived connection runs once it is registered: session row / token row (by id) still live and still on the account, account not soft-deleted; a daemon token re-reads its account only. Reuses the middleware's own queries and predicates. Called by the WS socket session (`actions/ws_socket_session.ts`) and the audit SSE route between registering a connection pending and admitting it. Twin of the Rust `revalidate_resolved_auth`.
259
+ - `auth/resolved_auth.ts` — `ResolvedAuth`, the resolved credential as one value — a union on `credential_type`, each arm carrying only its own fields: `session` (`account`, `session_hash`, `credential_deadline`), `api_token` (`account`, `api_token_id`, `scope`, `credential_deadline`), `daemon_token` (`account`, `credential_deadline: null`) — `account` the row the credential leg read, which the authorization phase builds on rather than reading the account again, as the Rust `ResolvedAuth::account` does (the daemon leg reads the keeper's row per request); `get_resolved_auth(c)` (reads it off `RESOLVED_AUTH_KEY`, the one context key every auth leg writes); the accessors `resolved_auth_scope` (an API token's scope, `full` for a session or daemon token, `null` for anonymous — every token-scope gate reads it), `resolved_auth_session_hash`, and `resolved_auth_api_token_id`; and `revalidate_resolved_auth(deps, resolved)`, the no-touch re-read a long-lived connection runs once it is registered: session row / token row (by id) still live and still on the account, account not soft-deleted; a daemon token re-reads its account only. Reuses the middleware's own queries and predicates. Called by the WS socket session (`actions/ws_socket_session.ts`) and the audit SSE route between registering a connection pending and admitting it. Twin of the Rust `revalidate_resolved_auth`.
260
260
  - `auth/credential_deadline.ts` — when a resolved credential stops authenticating, which a WebSocket or audit stream opened on it closes at (expiry writes nothing a revocation listener hears): `credential_deadline_after` (the earliest remaining lifetime, anchored to `performance.now()`), `EXPIRES_IN_MS_SQL` (a row's `expires_at - NOW()`, read on the database clock in the statement that checks it, so the session and token validation queries return `expires_in_ms`), and `schedule_credential_deadline` (a chain of timers of at most `CREDENTIAL_DEADLINE_TIMER_CAP_MS`, an hour — a 30-day session is past `setTimeout`'s ceiling — each wake-up also checking a wall-clock copy of the deadline, so a host suspend, which stops the monotonic clock, delays the close by at most one timer after the resume). The middleware sets it on `ResolvedAuth.credential_deadline`: session — the earlier of the cookie's signed expiry (`SESSION_COOKIE_EXPIRES_AT_KEY`, set by the session middleware) and the row's; bearer — the row's, none for an eternal token; daemon token — none. Twin of the Rust `ResolvedAuth::credential_deadline`.
261
261
  - `auth/bearer_auth.ts` — soft-fail bearer middleware; reads the header through `read_bearer_token` (one line, `Bearer` in any case, one SP, an `is_api_token_shaped` value — anything else, a repeated `Authorization` line included, is no credential and costs no query), and discards the token when the request carries any `Origin` or `Referer` line, an empty one included (browser context, `is_browser_context`). The scope it sets is the one the query parsed — there is no fallback. The last credential leg: it skips before reading the header when the daemon token or a session already resolved the request, so a bearer sent beside one is never looked up and its `last_used_at` / `last_used_ip` never move. A token whose account is tombstoned is no credential either — the anonymous answer, no use recorded.
262
262
  - `auth/daemon_token_middleware.ts` — `create_daemon_token_middleware(state, deps, log)` — the credential **consumer** only (soft-fail validation, keeper account resolution). The producer (`write_daemon_token` / `start_daemon_token_rotation`) lives in `testing/daemon_token_rotation.ts` behind the dev-env guard — no production assembly mints daemon tokens, mirroring the Rust spine's `fuz_testing`-confined producer. Soft-fails — discards the credential (pass-through, no own 401/503) on **every** non-success path: browser context (any `Origin` or `Referer` line, an empty one included), malformed/invalid token (anything `read_daemon_token` does not read: off-shape, or the header sent twice), and valid-token-but-no-keeper all `next()` through to the dispatcher's `credential_type_required` (403) gate, mirroring the bearer guard and the Rust spine's `resolve.rs`. Daemon tokens are loopback-only, so browser context never arises in practice — the discard is defense-in-depth. The first credential leg, so it clears `RESOLVED_AUTH_KEY` on entry; a valid daemon token sets the `daemon_token` arm, and the session and bearer legs after it skip, so a cookie or bearer sent beside it is never looked up — as on the Rust spine, whose resolve walk never reads the cookie (its cookie-clear layer still verifies one, to clear it when invalid — as the session middleware here does). A discarded daemon token falls through to them.
@@ -457,11 +457,14 @@ with `RequestContext.actor: null`.
457
457
  without touching the Hono context. Each transport binds the same failure to
458
458
  its wire shape: REST `c.json(body, status)`; HTTP RPC + WS fold into a
459
459
  JSON-RPC envelope where `error.message` is the reason string and
460
- `error.data: {reason, ...rest}` flattens diagnostic fields. The 500 reasons
461
- stay distinct: `no_actors_on_account` (signup invariant violation),
462
- `account_vanished` (torn read after resolve — the session and bearer legs
463
- already resolve a tombstoned account as no credential, so this is only an
464
- account removed between the leg and the authorization phase).
460
+ `error.data: {reason, ...rest}` flattens diagnostic fields. The one 500
461
+ reason is `no_actors_on_account` (signup invariant violation: a live account
462
+ with no active actor). The phase builds on the account row the credential leg
463
+ read, so an account deleted or purged after that read runs an account-grain
464
+ handler on that row, as on the Rust spine. An actor-grain one finds no actor,
465
+ and the one read that tells the two cases apart answers a removed account
466
+ with the dead credential's 401 (`authentication_required`). `account_verify`
467
+ re-reads the account live and answers the same 401.
465
468
 
466
469
  **Production-middleware invariant.** No production middleware on the auth
467
470
  path populates `REQUEST_CONTEXT_KEY`; it sets only `RESOLVED_AUTH_KEY`. Test
@@ -476,6 +479,16 @@ under `SESSION_TOKEN_KEY` (`hono_context.ts`, `'auth_session_id'`) and the
476
479
  session leg reads it there; `SessionOptions` carries no context key, so the two
477
480
  cannot disagree and the token cannot land on another spine key.
478
481
 
482
+ ### Row locks
483
+
484
+ One class order in every transaction — accounts, then offers, then grants and
485
+ actors — and id order within a class. Every writer of an account takes its row
486
+ first (two mints of one account take turns there, so the caps hold); a
487
+ multi-row write (credential deletes, offer cascades, the expiry sweeps) locks
488
+ its rows in one id-ordered statement before writing. Each lock's strength and
489
+ reason is on its query's TSDoc; the rule set: ../../../docs/security.md §Row
490
+ Locks. `lock_pins.cross.test.ts` pins them on both spines (../../test/CLAUDE.md).
491
+
479
492
  ### Wire timestamp shape
480
493
 
481
494
  Every timestamp on the wire is **second-precision UTC** —
@@ -601,8 +614,11 @@ account event plus one per-actor event (`delete` = soft, `purge` = hard,
601
614
  "Account-removal target guards").
602
615
 
603
616
  `role_grant_offer_supersede` carries
604
- `reason: 'sibling_accepted' | 'role_grant_revoked' | 'scope_destroyed' | 'account_deleted'` (for `account_deleted`, `cause_id` is the removed account, the grantor's or the recipient's; the WS `_supersede` notification never carries it — an account removal notifies no one)
605
- plus `cause_id` pointing to the row that triggered the supersede.
617
+ `reason: 'sibling_accepted' | 'role_grant_revoked' | 'scope_destroyed' | 'account_deleted'` (for `account_deleted`, `cause_id` is the removed account, the grantor's or the recipient's)
618
+ plus `cause_id` pointing to the row that triggered the supersede. The WS
619
+ `role_grant_offer_supersede` notification's reason set is narrower —
620
+ `sibling_accepted | role_grant_revoked | account_deleted`; `scope_destroyed`
621
+ is an audit reason only (a consumer's own cascade writes it).
606
622
 
607
623
  ### Keeper auth shape
608
624
 
@@ -708,7 +724,7 @@ authenticate.
708
724
 
709
725
  - `admin_account_list_action_spec` — read; input `{limit?, offset?, include_deleted?}`; output `{accounts, grantable_roles}`. On it and the other paged reads (`audit_log_list`, `audit_log_role_grant_history`, `role_grant_offer_history`) `limit` / `offset` declare `invalid_reason` `ERROR_LIMIT_INVALID` / `ERROR_OFFSET_INVALID` (`http/error_schemas.ts`), and `audit_log_list`'s `since_seq` / `outcome` `ERROR_SINCE_SEQ_INVALID` / `ERROR_OUTCOME_INVALID`: every refusal of the field carries it. `include_deleted` (default false) surfaces soft-deleted rows (with `account.deleted_at` set) for the admin UI's reactivation view.
710
726
  - `account_delete_action_spec` — mutation (soft delete); self-or-admin (`{account, actor}`, handler elevates to admin when `account_id` ≠ self); the self path is session-only, handler-enforced ahead of the target guards (an API or daemon token gets the dispatcher's `ERROR_CREDENTIAL_TYPE_REQUIRED` 403 via `credential_type_required_error`), while an admin deleting another account keeps any credential; input `{account_id?}`; output `{ok, deleted}`. Tombstones account + actor(s), supersedes every pending offer the account made and every pending offer made to it (`reason: 'account_deleted'`, an audit row each), revokes sessions/tokens, deletes the unclaimed invites the account issued (an `invite_delete` row each), emits `account_delete` + per-actor `actor_delete`. Role grants are kept — inert while the account is tombstoned. Refuses a keeper-role target (`ERROR_CANNOT_DELETE_KEEPER`) or the sole active admin (`ERROR_CANNOT_DELETE_LAST_ADMIN`) — both fail-loud with a failure-audit row.
711
- - `account_purge_action_spec` — mutation (hard purge); keeper-only (`credential_types: ['daemon_token']` + `roles: ['keeper']`) + `confirm: true` + WARN; input `{account_id, confirm?}`; output `{ok, purged}`. Supersedes the account's outgoing offers and deletes the unclaimed invites it issued, then the cascading delete; emits `account_purge` + per-actor `actor_purge` (identity snapshot survives in metadata since `audit_log` ids carry no FK). Refuses a keeper-role target (`ERROR_CANNOT_DELETE_KEEPER`) or the sole active admin (`ERROR_CANNOT_DELETE_LAST_ADMIN`).
727
+ - `account_purge_action_spec` — mutation (hard purge); keeper-only (`credential_types: ['daemon_token']` + `roles: ['keeper']`) + `confirm: true` + WARN; input `{account_id, confirm?}`; output `{ok, purged}`. Supersedes the offers the account made and those made to it (audited and notified, as `account_delete` does), deletes the unclaimed invites it issued, revokes its sessions and tokens, then the cascading delete (its locks: §Row locks); emits `account_purge` + per-actor `actor_purge` (identity snapshot survives in metadata since `audit_log` ids carry no FK). Refuses a keeper-role target (`ERROR_CANNOT_DELETE_KEEPER`) or the sole active admin (`ERROR_CANNOT_DELETE_LAST_ADMIN`).
712
728
  - `account_undelete_action_spec` — mutation (reactivation, inverse of soft delete); admin-only (`roles: ['admin']` — no self path, a tombstoned account can't authenticate); input `{account_id}`; output `{ok, undeleted}`. Clears the `deleted_at` tombstone on the account + its actor(s), emits `account_undelete` + per-actor `actor_undelete`. Restores the account, its actors and its role grants as they were; does not restore revoked sessions/tokens, superseded offers, or deleted invites.
713
729
  - `admin_session_list_action_spec` — read; input `{acting?}` (an omitted input reads as `{}`); output `{sessions}`.
714
730
  - `admin_session_revoke_all_action_spec` — mutation; input `{account_id}`; output `{ok, count}`.
@@ -795,15 +811,14 @@ the list and history inputs read an omitted input as a fresh `{}`
795
811
  A global `admin` grant is guarded: the keeper account's is refused
796
812
  (`ERROR_CANNOT_REVOKE_KEEPER_ADMIN`, 403) and so is one whose revoke would
797
813
  leave no active admin account (`ERROR_CANNOT_REVOKE_LAST_ADMIN`, 403, under
798
- the locked count `query_count_active_accounts_with_global_role_for_update`,
799
- which leaves the revoked grant out). Besides the
800
- revokee's incoming sibling offers, the revoke supersedes every pending offer
801
- the revokee's actor made (`query_role_grant_offer_supersede_outgoing`) —
802
- `account_delete` / `account_purge` do the same for every actor of the account
803
- (`reason: 'account_deleted'`, audited, no notification), and `account_delete`
804
- also supersedes every pending offer made TO the account
805
- (`query_role_grant_offer_supersede_incoming`, same reason). Every supersede
806
- cascade returns — and audits — its rows ordered by `created_at, id`.
814
+ the locked count `query_count_active_accounts_with_global_role_locked`,
815
+ which leaves the revoked grant out — §Row locks). Besides the revokee's
816
+ incoming sibling offers, the revoke supersedes every pending offer the
817
+ revokee's actor made (`query_role_grant_offer_supersede_outgoing`);
818
+ `account_delete` / `account_purge` supersede both directions for the whole
819
+ account (`reason: 'account_deleted'`). Every supersede cascade returns —
820
+ and audits and notifies — its rows ordered by `created_at, id`; who is
821
+ told: §WS notifications.
807
822
  - `role_grant_assign_action_spec` — global-admin-only immediate conferral (no
808
823
  consent step); input `{to_account_id, to_actor_id?, role, scope_kind?, scope_id?}`
809
824
  (the pair as on offer-create); output `{ok, role_grant_id}`. The handler:
@@ -857,7 +872,7 @@ becomes a grant) refuses a `keeper` offer (`ERROR_ROLE_GRANT_OFFER_ROLE_NOT_GRAN
857
872
  a scoped `admin` offer (`invalid_request` + `ERROR_ROLE_GRANT_BUILTIN_SCOPED`), and a
858
873
  builtin offer whose grantor no longer holds an active global `admin` on an
859
874
  active actor of an active account (`ERROR_ROLE_GRANT_OFFER_NOT_AUTHORIZED`,
860
- re-checked under `FOR SHARE` so a racing revoke is ordered against it) — via
875
+ read under the grantor's account lock) — via
861
876
  `RoleGrantOfferBuiltinRefusedError` (`refusal: BuiltinOfferRefusal`). Each
862
877
  refusal leaves the offer pending and is audited as a failed
863
878
  `role_grant_offer_accept` with `{offer_id, role, scope_id, reason}`. The
@@ -893,9 +908,17 @@ Post-commit via `emit_after_commit` (see `http/CLAUDE.md` §Pending Effects):
893
908
 
894
909
  - Create — `role_grant_offer_received` → recipient.
895
910
  - Retract — `role_grant_offer_retracted` → recipient.
896
- - Accept — `role_grant_offer_accepted` → grantor + `_supersede` per sibling.
911
+ - Accept — `role_grant_offer_accepted` → grantor; `_supersede` per sibling → its grantor (the caller's answer lists the siblings).
897
912
  - Decline — `role_grant_offer_declined` → grantor.
898
- - Revoke (`role_grant_revoke`) — `role_grant_revoked` → revokee + `_supersede` per superseded offer (the revokee's incoming siblings and its own outgoing offers, each to its grantor).
913
+ - Revoke (`role_grant_revoke`) — `role_grant_revoked` → revokee + `_supersede` per superseded offer (the revokee's incoming siblings and its own outgoing offers), each to its grantor and its recipient.
914
+ - Delete / purge (`account_delete`, `account_purge`) — `_supersede` (`account_deleted`) per superseded offer to the live party: the recipient of each offer the account made, the grantor of each offer made to it. The removed account hears nothing (its sockets close).
915
+ - Self-service disable — `_supersede` per incoming sibling, to its grantor and to the caller (its answer lists no offers).
916
+
917
+ `queue_supersede_notifications(ctx, offers, reason, audience)` sends them in
918
+ the cascade's row order, grantor before recipient; the `SupersedeAudience`
919
+ names the `cause_id` each told party gets (a recipient told of its grantor's
920
+ removal gets the grantor's actor, never its account id — TSDoc on
921
+ `SupersedeAudience`).
899
922
 
900
923
  Spec module is `auth/role_grant_offer_notifications.ts` —
901
924
  `RemoteNotificationActionSpec`s with `@fuzdev/fuz_schema` params schemas and
@@ -910,23 +933,19 @@ notification is `role_grant_revoked`, not the admin action's
910
933
  `role_grant_revoke`, so the two methods never collide. They never reach
911
934
  dispatch: an inbound frame for one is answered `method_not_found`. They are not SSE events; `role_grant_offer_notification_specs`
912
935
  holds them as `EventSpec`s for a consumer that broadcasts them on an SSE
913
- channel of its own. Under DEV, `create_role_grant_offer_actions` wraps the
914
- sender in `create_validated_notification_sender`, which checks each params
915
- object against its spec's `input` and logs a mismatch, sending it either way;
916
- production sends unchecked.
936
+ channel of its own. Handlers send through `ctx.notification_sender`
937
+ (`actions/CLAUDE.md` §Notification sender) with `queue_offer_notification` /
938
+ `queue_supersede_notifications`, each queued post-commit.
917
939
 
918
- Deps: `RevokingActionFactoryDeps & {notification_sender?: NotificationSender | null}`.
940
+ Deps: `RevokingActionFactoryDeps`.
919
941
  `role_grant_revoke` of a global grant queues a close of the revokee account's
920
942
  connections gated on the role (`queue_connection_close`, `{kind: 'role'}`),
921
943
  run after the transaction commits and independent of the audit row's
922
944
  announcement; the revocation guard repeats it on the announced row. A scoped revoke
923
945
  closes nothing — a role gate admits on global grants alone.
924
- `NotificationSender` is the narrow structural capability
925
- (`send_to_account(account_id, message): number`); `ConnectionRegistry`
926
- satisfies it structurally. Target account travels via the send argument, not
927
- the payload — `revoked_by` is deliberately not in the `role_grant_revoked`
928
- payload (the revokee doesn't need to learn the admin's identity). When
929
- `notification_sender` is absent, WS fan-out is silently skipped.
946
+ Target account travels via the send argument, not the payload — `revoked_by`
947
+ is deliberately not in the `role_grant_revoked` payload (the revokee doesn't
948
+ need to learn the admin's identity).
930
949
 
931
950
  Options: `roles?: RoleRegistry` (drives admin-grant-path lookup),
932
951
  `default_ttl_ms?` (defaults to `ROLE_GRANT_OFFER_DEFAULT_TTL_MS` = 30 days),
@@ -980,9 +999,9 @@ app-settings methods are always wired). Frontend mirror is
980
999
 
981
1000
  Option routing — `roles` is shared between admin + role-grant-offer;
982
1001
  `default_ttl_ms` + `authorize` → role-grant-offer
983
- only; `max_tokens` → account only. On `deps`: `notification_sender` →
984
- role-grant-offer only; `connection_closer` (required) → admin, account, and
985
- role-grant-offer (the role revoke's close).
1002
+ only; `max_tokens` → account only. On `deps`: `connection_closer`
1003
+ (required) → admin, account, and role-grant-offer (the role revoke's close).
1004
+ The notification sender is on every action's context, not on `deps`.
986
1005
 
987
1006
  Pair with `create_app_server`'s `rpc_endpoints` factory form
988
1007
  `(ctx) => Array<RpcEndpointSpec>` so the combined action list gets
@@ -1 +1 @@
1
- {"version":3,"file":"account_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA2BhG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA0B3D,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,yBAAyB,EAC/B,UAAS,oBAAyB,KAChC,KAAK,CAAC,SAAS,CAgNjB,CAAC"}
1
+ {"version":3,"file":"account_actions.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,OAAO,EAAsC,KAAK,SAAS,EAAE,MAAM,4BAA4B,CAAC;AA2BhG,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,WAAW,CAAC;AA0B3D,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACpC;;;;;OAKG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,GAClC,MAAM,yBAAyB,EAC/B,UAAS,oBAAyB,KAChC,KAAK,CAAC,SAAS,CA6NjB,CAAC"}
@@ -33,7 +33,7 @@ import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
33
33
  import { ERROR_AUTHENTICATION_REQUIRED } from '../http/error_schemas.js';
34
34
  import { queue_connection_close } from '../actions/connection_closer.js';
35
35
  import { to_session_account } from './account_schema.js';
36
- import { query_account_lock_live } from './account_queries.js';
36
+ import { query_account_by_id, query_account_lock_live } from './account_queries.js';
37
37
  import { query_session_is_live, query_session_list_for_account, query_session_revoke_for_account, query_session_revoke_all_for_account } from './session_queries.js';
38
38
  import { query_api_token_enforce_limit, query_api_token_list_for_account, query_create_api_token, query_revoke_api_token_for_account } from './api_token_queries.js';
39
39
  import { parse_stored_token_scope, serialize_token_scope, token_scope_from_input, token_scope_label } from './token_scope.js';
@@ -56,8 +56,18 @@ import { account_verify_action_spec, account_session_list_action_spec, account_s
56
56
  export const create_account_actions = (deps, options = {}) => {
57
57
  const { max_tokens = DEFAULT_MAX_TOKENS } = options;
58
58
  const { connection_closer } = deps;
59
- const verify_handler = (_input, ctx) => {
60
- return to_session_account(ctx.auth.account);
59
+ // The account read again, live: the answer is the account itself, so one
60
+ // deleted or purged since the credential leg is the dead credential's 401,
61
+ // not a description of a removed account. The Rust twin reads its summary
62
+ // the same way.
63
+ const verify_handler = async (_input, ctx) => {
64
+ const account = await query_account_by_id(ctx, ctx.auth.account.id);
65
+ if (!account) {
66
+ throw jsonrpc_errors.unauthenticated('unauthenticated', {
67
+ reason: ERROR_AUTHENTICATION_REQUIRED
68
+ });
69
+ }
70
+ return to_session_account(account);
61
71
  };
62
72
  const session_list_handler = async (_input, ctx) => {
63
73
  const sessions = await query_session_list_for_account(ctx, ctx.auth.account.id);
@@ -42,8 +42,8 @@ export declare const query_create_account: (deps: QueryDeps, input: CreateAccoun
42
42
  /**
43
43
  * Find an **active** account by id (`deleted_at IS NULL`).
44
44
  *
45
- * This is the auth-resolution workhorse (`build_request_context` /
46
- * `build_account_context`) and the admin-target lookup, so it
45
+ * This is the auth-resolution workhorse (every credential leg reads the
46
+ * account through it) and the admin-target lookup, so it
47
47
  * deliberately excludes soft-deleted accounts: a tombstoned account must
48
48
  * not authenticate (`delete` = soft, `purge` = hard). Purge, which must operate on
49
49
  * soft-deleted rows too, uses `query_purge_account` directly.
@@ -110,9 +110,24 @@ export declare const query_update_account_password: (deps: QueryDeps, id: string
110
110
  * writers write the account row before they revoke, which is what makes the
111
111
  * lock order them.
112
112
  *
113
- * `FOR SHARE` is the weakest lock that conflicts with their `UPDATE`s (the
114
- * session insert's foreign-key `FOR KEY SHARE` does not), and concurrent
115
- * logins of one account share it. Twin of the Rust
113
+ * `FOR NO KEY UPDATE`, the strength of their `UPDATE`s, so it also conflicts
114
+ * with itself: the mints of one account take turns. The session cap needs
115
+ * that. A mint inserts its session and evicts the oldest past the cap in one
116
+ * transaction, and two mints running together each count without the other's
117
+ * uncommitted row — both commit above the cap — while their evictions lock
118
+ * the same old rows in orders the query plan picks, and can deadlock. Taken
119
+ * in turn, the second mint runs its statements after the first commits and
120
+ * counts its row. The foreign-key `FOR KEY SHARE` of a row inserted under the
121
+ * account does not conflict with it, so no write that merely references the
122
+ * account waits on a login. Besides the writers it orders against, it
123
+ * conflicts with `query_account_lock_live` (the token mint, the same
124
+ * strength), the `FOR SHARE` of `query_account_lock_live_many` (an offer or
125
+ * invite create), an offer accept's locks (`query_account_lock_for_offer_accept`,
126
+ * the recipient's at this strength, a grantor's shared), and the last-admin
127
+ * guard's `FOR NO KEY UPDATE`. None of
128
+ * those waits on an account row while holding a session row, and once a mint
129
+ * holds the lock it waits on nothing but the session rows its eviction
130
+ * deletes, so no cycle runs through it. Twin of the Rust
116
131
  * `fuz_auth::query_account_lock_verified`.
117
132
  *
118
133
  * @param deps - query dependencies (must be the mint's transaction)
@@ -130,13 +145,13 @@ export declare const query_account_lock_verified: (deps: QueryDeps, id: string,
130
145
  * token before the new one exists. Run first in the mint's transaction, this
131
146
  * read waits on the delete's row lock and then sees its tombstone; once it
132
147
  * holds the lock, a delete waits for the mint to commit and then revokes the
133
- * token. The password is not re-checked: the mint verified none. `invite_create`
134
- * takes the same lock on its issuer's account, before its insert, so an
135
- * invite and a delete of its issuer are ordered: the invite is refused, or the
136
- * delete deletes it. An offer locks two accounts, so it takes them together
137
- * through `query_account_lock_live_many`. Twin of the Rust
138
- * `fuz_auth::query_account_lock_live`; `query_account_lock_verified` has why
139
- * `FOR SHARE`.
148
+ * token. The password is not re-checked: the mint verified none. Taken
149
+ * `FOR NO KEY UPDATE` for the token cap, as the login's lock is for the session
150
+ * cap — `query_account_lock_verified` has why, and what it conflicts with; a
151
+ * token mint and a login of one account take turns too. A write that only
152
+ * needs ordering against a delete takes `query_account_lock_live_many`, which
153
+ * lets such writes run together. Twin of the Rust
154
+ * `fuz_auth::query_account_lock_live`.
140
155
  *
141
156
  * @param deps - query dependencies (must be the mint's transaction)
142
157
  * @param id - the account the credential is for
@@ -144,13 +159,96 @@ export declare const query_account_lock_verified: (deps: QueryDeps, id: string,
144
159
  */
145
160
  export declare const query_account_lock_live: (deps: QueryDeps, id: string) => Promise<boolean>;
146
161
  /**
147
- * Lock several live account rows in one statement, in id order, for a write
148
- * that must be ordered against a delete of any of them — the two parties of an
149
- * offer (`query_role_grant_offer_create`).
162
+ * Lock, for a purge, the account rows of every holder of an unrevoked global
163
+ * `admin` grant and the purged account's own, in one statement, in id order,
164
+ * `FOR NO KEY UPDATE`.
165
+ *
166
+ * A purge's cascade writes rows of other accounts: it sets null the
167
+ * `granted_by` and `revoked_by` of every grant the purged account's actors
168
+ * named, admins' grants among them, in whatever order the plan walks them. A
169
+ * last-admin guard of another removal takes admin accounts, actors and grants
170
+ * in account-id order. A purge reaching an admin's grant before the guard does
171
+ * and waiting on one the guard took could hold a row the guard waits on.
172
+ * Holding every admin's account first, in the order the guard and
173
+ * `query_account_lock_live_many` take account rows, another guard waits at its
174
+ * first account holding nothing, and two purges take turns. The purged
175
+ * account's row is taken in the same statement, so an offer create holding one
176
+ * of these rows `FOR SHARE` and waiting on another meets them in the same order.
177
+ * No `deleted_at` filter on either: a tombstoned admin's grant is written by
178
+ * the cascade as well, and a purge removes a tombstoned account. The admins
179
+ * are those the statement's snapshot sees; one made by a transaction that
180
+ * commits after it starts is not among them. Cost: a purge waits behind
181
+ * admins' logins, token creates and offers. Run first in the purge's
182
+ * transaction, before the last-admin guard (an admin target's only) and
183
+ * `query_account_lock_for_purge`.
184
+ * Twin of the Rust `fuz_auth::account_queries::query_account_lock_admins_for_purge`.
185
+ *
186
+ * @param deps - query dependencies (must be the purge's transaction)
187
+ * @param id - the account to purge
188
+ */
189
+ export declare const query_account_lock_admins_for_purge: (deps: QueryDeps, id: string) => Promise<void>;
190
+ /**
191
+ * Lock the account row of a revoke's revokee, by its actor, tombstoned or not,
192
+ * `FOR NO KEY UPDATE`.
193
+ *
194
+ * Every revoke of a grant takes it, before it locks the offers it supersedes
195
+ * and before it updates the grant. It keeps those offers from growing: an offer
196
+ * to or from the account takes the row `FOR SHARE`
197
+ * (`query_account_lock_live_many`), so none is made while the revoke runs, and
198
+ * an accept by the account takes it `FOR NO KEY UPDATE`
199
+ * (`query_account_lock_for_offer_accept`), so none claims one. And it is the
200
+ * lock an accept of an offer from the revokee is ordered by: the accept reads
201
+ * its grantor's authority under the grantor's account row, and a revoke of that
202
+ * authority takes the row here whether or not its last-admin guard ran (the
203
+ * guard runs only while the account holds an active global `admin`). A revoke
204
+ * of an admin grant takes it after the guard, which holds it already among the
205
+ * admins' rows in id order. Twin of the Rust
206
+ * `fuz_auth::account_queries::query_account_lock_for_revoke`.
207
+ *
208
+ * @param deps - query dependencies (must be the revoke's transaction)
209
+ * @param actor_id - the revokee actor
210
+ */
211
+ export declare const query_account_lock_for_revoke: (deps: QueryDeps, actor_id: string) => Promise<void>;
212
+ /**
213
+ * Lock an account row for its purge, tombstoned or not.
214
+ *
215
+ * Every writer of an account takes the account row before its other rows — a
216
+ * credential mint its lock, a password change or a delete its `UPDATE` — and a
217
+ * purge takes it first as well, ahead of the credential rows its revokes and
218
+ * its cascade delete. A purge reaching the row only at its `DELETE` would hold
219
+ * the account's sessions and tokens while waiting on a writer that holds the
220
+ * row and goes on to those same rows: a login evicting at the cap, a password
221
+ * change or a delete revoking. `FOR UPDATE`, the lock the purge's `DELETE`
222
+ * takes anyway: it conflicts with every other lock on the row, so a writer
223
+ * holding one is waited out, and a writer arriving later waits for the purge
224
+ * and then finds no row. No `deleted_at` filter — a purge removes a tombstoned
225
+ * account too. Run after `query_account_lock_admins_for_purge`, which takes the
226
+ * row `FOR NO KEY UPDATE` among every admin's in id order, and, for an admin
227
+ * target, the last-admin guard, so this only strengthens a lock the purge
228
+ * already holds. Twin of the Rust
229
+ * `fuz_auth::account_queries::query_account_lock_for_purge`.
230
+ *
231
+ * @param deps - query dependencies (must be the purge's transaction)
232
+ * @param id - the account to purge
233
+ * @returns `true` when the row is locked, `false` when there is no such account
234
+ */
235
+ export declare const query_account_lock_for_purge: (deps: QueryDeps, id: string) => Promise<boolean>;
236
+ /**
237
+ * Lock live account rows in one statement, in id order, for a write that must
238
+ * be ordered against a delete of any of them.
239
+ *
240
+ * An offer locks its two parties (`query_role_grant_offer_create`), an invite
241
+ * its issuer (`invite_create`, one id).
242
+ *
243
+ * `FOR SHARE`: the weakest lock that conflicts with a delete's `UPDATE` of the
244
+ * row, so these writes don't wait on one another. It also waits on a
245
+ * credential mint's `FOR NO KEY UPDATE` (`query_account_lock_verified`), and a
246
+ * mint waits on it — but a mint holding its lock waits on no row these writes
247
+ * hold.
150
248
  *
151
249
  * The rows are locked as the sort returns them, so every caller takes them in
152
250
  * id order, as the last-admin guard
153
- * (`query_count_active_accounts_with_global_role_for_update`) takes its
251
+ * (`query_count_active_accounts_with_global_role_locked`) takes its
154
252
  * account rows: two transactions locking two of the same accounts never wait
155
253
  * on each other in opposite orders. Taken one statement per account, an offer
156
254
  * between two admins could hold one party's row while the guard held the
@@ -165,6 +263,50 @@ export declare const query_account_lock_live: (deps: QueryDeps, id: string) => P
165
263
  * @returns the ids locked: those of the accounts neither deleted nor tombstoned
166
264
  */
167
265
  export declare const query_account_lock_live_many: (deps: QueryDeps, ids: ReadonlyArray<string>) => Promise<Set<string>>;
266
+ /**
267
+ * Lock the account rows an offer accept is ordered by, in id order: the
268
+ * recipient's `FOR NO KEY UPDATE`, and — when the offer confers the global
269
+ * `admin` its grantor must still hold — the grantor's `FOR SHARE`.
270
+ *
271
+ * The recipient's lock is a credential mint's strength
272
+ * (`query_account_lock_verified`), so it conflicts with itself: two accepts
273
+ * by one recipient take turns, and the second claims after the first has
274
+ * superseded its siblings. It conflicts with a delete's or a purge's first
275
+ * write of the account (the soft-delete `UPDATE`,
276
+ * `query_account_lock_admins_for_purge`, the last-admin guard), so a removal of
277
+ * the recipient waits here or is waited for whole, and never meets the accept
278
+ * at its offers or its actor; with a revoke's `query_account_lock_for_revoke`,
279
+ * so a revoke of the recipient's grant and the accept take turns; and with
280
+ * `query_account_lock_live_many`, so no offer to the recipient is made or
281
+ * refreshed while the accept holds it. Cost: an accept waits behind the
282
+ * recipient's own logins and token mints, which take the same lock.
283
+ *
284
+ * The grantor's share lock is what the grantor's authority is read under (an
285
+ * unlocked read after this one): every write that ends a grantor's global
286
+ * `admin` takes the grantor's account row first — a revoke of the grant through
287
+ * `query_account_lock_for_revoke` (whether or not its last-admin guard ran), a
288
+ * delete through its write of the row, a purge through
289
+ * `query_account_lock_admins_for_purge` and `query_account_lock_for_purge` — so
290
+ * it either commits before the read, which sees it, or waits for the accept to
291
+ * commit. A share lock on the account,
292
+ * not on the grant, so a purge's cascade reaching the grant (its `granted_by`
293
+ * naming an actor of the purged account) never waits on the accept.
294
+ *
295
+ * Two statements, as the two strengths can't share one locking clause, the
296
+ * lower id first — the order the last-admin guard
297
+ * (`query_count_active_accounts_with_global_role_locked`) and
298
+ * `query_account_lock_live_many` take account rows in — so an accept and a
299
+ * guard over an admin recipient and its grantor never wait on each other in
300
+ * opposite orders. Neither is filtered on the grantor's tombstone: the
301
+ * authority read judges it. Twin of the Rust
302
+ * `fuz_auth::query_account_lock_for_offer_accept`.
303
+ *
304
+ * @param deps - query dependencies (must be the accept's transaction)
305
+ * @param recipient_id - the accepting account
306
+ * @param grantor_id - the grantor's account, or `null` when the offer needs no grantor authority
307
+ * @returns `true` when the recipient's row is locked and live, `false` when it was deleted or tombstoned
308
+ */
309
+ export declare const query_account_lock_for_offer_accept: (deps: QueryDeps, recipient_id: string, grantor_id: string | null) => Promise<boolean>;
168
310
  /**
169
311
  * Identifying values snapshotted into a deletion/purge audit event so the
170
312
  * identity behind a now-orphaned `audit_log` id isn't lost. Mirrors the
@@ -1 +1 @@
1
- {"version":3,"file":"account_queries.d.ts","sourceRoot":"","sources":["../../src/lib/auth/account_queries.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAQrD,OAAO,EAEN,KAAK,OAAO,EACZ,KAAK,KAAK,EACV,KAAK,kBAAkB,EACvB,KAAK,qBAAqB,EAC1B,MAAM,qBAAqB,CAAC;AAK7B;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,6JAYqB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,aAAa,6GASqB,CAAC;AAehD;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,GAChC,MAAM,SAAS,EACf,OAAO,kBAAkB,KACvB,OAAO,CAAC,OAAO,CAQjB,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,GAC/B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