@fuzdev/fuz_app 0.182.0 → 0.184.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (295) hide show
  1. package/README.md +2 -0
  2. package/dist/actions/CLAUDE.md +535 -1223
  3. package/dist/actions/action_codegen.d.ts +1 -1
  4. package/dist/actions/action_codegen.d.ts.map +1 -1
  5. package/dist/actions/action_codegen.js +3 -2
  6. package/dist/actions/connection_closer.d.ts +11 -9
  7. package/dist/actions/connection_closer.d.ts.map +1 -1
  8. package/dist/actions/connection_closer.js +11 -9
  9. package/dist/actions/frontend_rpc_client.d.ts +1 -1
  10. package/dist/actions/register_action_ws.d.ts +14 -1
  11. package/dist/actions/register_action_ws.d.ts.map +1 -1
  12. package/dist/actions/register_action_ws.js +2 -1
  13. package/dist/actions/ws_socket_session.d.ts +9 -1
  14. package/dist/actions/ws_socket_session.d.ts.map +1 -1
  15. package/dist/actions/ws_socket_session.js +43 -19
  16. package/dist/auth/CLAUDE.md +430 -1024
  17. package/dist/auth/account_queries.d.ts +1 -1
  18. package/dist/auth/account_queries.js +1 -1
  19. package/dist/auth/account_routes.d.ts +9 -8
  20. package/dist/auth/account_routes.d.ts.map +1 -1
  21. package/dist/auth/account_routes.js +78 -75
  22. package/dist/auth/admin_actions.d.ts.map +1 -1
  23. package/dist/auth/admin_actions.js +32 -28
  24. package/dist/auth/api_token.d.ts +20 -3
  25. package/dist/auth/api_token.d.ts.map +1 -1
  26. package/dist/auth/api_token.js +28 -9
  27. package/dist/auth/api_token_queries.d.ts +2 -2
  28. package/dist/auth/api_token_queries.js +2 -2
  29. package/dist/auth/audit_emitter.d.ts +75 -84
  30. package/dist/auth/audit_emitter.d.ts.map +1 -1
  31. package/dist/auth/audit_emitter.js +83 -71
  32. package/dist/auth/audit_log_schema.d.ts +25 -14
  33. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  34. package/dist/auth/audit_log_schema.js +23 -8
  35. package/dist/auth/auth_guard_resolver.d.ts +1 -1
  36. package/dist/auth/auth_guard_resolver.js +1 -1
  37. package/dist/auth/bearer_auth.d.ts +2 -5
  38. package/dist/auth/bearer_auth.d.ts.map +1 -1
  39. package/dist/auth/bearer_auth.js +4 -13
  40. package/dist/auth/bootstrap_account.d.ts +42 -26
  41. package/dist/auth/bootstrap_account.d.ts.map +1 -1
  42. package/dist/auth/bootstrap_account.js +36 -19
  43. package/dist/auth/bootstrap_routes.d.ts +20 -21
  44. package/dist/auth/bootstrap_routes.d.ts.map +1 -1
  45. package/dist/auth/bootstrap_routes.js +26 -31
  46. package/dist/auth/bootstrap_token_store.d.ts +3 -4
  47. package/dist/auth/bootstrap_token_store.d.ts.map +1 -1
  48. package/dist/auth/bootstrap_token_store.js +1 -1
  49. package/dist/auth/daemon_token.d.ts +5 -1
  50. package/dist/auth/daemon_token.d.ts.map +1 -1
  51. package/dist/auth/daemon_token_middleware.d.ts +12 -8
  52. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  53. package/dist/auth/daemon_token_middleware.js +15 -21
  54. package/dist/auth/deps.d.ts +19 -5
  55. package/dist/auth/deps.d.ts.map +1 -1
  56. package/dist/auth/deps.js +3 -2
  57. package/dist/auth/invite_queries.d.ts +51 -3
  58. package/dist/auth/invite_queries.d.ts.map +1 -1
  59. package/dist/auth/invite_queries.js +81 -6
  60. package/dist/auth/invite_schema.d.ts +2 -1
  61. package/dist/auth/invite_schema.d.ts.map +1 -1
  62. package/dist/auth/middleware.d.ts +2 -3
  63. package/dist/auth/middleware.d.ts.map +1 -1
  64. package/dist/auth/middleware.js +3 -3
  65. package/dist/auth/request_context.d.ts +3 -3
  66. package/dist/auth/request_context.js +3 -3
  67. package/dist/auth/resolved_auth.d.ts +7 -7
  68. package/dist/auth/resolved_auth.d.ts.map +1 -1
  69. package/dist/auth/resolved_auth.js +4 -4
  70. package/dist/auth/role_grant_offer_actions.d.ts +27 -3
  71. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  72. package/dist/auth/role_grant_offer_actions.js +42 -35
  73. package/dist/auth/role_grant_offer_queries.d.ts +60 -4
  74. package/dist/auth/role_grant_offer_queries.d.ts.map +1 -1
  75. package/dist/auth/role_grant_offer_queries.js +79 -5
  76. package/dist/auth/role_grant_queries.d.ts +3 -52
  77. package/dist/auth/role_grant_queries.d.ts.map +1 -1
  78. package/dist/auth/role_grant_queries.js +5 -80
  79. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  80. package/dist/auth/self_service_role_actions.js +11 -22
  81. package/dist/auth/session_cookie.d.ts +82 -174
  82. package/dist/auth/session_cookie.d.ts.map +1 -1
  83. package/dist/auth/session_cookie.js +80 -130
  84. package/dist/auth/session_middleware.d.ts +8 -17
  85. package/dist/auth/session_middleware.d.ts.map +1 -1
  86. package/dist/auth/session_middleware.js +14 -23
  87. package/dist/auth/session_queries.d.ts +15 -17
  88. package/dist/auth/session_queries.d.ts.map +1 -1
  89. package/dist/auth/session_queries.js +28 -20
  90. package/dist/auth/signup_routes.d.ts.map +1 -1
  91. package/dist/auth/signup_routes.js +93 -43
  92. package/dist/db/CLAUDE.md +5 -3
  93. package/dist/db/sql_columns.d.ts +1 -1
  94. package/dist/db/sql_columns.js +1 -1
  95. package/dist/dev/setup.d.ts +3 -1
  96. package/dist/dev/setup.d.ts.map +1 -1
  97. package/dist/dev/setup.js +3 -1
  98. package/dist/http/CLAUDE.md +315 -763
  99. package/dist/http/db_routes.d.ts +8 -23
  100. package/dist/http/db_routes.d.ts.map +1 -1
  101. package/dist/http/db_routes.js +73 -73
  102. package/dist/http/origin.d.ts +7 -8
  103. package/dist/http/origin.d.ts.map +1 -1
  104. package/dist/http/origin.js +7 -8
  105. package/dist/http/pending_effects.d.ts +118 -6
  106. package/dist/http/pending_effects.d.ts.map +1 -1
  107. package/dist/http/pending_effects.js +114 -6
  108. package/dist/http/route_result.d.ts +1 -1
  109. package/dist/http/route_spec.d.ts +14 -11
  110. package/dist/http/route_spec.d.ts.map +1 -1
  111. package/dist/realtime/sse.d.ts +4 -23
  112. package/dist/realtime/sse.d.ts.map +1 -1
  113. package/dist/realtime/sse.js +4 -25
  114. package/dist/server/app_backend.d.ts +4 -5
  115. package/dist/server/app_backend.d.ts.map +1 -1
  116. package/dist/server/app_backend.js +3 -1
  117. package/dist/server/app_server.d.ts +80 -16
  118. package/dist/server/app_server.d.ts.map +1 -1
  119. package/dist/server/app_server.js +113 -31
  120. package/dist/server/app_server_context.d.ts +1 -2
  121. package/dist/server/app_server_context.d.ts.map +1 -1
  122. package/dist/server/env.js +2 -2
  123. package/dist/testing/CLAUDE.md +265 -796
  124. package/dist/testing/admin_integration.d.ts +2 -3
  125. package/dist/testing/admin_integration.d.ts.map +1 -1
  126. package/dist/testing/admin_integration.js +3 -3
  127. package/dist/testing/adversarial_404.d.ts +6 -1
  128. package/dist/testing/adversarial_404.d.ts.map +1 -1
  129. package/dist/testing/adversarial_404.js +38 -17
  130. package/dist/testing/app_server.d.ts +23 -148
  131. package/dist/testing/app_server.d.ts.map +1 -1
  132. package/dist/testing/app_server.js +53 -131
  133. package/dist/testing/attack_surface.d.ts +1 -1
  134. package/dist/testing/attack_surface.d.ts.map +1 -1
  135. package/dist/testing/audit_completeness.d.ts +2 -3
  136. package/dist/testing/audit_completeness.d.ts.map +1 -1
  137. package/dist/testing/audit_completeness.js +1 -1
  138. package/dist/testing/audit_drift_guard.d.ts +11 -6
  139. package/dist/testing/audit_drift_guard.d.ts.map +1 -1
  140. package/dist/testing/audit_drift_guard.js +15 -8
  141. package/dist/testing/cross_backend/audit_cross_helpers.d.ts +12 -9
  142. package/dist/testing/cross_backend/audit_cross_helpers.d.ts.map +1 -1
  143. package/dist/testing/cross_backend/audit_cross_helpers.js +13 -14
  144. package/dist/testing/cross_backend/capabilities.d.ts +9 -6
  145. package/dist/testing/cross_backend/capabilities.d.ts.map +1 -1
  146. package/dist/testing/cross_backend/capabilities.js +11 -7
  147. package/dist/testing/cross_backend/capability_mounts.d.ts +103 -0
  148. package/dist/testing/cross_backend/capability_mounts.d.ts.map +1 -0
  149. package/dist/testing/cross_backend/capability_mounts.js +428 -0
  150. package/dist/testing/cross_backend/cell_moderate.js +2 -2
  151. package/dist/testing/cross_backend/cell_relations.d.ts.map +1 -1
  152. package/dist/testing/cross_backend/cell_relations.js +12 -11
  153. package/dist/testing/cross_backend/conformance_principal.d.ts +54 -0
  154. package/dist/testing/cross_backend/conformance_principal.d.ts.map +1 -0
  155. package/dist/testing/cross_backend/conformance_principal.js +283 -0
  156. package/dist/testing/cross_backend/conformance_table.d.ts +7 -56
  157. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  158. package/dist/testing/cross_backend/conformance_table.js +6 -274
  159. package/dist/testing/cross_backend/cookie_attributes.js +1 -1
  160. package/dist/testing/cross_backend/credential_deadline.d.ts.map +1 -1
  161. package/dist/testing/cross_backend/credential_deadline.js +2 -0
  162. package/dist/testing/cross_backend/credential_wire.d.ts +1 -1
  163. package/dist/testing/cross_backend/credential_wire.d.ts.map +1 -1
  164. package/dist/testing/cross_backend/db_state_diff.d.ts +72 -0
  165. package/dist/testing/cross_backend/db_state_diff.d.ts.map +1 -0
  166. package/dist/testing/cross_backend/db_state_diff.js +444 -0
  167. package/dist/testing/cross_backend/declared_skips.d.ts +68 -0
  168. package/dist/testing/cross_backend/declared_skips.d.ts.map +1 -0
  169. package/dist/testing/cross_backend/declared_skips.js +132 -0
  170. package/dist/testing/cross_backend/default_backend_configs.d.ts +3 -3
  171. package/dist/testing/cross_backend/default_spine_surface.d.ts +0 -6
  172. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  173. package/dist/testing/cross_backend/default_spine_surface.js +4 -9
  174. package/dist/testing/cross_backend/differential.d.ts +13 -5
  175. package/dist/testing/cross_backend/differential.d.ts.map +1 -1
  176. package/dist/testing/cross_backend/differential.js +35 -11
  177. package/dist/testing/cross_backend/differential_normalize.d.ts +12 -0
  178. package/dist/testing/cross_backend/differential_normalize.d.ts.map +1 -1
  179. package/dist/testing/cross_backend/differential_normalize.js +16 -0
  180. package/dist/testing/cross_backend/full_spine_mount.d.ts +1 -42
  181. package/dist/testing/cross_backend/full_spine_mount.d.ts.map +1 -1
  182. package/dist/testing/cross_backend/full_spine_mount.js +45 -4
  183. package/dist/testing/cross_backend/in_process_setup.d.ts +28 -19
  184. package/dist/testing/cross_backend/in_process_setup.d.ts.map +1 -1
  185. package/dist/testing/cross_backend/in_process_setup.js +156 -142
  186. package/dist/testing/cross_backend/login_security.d.ts +12 -0
  187. package/dist/testing/cross_backend/login_security.d.ts.map +1 -1
  188. package/dist/testing/cross_backend/login_security.js +21 -4
  189. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts +0 -2
  190. package/dist/testing/cross_backend/request_target_conformance_wire.d.ts.map +1 -1
  191. package/dist/testing/cross_backend/request_target_conformance_wire.js +3 -1
  192. package/dist/testing/cross_backend/revocation_drivers.d.ts +18 -5
  193. package/dist/testing/cross_backend/revocation_drivers.d.ts.map +1 -1
  194. package/dist/testing/cross_backend/revocation_drivers.js +18 -10
  195. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts +1 -1
  196. package/dist/testing/cross_backend/role_grant_cross_helpers.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/role_grant_offer_lifecycle.d.ts.map +1 -1
  198. package/dist/testing/cross_backend/role_grant_offer_lifecycle.js +33 -1
  199. package/dist/testing/cross_backend/role_grant_participation.js +4 -4
  200. package/dist/testing/cross_backend/rpc_adversarial.js +1 -1
  201. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -4
  202. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  203. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +2 -2
  204. package/dist/testing/cross_backend/session_cap.d.ts +2 -2
  205. package/dist/testing/cross_backend/session_cap.d.ts.map +1 -1
  206. package/dist/testing/cross_backend/session_cap.js +22 -11
  207. package/dist/testing/cross_backend/setup.d.ts +32 -2
  208. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  209. package/dist/testing/cross_backend/setup.js +32 -1
  210. package/dist/testing/cross_backend/spine_suites.d.ts +125 -15
  211. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  212. package/dist/testing/cross_backend/spine_suites.js +459 -62
  213. package/dist/testing/cross_backend/spine_surface_constants.d.ts +1 -1
  214. package/dist/testing/cross_backend/spine_surface_constants.d.ts.map +1 -1
  215. package/dist/testing/cross_backend/spine_surface_constants.js +1 -0
  216. package/dist/testing/cross_backend/sse_round_trip.d.ts +9 -1
  217. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  218. package/dist/testing/cross_backend/sse_round_trip.js +123 -27
  219. package/dist/testing/cross_backend/standard.d.ts +2 -3
  220. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  221. package/dist/testing/cross_backend/standard.js +3 -3
  222. package/dist/testing/cross_backend/testing_backdoor.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/testing_backdoor.js +4 -2
  224. package/dist/testing/cross_backend/testing_credential_read.d.ts +10 -11
  225. package/dist/testing/cross_backend/testing_credential_read.d.ts.map +1 -1
  226. package/dist/testing/cross_backend/testing_credential_read.js +12 -12
  227. package/dist/testing/cross_backend/testing_reset_actions.d.ts +84 -47
  228. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  229. package/dist/testing/cross_backend/testing_reset_actions.js +95 -63
  230. package/dist/testing/cross_backend/testing_server_core.d.ts.map +1 -1
  231. package/dist/testing/cross_backend/testing_server_core.js +2 -3
  232. package/dist/testing/cross_backend/transport_composition.d.ts +1 -1
  233. package/dist/testing/cross_backend/transport_composition.d.ts.map +1 -1
  234. package/dist/testing/cross_backend/transport_composition.js +7 -3
  235. package/dist/testing/cross_backend/ws_round_trip.d.ts +5 -0
  236. package/dist/testing/cross_backend/ws_round_trip.d.ts.map +1 -1
  237. package/dist/testing/cross_backend/ws_round_trip.js +54 -8
  238. package/dist/testing/daemon_token_rotation.d.ts.map +1 -1
  239. package/dist/testing/daemon_token_rotation.js +2 -3
  240. package/dist/testing/data_exposure.d.ts.map +1 -1
  241. package/dist/testing/data_exposure.js +3 -0
  242. package/dist/testing/db.d.ts +0 -32
  243. package/dist/testing/db.d.ts.map +1 -1
  244. package/dist/testing/db.js +0 -86
  245. package/dist/testing/db_entities.d.ts +14 -0
  246. package/dist/testing/db_entities.d.ts.map +1 -1
  247. package/dist/testing/db_entities.js +17 -0
  248. package/dist/testing/db_invariant_queries.d.ts +259 -0
  249. package/dist/testing/db_invariant_queries.d.ts.map +1 -0
  250. package/dist/testing/db_invariant_queries.js +400 -0
  251. package/dist/testing/db_invariants.d.ts +106 -0
  252. package/dist/testing/db_invariants.d.ts.map +1 -0
  253. package/dist/testing/db_invariants.gen.sql.d.ts +11 -0
  254. package/dist/testing/db_invariants.gen.sql.d.ts.map +1 -0
  255. package/dist/testing/db_invariants.gen.sql.js +13 -0
  256. package/dist/testing/db_invariants.js +141 -0
  257. package/dist/testing/db_invariants.sql +152 -0
  258. package/dist/testing/describe_db.d.ts +36 -0
  259. package/dist/testing/describe_db.d.ts.map +1 -0
  260. package/dist/testing/describe_db.js +71 -0
  261. package/dist/testing/integration.d.ts +8 -12
  262. package/dist/testing/integration.d.ts.map +1 -1
  263. package/dist/testing/integration.js +13 -17
  264. package/dist/testing/integration_helpers.d.ts +1 -1
  265. package/dist/testing/integration_helpers.d.ts.map +1 -1
  266. package/dist/testing/rate_limiting.d.ts +3 -4
  267. package/dist/testing/rate_limiting.d.ts.map +1 -1
  268. package/dist/testing/rate_limiting.js +6 -5
  269. package/dist/testing/role_grant_helpers.d.ts +1 -1
  270. package/dist/testing/role_grant_helpers.d.ts.map +1 -1
  271. package/dist/testing/round_trip.d.ts.map +1 -1
  272. package/dist/testing/round_trip.js +3 -0
  273. package/dist/testing/rpc_attack_surface.d.ts +8 -6
  274. package/dist/testing/rpc_attack_surface.d.ts.map +1 -1
  275. package/dist/testing/rpc_attack_surface.js +69 -6
  276. package/dist/testing/rpc_helpers.d.ts +1 -2
  277. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  278. package/dist/testing/rpc_helpers.js +3 -3
  279. package/dist/testing/rpc_round_trip.d.ts +3 -4
  280. package/dist/testing/rpc_round_trip.d.ts.map +1 -1
  281. package/dist/testing/rpc_round_trip.js +4 -1
  282. package/dist/testing/sse_round_trip.d.ts +3 -4
  283. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  284. package/dist/testing/sse_round_trip.js +15 -6
  285. package/dist/testing/stubs.d.ts +9 -8
  286. package/dist/testing/stubs.d.ts.map +1 -1
  287. package/dist/testing/stubs.js +20 -13
  288. package/dist/testing/test_app.d.ts +168 -0
  289. package/dist/testing/test_app.d.ts.map +1 -0
  290. package/dist/testing/test_app.js +123 -0
  291. package/dist/testing/ws_round_trip.d.ts.map +1 -1
  292. package/dist/testing/ws_round_trip.js +3 -0
  293. package/dist/ui/ui_format.d.ts.map +1 -1
  294. package/dist/ui/ui_format.js +1 -2
  295. package/package.json +1 -1
@@ -30,7 +30,9 @@ import '../assert_dev_env.js';
30
30
  * **Mount flags have no default.** A flag naming something a backend mounts
31
31
  * (a `MountFlag`) is never inherited, nor is the `testing_backdoors` list: the
32
32
  * family defaults are `FamilyDefaultCapabilities`, which omits them, so every
33
- * backend config states each one. The family defaults carry only what the family guarantees — the
33
+ * backend config states each one, and `describe_capability_mounts_cross_tests`
34
+ * holds each a request can observe to what the backend mounts, `false` as
35
+ * much as `true`. The family defaults carry only what the family guarantees — the
34
36
  * declared spine surface's mounts, fallback and host gate (`account_lifecycle`,
35
37
  * `account_status`, `spine_fallback`, `host_gate`) and the runtime behavior of its
36
38
  * reference runtime (`ws_handshake_pipelining`,
@@ -46,6 +48,7 @@ import '../assert_dev_env.js';
46
48
  * @module
47
49
  */
48
50
  import { test } from 'vitest';
51
+ import { test_skip_gated } from './declared_skips.js';
49
52
  /**
50
53
  * The upgrade refusals a runtime makes before the app runs, which
51
54
  * `BackendCapabilities.ws_upgrade_runtime_refusals` declares: `empty_host`, an
@@ -108,18 +111,19 @@ export const in_process_capabilities = Object.freeze({
108
111
  });
109
112
  /**
110
113
  * Conditional `test()` wrapper — registers a vitest case only when
111
- * `cond` is true; otherwise registers it as `.skip` so the run still
112
- * surfaces the gated coverage in the report.
114
+ * `cond` is true; otherwise registers it as a gated skip
115
+ * (`test_skip_gated`), so the run still surfaces the gated coverage in the
116
+ * report and `check_declared_skips` can hold the skip to a declaration.
113
117
  *
114
- * Thin wrapper around vitest's `test.skipIf(!cond)` with the argument
115
- * order flipped to match the more readable `test_if(capabilities.ws, ...)`
116
- * call pattern.
118
+ * `test.skipIf(!cond)` with the argument order flipped to match the more
119
+ * readable `test_if(capabilities.ws, ...)` call pattern, and the skip tagged
120
+ * at registration.
117
121
  */
118
122
  export const test_if = (cond, name, fn) => {
119
123
  if (cond) {
120
124
  test(name, fn);
121
125
  }
122
126
  else {
123
- test.skip(name, fn);
127
+ test_skip_gated(name, fn);
124
128
  }
125
129
  };
@@ -0,0 +1,103 @@
1
+ import '../assert_dev_env.js';
2
+ import type { BackendCapabilities } from './capabilities.js';
3
+ import type { RpcPathCapabilityGatedCrossSuiteOptions, SetupTest } from './setup.js';
4
+ /** The capability flags a request can observe, each probed in both directions. */
5
+ export type ProbedCapability = keyof Pick<BackendCapabilities, 'ws' | 'sse' | 'cell_crud' | 'cell_relations' | 'fact_serving' | 'fact_serving_admin_hash' | 'ready' | 'account_status' | 'ws_account_actions' | 'ws_role_gated'>;
6
+ /** The capabilities no probe checks — every `BackendCapabilities` key but the probed ones. */
7
+ export type UnprobedCapability = Exclude<keyof BackendCapabilities, ProbedCapability>;
8
+ /**
9
+ * Why each unprobed capability has no probe, shown in the run as a skipped
10
+ * test. Keyed by `UnprobedCapability`, so a new flag fails to compile until it
11
+ * is either probed or listed here.
12
+ */
13
+ export declare const UNPROBED_CAPABILITIES: Readonly<Record<UnprobedCapability, string>>;
14
+ /** Options for the capability mount suite. */
15
+ export interface CapabilityMountsCrossTestOptions extends RpcPathCapabilityGatedCrossSuiteOptions {
16
+ /** Base URL the backend is reachable at (e.g. `http://localhost:1178`), for the upgrade probes. */
17
+ readonly base_url: string;
18
+ /** WebSocket endpoint path. Default `SPINE_WS_PATH`. */
19
+ readonly ws_path?: string;
20
+ /** Audit-log SSE stream path. Default `SPINE_SSE_PATH`. */
21
+ readonly sse_path?: string;
22
+ /** Role-gated WebSocket endpoint path. Default `SPINE_ROLE_GATED_WS_PATH`. */
23
+ readonly gated_ws_path?: string;
24
+ /** Readiness route path. Default `/ready`. */
25
+ readonly ready_path?: string;
26
+ /**
27
+ * A note per flag, added to that probe's failure — where its path came from
28
+ * and how to move it. `describe_spine_cross_suites` sets one for a flag
29
+ * whose path it reads from a sibling suite the call excludes.
30
+ */
31
+ readonly path_notes?: Readonly<Partial<Record<ProbedCapability, string>>>;
32
+ }
33
+ /**
34
+ * The suite's options with every path resolved — where the probes send. Each
35
+ * of these is a declaration as much as a flag is: a probe sent to the wrong
36
+ * path finds nothing mounted there.
37
+ *
38
+ * @internal Used by the suite's own tests and `describe_spine_cross_suites` — not stable API.
39
+ */
40
+ export interface CapabilityMountsTarget {
41
+ readonly base_url: string;
42
+ readonly rpc_path: string;
43
+ readonly ws_path: string;
44
+ readonly sse_path: string;
45
+ readonly gated_ws_path: string;
46
+ readonly ready_path: string;
47
+ }
48
+ /**
49
+ * Resolve the suite's paths, each option's default filled.
50
+ *
51
+ * @param options - the suite's options
52
+ * @returns where every probe sends
53
+ * @internal Used by the suite's own tests and `describe_spine_cross_suites`, which derives the
54
+ * suite's options resolved — not stable API.
55
+ */
56
+ export declare const resolve_capability_mounts_target: (options: Omit<CapabilityMountsCrossTestOptions, "setup_test" | "capabilities">) => CapabilityMountsTarget;
57
+ /**
58
+ * The name the unmounted controls send to: a path segment, RPC method and WS
59
+ * method no backend mounts.
60
+ */
61
+ export declare const CAPABILITY_MOUNTS_ABSENT = "capability_mounts_absent";
62
+ /** Every probed capability, in the order the suite runs them. */
63
+ export declare const PROBED_CAPABILITIES: ReadonlyArray<ProbedCapability>;
64
+ /**
65
+ * One test the suite registers: its describe group, name, and whether it runs.
66
+ *
67
+ * @internal Used by the suite's own tests — not stable API.
68
+ */
69
+ export interface CapabilityMountRow {
70
+ readonly group: 'capability mounts' | 'capability mount controls' | 'capability mounts not probed';
71
+ readonly name: string;
72
+ /**
73
+ * `run` sends and checks; `fail` fails at once (a contradictory
74
+ * declaration); `skip` is shown skipped (a flag no request observes);
75
+ * `gated_skip` is a skip the backend's declarations cause, registered
76
+ * through `test_skip_gated` so `check_declared_skips` holds it.
77
+ */
78
+ readonly mode: 'run' | 'fail' | 'skip' | 'gated_skip';
79
+ /** The check a `run` row makes, or the failure a `fail` row reports. */
80
+ readonly body: (setup_test: SetupTest) => Promise<void>;
81
+ }
82
+ /**
83
+ * Plan the suite's tests from a backend's capabilities and paths — what
84
+ * `describe_capability_mounts_cross_tests` registers, as data, so the
85
+ * classification is checkable without a backend.
86
+ *
87
+ * @param capabilities - the backend's declarations
88
+ * @param target - where the probes send
89
+ * @param path_notes - a note per flag added to its probe's failure
90
+ * @returns every row, in registration order
91
+ * @internal Used by the suite's own tests — not stable API.
92
+ */
93
+ export declare const plan_capability_mount_rows: (capabilities: BackendCapabilities, target: CapabilityMountsTarget, path_notes?: Readonly<Partial<Record<ProbedCapability, string>>>) => Array<CapabilityMountRow>;
94
+ /**
95
+ * Register the capability mount suite: one probe per `ProbedCapability`, each
96
+ * asserting the backend's answer matches its declaration, the same probe again
97
+ * as an unmounted control, and one skipped test per `UNPROBED_CAPABILITIES`
98
+ * entry naming why.
99
+ *
100
+ * @param options - the fixture, the backend's capabilities, and its paths
101
+ */
102
+ export declare const describe_capability_mounts_cross_tests: (options: CapabilityMountsCrossTestOptions) => void;
103
+ //# sourceMappingURL=capability_mounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"capability_mounts.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/capability_mounts.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAyF9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,KAAK,EAAE,uCAAuC,EAAE,SAAS,EAAe,MAAM,YAAY,CAAC;AAUlG,kFAAkF;AAClF,MAAM,MAAM,gBAAgB,GAAG,MAAM,IAAI,CACxC,mBAAmB,EACjB,IAAI,GACJ,KAAK,GACL,WAAW,GACX,gBAAgB,GAChB,cAAc,GACd,yBAAyB,GACzB,OAAO,GACP,gBAAgB,GAChB,oBAAoB,GACpB,eAAe,CACjB,CAAC;AAEF,8FAA8F;AAC9F,MAAM,MAAM,kBAAkB,GAAG,OAAO,CAAC,MAAM,mBAAmB,EAAE,gBAAgB,CAAC,CAAC;AAEtF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,EAAE,QAAQ,CAAC,MAAM,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAqB7E,CAAC;AAEH,8CAA8C;AAC9C,MAAM,WAAW,gCAAiC,SAAQ,uCAAuC;IAChG,mGAAmG;IACnG,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,2DAA2D;IAC3D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,8EAA8E;IAC9E,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;CAC1E;AAQD;;;;;;GAMG;AACH,MAAM,WAAW,sBAAsB;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gCAAgC,GAC5C,SAAS,IAAI,CAAC,gCAAgC,EAAE,YAAY,GAAG,cAAc,CAAC,KAC5E,sBAOD,CAAC;AAmCH;;;GAGG;AACH,eAAO,MAAM,wBAAwB,6BAA6B,CAAC;AAoNnE,iEAAiE;AACjE,eAAO,MAAM,mBAAmB,EAAE,aAAa,CAAC,gBAAgB,CAE/D,CAAC;AAEF;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,KAAK,EACb,mBAAmB,GAAG,2BAA2B,GAAG,8BAA8B,CAAC;IACpF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;OAKG;IACH,QAAQ,CAAC,IAAI,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,GAAG,YAAY,CAAC;IACtD,wEAAwE;IACxE,QAAQ,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,SAAS,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxD;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,GACtC,cAAc,mBAAmB,EACjC,QAAQ,sBAAsB,EAC9B,aAAY,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,CAAC,CAAM,KAClE,KAAK,CAAC,kBAAkB,CA4F1B,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,sCAAsC,GAClD,SAAS,gCAAgC,KACvC,IAyBF,CAAC"}
@@ -0,0 +1,428 @@
1
+ import '../assert_dev_env.js';
2
+ /**
3
+ * Cross-backend suite holding a backend's mount flags to what it mounts, in
4
+ * both directions.
5
+ *
6
+ * A capability flag gates the suites that need its surface: `true` runs them,
7
+ * `false` skips them. Nothing in those suites checks a `false` — a backend
8
+ * declaring `cell_crud: false` while mounting the cell verbs skips the cell
9
+ * suites, and its cell surface goes untested with no failure anywhere. And on a
10
+ * backend declaring every flag `true`, as fuz_app's own spine presets do, a
11
+ * check of the `false` direction alone would never run. So each flag a request
12
+ * can observe is probed once, and the observation must equal the declaration:
13
+ * `true` must answer as mounted, `false` as unmounted.
14
+ *
15
+ * Each probe is the cheapest honest request — anonymous, so no setup state
16
+ * shapes the answer — and none of them answers a mounted surface with a `404`.
17
+ * An unmounted path under `/api` answers `404`: the spine's JSON
18
+ * `route_not_found`, or, for a refused upgrade only, no body where the runtime
19
+ * drops it (`ws_refusal_body`).
20
+ *
21
+ * - **RPC verbs** (`cell_crud`: `cell_create`, `cell_relations`:
22
+ * `cell_grant_create`) — both spines look a method up before they
23
+ * authenticate the caller, so a mounted verb refuses an anonymous call `401`
24
+ * and an unmounted one answers `method_not_found` (`404`).
25
+ * - **Auth-gated routes** (`sse` on `sse_path`, `account_status`) — a mounted
26
+ * route refuses an anonymous `GET` `401`.
27
+ * - **The fact routes** (`fact_serving`, `fact_serving_admin_hash`) — a
28
+ * malformed `hash` param: both spines validate a route's params ahead of
29
+ * auth, so a mounted route answers `400` `invalid_route_params`. (The cell
30
+ * route's masked `404` for a cell no row names can't tell itself from an
31
+ * unmatched `404`.)
32
+ * - **`ready`** — `GET /ready` answers `200 {ready: true}`, or `503` with
33
+ * `schema_drift` / `db_unreachable` (mounted, if drifted — the readiness
34
+ * suite fails that); unmounted, a `404` (any body — the spine fallback's
35
+ * plain text) or a `200` that isn't JSON (a static page).
36
+ * - **WebSocket endpoints** (`ws` on `ws_path`, `ws_role_gated` on the gated
37
+ * path) — a mounted endpoint refuses an anonymous upgrade `401`.
38
+ * - **`ws_account_actions`** — `account_verify` sent on the keeper's session
39
+ * socket answers unless the endpoint lacks it (`method_not_found`). Needs
40
+ * `ws`: with `ws` declared `false` the probe is skipped when the flag is
41
+ * `false` too, and fails when it is `true`.
42
+ *
43
+ * An answer that is neither the mounted nor the unmounted one fails the probe.
44
+ *
45
+ * **Unmounted controls.** On a backend declaring every probed flag `true`, as
46
+ * fuz_app's spine presets do, no probe meets an unmounted surface, so a
47
+ * classifier reading every answer as mounted would pass. Each flag's own probe
48
+ * is also sent to its surface moved where no backend mounts anything
49
+ * (`CAPABILITY_MOUNTS_ABSENT` — the path under an absent segment, the method
50
+ * renamed), and must read as unmounted, on every backend. So a backend with a
51
+ * catch-all under `/api`, or an RPC dispatcher answering an unknown method,
52
+ * fails the controls: the suite rests on the spine's `404` and
53
+ * `method_not_found` for what isn't mounted.
54
+ *
55
+ * The other flags are listed in `UNPROBED_CAPABILITIES` with why no request
56
+ * checks them, and each shows in the run as a skipped test carrying that
57
+ * reason. `ProbedCapability` and `UNPROBED_CAPABILITIES` together are
58
+ * exhaustive over `BackendCapabilities` by their types, so a new flag fails to
59
+ * compile until it is classified.
60
+ *
61
+ * `describe_spine_cross_suites` runs this suite on every backend and refuses to
62
+ * exclude it, exclude one of its cases, or override any of its options: it
63
+ * checks the declarations every other suite gates on, so each path it probes
64
+ * is the one the suites gated on that flag send to — the backend config's,
65
+ * `ws_role_gated`'s `gated_ws_path`, `ready`'s `ready_path`, and the
66
+ * `SPINE_ACCOUNT_STATUS_PATH` that `query_shape`, `token_scope_surface` and
67
+ * `request_target_conformance_wire` (each gated on `account_status`) send to.
68
+ * A probe whose sibling suite the call excludes falls back to the spine
69
+ * default, and its failure names the remedy (`path_notes`). It runs cross-process
70
+ * only — in-process apps are assembled per test file, each mounting what its
71
+ * suite needs, so no one in-process declaration describes them, and the WS
72
+ * probes need a real socket.
73
+ *
74
+ * @module
75
+ */
76
+ import { describe, test, assert } from 'vitest';
77
+ import { ERROR_DB_UNREACHABLE, ERROR_INVALID_ROUTE_PARAMS, ERROR_ROUTE_NOT_FOUND, ERROR_SCHEMA_DRIFT } from '../../http/error_schemas.js';
78
+ import { JSONRPC_ERROR_CODES } from '../../http/jsonrpc_errors.js';
79
+ import { rpc_call } from '../rpc_helpers.js';
80
+ import { create_ws_transport, WsUpgradeRefusedError } from '../transports/ws_transport.js';
81
+ import { is_response_for } from '../transports/ws_client.js';
82
+ import { test_skip_gated } from './declared_skips.js';
83
+ import { SPINE_ACCOUNT_STATUS_PATH, SPINE_ROLE_GATED_WS_PATH, SPINE_RPC_PATH, SPINE_SSE_PATH, SPINE_WS_PATH } from './spine_surface_constants.js';
84
+ import { open_session_ws } from './ws_endpoint.js';
85
+ /**
86
+ * Why each unprobed capability has no probe, shown in the run as a skipped
87
+ * test. Keyed by `UnprobedCapability`, so a new flag fails to compile until it
88
+ * is either probed or listed here.
89
+ */
90
+ export const UNPROBED_CAPABILITIES = Object.freeze({
91
+ account_lifecycle: 'gates behavior, not a mount: the lifecycle verbs are on the declared surface, whose round-trip and attack-surface suites already reach them',
92
+ peer_request: 'the server→client request direction (`peer/ping`, a protocol action), which no request a client sends can observe; the peer suite drives it',
93
+ cell_gated_create: 'names a test policy over the cell verbs, not a mount — a backend mounting the verbs over its own policy states `false`; `cell_crud` probes the verbs',
94
+ rooms: 'names a test policy (the test room authorizer) over the room verbs, not a mount — a backend mounting rooms over its own authorizer states `false`',
95
+ ws_handshake_pipelining: "a trait of the backend's HTTP runtime, not a mount",
96
+ ws_refusal_body: "a trait of the backend's HTTP runtime, not a mount",
97
+ ws_upgrade_runtime_refusals: "a trait of the backend's HTTP runtime, not a mount; the request header wire leg fails a declaration the runtime doesn't honor",
98
+ runtime_resolves_dot_segments: "a trait of the backend's HTTP runtime, not a mount; the request target wire leg fails a declaration the runtime doesn't honor",
99
+ spine_fallback: "the fallback's behavior, not a mount; the request target wire leg's rows outside `/api` fail a `true` the backend doesn't honor",
100
+ host_gate: "the host gate's configuration, not a mount; the request header wire leg's host rows fail a `true` the backend doesn't honor",
101
+ testing_backdoors: 'a list, checked against the backend in both directions by the testing-backdoor suite'
102
+ });
103
+ /**
104
+ * Resolve the suite's paths, each option's default filled.
105
+ *
106
+ * @param options - the suite's options
107
+ * @returns where every probe sends
108
+ * @internal Used by the suite's own tests and `describe_spine_cross_suites`, which derives the
109
+ * suite's options resolved — not stable API.
110
+ */
111
+ export const resolve_capability_mounts_target = (options) => ({
112
+ base_url: options.base_url,
113
+ rpc_path: options.rpc_path ?? SPINE_RPC_PATH,
114
+ ws_path: options.ws_path ?? SPINE_WS_PATH,
115
+ sse_path: options.sse_path ?? SPINE_SSE_PATH,
116
+ gated_ws_path: options.gated_ws_path ?? SPINE_ROLE_GATED_WS_PATH,
117
+ ready_path: options.ready_path ?? '/ready'
118
+ });
119
+ /** A well-formed UUID no row has. */
120
+ const PROBE_CELL_ID = '00000000-0000-4000-8000-000000000000';
121
+ /**
122
+ * A `hash` param no fact route accepts: both spines validate a route's params
123
+ * ahead of auth and answer the flat `400` `invalid_route_params`, an answer
124
+ * only a mounted route gives.
125
+ */
126
+ const PROBE_MALFORMED_FACT_HASH = 'not-a-hash';
127
+ /**
128
+ * The name the unmounted controls send to: a path segment, RPC method and WS
129
+ * method no backend mounts.
130
+ */
131
+ export const CAPABILITY_MOUNTS_ABSENT = 'capability_mounts_absent';
132
+ /** A path moved under `CAPABILITY_MOUNTS_ABSENT`, inside `/api` when it was. */
133
+ const to_absent_path = (path) => path.startsWith('/api/')
134
+ ? `/api/${CAPABILITY_MOUNTS_ABSENT}${path.slice('/api'.length)}`
135
+ : `/${CAPABILITY_MOUNTS_ABSENT}${path}`;
136
+ /** A method renamed under `CAPABILITY_MOUNTS_ABSENT`. */
137
+ const to_absent_method = (method) => `${CAPABILITY_MOUNTS_ABSENT}_${method}`;
138
+ /** `path_of`'s path, moved when `absent`. */
139
+ const locate = (path_of, t, absent) => (absent ? to_absent_path(path_of(t)) : path_of(t));
140
+ /** Parse JSON text, `undefined` when it isn't JSON. */
141
+ const parse_json = (text) => {
142
+ try {
143
+ return JSON.parse(text);
144
+ }
145
+ catch {
146
+ return undefined;
147
+ }
148
+ };
149
+ const error_of = (json) => json !== null && typeof json === 'object' ? json.error : undefined;
150
+ /** A status and the start of its body, for a failure message. */
151
+ const describe_answer = (status, text) => `${status} ${text === '' ? '(no body)' : text.slice(0, 200)}`;
152
+ /**
153
+ * Whether an answer is an unmatched path's `404` under `/api`: the spine's JSON
154
+ * `route_not_found`. No probe's mounted answer is a `404`.
155
+ */
156
+ const is_unmatched_404 = (status, text) => status === 404 && error_of(parse_json(text)) === ERROR_ROUTE_NOT_FOUND;
157
+ const UNMATCHED_404 = `404 ${ERROR_ROUTE_NOT_FOUND}`;
158
+ /**
159
+ * Whether a refused upgrade is an unmatched path's `404`: `is_unmatched_404`,
160
+ * or a bodiless one — what a runtime dropping a refused upgrade's body
161
+ * (`ws_refusal_body`) sends.
162
+ */
163
+ const is_unmatched_upgrade_404 = (status, text) => is_unmatched_404(status, text) || (status === 404 && text === '');
164
+ const UNMATCHED_UPGRADE_404 = `404 (${ERROR_ROUTE_NOT_FOUND} or no body)`;
165
+ /** An anonymous RPC call: `401` mounted, `method_not_found` unmounted. */
166
+ const rpc_probe = (declared_method) => ({
167
+ request: (t, absent) => `anonymous \`${absent ? to_absent_method(declared_method) : declared_method}\` on ${t.rpc_path}`,
168
+ mounted: '401',
169
+ unmounted: 'method_not_found',
170
+ observe: async (fixture, t, absent) => {
171
+ const method = absent ? to_absent_method(declared_method) : declared_method;
172
+ const res = await rpc_call({ app: fixture.fresh_transport(), path: t.rpc_path, method });
173
+ const answer = res.ok
174
+ ? `${res.status} result`
175
+ : `${res.status} error ${res.error.code} ${res.error.message}`;
176
+ if (!res.ok && res.status === 401 && res.error.code === JSONRPC_ERROR_CODES.unauthenticated) {
177
+ return { mounted: true, answer };
178
+ }
179
+ if (!res.ok && res.status === 404 && res.error.code === JSONRPC_ERROR_CODES.method_not_found) {
180
+ return { mounted: false, answer };
181
+ }
182
+ assert.fail(`${method}: expected 401 (mounted) or method_not_found (unmounted), got ${answer}`);
183
+ }
184
+ });
185
+ /**
186
+ * An anonymous `GET`: the route's own refusal mounted, an unmatched `404`
187
+ * unmounted.
188
+ */
189
+ const route_probe = (path_of, mounted) => {
190
+ const mounted_label = `${mounted.status}${mounted.error ? ` ${mounted.error}` : ''}`;
191
+ return {
192
+ request: (t, absent) => `anonymous GET ${locate(path_of, t, absent)}`,
193
+ mounted: mounted_label,
194
+ unmounted: UNMATCHED_404,
195
+ observe: async (fixture, t, absent) => {
196
+ const path = locate(path_of, t, absent);
197
+ const res = await fixture.fresh_transport()(path, { method: 'GET' });
198
+ const text = await res.text();
199
+ const answer = describe_answer(res.status, text);
200
+ if (res.status === mounted.status &&
201
+ (mounted.error === undefined || error_of(parse_json(text)) === mounted.error)) {
202
+ return { mounted: true, answer };
203
+ }
204
+ if (is_unmatched_404(res.status, text))
205
+ return { mounted: false, answer };
206
+ assert.fail(`GET ${path}: expected ${mounted_label} (mounted) or ${UNMATCHED_404} (unmounted), got ${answer}`);
207
+ }
208
+ };
209
+ };
210
+ /** An anonymous upgrade: refused `401` mounted, `404` unmounted. */
211
+ const upgrade_probe = (path_of) => ({
212
+ request: (t, absent) => `anonymous upgrade on ${locate(path_of, t, absent)}`,
213
+ mounted: '401',
214
+ unmounted: UNMATCHED_UPGRADE_404,
215
+ observe: async (_fixture, t, absent) => {
216
+ const ws_path = locate(path_of, t, absent);
217
+ let refusal;
218
+ try {
219
+ const client = await create_ws_transport({
220
+ base_url: t.base_url,
221
+ ws_path,
222
+ cookies: [],
223
+ origin: t.base_url
224
+ });
225
+ await client.close();
226
+ assert.fail(`upgrade on ${ws_path}: an anonymous socket opened`);
227
+ }
228
+ catch (error) {
229
+ if (!(error instanceof WsUpgradeRefusedError))
230
+ throw error;
231
+ refusal = error;
232
+ }
233
+ const answer = describe_answer(refusal.status, refusal.body);
234
+ if (refusal.status === 401)
235
+ return { mounted: true, answer };
236
+ if (is_unmatched_upgrade_404(refusal.status, refusal.body))
237
+ return { mounted: false, answer };
238
+ assert.fail(`upgrade on ${ws_path}: expected a 401 (mounted) or 404 (unmounted) refusal, got ${answer}`);
239
+ }
240
+ });
241
+ /**
242
+ * `GET` of a readiness route outside `/api`: `200 {ready: true}`, or `503`
243
+ * with a drift code, mounted; a `404` (any body — the fallback's plain text
244
+ * included) or a `200` that isn't JSON (a static page) unmounted.
245
+ */
246
+ const ready_probe = (path_of) => ({
247
+ request: (t, absent) => `GET ${locate(path_of, t, absent)}`,
248
+ mounted: `200 {ready: true} (or 503 ${ERROR_SCHEMA_DRIFT} / ${ERROR_DB_UNREACHABLE})`,
249
+ unmounted: '404, or a 200 that is not JSON',
250
+ observe: async (fixture, t, absent) => {
251
+ const path = locate(path_of, t, absent);
252
+ const res = await fixture.fresh_transport({ origin: null })(path, { method: 'GET' });
253
+ const text = await res.text();
254
+ const json = parse_json(text);
255
+ const answer = describe_answer(res.status, text);
256
+ const ready = json !== null && typeof json === 'object' && 'ready' in json && json.ready;
257
+ const error = error_of(json);
258
+ if ((res.status === 200 && ready === true) ||
259
+ (res.status === 503 && (error === ERROR_SCHEMA_DRIFT || error === ERROR_DB_UNREACHABLE))) {
260
+ return { mounted: true, answer };
261
+ }
262
+ if (res.status === 404 || (res.status === 200 && json === undefined)) {
263
+ return { mounted: false, answer };
264
+ }
265
+ assert.fail(`GET ${path}: expected 200 {ready: true} or a drift 503 (mounted), or a 404 or a ` +
266
+ `non-JSON 200 (unmounted), got ${answer}`);
267
+ }
268
+ });
269
+ /** A method sent on the keeper's session socket: any answer mounted, `method_not_found` unmounted. */
270
+ const socket_method_probe = (declared_method) => ({
271
+ request: (t, absent) => `\`${absent ? to_absent_method(declared_method) : declared_method}\` on the keeper's session socket on ${t.ws_path}`,
272
+ mounted: 'an answer',
273
+ unmounted: 'method_not_found',
274
+ observe: async (fixture, t, absent) => {
275
+ const method = absent ? to_absent_method(declared_method) : declared_method;
276
+ const client = await open_session_ws({ base_url: t.base_url, ws_path: t.ws_path }, fixture, {
277
+ admitted: true
278
+ });
279
+ try {
280
+ const id = `capability_mounts_${method}`;
281
+ await client.send({ jsonrpc: '2.0', id, method });
282
+ const frame = await client.wait_for(is_response_for(id));
283
+ const answer = JSON.stringify(frame).slice(0, 200);
284
+ return { mounted: frame.error?.code !== JSONRPC_ERROR_CODES.method_not_found, answer };
285
+ }
286
+ finally {
287
+ await client.close();
288
+ }
289
+ }
290
+ });
291
+ const PROBES = {
292
+ ws: upgrade_probe((t) => t.ws_path),
293
+ sse: route_probe((t) => t.sse_path, { status: 401 }),
294
+ cell_crud: rpc_probe('cell_create'),
295
+ cell_relations: rpc_probe('cell_grant_create'),
296
+ fact_serving: route_probe(() => `/api/cells/${PROBE_CELL_ID}/facts/${PROBE_MALFORMED_FACT_HASH}`, { status: 400, error: ERROR_INVALID_ROUTE_PARAMS }),
297
+ fact_serving_admin_hash: route_probe(() => `/api/facts/${PROBE_MALFORMED_FACT_HASH}`, {
298
+ status: 400,
299
+ error: ERROR_INVALID_ROUTE_PARAMS
300
+ }),
301
+ ready: ready_probe((t) => t.ready_path),
302
+ account_status: route_probe(() => SPINE_ACCOUNT_STATUS_PATH, { status: 401 }),
303
+ ws_account_actions: socket_method_probe('account_verify'),
304
+ ws_role_gated: upgrade_probe((t) => t.gated_ws_path)
305
+ };
306
+ /** Every probed capability, in the order the suite runs them. */
307
+ export const PROBED_CAPABILITIES = Object.freeze(Object.keys(PROBES));
308
+ /**
309
+ * Plan the suite's tests from a backend's capabilities and paths — what
310
+ * `describe_capability_mounts_cross_tests` registers, as data, so the
311
+ * classification is checkable without a backend.
312
+ *
313
+ * @param capabilities - the backend's declarations
314
+ * @param target - where the probes send
315
+ * @param path_notes - a note per flag added to its probe's failure
316
+ * @returns every row, in registration order
317
+ * @internal Used by the suite's own tests — not stable API.
318
+ */
319
+ export const plan_capability_mount_rows = (capabilities, target, path_notes = {}) => {
320
+ const rows = [];
321
+ const noop = () => Promise.resolve();
322
+ for (const flag of PROBED_CAPABILITIES) {
323
+ const probe = PROBES[flag];
324
+ const declared = capabilities[flag];
325
+ const name = `${flag} declared ${declared}: ${probe.request(target, false)} → ` +
326
+ (declared ? probe.mounted : probe.unmounted);
327
+ // the account-actions probe needs a socket; with no WS endpoint
328
+ // declared, a `false` has nothing to probe, and a `true` is wrong
329
+ if (flag === 'ws_account_actions' && !capabilities.ws) {
330
+ rows.push(declared
331
+ ? {
332
+ group: 'capability mounts',
333
+ name,
334
+ mode: 'fail',
335
+ body: () => Promise.reject(new Error('capabilities.ws_account_actions is true, but capabilities.ws is false — ' +
336
+ 'the account actions need a WebSocket endpoint to be mounted on'))
337
+ }
338
+ : {
339
+ group: 'capability mounts',
340
+ name: `${flag}: no WebSocket endpoint to probe (capabilities.ws is false)`,
341
+ mode: 'gated_skip',
342
+ body: noop
343
+ });
344
+ continue;
345
+ }
346
+ rows.push({
347
+ group: 'capability mounts',
348
+ name,
349
+ mode: 'run',
350
+ body: async (setup_test) => {
351
+ const observed = await probe.observe(await setup_test(), target, false);
352
+ const mismatch = declared
353
+ ? `capabilities.${flag} is true, but the backend doesn't mount it — ` +
354
+ `${probe.request(target, false)} answered ${observed.answer}`
355
+ : `capabilities.${flag} is false, but the backend mounts it — ` +
356
+ `${probe.request(target, false)} answered ${observed.answer}; declare it true`;
357
+ const note = path_notes[flag];
358
+ assert.strictEqual(observed.mounted, declared, note === undefined ? mismatch : `${mismatch} (${note})`);
359
+ }
360
+ });
361
+ }
362
+ for (const flag of PROBED_CAPABILITIES) {
363
+ const probe = PROBES[flag];
364
+ const name = `${flag} control: ${probe.request(target, true)} → ${probe.unmounted}`;
365
+ // the account-actions control sends on the keeper's socket too
366
+ if (flag === 'ws_account_actions' && !capabilities.ws) {
367
+ rows.push({
368
+ group: 'capability mount controls',
369
+ name: `${name}: no WebSocket endpoint (capabilities.ws is false)`,
370
+ mode: 'gated_skip',
371
+ body: noop
372
+ });
373
+ continue;
374
+ }
375
+ rows.push({
376
+ group: 'capability mount controls',
377
+ name,
378
+ mode: 'run',
379
+ body: async (setup_test) => {
380
+ const observed = await probe.observe(await setup_test(), target, true);
381
+ assert.strictEqual(observed.mounted, false, `${probe.request(target, true)} reads as mounted (answered ${observed.answer}) — ` +
382
+ `the ${flag} probe's classifier is broken, or the backend answers a surface it doesn't mount`);
383
+ }
384
+ });
385
+ }
386
+ for (const [flag, reason] of Object.entries(UNPROBED_CAPABILITIES)) {
387
+ rows.push({
388
+ group: 'capability mounts not probed',
389
+ name: `${flag}: ${reason}`,
390
+ mode: 'skip',
391
+ body: noop
392
+ });
393
+ }
394
+ return rows;
395
+ };
396
+ /**
397
+ * Register the capability mount suite: one probe per `ProbedCapability`, each
398
+ * asserting the backend's answer matches its declaration, the same probe again
399
+ * as an unmounted control, and one skipped test per `UNPROBED_CAPABILITIES`
400
+ * entry naming why.
401
+ *
402
+ * @param options - the fixture, the backend's capabilities, and its paths
403
+ */
404
+ export const describe_capability_mounts_cross_tests = (options) => {
405
+ const { setup_test, capabilities } = options;
406
+ const rows = plan_capability_mount_rows(capabilities, resolve_capability_mounts_target(options), options.path_notes);
407
+ for (const group of [
408
+ 'capability mounts',
409
+ 'capability mount controls',
410
+ 'capability mounts not probed'
411
+ ]) {
412
+ describe(group, () => {
413
+ for (const row of rows) {
414
+ if (row.group !== group)
415
+ continue;
416
+ if (row.mode === 'skip') {
417
+ test.skip(row.name, () => { });
418
+ }
419
+ else if (row.mode === 'gated_skip') {
420
+ test_skip_gated(row.name, () => { });
421
+ }
422
+ else {
423
+ test(row.name, () => row.body(setup_test));
424
+ }
425
+ }
426
+ });
427
+ }
428
+ };
@@ -380,8 +380,8 @@ export const describe_cell_moderate_cross_tests = (options) => {
380
380
  const react = expect_output(await cross_rpc_call(fixture.transport, rpc_path, 'cell_create', { kind: 'react', data: {}, parent_id: space.cell.id, visibility: 'public' }, author_h), CellCreateOutput);
381
381
  await set_visibility(fixture, author_h, post.cell.id, 'public');
382
382
  const collection = expect_output(await cross_rpc_call(fixture.transport, rpc_path, 'cell_create', { kind: 'collection', data: {}, visibility: 'public' }, author_h), CellCreateOutput);
383
- const pos_a = fractional_index_between(null, null);
384
- const pos_b = fractional_index_between(pos_a, null);
383
+ const pos_a = fractional_index_between(null, null, { jitter: false });
384
+ const pos_b = fractional_index_between(pos_a, null, { jitter: false });
385
385
  for (const [child_id, position] of [
386
386
  [post.cell.id, pos_a],
387
387
  [react.cell.id, pos_b]
@@ -1 +1 @@
1
- {"version":3,"file":"cell_relations.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/cell_relations.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AA+G9B,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,YAAY,CAAC;AAuE1E,eAAO,MAAM,mCAAmC,GAC/C,SAAS,uCAAuC,KAC9C,IAwtCF,CAAC"}
1
+ {"version":3,"file":"cell_relations.d.ts","sourceRoot":"","sources":["../../../src/lib/testing/cross_backend/cell_relations.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAgH9B,OAAO,KAAK,EAAE,uCAAuC,EAAE,MAAM,YAAY,CAAC;AAuE1E,eAAO,MAAM,mCAAmC,GAC/C,SAAS,uCAAuC,KAC9C,IAwtCF,CAAC"}