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