@fuzdev/fuz_app 0.162.0 → 0.164.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 (280) hide show
  1. package/README.md +2 -1
  2. package/dist/actions/action_event_data.d.ts +1 -1
  3. package/dist/actions/action_rpc.d.ts.map +1 -1
  4. package/dist/actions/action_rpc.js +4 -0
  5. package/dist/actions/action_spec.d.ts +3 -3
  6. package/dist/actions/action_spec.d.ts.map +1 -1
  7. package/dist/auth/CLAUDE.md +39 -36
  8. package/dist/auth/account_action_specs.d.ts +441 -115
  9. package/dist/auth/account_action_specs.d.ts.map +1 -1
  10. package/dist/auth/account_action_specs.js +47 -46
  11. package/dist/auth/account_route_schema.d.ts +98 -62
  12. package/dist/auth/account_route_schema.d.ts.map +1 -1
  13. package/dist/auth/account_route_schema.js +45 -45
  14. package/dist/auth/account_routes.js +1 -1
  15. package/dist/auth/account_schema.d.ts +54 -27
  16. package/dist/auth/account_schema.d.ts.map +1 -1
  17. package/dist/auth/account_schema.js +16 -18
  18. package/dist/auth/admin_action_specs.d.ts +76 -76
  19. package/dist/auth/admin_action_specs.js +2 -4
  20. package/dist/auth/admin_actions.d.ts +4 -4
  21. package/dist/auth/admin_actions.d.ts.map +1 -1
  22. package/dist/auth/admin_actions.js +3 -3
  23. package/dist/auth/all_cell_actions.d.ts +3 -3
  24. package/dist/auth/all_cell_actions.d.ts.map +1 -1
  25. package/dist/auth/all_cell_actions.js +1 -1
  26. package/dist/auth/api_token.d.ts +4 -4
  27. package/dist/auth/api_token.d.ts.map +1 -1
  28. package/dist/auth/api_token.js +3 -3
  29. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  30. package/dist/auth/audit_log_route_schema.d.ts.map +1 -1
  31. package/dist/auth/audit_log_route_schema.js +4 -5
  32. package/dist/auth/audit_log_schema.d.ts +46 -66
  33. package/dist/auth/audit_log_schema.d.ts.map +1 -1
  34. package/dist/auth/audit_log_schema.js +34 -30
  35. package/dist/auth/bootstrap_route_schema.d.ts +146 -52
  36. package/dist/auth/bootstrap_route_schema.d.ts.map +1 -1
  37. package/dist/auth/bootstrap_route_schema.js +33 -19
  38. package/dist/auth/cell_grant_action_specs.d.ts +1 -1
  39. package/dist/auth/cell_grant_action_specs.js +1 -1
  40. package/dist/auth/cell_grant_actions.d.ts +4 -4
  41. package/dist/auth/cell_grant_actions.d.ts.map +1 -1
  42. package/dist/auth/cell_grant_actions.js +1 -1
  43. package/dist/auth/credential_type_schema.d.ts +16 -29
  44. package/dist/auth/credential_type_schema.d.ts.map +1 -1
  45. package/dist/auth/credential_type_schema.js +14 -18
  46. package/dist/auth/daemon_token.d.ts +4 -4
  47. package/dist/auth/daemon_token.d.ts.map +1 -1
  48. package/dist/auth/daemon_token.js +3 -3
  49. package/dist/auth/daemon_token_middleware.d.ts +1 -1
  50. package/dist/auth/daemon_token_middleware.d.ts.map +1 -1
  51. package/dist/auth/daemon_token_middleware.js +5 -5
  52. package/dist/auth/grant_path_schema.d.ts +15 -29
  53. package/dist/auth/grant_path_schema.d.ts.map +1 -1
  54. package/dist/auth/grant_path_schema.js +13 -17
  55. package/dist/auth/middleware.js +4 -4
  56. package/dist/auth/migrations.js +1 -1
  57. package/dist/auth/name_schema.d.ts +7 -6
  58. package/dist/auth/name_schema.d.ts.map +1 -1
  59. package/dist/auth/name_schema.js +8 -9
  60. package/dist/auth/password.d.ts +15 -7
  61. package/dist/auth/password.d.ts.map +1 -1
  62. package/dist/auth/password.js +16 -9
  63. package/dist/auth/role_grant_offer_action_specs.d.ts +2 -2
  64. package/dist/auth/role_grant_offer_action_specs.js +2 -2
  65. package/dist/auth/role_grant_offer_actions.d.ts +4 -4
  66. package/dist/auth/role_grant_offer_actions.d.ts.map +1 -1
  67. package/dist/auth/role_grant_offer_actions.js +3 -3
  68. package/dist/auth/role_grant_offer_notifications.js +2 -2
  69. package/dist/auth/role_grant_offer_schema.d.ts +2 -2
  70. package/dist/auth/role_grant_offer_schema.js +2 -2
  71. package/dist/auth/role_schema.d.ts +47 -55
  72. package/dist/auth/role_schema.d.ts.map +1 -1
  73. package/dist/auth/role_schema.js +29 -35
  74. package/dist/auth/scope_kind_schema.d.ts +22 -26
  75. package/dist/auth/scope_kind_schema.d.ts.map +1 -1
  76. package/dist/auth/scope_kind_schema.js +19 -19
  77. package/dist/auth/self_service_role_action_specs.js +1 -1
  78. package/dist/auth/self_service_role_actions.d.ts +6 -6
  79. package/dist/auth/self_service_role_actions.d.ts.map +1 -1
  80. package/dist/auth/self_service_role_actions.js +7 -6
  81. package/dist/auth/signup_route_schema.d.ts +71 -21
  82. package/dist/auth/signup_route_schema.d.ts.map +1 -1
  83. package/dist/auth/signup_route_schema.js +17 -19
  84. package/dist/auth/standard_rpc_actions.d.ts +1 -1
  85. package/dist/auth/standard_rpc_actions.js +1 -1
  86. package/dist/auth/token_lifetime.d.ts +33 -9
  87. package/dist/auth/token_lifetime.d.ts.map +1 -1
  88. package/dist/auth/token_lifetime.js +8 -7
  89. package/dist/auth/token_scope.d.ts +99 -25
  90. package/dist/auth/token_scope.d.ts.map +1 -1
  91. package/dist/auth/token_scope.js +57 -35
  92. package/dist/db/CLAUDE.md +2 -1
  93. package/dist/db/file_fact_url.d.ts +11 -6
  94. package/dist/db/file_fact_url.d.ts.map +1 -1
  95. package/dist/db/file_fact_url.js +5 -5
  96. package/dist/db/schema_ready.d.ts +0 -5
  97. package/dist/db/schema_ready.d.ts.map +1 -1
  98. package/dist/db/schema_ready.js +0 -5
  99. package/dist/http/CLAUDE.md +104 -71
  100. package/dist/http/auth_shape.d.ts +48 -29
  101. package/dist/http/auth_shape.d.ts.map +1 -1
  102. package/dist/http/auth_shape.js +12 -85
  103. package/dist/http/body_limit.d.ts +12 -0
  104. package/dist/http/body_limit.d.ts.map +1 -1
  105. package/dist/http/body_limit.js +15 -0
  106. package/dist/http/body_limit_schema.d.ts +20 -0
  107. package/dist/http/body_limit_schema.d.ts.map +1 -0
  108. package/dist/http/body_limit_schema.js +20 -0
  109. package/dist/http/common_routes.d.ts +1 -1
  110. package/dist/http/common_routes.d.ts.map +1 -1
  111. package/dist/http/common_routes.js +11 -14
  112. package/dist/http/db_routes.d.ts.map +1 -1
  113. package/dist/http/db_routes.js +59 -69
  114. package/dist/http/dev_route_error_check.d.ts +70 -0
  115. package/dist/http/dev_route_error_check.d.ts.map +1 -0
  116. package/dist/http/dev_route_error_check.js +119 -0
  117. package/dist/http/error_schemas.d.ts +365 -189
  118. package/dist/http/error_schemas.d.ts.map +1 -1
  119. package/dist/http/error_schemas.js +256 -149
  120. package/dist/http/health_schema.d.ts +10 -6
  121. package/dist/http/health_schema.d.ts.map +1 -1
  122. package/dist/http/health_schema.js +3 -3
  123. package/dist/http/middleware_spec.d.ts +8 -3
  124. package/dist/http/middleware_spec.d.ts.map +1 -1
  125. package/dist/http/origin.d.ts +12 -43
  126. package/dist/http/origin.d.ts.map +1 -1
  127. package/dist/http/origin.js +10 -6
  128. package/dist/http/route_error_check.d.ts +158 -0
  129. package/dist/http/route_error_check.d.ts.map +1 -0
  130. package/dist/http/route_error_check.js +247 -0
  131. package/dist/http/route_errors.d.ts +80 -0
  132. package/dist/http/route_errors.d.ts.map +1 -0
  133. package/dist/http/route_errors.js +83 -0
  134. package/dist/http/route_spec.d.ts +33 -17
  135. package/dist/http/route_spec.d.ts.map +1 -1
  136. package/dist/http/route_spec.js +48 -62
  137. package/dist/http/schema_helpers.d.ts +0 -33
  138. package/dist/http/schema_helpers.d.ts.map +1 -1
  139. package/dist/http/schema_helpers.js +0 -45
  140. package/dist/http/surface.d.ts +19 -12
  141. package/dist/http/surface.d.ts.map +1 -1
  142. package/dist/http/surface.js +25 -38
  143. package/dist/http/surface_query.d.ts +11 -2
  144. package/dist/http/surface_query.d.ts.map +1 -1
  145. package/dist/http/surface_query.js +7 -1
  146. package/dist/primitive_schemas.d.ts +2 -19
  147. package/dist/primitive_schemas.d.ts.map +1 -1
  148. package/dist/primitive_schemas.js +2 -20
  149. package/dist/primitive_schemas_fuz.d.ts +39 -5
  150. package/dist/primitive_schemas_fuz.d.ts.map +1 -1
  151. package/dist/primitive_schemas_fuz.js +36 -7
  152. package/dist/rate_limiter.d.ts +13 -0
  153. package/dist/rate_limiter.d.ts.map +1 -1
  154. package/dist/rate_limiter.js +20 -2
  155. package/dist/schema_issues.d.ts +29 -11
  156. package/dist/schema_issues.d.ts.map +1 -1
  157. package/dist/schema_issues.js +11 -10
  158. package/dist/schema_meta.d.ts +8 -1
  159. package/dist/schema_meta.d.ts.map +1 -1
  160. package/dist/schema_meta.js +2 -1
  161. package/dist/server/app_server.d.ts +3 -1
  162. package/dist/server/app_server.d.ts.map +1 -1
  163. package/dist/server/app_server.js +24 -10
  164. package/dist/server/serve_fact_route.d.ts.map +1 -1
  165. package/dist/server/serve_fact_route.js +8 -31
  166. package/dist/server/surface_route.d.ts.map +1 -1
  167. package/dist/server/surface_route.js +5 -6
  168. package/dist/server/x_accel.d.ts +12 -7
  169. package/dist/server/x_accel.d.ts.map +1 -1
  170. package/dist/server/x_accel.js +7 -9
  171. package/dist/testing/CLAUDE.md +55 -44
  172. package/dist/testing/admin_integration.d.ts +3 -3
  173. package/dist/testing/admin_integration.d.ts.map +1 -1
  174. package/dist/testing/admin_integration.js +2 -2
  175. package/dist/testing/adversarial_404.d.ts +4 -18
  176. package/dist/testing/adversarial_404.d.ts.map +1 -1
  177. package/dist/testing/adversarial_404.js +19 -51
  178. package/dist/testing/adversarial_headers.d.ts +3 -4
  179. package/dist/testing/adversarial_headers.d.ts.map +1 -1
  180. package/dist/testing/adversarial_headers.js +8 -6
  181. package/dist/testing/adversarial_input.d.ts.map +1 -1
  182. package/dist/testing/adversarial_input.js +18 -17
  183. package/dist/testing/assertions.d.ts +33 -11
  184. package/dist/testing/assertions.d.ts.map +1 -1
  185. package/dist/testing/assertions.js +52 -12
  186. package/dist/testing/attack_surface.d.ts +5 -35
  187. package/dist/testing/attack_surface.d.ts.map +1 -1
  188. package/dist/testing/attack_surface.js +29 -91
  189. package/dist/testing/auth_apps.d.ts.map +1 -1
  190. package/dist/testing/auth_apps.js +2 -1
  191. package/dist/testing/cross_backend/action_manifest.d.ts +126 -56
  192. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  193. package/dist/testing/cross_backend/action_manifest.js +11 -11
  194. package/dist/testing/cross_backend/action_manifest_parity.d.ts +1 -1
  195. package/dist/testing/cross_backend/action_manifest_parity.d.ts.map +1 -1
  196. package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
  197. package/dist/testing/cross_backend/cell_crud.js +2 -1
  198. package/dist/testing/cross_backend/conformance_table.js +1 -1
  199. package/dist/testing/cross_backend/default_spine_surface.d.ts +2 -2
  200. package/dist/testing/cross_backend/default_spine_surface.d.ts.map +1 -1
  201. package/dist/testing/cross_backend/default_spine_surface.js +2 -2
  202. package/dist/testing/cross_backend/fact_serving.js +3 -3
  203. package/dist/testing/cross_backend/identity_parity.d.ts.map +1 -1
  204. package/dist/testing/cross_backend/identity_parity.js +39 -6
  205. package/dist/testing/cross_backend/origin_conformance.d.ts +278 -102
  206. package/dist/testing/cross_backend/origin_conformance.d.ts.map +1 -1
  207. package/dist/testing/cross_backend/origin_conformance.js +21 -21
  208. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts +3 -3
  209. package/dist/testing/cross_backend/rust_spine_consumer_surface.d.ts.map +1 -1
  210. package/dist/testing/cross_backend/rust_spine_consumer_surface.js +7 -1
  211. package/dist/testing/cross_backend/setup.d.ts +14 -1
  212. package/dist/testing/cross_backend/setup.d.ts.map +1 -1
  213. package/dist/testing/cross_backend/setup.js +68 -48
  214. package/dist/testing/cross_backend/spine_suites.d.ts +3 -3
  215. package/dist/testing/cross_backend/spine_suites.d.ts.map +1 -1
  216. package/dist/testing/cross_backend/standard.d.ts +4 -4
  217. package/dist/testing/cross_backend/standard.d.ts.map +1 -1
  218. package/dist/testing/cross_backend/testing_origin_check.d.ts +147 -71
  219. package/dist/testing/cross_backend/testing_origin_check.d.ts.map +1 -1
  220. package/dist/testing/cross_backend/testing_origin_check.js +16 -13
  221. package/dist/testing/cross_backend/testing_reset_actions.d.ts +70 -27
  222. package/dist/testing/cross_backend/testing_reset_actions.d.ts.map +1 -1
  223. package/dist/testing/cross_backend/token_lifetime.d.ts.map +1 -1
  224. package/dist/testing/cross_backend/token_lifetime.js +34 -1
  225. package/dist/testing/data_exposure.d.ts.map +1 -1
  226. package/dist/testing/data_exposure.js +5 -4
  227. package/dist/testing/error_coverage.d.ts +24 -34
  228. package/dist/testing/error_coverage.d.ts.map +1 -1
  229. package/dist/testing/error_coverage.js +46 -89
  230. package/dist/testing/integration.d.ts.map +1 -1
  231. package/dist/testing/integration.js +6 -14
  232. package/dist/testing/integration_helpers.d.ts +37 -9
  233. package/dist/testing/integration_helpers.d.ts.map +1 -1
  234. package/dist/testing/integration_helpers.js +86 -40
  235. package/dist/testing/middleware.d.ts +3 -5
  236. package/dist/testing/middleware.d.ts.map +1 -1
  237. package/dist/testing/middleware.js +5 -4
  238. package/dist/testing/rate_limiting.d.ts +1 -1
  239. package/dist/testing/rate_limiting.d.ts.map +1 -1
  240. package/dist/testing/rate_limiting.js +5 -4
  241. package/dist/testing/round_trip.d.ts.map +1 -1
  242. package/dist/testing/round_trip.js +5 -3
  243. package/dist/testing/schema_generators.d.ts +10 -3
  244. package/dist/testing/schema_generators.d.ts.map +1 -1
  245. package/dist/testing/schema_generators.js +23 -11
  246. package/dist/testing/stubs.d.ts +10 -1
  247. package/dist/testing/stubs.d.ts.map +1 -1
  248. package/dist/testing/stubs.js +15 -5
  249. package/dist/testing/surface_invariants.d.ts +36 -115
  250. package/dist/testing/surface_invariants.d.ts.map +1 -1
  251. package/dist/testing/surface_invariants.js +106 -269
  252. package/dist/testing/token_scope_fixtures.d.ts +24 -0
  253. package/dist/testing/token_scope_fixtures.d.ts.map +1 -0
  254. package/dist/testing/token_scope_fixtures.js +49 -0
  255. package/dist/testing/transports/bootstrap.d.ts +1 -1
  256. package/dist/testing/transports/bootstrap.d.ts.map +1 -1
  257. package/dist/testing/transports/bootstrap.js +13 -12
  258. package/dist/ui/BootstrapForm.svelte +4 -2
  259. package/dist/ui/BootstrapForm.svelte.d.ts.map +1 -1
  260. package/dist/ui/CLAUDE.md +4 -2
  261. package/dist/ui/SignupForm.svelte +4 -2
  262. package/dist/ui/SignupForm.svelte.d.ts.map +1 -1
  263. package/dist/ui/auth_state.svelte.d.ts.map +1 -1
  264. package/dist/ui/auth_state.svelte.js +2 -8
  265. package/dist/ui/backend_probe.svelte.js +3 -3
  266. package/dist/ui/table_state.svelte.d.ts.map +1 -1
  267. package/dist/ui/table_state.svelte.js +1 -8
  268. package/dist/ui/ui_fetch.d.ts +12 -2
  269. package/dist/ui/ui_fetch.d.ts.map +1 -1
  270. package/dist/ui/ui_fetch.js +22 -4
  271. package/package.json +1 -1
  272. package/dist/auth/audit_log_schema_fuz.d.ts +0 -53
  273. package/dist/auth/audit_log_schema_fuz.d.ts.map +0 -1
  274. package/dist/auth/audit_log_schema_fuz.js +0 -50
  275. package/dist/auth/role_schema_fuz.d.ts +0 -30
  276. package/dist/auth/role_schema_fuz.d.ts.map +0 -1
  277. package/dist/auth/role_schema_fuz.js +0 -30
  278. package/dist/auth/scope_kind_schema_fuz.d.ts +0 -31
  279. package/dist/auth/scope_kind_schema_fuz.d.ts.map +0 -1
  280. package/dist/auth/scope_kind_schema_fuz.js +0 -31
@@ -1,29 +1,13 @@
1
1
  import './assert_dev_env.js';
2
2
  import type { RouteSpec } from '../http/route_spec.js';
3
- import type { ValidationSchema } from '../schema_issues.js';
4
- /**
5
- * Extract declared error code values from an error response schema.
6
- *
7
- * Recognizes schemas shaped like `z.object({error: z.literal(...)})` or
8
- * `z.object({error: z.enum([...])})` (incl. `looseObject`/`strictObject`),
9
- * and the `@fuzdev/fuz_schema` forms `object({error: literal(...)})` or
10
- * `object({error: one_of([...])})` (any object kind, under any wrappers —
11
- * `get_schema_entries`; the `error` entry itself read as given, as the Zod
12
- * field is). Returns the set of declared code values, or `null` if the schema
13
- * doesn't expose a literal/enum `error` field (e.g., bare `ApiError` with
14
- * `z.string()`).
15
- *
16
- * Used by coverage reporting to split a single declared status into per-code
17
- * rows when the route's error schema names specific codes.
18
- */
19
- export declare const extract_declared_error_codes: (schema: ValidationSchema) => Array<string> | null;
20
- /** Uncovered entry — either a status-level row (no `code`) or a specific-code row. */
3
+ import { type RouteErrorMap } from '../http/route_errors.js';
4
+ /** Uncovered entry — a declared code at a status of a route, never observed. */
21
5
  export interface UncoveredEntry {
22
6
  method: string;
23
7
  path: string;
24
8
  status: number;
25
- /** Declared code value missing, when the status's error schema names specific codes. */
26
- code?: string;
9
+ /** The declared code missing. */
10
+ code: string;
27
11
  }
28
12
  /** Options controlling which routes/statuses are considered for coverage. */
29
13
  export interface CoverageFilterOptions {
@@ -46,9 +30,19 @@ export interface CoverageFilterOptions {
46
30
  * requirements for the same status — i.e., if a caller records just the status,
47
31
  * all declared codes for that status are considered covered. Per-code tracking
48
32
  * is additive: callers who know the body's `error` value should pass it to get
49
- * precise per-code gap reporting on routes with literal/enum error schemas.
33
+ * precise per-code gap reporting.
50
34
  */
51
35
  export declare class ErrorCoverageCollector {
36
+ /**
37
+ * Each route's error map, keyed `METHOD path` (`AppSurfaceSpec.route_error_maps`),
38
+ * which the declared paths and the response checks read; without one, a
39
+ * route's own map without middleware.
40
+ */
41
+ readonly route_error_maps: ReadonlyMap<string, RouteErrorMap> | null;
42
+ /**
43
+ * @param route_error_maps - each route's error map, keyed `METHOD path` (`AppSurfaceSpec.route_error_maps`)
44
+ */
45
+ constructor(route_error_maps?: ReadonlyMap<string, RouteErrorMap> | null);
52
46
  /**
53
47
  * Observed keys: `"METHOD /spec-path:STATUS"` or `"METHOD /spec-path:STATUS:CODE"`.
54
48
  *
@@ -64,8 +58,7 @@ export declare class ErrorCoverageCollector {
64
58
  * it is stored alongside the status for per-code coverage tracking.
65
59
  *
66
60
  * @param path - request path (may be concrete)
67
- * @param code - observed body `error` code (pass when the route's error
68
- * schema declares specific codes via `z.literal` or `z.enum`)
61
+ * @param code - observed body `error` code, for per-code coverage
69
62
  * @mutates `this.observed` - adds the resolved `"METHOD /spec-path:STATUS"`
70
63
  * key (and the `:CODE` variant when `code` is provided).
71
64
  */
@@ -91,11 +84,10 @@ export declare class ErrorCoverageCollector {
91
84
  /**
92
85
  * Find declared error paths that were never observed.
93
86
  *
94
- * Computes the declared set from `merge_error_schemas` for each route spec.
95
- * For statuses whose error schema names specific codes (via `z.literal` or
96
- * `z.enum`), reports per-code rows; otherwise reports one row per status.
97
- * A status-only observation (no code) satisfies all declared codes for that
98
- * status — the "any-code" rule.
87
+ * Computes the declared set from each route's error map
88
+ * (`resolve_route_error_map`, `this.route_error_maps`): one row per declared code
89
+ * at each status. A status-only observation (no code) satisfies all
90
+ * declared codes for that status — the "any-code" rule.
99
91
  */
100
92
  uncovered(route_specs: Array<RouteSpec>, options?: CoverageFilterOptions): Array<UncoveredEntry>;
101
93
  }
@@ -113,12 +105,10 @@ export interface ErrorCoverageOptions extends CoverageFilterOptions {
113
105
  /**
114
106
  * Assert error coverage meets a minimum threshold.
115
107
  *
116
- * Computes the ratio of exercised error paths to total declared error paths.
117
- * For routes whose status error schema names specific codes (`z.literal` or
118
- * `z.enum`), each declared code counts as one coverage path; for schemas
119
- * without declared codes (`ApiError`/`z.string()`), the status counts as one
120
- * path. A status-only observation covers all declared codes for that status
121
- * (the "any-code" rule).
108
+ * Computes the ratio of exercised error paths to total declared error paths,
109
+ * each declared code at each status of a route's error map
110
+ * (`collector.route_error_maps`) one path. A status-only observation covers all
111
+ * declared codes for that status (the "any-code" rule).
122
112
  *
123
113
  * When `min_coverage` is 0 (default), logs coverage info without failing.
124
114
  * When > 0, fails if coverage is below the threshold.
@@ -1 +1 @@
1
- {"version":3,"file":"error_coverage.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/error_coverage.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAoB7B,OAAO,KAA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QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAa;IAE3C;;;;;;;;;;;OAWG;IACH,MAAM,CACL,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,EAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,IAAI,CAAC,EAAE,MAAM,GACX,IAAI;IAUP;;;;;;;;;;;;;;;;OAgBG;IACG,iBAAiB,CACtB,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,EAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,QAAQ,EAClB,IAAI,CAAC,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC;IAgBhB;;;;;;;OAOG;IACH,SAAS,CAAC,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,KAAK,CAAC,cAAc,CAAC;CAKhG;AAED;;;;GAIG;AACH,eAAO,MAAM,kCAAkC,MAAM,CAAC;AAEtD,2CAA2C;AAC3C,MAAM,WAAW,oBAAqB,SAAQ,qBAAqB;IAClE,sEAAsE;IACtE,YAAY,CAAC,EAAE,MAAM,CAAC;CACtB;AAYD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,qBAAqB,GACjC,WAAW,sBAAsB,EACjC,aAAa,KAAK,CAAC,SAAS,CAAC,EAC7B,UAAU,oBAAoB,KAC5B,IAsBF,CAAC"}
@@ -2,99 +2,48 @@ import './assert_dev_env.js';
2
2
  /**
3
3
  * Error reachability coverage tracking.
4
4
  *
5
- * Tracks which declared error statuses (and specific error codes) are
6
- * actually exercised in tests. `ErrorCoverageCollector` records status
7
- * codes (optionally with body `error` codes) observed during test runs,
8
- * then `assert_error_coverage` compares against declared error schemas
9
- * to find uncovered error paths — reporting per-code when the declared
10
- * schema is a literal or enum, per-status otherwise.
5
+ * Tracks which declared error codes are actually exercised in tests.
6
+ * `ErrorCoverageCollector` records status codes (optionally with body
7
+ * `error` codes) observed during test runs, then `assert_error_coverage`
8
+ * compares against each route's error map (`resolve_route_error_map`) to find
9
+ * uncovered error paths — one per declared code at each status, read from
10
+ * the map's definitions.
11
11
  *
12
12
  * @module
13
13
  */
14
- import { z } from 'zod';
15
14
  import { assert } from 'vitest';
16
- import { is_schema } from '@fuzdev/fuz_schema/schema.ts';
17
- import { get_schema_entries } from '@fuzdev/fuz_schema/introspect.ts';
18
- import { merge_error_schemas } from '../http/schema_helpers.js';
15
+ import { format_route_key } from '../http/surface_query.js';
16
+ import { get_route_error_map } from '../http/route_errors.js';
19
17
  import { find_route_spec, assert_response_matches_spec } from './integration_helpers.js';
20
- /**
21
- * Extract declared error code values from an error response schema.
22
- *
23
- * Recognizes schemas shaped like `z.object({error: z.literal(...)})` or
24
- * `z.object({error: z.enum([...])})` (incl. `looseObject`/`strictObject`),
25
- * and the `@fuzdev/fuz_schema` forms `object({error: literal(...)})` or
26
- * `object({error: one_of([...])})` (any object kind, under any wrappers —
27
- * `get_schema_entries`; the `error` entry itself read as given, as the Zod
28
- * field is). Returns the set of declared code values, or `null` if the schema
29
- * doesn't expose a literal/enum `error` field (e.g., bare `ApiError` with
30
- * `z.string()`).
31
- *
32
- * Used by coverage reporting to split a single declared status into per-code
33
- * rows when the route's error schema names specific codes.
34
- */
35
- export const extract_declared_error_codes = (schema) => {
36
- if (is_schema(schema)) {
37
- const error_field = get_schema_entries(schema)?.error;
38
- if (!error_field)
39
- return null;
40
- if (error_field.kind === 'literal')
41
- return [String(error_field.def)];
42
- if (error_field.kind === 'one_of') {
43
- return error_field.def.map(String);
44
- }
45
- return null;
46
- }
47
- if (!(schema instanceof z.ZodObject))
48
- return null;
49
- const error_field = schema.shape.error;
50
- if (!error_field)
51
- return null;
52
- if (error_field instanceof z.ZodLiteral) {
53
- return [...error_field.values].map(String);
54
- }
55
- if (error_field instanceof z.ZodEnum) {
56
- return error_field.options.map(String);
57
- }
58
- return null;
59
- };
60
18
  /**
61
19
  * Shared walk over declared error paths.
62
20
  *
63
21
  * Single source of truth for the route → status → code traversal used by
64
22
  * both `uncovered()` and `assert_error_coverage`. Yields one entry per
65
- * declared coverage path with a `covered` flag, applying the "any-code"
66
- * rule (status-only observation covers all declared codes).
23
+ * declared (status, code) of each route's error map, read from its
24
+ * definitions, with a `covered` flag, applying the "any-code" rule
25
+ * (status-only observation covers all declared codes).
67
26
  */
68
27
  const walk_coverage = (collector, route_specs, options) => {
69
28
  const ignore_routes = new Set(options?.ignore_routes);
70
29
  const ignore_statuses = new Set(options?.ignore_statuses);
71
30
  const entries = [];
72
31
  for (const spec of route_specs) {
73
- const route_key = `${spec.method} ${spec.path}`;
32
+ const route_key = format_route_key(spec);
74
33
  if (ignore_routes.has(route_key))
75
34
  continue;
76
- const merged = merge_error_schemas(spec);
77
- if (!merged)
78
- continue;
79
- for (const status_str of Object.keys(merged)) {
80
- const status = Number(status_str);
35
+ // a code with two shapes at one status is one path
36
+ const seen = new Set();
37
+ for (const { status, code } of get_route_error_map(collector.route_error_maps, spec).defs) {
81
38
  if (ignore_statuses.has(status))
82
39
  continue;
83
- const error_schema = merged[status];
84
- if (!error_schema)
85
- continue;
86
40
  const status_key = `${spec.method} ${spec.path}:${status}`;
87
- const status_observed = collector.observed.has(status_key);
88
- const codes = extract_declared_error_codes(error_schema);
89
- if (codes && codes.length > 0) {
90
- for (const code of codes) {
91
- const covered = status_observed || collector.observed.has(`${status_key}:${code}`);
92
- entries.push({ method: spec.method, path: spec.path, status, code, covered });
93
- }
94
- }
95
- else {
96
- entries.push({ method: spec.method, path: spec.path, status, covered: status_observed });
97
- }
41
+ const code_key = `${status_key}:${code}`;
42
+ if (seen.has(code_key))
43
+ continue;
44
+ seen.add(code_key);
45
+ const covered = collector.observed.has(status_key) || collector.observed.has(code_key);
46
+ entries.push({ method: spec.method, path: spec.path, status, code, covered });
98
47
  }
99
48
  }
100
49
  return entries;
@@ -113,9 +62,21 @@ const walk_coverage = (collector, route_specs, options) => {
113
62
  * requirements for the same status — i.e., if a caller records just the status,
114
63
  * all declared codes for that status are considered covered. Per-code tracking
115
64
  * is additive: callers who know the body's `error` value should pass it to get
116
- * precise per-code gap reporting on routes with literal/enum error schemas.
65
+ * precise per-code gap reporting.
117
66
  */
118
67
  export class ErrorCoverageCollector {
68
+ /**
69
+ * Each route's error map, keyed `METHOD path` (`AppSurfaceSpec.route_error_maps`),
70
+ * which the declared paths and the response checks read; without one, a
71
+ * route's own map without middleware.
72
+ */
73
+ route_error_maps;
74
+ /**
75
+ * @param route_error_maps - each route's error map, keyed `METHOD path` (`AppSurfaceSpec.route_error_maps`)
76
+ */
77
+ constructor(route_error_maps) {
78
+ this.route_error_maps = route_error_maps ?? null;
79
+ }
119
80
  /**
120
81
  * Observed keys: `"METHOD /spec-path:STATUS"` or `"METHOD /spec-path:STATUS:CODE"`.
121
82
  *
@@ -131,8 +92,7 @@ export class ErrorCoverageCollector {
131
92
  * it is stored alongside the status for per-code coverage tracking.
132
93
  *
133
94
  * @param path - request path (may be concrete)
134
- * @param code - observed body `error` code (pass when the route's error
135
- * schema declares specific codes via `z.literal` or `z.enum`)
95
+ * @param code - observed body `error` code, for per-code coverage
136
96
  * @mutates `this.observed` - adds the resolved `"METHOD /spec-path:STATUS"`
137
97
  * key (and the `:CODE` variant when `code` is provided).
138
98
  */
@@ -163,7 +123,7 @@ export class ErrorCoverageCollector {
163
123
  * schemas (propagated from `assert_response_matches_spec`).
164
124
  */
165
125
  async assert_and_record(route_specs, method, path, response, code) {
166
- await assert_response_matches_spec(route_specs, method, path, response);
126
+ await assert_response_matches_spec(route_specs, method, path, response, this.route_error_maps);
167
127
  let resolved_code = code;
168
128
  if (resolved_code === undefined && !response.ok && !response.bodyUsed) {
169
129
  try {
@@ -181,16 +141,15 @@ export class ErrorCoverageCollector {
181
141
  /**
182
142
  * Find declared error paths that were never observed.
183
143
  *
184
- * Computes the declared set from `merge_error_schemas` for each route spec.
185
- * For statuses whose error schema names specific codes (via `z.literal` or
186
- * `z.enum`), reports per-code rows; otherwise reports one row per status.
187
- * A status-only observation (no code) satisfies all declared codes for that
188
- * status — the "any-code" rule.
144
+ * Computes the declared set from each route's error map
145
+ * (`resolve_route_error_map`, `this.route_error_maps`): one row per declared code
146
+ * at each status. A status-only observation (no code) satisfies all
147
+ * declared codes for that status — the "any-code" rule.
189
148
  */
190
149
  uncovered(route_specs, options) {
191
150
  return walk_coverage(this, route_specs, options)
192
151
  .filter((entry) => !entry.covered)
193
- .map(({ method, path, status, code }) => ({ method, path, status, ...(code && { code }) }));
152
+ .map(({ method, path, status, code }) => ({ method, path, status, code }));
194
153
  }
195
154
  }
196
155
  /**
@@ -205,16 +164,14 @@ export const DEFAULT_INTEGRATION_ERROR_COVERAGE = 0.2;
205
164
  * Uses `status (code)` — spaces around the code make `:` unambiguous as
206
165
  * the route_key / status separator.
207
166
  */
208
- const format_uncovered = (entry) => `${entry.method} ${entry.path} → ${entry.status}${entry.code ? ` (${entry.code})` : ''}`;
167
+ const format_uncovered = (entry) => `${entry.method} ${entry.path} → ${entry.status} (${entry.code})`;
209
168
  /**
210
169
  * Assert error coverage meets a minimum threshold.
211
170
  *
212
- * Computes the ratio of exercised error paths to total declared error paths.
213
- * For routes whose status error schema names specific codes (`z.literal` or
214
- * `z.enum`), each declared code counts as one coverage path; for schemas
215
- * without declared codes (`ApiError`/`z.string()`), the status counts as one
216
- * path. A status-only observation covers all declared codes for that status
217
- * (the "any-code" rule).
171
+ * Computes the ratio of exercised error paths to total declared error paths,
172
+ * each declared code at each status of a route's error map
173
+ * (`collector.route_error_maps`) one path. A status-only observation covers all
174
+ * declared codes for that status (the "any-code" rule).
218
175
  *
219
176
  * When `min_coverage` is 0 (default), logs coverage info without failing.
220
177
  * When > 0, fails if coverage is below the threshold.
@@ -1 +1 @@
1
- {"version":3,"file":"integration.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;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C;;;;OAIG;IACH,UAAU,EAAE,SAAS,CAAC;IACtB;;;;;;;;;OASG;IACH,cAAc,EAAE,cAAc,CAAC;IAC/B,kEAAkE;IAClE,YAAY,EAAE,mBAAmB,CAAC;IAClC;;;;OAIG;IACH,eAAe,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC;IACxC;;;;;;;;;;;;OAYG;IACH,aAAa,EAAE,uBAAuB,CAAC;IACvC;;;;;;;OAOG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,mCAAmC,GAC/C,SAAS,8BAA8B,KACrC,IAq9CF,CAAC"}
@@ -74,7 +74,7 @@ export const describe_standard_integration_tests = (options) => {
74
74
  describe('standard_integration', () => {
75
75
  const { cookie_name } = options.session_options;
76
76
  // Error coverage tracking across test groups
77
- const error_collector = new ErrorCoverageCollector();
77
+ const error_collector = new ErrorCoverageCollector(options.surface_source.route_error_maps);
78
78
  // the auth routes this suite drives: login / logout / password, signup
79
79
  // (when wired), and the shared RPC endpoint — admin-role routes belong to
80
80
  // the admin suite
@@ -98,15 +98,7 @@ export const describe_standard_integration_tests = (options) => {
98
98
  // the admin suite instead.
99
99
  const auth_routes = route_specs.filter(is_suite_auth_route);
100
100
  assert_error_coverage(error_collector, auth_routes.length > 0 ? auth_routes : route_specs, {
101
- min_coverage: options.error_coverage_min ?? DEFAULT_INTEGRATION_ERROR_COVERAGE,
102
- // Authorization denials (403) on these scoped auth routes — the
103
- // credential-channel gate on /logout + /password, the invite gate on
104
- // /signup — are exercised by the conformance + attack-surface suites,
105
- // not this lifecycle suite. Drop 403 from this collector's denominator
106
- // (same spirit as the [401, 403, 429] ignore in the attack-surface
107
- // tightness defaults); otherwise #10 adding /logout's 403 to the spine
108
- // surface tips the ratio under threshold here though the gate is tested.
109
- ignore_statuses: [403]
101
+ min_coverage: options.error_coverage_min ?? DEFAULT_INTEGRATION_ERROR_COVERAGE
110
102
  });
111
103
  });
112
104
  // --- 1. Login/logout lifecycle ---
@@ -292,7 +284,7 @@ export const describe_standard_integration_tests = (options) => {
292
284
  assert.strictEqual(res.status, 200);
293
285
  const body = await res.json();
294
286
  // Throws on any extra or missing field — drift on either backend fails.
295
- LoginOutput.parse(body);
287
+ parse_or_throw(LoginOutput, body);
296
288
  });
297
289
  });
298
290
  // --- 1b. Account status body (strict schema) ---
@@ -868,7 +860,7 @@ export const describe_standard_integration_tests = (options) => {
868
860
  })
869
861
  });
870
862
  assert.strictEqual(res.status, 401);
871
- await assert_response_matches_spec(route_specs, 'POST', login_route.path, res);
863
+ await assert_response_matches_spec(route_specs, 'POST', login_route.path, res, options.surface_source.route_error_maps);
872
864
  });
873
865
  test('POST /logout 200 response matches output schema', async () => {
874
866
  const fixture = await options.setup_test();
@@ -880,7 +872,7 @@ export const describe_standard_integration_tests = (options) => {
880
872
  body: JSON.stringify({})
881
873
  });
882
874
  assert.strictEqual(res.status, 200);
883
- await assert_response_matches_spec(route_specs, 'POST', logout_route.path, res);
875
+ await assert_response_matches_spec(route_specs, 'POST', logout_route.path, res, options.surface_source.route_error_maps);
884
876
  });
885
877
  test('POST /logout 401 response matches declared error schema', async () => {
886
878
  const fixture = await options.setup_test();
@@ -894,7 +886,7 @@ export const describe_standard_integration_tests = (options) => {
894
886
  body: JSON.stringify({})
895
887
  });
896
888
  assert.strictEqual(res.status, 401);
897
- await assert_response_matches_spec(route_specs, 'POST', logout_route.path, res);
889
+ await assert_response_matches_spec(route_specs, 'POST', logout_route.path, res, options.surface_source.route_error_maps);
898
890
  });
899
891
  });
900
892
  // Rate-limit behavior is covered end-to-end by
@@ -1,13 +1,22 @@
1
1
  import './assert_dev_env.js';
2
2
  import type { RouteSpec, RouteMethod } from '../http/route_spec.js';
3
+ import { type RouteErrorMap } from '../http/route_errors.js';
3
4
  import { type RouteAuth } from '../http/auth_shape.js';
4
5
  import type { TestAccount } from './app_server.js';
5
6
  /**
6
- * Find a route spec matching the given method and path.
7
+ * Find the route spec a request reaches: the first in list (mount) order
8
+ * whose method and path template match it, `HEAD` read as `GET` — the order
9
+ * Hono dispatches by, which the DEV error check reads through Hono's own
10
+ * router (`create_route_lookup`). This lookup is hono-free
11
+ * (`find_mounted_route`), pinned against Hono by the route-lookup tests. The
12
+ * path is read as Hono reads it: its pathname, percent-decoded.
7
13
  *
8
- * Supports both exact matches and parameterized paths (`:param` segments).
14
+ * A path template passed as the path (`/api/things/:id`, a segment that is
15
+ * `*` or starts with `:`) finds its own spec first, outranking mount order.
9
16
  *
10
- * @param path - request path (exact or with concrete param values)
17
+ * @param specs - the route specs, in mount order
18
+ * @param method - the request method
19
+ * @param path - request path, concrete or a route's own template
11
20
  */
12
21
  export declare const find_route_spec: (specs: Array<RouteSpec>, method: string, path: string) => RouteSpec | undefined;
13
22
  /**
@@ -33,14 +42,33 @@ export declare const find_auth_route: (specs: Array<RouteSpec>, suffix: RestAuth
33
42
  /**
34
43
  * Validate a response body against the route spec's declared schemas.
35
44
  *
36
- * For 2xx responses, validates against `spec.output`.
37
- * For error responses, validates against the merged error schema for that status code.
45
+ * For 2xx responses, validates against `spec.output`. For an error response
46
+ * (400 and up), checks it against the route's error map
47
+ * (`resolve_route_error_map`) — the one in `route_error_maps`, an
48
+ * `AppSurfaceSpec`'s, built with the app's middleware, or without one the
49
+ * route's own — through `assert_error_response_declared`, by the rule the DEV
50
+ * error check runs (`check_route_error`): the status must be
51
+ * declared and the body must parse against it. A 500 `internal_error` and a
52
+ * 503 `service_unavailable` are always accepted, and on a `jsonrpc` route (the
53
+ * RPC endpoint's) a JSON-RPC error envelope is not a REST error body; on any
54
+ * other route it is checked like any error body.
38
55
  *
39
- * @throws Error if no route spec matches `method` + `path`, if the response
40
- * body fails to parse against the declared output / error schema, or if the
41
- * response is non-JSON despite a declared schema for that status.
56
+ * The route is the one `find_route_spec` finds, the request's as Hono
57
+ * dispatches it. A failure reads as the DEV check logs it
58
+ * (`format_route_error_check`), then `: ` and the issues or the body as JSON.
59
+ *
60
+ * Only a JSON response, by its `Content-Type` (`is_json_response`, the DEV
61
+ * check's gate), has a body to check. A non-JSON response passes only where
62
+ * no schema applies: a 2xx on a route with a null output, or an error status
63
+ * the map doesn't declare.
64
+ *
65
+ * @param route_error_maps - each route's error map, keyed `METHOD path` (`AppSurfaceSpec.route_error_maps`)
66
+ * @throws Error if no route spec matches `method` + `path`, if the body fails
67
+ * its output schema, if a JSON error is at a status the route's map lacks or
68
+ * off its schema, or if the response is non-JSON despite a declared schema
69
+ * for its status.
42
70
  */
43
- export declare const assert_response_matches_spec: (route_specs: Array<RouteSpec>, method: string, path: string, response: Response) => Promise<void>;
71
+ export declare const assert_response_matches_spec: (route_specs: Array<RouteSpec>, method: string, path: string, response: Response, route_error_maps?: ReadonlyMap<string, RouteErrorMap> | null) => Promise<void>;
44
72
  /**
45
73
  * Assert that an error response contains no leaky field values.
46
74
  *
@@ -1 +1 @@
1
- {"version":3,"file":"integration_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/testing/integration_helpers.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAU7B,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAkB,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAGvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAInD;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,GAC3B,OAAO,KAAK,CAAC,SAAS,CAAC,EACvB,QAAQ,MAAM,EACd,MAAM,MAAM,KACV,SAAS,GAAG,SAad,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,iFAO3B,CAAC;AACX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,GAC3B,OAAO,KAAK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