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