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