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