1pub struct DiagnosticInfo {
21 pub code: &'static str,
22 pub summary: &'static str,
23 pub grammar_symbol: &'static [&'static str],
31}
32
33pub 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.outside_context",
65 "An `actor` was declared outside a context (e.g. in a commons).",
66 ),
67 d(
68 "bynk.actor.refinement_base_unsupported",
69 "A refinement actor's base is not a `Bearer` actor (no claims to authorise against).",
70 ),
71 d(
72 "bynk.actor.refinement_in_sum",
73 "A refinement actor appears as a member of a multi-actor sum.",
74 ),
75 d(
76 "bynk.actor.refinement_predicate_unsupported",
77 "A refinement actor's `where` predicate is outside the closed claim-predicate set.",
78 ),
79 d(
80 "bynk.actor.scheme_not_admissible",
81 "An actor's scheme is not admissible on this handler's protocol.",
82 ),
83 d(
84 "bynk.actor.signature_identity_unsupported",
85 "A `Signature` actor declared an `identity`, which is not yet supported.",
86 ),
87 d(
88 "bynk.actor.signature_missing_header",
89 "A `Signature` actor does not name its signature header.",
90 ),
91 d(
92 "bynk.actor.signature_missing_secret",
93 "A `Signature` actor does not name its signing secret.",
94 ),
95 d(
96 "bynk.actor.signature_requires_body",
97 "A `Signature` handler does not take a `body` parameter.",
98 ),
99 d(
100 "bynk.actor.signature_tolerance_without_timestamp",
101 "A `Signature` actor set `tolerance` without a `timestamp` header.",
102 ),
103 d(
104 "bynk.actor.sum_requires_binder",
105 "A multi-actor sum `by` clause has no binder to match the resolved actor.",
106 ),
107 d(
108 "bynk.actor.unknown_actor",
109 "A handler's `by` clause names an actor that is not declared.",
110 ),
111 d(
112 "bynk.actor.unknown_scheme",
113 "An actor declares an authentication scheme that is not compiler-known.",
114 ),
115 d(
116 "bynk.actor.unreachable_sum_arm",
117 "A multi-actor sum has an arm unreachable after a catch-all (`None`) peer.",
118 ),
119 dg(
120 "bynk.adapter.consumes_context",
121 "An `adapter` consumed a context; adapter dependencies are adapter-to-adapter.",
122 &["consumes_decl"],
123 ),
124 dg(
125 "bynk.adapter.consumes_requires_selection",
126 "An `adapter` used a whole-unit or aliased `consumes`; adapters must select capabilities with `consumes U { Cap, … }`.",
127 &["consumes_decl"],
128 ),
129 dg(
130 "bynk.adapter.disallowed_item",
131 "An `adapter` declared a `service`, `agent`, or other item it may not contain.",
132 &["adapter_decl"],
133 ),
134 dg(
135 "bynk.adapter.duplicate_binding",
136 "An `adapter` declared more than one `binding` clause.",
137 &["binding_decl"],
138 ),
139 dg(
140 "bynk.adapter.no_binding",
141 "An `adapter` declares an external provider but no `binding` module to supply it.",
142 &["adapter_decl"],
143 ),
144 dg(
145 "bynk.adapter.provider_has_body",
146 "A provider inside an `adapter` has a Bynk body; adapter providers must be external.",
147 &["provider_decl"],
148 ),
149 dg(
150 "bynk.agent.construction_arity",
151 "An agent was constructed with the wrong number of key arguments.",
152 &["agent_decl"],
153 ),
154 dg(
155 "bynk.agent.handler_arity",
156 "An agent handler was called with the wrong number of arguments.",
157 &["agent_decl"],
158 ),
159 dg(
160 "bynk.agent.handler_not_found",
161 "Called a handler the agent does not declare.",
162 &["agent_decl"],
163 ),
164 dg(
165 "bynk.agent.key_mismatch",
166 "An agent key argument has the wrong type.",
167 &["agent_decl"],
168 ),
169 dg(
170 "bynk.agent.outside_context",
171 "An `agent` was declared outside a context.",
172 &["agent_decl"],
173 ),
174 dg(
175 "bynk.agent.return_not_effect",
176 "An agent handler's return type is not an `Effect`.",
177 &["agent_decl"],
178 ),
179 dg(
180 "bynk.agents.bad_state_initialiser",
181 "An agent `store` field initialiser is not a static value of the field's type.",
182 &["store_field"],
183 ),
184 dg(
185 "bynk.agents.non_zeroable_state_field",
186 "An agent `store` field has no initialiser and no implicit zero value.",
187 &["store_field"],
188 ),
189 dg(
190 "bynk.assert.non_bool",
191 "`assert` was given a non-`Bool` expression.",
192 &["assert_expr"],
193 ),
194 dg(
195 "bynk.assert.outside_test",
196 "`assert` was used outside a test case body.",
197 &["assert_expr"],
198 ),
199 d(
200 "bynk.boundary.structural_mismatch",
201 "Data crossing a context boundary did not match the expected shape.",
202 ),
203 dg(
204 "bynk.capability.op_arity",
205 "A capability operation was called with the wrong number of arguments.",
206 &["capability_decl"],
207 ),
208 dg(
209 "bynk.capability.outside_context",
210 "A `capability` was declared outside a context.",
211 &["capability_decl"],
212 ),
213 dg(
214 "bynk.capability.unknown_operation",
215 "Referenced an operation the capability does not declare.",
216 &["capability_decl"],
217 ),
218 d(
219 "bynk.cell.invalid_target",
220 "A `:=` write targets something that is not a `store Cell` field.",
221 ),
222 d(
223 "bynk.cell.self_reference",
224 "A `:=` right-hand side reads the cell being written (a read-modify-write); use `.update`.",
225 ),
226 dg(
227 "bynk.consumes.alias_conflict",
228 "Two `consumes` aliases collide.",
229 &["consumes_decl"],
230 ),
231 dg(
232 "bynk.consumes.capability_name_clash",
233 "Two flattened `consumes U { Cap }` capabilities collide, or one clashes with a local capability.",
234 &["consumes_decl"],
235 ),
236 dg(
237 "bynk.consumes.in_commons",
238 "`consumes` appears in a `commons` (it is only valid in a context).",
239 &["consumes_decl"],
240 ),
241 dg(
242 "bynk.consumes.name_conflict",
243 "A `consumes` name collides with another name in scope.",
244 &["consumes_decl"],
245 ),
246 dg(
247 "bynk.consumes.self_reference",
248 "A context `consumes` itself.",
249 &["consumes_decl"],
250 ),
251 dg(
252 "bynk.consumes.service_arity",
253 "A consumed service was called with the wrong number of arguments.",
254 &["consumes_decl"],
255 ),
256 dg(
257 "bynk.consumes.target_is_commons",
258 "`consumes` targets a `commons` instead of a context.",
259 &["consumes_decl"],
260 ),
261 dg(
262 "bynk.consumes.unknown_context",
263 "`consumes` names a context that does not exist.",
264 &["consumes_decl"],
265 ),
266 dg(
267 "bynk.consumes.unknown_service",
268 "Called a service the consumed context does not declare.",
269 &["consumes_decl"],
270 ),
271 d(
272 "bynk.context.consumes_cycle",
273 "Contexts form a `consumes` dependency cycle.",
274 ),
275 d(
276 "bynk.context.external_construction",
277 "A context-owned type was constructed from outside that context.",
278 ),
279 dg(
280 "bynk.context.external_provider",
281 "A bodiless (external) provider was declared outside an `adapter`.",
282 &["provider_decl"],
283 ),
284 d(
285 "bynk.context.opaque_inspection",
286 "An opaquely-exported type was inspected from outside its context.",
287 ),
288 dg(
289 "bynk.cron.bad_params",
290 "A cron handler declares more than one parameter, or a non-`Int` one.",
291 &["cron_handler"],
292 ),
293 dg(
294 "bynk.cron.duplicate_schedule",
295 "Two cron handlers declare the same schedule.",
296 &["cron_handler"],
297 ),
298 dg(
299 "bynk.cron.invalid_schedule",
300 "A cron expression is not five whitespace-separated fields.",
301 &["cron_handler"],
302 ),
303 dg(
304 "bynk.cron.return_not_effect_result",
305 "A cron handler does not return `Effect[Result[(), E]]`.",
306 &["cron_handler"],
307 ),
308 d(
309 "bynk.duration.literal_overflow",
310 "A `Duration` literal (`<int>.<unit>`) exceeds the representable millisecond range.",
311 ),
312 dg(
313 "bynk.effect.bind_in_pure_context",
314 "An `<-` bind was used in a pure (non-effectful) context.",
315 &["effect_let_stmt"],
316 ),
317 dg(
318 "bynk.effect.bind_on_non_effect",
319 "An `<-` bind was applied to a non-`Effect` value.",
320 &["effect_let_stmt"],
321 ),
322 d(
323 "bynk.effect.capability_in_pure_context",
324 "A capability was used in a pure context.",
325 ),
326 d(
327 "bynk.effect.cross_context_in_pure_context",
328 "A cross-context call was made in a pure context.",
329 ),
330 dg(
331 "bynk.effect.fn_value_in_pure_context",
332 "An effectful function value was called in a pure context; like a capability call, it is legal only where the enclosing body is effectful.",
333 &["call"],
334 ),
335 dg(
336 "bynk.exports.capability_not_provided",
337 "An exported capability has no provider in its context.",
338 &["exports_decl"],
339 ),
340 dg(
341 "bynk.exports.conflicting_visibility",
342 "A type is exported with conflicting visibilities.",
343 &["exports_decl"],
344 ),
345 dg(
346 "bynk.exports.duplicate_export",
347 "The same name is exported more than once.",
348 &["exports_decl"],
349 ),
350 dg(
351 "bynk.exports.duplicate_in_clause",
352 "A name appears twice in one `exports` clause.",
353 &["exports_decl"],
354 ),
355 dg(
356 "bynk.exports.undeclared_capability",
357 "`exports capability` names a capability that is not declared.",
358 &["exports_decl"],
359 ),
360 dg(
361 "bynk.exports.undeclared_type",
362 "`exports` names a type that is not declared.",
363 &["exports_decl"],
364 ),
365 dg(
366 "bynk.generics.no_bounds",
367 "A type parameter carries a bound (`[A: …]`); bounded generics are not in v0.20a.",
368 &["fn_decl"],
369 ),
370 dg(
371 "bynk.generics.no_generic_types",
372 "A `type` declaration carries a type-parameter list; generic type declarations are not in v0.20a (type parameters belong to functions).",
373 &["type_decl"],
374 ),
375 dg(
376 "bynk.generics.type_arg_mismatch",
377 "Inferred or explicit type arguments conflict, have the wrong arity, target a non-generic function, or a type parameter shadows a declared type.",
378 &["call"],
379 ),
380 dg(
381 "bynk.generics.uninferable_type_arg",
382 "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.",
383 &["call"],
384 ),
385 dg(
386 "bynk.given.cross_context_unknown_capability",
387 "`given B.Cap` names a capability the consumed context does not export.",
388 &["given_clause"],
389 ),
390 dg(
391 "bynk.given.undeclared_capability",
392 "A handler uses a capability it did not declare with `given`.",
393 &["given_clause"],
394 ),
395 dg(
396 "bynk.given.unknown_capability",
397 "`given` names a capability that does not exist.",
398 &["given_clause"],
399 ),
400 dg(
401 "bynk.given.unused_capability",
402 "A `given` capability is never used (warning).",
403 &["given_clause"],
404 ),
405 d(
406 "bynk.held.branch_divergence",
407 "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).",
408 ),
409 d(
410 "bynk.held.consume_on_borrow",
411 "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).",
412 ),
413 d(
414 "bynk.held.leak",
415 "A held value (`Connection[F]`) is still owned at scope exit — it must be disposed (stored, closed, or transferred) before the handler returns (§2.9.1, real-time track slice 2).",
416 ),
417 d(
418 "bynk.held.unsupported_map_op",
419 "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).",
420 ),
421 d(
422 "bynk.held.unsupported_storage",
423 "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).",
424 ),
425 d(
426 "bynk.held.use_after_consume",
427 "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).",
428 ),
429 dg(
430 "bynk.http.body_on_get_or_delete",
431 "A GET or DELETE handler declares a `body` parameter.",
432 &["http_handler"],
433 ),
434 dg(
435 "bynk.http.duplicate_route",
436 "Two handlers share the same method and route.",
437 &["http_handler"],
438 ),
439 dg(
440 "bynk.http.extra_param",
441 "A handler parameter is neither a path parameter nor `body`.",
442 &["http_handler"],
443 ),
444 dg(
445 "bynk.http.invalid_path",
446 "An HTTP route path is malformed.",
447 &["http_handler"],
448 ),
449 dg(
450 "bynk.http.path_param_not_stringy",
451 "A path parameter's type is not constructible from a string.",
452 &["http_handler"],
453 ),
454 dg(
455 "bynk.http.reserved_prefix",
456 "A route uses the reserved `/_bynk/` prefix.",
457 &["http_handler"],
458 ),
459 dg(
460 "bynk.http.return_not_effect_http_result",
461 "An HTTP handler does not return `Effect[HttpResult[T]]`.",
462 &["http_handler"],
463 ),
464 dg(
465 "bynk.http.unbound_path_param",
466 "A `:name` route segment has no matching handler parameter.",
467 &["http_handler"],
468 ),
469 d(
470 "bynk.index.bad_argument",
471 "An `@indexed` argument is not a `by: <field>` label.",
472 ),
473 d(
474 "bynk.index.missing",
475 "A query filters a map by equality on a field that is not `@indexed` (a perf-hint warning).",
476 ),
477 d(
478 "bynk.index.unkeyable_key",
479 "An `@indexed(by: k)` field is not value-keyable.",
480 ),
481 d(
482 "bynk.index.unknown_key",
483 "An `@indexed(by: k)` field is not a field of the map's value type.",
484 ),
485 d(
486 "bynk.index.unused",
487 "A declared `@indexed(by: k)` is never used by an equality filter (a hygiene warning).",
488 ),
489 dg(
490 "bynk.integration.duplicate_participant",
491 "A context is listed more than once in a `wires` clause.",
492 &["wires_decl"],
493 ),
494 dg(
495 "bynk.integration.duplicate_suite",
496 "Two integration tests share the same suite name.",
497 &["integration_decl"],
498 ),
499 dg(
500 "bynk.integration.mock_in_integration",
501 "`mocks` is not allowed in an integration test.",
502 &["mocks_decl"],
503 ),
504 dg(
505 "bynk.integration.too_few_participants",
506 "An integration test wires fewer than two contexts.",
507 &["wires_decl"],
508 ),
509 dg(
510 "bynk.integration.unknown_participant",
511 "A `wires` clause names something that is not a declared context.",
512 &["wires_decl"],
513 ),
514 dg(
515 "bynk.integration.unwired_dependency",
516 "A participant consumes a context that is not wired into the integration test.",
517 &["integration_decl"],
518 ),
519 d(
520 "bynk.invariant.cross_agent_reference",
521 "An invariant predicate references another agent; invariants are per-agent.",
522 ),
523 d(
524 "bynk.invariant.duplicate_name",
525 "An agent declares two invariants with the same name.",
526 ),
527 d(
528 "bynk.invariant.impure_predicate",
529 "An invariant predicate uses an effectful or test-only construct.",
530 ),
531 d(
532 "bynk.invariant.not_bool",
533 "An invariant predicate does not have type `Bool`.",
534 ),
535 dg(
536 "bynk.lambda.unannotated_param",
537 "A lambda parameter has no type annotation in a position where no function type is expected to infer it from.",
538 &["lambda_expr"],
539 ),
540 dg(
541 "bynk.lex.bad_escape",
542 "An invalid escape sequence in a string literal.",
543 &["string_literal"],
544 ),
545 dg(
546 "bynk.lex.float_literal_overflow",
547 "A float literal does not fit a finite 64-bit float.",
548 &["float_literal"],
549 ),
550 dg(
551 "bynk.lex.integer_overflow",
552 "An integer literal is out of range.",
553 &["number_literal"],
554 ),
555 d(
556 "bynk.lex.unclosed_doc_block",
557 "A documentation block is not closed.",
558 ),
559 d(
560 "bynk.lex.unexpected_character",
561 "An unexpected character in the source.",
562 ),
563 dg(
564 "bynk.lex.unterminated_interpolation",
565 "An interpolation hole `\\(…)` is not closed on its line.",
566 &["string_literal"],
567 ),
568 dg(
569 "bynk.lex.unterminated_string",
570 "A string literal is not terminated.",
571 &["string_literal"],
572 ),
573 d(
574 "bynk.list.deprecated_function",
575 "A `bynk.list` free function (`map`/`filter`/`find`/`any`/`all`) is deprecated in favour of the `List` method form (warning; auto-fixable).",
576 ),
577 dg(
578 "bynk.mock.arity",
579 "`Mock[T]` was given the wrong number of pin arguments.",
580 &["mock_expr"],
581 ),
582 dg(
583 "bynk.mock.duplicate_target",
584 "A `mocks` target is declared more than once.",
585 &["mocks_decl"],
586 ),
587 dg(
588 "bynk.mock.in_commons_test",
589 "`mocks` used in a commons test, where there is no dependency to inject.",
590 &["mocks_decl"],
591 ),
592 dg(
593 "bynk.mock.literal_violates",
594 "A pinned `Mock[T]` value violates the type's refinement.",
595 &["mock_expr"],
596 ),
597 dg(
598 "bynk.mock.needs_pin",
599 "A bare `Mock[T]` cannot generate a value (e.g. a `Matches` string); pin one.",
600 &["mock_expr"],
601 ),
602 dg(
603 "bynk.mock.outside_test",
604 "`Mock[T]` was used outside a test case body.",
605 &["mock_expr"],
606 ),
607 dg(
608 "bynk.mock.pin_not_literal",
609 "A `Mock[T]` pin argument is not a compile-time literal.",
610 &["mock_expr"],
611 ),
612 dg(
613 "bynk.mock.pin_unsupported",
614 "A pin was given for a type kind that does not support pinning.",
615 &["mock_expr"],
616 ),
617 dg(
618 "bynk.mock.signature_mismatch",
619 "A `mocks` implementation's signature does not match the capability.",
620 &["mocks_decl"],
621 ),
622 dg(
623 "bynk.mock.unknown_target",
624 "`mocks` names a capability that is not in scope.",
625 &["mocks_decl"],
626 ),
627 dg(
628 "bynk.mock.unknown_type",
629 "`Mock[T]` names a type that does not resolve.",
630 &["mock_expr"],
631 ),
632 dg(
633 "bynk.mock.unsupported_kind",
634 "`Mock[T]` cannot fabricate a value for this kind of type.",
635 &["mock_expr"],
636 ),
637 d(
638 "bynk.namespace.reserved",
639 "A user unit is named `bynk` or `bynk.*`; the `bynk` root is reserved for the toolchain.",
640 ),
641 dg(
642 "bynk.parse.consumes_after_decls",
643 "`consumes` appears after other declarations.",
644 &["consumes_decl"],
645 ),
646 dg(
647 "bynk.parse.empty_agent",
648 "An `agent` body is empty.",
649 &["agent_decl"],
650 ),
651 dg(
652 "bynk.parse.empty_capability",
653 "A `capability` body is empty.",
654 &["capability_decl"],
655 ),
656 d(
657 "bynk.parse.empty_interpolation",
658 "An interpolation hole `\\(…)` contains no expression.",
659 ),
660 dg(
661 "bynk.parse.empty_match",
662 "A `match` has no arms.",
663 &["match_expr"],
664 ),
665 dg(
666 "bynk.parse.empty_mock_body",
667 "A `mocks` body is empty.",
668 &["mocks_decl"],
669 ),
670 dg(
671 "bynk.parse.empty_service",
672 "A `service` body is empty.",
673 &["service_decl"],
674 ),
675 dg(
676 "bynk.parse.expected_agent_key",
677 "Expected a `key` declaration in an agent.",
678 &["agent_decl"],
679 ),
680 d(
681 "bynk.parse.expected_agent_storage",
682 "An agent declares no storage — it has no `store` fields.",
683 ),
684 dg(
685 "bynk.parse.expected_base_type",
686 "Expected a base type.",
687 &["base_type"],
688 ),
689 dg(
690 "bynk.parse.expected_capability_op",
691 "Expected a capability operation.",
692 &["capability_op"],
693 ),
694 d("bynk.parse.expected_expression", "Expected an expression."),
695 dg(
696 "bynk.parse.expected_handler",
697 "Expected a handler.",
698 &["handler"],
699 ),
700 d("bynk.parse.expected_item", "Expected a declaration."),
701 dg(
702 "bynk.parse.expected_predicate",
703 "Expected a refinement predicate.",
704 &["refinement"],
705 ),
706 dg(
707 "bynk.parse.expected_provider_op",
708 "Expected a provider operation.",
709 &["provider_op"],
710 ),
711 d("bynk.parse.expected_token", "Expected a specific token."),
712 d("bynk.parse.expected_type", "Expected a type."),
713 d(
714 "bynk.parse.expected_unit_header",
715 "Expected a `commons` or `context` header.",
716 ),
717 dg(
718 "bynk.parse.expected_visibility",
719 "Expected a visibility keyword.",
720 &["exports_decl"],
721 ),
722 dg(
723 "bynk.parse.exports_after_decls",
724 "`exports` appears after other declarations.",
725 &["exports_decl"],
726 ),
727 d(
728 "bynk.parse.extra_tokens",
729 "Unexpected tokens after an otherwise complete construct.",
730 ),
731 dg(
732 "bynk.parse.generic_arg_count",
733 "Wrong number of generic type arguments.",
734 &["generic_type_ref"],
735 ),
736 dg(
737 "bynk.parse.handler_in_agent",
738 "A protocol handler (`on GET`/`schedule`/`message`) was declared in an agent.",
739 &["handler"],
740 ),
741 d(
742 "bynk.parse.invariant_after_handler",
743 "An `invariant` was declared after a handler; invariants precede handlers.",
744 ),
745 dg(
746 "bynk.parse.malformed_float_literal",
747 "A float literal is missing a digit on one side of the `.` (`1.`, `.5`).",
748 &["float_literal"],
749 ),
750 dg(
751 "bynk.parse.non_associative",
752 "A non-associative operator was chained (e.g. `a == b == c`).",
753 &["binary_expr"],
754 ),
755 d(
756 "bynk.parse.orphan_doc_block",
757 "A documentation block is not attached to a declaration (warning).",
758 ),
759 dg(
760 "bynk.parse.reserved_keyword",
761 "A reserved keyword was used as an identifier.",
762 &["identifier"],
763 ),
764 dg(
765 "bynk.parse.self_outside_method",
766 "`self` used outside a method or handler.",
767 &["self_expr"],
768 ),
769 d(
770 "bynk.parse.storage_after_phase",
771 "Agent storage (`state` / `store`) is declared after the invariants or handlers.",
772 ),
773 d(
774 "bynk.parse.unexpected_adapter",
775 "An `adapter` appeared where it is not allowed.",
776 ),
777 dg(
778 "bynk.parse.unexpected_context",
779 "A `context` appeared where it is not allowed.",
780 &["context_decl"],
781 ),
782 d("bynk.parse.unexpected_eof", "Unexpected end of input."),
783 dg(
784 "bynk.parse.unexpected_test",
785 "A `test` appeared where it is not allowed.",
786 &["test_decl"],
787 ),
788 d(
789 "bynk.parse.unknown_effect_method",
790 "An unknown method on `Effect`.",
791 ),
792 dg(
793 "bynk.parse.unknown_handler_kind",
794 "An unknown handler form (expected `call`, an HTTP method, `schedule`, or `message`).",
795 &["handler"],
796 ),
797 dg(
798 "bynk.parse.unknown_predicate",
799 "An unknown refinement predicate.",
800 &["predicate_name"],
801 ),
802 dg(
803 "bynk.parse.uses_after_decls",
804 "`uses` appears after other declarations.",
805 &["uses_decl"],
806 ),
807 d(
808 "bynk.project.file_and_directory",
809 "A unit exists as both a file and a directory.",
810 ),
811 d(
812 "bynk.project.inconsistent_commons_name",
813 "A source file's path does not match its declared name.",
814 ),
815 d(
816 "bynk.project.inconsistent_test_path",
817 "A test file's path does not match its target's name.",
818 ),
819 d(
820 "bynk.project.kind_conflict",
821 "A name is declared as both a commons and a context.",
822 ),
823 d(
824 "bynk.project.no_root",
825 "No project root could be determined.",
826 ),
827 d(
828 "bynk.project.no_sources",
829 "The project contains no source files.",
830 ),
831 d(
832 "bynk.project.read_failed",
833 "A source file could not be read.",
834 ),
835 dg(
836 "bynk.provider.dependency_cycle",
837 "Providers form a capability dependency cycle through `given`.",
838 &["provider_decl"],
839 ),
840 dg(
841 "bynk.provider.extra_operation",
842 "A `provides` block implements an operation not in the capability.",
843 &["provider_decl"],
844 ),
845 dg(
846 "bynk.provider.missing_operation",
847 "A `provides` block is missing a capability operation.",
848 &["provider_decl"],
849 ),
850 dg(
851 "bynk.provider.outside_context",
852 "`provides` was declared outside a context.",
853 &["provider_decl"],
854 ),
855 dg(
856 "bynk.provider.signature_mismatch",
857 "A `provides` operation's signature does not match the capability.",
858 &["provider_decl"],
859 ),
860 dg(
861 "bynk.provider.unknown_capability",
862 "`provides` names a capability that does not exist.",
863 &["provider_decl"],
864 ),
865 d(
866 "bynk.query.join_key_mismatch",
867 "A `joinOn`/`leftJoin` left and right key function return different types.",
868 ),
869 dg(
870 "bynk.query.sum_needs_numeric",
871 "A `sum`/`average` key function does not return a numeric type (`Int`, `Float`, or `Duration`).",
872 &[],
873 ),
874 dg(
875 "bynk.queue.bad_params",
876 "An `on message` handler does not take exactly one `message` parameter.",
877 &["queue_handler"],
878 ),
879 dg(
880 "bynk.queue.duplicate_consumer",
881 "Two `on message` handlers consume the same queue.",
882 &["queue_handler"],
883 ),
884 dg(
885 "bynk.queue.invalid_name",
886 "A `from queue(\"…\")` binding has an empty queue name.",
887 &["queue_handler"],
888 ),
889 dg(
890 "bynk.queue.return_not_queue_result",
891 "An `on message` handler does not return `Effect[QueueResult]`.",
892 &["handler"],
893 ),
894 dg(
895 "bynk.record_spread.field_type_mismatch",
896 "A record-spread override has the wrong type for the field.",
897 &["record_spread"],
898 ),
899 dg(
900 "bynk.record_spread.non_record_base",
901 "The base of a record spread is not a record.",
902 &["record_spread"],
903 ),
904 dg(
905 "bynk.record_spread.type_mismatch",
906 "A record spread's base is a different record type.",
907 &["record_spread"],
908 ),
909 dg(
910 "bynk.record_spread.unknown_field",
911 "A record spread overrides a field the record does not have.",
912 &["record_spread"],
913 ),
914 dg(
915 "bynk.refine.literal_violates",
916 "A literal does not satisfy the refined type's predicate.",
917 &["refined_type"],
918 ),
919 dg(
920 "bynk.requires.unpinned_dependency",
921 "An adapter `binding … requires { … }` entry has an unpinned version range.",
922 &["binding_decl"],
923 ),
924 d(
925 "bynk.resolve.ambiguous_variant",
926 "A variant name is ambiguous across several sum types.",
927 ),
928 dg(
929 "bynk.resolve.arity_mismatch",
930 "A function was called with the wrong number of arguments.",
931 &["call"],
932 ),
933 d("bynk.resolve.duplicate_actor", "Two actors share a name."),
934 dg(
935 "bynk.resolve.duplicate_agent",
936 "Two agents share a name.",
937 &["agent_decl"],
938 ),
939 dg(
940 "bynk.resolve.duplicate_capability",
941 "Two capabilities share a name.",
942 &["capability_decl"],
943 ),
944 dg(
945 "bynk.resolve.duplicate_field",
946 "A record declares a field twice.",
947 &["record_type"],
948 ),
949 dg(
950 "bynk.resolve.duplicate_field_init",
951 "A record construction initialises a field twice.",
952 &["record_construction"],
953 ),
954 dg(
955 "bynk.resolve.duplicate_fn",
956 "Two functions share a name.",
957 &["fn_decl"],
958 ),
959 dg(
960 "bynk.resolve.duplicate_method",
961 "Two methods share a name.",
962 &["fn_decl"],
963 ),
964 dg(
965 "bynk.resolve.duplicate_param",
966 "A parameter name is repeated.",
967 &["param"],
968 ),
969 dg(
970 "bynk.resolve.duplicate_provider",
971 "A capability is provided more than once.",
972 &["provider_decl"],
973 ),
974 dg(
975 "bynk.resolve.duplicate_service",
976 "Two services share a name.",
977 &["service_decl"],
978 ),
979 dg(
980 "bynk.resolve.duplicate_type",
981 "Two types share a name.",
982 &["type_decl"],
983 ),
984 dg(
985 "bynk.resolve.duplicate_variant",
986 "A sum type declares a variant twice.",
987 &["sum_type"],
988 ),
989 d(
990 "bynk.resolve.fn_without_call",
991 "A function was referenced without being called.",
992 ),
993 dg(
994 "bynk.resolve.let_shadows_fn",
995 "A `let` binding shadows a function.",
996 &["let_stmt"],
997 ),
998 dg(
999 "bynk.resolve.let_shadows_type",
1000 "A `let` binding shadows a type.",
1001 &["let_stmt"],
1002 ),
1003 d(
1004 "bynk.resolve.method_unknown_type",
1005 "A method is defined on an unknown type.",
1006 ),
1007 dg(
1008 "bynk.resolve.missing_field",
1009 "A record construction omits a required field.",
1010 &["record_construction"],
1011 ),
1012 d(
1013 "bynk.resolve.name_conflict",
1014 "Two declarations share a name.",
1015 ),
1016 dg(
1017 "bynk.resolve.not_a_record_type",
1018 "Record syntax was used on a non-record type.",
1019 &["record_construction"],
1020 ),
1021 dg(
1022 "bynk.resolve.opaque_record_construction",
1023 "An opaque type was constructed with record syntax.",
1024 &["record_construction"],
1025 ),
1026 dg(
1027 "bynk.resolve.param_as_function",
1028 "A value (such as a parameter) was called as a function.",
1029 &["call"],
1030 ),
1031 dg(
1032 "bynk.resolve.recursive_record_field",
1033 "A record directly contains a field of its own type.",
1034 &["record_type"],
1035 ),
1036 dg(
1037 "bynk.resolve.self_outside_method",
1038 "`self` referenced outside a method or handler.",
1039 &["self_expr"],
1040 ),
1041 dg(
1042 "bynk.resolve.type_as_function",
1043 "A type name was called as if it were a function.",
1044 &["call"],
1045 ),
1046 d(
1047 "bynk.resolve.type_in_expr",
1048 "A type name was used where a value is expected.",
1049 ),
1050 dg(
1051 "bynk.resolve.unconsumed_context",
1052 "A context's service was called without a `consumes` declaration.",
1053 &["consumes_decl"],
1054 ),
1055 dg(
1056 "bynk.resolve.unknown_field",
1057 "Accessed a field the record does not have.",
1058 &["field_access"],
1059 ),
1060 dg(
1061 "bynk.resolve.unknown_function",
1062 "Called a function that does not exist.",
1063 &["call"],
1064 ),
1065 d(
1066 "bynk.resolve.unknown_name",
1067 "Referenced a name that is not in scope.",
1068 ),
1069 dg(
1070 "bynk.resolve.unknown_static_member",
1071 "Referenced an unknown static member (e.g. `T.x`).",
1072 &["field_access"],
1073 ),
1074 d(
1075 "bynk.resolve.unknown_type",
1076 "Referenced a type that does not exist.",
1077 ),
1078 dg(
1079 "bynk.send.in_pure_context",
1080 "A `~>` send was used in a pure (non-effectful) context.",
1081 &["effect_send_stmt"],
1082 ),
1083 dg(
1084 "bynk.send.non_effect",
1085 "A `~>` send was applied to a non-`Effect` value.",
1086 &["effect_send_stmt"],
1087 ),
1088 dg(
1089 "bynk.send.requires_unit",
1090 "A `~>` send targets an operation whose reply is not `Effect[()]`.",
1091 &["effect_send_stmt"],
1092 ),
1093 dg(
1094 "bynk.service.missing_from",
1095 "A `from`-less service has a handler other than `on call`.",
1096 &["service_decl"],
1097 ),
1098 dg(
1099 "bynk.service.mixed_protocols",
1100 "A service mixes handler forms that do not match its `from <protocol>`.",
1101 &["service_decl"],
1102 ),
1103 dg(
1104 "bynk.service.outside_context",
1105 "A `service` was declared outside a context.",
1106 &["service_decl"],
1107 ),
1108 dg(
1109 "bynk.service.return_not_effect",
1110 "A service handler's return type is not an `Effect`.",
1111 &["service_decl"],
1112 ),
1113 dg(
1114 "bynk.service.unknown_protocol",
1115 "A `from <protocol>` names an unknown protocol (e.g. a transport like Kafka).",
1116 &["service_decl"],
1117 ),
1118 d(
1119 "bynk.service.websocket_header",
1120 "The `from WebSocket` header is malformed — it binds frame types as `WebSocket(in: <type>, out: <type>)` (real-time track slice 3).",
1121 ),
1122 d(
1123 "bynk.service.websocket_multiple",
1124 "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).",
1125 ),
1126 d(
1127 "bynk.service.websocket_open_arity",
1128 "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).",
1129 ),
1130 d(
1131 "bynk.store.annotation_kind_mismatch",
1132 "A storage annotation is used on a kind it does not apply to (e.g. `@ttl` on a `Map`).",
1133 ),
1134 d(
1135 "bynk.store.annotation_unsupported",
1136 "A known storage annotation (`@ttl`/`@retain`/`@indexed`/`@bounded`) is used before the slice that supports it.",
1137 ),
1138 d(
1139 "bynk.store.cache_needs_clock",
1140 "A handler performs a `Cache` operation (TTL expiry reads the clock) without declaring `given Clock`.",
1141 ),
1142 d(
1143 "bynk.store.cache_ttl_required",
1144 "A `Cache` field is missing its required `@ttl(<duration>)` annotation (a keyed store with no expiry is a `Map`).",
1145 ),
1146 d(
1147 "bynk.store.kind_arity",
1148 "A storage kind was applied to the wrong number of type arguments (e.g. `Cell[A, B]`).",
1149 ),
1150 d(
1151 "bynk.store.kind_unsupported",
1152 "A known storage kind (`Queue`) is used before the slice that supports it.",
1153 ),
1154 d(
1155 "bynk.store.log_needs_clock",
1156 "A handler calls `Log.append` (which stamps the current time) without declaring `given Clock`.",
1157 ),
1158 d(
1159 "bynk.store.unknown_annotation",
1160 "A `store` field carries an annotation outside the closed `@indexed`/`@ttl`/`@retain`/`@bounded` set.",
1161 ),
1162 d(
1163 "bynk.store.unknown_kind",
1164 "A `store` field's type is not a known storage kind.",
1165 ),
1166 d(
1167 "bynk.store.unknown_op",
1168 "A storage-`Map`/`Set` operation is not a recognised entry/membership method.",
1169 ),
1170 d(
1171 "bynk.target.browser_bundle_only",
1172 "The `browser` platform builds only the in-process `Bundle` topology; `--target workers` is not a browser build.",
1173 ),
1174 dg(
1175 "bynk.target.vendor_conflict",
1176 "One deployment unit's in-process closure uses platform-native capabilities from two mutually-exclusive platforms.",
1177 &["consumes_decl"],
1178 ),
1179 dg(
1180 "bynk.target.vendor_required",
1181 "A deployment unit uses a platform-native capability but the build selects another `--platform`.",
1182 &["consumes_decl"],
1183 ),
1184 dg(
1185 "bynk.test.duplicate_case_name",
1186 "Two test cases share a description.",
1187 &["test_case"],
1188 ),
1189 dg(
1190 "bynk.test.unknown_target",
1191 "A `test` block targets a unit that does not exist.",
1192 &["test_decl"],
1193 ),
1194 d(
1195 "bynk.types.ambiguous_constructor",
1196 "`Ok`/`Err` is ambiguous between `Result` and `HttpResult`; qualify it.",
1197 ),
1198 dg(
1199 "bynk.types.argument_mismatch",
1200 "A function argument has the wrong type.",
1201 &["call"],
1202 ),
1203 dg(
1204 "bynk.types.call_arity",
1205 "A function value was applied with the wrong number of arguments.",
1206 &["call"],
1207 ),
1208 dg(
1209 "bynk.types.cannot_infer_option_type_param",
1210 "The value type of `None` could not be inferred.",
1211 &["none_expr"],
1212 ),
1213 d(
1214 "bynk.types.cannot_infer_result_type_params",
1215 "The type parameters of a `Result` could not be inferred.",
1216 ),
1217 d(
1218 "bynk.types.constructor_arity",
1219 "A variant constructor got the wrong number of arguments.",
1220 ),
1221 d(
1222 "bynk.types.constructor_base_mismatch",
1223 "A `.of` constructor was given an argument of the wrong base type.",
1224 ),
1225 dg(
1226 "bynk.types.duplicate_variant_arm",
1227 "A `match` has two arms for the same variant.",
1228 &["match_arm"],
1229 ),
1230 dg(
1231 "bynk.types.empty_refinement",
1232 "A refinement admits no values (contradictory predicates).",
1233 &["refinement"],
1234 ),
1235 dg(
1236 "bynk.types.err_value_mismatch",
1237 "An `Err` payload has the wrong type.",
1238 &["err_expr"],
1239 ),
1240 dg(
1241 "bynk.types.field_access_on_non_record",
1242 "Field access on a value that is not a record.",
1243 &["field_access"],
1244 ),
1245 dg(
1246 "bynk.types.field_refinement_not_base",
1247 "An inline field refinement requires a base or refined type.",
1248 &["record_field"],
1249 ),
1250 dg(
1251 "bynk.types.field_value_mismatch",
1252 "A record field was given a value of the wrong type.",
1253 &["record_construction"],
1254 ),
1255 dg(
1256 "bynk.types.function_at_boundary",
1257 "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.",
1258 &["function_type_ref"],
1259 ),
1260 d(
1261 "bynk.types.held_at_boundary",
1262 "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).",
1263 ),
1264 d(
1265 "bynk.types.held_not_comparable",
1266 "A held value (`Connection[F]`) is compared with `==`/`!=` — held values have identity, not value-equality (§2.9.3, real-time track slice 2).",
1267 ),
1268 dg(
1269 "bynk.types.if_branch_mismatch",
1270 "The branches of an `if` have different types.",
1271 &["if_expr"],
1272 ),
1273 dg(
1274 "bynk.types.if_non_bool_cond",
1275 "An `if` condition is not a `Bool`.",
1276 &["if_expr"],
1277 ),
1278 d(
1279 "bynk.types.interpolation_non_scalar",
1280 "An interpolation hole holds a value with no string form.",
1281 ),
1282 dg(
1283 "bynk.types.invalid_regex",
1284 "A `Matches` predicate contains an invalid regular expression.",
1285 &["refinement"],
1286 ),
1287 dg(
1288 "bynk.types.inverted_range",
1289 "An `InRange` predicate has its bounds inverted.",
1290 &["refinement"],
1291 ),
1292 dg(
1293 "bynk.types.is_base_mismatch",
1294 "An `is` refinement check is applied to a value of the wrong base type.",
1295 &["is_expr"],
1296 ),
1297 dg(
1298 "bynk.types.is_non_sum",
1299 "`is` was applied to a value that is not a sum type.",
1300 &["is_expr"],
1301 ),
1302 dg(
1303 "bynk.types.is_unknown_variant",
1304 "`is` names a variant the type does not have.",
1305 &["is_expr"],
1306 ),
1307 dg(
1308 "bynk.types.json_uncodable",
1309 "A `Json.encode`/`Json.decode` target type cannot pass through the typed JSON codec (functions, effects, error builtins).",
1310 &["method_call"],
1311 ),
1312 dg(
1313 "bynk.types.key_not_orderable",
1314 "A `sortBy`/`min`/`max` key function does not return an orderable type (`Int`, `Float`, `String`, `Duration`, or `Instant`).",
1315 &[],
1316 ),
1317 dg(
1318 "bynk.types.lambda_mismatch",
1319 "A lambda's parameter count, parameter annotations, or body type do not match the expected function type.",
1320 &["lambda_expr"],
1321 ),
1322 dg(
1323 "bynk.types.let_annotation_mismatch",
1324 "A `let` value does not match its type annotation.",
1325 &["let_stmt"],
1326 ),
1327 dg(
1328 "bynk.types.list_element_mismatch",
1329 "A list-literal element has a different type from the list's element type.",
1330 &["list_literal"],
1331 ),
1332 dg(
1333 "bynk.types.match_arm_mismatch",
1334 "A `match` arm has a different type from the others.",
1335 &["match_arm"],
1336 ),
1337 dg(
1338 "bynk.types.match_non_sum_discriminant",
1339 "`match` was applied to a value that is not a sum type.",
1340 &["match_expr"],
1341 ),
1342 dg(
1343 "bynk.types.method_arity",
1344 "A method was called with the wrong number of arguments.",
1345 &["method_call"],
1346 ),
1347 dg(
1348 "bynk.types.method_not_found",
1349 "Called a method the type does not have.",
1350 &["method_call"],
1351 ),
1352 dg(
1353 "bynk.types.method_on_non_named_type",
1354 "A method was called on a built-in type that has no methods.",
1355 &["method_call"],
1356 ),
1357 dg(
1358 "bynk.types.mixed_pattern_bindings",
1359 "A pattern mixes named and positional bindings.",
1360 &["variant_pattern"],
1361 ),
1362 dg(
1363 "bynk.types.negative_length",
1364 "A length predicate was given a negative value.",
1365 &["refinement"],
1366 ),
1367 dg(
1368 "bynk.types.no_numeric_coercion",
1369 "`Int` and `Float` were mixed without an explicit conversion — in an operation or in refinement bounds.",
1370 &["binary_expr", "refinement"],
1371 ),
1372 dg(
1373 "bynk.types.non_exhaustive_match",
1374 "A `match` does not cover every variant.",
1375 &["match_expr"],
1376 ),
1377 dg(
1378 "bynk.types.ok_value_mismatch",
1379 "An `Ok` payload has the wrong type.",
1380 &["ok_expr"],
1381 ),
1382 dg(
1383 "bynk.types.opaque_raw_outside",
1384 "`.raw` on an opaque type was used outside its defining commons.",
1385 &["field_access"],
1386 ),
1387 dg(
1388 "bynk.types.opaque_record_construction",
1389 "An opaque type was constructed with record syntax.",
1390 &["record_construction"],
1391 ),
1392 dg(
1393 "bynk.types.opaque_unsafe_outside",
1394 "`.unsafe` on an opaque type was used outside its defining context.",
1395 &["field_access"],
1396 ),
1397 dg(
1398 "bynk.types.pattern_arity",
1399 "A pattern binds the wrong number of payload fields.",
1400 &["variant_pattern"],
1401 ),
1402 dg(
1403 "bynk.types.pattern_type_mismatch",
1404 "A pattern's type does not match the matched value.",
1405 &["variant_pattern"],
1406 ),
1407 dg(
1408 "bynk.types.predicate_base_mismatch",
1409 "A predicate does not apply to the type's base (e.g. a string predicate on an `Int`).",
1410 &["refinement"],
1411 ),
1412 d(
1413 "bynk.types.query_at_boundary",
1414 "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).",
1415 ),
1416 dg(
1417 "bynk.types.question_error_mismatch",
1418 "`?` propagates an error type incompatible with the function's.",
1419 &["question_expr"],
1420 ),
1421 dg(
1422 "bynk.types.question_on_non_result",
1423 "`?` was applied to a non-`Result` value.",
1424 &["question_expr"],
1425 ),
1426 dg(
1427 "bynk.types.question_outside_result",
1428 "`?` used in a function that does not return a `Result`.",
1429 &["question_expr"],
1430 ),
1431 d(
1432 "bynk.types.return_mismatch",
1433 "A returned value does not match the declared return type.",
1434 ),
1435 dg(
1436 "bynk.types.some_value_mismatch",
1437 "A `Some` payload has the wrong type.",
1438 &["some_expr"],
1439 ),
1440 d(
1441 "bynk.types.stream_at_boundary",
1442 "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).",
1443 ),
1444 d(
1445 "bynk.types.stream_not_comparable",
1446 "A `Stream` value is compared with `==`/`!=` — a stream is a live value-over-time source, not a comparable value (real-time track slice 0).",
1447 ),
1448 d(
1449 "bynk.types.type_mismatch",
1450 "Two types that were required to match did not.",
1451 ),
1452 dg(
1453 "bynk.types.uninferable_element_type",
1454 "An empty `[]` (or `List.empty()` / `Map.empty()`) has no expected type to infer its element type from.",
1455 &["list_literal"],
1456 ),
1457 dg(
1458 "bynk.types.unkeyable_distinct",
1459 "A `distinct`/`distinctBy` element or key is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
1460 &[],
1461 ),
1462 dg(
1463 "bynk.types.unkeyable_map_key",
1464 "A `Map` key type is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
1465 &["generic_type_ref"],
1466 ),
1467 dg(
1468 "bynk.types.unknown_field",
1469 "Referenced a field the record type does not declare.",
1470 &["field_access"],
1471 ),
1472 dg(
1473 "bynk.types.unknown_pattern_field",
1474 "A pattern names a field the variant does not have.",
1475 &["variant_pattern"],
1476 ),
1477 dg(
1478 "bynk.types.unknown_static_member",
1479 "Referenced an unknown static member on a type.",
1480 &["field_access"],
1481 ),
1482 dg(
1483 "bynk.types.unknown_variant_in_pattern",
1484 "A pattern names a variant the sum type does not have.",
1485 &["variant_pattern"],
1486 ),
1487 dg(
1488 "bynk.types.unreachable_arm",
1489 "A `match` arm is unreachable.",
1490 &["match_arm"],
1491 ),
1492 d(
1493 "bynk.types.variant_arity",
1494 "A variant constructor got the wrong number of payload values.",
1495 ),
1496 d(
1497 "bynk.types.variant_missing_payload",
1498 "A variant requiring a payload was used without one.",
1499 ),
1500 d(
1501 "bynk.types.variant_payload_mismatch",
1502 "A variant payload has the wrong type.",
1503 ),
1504 dg(
1505 "bynk.uses.name_conflict",
1506 "A `uses` name collides with another name.",
1507 &["uses_decl"],
1508 ),
1509 dg(
1510 "bynk.uses.self_reference",
1511 "A commons `uses` itself.",
1512 &["uses_decl"],
1513 ),
1514 dg(
1515 "bynk.uses.target_is_context",
1516 "`uses` targets a context instead of a commons.",
1517 &["uses_decl"],
1518 ),
1519 dg(
1520 "bynk.uses.unknown_commons",
1521 "`uses` names a commons that does not exist.",
1522 &["uses_decl"],
1523 ),
1524 d(
1525 "bynk.ws.message_frame_param",
1526 "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).",
1527 ),
1528 d(
1529 "bynk.ws.open_given_unsupported",
1530 "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).",
1531 ),
1532 d(
1533 "bynk.ws.open_transfer_shape",
1534 "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).",
1535 ),
1536 d(
1537 "bynk.ws.route_param_mismatch",
1538 "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).",
1539 ),
1540];
1541
1542const fn d(code: &'static str, summary: &'static str) -> DiagnosticInfo {
1544 DiagnosticInfo {
1545 code,
1546 summary,
1547 grammar_symbol: &[],
1548 }
1549}
1550
1551const fn dg(
1553 code: &'static str,
1554 summary: &'static str,
1555 grammar_symbol: &'static [&'static str],
1556) -> DiagnosticInfo {
1557 DiagnosticInfo {
1558 code,
1559 summary,
1560 grammar_symbol,
1561 }
1562}
1563
1564pub fn category(code: &str) -> &str {
1567 code.split('.').nth(1).unwrap_or("")
1568}
1569
1570fn category_title(cat: &str) -> &'static str {
1572 match cat {
1573 "agent" | "agents" => "Agents",
1574 "assert" => "Assertions",
1575 "boundary" => "Boundaries",
1576 "capability" => "Capabilities",
1577 "consumes" => "Consumes",
1578 "context" => "Contexts",
1579 "cron" => "Cron",
1580 "effect" => "Effects",
1581 "exports" => "Exports",
1582 "given" => "Given capabilities",
1583 "http" => "HTTP",
1584 "lex" => "Lexer",
1585 "mock" => "Mock and mocks",
1586 "parse" => "Parser",
1587 "project" => "Project",
1588 "provider" => "Providers",
1589 "queue" => "Queue",
1590 "record_spread" => "Record spread",
1591 "refine" => "Refinement",
1592 "resolve" => "Resolution",
1593 "service" => "Services",
1594 "test" => "Tests",
1595 "types" => "Type checking",
1596 "uses" => "Uses",
1597 _ => "Other",
1598 }
1599}
1600
1601pub fn render_markdown() -> String {
1604 use std::collections::BTreeMap;
1605
1606 let mut by_category: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
1608 for info in REGISTRY {
1609 by_category
1610 .entry(category_title(category(info.code)))
1611 .or_default()
1612 .push(info);
1613 }
1614
1615 let mut out = String::new();
1616 out.push_str("# Diagnostic index\n\n");
1617 out.push_str(
1618 "<!-- GENERATED FILE — do not edit by hand.\n \
1619 Source: bynkc/src/diagnostics.rs (`render_markdown`).\n \
1620 Regenerate with: BYNK_BLESS=1 cargo test -p bynkc --test diagnostics_registry -->\n\n",
1621 );
1622 out.push_str(
1623 "Every diagnostic code the compiler can emit, with a one-line summary of \
1624 the cause, grouped by category. For step-by-step cause-and-fix guidance \
1625 on the most common ones, see the [troubleshooting guides](../troubleshooting/index.md).\n\n",
1626 );
1627 out.push_str(&format!(
1628 "There are **{}** codes in total.\n",
1629 REGISTRY.len()
1630 ));
1631
1632 for (title, infos) in &by_category {
1633 out.push_str(&format!("\n## {title}\n\n"));
1634 out.push_str("| Code | Summary | Construct |\n|---|---|---|\n");
1635 for info in infos {
1636 let construct = info
1641 .grammar_symbol
1642 .iter()
1643 .map(|sym| format!("[`{sym}`](grammar.md#rule-{sym})"))
1644 .collect::<Vec<_>>()
1645 .join(", ");
1646 out.push_str(&format!(
1647 "| `{}` | {} | {} |\n",
1648 info.code, info.summary, construct
1649 ));
1650 }
1651 }
1652
1653 out
1654}
1655
1656pub fn render_grammar_semantics_json() -> String {
1662 use std::collections::BTreeMap;
1663
1664 let mut by_symbol: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
1667 for info in REGISTRY {
1668 for sym in info.grammar_symbol {
1669 by_symbol.entry(sym).or_default().push(info);
1670 }
1671 }
1672
1673 let mut map = serde_json::Map::new();
1674 map.insert(
1675 "_generated".to_string(),
1676 serde_json::Value::String(
1677 "Generated from the grammar_symbol field of bynkc/src/diagnostics.rs. \
1678 Do not edit by hand. Regenerate with: BYNK_BLESS=1 cargo test -p \
1679 bynkc --test diagnostics_registry"
1680 .to_string(),
1681 ),
1682 );
1683 for (sym, infos) in by_symbol {
1684 let arr: Vec<serde_json::Value> = infos
1685 .iter()
1686 .map(|info| serde_json::json!({ "code": info.code, "summary": info.summary }))
1687 .collect();
1688 map.insert(sym.to_string(), serde_json::Value::Array(arr));
1689 }
1690
1691 let mut s =
1692 serde_json::to_string_pretty(&serde_json::Value::Object(map)).expect("serialise semantics");
1693 s.push('\n');
1694 s
1695}