@fuzdev/fuz_app 0.155.1 → 0.157.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 (145) hide show
  1. package/dist/actions/CLAUDE.md +27 -14
  2. package/dist/actions/action_codegen.d.ts +10 -3
  3. package/dist/actions/action_codegen.d.ts.map +1 -1
  4. package/dist/actions/action_codegen.js +52 -13
  5. package/dist/actions/action_event.d.ts.map +1 -1
  6. package/dist/actions/action_event.js +13 -11
  7. package/dist/actions/action_rpc.d.ts +4 -3
  8. package/dist/actions/action_rpc.d.ts.map +1 -1
  9. package/dist/actions/action_rpc.js +4 -3
  10. package/dist/actions/action_spec.d.ts +102 -206
  11. package/dist/actions/action_spec.d.ts.map +1 -1
  12. package/dist/actions/action_spec.js +18 -96
  13. package/dist/actions/action_types.d.ts +4 -4
  14. package/dist/actions/action_types.d.ts.map +1 -1
  15. package/dist/actions/action_types.js +2 -2
  16. package/dist/actions/broadcast_api.d.ts.map +1 -1
  17. package/dist/actions/broadcast_api.js +6 -5
  18. package/dist/actions/compile_action_registry.d.ts +11 -6
  19. package/dist/actions/compile_action_registry.d.ts.map +1 -1
  20. package/dist/actions/compile_action_registry.js +15 -9
  21. package/dist/actions/perform_action.d.ts +4 -4
  22. package/dist/actions/perform_action.d.ts.map +1 -1
  23. package/dist/actions/perform_action.js +11 -11
  24. package/dist/auth/CLAUDE.md +1 -1
  25. package/dist/auth/account_action_specs.d.ts +50 -23
  26. package/dist/auth/account_action_specs.d.ts.map +1 -1
  27. package/dist/auth/account_action_specs.js +18 -8
  28. package/dist/auth/account_route_schema.d.ts +10 -10
  29. package/dist/auth/account_schema.d.ts +21 -21
  30. package/dist/auth/actor_lookup_action_specs.d.ts +7 -7
  31. package/dist/auth/actor_search_action_specs.d.ts +6 -6
  32. package/dist/auth/admin_action_specs.d.ts +98 -98
  33. package/dist/auth/app_settings_schema.d.ts +2 -2
  34. package/dist/auth/audit_log_route_schema.d.ts +1 -1
  35. package/dist/auth/audit_log_schema.d.ts +44 -44
  36. package/dist/auth/auth_guard_resolver.d.ts +2 -2
  37. package/dist/auth/auth_guard_resolver.js +2 -2
  38. package/dist/auth/bootstrap_route_schema.d.ts +4 -4
  39. package/dist/auth/cell_action_specs.d.ts +241 -241
  40. package/dist/auth/cell_actions.js +3 -3
  41. package/dist/auth/cell_audit_action_specs.d.ts +14 -14
  42. package/dist/auth/cell_audit_metadata.d.ts +6 -6
  43. package/dist/auth/cell_field_action_specs.d.ts +38 -38
  44. package/dist/auth/cell_field_audit_metadata.d.ts +4 -4
  45. package/dist/auth/cell_grant_action_specs.d.ts +61 -61
  46. package/dist/auth/cell_grant_audit_metadata.d.ts +10 -10
  47. package/dist/auth/cell_item_action_specs.d.ts +50 -50
  48. package/dist/auth/cell_item_audit_metadata.d.ts +5 -5
  49. package/dist/auth/invite_schema.d.ts +6 -6
  50. package/dist/auth/role_grant_offer_action_specs.d.ts +120 -120
  51. package/dist/auth/role_grant_offer_notifications.d.ts +66 -66
  52. package/dist/auth/role_grant_offer_schema.d.ts +6 -6
  53. package/dist/auth/self_service_role_action_specs.d.ts +2 -2
  54. package/dist/auth/signup_route_schema.d.ts +2 -2
  55. package/dist/http/CLAUDE.md +26 -17
  56. package/dist/http/auth_shape.d.ts +51 -17
  57. package/dist/http/auth_shape.d.ts.map +1 -1
  58. package/dist/http/auth_shape.js +101 -52
  59. package/dist/http/error_schemas.d.ts +15 -8
  60. package/dist/http/error_schemas.d.ts.map +1 -1
  61. package/dist/http/error_schemas.js +4 -9
  62. package/dist/http/jsonrpc_errors.d.ts +11 -4
  63. package/dist/http/jsonrpc_errors.d.ts.map +1 -1
  64. package/dist/http/jsonrpc_errors.js +11 -4
  65. package/dist/http/jsonrpc_helpers.d.ts.map +1 -1
  66. package/dist/http/jsonrpc_helpers.js +2 -1
  67. package/dist/http/route_spec.d.ts +37 -19
  68. package/dist/http/route_spec.d.ts.map +1 -1
  69. package/dist/http/route_spec.js +54 -24
  70. package/dist/http/schema_helpers.d.ts +27 -24
  71. package/dist/http/schema_helpers.d.ts.map +1 -1
  72. package/dist/http/schema_helpers.js +24 -19
  73. package/dist/http/surface.d.ts.map +1 -1
  74. package/dist/http/surface.js +7 -3
  75. package/dist/primitive_schemas.d.ts +16 -5
  76. package/dist/primitive_schemas.d.ts.map +1 -1
  77. package/dist/primitive_schemas.js +26 -4
  78. package/dist/primitive_schemas_fuz.d.ts +67 -0
  79. package/dist/primitive_schemas_fuz.d.ts.map +1 -0
  80. package/dist/primitive_schemas_fuz.js +47 -0
  81. package/dist/realtime/sse.d.ts +3 -3
  82. package/dist/realtime/sse.d.ts.map +1 -1
  83. package/dist/realtime/sse.js +4 -4
  84. package/dist/schema_issues.d.ts +91 -4
  85. package/dist/schema_issues.d.ts.map +1 -1
  86. package/dist/schema_issues.js +262 -1
  87. package/dist/schema_meta.d.ts +24 -8
  88. package/dist/schema_meta.d.ts.map +1 -1
  89. package/dist/schema_meta.js +31 -10
  90. package/dist/server/serve_fact_route.d.ts.map +1 -1
  91. package/dist/server/serve_fact_route.js +2 -1
  92. package/dist/testing/CLAUDE.md +23 -17
  93. package/dist/testing/admin_integration.d.ts.map +1 -1
  94. package/dist/testing/admin_integration.js +3 -2
  95. package/dist/testing/adversarial_404.d.ts +2 -2
  96. package/dist/testing/adversarial_404.d.ts.map +1 -1
  97. package/dist/testing/adversarial_404.js +8 -5
  98. package/dist/testing/adversarial_input.js +1 -1
  99. package/dist/testing/adversarial_input_cases.d.ts +18 -23
  100. package/dist/testing/adversarial_input_cases.d.ts.map +1 -1
  101. package/dist/testing/adversarial_input_cases.js +51 -46
  102. package/dist/testing/assertions.d.ts +6 -5
  103. package/dist/testing/assertions.d.ts.map +1 -1
  104. package/dist/testing/assertions.js +9 -4
  105. package/dist/testing/cross_backend/action_manifest.d.ts +2 -1
  106. package/dist/testing/cross_backend/action_manifest.d.ts.map +1 -1
  107. package/dist/testing/cross_backend/action_manifest.js +3 -3
  108. package/dist/testing/cross_backend/cell_crud.d.ts.map +1 -1
  109. package/dist/testing/cross_backend/cell_crud.js +3 -8
  110. package/dist/testing/cross_backend/conformance_table.d.ts.map +1 -1
  111. package/dist/testing/cross_backend/conformance_table.js +5 -4
  112. package/dist/testing/cross_backend/cross_rpc.d.ts +4 -2
  113. package/dist/testing/cross_backend/cross_rpc.d.ts.map +1 -1
  114. package/dist/testing/cross_backend/cross_rpc.js +6 -4
  115. package/dist/testing/cross_backend/rpc_success_fixtures.d.ts.map +1 -1
  116. package/dist/testing/cross_backend/sse_round_trip.d.ts.map +1 -1
  117. package/dist/testing/cross_backend/sse_round_trip.js +3 -2
  118. package/dist/testing/cross_backend/testing_reset_actions.d.ts +8 -8
  119. package/dist/testing/error_coverage.d.ts +9 -17
  120. package/dist/testing/error_coverage.d.ts.map +1 -1
  121. package/dist/testing/error_coverage.js +20 -3
  122. package/dist/testing/integration_helpers.d.ts.map +1 -1
  123. package/dist/testing/integration_helpers.js +7 -6
  124. package/dist/testing/rpc_envelope_cases.d.ts +3 -3
  125. package/dist/testing/rpc_envelope_cases.d.ts.map +1 -1
  126. package/dist/testing/rpc_envelope_cases.js +1 -1
  127. package/dist/testing/rpc_helpers.d.ts +12 -8
  128. package/dist/testing/rpc_helpers.d.ts.map +1 -1
  129. package/dist/testing/rpc_helpers.js +18 -15
  130. package/dist/testing/schema_generators.d.ts +75 -40
  131. package/dist/testing/schema_generators.d.ts.map +1 -1
  132. package/dist/testing/schema_generators.js +273 -99
  133. package/dist/testing/sse_round_trip.d.ts.map +1 -1
  134. package/dist/testing/sse_round_trip.js +4 -3
  135. package/dist/ui/admin_accounts_state.svelte.d.ts +10 -10
  136. package/dist/ui/admin_accounts_state.svelte.d.ts.map +1 -1
  137. package/dist/ui/admin_invites_state.svelte.d.ts +1 -1
  138. package/dist/ui/admin_invites_state.svelte.d.ts.map +1 -1
  139. package/dist/ui/admin_sessions_state.svelte.d.ts +2 -2
  140. package/dist/ui/admin_sessions_state.svelte.d.ts.map +1 -1
  141. package/dist/ui/role_grant_offers_state.svelte.d.ts +6 -6
  142. package/dist/zod.d.ts +23 -5
  143. package/dist/zod.d.ts.map +1 -1
  144. package/dist/zod.js +2 -2
  145. package/package.json +6 -6
@@ -20,18 +20,21 @@
20
20
  * `actions → http` dependency direction (and `http/error_schemas.ts` /
21
21
  * `http/surface.ts` consume the type).
22
22
  *
23
- * Registry-time invariants 1, 3, and 4 live on the schema's
24
- * `.superRefine` so any spec that fails them throws at the Zod parse
25
- * boundary. Invariant 2 (the `actor !== 'none' ⟺ input or query
26
- * declares acting?: ActingActor` biconditional) needs introspection of
27
- * the spec's input/query schemas, so it is enforced at registration
28
- * time inside the dispatcher loops (`apply_route_specs`,
29
- * `create_rpc_endpoint`, `register_action_ws`) via the
30
- * `assert_route_auth_acting_biconditional` helper exported below.
23
+ * Every registry-time invariant is enforced at registration, inside the
24
+ * dispatcher loops every spec passes (`apply_route_specs` for route specs,
25
+ * `compile_action_registry` for `create_rpc_endpoint` and
26
+ * `register_action_ws`): the cross-axis invariants 1, 3, and 4 by
27
+ * `assert_route_auth_invariants`, which reads the auth shape alone, and
28
+ * invariant 2 (the `actor !== 'none' ⟺ input or query declares
29
+ * acting?: ActingActor` biconditional), which introspects the spec's
30
+ * input/query schemas, by `assert_route_auth_acting_biconditional`. Specs
31
+ * are plain objects that no registration path parses, so neither check
32
+ * can live only on a schema.
31
33
  *
32
34
  * @module
33
35
  */
34
36
  import { z } from 'zod';
37
+ import type { ValidationSchema } from '../schema_issues.js';
35
38
  /**
36
39
  * `acting` field shared by every input that needs the caller's acting actor.
37
40
  * Declaring `acting: ActingActor` on a route or action input signals to the
@@ -51,8 +54,11 @@ import { z } from 'zod';
51
54
  * invariant 2: `auth.actor !== 'none'` ⟺ input (or query, on REST GETs)
52
55
  * declares `acting?: ActingActor`. Keeping the contract in one module
53
56
  * removes the http/ → auth/ import that an earlier split forced.
57
+ *
58
+ * A fuz_schema input declares the twin in `primitive_schemas_fuz.ts`, which
59
+ * the dispatcher finds the same way.
54
60
  */
55
- export declare const ActingActor: z.ZodOptional<z.core.$ZodBranded<z.ZodUUID, "Uuid", "out">>;
61
+ export declare const ActingActor: z.ZodOptional<z.ZodUUID & z.ZodType<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string, z.core.$ZodTypeInternals<import("@fuzdev/fuz_schema/schema.ts").Branded<string, "Uuid">, string>>>;
56
62
  export type ActingActor = z.infer<typeof ActingActor>;
57
63
  /**
58
64
  * Read an `acting` selector out of an unvalidated value.
@@ -74,6 +80,12 @@ export type ActingActor = z.infer<typeof ActingActor>;
74
80
  * an input schema behind it, so there a malformed selector is final (the
75
81
  * status route answers account-only).
76
82
  *
83
+ * The grammar is the fuz_schema twin's, which is the Zod `ActingActor`'s and
84
+ * the Rust spine's, so every value reads as the Zod `ActingActor` would, the
85
+ * max UUID in any case included. The id comes back lowercased. A route
86
+ * declaring `acting` on its Zod `query` schema doesn't read it here: that
87
+ * schema runs ahead of the authorization phase, with the same grammar.
88
+ *
77
89
  * @param value - the raw `acting` field, from params / query / body
78
90
  * @returns the actor id, or `undefined` when absent or malformed
79
91
  */
@@ -102,7 +114,9 @@ export type AuthAxisState = z.infer<typeof AuthAxisState>;
102
114
  * The canonical auth shape used by both `ActionSpec.auth` and
103
115
  * `RouteSpec.auth`.
104
116
  *
105
- * Cross-axis registry invariants enforced via `.superRefine`:
117
+ * Cross-axis registry invariants, checked at registration by
118
+ * `assert_route_auth_invariants` (and by this schema's `.superRefine`, the
119
+ * same check, when a caller parses an auth shape):
106
120
  *
107
121
  * 1. **Roles imply actor.** `roles?.length` ⟹ `actor === 'required'`.
108
122
  * Role checks read the actor's role_grants, so a role-gated spec without
@@ -114,8 +128,7 @@ export type AuthAxisState = z.infer<typeof AuthAxisState>;
114
128
  * ⟹ no `roles`, no `credential_types` (nothing left to gate). The same
115
129
  * rule covers `required_scope`, but enforcing it needs the capability
116
130
  * vocabulary from `auth/`, so it lives with the other `required_scope`
117
- * check in `fuz_auth_guard_resolver` — which is also the only site every
118
- * route spec traverses, since the route pipeline never parses this schema.
131
+ * check in `fuz_auth_guard_resolver`.
119
132
  *
120
133
  * Invariant 2 — the `actor !== 'none' ⟺ input or query declares
121
134
  * acting?: ActingActor` biconditional — needs introspection of the
@@ -184,18 +197,39 @@ export declare const is_keeper_auth: (auth: RouteAuth) => boolean;
184
197
  * `is_credential_gated_auth` instead.
185
198
  */
186
199
  export declare const is_plain_authenticated_auth: (auth: RouteAuth) => boolean;
200
+ /**
201
+ * Registry-time check of the cross-axis invariants 1, 3, and 4 (see
202
+ * `RouteAuth`). Throws on violation, naming every invariant the shape breaks.
203
+ *
204
+ * Called by every dispatcher registration loop (`apply_route_specs`,
205
+ * `compile_action_registry`) on every spec it accepts, so a spec that breaks
206
+ * one fails at assembly rather than at its first request.
207
+ *
208
+ * @param auth - the route/action's auth shape
209
+ * @param context - identifier for the throwing message (route key, RPC method, etc.)
210
+ * @throws Error when any cross-axis invariant is violated
211
+ */
212
+ export declare const assert_route_auth_invariants: (auth: RouteAuth, context: string) => void;
187
213
  /**
188
214
  * Whether a schema declares the canonical `acting?: ActingActor` field.
189
- * Reference-equality on the exported `ActingActor` schema — consumer
190
- * schemas with unrelated `acting` fields don't trip this check.
215
+ * Reference-equality on the exported `ActingActor` schema of the input's
216
+ * library — the Zod one here, the fuz_schema twin in
217
+ * `primitive_schemas_fuz.ts` — so consumer schemas with unrelated `acting`
218
+ * fields don't trip this check, nor does either twin in the other library's
219
+ * object.
191
220
  *
192
221
  * Peels through Zod wrappers (`optional`, `nullable`, `default`,
193
222
  * `transform`, `pipe`, `prefault`) via `zod_unwrap_to_object` so a spec
194
223
  * authored as `z.optional(z.strictObject({acting: ActingActor}))` or
195
224
  * `z.strictObject({acting: ActingActor}).default({})` still trips the
196
225
  * predicate.
226
+ *
227
+ * A `@fuzdev/fuz_schema` schema is read by `get_schema_entries`, which sees
228
+ * through its wrappers (`optional`, `nullable`, the defaults) and a `pipe` to
229
+ * the schema it starts with; a schema that isn't an object under them (a void
230
+ * input, say) answers `false`.
197
231
  */
198
- export declare const input_schema_declares_acting: (schema: z.ZodType) => boolean;
232
+ export declare const input_schema_declares_acting: (schema: ValidationSchema) => boolean;
199
233
  /**
200
234
  * Slots where a spec may declare the `acting?: ActingActor` field —
201
235
  * input for both REST + actions; query for REST GETs that bi-locate
@@ -203,8 +237,8 @@ export declare const input_schema_declares_acting: (schema: z.ZodType) => boolea
203
237
  * field is omitted on action call sites).
204
238
  */
205
239
  export interface ActingSlots {
206
- input: z.ZodType;
207
- query?: z.ZodType;
240
+ input: ValidationSchema;
241
+ query?: ValidationSchema;
208
242
  }
209
243
  /**
210
244
  * Registry-time biconditional check: `auth.actor !== 'none' ⟺ some
@@ -1 +1 @@
1
- {"version":3,"file":"auth_shape.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/auth_shape.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,WAAW,6DAGtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,eAAO,MAAM,YAAY,GAAI,OAAO,OAAO,KAAG,MAAM,GAAG,SAGtD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,aAAa;;;;EAA2C,CAAC;AACtE,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;kBA+EnB,CAAC;AACJ,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AAUlD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,CAAC,EAAE,gBAAgB,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,sCAAsC,GAClD,MAAM,SAAS,EACf,OAAO,WAAW,EAClB,SAAS,MAAM,KACb,IAmBF,CAAC"}
@@ -20,19 +20,24 @@
20
20
  * `actions → http` dependency direction (and `http/error_schemas.ts` /
21
21
  * `http/surface.ts` consume the type).
22
22
  *
23
- * Registry-time invariants 1, 3, and 4 live on the schema's
24
- * `.superRefine` so any spec that fails them throws at the Zod parse
25
- * boundary. Invariant 2 (the `actor !== 'none' ⟺ input or query
26
- * declares acting?: ActingActor` biconditional) needs introspection of
27
- * the spec's input/query schemas, so it is enforced at registration
28
- * time inside the dispatcher loops (`apply_route_specs`,
29
- * `create_rpc_endpoint`, `register_action_ws`) via the
30
- * `assert_route_auth_acting_biconditional` helper exported below.
23
+ * Every registry-time invariant is enforced at registration, inside the
24
+ * dispatcher loops every spec passes (`apply_route_specs` for route specs,
25
+ * `compile_action_registry` for `create_rpc_endpoint` and
26
+ * `register_action_ws`): the cross-axis invariants 1, 3, and 4 by
27
+ * `assert_route_auth_invariants`, which reads the auth shape alone, and
28
+ * invariant 2 (the `actor !== 'none' ⟺ input or query declares
29
+ * acting?: ActingActor` biconditional), which introspects the spec's
30
+ * input/query schemas, by `assert_route_auth_acting_biconditional`. Specs
31
+ * are plain objects that no registration path parses, so neither check
32
+ * can live only on a schema.
31
33
  *
32
34
  * @module
33
35
  */
34
36
  import { z } from 'zod';
37
+ import { is_schema, parse } from '@fuzdev/fuz_schema/schema.ts';
38
+ import { get_schema_entries } from '@fuzdev/fuz_schema/introspect.ts';
35
39
  import { Uuid } from '../primitive_schemas.js';
40
+ import { ACTING_ACTOR_DESCRIPTION, ActingActor as ActingActorFuz } from '../primitive_schemas_fuz.js';
36
41
  import { zod_unwrap_to_object } from '../zod.js';
37
42
  /**
38
43
  * `acting` field shared by every input that needs the caller's acting actor.
@@ -53,10 +58,11 @@ import { zod_unwrap_to_object } from '../zod.js';
53
58
  * invariant 2: `auth.actor !== 'none'` ⟺ input (or query, on REST GETs)
54
59
  * declares `acting?: ActingActor`. Keeping the contract in one module
55
60
  * removes the http/ → auth/ import that an earlier split forced.
61
+ *
62
+ * A fuz_schema input declares the twin in `primitive_schemas_fuz.ts`, which
63
+ * the dispatcher finds the same way.
56
64
  */
57
- export const ActingActor = Uuid.optional().meta({
58
- description: 'Actor on the authenticated account that this request acts as. Omit on single-actor accounts; required on multi-actor.'
59
- });
65
+ export const ActingActor = Uuid.optional().meta({ description: ACTING_ACTOR_DESCRIPTION });
60
66
  /**
61
67
  * Read an `acting` selector out of an unvalidated value.
62
68
  *
@@ -77,12 +83,18 @@ export const ActingActor = Uuid.optional().meta({
77
83
  * an input schema behind it, so there a malformed selector is final (the
78
84
  * status route answers account-only).
79
85
  *
86
+ * The grammar is the fuz_schema twin's, which is the Zod `ActingActor`'s and
87
+ * the Rust spine's, so every value reads as the Zod `ActingActor` would, the
88
+ * max UUID in any case included. The id comes back lowercased. A route
89
+ * declaring `acting` on its Zod `query` schema doesn't read it here: that
90
+ * schema runs ahead of the authorization phase, with the same grammar.
91
+ *
80
92
  * @param value - the raw `acting` field, from params / query / body
81
93
  * @returns the actor id, or `undefined` when absent or malformed
82
94
  */
83
95
  export const parse_acting = (value) => {
84
- const parsed = ActingActor.safeParse(value);
85
- return parsed.success ? parsed.data : undefined;
96
+ const parsed = parse(ActingActorFuz, value);
97
+ return parsed.ok ? parsed.value : undefined;
86
98
  };
87
99
  /**
88
100
  * Per-axis auth state — names the dispatcher's behavior on `account` and
@@ -99,11 +111,51 @@ export const parse_acting = (value) => {
99
111
  * without an actor binding).
100
112
  */
101
113
  export const AuthAxisState = z.enum(['none', 'optional', 'required']);
114
+ /**
115
+ * The cross-axis invariants 1, 3, and 4 an auth shape breaks, in that order —
116
+ * the one implementation behind `assert_route_auth_invariants` and the
117
+ * `RouteAuth` schema's `.superRefine`.
118
+ */
119
+ const route_auth_invariant_violations = (auth) => {
120
+ const violations = [];
121
+ // invariant 1: roles imply actor
122
+ if (auth.roles?.length && auth.actor !== 'required') {
123
+ violations.push({
124
+ path: 'roles',
125
+ message: "auth.roles requires auth.actor === 'required' (role checks read the actor's role_grants)"
126
+ });
127
+ }
128
+ // invariant 3: no accountless actors yet
129
+ if (auth.account === 'none' && auth.actor !== 'none') {
130
+ violations.push({
131
+ path: 'actor',
132
+ message: "auth.account === 'none' && auth.actor !== 'none' is not yet supported — accountless credentials (agent-token, group-actor) are out of scope for v1"
133
+ });
134
+ }
135
+ // invariant 4: unrestricted is leaf
136
+ if (auth.account === 'none' && auth.actor === 'none') {
137
+ if (auth.roles?.length) {
138
+ violations.push({
139
+ path: 'roles',
140
+ message: "unrestricted auth (account === 'none' && actor === 'none') cannot declare roles — nothing to gate"
141
+ });
142
+ }
143
+ if (auth.credential_types?.length) {
144
+ violations.push({
145
+ path: 'credential_types',
146
+ message: "unrestricted auth (account === 'none' && actor === 'none') cannot declare credential_types — nothing to gate"
147
+ });
148
+ }
149
+ }
150
+ return violations;
151
+ };
102
152
  /**
103
153
  * The canonical auth shape used by both `ActionSpec.auth` and
104
154
  * `RouteSpec.auth`.
105
155
  *
106
- * Cross-axis registry invariants enforced via `.superRefine`:
156
+ * Cross-axis registry invariants, checked at registration by
157
+ * `assert_route_auth_invariants` (and by this schema's `.superRefine`, the
158
+ * same check, when a caller parses an auth shape):
107
159
  *
108
160
  * 1. **Roles imply actor.** `roles?.length` ⟹ `actor === 'required'`.
109
161
  * Role checks read the actor's role_grants, so a role-gated spec without
@@ -115,8 +167,7 @@ export const AuthAxisState = z.enum(['none', 'optional', 'required']);
115
167
  * ⟹ no `roles`, no `credential_types` (nothing left to gate). The same
116
168
  * rule covers `required_scope`, but enforcing it needs the capability
117
169
  * vocabulary from `auth/`, so it lives with the other `required_scope`
118
- * check in `fuz_auth_guard_resolver` — which is also the only site every
119
- * route spec traverses, since the route pipeline never parses this schema.
170
+ * check in `fuz_auth_guard_resolver`.
120
171
  *
121
172
  * Invariant 2 — the `actor !== 'none' ⟺ input or query declares
122
173
  * acting?: ActingActor` biconditional — needs introspection of the
@@ -166,38 +217,8 @@ export const RouteAuth = z
166
217
  required_scope: z.string().optional()
167
218
  })
168
219
  .superRefine((value, ctx) => {
169
- // invariant 1: roles imply actor
170
- if (value.roles?.length && value.actor !== 'required') {
171
- ctx.addIssue({
172
- code: 'custom',
173
- message: "auth.roles requires auth.actor === 'required' (role checks read the actor's role_grants)",
174
- path: ['roles']
175
- });
176
- }
177
- // invariant 3: no accountless actors yet
178
- if (value.account === 'none' && value.actor !== 'none') {
179
- ctx.addIssue({
180
- code: 'custom',
181
- message: "auth.account === 'none' && auth.actor !== 'none' is not yet supported — accountless credentials (agent-token, group-actor) are out of scope for v1",
182
- path: ['actor']
183
- });
184
- }
185
- // invariant 4: unrestricted is leaf
186
- if (value.account === 'none' && value.actor === 'none') {
187
- if (value.roles?.length) {
188
- ctx.addIssue({
189
- code: 'custom',
190
- message: "unrestricted auth (account === 'none' && actor === 'none') cannot declare roles — nothing to gate",
191
- path: ['roles']
192
- });
193
- }
194
- if (value.credential_types?.length) {
195
- ctx.addIssue({
196
- code: 'custom',
197
- message: "unrestricted auth (account === 'none' && actor === 'none') cannot declare credential_types — nothing to gate",
198
- path: ['credential_types']
199
- });
200
- }
220
+ for (const { path, message } of route_auth_invariant_violations(value)) {
221
+ ctx.addIssue({ code: 'custom', message, path: [path] });
201
222
  }
202
223
  });
203
224
  // --- Predicates over the flat-record shape ---
@@ -252,6 +273,24 @@ export const is_keeper_auth = (auth) => auth.credential_types?.includes('daemon_
252
273
  * `is_credential_gated_auth` instead.
253
274
  */
254
275
  export const is_plain_authenticated_auth = (auth) => auth.account === 'required' && !is_role_auth(auth) && !is_credential_gated_auth(auth);
276
+ /**
277
+ * Registry-time check of the cross-axis invariants 1, 3, and 4 (see
278
+ * `RouteAuth`). Throws on violation, naming every invariant the shape breaks.
279
+ *
280
+ * Called by every dispatcher registration loop (`apply_route_specs`,
281
+ * `compile_action_registry`) on every spec it accepts, so a spec that breaks
282
+ * one fails at assembly rather than at its first request.
283
+ *
284
+ * @param auth - the route/action's auth shape
285
+ * @param context - identifier for the throwing message (route key, RPC method, etc.)
286
+ * @throws Error when any cross-axis invariant is violated
287
+ */
288
+ export const assert_route_auth_invariants = (auth, context) => {
289
+ const violations = route_auth_invariant_violations(auth);
290
+ if (violations.length === 0)
291
+ return;
292
+ throw new Error(`${context}: ${violations.map((v) => v.message).join('; ')} (registry-time invariants)`);
293
+ };
255
294
  // --- Registry-time invariant 2 enforcement ---
256
295
  //
257
296
  // The biconditional `auth.actor !== 'none' ⟺ input (or query, on REST
@@ -263,16 +302,26 @@ export const is_plain_authenticated_auth = (auth) => auth.account === 'required'
263
302
  // `create_rpc_endpoint` + `register_action_ws`).
264
303
  /**
265
304
  * Whether a schema declares the canonical `acting?: ActingActor` field.
266
- * Reference-equality on the exported `ActingActor` schema — consumer
267
- * schemas with unrelated `acting` fields don't trip this check.
305
+ * Reference-equality on the exported `ActingActor` schema of the input's
306
+ * library — the Zod one here, the fuz_schema twin in
307
+ * `primitive_schemas_fuz.ts` — so consumer schemas with unrelated `acting`
308
+ * fields don't trip this check, nor does either twin in the other library's
309
+ * object.
268
310
  *
269
311
  * Peels through Zod wrappers (`optional`, `nullable`, `default`,
270
312
  * `transform`, `pipe`, `prefault`) via `zod_unwrap_to_object` so a spec
271
313
  * authored as `z.optional(z.strictObject({acting: ActingActor}))` or
272
314
  * `z.strictObject({acting: ActingActor}).default({})` still trips the
273
315
  * predicate.
316
+ *
317
+ * A `@fuzdev/fuz_schema` schema is read by `get_schema_entries`, which sees
318
+ * through its wrappers (`optional`, `nullable`, the defaults) and a `pipe` to
319
+ * the schema it starts with; a schema that isn't an object under them (a void
320
+ * input, say) answers `false`.
274
321
  */
275
322
  export const input_schema_declares_acting = (schema) => {
323
+ if (is_schema(schema))
324
+ return get_schema_entries(schema)?.acting === ActingActorFuz;
276
325
  const obj = zod_unwrap_to_object(schema);
277
326
  if (!obj)
278
327
  return false;
@@ -305,7 +354,7 @@ export const assert_route_auth_acting_biconditional = (auth, slots, context) =>
305
354
  return;
306
355
  const slot_phrase = slots.query !== undefined ? 'input or query schema' : 'input schema';
307
356
  if (wants_actor) {
308
- throw new Error(`${context}: auth.actor === '${auth.actor}' requires the ${slot_phrase} to declare 'acting?: ActingActor' (registry-time invariant 2)`);
357
+ throw new Error(`${context}: auth.actor === '${auth.actor}' requires the ${slot_phrase} to declare 'acting?: ActingActor', the Zod one or its fuz_schema twin (registry-time invariant 2)`);
309
358
  }
310
- throw new Error(`${context}: ${slot_phrase} declares 'acting?: ActingActor' but auth.actor === 'none' (registry-time invariant 2)`);
359
+ throw new Error(`${context}: ${slot_phrase} declares 'acting?: ActingActor' (Zod or fuz_schema) but auth.actor === 'none' (registry-time invariant 2)`);
311
360
  };
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import { z } from 'zod';
15
15
  import { type RouteAuth } from './auth_shape.js';
16
+ import { type ValidationSchema } from '../schema_issues.js';
16
17
  /** Request body failed Zod validation. */
17
18
  export declare const ERROR_INVALID_REQUEST_BODY: "invalid_request_body";
18
19
  /** Request body is not valid JSON or not an object. */
@@ -175,8 +176,8 @@ export type ApiError = z.infer<typeof ApiError>;
175
176
  * parsing, or when the request body is not valid JSON.
176
177
  *
177
178
  * `error` is one of the four validation codes the framework emits.
178
- * `issues` carries Zod's validation issues for diagnostic display on the
179
- * three schema-failure cases (`invalid_request_body`,
179
+ * `issues` carries the validation issues as `WireIssue`s, whichever schema
180
+ * library refused, for diagnostic display on the three schema-failure cases (`invalid_request_body`,
180
181
  * `invalid_route_params`, `invalid_query_params`). The field is optional:
181
182
  * the `invalid_json_body` case (request body parse failure or non-object
182
183
  * root) emits no `issues`, and the schema-failure cases emit them only in
@@ -191,9 +192,11 @@ export declare const ValidationError: z.ZodObject<{
191
192
  invalid_query_params: "invalid_query_params";
192
193
  }>;
193
194
  issues: z.ZodOptional<z.ZodArray<z.ZodObject<{
194
- code: z.ZodString;
195
- message: z.ZodString;
195
+ kind: z.ZodString;
196
196
  path: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>;
197
+ expected: z.ZodString;
198
+ received: z.ZodString;
199
+ message: z.ZodString;
197
200
  }, z.core.$loose>>>;
198
201
  }, z.core.$loose>;
199
202
  export type ValidationError = z.infer<typeof ValidationError>;
@@ -306,11 +309,15 @@ export declare const AccountVanishedError: z.ZodObject<{
306
309
  }, z.core.$loose>;
307
310
  export type AccountVanishedError = z.infer<typeof AccountVanishedError>;
308
311
  /**
309
- * Error schema map — maps HTTP status codes to Zod schemas.
312
+ * Error schema map — maps HTTP status codes to Zod or `@fuzdev/fuz_schema`
313
+ * schemas.
310
314
  *
311
- * Used on `RouteSpec.errors` and internally by `derive_error_schemas`.
315
+ * Used on `RouteSpec.errors` and `MiddlewareSpec.errors`; `derive_error_schemas`
316
+ * returns its Zod-only form, `DerivedErrorSchemas`.
312
317
  */
313
- export type RouteErrorSchemas = Partial<Record<number, z.ZodType>>;
318
+ export type RouteErrorSchemas = Partial<Record<number, ValidationSchema>>;
319
+ /** The error schemas `derive_error_schemas` builds, all of them Zod. */
320
+ export type DerivedErrorSchemas = Partial<Record<number, z.ZodType>>;
314
321
  /**
315
322
  * Rate limit key type — declares what a route or RPC action's rate limiter
316
323
  * is keyed on.
@@ -364,5 +371,5 @@ export interface DeriveErrorSchemasOptions {
364
371
  rate_limit?: RateLimitKey;
365
372
  checks_content_type?: boolean;
366
373
  }
367
- export declare const derive_error_schemas: ({ auth, has_input, has_params, has_query, rate_limit, checks_content_type }: DeriveErrorSchemasOptions) => RouteErrorSchemas;
374
+ export declare const derive_error_schemas: ({ auth, has_input, has_params, has_query, rate_limit, checks_content_type }: DeriveErrorSchemasOptions) => DerivedErrorSchemas;
368
375
  //# sourceMappingURL=error_schemas.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error_schemas.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/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CAAC,CAAC;AAEpE,eAAO,MAAM,sBAAsB;;iBAEjC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E,eAAO,MAAM,sBAAsB;;iBAEjC,CAAC;AACH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAE5E,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAE1E,wEAAwE;AACxE,MAAM,MAAM,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;AAErE;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY;;;;EAAoC,CAAC;AAC9D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,MAAM,WAAW,yBAAyB;IACzC,IAAI,EAAE,SAAS,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,YAAY,CAAC;IAC1B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,oBAAoB,GAAI,6EAOlC,yBAAyB,KAAG,mBA8C9B,CAAC"}
@@ -13,6 +13,7 @@
13
13
  */
14
14
  import { z } from 'zod';
15
15
  import { needs_actor } from './auth_shape.js';
16
+ import { WireIssue } from '../schema_issues.js';
16
17
  // --- Core: Validation (auto-derived by route spec middleware) ---
17
18
  /** Request body failed Zod validation. */
18
19
  export const ERROR_INVALID_REQUEST_BODY = 'invalid_request_body';
@@ -186,8 +187,8 @@ export const ApiError = z.looseObject({ error: z.string() });
186
187
  * parsing, or when the request body is not valid JSON.
187
188
  *
188
189
  * `error` is one of the four validation codes the framework emits.
189
- * `issues` carries Zod's validation issues for diagnostic display on the
190
- * three schema-failure cases (`invalid_request_body`,
190
+ * `issues` carries the validation issues as `WireIssue`s, whichever schema
191
+ * library refused, for diagnostic display on the three schema-failure cases (`invalid_request_body`,
191
192
  * `invalid_route_params`, `invalid_query_params`). The field is optional:
192
193
  * the `invalid_json_body` case (request body parse failure or non-object
193
194
  * root) emits no `issues`, and the schema-failure cases emit them only in
@@ -201,13 +202,7 @@ export const ValidationError = z.looseObject({
201
202
  ERROR_INVALID_ROUTE_PARAMS,
202
203
  ERROR_INVALID_QUERY_PARAMS
203
204
  ]),
204
- issues: z
205
- .array(z.looseObject({
206
- code: z.string(),
207
- message: z.string(),
208
- path: z.array(z.union([z.string(), z.number()]))
209
- }))
210
- .optional()
205
+ issues: z.array(WireIssue).optional()
211
206
  });
212
207
  /**
213
208
  * Permission error — returned by `require_role()` and the dispatcher's
@@ -37,13 +37,14 @@ export type JsonrpcErrorName = 'parse_error' | 'invalid_request' | 'method_not_f
37
37
  */
38
38
  export declare const JSONRPC_ERROR_CODES: Readonly<Record<JsonrpcErrorName, JsonrpcErrorCode>>;
39
39
  /**
40
- * Pass `value` through in development, return `undefined` in production — so
41
- * `JSON.stringify` drops the field from the response.
40
+ * Call `get` and return its value in development, return `undefined` in
41
+ * production without calling it — so `JSON.stringify` drops the field from the
42
+ * response, and production pays nothing to build it.
42
43
  *
43
44
  * The single gate for keeping internal diagnostic detail out of production
44
45
  * error responses. Two classes flow through it:
45
46
  *
46
- * - **Zod `issues`** — the issues array exposes field names, types, and
47
+ * - **Validation `issues`** — the issues array exposes field names, types, and
47
48
  * constraints, enough to reverse-engineer an input schema (including on
48
49
  * public/unauthenticated actions). Gate the whole `data` object on JSON-RPC
49
50
  * errors (so `error.data` is absent, matching the Rust spine) and the
@@ -54,9 +55,15 @@ export declare const JSONRPC_ERROR_CODES: Readonly<Record<JsonrpcErrorName, Json
54
55
  *
55
56
  * A legitimate caller only ever needs the error code and a stable message.
56
57
  *
58
+ * A thunk rather than a value because the detail costs work to build — mapping
59
+ * a failed parse's issues walks the input — and a caller must not be able to
60
+ * make production pay for, or trip on, that work.
61
+ *
62
+ * @param get - builds the diagnostic detail, called only in development
63
+ * @returns the detail in development, `undefined` in production
57
64
  * @nodocs
58
65
  */
59
- export declare const dev_only: <T>(value: T) => T | undefined;
66
+ export declare const dev_only: <T>(get: () => T) => T | undefined;
60
67
  /**
61
68
  * Named constructors for `JsonrpcErrorObject` values.
62
69
  *
@@ -1 +1 @@
1
- {"version":3,"file":"jsonrpc_errors.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/http/jsonrpc_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAEnE,OAAO,EASN,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,MAAM,cAAc,CAAC;AAEtB,0CAA0C;AAC1C,eAAO,MAAM,qBAAqB,kBAAkB,CAAC;AAErD,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GACzB,aAAa,GACb,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,gBAAgB,GAChB,iBAAiB,GACjB,WAAW,GACX,WAAW,GACX,UAAU,GACV,kBAAkB,GAClB,cAAc,GACd,qBAAqB,GACrB,SAAS,GACT,gBAAgB,GAChB,mBAAmB,CAAC;AAEvB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EA4C1B,QAAQ,CAAC,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAE3D;;;;;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eAAO,MAAM,iCAAiC,GAAI,QAAQ,MAAM,KAAG,gBACa,CAAC;AAEjF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,0BAA0B,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAMjF,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,GAAI,MAAM,gBAAgB,KAAG,gBACL,CAAC"}
@@ -79,13 +79,14 @@ export const JSONRPC_ERROR_CODES = Object.freeze({
79
79
  request_cancelled: -32010
80
80
  });
81
81
  /**
82
- * Pass `value` through in development, return `undefined` in production — so
83
- * `JSON.stringify` drops the field from the response.
82
+ * Call `get` and return its value in development, return `undefined` in
83
+ * production without calling it — so `JSON.stringify` drops the field from the
84
+ * response, and production pays nothing to build it.
84
85
  *
85
86
  * The single gate for keeping internal diagnostic detail out of production
86
87
  * error responses. Two classes flow through it:
87
88
  *
88
- * - **Zod `issues`** — the issues array exposes field names, types, and
89
+ * - **Validation `issues`** — the issues array exposes field names, types, and
89
90
  * constraints, enough to reverse-engineer an input schema (including on
90
91
  * public/unauthenticated actions). Gate the whole `data` object on JSON-RPC
91
92
  * errors (so `error.data` is absent, matching the Rust spine) and the
@@ -96,9 +97,15 @@ export const JSONRPC_ERROR_CODES = Object.freeze({
96
97
  *
97
98
  * A legitimate caller only ever needs the error code and a stable message.
98
99
  *
100
+ * A thunk rather than a value because the detail costs work to build — mapping
101
+ * a failed parse's issues walks the input — and a caller must not be able to
102
+ * make production pay for, or trip on, that work.
103
+ *
104
+ * @param get - builds the diagnostic detail, called only in development
105
+ * @returns the detail in development, `undefined` in production
99
106
  * @nodocs
100
107
  */
101
- export const dev_only = (value) => (DEV ? value : undefined);
108
+ export const dev_only = (get) => (DEV ? get() : undefined);
102
109
  /**
103
110
  * Named constructors for `JsonrpcErrorObject` values.
104
111
  *
@@ -1 +1 @@
1
- {"version":3,"file":"jsonrpc_helpers.d.ts","sourceRoot":"../src/lib/","sources":["../../src/lib/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E,eAAO,MAAM,yBAAyB,GAAI,SAAS,OAAO,KAAG,OAAO,IAAI,oBACJ,CAAC;AAIrE;;;GAGG;AACH,eAAO,MAAM,qBAAqB,GAAI,eAAe,OAAO,KAAG,gBAAgB,GAAG,IAOjF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,GAAI,OAAO,OAAO,KAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAQxE,CAAC;AAIF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,MAAM,wBAAwB,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,OAAO,EAAE,cAAc,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,MAAM,EAAE,aAAa,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,GAChE;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,QAAQ,EAAE,eAAe,GAAG,oBAAoB,CAAA;CAAE,GACtE;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,EAAE,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,wBAAwB,GAAI,MAAM,OAAO,KAAG,wBAqCxD,CAAC"}
@@ -10,6 +10,7 @@
10
10
  import { DEV } from 'esm-env';
11
11
  import { JsonrpcRequest, JSONRPC_VERSION } from './jsonrpc.js';
12
12
  import { JSONRPC_ERROR_CODES, dev_only, jsonrpc_error_messages, to_thrown_jsonrpc_error } from './jsonrpc_errors.js';
13
+ import { to_wire_issues } from '../schema_issues.js';
13
14
  // --- Message builders ---
14
15
  /** Creates a JSON-RPC request message. */
15
16
  export const create_jsonrpc_request = (method, params, id) => {
@@ -177,7 +178,7 @@ export const classify_jsonrpc_message = (json) => {
177
178
  return {
178
179
  kind: 'invalid',
179
180
  id,
180
- error: jsonrpc_error_messages.invalid_request(dev_only({ issues: parsed.error.issues }))
181
+ error: jsonrpc_error_messages.invalid_request(dev_only(() => ({ issues: to_wire_issues(parsed.error.issues, frame) })))
181
182
  };
182
183
  }
183
184
  // the frame itself, validated — not Zod's rebuilt copy, which drops an own