@fuzdev/fuz_app 0.180.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 (389) hide show
  1. package/dist/actions/CLAUDE.md +38 -20
  2. package/dist/actions/action_rpc.d.ts +25 -6
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +56 -48
  5. package/dist/actions/action_types.d.ts +31 -13
  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 +13 -4
  12. package/dist/actions/perform_action.d.ts.map +1 -1
  13. package/dist/actions/perform_action.js +27 -18
  14. package/dist/actions/register_action_ws.d.ts +20 -2
  15. package/dist/actions/register_action_ws.d.ts.map +1 -1
  16. package/dist/actions/register_action_ws.js +17 -5
  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 +3 -2
  20. package/dist/auth/CLAUDE.md +84 -59
  21. package/dist/auth/account_actions.d.ts.map +1 -1
  22. package/dist/auth/account_actions.js +30 -3
  23. package/dist/auth/account_queries.d.ts +213 -2
  24. package/dist/auth/account_queries.d.ts.map +1 -1
  25. package/dist/auth/account_queries.js +255 -2
  26. package/dist/auth/account_route_schema.d.ts +26 -16
  27. package/dist/auth/account_route_schema.d.ts.map +1 -1
  28. package/dist/auth/account_route_schema.js +10 -24
  29. package/dist/auth/account_routes.d.ts +5 -7
  30. package/dist/auth/account_routes.d.ts.map +1 -1
  31. package/dist/auth/account_routes.js +110 -89
  32. package/dist/auth/admin_actions.d.ts.map +1 -1
  33. package/dist/auth/admin_actions.js +117 -25
  34. package/dist/auth/api_token_queries.d.ts +29 -12
  35. package/dist/auth/api_token_queries.d.ts.map +1 -1
  36. package/dist/auth/api_token_queries.js +42 -27
  37. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  38. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  39. package/dist/auth/audit_log_routes.d.ts +1 -1
  40. package/dist/auth/audit_log_routes.d.ts.map +1 -1
  41. package/dist/auth/audit_log_routes.js +10 -12
  42. package/dist/auth/audit_log_schema.js +4 -4
  43. package/dist/auth/bearer_auth.d.ts +4 -3
  44. package/dist/auth/bearer_auth.d.ts.map +1 -1
  45. package/dist/auth/bearer_auth.js +37 -32
  46. package/dist/auth/bootstrap_account.d.ts +65 -37
  47. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_account.js +115 -66
  49. package/dist/auth/bootstrap_route_schema.d.ts +6 -2
  50. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  51. package/dist/auth/bootstrap_route_schema.js +7 -2
  52. package/dist/auth/bootstrap_routes.d.ts +50 -33
  53. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  54. package/dist/auth/bootstrap_routes.js +109 -87
  55. package/dist/auth/bootstrap_token_store.d.ts +60 -0
  56. package/dist/auth/bootstrap_token_store.d.ts.map +1 -0
  57. package/dist/auth/bootstrap_token_store.js +39 -0
  58. package/dist/auth/credential_headers.d.ts +71 -0
  59. package/dist/auth/credential_headers.d.ts.map +1 -0
  60. package/dist/auth/credential_headers.js +100 -0
  61. package/dist/auth/daemon_token.d.ts +13 -1
  62. package/dist/auth/daemon_token.d.ts.map +1 -1
  63. package/dist/auth/daemon_token.js +14 -2
  64. package/dist/auth/daemon_token_middleware.d.ts +10 -11
  65. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  66. package/dist/auth/daemon_token_middleware.js +39 -30
  67. package/dist/auth/deps.d.ts +10 -11
  68. package/dist/auth/deps.d.ts.map +1 -1
  69. package/dist/auth/invite_queries.d.ts +18 -0
  70. package/dist/auth/invite_queries.d.ts.map +1 -1
  71. package/dist/auth/invite_queries.js +24 -0
  72. package/dist/auth/request_context.d.ts +97 -76
  73. package/dist/auth/request_context.d.ts.map +1 -1
  74. package/dist/auth/request_context.js +93 -104
  75. package/dist/auth/resolved_auth.d.ts +10 -5
  76. package/dist/auth/resolved_auth.d.ts.map +1 -1
  77. package/dist/auth/resolved_auth.js +2 -2
  78. package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
  79. package/dist/auth/role_grant_offer_action_specs.d.ts.map +1 -1
  80. package/dist/auth/role_grant_offer_action_specs.js +5 -3
  81. package/dist/auth/role_grant_offer_actions.d.ts +7 -11
  82. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  83. package/dist/auth/role_grant_offer_actions.js +97 -106
  84. package/dist/auth/role_grant_offer_ddl.d.ts +7 -1
  85. package/dist/auth/role_grant_offer_ddl.d.ts.map +1 -1
  86. package/dist/auth/role_grant_offer_ddl.js +9 -2
  87. package/dist/auth/role_grant_offer_notifications.d.ts +87 -38
  88. package/dist/auth/role_grant_offer_notifications.d.ts.map +1 -1
  89. package/dist/auth/role_grant_offer_notifications.js +75 -22
  90. package/dist/auth/role_grant_offer_queries.d.ts +143 -9
  91. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  92. package/dist/auth/role_grant_offer_queries.js +266 -66
  93. package/dist/auth/role_grant_offer_schema.js +1 -1
  94. package/dist/auth/role_grant_queries.d.ts +57 -10
  95. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  96. package/dist/auth/role_grant_queries.js +81 -22
  97. package/dist/auth/role_grant_sql.d.ts +21 -0
  98. package/dist/auth/role_grant_sql.d.ts.map +1 -1
  99. package/dist/auth/role_grant_sql.js +21 -0
  100. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  101. package/dist/auth/self_service_role_actions.js +9 -2
  102. package/dist/auth/session_cookie.d.ts +105 -25
  103. package/dist/auth/session_cookie.d.ts.map +1 -1
  104. package/dist/auth/session_cookie.js +124 -15
  105. package/dist/auth/session_middleware.d.ts +83 -54
  106. package/dist/auth/session_middleware.d.ts.map +1 -1
  107. package/dist/auth/session_middleware.js +92 -66
  108. package/dist/auth/session_queries.d.ts +95 -14
  109. package/dist/auth/session_queries.d.ts.map +1 -1
  110. package/dist/auth/session_queries.js +98 -19
  111. package/dist/auth/signup_route_schema.d.ts +5 -5
  112. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  113. package/dist/auth/signup_route_schema.js +4 -4
  114. package/dist/auth/signup_routes.d.ts.map +1 -1
  115. package/dist/auth/signup_routes.js +17 -14
  116. package/dist/auth/standard_rpc_actions.d.ts +6 -19
  117. package/dist/auth/standard_rpc_actions.d.ts.map +1 -1
  118. package/dist/auth/standard_rpc_actions.js +5 -6
  119. package/dist/auth/token_scope.d.ts +6 -8
  120. package/dist/auth/token_scope.d.ts.map +1 -1
  121. package/dist/auth/token_scope.js +6 -9
  122. package/dist/dev/setup.d.ts +6 -1
  123. package/dist/dev/setup.d.ts.map +1 -1
  124. package/dist/dev/setup.js +42 -34
  125. package/dist/hono_context.d.ts +21 -0
  126. package/dist/hono_context.d.ts.map +1 -1
  127. package/dist/hono_context.js +17 -0
  128. package/dist/http/CLAUDE.md +156 -48
  129. package/dist/http/auth_shape.d.ts +4 -4
  130. package/dist/http/common_routes.js +1 -1
  131. package/dist/http/db_routes.d.ts +4 -3
  132. package/dist/http/db_routes.d.ts.map +1 -1
  133. package/dist/http/db_routes.js +14 -14
  134. package/dist/http/dev_route_error_check.d.ts +6 -3
  135. package/dist/http/dev_route_error_check.d.ts.map +1 -1
  136. package/dist/http/dev_route_error_check.js +6 -3
  137. package/dist/http/dev_set_cookie_check.d.ts +53 -0
  138. package/dist/http/dev_set_cookie_check.d.ts.map +1 -0
  139. package/dist/http/dev_set_cookie_check.js +80 -0
  140. package/dist/http/error_schemas.d.ts +45 -22
  141. package/dist/http/error_schemas.d.ts.map +1 -1
  142. package/dist/http/error_schemas.js +53 -26
  143. package/dist/http/header_lines.d.ts +42 -0
  144. package/dist/http/header_lines.d.ts.map +1 -0
  145. package/dist/http/header_lines.js +80 -0
  146. package/dist/http/host.d.ts +12 -9
  147. package/dist/http/host.d.ts.map +1 -1
  148. package/dist/http/host.js +25 -20
  149. package/dist/http/origin.d.ts +7 -22
  150. package/dist/http/origin.d.ts.map +1 -1
  151. package/dist/http/origin.js +11 -25
  152. package/dist/http/proxy.d.ts +1 -0
  153. package/dist/http/proxy.d.ts.map +1 -1
  154. package/dist/http/proxy.js +3 -0
  155. package/dist/http/request_headers.d.ts +95 -0
  156. package/dist/http/request_headers.d.ts.map +1 -0
  157. package/dist/http/request_headers.js +110 -0
  158. package/dist/http/request_target.d.ts +134 -0
  159. package/dist/http/request_target.d.ts.map +1 -0
  160. package/dist/http/request_target.js +193 -0
  161. package/dist/http/route_error_check.d.ts +4 -11
  162. package/dist/http/route_error_check.d.ts.map +1 -1
  163. package/dist/http/route_error_check.js +4 -21
  164. package/dist/http/route_result.d.ts +127 -23
  165. package/dist/http/route_result.d.ts.map +1 -1
  166. package/dist/http/route_result.js +97 -19
  167. package/dist/http/route_spec.d.ts +299 -83
  168. package/dist/http/route_spec.d.ts.map +1 -1
  169. package/dist/http/route_spec.js +548 -71
  170. package/dist/http/simple_request.d.ts +19 -14
  171. package/dist/http/simple_request.d.ts.map +1 -1
  172. package/dist/http/simple_request.js +17 -29
  173. package/dist/http/surface.d.ts +2 -0
  174. package/dist/http/surface.d.ts.map +1 -1
  175. package/dist/http/surface.js +4 -1
  176. package/dist/realtime/outbound_budget.d.ts +1 -2
  177. package/dist/realtime/outbound_budget.d.ts.map +1 -1
  178. package/dist/realtime/outbound_budget.js +1 -2
  179. package/dist/realtime/sse.d.ts +47 -17
  180. package/dist/realtime/sse.d.ts.map +1 -1
  181. package/dist/realtime/sse.js +115 -93
  182. package/dist/realtime/sse_constants.d.ts +7 -1
  183. package/dist/realtime/sse_constants.d.ts.map +1 -1
  184. package/dist/realtime/sse_constants.js +12 -1
  185. package/dist/realtime/sse_registry.d.ts +3 -3
  186. package/dist/realtime/sse_registry.js +3 -3
  187. package/dist/runtime/deps.d.ts +20 -4
  188. package/dist/runtime/deps.d.ts.map +1 -1
  189. package/dist/runtime/mock.d.ts +7 -1
  190. package/dist/runtime/mock.d.ts.map +1 -1
  191. package/dist/runtime/mock.js +33 -3
  192. package/dist/runtime/node.d.ts.map +1 -1
  193. package/dist/runtime/node.js +2 -1
  194. package/dist/runtime/secure_file.d.ts +71 -10
  195. package/dist/runtime/secure_file.d.ts.map +1 -1
  196. package/dist/runtime/secure_file.js +91 -11
  197. package/dist/server/app_backend.d.ts +0 -8
  198. package/dist/server/app_backend.d.ts.map +1 -1
  199. package/dist/server/app_backend.js +4 -4
  200. package/dist/server/app_server.d.ts +54 -33
  201. package/dist/server/app_server.d.ts.map +1 -1
  202. package/dist/server/app_server.js +69 -41
  203. package/dist/server/serve_fact_route.d.ts +3 -3
  204. package/dist/server/serve_fact_route.d.ts.map +1 -1
  205. package/dist/server/serve_fact_route.js +59 -55
  206. package/dist/server/static.d.ts +20 -0
  207. package/dist/server/static.d.ts.map +1 -1
  208. package/dist/server/static.js +56 -8
  209. package/dist/server/unmatched_route.d.ts +42 -0
  210. package/dist/server/unmatched_route.d.ts.map +1 -0
  211. package/dist/server/unmatched_route.js +64 -0
  212. package/dist/testing/CLAUDE.md +406 -1202
  213. package/dist/testing/app_server.d.ts +3 -1
  214. package/dist/testing/app_server.d.ts.map +1 -1
  215. package/dist/testing/app_server.js +5 -9
  216. package/dist/testing/auth_apps.d.ts.map +1 -1
  217. package/dist/testing/auth_apps.js +3 -2
  218. package/dist/testing/cross_backend/account_lifecycle.d.ts +11 -4
  219. package/dist/testing/cross_backend/account_lifecycle.d.ts.map +1 -1
  220. package/dist/testing/cross_backend/account_lifecycle.js +320 -6
  221. package/dist/testing/cross_backend/build_test_backend_paths.d.ts +4 -1
  222. package/dist/testing/cross_backend/build_test_backend_paths.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/build_test_backend_paths.js +1 -1
  224. package/dist/testing/cross_backend/capabilities.d.ts +68 -5
  225. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  226. package/dist/testing/cross_backend/capabilities.js +20 -4
  227. package/dist/testing/cross_backend/cell_gated_create.js +1 -1
  228. package/dist/testing/cross_backend/conformance_case.d.ts +63 -21
  229. package/dist/testing/cross_backend/conformance_case.d.ts.map +1 -1
  230. package/dist/testing/cross_backend/conformance_table.d.ts +54 -12
  231. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  232. package/dist/testing/cross_backend/conformance_table.js +179 -23
  233. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  234. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts +7 -1
  235. package/dist/testing/cross_backend/create_dual_spawn_global_setup.d.ts.map +1 -1
  236. package/dist/testing/cross_backend/create_dual_spawn_global_setup.js +3 -3
  237. package/dist/testing/cross_backend/credential_conformance.d.ts +196 -0
  238. package/dist/testing/cross_backend/credential_conformance.d.ts.map +1 -0
  239. package/dist/testing/cross_backend/credential_conformance.js +296 -0
  240. package/dist/testing/cross_backend/credential_conformance.json +1284 -0
  241. package/dist/testing/cross_backend/credential_conformance_wire.d.ts +40 -0
  242. package/dist/testing/cross_backend/credential_conformance_wire.d.ts.map +1 -0
  243. package/dist/testing/cross_backend/credential_conformance_wire.js +293 -0
  244. package/dist/testing/cross_backend/credential_header_robustness.d.ts +1 -3
  245. package/dist/testing/cross_backend/credential_header_robustness.d.ts.map +1 -1
  246. package/dist/testing/cross_backend/credential_header_robustness.js +24 -55
  247. package/dist/testing/cross_backend/credential_wire.d.ts +112 -0
  248. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -0
  249. package/dist/testing/cross_backend/credential_wire.js +188 -0
  250. package/dist/testing/cross_backend/default_backend_configs.d.ts.map +1 -1
  251. package/dist/testing/cross_backend/default_backend_configs.js +22 -2
  252. package/dist/testing/cross_backend/default_spine_surface.d.ts +1 -26
  253. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  254. package/dist/testing/cross_backend/default_spine_surface.js +3 -7
  255. package/dist/testing/cross_backend/differential.d.ts +1 -1
  256. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  257. package/dist/testing/cross_backend/differential.js +3 -2
  258. package/dist/testing/cross_backend/differential_normalize.d.ts +23 -6
  259. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  260. package/dist/testing/cross_backend/differential_normalize.js +11 -5
  261. package/dist/testing/cross_backend/full_spine_mount.d.ts +4 -10
  262. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  263. package/dist/testing/cross_backend/full_spine_mount.js +11 -4
  264. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  265. package/dist/testing/cross_backend/identity_parity.js +4 -0
  266. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  267. package/dist/testing/cross_backend/in_process_setup.js +78 -4
  268. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  269. package/dist/testing/cross_backend/login_security.js +13 -10
  270. package/dist/testing/cross_backend/peer_ping_ws.d.ts +1 -1
  271. package/dist/testing/cross_backend/peer_ping_ws.js +2 -2
  272. package/dist/testing/cross_backend/request_header_conformance.d.ts +174 -0
  273. package/dist/testing/cross_backend/request_header_conformance.d.ts.map +1 -0
  274. package/dist/testing/cross_backend/request_header_conformance.js +196 -0
  275. package/dist/testing/cross_backend/request_header_conformance.json +1158 -0
  276. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts +39 -0
  277. package/dist/testing/cross_backend/request_header_conformance_wire.d.ts.map +1 -0
  278. package/dist/testing/cross_backend/request_header_conformance_wire.js +284 -0
  279. package/dist/testing/cross_backend/request_target_conformance.d.ts +298 -0
  280. package/dist/testing/cross_backend/request_target_conformance.d.ts.map +1 -0
  281. package/dist/testing/cross_backend/request_target_conformance.js +186 -0
  282. package/dist/testing/cross_backend/request_target_conformance.json +3765 -0
  283. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +32 -0
  284. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -0
  285. package/dist/testing/cross_backend/request_target_conformance_wire.js +278 -0
  286. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  287. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +173 -1
  288. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts +5 -4
  289. package/dist/testing/cross_backend/role_grant_offer_notification_ws.d.ts.map +1 -1
  290. package/dist/testing/cross_backend/role_grant_offer_notification_ws.js +185 -31
  291. package/dist/testing/cross_backend/rpc_adversarial.d.ts +6 -4
  292. package/dist/testing/cross_backend/rpc_adversarial.d.ts.map +1 -1
  293. package/dist/testing/cross_backend/rpc_adversarial.js +5 -2
  294. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +6 -7
  295. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  296. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +4 -5
  297. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  298. package/dist/testing/cross_backend/session_cap.js +82 -34
  299. package/dist/testing/cross_backend/session_cookie_effect.d.ts +43 -0
  300. package/dist/testing/cross_backend/session_cookie_effect.d.ts.map +1 -0
  301. package/dist/testing/cross_backend/session_cookie_effect.js +103 -0
  302. package/dist/testing/cross_backend/session_login.d.ts +24 -0
  303. package/dist/testing/cross_backend/session_login.d.ts.map +1 -0
  304. package/dist/testing/cross_backend/session_login.js +31 -0
  305. package/dist/testing/cross_backend/setup.d.ts +117 -0
  306. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  307. package/dist/testing/cross_backend/setup.js +193 -9
  308. package/dist/testing/cross_backend/simple_request.d.ts.map +1 -1
  309. package/dist/testing/cross_backend/simple_request.js +5 -0
  310. package/dist/testing/cross_backend/spine_suites.d.ts +9 -1
  311. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  312. package/dist/testing/cross_backend/spine_suites.js +88 -5
  313. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  314. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  315. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  316. package/dist/testing/cross_backend/sse_round_trip.d.ts +8 -5
  317. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  318. package/dist/testing/cross_backend/sse_round_trip.js +205 -64
  319. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  320. package/dist/testing/cross_backend/testing_backdoor.js +5 -2
  321. package/dist/testing/cross_backend/testing_credential_read.d.ts +165 -0
  322. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -0
  323. package/dist/testing/cross_backend/testing_credential_read.js +175 -0
  324. package/dist/testing/cross_backend/testing_reset_actions.d.ts +19 -0
  325. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  326. package/dist/testing/cross_backend/testing_reset_actions.js +22 -6
  327. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  328. package/dist/testing/cross_backend/token_lifetime.js +58 -2
  329. package/dist/testing/cross_backend/transport_composition.d.ts +2 -4
  330. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  331. package/dist/testing/cross_backend/transport_composition.js +13 -10
  332. package/dist/testing/cross_backend/ts_spine_backend_config.d.ts.map +1 -1
  333. package/dist/testing/cross_backend/ts_spine_backend_config.js +5 -3
  334. package/dist/testing/cross_backend/ws_endpoint.d.ts +11 -1
  335. package/dist/testing/cross_backend/ws_endpoint.d.ts.map +1 -1
  336. package/dist/testing/cross_backend/ws_endpoint.js +19 -2
  337. package/dist/testing/cross_backend/ws_role_gated.d.ts.map +1 -1
  338. package/dist/testing/cross_backend/ws_role_gated.js +2 -3
  339. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  340. package/dist/testing/cross_backend/ws_round_trip.js +28 -12
  341. package/dist/testing/cross_backend/xfail.d.ts +44 -11
  342. package/dist/testing/cross_backend/xfail.d.ts.map +1 -1
  343. package/dist/testing/cross_backend/xfail.js +68 -23
  344. package/dist/testing/data_exposure.d.ts.map +1 -1
  345. package/dist/testing/data_exposure.js +4 -3
  346. package/dist/testing/integration.d.ts +1 -2
  347. package/dist/testing/integration.d.ts.map +1 -1
  348. package/dist/testing/integration.js +14 -8
  349. package/dist/testing/integration_helpers.d.ts +50 -3
  350. package/dist/testing/integration_helpers.d.ts.map +1 -1
  351. package/dist/testing/integration_helpers.js +87 -9
  352. package/dist/testing/middleware.d.ts +3 -1
  353. package/dist/testing/middleware.d.ts.map +1 -1
  354. package/dist/testing/middleware.js +14 -7
  355. package/dist/testing/resolved_auth.d.ts +3 -1
  356. package/dist/testing/resolved_auth.d.ts.map +1 -1
  357. package/dist/testing/resolved_auth.js +4 -4
  358. package/dist/testing/round_trip.d.ts +6 -2
  359. package/dist/testing/round_trip.d.ts.map +1 -1
  360. package/dist/testing/round_trip.js +17 -6
  361. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  362. package/dist/testing/rpc_envelope_cases.js +7 -0
  363. package/dist/testing/rpc_helpers.d.ts +4 -2
  364. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  365. package/dist/testing/rpc_helpers.js +6 -1
  366. package/dist/testing/rpc_round_trip.d.ts +13 -2
  367. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  368. package/dist/testing/rpc_round_trip.js +25 -6
  369. package/dist/testing/schema_generators.d.ts +2 -2
  370. package/dist/testing/schema_generators.d.ts.map +1 -1
  371. package/dist/testing/schema_generators.js +4 -4
  372. package/dist/testing/stubs.d.ts +2 -2
  373. package/dist/testing/stubs.d.ts.map +1 -1
  374. package/dist/testing/stubs.js +13 -10
  375. package/dist/testing/transports/fetch_transport.d.ts +6 -3
  376. package/dist/testing/transports/fetch_transport.d.ts.map +1 -1
  377. package/dist/testing/transports/fetch_transport.js +31 -19
  378. package/dist/testing/transports/raw_http.d.ts +61 -1
  379. package/dist/testing/transports/raw_http.d.ts.map +1 -1
  380. package/dist/testing/transports/raw_http.js +61 -1
  381. package/dist/testing/transports/ws_raw_client.d.ts +20 -0
  382. package/dist/testing/transports/ws_raw_client.d.ts.map +1 -1
  383. package/dist/testing/transports/ws_raw_client.js +10 -4
  384. package/dist/testing/transports/ws_transport.d.ts +21 -1
  385. package/dist/testing/transports/ws_transport.d.ts.map +1 -1
  386. package/dist/testing/transports/ws_transport.js +58 -20
  387. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  388. package/dist/testing/ws_round_trip.js +8 -4
  389. 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: `read_secure_file` (hardened bootstrap-token read), `delete_file`, `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
 
@@ -32,12 +32,14 @@ over the pool so rows persist when request transactions roll back. See root
32
32
  ### Crypto primitives (pure, I/O-free)
33
33
 
34
34
  - `auth/keyring.ts` — `Keyring`, `create_keyring` (validates — the one way to build a `Keyring`), `validate_keyring`.
35
- - `auth/session_cookie.ts` — `SessionOptions<T>`, `parse_session`, `process_session_cookie` (`'none' | 'clear'` — no refresh action; the 30-day lifetime is an absolute cap signed once at mint), `create_session_config`, `fuz_session_config`, `SESSION_AGE_MAX`.
35
+ - `auth/session_cookie.ts` — `SessionOptions<T>`, `parse_session`, `process_session_cookie` (`'none' | 'clear'` — no refresh action; the 30-day lifetime is an absolute cap signed once at mint; a value that is present and does not verify, the empty string included, is `'clear'`, and only an absent cookie is `'none'`), `create_session_cookie_value`, `create_session_config`, `fuz_session_config`, `SESSION_AGE_MAX`. The cookie's attributes are fixed — `SESSION_COOKIE_ATTRIBUTES` (`Path=/; HttpOnly; Secure; SameSite=Strict`), no option weakens them — and `format_session_set_cookie` / `format_session_clear_cookie` (and `session_cookie_header` / `clear_session_cookie_header`, the same lines from a `SessionOptions`, for a route's success result — the Rust `route_helpers`' names; the TS form takes the signed value, the Rust one signs the token itself) write the exact `Set-Cookie` strings the Rust spine writes, the value raw (never percent-encoded), refusing a name or value outside RFC 6265 (`is_cookie_name`, `is_cookie_value`) by throwing, so a consumer's `encode_identity` must emit cookie-octets.
36
+ - `auth/credential_headers.ts` — the grammar of the three credential headers as pure readers over header lines (`get_header_lines` of `http/header_lines.ts`): `read_session_cookie_value` (several `Cookie` lines read as their `; ` join; split on `;`, SP and HTAB stripped from each pair, the first pair beginning `<name>=` wins, its value verbatim — an invalid first pair is not skipped for a later one), `read_bearer_token` and `read_daemon_token` (exactly one line, exact shape; a header sent twice is discarded). Hono-free. Twin of the Rust `fuz_auth::credential_headers`; `testing/cross_backend/credential_conformance.json` holds both to the same rows.
36
37
  - `auth/password.ts` — `Password`, `PasswordProvided` (`@fuzdev/fuz_schema` schemas), `PasswordHashDeps`, `PASSWORD_LENGTH_MIN` (12, OWASP), `PASSWORD_LENGTH_MAX` (300).
37
38
  - `auth/password_argon2.ts` — `hash_password`, `verify_password`, `verify_dummy`, `argon2_password_deps`.
38
39
  - `auth/api_token.ts` — `API_TOKEN_PREFIX` (`secret_fuz_token_`), `ApiTokenId` (the public id, `pipe(string, regex(API_TOKEN_ID_REGEX))`, a `@fuzdev/fuz_schema` schema), `hash_api_token`, `generate_api_token`, and the shape precheck `is_api_token_shaped` (`API_TOKEN_REGEX`: the prefix plus exactly `API_TOKEN_BODY_LENGTH` = 43 base64url chars).
39
- - `auth/daemon_token.ts` — `DaemonToken`, `DAEMON_TOKEN_HEADER` (`X-Daemon-Token`), `generate_daemon_token`, `validate_daemon_token`, `DaemonTokenState`.
40
- - `auth/bootstrap_account.ts` — `bootstrap_account` (one-shot, `bootstrap_lock`-protected) + `read_bootstrap_token`, the read both it and `check_bootstrap_status` use: the secure read less one trailing LF, a token under `BOOTSTRAP_TOKEN_MIN_BYTES` (32) refused as unreadable with an error log.
40
+ - `auth/daemon_token.ts` — `DaemonToken`, `DAEMON_TOKEN_REGEX` + the shape precheck `is_daemon_token_shaped` (43 base64url chars), `DAEMON_TOKEN_HEADER` (`X-Daemon-Token`), `generate_daemon_token`, `validate_daemon_token`, `DaemonTokenState`.
41
+ - `auth/bootstrap_account.ts` — `bootstrap_account` (one-shot, `bootstrap_lock`-protected) + `read_bootstrap_token`, the read both it and `check_bootstrap_status` use: the secure read less one trailing LF, a token under `BOOTSTRAP_TOKEN_MIN_BYTES` (32) refused as unreadable with an error log. One transaction holds the whole bootstrap: the lock, the account and grants, the session (`create_capped_session`), and last the burn of the token (`token_store.burn_token`) — a failed burn throws out of the transaction (`BootstrapTokenBurnError`) and answers `token_file_undeletable` with nothing created; the success carries `session_cookie_value`, the signed cookie the route sets. `BootstrapAccountCreated` is what `on_bootstrap` receives.
42
+ - `auth/bootstrap_token_store.ts` — `BootstrapTokenStore` (`path`, `read_token`, `burn_token`), the one seam to the token file, and `create_file_bootstrap_token_store(deps, path)` over the runtime's secure read and burn. Its read asks the secure read for a single hard link (`require_single_link`): a token file with a second link would outlive its burn under the other name, so it is refused as unreadable, at boot and on a request alike. Twin of the Rust `BootstrapTokenStore` trait, which carries no path (its availability check is handed one).
41
43
 
42
44
  Cross-cutting notes that don't live on any single symbol:
43
45
 
@@ -72,19 +74,19 @@ Convention — `*_schema.ts` holds a domain's `@fuzdev/fuz_schema` schemas; `*_d
72
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`.
73
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`).
74
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.
75
- - `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`.
76
78
 
77
79
  ### Queries
78
80
 
79
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.
80
82
 
81
- - `auth/account_queries.ts` — account CRUD, actor resolution, password update with verify-write race guard, paged `query_admin_account_list`.
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`.
82
84
  - `auth/actor_lookup_queries.ts` — batched `actor` ⨝ `account` for the labels arc; active actors of active accounts only.
83
85
  - `auth/actor_search_queries.ts` — case-insensitive prefix search on `actor.name`, scope-filtered when not admin; active actors of active accounts only.
84
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.
85
- - `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`.
86
- - `auth/session_queries.ts` — server-side sessions (blake3-hashed), `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`).
87
- - `auth/api_token_queries.ts` — token validation with fire-and-forget usage tracking, `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).
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
+ - `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
+ - `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).
88
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).
89
91
  - `auth/app_settings_queries.ts` — load/update for the single-row settings table.
90
92
  - `auth/audit_log_queries.ts` — `query_audit_log` (in-tx insert), `_list` / `_list_with_usernames` / `_list_role_grant_history` / `_cleanup_before`, drift counters (`get_audit_metadata_validation_failures` / `get_audit_unknown_event_type_failures`).
@@ -195,8 +197,8 @@ counted, the request proceeds — so the count is how a lost row is seen.
195
197
 
196
198
  ### Routes
197
199
 
198
- - `auth/account_routes.ts` — `POST /login` / `/logout` / `/password`, `GET /verify` (nginx `auth_request` shim), `GET /api/account/status`. Constants: `DEFAULT_MAX_SESSIONS = 5`, `DEFAULT_MAX_TOKENS = 10`, `DEFAULT_LOGIN_FAIL_FLOOR_MS = 250`, `DEFAULT_LOGIN_FAIL_JITTER_MS = 25`.
199
- - `auth/bootstrap_routes.ts` — `POST /bootstrap` + `check_bootstrap_status`; `BootstrapStatus` runtime ref.
200
+ - `auth/account_routes.ts` — `POST /login` / `/logout` / `/password`, `GET /api/account/status`. Constants: `DEFAULT_MAX_SESSIONS = 5`, `DEFAULT_MAX_TOKENS = 10`, `DEFAULT_LOGIN_FAIL_FLOOR_MS = 250`, `DEFAULT_LOGIN_FAIL_JITTER_MS = 25`.
201
+ - `auth/bootstrap_routes.ts` — `POST /bootstrap` + `check_bootstrap_status` (the boot report: the lock read first; a token file left on a bootstrapped database and an unreadable one on an open window each warn; a missing lock row reads unavailable); `BootstrapStatus` runtime ref (`{available}`); `OnBootstrap`, the post-commit callback over what was created. A failed burn answers 500 `token_file_undeletable` with the window left open; the lock race loser closes its window with no audit row and no charge.
200
202
  - `auth/signup_routes.ts` — `POST /signup` (open or invite-gated).
201
203
  - `auth/audit_log_routes.ts` — optional `GET /audit/stream` (SSE); list/history are on the RPC surface. Takes `stream: {registry, log}` (an `AuditLogSse` satisfies it). The handler admits the stream in two phases — register pending on the `SseRegistry`, re-read the credential (`revalidate_resolved_auth`) and the acting actor's role grants, admit — so a revocation racing the request opens no stream: 401 / 403 from the re-reads, or a 200 whose body is the connect comment alone when the pending registration was closed.
202
204
  - `auth/auth_guard_resolver.ts` — `fuz_auth_guard_resolver` injected into `apply_route_specs` so the framework stays auth-agnostic. Maps each `RouteAuth` axis to a guard and is the single site every route spec traverses, so it also carries the two invariants the auth shape alone can't (a `required_scope` that isn't a well-formed capability, and one on an unrestricted route).
@@ -211,8 +213,8 @@ attach the live (hono-coupled) handler; a cross-process surface builder spreads
211
213
  the same shape with a stub handler (surface generation never runs handlers).
212
214
  Single source of truth — the shape can't drift between the live route and the
213
215
  attack surface — and a backend-spawning consumer assembling its surface imports
214
- the shapes without dragging `hono/cookie` / `hono/streaming` (and the optional
215
- `hono` peer) onto a Rust-only cross-process suite. Shared route-limit constants
216
+ the shapes without dragging `hono/streaming` (and the optional `hono` peer)
217
+ onto a Rust-only cross-process suite. Shared route-limit constants
216
218
  (`DEFAULT_MAX_SESSIONS` / `_TOKENS`) live in `account_route_schema.ts` for the
217
219
  same reason (the RPC `account_actions` reads `DEFAULT_MAX_TOKENS`). The
218
220
  account, signup and bootstrap shapes' schemas, error bodies included, are
@@ -246,18 +248,18 @@ for each session its cap evicted (`queue_connection_close` on
246
248
  committed and is dropped if the handler throws.
247
249
 
248
250
  REST-only post RPC migration: `/login`, `/logout`, `/password`, `/signup`,
249
- `/bootstrap`, `/verify` (empty-body shim), optional `/audit/stream`.
251
+ `/bootstrap`, optional `/audit/stream`.
250
252
  Everything else listed under §RPC action surfaces.
251
253
 
252
254
  ### Middleware
253
255
 
254
- - `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 (`[proxy, ...auth]`) — each stack spec, matched by its `handler` closure (not its spoofable `name`), mounted exactly once at its original path (`'*'` for 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.
255
- - `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` (the account id a `reads_credential` route may read — `null` for a scope-narrowed token, which such a route answers as anonymous; twin of the Rust `AuthGate::public_request_context` downgrade), `refresh_role_grants`.
256
- - `auth/session_middleware.ts` — `process_session_cookie` integration, `create_session_and_set_cookie` (shared by login / signup / bootstrap; returns the token hashes of the sessions the cap evicted, which the caller closes after its commit — only login passes a cap).
257
- - `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`.
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(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
+ - `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`, `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`.
258
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`.
259
- - `auth/bearer_auth.ts` — soft-fail bearer middleware; rejects when `Origin` or `Referer` present (browser context), and soft-fails a value that is not `is_api_token_shaped` before any query. 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.
260
- - `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 (`Origin`/`Referer` present), malformed/invalid token, 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. A discarded daemon token falls through to them.
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
+ - `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.
261
263
 
262
264
  See root ../../../CLAUDE.md §Middleware Ordering for canonical assembly
263
265
  order. The auth-specific invariants are described below in §Cross-cutting
@@ -455,9 +457,14 @@ with `RequestContext.actor: null`.
455
457
  without touching the Hono context. Each transport binds the same failure to
456
458
  its wire shape: REST `c.json(body, status)`; HTTP RPC + WS fold into a
457
459
  JSON-RPC envelope where `error.message` is the reason string and
458
- `error.data: {reason, ...rest}` flattens diagnostic fields. The 500 reasons
459
- stay distinct: `no_actors_on_account` (signup invariant violation),
460
- `account_vanished` (torn read after resolve).
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.
461
468
 
462
469
  **Production-middleware invariant.** No production middleware on the auth
463
470
  path populates `REQUEST_CONTEXT_KEY`; it sets only `RESOLVED_AUTH_KEY`. Test
@@ -472,6 +479,16 @@ under `SESSION_TOKEN_KEY` (`hono_context.ts`, `'auth_session_id'`) and the
472
479
  session leg reads it there; `SessionOptions` carries no context key, so the two
473
480
  cannot disagree and the token cannot land on another spine key.
474
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
+
475
492
  ### Wire timestamp shape
476
493
 
477
494
  Every timestamp on the wire is **second-precision UTC** —
@@ -597,8 +614,11 @@ account event plus one per-actor event (`delete` = soft, `purge` = hard,
597
614
  "Account-removal target guards").
598
615
 
599
616
  `role_grant_offer_supersede` carries
600
- `reason: 'sibling_accepted' | 'role_grant_revoked' | 'scope_destroyed'`
601
- 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).
602
622
 
603
623
  ### Keeper auth shape
604
624
 
@@ -703,9 +723,9 @@ reactivation has no self path because a soft-deleted account can't
703
723
  authenticate.
704
724
 
705
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.
706
- - `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), revokes sessions/tokens, emits `account_delete` + per-actor `actor_delete`. 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.
707
- - `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}`. 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`).
708
- - `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`. Does not restore revoked sessions/tokens.
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.
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`).
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.
709
729
  - `admin_session_list_action_spec` — read; input `{acting?}` (an omitted input reads as `{}`); output `{sessions}`.
710
730
  - `admin_session_revoke_all_action_spec` — mutation; input `{account_id}`; output `{ok, count}`.
711
731
  - `admin_token_revoke_all_action_spec` — mutation; input `{account_id}`; output `{ok, count}`.
@@ -781,7 +801,7 @@ The create and assign inputs end in a `check` of `is_grant_scope_paired`
781
801
  the list and history inputs read an omitted input as a fresh `{}`
782
802
  (`with_default_fn`); history's `offset` is held to `Number.MAX_SAFE_INTEGER`.
783
803
 
784
- - `role_grant_offer_create_action_spec` — session-only; input `{to_account_id, to_actor_id?, role, scope_kind?, scope_id?, message?}` (`scope_kind` a `ScopeKindName`; `scope_kind` + `scope_id` paired — both or neither, else `invalid_params`); output `{offer}`.
804
+ - `role_grant_offer_create_action_spec` — session-only; input `{to_account_id, to_actor_id?, role, scope_kind?, scope_id?, message?}` (`scope_kind` a `ScopeKindName`; `scope_kind` + `scope_id` paired — both or neither, else `invalid_params`); output `{offer}`. The create query itself (`query_role_grant_offer_create`) refuses a recipient that is not an active account — deleted or missing alike, answered as `role_grant_assign` answers them: 404 `not_found` (message `account not found`, no `data.reason`), or 400 `role_grant_offer_actor_account_mismatch` when an actor is named — after the self-target check and after the handler's authority gates, and a grantor that is no longer active (deleted mid-request: the dead-credential 401, no audit row). It takes `FOR SHARE` on both accounts first, so a delete of either party in flight is ordered against it.
785
805
  - `role_grant_offer_accept_action_spec` — session-only; input `{offer_id}`; output `{role_grant_id, offer, superseded_offer_ids}`. Refuses a builtin-role offer that must not mint (see below), leaving it pending.
786
806
  - `role_grant_offer_decline_action_spec` — input `{offer_id, reason?}`; output `{offer}` (the declined offer, as accept answers its own).
787
807
  - `role_grant_offer_retract_action_spec` — input `{offer_id}`; output `{offer}` (the retracted offer).
@@ -791,12 +811,14 @@ the list and history inputs read an omitted input as a fresh `{}`
791
811
  A global `admin` grant is guarded: the keeper account's is refused
792
812
  (`ERROR_CANNOT_REVOKE_KEEPER_ADMIN`, 403) and so is one whose revoke would
793
813
  leave no active admin account (`ERROR_CANNOT_REVOKE_LAST_ADMIN`, 403, under
794
- the locked count `query_count_active_accounts_with_global_role_for_update`,
795
- which leaves the revoked grant out). Besides the
796
- revokee's incoming sibling offers, the revoke supersedes every pending offer
797
- the revokee's actor made (`query_role_grant_offer_supersede_outgoing`) —
798
- `account_delete` / `account_purge` do the same for every actor of the account
799
- (`reason: 'account_deleted'`, audited, no notification).
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.
800
822
  - `role_grant_assign_action_spec` — global-admin-only immediate conferral (no
801
823
  consent step); input `{to_account_id, to_actor_id?, role, scope_kind?, scope_id?}`
802
824
  (the pair as on offer-create); output `{ok, role_grant_id}`. The handler:
@@ -850,7 +872,7 @@ becomes a grant) refuses a `keeper` offer (`ERROR_ROLE_GRANT_OFFER_ROLE_NOT_GRAN
850
872
  a scoped `admin` offer (`invalid_request` + `ERROR_ROLE_GRANT_BUILTIN_SCOPED`), and a
851
873
  builtin offer whose grantor no longer holds an active global `admin` on an
852
874
  active actor of an active account (`ERROR_ROLE_GRANT_OFFER_NOT_AUTHORIZED`,
853
- re-checked under `FOR SHARE` so a racing revoke is ordered against it) — via
875
+ read under the grantor's account lock) — via
854
876
  `RoleGrantOfferBuiltinRefusedError` (`refusal: BuiltinOfferRefusal`). Each
855
877
  refusal leaves the offer pending and is audited as a failed
856
878
  `role_grant_offer_accept` with `{offer_id, role, scope_id, reason}`. The
@@ -886,9 +908,17 @@ Post-commit via `emit_after_commit` (see `http/CLAUDE.md` §Pending Effects):
886
908
 
887
909
  - Create — `role_grant_offer_received` → recipient.
888
910
  - Retract — `role_grant_offer_retracted` → recipient.
889
- - 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).
890
912
  - Decline — `role_grant_offer_declined` → grantor.
891
- - 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`).
892
922
 
893
923
  Spec module is `auth/role_grant_offer_notifications.ts` —
894
924
  `RemoteNotificationActionSpec`s with `@fuzdev/fuz_schema` params schemas and
@@ -903,23 +933,19 @@ notification is `role_grant_revoked`, not the admin action's
903
933
  `role_grant_revoke`, so the two methods never collide. They never reach
904
934
  dispatch: an inbound frame for one is answered `method_not_found`. They are not SSE events; `role_grant_offer_notification_specs`
905
935
  holds them as `EventSpec`s for a consumer that broadcasts them on an SSE
906
- channel of its own. Under DEV, `create_role_grant_offer_actions` wraps the
907
- sender in `create_validated_notification_sender`, which checks each params
908
- object against its spec's `input` and logs a mismatch, sending it either way;
909
- 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.
910
939
 
911
- Deps: `RevokingActionFactoryDeps & {notification_sender?: NotificationSender | null}`.
940
+ Deps: `RevokingActionFactoryDeps`.
912
941
  `role_grant_revoke` of a global grant queues a close of the revokee account's
913
942
  connections gated on the role (`queue_connection_close`, `{kind: 'role'}`),
914
943
  run after the transaction commits and independent of the audit row's
915
944
  announcement; the revocation guard repeats it on the announced row. A scoped revoke
916
945
  closes nothing — a role gate admits on global grants alone.
917
- `NotificationSender` is the narrow structural capability
918
- (`send_to_account(account_id, message): number`); `ConnectionRegistry`
919
- satisfies it structurally. Target account travels via the send argument, not
920
- the payload — `revoked_by` is deliberately not in the `role_grant_revoked`
921
- payload (the revokee doesn't need to learn the admin's identity). When
922
- `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).
923
949
 
924
950
  Options: `roles?: RoleRegistry` (drives admin-grant-path lookup),
925
951
  `default_ttl_ms?` (defaults to `ROLE_GRANT_OFFER_DEFAULT_TTL_MS` = 30 days),
@@ -937,12 +963,11 @@ Options: `roles?: RoleRegistry` (drives admin-grant-path lookup),
937
963
  - `account_token_list_action_spec` — read; input fuz_schema's `void`; output `{tokens}`, each a `ClientApiTokenJson`.
938
964
  - `account_token_revoke_action_spec` — mutation; input `{token_id}`; output `{ok, revoked}`.
939
965
 
940
- `account_verify` is intentionally on both surfaces: the REST `GET /verify`
941
- shim is a status-only nginx probe; the RPC action returns
942
- `SessionAccountJson` for programmatic callers. Only the RPC action is open to a
943
- narrowed token that names it: the REST probe is the `surface:account_verify`
944
- rule-3 surface, refused to every narrowed token, and `GET /status` answers one
945
- as the anonymous caller.
966
+ `account_verify` is the credential probe on both spines: it returns
967
+ `SessionAccountJson`, and a narrowed token that names it may call it.
968
+ `GET /status` answers a narrowed token as the anonymous caller. There is no
969
+ REST probe (an nginx `auth_request` gate would need one mounted on both
970
+ spines).
946
971
 
947
972
  `session_id` validates as `SessionId`, the fuz_schema `Blake3Hash` branded;
948
973
  `token_id` as `ApiTokenId` (`tok_[A-Za-z0-9_-]{12}`). Every input and output
@@ -974,9 +999,9 @@ app-settings methods are always wired). Frontend mirror is
974
999
 
975
1000
  Option routing — `roles` is shared between admin + role-grant-offer;
976
1001
  `default_ttl_ms` + `authorize` → role-grant-offer
977
- only; `max_tokens` → account only. On `deps`: `notification_sender` →
978
- role-grant-offer only; `connection_closer` (required) → admin, account, and
979
- 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`.
980
1005
 
981
1006
  Pair with `create_app_server`'s `rpc_endpoints` factory form
982
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;AAwBhG,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,CA+LjB,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"}
@@ -30,9 +30,11 @@
30
30
  import { to_error_message } from '@fuzdev/fuz_util/error.ts';
31
31
  import { rpc_action } from '../actions/action_types.js';
32
32
  import { jsonrpc_errors } from '../http/jsonrpc_errors.js';
33
+ import { ERROR_AUTHENTICATION_REQUIRED } from '../http/error_schemas.js';
33
34
  import { queue_connection_close } from '../actions/connection_closer.js';
34
35
  import { to_session_account } from './account_schema.js';
35
- import { query_session_list_for_account, query_session_revoke_for_account, query_session_revoke_all_for_account } from './session_queries.js';
36
+ import { query_account_by_id, query_account_lock_live } from './account_queries.js';
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';
36
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';
37
39
  import { parse_stored_token_scope, serialize_token_scope, token_scope_from_input, token_scope_label } from './token_scope.js';
38
40
  import { token_lifetime_to_expires_at } from './token_lifetime.js';
@@ -54,8 +56,18 @@ import { account_verify_action_spec, account_session_list_action_spec, account_s
54
56
  export const create_account_actions = (deps, options = {}) => {
55
57
  const { max_tokens = DEFAULT_MAX_TOKENS } = options;
56
58
  const { connection_closer } = deps;
57
- const verify_handler = (_input, ctx) => {
58
- 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);
59
71
  };
60
72
  const session_list_handler = async (_input, ctx) => {
61
73
  const sessions = await query_session_list_for_account(ctx, ctx.auth.account.id);
@@ -131,6 +143,21 @@ export const create_account_actions = (deps, options = {}) => {
131
143
  // `input.lifetime` is required for the same reason — an omitted lifetime
132
144
  // is a validation error, never an eternal token.
133
145
  const expires_at = token_lifetime_to_expires_at(input.lifetime);
146
+ // The session that authorized this was read before the transaction. A
147
+ // delete or a password change committed since mints nothing — refused as
148
+ // the dead session it now is, the two losers one answer — and one still
149
+ // to commit waits on the account lock and then revokes the token: both
150
+ // write the account row before they revoke (`query_account_lock_live`,
151
+ // then `query_session_is_live`, which sees a revoke committed before
152
+ // the lock was granted).
153
+ const session_hash = ctx.session_hash;
154
+ if (!(await query_account_lock_live(ctx, ctx.auth.account.id)) ||
155
+ session_hash === null ||
156
+ !(await query_session_is_live(ctx, session_hash, ctx.auth.account.id))) {
157
+ throw jsonrpc_errors.unauthenticated('unauthenticated', {
158
+ reason: ERROR_AUTHENTICATION_REQUIRED
159
+ });
160
+ }
134
161
  await query_create_api_token(ctx, id, ctx.auth.account.id, input.name, token_hash, scope, expires_at);
135
162
  if (max_tokens != null) {
136
163
  const evicted = await query_api_token_enforce_limit(ctx, ctx.auth.account.id, max_tokens);