Skip to main content

bynk_syntax/
diagnostics.rs

1//! Central registry of diagnostic codes.
2//!
3//! This is the single source of truth for the `bynk.*` codes the compiler can
4//! emit. The reference page `site/src/content/docs/book/reference/diagnostics.md` is generated
5//! from [`render_markdown`], and the test `tests/diagnostics_registry.rs`
6//! asserts that this table matches exactly the set of codes used across the
7//! compiler source — so a new code cannot be introduced without documenting it
8//! here, and a removed code cannot linger in the docs.
9//!
10//! Each entry is a `(code, summary)` pair, optionally tagged with the grammar
11//! production(s) it constrains (`grammar_symbol`). The category shown in the
12//! generated reference is derived from the second dotted segment of the code;
13//! the grammar weave (`docs/grammar-semantics.json`, the
14//! `{{#grammar-semantics}}` directive, and the diagnostics page's Construct
15//! column) is generated from `grammar_symbol`.
16
17/// One documented diagnostic: its stable code and a one-line summary of the
18/// cause. Richer "cause and fix" material for the common diagnostics lives in
19/// the troubleshooting how-to guides.
20pub struct DiagnosticInfo {
21    pub code: &'static str,
22    pub summary: &'static str,
23    /// The grammar production(s) this diagnostic constrains, by `tree-sitter`
24    /// rule name (e.g. `http_handler`). This is the single source of the
25    /// "static semantics" weave: a grammar-reference entry embeds the
26    /// diagnostics for a rule via `{{#grammar-semantics <rule>}}`, generated
27    /// from here. Empty for diagnostics with no single governing construct
28    /// (e.g. `bynk.boundary.structural_mismatch`). Every non-empty name is
29    /// checked against the grammar by `tests/diagnostics_registry.rs`.
30    pub grammar_symbol: &'static [&'static str],
31}
32
33/// Every diagnostic code the compiler emits, sorted by code.
34pub const REGISTRY: &[DiagnosticInfo] = &[
35    d(
36        "bynk.actor.bearer_identity_not_string_constructible",
37        "A `Bearer` actor's identity is not a string-constructible type.",
38    ),
39    d(
40        "bynk.actor.bearer_missing_secret",
41        "A `Bearer` actor does not name its signing secret.",
42    ),
43    d(
44        "bynk.actor.binder_shadows_param",
45        "A `by` actor binder collides with a handler parameter of the same name.",
46    ),
47    d(
48        "bynk.actor.by_on_agent",
49        "A `by` actor clause was placed on an agent `on call` handler, which has no actor.",
50    ),
51    d(
52        "bynk.actor.duplicate_sum_scheme",
53        "Two peers in a multi-actor sum share an authentication scheme.",
54    ),
55    d(
56        "bynk.actor.identity_not_sealed",
57        "An actor identity type is not a context-ownable (sealed) value type.",
58    ),
59    d(
60        "bynk.actor.missing_by_on_http",
61        "An HTTP handler lacks the required `by` actor clause.",
62    ),
63    d(
64        "bynk.actor.oidc_identity_not_string_constructible",
65        "An `Oidc` actor's identity is not a string-constructible type.",
66    ),
67    d(
68        "bynk.actor.oidc_missing_audience",
69        "An `Oidc` actor does not name its `audience`.",
70    ),
71    d(
72        "bynk.actor.oidc_missing_issuer",
73        "An `Oidc` actor does not name its `issuer`.",
74    ),
75    d(
76        "bynk.actor.oidc_missing_jwks",
77        "An `Oidc` actor does not name its `jwks` endpoint.",
78    ),
79    d(
80        "bynk.actor.oidc_not_in_sum",
81        "An `Oidc` actor appears as a member of a multi-actor sum.",
82    ),
83    d(
84        "bynk.actor.outside_context",
85        "An `actor` was declared outside a context (e.g. in a commons).",
86    ),
87    d(
88        "bynk.actor.refinement_base_unsupported",
89        "A refinement actor's base is not a `Bearer` actor (no claims to authorise against).",
90    ),
91    d(
92        "bynk.actor.refinement_in_sum",
93        "A refinement actor appears as a member of a multi-actor sum.",
94    ),
95    d(
96        "bynk.actor.refinement_predicate_unsupported",
97        "A refinement actor's `where` predicate is outside the closed claim-predicate set.",
98    ),
99    d(
100        "bynk.actor.scheme_not_admissible",
101        "An actor's scheme is not admissible on this handler's protocol.",
102    ),
103    d(
104        "bynk.actor.signature_identity_unsupported",
105        "A `Signature` actor declared an `identity`, which is not yet supported.",
106    ),
107    d(
108        "bynk.actor.signature_missing_header",
109        "A `Signature` actor does not name its signature header.",
110    ),
111    d(
112        "bynk.actor.signature_missing_secret",
113        "A `Signature` actor does not name its signing secret.",
114    ),
115    d(
116        "bynk.actor.signature_requires_body",
117        "A `Signature` handler does not take a `body` parameter.",
118    ),
119    d(
120        "bynk.actor.signature_tolerance_without_timestamp",
121        "A `Signature` actor set `tolerance` without a `timestamp` header.",
122    ),
123    d(
124        "bynk.actor.sum_requires_binder",
125        "A multi-actor sum `by` clause has no binder to match the resolved actor.",
126    ),
127    d(
128        "bynk.actor.unknown_actor",
129        "A handler's `by` clause names an actor that is not declared.",
130    ),
131    d(
132        "bynk.actor.unknown_scheme",
133        "An actor declares an authentication scheme that is not compiler-known.",
134    ),
135    d(
136        "bynk.actor.unreachable_sum_arm",
137        "A multi-actor sum has an arm unreachable after a catch-all (`None`) peer.",
138    ),
139    dg(
140        "bynk.adapter.consumes_context",
141        "An `adapter` consumed a context; adapter dependencies are adapter-to-adapter.",
142        &["consumes_decl"],
143    ),
144    dg(
145        "bynk.adapter.consumes_requires_selection",
146        "An `adapter` used a whole-unit or aliased `consumes`; adapters must select capabilities with `consumes U { Cap, … }`.",
147        &["consumes_decl"],
148    ),
149    dg(
150        "bynk.adapter.disallowed_item",
151        "An `adapter` declared a `service`, `agent`, or other item it may not contain.",
152        &["adapter_decl"],
153    ),
154    dg(
155        "bynk.adapter.duplicate_binding",
156        "An `adapter` declared more than one `binding` clause.",
157        &["binding_decl"],
158    ),
159    dg(
160        "bynk.adapter.no_binding",
161        "An `adapter` declares an external provider but no `binding` module to supply it.",
162        &["adapter_decl"],
163    ),
164    dg(
165        "bynk.adapter.provider_has_body",
166        "A provider inside an `adapter` has a Bynk body; adapter providers must be external.",
167        &["provider_decl"],
168    ),
169    dg(
170        "bynk.agent.construction_arity",
171        "An agent was constructed with the wrong number of key arguments.",
172        &["agent_decl"],
173    ),
174    dg(
175        "bynk.agent.handler_arity",
176        "An agent handler was called with the wrong number of arguments.",
177        &["agent_decl"],
178    ),
179    dg(
180        "bynk.agent.handler_not_found",
181        "Called a handler the agent does not declare.",
182        &["agent_decl"],
183    ),
184    dg(
185        "bynk.agent.key_mismatch",
186        "An agent key argument has the wrong type.",
187        &["agent_decl"],
188    ),
189    dg(
190        "bynk.agent.outside_context",
191        "An `agent` was declared outside a context.",
192        &["agent_decl"],
193    ),
194    dg(
195        "bynk.agent.return_not_effect",
196        "An agent handler's return type is not an `Effect`.",
197        &["agent_decl"],
198    ),
199    dg(
200        "bynk.agents.bad_state_initialiser",
201        "An agent `store` field initialiser is not a static value of the field's type.",
202        &["store_field"],
203    ),
204    dg(
205        "bynk.agents.non_zeroable_state_field",
206        "An agent `store` field has no initialiser and no implicit zero value.",
207        &["store_field"],
208    ),
209    d(
210        "bynk.boundary.structural_mismatch",
211        "Data crossing a context boundary did not match the expected shape.",
212    ),
213    dg(
214        "bynk.capability.op_arity",
215        "A capability operation was called with the wrong number of arguments.",
216        &["capability_decl"],
217    ),
218    dg(
219        "bynk.capability.outside_context",
220        "A `capability` was declared outside a context.",
221        &["capability_decl"],
222    ),
223    dg(
224        "bynk.capability.unknown_operation",
225        "Referenced an operation the capability does not declare.",
226        &["capability_decl"],
227    ),
228    d(
229        "bynk.cell.invalid_target",
230        "A `:=` write targets something that is not a `store Cell` field.",
231    ),
232    d(
233        "bynk.cell.self_reference",
234        "A `:=` right-hand side reads the cell being written (a read-modify-write); use `.update`.",
235    ),
236    dg(
237        "bynk.consumes.alias_conflict",
238        "Two `consumes` aliases collide.",
239        &["consumes_decl"],
240    ),
241    dg(
242        "bynk.consumes.capability_name_clash",
243        "Two flattened `consumes U { Cap }` capabilities collide, or one clashes with a local capability.",
244        &["consumes_decl"],
245    ),
246    dg(
247        "bynk.consumes.in_commons",
248        "`consumes` appears in a `commons` (it is only valid in a context).",
249        &["consumes_decl"],
250    ),
251    dg(
252        "bynk.consumes.name_conflict",
253        "A `consumes` name collides with another name in scope.",
254        &["consumes_decl"],
255    ),
256    dg(
257        "bynk.consumes.self_reference",
258        "A context `consumes` itself.",
259        &["consumes_decl"],
260    ),
261    dg(
262        "bynk.consumes.service_arity",
263        "A consumed service was called with the wrong number of arguments.",
264        &["consumes_decl"],
265    ),
266    dg(
267        "bynk.consumes.target_is_commons",
268        "`consumes` targets a `commons` instead of a context.",
269        &["consumes_decl"],
270    ),
271    dg(
272        "bynk.consumes.unknown_context",
273        "`consumes` names a context that does not exist.",
274        &["consumes_decl"],
275    ),
276    dg(
277        "bynk.consumes.unknown_service",
278        "Called a service the consumed context does not declare.",
279        &["consumes_decl"],
280    ),
281    d(
282        "bynk.context.consumes_cycle",
283        "Contexts form a `consumes` dependency cycle.",
284    ),
285    d(
286        "bynk.context.external_construction",
287        "A context-owned type was constructed from outside that context.",
288    ),
289    dg(
290        "bynk.context.external_provider",
291        "A bodiless (external) provider was declared outside an `adapter`.",
292        &["provider_decl"],
293    ),
294    d(
295        "bynk.context.opaque_inspection",
296        "An opaquely-exported type was inspected from outside its context.",
297    ),
298    d(
299        "bynk.contract.duplicate_name",
300        "A function declares two contract clauses (`requires`/`ensures`) with the same name.",
301    ),
302    d(
303        "bynk.contract.impure_predicate",
304        "A contract predicate uses an effectful or test-only construct; a contract clause must be pure.",
305    ),
306    d(
307        "bynk.contract.not_bool",
308        "A contract predicate does not have type `Bool`.",
309    ),
310    d(
311        "bynk.contract.restated_by_test",
312        "A `case`/`property` merely restates a contract clause already declared at the function; the test is redundant.",
313    ),
314    d(
315        "bynk.contract.result_in_requires",
316        "A precondition (`requires`) references `result`; the return value is only in scope inside an `ensures`.",
317    ),
318    dg(
319        "bynk.cron.bad_params",
320        "A cron handler declares more than one parameter, or a non-`Int` one.",
321        &["cron_handler"],
322    ),
323    dg(
324        "bynk.cron.duplicate_schedule",
325        "Two cron handlers declare the same schedule.",
326        &["cron_handler"],
327    ),
328    dg(
329        "bynk.cron.invalid_schedule",
330        "A cron expression is not five whitespace-separated fields.",
331        &["cron_handler"],
332    ),
333    dg(
334        "bynk.cron.return_not_effect_result",
335        "A cron handler does not return `Effect[Result[(), E]]`.",
336        &["cron_handler"],
337    ),
338    d(
339        "bynk.duration.literal_overflow",
340        "A `Duration` literal (`<int>.<unit>`) exceeds the representable millisecond range.",
341    ),
342    dg(
343        "bynk.effect.bind_in_pure_context",
344        "An `<-` bind was used in a pure (non-effectful) context.",
345        &["effect_let_stmt"],
346    ),
347    dg(
348        "bynk.effect.bind_on_non_effect",
349        "An `<-` bind was applied to a non-`Effect` value.",
350        &["effect_let_stmt"],
351    ),
352    d(
353        "bynk.effect.capability_in_pure_context",
354        "A capability was used in a pure context.",
355    ),
356    d(
357        "bynk.effect.cross_context_in_pure_context",
358        "A cross-context call was made in a pure context.",
359    ),
360    dg(
361        "bynk.effect.do_in_pure_context",
362        "A `do` statement was used in a pure (non-effectful) context.",
363        &["do_stmt"],
364    ),
365    dg(
366        "bynk.effect.do_on_non_effect",
367        "A `do` statement was applied to a non-`Effect` value.",
368        &["do_stmt"],
369    ),
370    dg(
371        "bynk.effect.do_requires_unit",
372        "A `do` statement was applied to a valued `Effect[T]`; `do` performs a unit effect, so a real result would be dropped — use `let _ <- e` instead.",
373        &["do_stmt"],
374    ),
375    dg(
376        "bynk.effect.fn_value_in_pure_context",
377        "An effectful function value was called in a pure context; like a capability call, it is legal only where the enclosing body is effectful.",
378        &["call"],
379    ),
380    dg(
381        "bynk.expect.not_bool",
382        "`expect` was given a non-`Bool` predicate.",
383        &["expect_expr"],
384    ),
385    dg(
386        "bynk.expect.outside_case",
387        "`expect` was used outside a `case` body.",
388        &["expect_expr"],
389    ),
390    dg(
391        "bynk.exports.capability_not_provided",
392        "An exported capability has no provider in its context.",
393        &["exports_decl"],
394    ),
395    dg(
396        "bynk.exports.conflicting_visibility",
397        "A type is exported with conflicting visibilities.",
398        &["exports_decl"],
399    ),
400    dg(
401        "bynk.exports.duplicate_export",
402        "The same name is exported more than once.",
403        &["exports_decl"],
404    ),
405    dg(
406        "bynk.exports.duplicate_in_clause",
407        "A name appears twice in one `exports` clause.",
408        &["exports_decl"],
409    ),
410    dg(
411        "bynk.exports.undeclared_capability",
412        "`exports capability` names a capability that is not declared.",
413        &["exports_decl"],
414    ),
415    dg(
416        "bynk.exports.undeclared_type",
417        "`exports` names a type that is not declared.",
418        &["exports_decl"],
419    ),
420    dg(
421        "bynk.generics.duplicate_type_param",
422        "A `type` or `fn` declares the same type-parameter name more than once (v0.157, ADR 0183).",
423        &[],
424    ),
425    dg(
426        "bynk.generics.generic_non_record",
427        "A `type` declaration carries type parameters on a non-record body; only a record body (`type Name[T] = { … }`) may be generic (v0.157, ADR 0183).",
428        &["type_decl"],
429    ),
430    dg(
431        "bynk.generics.generic_record_at_boundary",
432        "A `Val[…]` fabricates a value of a generic type; per-instantiation value fabrication is not yet wired (ADR 0197). Since v0.174 a generic-record instantiation may otherwise cross a boundary through its monomorphised codec.",
433        &[],
434    ),
435    dg(
436        "bynk.generics.method_on_generic_type",
437        "A method is attached to a generic type; methods on generic types (generic methods) are not in v0.157 (ADR 0183).",
438        &["fn_decl"],
439    ),
440    dg(
441        "bynk.generics.no_bounds",
442        "A type parameter carries a bound (`[A: …]`); bounded generics are not in v0.20a.",
443        &["fn_decl"],
444    ),
445    dg(
446        "bynk.generics.recursive_generic_at_boundary",
447        "A recursive generic record (one that transitively contains itself, through any wrapper or generic argument) appears at a boundary; it has no finite set of monomorphised codecs, so it is not yet boundary-serialisable (ADR 0197).",
448        &[],
449    ),
450    dg(
451        "bynk.generics.type_arg_count",
452        "A user-declared generic type is applied to the wrong number of type arguments, or a generic type is named without its `[…]` arguments (v0.157, ADR 0183).",
453        &["applied_type_ref"],
454    ),
455    dg(
456        "bynk.generics.type_arg_mismatch",
457        "Inferred or explicit type arguments conflict, have the wrong arity, target a non-generic function, or a type parameter shadows a declared type.",
458        &["call"],
459    ),
460    dg(
461        "bynk.generics.uninferable_type_arg",
462        "A generic function's type parameter could not be inferred from the arguments and was not given explicitly (`name[T](…)`); a bare generic function also cannot be passed as a value in v0.20a.",
463        &["call"],
464    ),
465    dg(
466        "bynk.given.cross_context_unknown_capability",
467        "`given B.Cap` names a capability the consumed context does not export.",
468        &["given_clause"],
469    ),
470    dg(
471        "bynk.given.undeclared_capability",
472        "A handler uses a capability it did not declare with `given`.",
473        &["given_clause"],
474    ),
475    dg(
476        "bynk.given.unknown_capability",
477        "`given` names a capability that does not exist.",
478        &["given_clause"],
479    ),
480    dg(
481        "bynk.given.unused_capability",
482        "A `given` capability is never used (warning).",
483        &["given_clause"],
484    ),
485    d(
486        "bynk.held.branch_divergence",
487        "Branches of a conditional leave a held value (e.g. `Connection[F]`) in inconsistent ownership states — one consumes or stores it, another leaves it owned (§2.9.5, real-time track slice 2).",
488    ),
489    d(
490        "bynk.held.consume_on_borrow",
491        "A consuming operation (`close`/`put`/`take`) is called on a *borrowed* held reference — borrows admit only non-consuming operations like `send` (§2.9.3, real-time track slice 2).",
492    ),
493    d(
494        "bynk.held.leak",
495        "A held value (`Connection[F]`) is still owned at scope exit — it must be disposed (stored, closed, or transferred) before the handler or function returns (§2.9.1, real-time track slice 2).",
496    ),
497    d(
498        "bynk.held.query_accessor_on_held_map",
499        "A key-aware query accessor (`.entries`/`.keys`/`.values`) is used on a held `Map[K, Connection]` — a held resource is iterated with the broadcast ops (`forEach`/`parTraverse`), not a key query.",
500    ),
501    d(
502        "bynk.held.unsupported_map_op",
503        "A held `Map[K, Connection]` is given an `update`/`upsert` — a held resource cannot be transformed by a `(Connection) -> Connection` function; use `put`/`get`/`remove` (real-time track slice 3b-ii).",
504    ),
505    d(
506        "bynk.held.unsupported_storage",
507        "A held value (`Connection[F]`) is stored in a `Set`/`Log`/`Cache` — held values may only live in `Cell[Option[Connection]]` or `Map[K, Connection]` (§2.9.3, real-time track slice 2).",
508    ),
509    d(
510        "bynk.held.use_after_consume",
511        "A held value (`Connection[F]`) is used after a consuming operation (`close`/`put`/`take`) ended its lifetime (§2.9.2, real-time track slice 2).",
512    ),
513    d(
514        "bynk.history.not_an_agent",
515        "A `for all run: History[T]` names a `T` that is not an agent — only an agent has handlers to sequence and reachable states to observe (testing track slice 7, ADR 0155).",
516    ),
517    d(
518        "bynk.history.not_generable",
519        "A `for all run: History[Agent]` targets an agent with a handler parameter whose type cannot be generated (e.g. a `Matches` refinement), so its call-history cannot be driven (testing track slice 7, ADR 0155).",
520    ),
521    d(
522        "bynk.history.outside_property",
523        "`History[Agent]` appears outside a `property`'s `for all` binding — it is a test-only generator, not a value type (testing track slice 7, ADR 0155).",
524    ),
525    d(
526        "bynk.history.restates_invariant",
527        "A history property merely re-checks a guarantee a declared `invariant`/`transition` already enforces on every reached state (testing track slice 7, ADR 0155).",
528    ),
529    dg(
530        "bynk.http.body_on_get_or_delete",
531        "A GET or DELETE handler declares a `body` parameter.",
532        &["http_handler"],
533    ),
534    d(
535        "bynk.http.cache_bad_max_age",
536        "A `@cache` annotation's `maxAge` is missing or not a positive `Duration` literal.",
537    ),
538    d(
539        "bynk.http.cache_bad_scope",
540        "A `@cache` annotation's `scope` is not `public` or `private`.",
541    ),
542    d(
543        "bynk.http.cache_duplicate",
544        "A handler carries more than one `@cache` annotation.",
545    ),
546    d(
547        "bynk.http.cache_on_non_get",
548        "A `@cache` annotation is placed on a handler that is not `on http GET`.",
549    ),
550    d(
551        "bynk.http.cache_unknown_arg",
552        "A `@cache` annotation has an argument outside the closed set (`maxAge`/`scope`).",
553    ),
554    d(
555        "bynk.http.cors_invalid_field",
556        "A `cors` policy field (`headers`/`credentials`/`maxAge`) has the wrong value shape.",
557    ),
558    d(
559        "bynk.http.cors_invalid_origins",
560        "A `cors` policy's `origins` is missing, empty, or not a list of string literals.",
561    ),
562    d(
563        "bynk.http.cors_not_http",
564        "A `cors { }` policy appears on a service that is not `from http`.",
565    ),
566    d(
567        "bynk.http.cors_unknown_field",
568        "A `cors { }` policy declares a field outside the closed set.",
569    ),
570    d(
571        "bynk.http.cors_wildcard_credentials",
572        "A `cors` policy combines `credentials: true` with the wildcard origin `[\"*\"]`.",
573    ),
574    dg(
575        "bynk.http.duplicate_route",
576        "Two handlers share the same method and route.",
577        &["http_handler"],
578    ),
579    dg(
580        "bynk.http.extra_param",
581        "A handler parameter is neither a path parameter nor `body`.",
582        &["http_handler"],
583    ),
584    dg(
585        "bynk.http.invalid_path",
586        "An HTTP route path is malformed.",
587        &["http_handler"],
588    ),
589    d(
590        "bynk.http.limit_bad_max_body",
591        "A `@limit` annotation's `maxBody` is missing or not a positive `Int` literal.",
592    ),
593    d(
594        "bynk.http.limit_duplicate",
595        "A handler carries more than one `@limit` annotation.",
596    ),
597    d(
598        "bynk.http.limit_on_bodyless",
599        "A `@limit` annotation is placed on a handler that takes no body (a GET or DELETE).",
600    ),
601    d(
602        "bynk.http.limit_unknown_arg",
603        "A `@limit` annotation has an argument outside the closed set (`maxBody`).",
604    ),
605    d(
606        "bynk.http.limits_invalid_field",
607        "A `limits` policy field (`maxBody`) has the wrong value shape.",
608    ),
609    d(
610        "bynk.http.limits_not_http",
611        "A `limits { }` policy appears on a service that is not `from http`.",
612    ),
613    d(
614        "bynk.http.limits_unknown_field",
615        "A `limits { }` policy declares a field outside the closed set.",
616    ),
617    dg(
618        "bynk.http.path_param_not_stringy",
619        "A path parameter's type is not constructible from a string.",
620        &["http_handler"],
621    ),
622    dg(
623        "bynk.http.reserved_prefix",
624        "A route uses the reserved `/_bynk/` prefix.",
625        &["http_handler"],
626    ),
627    dg(
628        "bynk.http.return_not_effect_http_result",
629        "An HTTP handler does not return `Effect[HttpResult[T]]`.",
630        &["http_handler"],
631    ),
632    d(
633        "bynk.http.security_invalid_field",
634        "A `security` policy field (`hsts`/`nosniff`) has the wrong value shape.",
635    ),
636    d(
637        "bynk.http.security_not_http",
638        "A `security { }` policy appears on a service that is not `from http`.",
639    ),
640    d(
641        "bynk.http.security_unknown_field",
642        "A `security { }` policy declares a field outside the closed set.",
643    ),
644    dg(
645        "bynk.http.unbound_path_param",
646        "A `:name` route segment has no matching handler parameter.",
647        &["http_handler"],
648    ),
649    d(
650        "bynk.http.unknown_handler_annotation",
651        "A handler carries an annotation outside the closed set (`@cache`/`@limit`).",
652    ),
653    d(
654        "bynk.index.bad_argument",
655        "An `@indexed` argument is not a `by: <field>` label.",
656    ),
657    d(
658        "bynk.index.missing",
659        "A query filters a map by equality on a field that is not `@indexed` (a perf-hint warning).",
660    ),
661    d(
662        "bynk.index.unkeyable_key",
663        "An `@indexed(by: k)` field is not value-keyable.",
664    ),
665    d(
666        "bynk.index.unknown_key",
667        "An `@indexed(by: k)` field is not a field of the map's value type.",
668    ),
669    d(
670        "bynk.index.unused",
671        "A declared `@indexed(by: k)` is never used by an equality filter (a hygiene warning).",
672    ),
673    d(
674        "bynk.invariant.cross_agent_reference",
675        "An invariant predicate references another agent; invariants are per-agent.",
676    ),
677    d(
678        "bynk.invariant.duplicate_name",
679        "An agent declares two invariants with the same name.",
680    ),
681    d(
682        "bynk.invariant.impure_predicate",
683        "An invariant predicate uses an effectful or test-only construct.",
684    ),
685    d(
686        "bynk.invariant.not_bool",
687        "An invariant predicate does not have type `Bool`.",
688    ),
689    dg(
690        "bynk.lambda.unannotated_param",
691        "A lambda parameter has no type annotation in a position where no function type is expected to infer it from.",
692        &["lambda_expr"],
693    ),
694    dg(
695        "bynk.lex.bad_escape",
696        "An invalid escape sequence in a string literal.",
697        &["string_literal"],
698    ),
699    dg(
700        "bynk.lex.float_literal_overflow",
701        "A float literal does not fit a finite 64-bit float.",
702        &["float_literal"],
703    ),
704    dg(
705        "bynk.lex.integer_overflow",
706        "An integer literal is out of range.",
707        &["number_literal"],
708    ),
709    dg(
710        "bynk.lex.interpolation_too_deep",
711        "A string interpolation `\\(…)` nests deeper than the lexer's fixed limit.",
712        &["string_literal"],
713    ),
714    d(
715        "bynk.lex.unclosed_doc_block",
716        "A documentation block is not closed.",
717    ),
718    d(
719        "bynk.lex.unexpected_character",
720        "An unexpected character in the source.",
721    ),
722    dg(
723        "bynk.lex.unterminated_interpolation",
724        "An interpolation hole `\\(…)` is not closed on its line.",
725        &["string_literal"],
726    ),
727    dg(
728        "bynk.lex.unterminated_string",
729        "A string literal is not terminated.",
730        &["string_literal"],
731    ),
732    d(
733        "bynk.list.deprecated_function",
734        "A `bynk.list` free function (`map`/`filter`/`find`/`any`/`all`) is deprecated in favour of the `List` method form (warning; auto-fixable).",
735    ),
736    d(
737        "bynk.namespace.reserved",
738        "A user unit is named `bynk` or `bynk.*`; the `bynk` root is reserved for the toolchain.",
739    ),
740    d(
741        "bynk.observe.bad_count",
742        "An observation call count is not a non-negative integer literal (`called once` / `called <n> times`).",
743    ),
744    d(
745        "bynk.observe.impure_with",
746        "A `with` predicate uses an effectful or test-only construct; it must be pure.",
747    ),
748    d(
749        "bynk.observe.not_a_seam",
750        "An observation targets a capability the unit under test does not consume.",
751    ),
752    d(
753        "bynk.observe.outside_case",
754        "An observation appears outside a `case` body.",
755    ),
756    d(
757        "bynk.observe.trace_outside_test",
758        "`trace(Cap.op)` appears outside a `case` body.",
759    ),
760    d(
761        "bynk.observe.unknown_op",
762        "An observation names an operation the capability does not declare.",
763    ),
764    d(
765        "bynk.observe.with_not_bool",
766        "A `with` predicate does not have type `Bool`.",
767    ),
768    dg(
769        "bynk.parse.consumes_after_decls",
770        "`consumes` appears after other declarations.",
771        &["consumes_decl"],
772    ),
773    d(
774        "bynk.parse.dangling_handler_annotation",
775        "A handler-position annotation (e.g. `@cache`) is not followed by an `on` handler.",
776    ),
777    dg(
778        "bynk.parse.duplicate_cors",
779        "A service declares more than one `cors { }` policy.",
780        &["service_decl"],
781    ),
782    dg(
783        "bynk.parse.duplicate_limits",
784        "A service declares more than one `limits { }` policy.",
785        &["service_decl"],
786    ),
787    dg(
788        "bynk.parse.duplicate_security",
789        "A service declares more than one `security { }` policy.",
790        &["service_decl"],
791    ),
792    dg(
793        "bynk.parse.empty_agent",
794        "An `agent` body is empty.",
795        &["agent_decl"],
796    ),
797    dg(
798        "bynk.parse.empty_capability",
799        "A `capability` body is empty.",
800        &["capability_decl"],
801    ),
802    d(
803        "bynk.parse.empty_interpolation",
804        "An interpolation hole `\\(…)` contains no expression.",
805    ),
806    dg(
807        "bynk.parse.empty_match",
808        "A `match` has no arms.",
809        &["match_expr"],
810    ),
811    dg(
812        "bynk.parse.empty_service",
813        "A `service` body is empty.",
814        &["service_decl"],
815    ),
816    dg(
817        "bynk.parse.expected_agent_key",
818        "Expected a `key` declaration in an agent.",
819        &["agent_decl"],
820    ),
821    d(
822        "bynk.parse.expected_agent_storage",
823        "An agent declares no storage — it has no `store` fields.",
824    ),
825    dg(
826        "bynk.parse.expected_base_type",
827        "Expected a base type.",
828        &["base_type"],
829    ),
830    dg(
831        "bynk.parse.expected_capability_op",
832        "Expected a capability operation.",
833        &["capability_op"],
834    ),
835    d("bynk.parse.expected_expression", "Expected an expression."),
836    dg(
837        "bynk.parse.expected_handler",
838        "Expected a handler.",
839        &["handler"],
840    ),
841    d("bynk.parse.expected_item", "Expected a declaration."),
842    dg(
843        "bynk.parse.expected_predicate",
844        "Expected a refinement predicate.",
845        &["refinement"],
846    ),
847    dg(
848        "bynk.parse.expected_provider_op",
849        "Expected a provider operation.",
850        &["provider_op"],
851    ),
852    d("bynk.parse.expected_token", "Expected a specific token."),
853    d("bynk.parse.expected_type", "Expected a type."),
854    d(
855        "bynk.parse.expected_unit_header",
856        "Expected a `commons` or `context` header.",
857    ),
858    dg(
859        "bynk.parse.expected_visibility",
860        "Expected a visibility keyword.",
861        &["exports_decl"],
862    ),
863    dg(
864        "bynk.parse.exports_after_decls",
865        "`exports` appears after other declarations.",
866        &["exports_decl"],
867    ),
868    d(
869        "bynk.parse.extra_tokens",
870        "Unexpected tokens after an otherwise complete construct.",
871    ),
872    dg(
873        "bynk.parse.generic_arg_count",
874        "Wrong number of generic type arguments.",
875        &["generic_type_ref"],
876    ),
877    dg(
878        "bynk.parse.handler_in_agent",
879        "A protocol handler (`on GET`/`schedule`/`message`) was declared in an agent.",
880        &["handler"],
881    ),
882    d(
883        "bynk.parse.invariant_after_handler",
884        "An `invariant` was declared after a handler; invariants precede handlers.",
885    ),
886    dg(
887        "bynk.parse.malformed_float_literal",
888        "A float literal is missing a digit on one side of the `.` (`1.`, `.5`).",
889        &["float_literal"],
890    ),
891    d(
892        "bynk.parse.nesting_too_deep",
893        "An expression or type nests deeper than the parser's fixed limit.",
894    ),
895    dg(
896        "bynk.parse.non_associative",
897        "A non-associative operator was chained (e.g. `a == b == c`).",
898        &["binary_expr"],
899    ),
900    d(
901        "bynk.parse.orphan_doc_block",
902        "A documentation block is not attached to a declaration (warning).",
903    ),
904    dg(
905        "bynk.parse.reserved_keyword",
906        "A reserved keyword was used as an identifier.",
907        &["identifier"],
908    ),
909    dg(
910        "bynk.parse.self_outside_method",
911        "`self` used outside a method or handler.",
912        &["self_expr"],
913    ),
914    d(
915        "bynk.parse.storage_after_phase",
916        "Agent storage (`state` / `store`) is declared after the invariants or handlers.",
917    ),
918    d(
919        "bynk.parse.transition_after_handler",
920        "A `transition` is declared after an agent handler; step invariants precede the handlers.",
921    ),
922    d(
923        "bynk.parse.unexpected_adapter",
924        "An `adapter` appeared where it is not allowed.",
925    ),
926    dg(
927        "bynk.parse.unexpected_context",
928        "A `context` appeared where it is not allowed.",
929        &["context_decl"],
930    ),
931    d("bynk.parse.unexpected_eof", "Unexpected end of input."),
932    dg(
933        "bynk.parse.unexpected_suite",
934        "A `suite` appeared where it is not allowed.",
935        &["suite_decl"],
936    ),
937    d(
938        "bynk.parse.unknown_effect_method",
939        "An unknown method on `Effect`.",
940    ),
941    dg(
942        "bynk.parse.unknown_handler_kind",
943        "An unknown handler form (expected `call`, an HTTP method, `schedule`, or `message`).",
944        &["handler"],
945    ),
946    dg(
947        "bynk.parse.unknown_predicate",
948        "An unknown refinement predicate.",
949        &["predicate_name"],
950    ),
951    d(
952        "bynk.parse.unknown_tier",
953        "A `case`/`suite` `as <tier>` clause names something other than `unit`, `integration`, or `system`.",
954    ),
955    dg(
956        "bynk.parse.uses_after_decls",
957        "`uses` appears after other declarations.",
958        &["uses_decl"],
959    ),
960    dg(
961        "bynk.parse.variant_name_case",
962        "A sum-type or enum variant name is not capitalised.",
963        &["sum_variant", "enum_type"],
964    ),
965    d(
966        "bynk.project.file_and_directory",
967        "A unit exists as both a file and a directory.",
968    ),
969    d(
970        "bynk.project.inconsistent_commons_name",
971        "A source file's path does not match its declared name.",
972    ),
973    d(
974        "bynk.project.kind_conflict",
975        "A name is declared as both a commons and a context.",
976    ),
977    d(
978        "bynk.project.no_root",
979        "No project root could be determined.",
980    ),
981    d(
982        "bynk.project.no_sources",
983        "The project contains no source files.",
984    ),
985    d(
986        "bynk.project.read_failed",
987        "A source file could not be read.",
988    ),
989    dg(
990        "bynk.property.restates_refinement",
991        "A `property` merely re-checks a refinement its type already guarantees.",
992        &["for_all"],
993    ),
994    dg(
995        "bynk.property.where_not_bool",
996        "A `for all ... where` filter does not type to `Bool`.",
997        &["for_all"],
998    ),
999    dg(
1000        "bynk.provider.dependency_cycle",
1001        "Providers form a capability dependency cycle through `given`.",
1002        &["provider_decl"],
1003    ),
1004    dg(
1005        "bynk.provider.extra_operation",
1006        "A `provides` block implements an operation not in the capability.",
1007        &["provider_decl"],
1008    ),
1009    dg(
1010        "bynk.provider.missing_operation",
1011        "A `provides` block is missing a capability operation.",
1012        &["provider_decl"],
1013    ),
1014    dg(
1015        "bynk.provider.outside_context",
1016        "`provides` was declared outside a context.",
1017        &["provider_decl"],
1018    ),
1019    dg(
1020        "bynk.provider.signature_mismatch",
1021        "A `provides` operation's signature does not match the capability.",
1022        &["provider_decl"],
1023    ),
1024    dg(
1025        "bynk.provider.unknown_capability",
1026        "`provides` names a capability that does not exist.",
1027        &["provider_decl"],
1028    ),
1029    d(
1030        "bynk.query.join_key_mismatch",
1031        "A `joinOn`/`leftJoin` left and right key function return different types.",
1032    ),
1033    dg(
1034        "bynk.query.sum_needs_numeric",
1035        "A `sum`/`average` key function does not return a numeric type (`Int`, `Float`, or `Duration`).",
1036        &[],
1037    ),
1038    dg(
1039        "bynk.queue.bad_params",
1040        "An `on message` handler does not take exactly one `message` parameter.",
1041        &["queue_handler"],
1042    ),
1043    dg(
1044        "bynk.queue.duplicate_consumer",
1045        "Two `on message` handlers consume the same queue.",
1046        &["queue_handler"],
1047    ),
1048    dg(
1049        "bynk.queue.invalid_name",
1050        "A `from queue(\"…\")` binding has an empty queue name.",
1051        &["queue_handler"],
1052    ),
1053    dg(
1054        "bynk.queue.return_not_queue_result",
1055        "An `on message` handler does not return `Effect[QueueResult]`.",
1056        &["handler"],
1057    ),
1058    dg(
1059        "bynk.record_spread.field_type_mismatch",
1060        "A record-spread override has the wrong type for the field.",
1061        &["record_spread"],
1062    ),
1063    dg(
1064        "bynk.record_spread.non_record_base",
1065        "The base of a record spread is not a record.",
1066        &["record_spread"],
1067    ),
1068    dg(
1069        "bynk.record_spread.type_mismatch",
1070        "A record spread's base is a different record type.",
1071        &["record_spread"],
1072    ),
1073    dg(
1074        "bynk.record_spread.unknown_field",
1075        "A record spread overrides a field the record does not have.",
1076        &["record_spread"],
1077    ),
1078    dg(
1079        "bynk.refine.literal_violates",
1080        "A literal does not satisfy the refined type's predicate.",
1081        &["refined_type"],
1082    ),
1083    dg(
1084        "bynk.requires.unpinned_dependency",
1085        "An adapter `binding … requires { … }` entry has an unpinned version range.",
1086        &["binding_decl"],
1087    ),
1088    d(
1089        "bynk.resolve.ambiguous_variant",
1090        "A variant name is ambiguous across several sum types.",
1091    ),
1092    dg(
1093        "bynk.resolve.arity_mismatch",
1094        "A function was called with the wrong number of arguments.",
1095        &["call"],
1096    ),
1097    d("bynk.resolve.duplicate_actor", "Two actors share a name."),
1098    dg(
1099        "bynk.resolve.duplicate_agent",
1100        "Two agents share a name.",
1101        &["agent_decl"],
1102    ),
1103    dg(
1104        "bynk.resolve.duplicate_capability",
1105        "Two capabilities share a name.",
1106        &["capability_decl"],
1107    ),
1108    dg(
1109        "bynk.resolve.duplicate_field",
1110        "A record declares a field twice.",
1111        &["record_type"],
1112    ),
1113    dg(
1114        "bynk.resolve.duplicate_field_init",
1115        "A record construction initialises a field twice.",
1116        &["record_construction"],
1117    ),
1118    dg(
1119        "bynk.resolve.duplicate_fn",
1120        "Two functions share a name.",
1121        &["fn_decl"],
1122    ),
1123    dg(
1124        "bynk.resolve.duplicate_method",
1125        "Two methods share a name.",
1126        &["fn_decl"],
1127    ),
1128    dg(
1129        "bynk.resolve.duplicate_param",
1130        "A parameter name is repeated.",
1131        &["param"],
1132    ),
1133    dg(
1134        "bynk.resolve.duplicate_provider",
1135        "A capability is provided more than once.",
1136        &["provider_decl"],
1137    ),
1138    dg(
1139        "bynk.resolve.duplicate_service",
1140        "Two services share a name.",
1141        &["service_decl"],
1142    ),
1143    dg(
1144        "bynk.resolve.duplicate_type",
1145        "Two types share a name.",
1146        &["type_decl"],
1147    ),
1148    dg(
1149        "bynk.resolve.duplicate_variant",
1150        "A sum type declares a variant twice.",
1151        &["sum_type"],
1152    ),
1153    d(
1154        "bynk.resolve.fn_without_call",
1155        "A function was referenced without being called.",
1156    ),
1157    dg(
1158        "bynk.resolve.let_shadows_fn",
1159        "A `let` binding shadows a function.",
1160        &["let_stmt"],
1161    ),
1162    dg(
1163        "bynk.resolve.let_shadows_type",
1164        "A `let` binding shadows a type.",
1165        &["let_stmt"],
1166    ),
1167    d(
1168        "bynk.resolve.method_unknown_type",
1169        "A method is defined on an unknown type.",
1170    ),
1171    dg(
1172        "bynk.resolve.missing_field",
1173        "A record construction omits a required field.",
1174        &["record_construction"],
1175    ),
1176    d(
1177        "bynk.resolve.name_conflict",
1178        "Two declarations share a name.",
1179    ),
1180    dg(
1181        "bynk.resolve.not_a_record_type",
1182        "Record syntax was used on a non-record type.",
1183        &["record_construction"],
1184    ),
1185    dg(
1186        "bynk.resolve.opaque_record_construction",
1187        "An opaque type was constructed with record syntax.",
1188        &["record_construction"],
1189    ),
1190    dg(
1191        "bynk.resolve.param_as_function",
1192        "A value (such as a parameter) was called as a function.",
1193        &["call"],
1194    ),
1195    dg(
1196        "bynk.resolve.recursive_record_field",
1197        "A record directly contains a field of its own type.",
1198        &["record_type"],
1199    ),
1200    dg(
1201        "bynk.resolve.reserved_builtin_type",
1202        "A type declaration reuses a compiler-known built-in type name.",
1203        &["type_decl"],
1204    ),
1205    dg(
1206        "bynk.resolve.self_outside_method",
1207        "`self` referenced outside a method or handler.",
1208        &["self_expr"],
1209    ),
1210    dg(
1211        "bynk.resolve.type_as_function",
1212        "A type name was called as if it were a function.",
1213        &["call"],
1214    ),
1215    d(
1216        "bynk.resolve.type_in_expr",
1217        "A type name was used where a value is expected.",
1218    ),
1219    dg(
1220        "bynk.resolve.unconsumed_context",
1221        "A context's service was called without a `consumes` declaration.",
1222        &["consumes_decl"],
1223    ),
1224    dg(
1225        "bynk.resolve.unknown_field",
1226        "Accessed a field the record does not have.",
1227        &["field_access"],
1228    ),
1229    dg(
1230        "bynk.resolve.unknown_function",
1231        "Called a function that does not exist.",
1232        &["call"],
1233    ),
1234    d(
1235        "bynk.resolve.unknown_name",
1236        "Referenced a name that is not in scope.",
1237    ),
1238    dg(
1239        "bynk.resolve.unknown_static_member",
1240        "Referenced an unknown static member (e.g. `T.x`).",
1241        &["field_access"],
1242    ),
1243    d(
1244        "bynk.resolve.unknown_type",
1245        "Referenced a type that does not exist.",
1246    ),
1247    d(
1248        "bynk.secrets.computed_name",
1249        "A `bynk.Secrets` read names its secret with a computed expression rather than a literal, so `bynk deploy` cannot plan it (warning).",
1250    ),
1251    dg(
1252        "bynk.send.in_pure_context",
1253        "A `~>` send was used in a pure (non-effectful) context.",
1254        &["effect_send_stmt"],
1255    ),
1256    dg(
1257        "bynk.send.non_effect",
1258        "A `~>` send was applied to a non-`Effect` value.",
1259        &["effect_send_stmt"],
1260    ),
1261    dg(
1262        "bynk.send.requires_unit",
1263        "A `~>` send targets an operation whose reply is not `Effect[()]`.",
1264        &["effect_send_stmt"],
1265    ),
1266    dg(
1267        "bynk.service.missing_from",
1268        "A `from`-less service has a handler other than `on call`.",
1269        &["service_decl"],
1270    ),
1271    dg(
1272        "bynk.service.mixed_protocols",
1273        "A service mixes handler forms that do not match its `from <protocol>`.",
1274        &["service_decl"],
1275    ),
1276    dg(
1277        "bynk.service.outside_context",
1278        "A `service` was declared outside a context.",
1279        &["service_decl"],
1280    ),
1281    dg(
1282        "bynk.service.return_not_effect",
1283        "A service handler's return type is not an `Effect`.",
1284        &["service_decl"],
1285    ),
1286    dg(
1287        "bynk.service.unknown_protocol",
1288        "A `from <protocol>` names an unknown protocol (e.g. a transport like Kafka).",
1289        &["service_decl"],
1290    ),
1291    d(
1292        "bynk.service.websocket_header",
1293        "The `from websocket` header is malformed — it binds frame types as `websocket(in: <type>, out: <type>)` (real-time track slice 3).",
1294    ),
1295    d(
1296        "bynk.service.websocket_multiple",
1297        "A context holds more than one `from websocket` service — at v1 the Workers upgrade routes by the `Upgrade: websocket` header alone, so one WebSocket service per context (real-time track slice 3b).",
1298    ),
1299    d(
1300        "bynk.service.websocket_open_arity",
1301        "A `from websocket` service must hold exactly one `on open` handler (the edge upgrade), and at most one `on message` (inbound) and one `on close` (real-time track slice 3/3b-iii).",
1302    ),
1303    d(
1304        "bynk.store.annotation_kind_mismatch",
1305        "A storage annotation is used on a kind it does not apply to (e.g. `@ttl` on a `Map`).",
1306    ),
1307    d(
1308        "bynk.store.annotation_unsupported",
1309        "A known storage annotation (`@ttl`/`@retain`/`@indexed`/`@bounded`) is used before the slice that supports it.",
1310    ),
1311    d(
1312        "bynk.store.cache_needs_clock",
1313        "A handler performs a `Cache` operation (TTL expiry reads the clock) without declaring `given Clock`.",
1314    ),
1315    d(
1316        "bynk.store.cache_ttl_required",
1317        "A `Cache` field is missing its required `@ttl(<duration>)` annotation (a keyed store with no expiry is a `Map`).",
1318    ),
1319    d(
1320        "bynk.store.kind_arity",
1321        "A storage kind was applied to the wrong number of type arguments (e.g. `Cell[A, B]`).",
1322    ),
1323    d(
1324        "bynk.store.kind_unsupported",
1325        "A known storage kind (`Queue`) is used before the slice that supports it.",
1326    ),
1327    d(
1328        "bynk.store.log_needs_clock",
1329        "A handler calls `Log.append` (which stamps the current time) without declaring `given Clock`.",
1330    ),
1331    d(
1332        "bynk.store.unknown_annotation",
1333        "A `store` field carries an annotation outside the closed `@indexed`/`@ttl`/`@retain`/`@bounded` set.",
1334    ),
1335    d(
1336        "bynk.store.unknown_kind",
1337        "A `store` field's type is not a known storage kind.",
1338    ),
1339    d(
1340        "bynk.store.unknown_map_accessor",
1341        "A `store Map` field access is not one of its query accessors (`entries`/`keys`/`values`).",
1342    ),
1343    d(
1344        "bynk.store.unknown_op",
1345        "A storage-`Map`/`Set` operation is not a recognised entry/membership method.",
1346    ),
1347    d(
1348        "bynk.stub.bad_sequence",
1349        "A `stub … returns each […]` sequence is malformed (e.g. empty).",
1350    ),
1351    d(
1352        "bynk.stub.not_a_seam",
1353        "A test `stub` overrides a capability the unit under test does not consume.",
1354    ),
1355    d(
1356        "bynk.stub.rhs_type",
1357        "A test `stub … returns <value>` right-hand side does not match the operation's return type.",
1358    ),
1359    d(
1360        "bynk.stub.unknown_op",
1361        "A test `stub` names an operation the capability does not declare.",
1362    ),
1363    dg(
1364        "bynk.suite.duplicate_case_name",
1365        "Two `case`s share a description.",
1366        &["case"],
1367    ),
1368    dg(
1369        "bynk.suite.unknown_target",
1370        "A `suite` targets a unit that does not exist.",
1371        &["suite_decl"],
1372    ),
1373    d(
1374        "bynk.target.browser_bundle_only",
1375        "The `browser` platform builds only the in-process `Bundle` topology; `--target workers` is not a browser build.",
1376    ),
1377    dg(
1378        "bynk.target.vendor_conflict",
1379        "One deployment unit's in-process closure uses platform-native capabilities from two mutually-exclusive platforms.",
1380        &["consumes_decl"],
1381    ),
1382    dg(
1383        "bynk.target.vendor_required",
1384        "A deployment unit uses a platform-native capability but the build selects another `--platform`.",
1385        &["consumes_decl"],
1386    ),
1387    dg(
1388        "bynk.test.actor_identity_required",
1389        "A call-site `by <Actor>` omits the identity an identity-carrying actor requires.",
1390        &["case"],
1391    ),
1392    dg(
1393        "bynk.test.actor_no_identity",
1394        "A call-site `by <Actor>(x)` supplies an identity to an actor that takes none — a unit-identity actor (e.g. `Visitor`) or `Nobody`.",
1395        &["case"],
1396    ),
1397    dg(
1398        "bynk.test.credential_needs_system",
1399        "A case drives `by Nobody` (the no-credential principal, which tests the auth seam's 401) outside a `system`-tier case, where there is no real seam to reject it.",
1400        &["case"],
1401    ),
1402    dg(
1403        "bynk.test.nobody_needs_secured_route",
1404        "A case drives `by Nobody` at a route that is not Bearer-secured (e.g. a public `Visitor` route) — there is no auth seam to reject the missing credential.",
1405        &["case"],
1406    ),
1407    dg(
1408        "bynk.test.principal_identity_mismatch",
1409        "A call-site `by <Actor>` acts as an actor whose identity is incompatible with the addressed handler's actor.",
1410        &["case"],
1411    ),
1412    dg(
1413        "bynk.test.principal_on_wrong_method",
1414        "A wrong-method `405` test carries a `by <Actor>` clause; it reaches no handler, so a principal is meaningless.",
1415        &["case"],
1416    ),
1417    dg(
1418        "bynk.test.principal_required",
1419        "A test drives an identity-carrying handler with no call-site `by <Actor>(<identity>)`.",
1420        &["case"],
1421    ),
1422    dg(
1423        "bynk.test.service_bad_address",
1424        "A test body addresses a service the wrong way for its protocol (e.g. an http route without a leading path string).",
1425        &["case"],
1426    ),
1427    dg(
1428        "bynk.test.service_call_arity",
1429        "A test body's `svc.call(...)` passes the wrong number of arguments for the service's `on call` handler.",
1430        &["case"],
1431    ),
1432    dg(
1433        "bynk.test.service_no_call_handler",
1434        "A test body invokes `svc.call(...)` on a service with no `on call` handler (a `from http`/`cron`/`queue` service).",
1435        &["case"],
1436    ),
1437    dg(
1438        "bynk.test.service_unknown_route",
1439        "A test body addresses an http route / cron schedule / queue message the service does not declare.",
1440        &["case"],
1441    ),
1442    dg(
1443        "bynk.test.unknown_actor",
1444        "A call-site `by <Actor>` names an actor the target context does not declare and that is not a prelude actor.",
1445        &["case"],
1446    ),
1447    dg(
1448        "bynk.test.wire_needs_system",
1449        "A `Wire(...)` raw argument is used outside a `system`-tier service address; `Wire` hands pre-validation input to the boundary and is meaningless at `unit` or in any other position.",
1450        &["case"],
1451    ),
1452    d(
1453        "bynk.tier.property_has_tier",
1454        "A `property` carries an `as <tier>` clause; tiers are a `case`-only affordance.",
1455    ),
1456    d(
1457        "bynk.tier.system_needs_wire",
1458        "An `as system` test stands up fewer than two contexts; the system tier wires across contexts.",
1459    ),
1460    d(
1461        "bynk.transition.cross_agent_reference",
1462        "A transition predicate references another agent; step invariants are per-agent.",
1463    ),
1464    d(
1465        "bynk.transition.duplicate_name",
1466        "An agent declares two transitions with the same name.",
1467    ),
1468    d(
1469        "bynk.transition.impure_predicate",
1470        "A transition predicate uses an effectful or test-only construct; a step invariant must be pure.",
1471    ),
1472    d(
1473        "bynk.transition.no_step_reference",
1474        "A transition references neither `old` nor `new`; it constrains one state, so it is an `invariant`, not a step.",
1475    ),
1476    d(
1477        "bynk.transition.not_bool",
1478        "A transition predicate does not have type `Bool`.",
1479    ),
1480    d(
1481        "bynk.types.ambiguous_constructor",
1482        "`Ok`/`Err` is ambiguous between `Result` and `HttpResult`; qualify it.",
1483    ),
1484    dg(
1485        "bynk.types.argument_mismatch",
1486        "A function argument has the wrong type.",
1487        &["call"],
1488    ),
1489    dg(
1490        "bynk.types.call_arity",
1491        "A function value was applied with the wrong number of arguments.",
1492        &["call"],
1493    ),
1494    dg(
1495        "bynk.types.cannot_infer_option_type_param",
1496        "The value type of `None` could not be inferred.",
1497        &["none_expr"],
1498    ),
1499    d(
1500        "bynk.types.cannot_infer_result_type_params",
1501        "The type parameters of a `Result` could not be inferred.",
1502    ),
1503    dg(
1504        "bynk.types.catastrophic_regex",
1505        "A `Matches` predicate nests unbounded quantifiers, risking catastrophic backtracking (ReDoS).",
1506        &["refinement"],
1507    ),
1508    d(
1509        "bynk.types.constructor_arity",
1510        "A variant constructor got the wrong number of arguments.",
1511    ),
1512    d(
1513        "bynk.types.constructor_base_mismatch",
1514        "A `.of` constructor was given an argument of the wrong base type.",
1515    ),
1516    dg(
1517        "bynk.types.duplicate_literal_arm",
1518        "A `match` has two arms for the same literal value.",
1519        &["match_arm"],
1520    ),
1521    dg(
1522        "bynk.types.duplicate_variant_arm",
1523        "A `match` has two arms for the same variant.",
1524        &["match_arm"],
1525    ),
1526    d(
1527        "bynk.types.embeds_ambiguous",
1528        "A type is embedded by more than one variant of a sum, so `?`'s conversion would be ambiguous.",
1529    ),
1530    d(
1531        "bynk.types.embeds_unknown_variant",
1532        "An `embeds … as V` clause names a variant the sum does not declare.",
1533    ),
1534    d(
1535        "bynk.types.embeds_variant_shape",
1536        "An `embeds E as V` target variant must have exactly one payload field, of type `E`.",
1537    ),
1538    dg(
1539        "bynk.types.empty_refinement",
1540        "A refinement admits no values (contradictory predicates).",
1541        &["refinement"],
1542    ),
1543    dg(
1544        "bynk.types.err_value_mismatch",
1545        "An `Err` payload has the wrong type.",
1546        &["err_expr"],
1547    ),
1548    dg(
1549        "bynk.types.field_access_on_non_record",
1550        "Field access on a value that is not a record.",
1551        &["field_access"],
1552    ),
1553    dg(
1554        "bynk.types.field_refinement_not_base",
1555        "An inline field refinement requires a base or refined type.",
1556        &["record_field"],
1557    ),
1558    dg(
1559        "bynk.types.field_value_mismatch",
1560        "A record field was given a value of the wrong type.",
1561        &["record_construction"],
1562    ),
1563    dg(
1564        "bynk.types.function_at_boundary",
1565        "A function type appeared in a serialisable or boundary position (a record field, sum payload, service/agent handler signature, capability operation signature, agent state field, or agent key); functions cannot serialise or cross a boundary.",
1566        &["function_type_ref"],
1567    ),
1568    dg(
1569        "bynk.types.guard_not_bool",
1570        "A match-arm `if` guard is not a `Bool` expression.",
1571        &["match_arm"],
1572    ),
1573    d(
1574        "bynk.types.held_at_boundary",
1575        "A held value (`Connection[F]`) appears in a serialisable or boundary position — a held resource is built and disposed in place, never persisted or sent across a boundary (§2.9, real-time track slice 2).",
1576    ),
1577    d(
1578        "bynk.types.held_not_comparable",
1579        "A held value (`Connection[F]`) is compared with `==`/`!=` — held values have identity, not value-equality (§2.9.3, real-time track slice 2).",
1580    ),
1581    dg(
1582        "bynk.types.if_branch_mismatch",
1583        "The branches of an `if` have different types.",
1584        &["if_expr"],
1585    ),
1586    dg(
1587        "bynk.types.if_non_bool_cond",
1588        "An `if` condition is not a `Bool`.",
1589        &["if_expr"],
1590    ),
1591    dg(
1592        "bynk.types.if_without_else_requires_unit",
1593        "An `if` with no `else` branch has a non-unit then-branch; the missing else defaults to `()`, so the branch must be `()` or `Effect[()]`.",
1594        &["if_expr"],
1595    ),
1596    d(
1597        "bynk.types.interpolation_non_scalar",
1598        "An interpolation hole holds a value with no string form.",
1599    ),
1600    dg(
1601        "bynk.types.invalid_regex",
1602        "A `Matches` predicate contains an invalid regular expression.",
1603        &["refinement"],
1604    ),
1605    dg(
1606        "bynk.types.inverted_range",
1607        "An `InRange` predicate has its bounds inverted.",
1608        &["refinement"],
1609    ),
1610    dg(
1611        "bynk.types.is_base_mismatch",
1612        "An `is` refinement check is applied to a value of the wrong base type.",
1613        &["is_expr"],
1614    ),
1615    dg(
1616        "bynk.types.is_literal_pattern",
1617        "A literal was used on the right of `is`; `is` tests type/refinement, not value equality (use `==`).",
1618        &["is_expr"],
1619    ),
1620    dg(
1621        "bynk.types.is_non_sum",
1622        "`is` was applied to a value that is not a sum type.",
1623        &["is_expr"],
1624    ),
1625    dg(
1626        "bynk.types.is_unknown_variant",
1627        "`is` names a variant the type does not have.",
1628        &["is_expr"],
1629    ),
1630    dg(
1631        "bynk.types.json_uncodable",
1632        "A `Json.encode`/`Json.decode` target type cannot pass through the typed JSON codec (functions, effects, error builtins).",
1633        &["method_call"],
1634    ),
1635    dg(
1636        "bynk.types.key_not_orderable",
1637        "A `sortBy`/`min`/`max` key function does not return an orderable type (`Int`, `Float`, `String`, `Duration`, or `Instant`).",
1638        &[],
1639    ),
1640    dg(
1641        "bynk.types.lambda_mismatch",
1642        "A lambda's parameter count, parameter annotations, or body type do not match the expected function type.",
1643        &["lambda_expr"],
1644    ),
1645    dg(
1646        "bynk.types.let_annotation_mismatch",
1647        "A `let` value does not match its type annotation.",
1648        &["let_stmt"],
1649    ),
1650    dg(
1651        "bynk.types.list_element_mismatch",
1652        "A list-literal element has a different type from the list's element type.",
1653        &["list_literal"],
1654    ),
1655    dg(
1656        "bynk.types.match_arm_mismatch",
1657        "A `match` arm has a different type from the others.",
1658        &["match_arm"],
1659    ),
1660    dg(
1661        "bynk.types.match_non_sum_discriminant",
1662        "`match` was applied to a value that is not a sum type.",
1663        &["match_expr"],
1664    ),
1665    dg(
1666        "bynk.types.method_arity",
1667        "A method was called with the wrong number of arguments.",
1668        &["method_call"],
1669    ),
1670    dg(
1671        "bynk.types.method_not_found",
1672        "Called a method the type does not have.",
1673        &["method_call"],
1674    ),
1675    dg(
1676        "bynk.types.method_on_non_named_type",
1677        "A method was called on a built-in type that has no methods.",
1678        &["method_call"],
1679    ),
1680    dg(
1681        "bynk.types.mixed_pattern_bindings",
1682        "A pattern mixes named and positional bindings.",
1683        &["variant_pattern"],
1684    ),
1685    dg(
1686        "bynk.types.negative_length",
1687        "A length predicate was given a negative value.",
1688        &["refinement"],
1689    ),
1690    dg(
1691        "bynk.types.no_numeric_coercion",
1692        "`Int` and `Float` were mixed without an explicit conversion — in an operation or in refinement bounds.",
1693        &["binary_expr", "refinement"],
1694    ),
1695    dg(
1696        "bynk.types.non_exhaustive_match",
1697        "A `match` does not cover every variant.",
1698        &["match_expr"],
1699    ),
1700    dg(
1701        "bynk.types.ok_value_mismatch",
1702        "An `Ok` payload has the wrong type.",
1703        &["ok_expr"],
1704    ),
1705    dg(
1706        "bynk.types.opaque_raw_outside",
1707        "`.raw` on an opaque type was used outside its defining commons.",
1708        &["field_access"],
1709    ),
1710    dg(
1711        "bynk.types.opaque_record_construction",
1712        "An opaque type was constructed with record syntax.",
1713        &["record_construction"],
1714    ),
1715    dg(
1716        "bynk.types.opaque_unsafe_outside",
1717        "`.unsafe` on an opaque type was used outside its defining context.",
1718        &["field_access"],
1719    ),
1720    dg(
1721        "bynk.types.pattern_arity",
1722        "A pattern binds the wrong number of payload fields.",
1723        &["variant_pattern"],
1724    ),
1725    dg(
1726        "bynk.types.pattern_type_mismatch",
1727        "A pattern's type does not match the matched value.",
1728        &["variant_pattern"],
1729    ),
1730    dg(
1731        "bynk.types.predicate_base_mismatch",
1732        "A predicate does not apply to the type's base (e.g. a string predicate on an `Int`).",
1733        &["refinement"],
1734    ),
1735    d(
1736        "bynk.types.query_at_boundary",
1737        "A `Query` type appears in a storable or boundary-crossing position — a query is built and executed in place, never persisted or sent (ADR 0115).",
1738    ),
1739    dg(
1740        "bynk.types.question_error_mismatch",
1741        "`?` propagates an error type incompatible with the function's.",
1742        &["question_expr"],
1743    ),
1744    dg(
1745        "bynk.types.question_on_non_result",
1746        "`?` was applied to a non-`Result` value.",
1747        &["question_expr"],
1748    ),
1749    dg(
1750        "bynk.types.question_option_outside_http",
1751        "`?` lifts an `Option` only inside a handler returning `HttpResult` (`None` becomes `NotFound`); elsewhere use `.okOr(err)`.",
1752        &["question_expr"],
1753    ),
1754    dg(
1755        "bynk.types.question_outside_result",
1756        "`?` used in a function that does not return a `Result`.",
1757        &["question_expr"],
1758    ),
1759    d(
1760        "bynk.types.return_mismatch",
1761        "A returned value does not match the declared return type.",
1762    ),
1763    dg(
1764        "bynk.types.some_value_mismatch",
1765        "A `Some` payload has the wrong type.",
1766        &["some_expr"],
1767    ),
1768    d(
1769        "bynk.types.stream_at_boundary",
1770        "A `Stream` type appears in a storable or boundary-crossing position — a stream is a live value-over-time source, never persisted or sent across a boundary (real-time track slice 0).",
1771    ),
1772    d(
1773        "bynk.types.stream_not_comparable",
1774        "A `Stream` value is compared with `==`/`!=` — a stream is a live value-over-time source, not a comparable value (real-time track slice 0).",
1775    ),
1776    d(
1777        "bynk.types.type_mismatch",
1778        "Two types that were required to match did not.",
1779    ),
1780    dg(
1781        "bynk.types.uninferable_element_type",
1782        "An empty `[]` (or `List.empty()` / `Map.empty()`) has no expected type to infer its element type from.",
1783        &["list_literal"],
1784    ),
1785    dg(
1786        "bynk.types.unkeyable_distinct",
1787        "A `distinct`/`distinctBy` element or key is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
1788        &[],
1789    ),
1790    dg(
1791        "bynk.types.unkeyable_map_key",
1792        "A `Map` key type is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
1793        &["generic_type_ref"],
1794    ),
1795    dg(
1796        "bynk.types.unknown_field",
1797        "Referenced a field the record type does not declare.",
1798        &["field_access"],
1799    ),
1800    dg(
1801        "bynk.types.unknown_pattern_field",
1802        "A pattern names a field the variant does not have.",
1803        &["variant_pattern"],
1804    ),
1805    dg(
1806        "bynk.types.unknown_static_member",
1807        "Referenced an unknown static member on a type.",
1808        &["field_access"],
1809    ),
1810    dg(
1811        "bynk.types.unknown_variant_in_pattern",
1812        "A pattern names a variant the sum type does not have.",
1813        &["variant_pattern"],
1814    ),
1815    dg(
1816        "bynk.types.unreachable_arm",
1817        "A `match` arm is unreachable.",
1818        &["match_arm"],
1819    ),
1820    d(
1821        "bynk.types.variant_arity",
1822        "A variant constructor got the wrong number of payload values.",
1823    ),
1824    d(
1825        "bynk.types.variant_missing_payload",
1826        "A variant requiring a payload was used without one.",
1827    ),
1828    d(
1829        "bynk.types.variant_payload_mismatch",
1830        "A variant payload has the wrong type.",
1831    ),
1832    dg(
1833        "bynk.uses.name_conflict",
1834        "A `uses` name collides with another name.",
1835        &["uses_decl"],
1836    ),
1837    dg(
1838        "bynk.uses.self_reference",
1839        "A commons `uses` itself.",
1840        &["uses_decl"],
1841    ),
1842    dg(
1843        "bynk.uses.target_is_context",
1844        "`uses` targets a context instead of a commons.",
1845        &["uses_decl"],
1846    ),
1847    dg(
1848        "bynk.uses.unknown_commons",
1849        "`uses` names a commons that does not exist.",
1850        &["uses_decl"],
1851    ),
1852    dg(
1853        "bynk.val.agent_not_generable",
1854        "A `for all`/`Val` cannot generate an agent — fabricated agent states need not be reachable.",
1855        &["for_all"],
1856    ),
1857    dg(
1858        "bynk.val.arity",
1859        "`Val[T]` was given the wrong number of pin arguments.",
1860        &["val_expr"],
1861    ),
1862    dg(
1863        "bynk.val.literal_violates",
1864        "A pinned `Val[T]` value violates the type's refinement.",
1865        &["val_expr"],
1866    ),
1867    dg(
1868        "bynk.val.needs_pin",
1869        "A bare `Val[T]` cannot generate a value (e.g. a `Matches` string); pin one.",
1870        &["val_expr"],
1871    ),
1872    dg(
1873        "bynk.val.outside_test",
1874        "`Val[T]` was used outside a test case body.",
1875        &["val_expr"],
1876    ),
1877    dg(
1878        "bynk.val.pin_not_literal",
1879        "A `Val[T]` pin argument is not a compile-time literal.",
1880        &["val_expr"],
1881    ),
1882    dg(
1883        "bynk.val.pin_unsupported",
1884        "A pin was given for a type kind that does not support pinning.",
1885        &["val_expr"],
1886    ),
1887    dg(
1888        "bynk.val.unknown_type",
1889        "`Val[T]` names a type that does not resolve.",
1890        &["val_expr"],
1891    ),
1892    dg(
1893        "bynk.val.unsupported_kind",
1894        "`Val[T]` cannot fabricate a value for this kind of type.",
1895        &["val_expr"],
1896    ),
1897    d(
1898        "bynk.ws.message_frame_param",
1899        "A WebSocket `on message` handler does not have exactly one parameter of the service's inbound (`in:`) frame type — the decoded frame (real-time track slice 3b-iii).",
1900    ),
1901    d(
1902        "bynk.ws.open_given_unsupported",
1903        "A WebSocket `on open` handler declares `given` capabilities — unsupported at v1, since on Workers the handler runs inside the connection-hosting Durable Object, which has no composition root to supply them (real-time track slice 3b).",
1904    ),
1905    d(
1906        "bynk.ws.open_transfer_shape",
1907        "A WebSocket `on open` handler does not transfer its `connection` into exactly one agent, so the Workers upgrade has no single Durable Object to route to (real-time track slice 3b).",
1908    ),
1909    d(
1910        "bynk.ws.route_param_mismatch",
1911        "A WebSocket `on message`/`on close` route parameter does not match the `on open` parameter at the same position — route values are recovered positionally from the connection, so they must be a type-compatible prefix of the `on open` parameters (real-time track slice 3b-iii).",
1912    ),
1913];
1914
1915/// A diagnostic with no single governing grammar construct.
1916const fn d(code: &'static str, summary: &'static str) -> DiagnosticInfo {
1917    DiagnosticInfo {
1918        code,
1919        summary,
1920        grammar_symbol: &[],
1921    }
1922}
1923
1924/// A diagnostic that constrains one or more grammar productions.
1925const fn dg(
1926    code: &'static str,
1927    summary: &'static str,
1928    grammar_symbol: &'static [&'static str],
1929) -> DiagnosticInfo {
1930    DiagnosticInfo {
1931        code,
1932        summary,
1933        grammar_symbol,
1934    }
1935}
1936
1937/// The category segment of a code (the part between the first two dots), e.g.
1938/// `"types"` for `"bynk.types.type_mismatch"`.
1939pub fn category(code: &str) -> &str {
1940    code.split('.').nth(1).unwrap_or("")
1941}
1942
1943/// A human-readable heading for a category segment.
1944fn category_title(cat: &str) -> &'static str {
1945    match cat {
1946        "agent" | "agents" => "Agents",
1947        "boundary" => "Boundaries",
1948        "capability" => "Capabilities",
1949        "consumes" => "Consumes",
1950        "context" => "Contexts",
1951        "contract" => "Contracts",
1952        "cron" => "Cron",
1953        "effect" => "Effects",
1954        "expect" => "Expectations",
1955        "exports" => "Exports",
1956        "given" => "Given capabilities",
1957        "http" => "HTTP",
1958        "lex" => "Lexer",
1959        "mock" => "Mocks (collaborators)",
1960        "observe" => "Observation",
1961        "parse" => "Parser",
1962        "project" => "Project",
1963        "property" => "Properties (generative tests)",
1964        "provider" => "Providers",
1965        "queue" => "Queue",
1966        "record_spread" => "Record spread",
1967        "refine" => "Refinement",
1968        "resolve" => "Resolution",
1969        "service" => "Services",
1970        "suite" => "Suites and cases",
1971        "transition" => "Transitions (step invariants)",
1972        "types" => "Type checking",
1973        "uses" => "Uses",
1974        "val" => "Value fabrication",
1975        _ => "Other",
1976    }
1977}
1978
1979/// Render the diagnostic index as a Markdown reference page, grouped by
1980/// category. This is the generator behind
1981/// `site/src/content/docs/book/reference/diagnostics.md`.
1982pub fn render_markdown() -> String {
1983    use std::collections::BTreeMap;
1984
1985    // Group codes by their category title, preserving sorted code order.
1986    let mut by_category: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
1987    for info in REGISTRY {
1988        by_category
1989            .entry(category_title(category(info.code)))
1990            .or_default()
1991            .push(info);
1992    }
1993
1994    let mut out = String::new();
1995    out.push_str("# Diagnostic index\n\n");
1996    out.push_str(
1997        "<!-- GENERATED FILE — do not edit by hand.\n     \
1998         Source: bynkc/src/diagnostics.rs (`render_markdown`).\n     \
1999         Regenerate with: BYNK_BLESS=1 cargo test -p bynkc --test diagnostics_registry -->\n\n",
2000    );
2001    out.push_str(
2002        "Every diagnostic code the compiler can emit, with a one-line summary of \
2003         the cause, grouped by category. For step-by-step cause-and-fix guidance \
2004         on the most common ones, see the [troubleshooting guides](../troubleshooting/index.md).\n\n",
2005    );
2006    out.push_str(&format!(
2007        "There are **{}** codes in total.\n",
2008        REGISTRY.len()
2009    ));
2010
2011    for (title, infos) in &by_category {
2012        out.push_str(&format!("\n## {title}\n\n"));
2013        out.push_str("| Code | Summary | Construct |\n|---|---|---|\n");
2014        for info in infos {
2015            // The construct column deep-links each governing production to its
2016            // entry in the annotated grammar reference; generated from
2017            // `grammar_symbol` (each value is an embeddable rule, so the
2018            // `#rule-<raw>` anchor resolves — enforced in diagnostics_registry).
2019            let construct = info
2020                .grammar_symbol
2021                .iter()
2022                .map(|sym| format!("[`{sym}`](grammar.md#rule-{sym})"))
2023                .collect::<Vec<_>>()
2024                .join(", ");
2025            out.push_str(&format!(
2026                "| `{}` | {} | {} |\n",
2027                info.code, info.summary, construct
2028            ));
2029        }
2030    }
2031
2032    out
2033}
2034
2035/// Invert the registry into a `{ "<rule>": [ { code, summary }, … ], … }` map,
2036/// serialised as pretty JSON with sorted keys and sorted codes. Only rules with
2037/// at least one diagnostic appear. This is the generator behind
2038/// `docs/grammar-semantics.json`, which the `{{#grammar-semantics <rule>}}`
2039/// preprocessor directive consumes.
2040pub fn render_grammar_semantics_json() -> String {
2041    use std::collections::BTreeMap;
2042
2043    // REGISTRY is sorted by code, so each rule's vector comes out code-sorted;
2044    // the BTreeMap gives sorted rule names.
2045    let mut by_symbol: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
2046    for info in REGISTRY {
2047        for sym in info.grammar_symbol {
2048            by_symbol.entry(sym).or_default().push(info);
2049        }
2050    }
2051
2052    let mut map = serde_json::Map::new();
2053    map.insert(
2054        "_generated".to_string(),
2055        serde_json::Value::String(
2056            "Generated from the grammar_symbol field of bynkc/src/diagnostics.rs. \
2057             Do not edit by hand. Regenerate with: BYNK_BLESS=1 cargo test -p \
2058             bynkc --test diagnostics_registry"
2059                .to_string(),
2060        ),
2061    );
2062    for (sym, infos) in by_symbol {
2063        let arr: Vec<serde_json::Value> = infos
2064            .iter()
2065            .map(|info| serde_json::json!({ "code": info.code, "summary": info.summary }))
2066            .collect();
2067        map.insert(sym.to_string(), serde_json::Value::Array(arr));
2068    }
2069
2070    let mut s =
2071        serde_json::to_string_pretty(&serde_json::Value::Object(map)).expect("serialise semantics");
2072    s.push('\n');
2073    s
2074}