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