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.reserved_keyword",
911 "A reserved keyword was used as an identifier.",
912 &["identifier"],
913 ),
914 dg(
915 "bynk.parse.self_outside_method",
916 "`self` used outside a method or handler.",
917 &["self_expr"],
918 ),
919 d(
920 "bynk.parse.storage_after_phase",
921 "Agent storage (`state` / `store`) is declared after the invariants or handlers.",
922 ),
923 d(
924 "bynk.parse.transition_after_handler",
925 "A `transition` is declared after an agent handler; step invariants precede the handlers.",
926 ),
927 d(
928 "bynk.parse.unexpected_adapter",
929 "An `adapter` appeared where it is not allowed.",
930 ),
931 dg(
932 "bynk.parse.unexpected_context",
933 "A `context` appeared where it is not allowed.",
934 &["context_decl"],
935 ),
936 d("bynk.parse.unexpected_eof", "Unexpected end of input."),
937 dg(
938 "bynk.parse.unexpected_suite",
939 "A `suite` appeared where it is not allowed.",
940 &["suite_decl"],
941 ),
942 d(
943 "bynk.parse.unknown_effect_method",
944 "An unknown method on `Effect`.",
945 ),
946 dg(
947 "bynk.parse.unknown_handler_kind",
948 "An unknown handler form (expected `call`, an HTTP method, `schedule`, or `message`).",
949 &["handler"],
950 ),
951 dg(
952 "bynk.parse.unknown_predicate",
953 "An unknown refinement predicate.",
954 &["predicate_name"],
955 ),
956 d(
957 "bynk.parse.unknown_tier",
958 "A `case`/`suite` `as <tier>` clause names something other than `unit`, `integration`, or `system`.",
959 ),
960 dg(
961 "bynk.parse.uses_after_decls",
962 "`uses` appears after other declarations.",
963 &["uses_decl"],
964 ),
965 dg(
966 "bynk.parse.variant_name_case",
967 "A sum-type or enum variant name is not capitalised.",
968 &["sum_variant", "enum_type"],
969 ),
970 d(
971 "bynk.project.file_and_directory",
972 "A unit exists as both a file and a directory.",
973 ),
974 d(
975 "bynk.project.inconsistent_commons_name",
976 "A source file's path does not match its declared name.",
977 ),
978 d(
979 "bynk.project.kind_conflict",
980 "A name is declared as both a commons and a context.",
981 ),
982 d(
983 "bynk.project.no_root",
984 "No project root could be determined.",
985 ),
986 d(
987 "bynk.project.no_sources",
988 "The project contains no source files.",
989 ),
990 d(
991 "bynk.project.read_failed",
992 "A source file could not be read.",
993 ),
994 dg(
995 "bynk.property.restates_refinement",
996 "A `property` merely re-checks a refinement its type already guarantees.",
997 &["for_all"],
998 ),
999 dg(
1000 "bynk.property.where_not_bool",
1001 "A `for all ... where` filter does not type to `Bool`.",
1002 &["for_all"],
1003 ),
1004 dg(
1005 "bynk.provider.dependency_cycle",
1006 "Providers form a capability dependency cycle through `given`.",
1007 &["provider_decl"],
1008 ),
1009 dg(
1010 "bynk.provider.extra_operation",
1011 "A `provides` block implements an operation not in the capability.",
1012 &["provider_decl"],
1013 ),
1014 dg(
1015 "bynk.provider.missing_operation",
1016 "A `provides` block is missing a capability operation.",
1017 &["provider_decl"],
1018 ),
1019 dg(
1020 "bynk.provider.outside_context",
1021 "`provides` was declared outside a context.",
1022 &["provider_decl"],
1023 ),
1024 dg(
1025 "bynk.provider.signature_mismatch",
1026 "A `provides` operation's signature does not match the capability.",
1027 &["provider_decl"],
1028 ),
1029 dg(
1030 "bynk.provider.unknown_capability",
1031 "`provides` names a capability that does not exist.",
1032 &["provider_decl"],
1033 ),
1034 d(
1035 "bynk.query.join_key_mismatch",
1036 "A `joinOn`/`leftJoin` left and right key function return different types.",
1037 ),
1038 dg(
1039 "bynk.query.sum_needs_numeric",
1040 "A `sum`/`average` key function does not return a numeric type (`Int`, `Float`, or `Duration`).",
1041 &[],
1042 ),
1043 dg(
1044 "bynk.queue.bad_params",
1045 "An `on message` handler does not take exactly one `message` parameter.",
1046 &["queue_handler"],
1047 ),
1048 dg(
1049 "bynk.queue.duplicate_consumer",
1050 "Two `on message` handlers consume the same queue.",
1051 &["queue_handler"],
1052 ),
1053 dg(
1054 "bynk.queue.invalid_name",
1055 "A `from queue(\"…\")` binding has an empty queue name.",
1056 &["queue_handler"],
1057 ),
1058 dg(
1059 "bynk.queue.return_not_queue_result",
1060 "An `on message` handler does not return `Effect[QueueResult]`.",
1061 &["handler"],
1062 ),
1063 dg(
1064 "bynk.record_spread.field_type_mismatch",
1065 "A record-spread override has the wrong type for the field.",
1066 &["record_spread"],
1067 ),
1068 dg(
1069 "bynk.record_spread.non_record_base",
1070 "The base of a record spread is not a record.",
1071 &["record_spread"],
1072 ),
1073 dg(
1074 "bynk.record_spread.type_mismatch",
1075 "A record spread's base is a different record type.",
1076 &["record_spread"],
1077 ),
1078 dg(
1079 "bynk.record_spread.unknown_field",
1080 "A record spread overrides a field the record does not have.",
1081 &["record_spread"],
1082 ),
1083 dg(
1084 "bynk.refine.literal_violates",
1085 "A literal does not satisfy the refined type's predicate.",
1086 &["refined_type"],
1087 ),
1088 dg(
1089 "bynk.requires.unpinned_dependency",
1090 "An adapter `binding … requires { … }` entry has an unpinned version range.",
1091 &["binding_decl"],
1092 ),
1093 d(
1094 "bynk.resolve.ambiguous_variant",
1095 "A variant name is ambiguous across several sum types.",
1096 ),
1097 dg(
1098 "bynk.resolve.arity_mismatch",
1099 "A function was called with the wrong number of arguments.",
1100 &["call"],
1101 ),
1102 d("bynk.resolve.duplicate_actor", "Two actors share a name."),
1103 dg(
1104 "bynk.resolve.duplicate_agent",
1105 "Two agents share a name.",
1106 &["agent_decl"],
1107 ),
1108 dg(
1109 "bynk.resolve.duplicate_capability",
1110 "Two capabilities share a name.",
1111 &["capability_decl"],
1112 ),
1113 dg(
1114 "bynk.resolve.duplicate_field",
1115 "A record declares a field twice.",
1116 &["record_type"],
1117 ),
1118 dg(
1119 "bynk.resolve.duplicate_field_init",
1120 "A record construction initialises a field twice.",
1121 &["record_construction"],
1122 ),
1123 dg(
1124 "bynk.resolve.duplicate_fn",
1125 "Two functions share a name.",
1126 &["fn_decl"],
1127 ),
1128 dg(
1129 "bynk.resolve.duplicate_method",
1130 "Two methods share a name.",
1131 &["fn_decl"],
1132 ),
1133 dg(
1134 "bynk.resolve.duplicate_param",
1135 "A parameter name is repeated.",
1136 &["param"],
1137 ),
1138 dg(
1139 "bynk.resolve.duplicate_provider",
1140 "A capability is provided more than once.",
1141 &["provider_decl"],
1142 ),
1143 dg(
1144 "bynk.resolve.duplicate_service",
1145 "Two services share a name.",
1146 &["service_decl"],
1147 ),
1148 dg(
1149 "bynk.resolve.duplicate_type",
1150 "Two types share a name.",
1151 &["type_decl"],
1152 ),
1153 dg(
1154 "bynk.resolve.duplicate_variant",
1155 "A sum type declares a variant twice.",
1156 &["sum_type"],
1157 ),
1158 d(
1159 "bynk.resolve.fn_without_call",
1160 "A function was referenced without being called.",
1161 ),
1162 dg(
1163 "bynk.resolve.let_shadows_fn",
1164 "A `let` binding shadows a function.",
1165 &["let_stmt"],
1166 ),
1167 dg(
1168 "bynk.resolve.let_shadows_type",
1169 "A `let` binding shadows a type.",
1170 &["let_stmt"],
1171 ),
1172 d(
1173 "bynk.resolve.method_unknown_type",
1174 "A method is defined on an unknown type.",
1175 ),
1176 dg(
1177 "bynk.resolve.missing_field",
1178 "A record construction omits a required field.",
1179 &["record_construction"],
1180 ),
1181 d(
1182 "bynk.resolve.name_conflict",
1183 "Two declarations share a name.",
1184 ),
1185 dg(
1186 "bynk.resolve.not_a_record_type",
1187 "Record syntax was used on a non-record type.",
1188 &["record_construction"],
1189 ),
1190 dg(
1191 "bynk.resolve.opaque_record_construction",
1192 "An opaque type was constructed with record syntax.",
1193 &["record_construction"],
1194 ),
1195 dg(
1196 "bynk.resolve.param_as_function",
1197 "A value (such as a parameter) was called as a function.",
1198 &["call"],
1199 ),
1200 dg(
1201 "bynk.resolve.recursive_record_field",
1202 "A record directly contains a field of its own type.",
1203 &["record_type"],
1204 ),
1205 dg(
1206 "bynk.resolve.reserved_builtin_type",
1207 "A type declaration reuses a compiler-known built-in type name.",
1208 &["type_decl"],
1209 ),
1210 dg(
1211 "bynk.resolve.self_outside_method",
1212 "`self` referenced outside a method or handler.",
1213 &["self_expr"],
1214 ),
1215 dg(
1216 "bynk.resolve.type_as_function",
1217 "A type name was called as if it were a function.",
1218 &["call"],
1219 ),
1220 d(
1221 "bynk.resolve.type_in_expr",
1222 "A type name was used where a value is expected.",
1223 ),
1224 dg(
1225 "bynk.resolve.unconsumed_context",
1226 "A context's service was called without a `consumes` declaration.",
1227 &["consumes_decl"],
1228 ),
1229 dg(
1230 "bynk.resolve.unknown_field",
1231 "Accessed a field the record does not have.",
1232 &["field_access"],
1233 ),
1234 dg(
1235 "bynk.resolve.unknown_function",
1236 "Called a function that does not exist.",
1237 &["call"],
1238 ),
1239 d(
1240 "bynk.resolve.unknown_name",
1241 "Referenced a name that is not in scope.",
1242 ),
1243 dg(
1244 "bynk.resolve.unknown_static_member",
1245 "Referenced an unknown static member (e.g. `T.x`).",
1246 &["field_access"],
1247 ),
1248 d(
1249 "bynk.resolve.unknown_type",
1250 "Referenced a type that does not exist.",
1251 ),
1252 d(
1253 "bynk.secrets.computed_name",
1254 "A `bynk.Secrets` read names its secret with a computed expression rather than a literal, so `bynk deploy` cannot plan it (warning).",
1255 ),
1256 dg(
1257 "bynk.send.in_pure_context",
1258 "A `~>` send was used in a pure (non-effectful) context.",
1259 &["effect_send_stmt"],
1260 ),
1261 dg(
1262 "bynk.send.non_effect",
1263 "A `~>` send was applied to a non-`Effect` value.",
1264 &["effect_send_stmt"],
1265 ),
1266 dg(
1267 "bynk.send.requires_unit",
1268 "A `~>` send targets an operation whose reply is not `Effect[()]`.",
1269 &["effect_send_stmt"],
1270 ),
1271 dg(
1272 "bynk.service.missing_from",
1273 "A `from`-less service has a handler other than `on call`.",
1274 &["service_decl"],
1275 ),
1276 dg(
1277 "bynk.service.mixed_protocols",
1278 "A service mixes handler forms that do not match its `from <protocol>`.",
1279 &["service_decl"],
1280 ),
1281 dg(
1282 "bynk.service.outside_context",
1283 "A `service` was declared outside a context.",
1284 &["service_decl"],
1285 ),
1286 dg(
1287 "bynk.service.return_not_effect",
1288 "A service handler's return type is not an `Effect`.",
1289 &["service_decl"],
1290 ),
1291 dg(
1292 "bynk.service.unknown_protocol",
1293 "A `from <protocol>` names an unknown protocol (e.g. a transport like Kafka).",
1294 &["service_decl"],
1295 ),
1296 d(
1297 "bynk.service.websocket_header",
1298 "The `from websocket` header is malformed — it binds frame types as `websocket(in: <type>, out: <type>)` (real-time track slice 3).",
1299 ),
1300 d(
1301 "bynk.service.websocket_multiple",
1302 "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).",
1303 ),
1304 d(
1305 "bynk.service.websocket_open_arity",
1306 "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).",
1307 ),
1308 d(
1309 "bynk.store.annotation_kind_mismatch",
1310 "A storage annotation is used on a kind it does not apply to (e.g. `@ttl` on a `Map`).",
1311 ),
1312 d(
1313 "bynk.store.annotation_unsupported",
1314 "A known storage annotation (`@ttl`/`@retain`/`@indexed`/`@bounded`) is used before the slice that supports it.",
1315 ),
1316 d(
1317 "bynk.store.cache_needs_clock",
1318 "A handler performs a `Cache` operation (TTL expiry reads the clock) without declaring `given Clock`.",
1319 ),
1320 d(
1321 "bynk.store.cache_ttl_required",
1322 "A `Cache` field is missing its required `@ttl(<duration>)` annotation (a keyed store with no expiry is a `Map`).",
1323 ),
1324 d(
1325 "bynk.store.kind_arity",
1326 "A storage kind was applied to the wrong number of type arguments (e.g. `Cell[A, B]`).",
1327 ),
1328 d(
1329 "bynk.store.kind_unsupported",
1330 "A known storage kind (`Queue`) is used before the slice that supports it.",
1331 ),
1332 d(
1333 "bynk.store.log_needs_clock",
1334 "A handler calls `Log.append` (which stamps the current time) without declaring `given Clock`.",
1335 ),
1336 d(
1337 "bynk.store.unknown_annotation",
1338 "A `store` field carries an annotation outside the closed `@indexed`/`@ttl`/`@retain`/`@bounded` set.",
1339 ),
1340 d(
1341 "bynk.store.unknown_kind",
1342 "A `store` field's type is not a known storage kind.",
1343 ),
1344 d(
1345 "bynk.store.unknown_map_accessor",
1346 "A `store Map` field access is not one of its query accessors (`entries`/`keys`/`values`).",
1347 ),
1348 d(
1349 "bynk.store.unknown_op",
1350 "A storage-`Map`/`Set` operation is not a recognised entry/membership method.",
1351 ),
1352 d(
1353 "bynk.stub.bad_sequence",
1354 "A `stub … returns each […]` sequence is malformed (e.g. empty).",
1355 ),
1356 d(
1357 "bynk.stub.not_a_seam",
1358 "A test `stub` overrides a capability the unit under test does not consume.",
1359 ),
1360 d(
1361 "bynk.stub.rhs_type",
1362 "A test `stub … returns <value>` right-hand side does not match the operation's return type.",
1363 ),
1364 d(
1365 "bynk.stub.unknown_op",
1366 "A test `stub` names an operation the capability does not declare.",
1367 ),
1368 dg(
1369 "bynk.suite.duplicate_case_name",
1370 "Two `case`s share a description.",
1371 &["case"],
1372 ),
1373 dg(
1374 "bynk.suite.unknown_target",
1375 "A `suite` targets a unit that does not exist.",
1376 &["suite_decl"],
1377 ),
1378 d(
1379 "bynk.target.browser_bundle_only",
1380 "The `browser` platform builds only the in-process `Bundle` topology; `--target workers` is not a browser build.",
1381 ),
1382 dg(
1383 "bynk.target.vendor_conflict",
1384 "One deployment unit's in-process closure uses platform-native capabilities from two mutually-exclusive platforms.",
1385 &["consumes_decl"],
1386 ),
1387 dg(
1388 "bynk.target.vendor_required",
1389 "A deployment unit uses a platform-native capability but the build selects another `--platform`.",
1390 &["consumes_decl"],
1391 ),
1392 dg(
1393 "bynk.test.actor_identity_required",
1394 "A call-site `by <Actor>` omits the identity an identity-carrying actor requires.",
1395 &["case"],
1396 ),
1397 dg(
1398 "bynk.test.actor_no_identity",
1399 "A call-site `by <Actor>(x)` supplies an identity to an actor that takes none — a unit-identity actor (e.g. `Visitor`) or `Nobody`.",
1400 &["case"],
1401 ),
1402 dg(
1403 "bynk.test.credential_needs_system",
1404 "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.",
1405 &["case"],
1406 ),
1407 dg(
1408 "bynk.test.nobody_needs_secured_route",
1409 "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.",
1410 &["case"],
1411 ),
1412 dg(
1413 "bynk.test.principal_identity_mismatch",
1414 "A call-site `by <Actor>` acts as an actor whose identity is incompatible with the addressed handler's actor.",
1415 &["case"],
1416 ),
1417 dg(
1418 "bynk.test.principal_on_wrong_method",
1419 "A wrong-method `405` test carries a `by <Actor>` clause; it reaches no handler, so a principal is meaningless.",
1420 &["case"],
1421 ),
1422 dg(
1423 "bynk.test.principal_required",
1424 "A test drives an identity-carrying handler with no call-site `by <Actor>(<identity>)`.",
1425 &["case"],
1426 ),
1427 dg(
1428 "bynk.test.service_bad_address",
1429 "A test body addresses a service the wrong way for its protocol (e.g. an http route without a leading path string).",
1430 &["case"],
1431 ),
1432 dg(
1433 "bynk.test.service_call_arity",
1434 "A test body's `svc.call(...)` passes the wrong number of arguments for the service's `on call` handler.",
1435 &["case"],
1436 ),
1437 dg(
1438 "bynk.test.service_no_call_handler",
1439 "A test body invokes `svc.call(...)` on a service with no `on call` handler (a `from http`/`cron`/`queue` service).",
1440 &["case"],
1441 ),
1442 dg(
1443 "bynk.test.service_unknown_route",
1444 "A test body addresses an http route / cron schedule / queue message the service does not declare.",
1445 &["case"],
1446 ),
1447 dg(
1448 "bynk.test.unknown_actor",
1449 "A call-site `by <Actor>` names an actor the target context does not declare and that is not a prelude actor.",
1450 &["case"],
1451 ),
1452 dg(
1453 "bynk.test.wire_needs_system",
1454 "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.",
1455 &["case"],
1456 ),
1457 d(
1458 "bynk.tier.property_has_tier",
1459 "A `property` carries an `as <tier>` clause; tiers are a `case`-only affordance.",
1460 ),
1461 d(
1462 "bynk.tier.system_needs_wire",
1463 "An `as system` test stands up fewer than two contexts; the system tier wires across contexts.",
1464 ),
1465 d(
1466 "bynk.transition.cross_agent_reference",
1467 "A transition predicate references another agent; step invariants are per-agent.",
1468 ),
1469 d(
1470 "bynk.transition.duplicate_name",
1471 "An agent declares two transitions with the same name.",
1472 ),
1473 d(
1474 "bynk.transition.impure_predicate",
1475 "A transition predicate uses an effectful or test-only construct; a step invariant must be pure.",
1476 ),
1477 d(
1478 "bynk.transition.no_step_reference",
1479 "A transition references neither `old` nor `new`; it constrains one state, so it is an `invariant`, not a step.",
1480 ),
1481 d(
1482 "bynk.transition.not_bool",
1483 "A transition predicate does not have type `Bool`.",
1484 ),
1485 d(
1486 "bynk.types.ambiguous_constructor",
1487 "`Ok`/`Err` is ambiguous between `Result` and `HttpResult`; qualify it.",
1488 ),
1489 dg(
1490 "bynk.types.argument_mismatch",
1491 "A function argument has the wrong type.",
1492 &["call"],
1493 ),
1494 dg(
1495 "bynk.types.call_arity",
1496 "A function value was applied with the wrong number of arguments.",
1497 &["call"],
1498 ),
1499 dg(
1500 "bynk.types.cannot_infer_option_type_param",
1501 "The value type of `None` could not be inferred.",
1502 &["none_expr"],
1503 ),
1504 d(
1505 "bynk.types.cannot_infer_result_type_params",
1506 "The type parameters of a `Result` could not be inferred.",
1507 ),
1508 dg(
1509 "bynk.types.catastrophic_regex",
1510 "A `Matches` predicate nests unbounded quantifiers, risking catastrophic backtracking (ReDoS).",
1511 &["refinement"],
1512 ),
1513 d(
1514 "bynk.types.constructor_arity",
1515 "A variant constructor got the wrong number of arguments.",
1516 ),
1517 d(
1518 "bynk.types.constructor_base_mismatch",
1519 "A `.of` constructor was given an argument of the wrong base type.",
1520 ),
1521 dg(
1522 "bynk.types.duplicate_literal_arm",
1523 "A `match` has two arms for the same literal value.",
1524 &["match_arm"],
1525 ),
1526 dg(
1527 "bynk.types.duplicate_variant_arm",
1528 "A `match` has two arms for the same variant.",
1529 &["match_arm"],
1530 ),
1531 d(
1532 "bynk.types.embeds_ambiguous",
1533 "A type is embedded by more than one variant of a sum, so `?`'s conversion would be ambiguous.",
1534 ),
1535 d(
1536 "bynk.types.embeds_unknown_variant",
1537 "An `embeds … as V` clause names a variant the sum does not declare.",
1538 ),
1539 d(
1540 "bynk.types.embeds_variant_shape",
1541 "An `embeds E as V` target variant must have exactly one payload field, of type `E`.",
1542 ),
1543 dg(
1544 "bynk.types.empty_refinement",
1545 "A refinement admits no values (contradictory predicates).",
1546 &["refinement"],
1547 ),
1548 dg(
1549 "bynk.types.err_value_mismatch",
1550 "An `Err` payload has the wrong type.",
1551 &["err_expr"],
1552 ),
1553 dg(
1554 "bynk.types.field_access_on_non_record",
1555 "Field access on a value that is not a record.",
1556 &["field_access"],
1557 ),
1558 dg(
1559 "bynk.types.field_refinement_not_base",
1560 "An inline field refinement requires a base or refined type.",
1561 &["record_field"],
1562 ),
1563 dg(
1564 "bynk.types.field_value_mismatch",
1565 "A record field was given a value of the wrong type.",
1566 &["record_construction"],
1567 ),
1568 dg(
1569 "bynk.types.function_at_boundary",
1570 "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.",
1571 &["function_type_ref"],
1572 ),
1573 dg(
1574 "bynk.types.guard_not_bool",
1575 "A match-arm `if` guard is not a `Bool` expression.",
1576 &["match_arm"],
1577 ),
1578 d(
1579 "bynk.types.held_at_boundary",
1580 "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).",
1581 ),
1582 d(
1583 "bynk.types.held_not_comparable",
1584 "A held value (`Connection[F]`) is compared with `==`/`!=` — held values have identity, not value-equality (§2.9.3, real-time track slice 2).",
1585 ),
1586 dg(
1587 "bynk.types.if_branch_mismatch",
1588 "The branches of an `if` have different types.",
1589 &["if_expr"],
1590 ),
1591 dg(
1592 "bynk.types.if_non_bool_cond",
1593 "An `if` condition is not a `Bool`.",
1594 &["if_expr"],
1595 ),
1596 dg(
1597 "bynk.types.if_without_else_requires_unit",
1598 "An `if` with no `else` branch has a non-unit then-branch; the missing else defaults to `()`, so the branch must be `()` or `Effect[()]`.",
1599 &["if_expr"],
1600 ),
1601 d(
1602 "bynk.types.interpolation_non_scalar",
1603 "An interpolation hole holds a value with no string form.",
1604 ),
1605 dg(
1606 "bynk.types.invalid_regex",
1607 "A `Matches` predicate contains an invalid regular expression.",
1608 &["refinement"],
1609 ),
1610 dg(
1611 "bynk.types.inverted_range",
1612 "An `InRange` predicate has its bounds inverted.",
1613 &["refinement"],
1614 ),
1615 dg(
1616 "bynk.types.is_base_mismatch",
1617 "An `is` refinement check is applied to a value of the wrong base type.",
1618 &["is_expr"],
1619 ),
1620 dg(
1621 "bynk.types.is_literal_pattern",
1622 "A literal was used on the right of `is`; `is` tests type/refinement, not value equality (use `==`).",
1623 &["is_expr"],
1624 ),
1625 dg(
1626 "bynk.types.is_non_sum",
1627 "`is` was applied to a value that is not a sum type.",
1628 &["is_expr"],
1629 ),
1630 dg(
1631 "bynk.types.is_unknown_variant",
1632 "`is` names a variant the type does not have.",
1633 &["is_expr"],
1634 ),
1635 dg(
1636 "bynk.types.json_uncodable",
1637 "A `Json.encode`/`Json.decode` target type cannot pass through the typed JSON codec (functions, effects, error builtins).",
1638 &["method_call"],
1639 ),
1640 dg(
1641 "bynk.types.key_not_orderable",
1642 "A `sortBy`/`min`/`max` key function does not return an orderable type (`Int`, `Float`, `String`, `Duration`, or `Instant`).",
1643 &[],
1644 ),
1645 dg(
1646 "bynk.types.lambda_mismatch",
1647 "A lambda's parameter count, parameter annotations, or body type do not match the expected function type.",
1648 &["lambda_expr"],
1649 ),
1650 dg(
1651 "bynk.types.let_annotation_mismatch",
1652 "A `let` value does not match its type annotation.",
1653 &["let_stmt"],
1654 ),
1655 dg(
1656 "bynk.types.list_element_mismatch",
1657 "A list-literal element has a different type from the list's element type.",
1658 &["list_literal"],
1659 ),
1660 dg(
1661 "bynk.types.match_arm_mismatch",
1662 "A `match` arm has a different type from the others.",
1663 &["match_arm"],
1664 ),
1665 dg(
1666 "bynk.types.match_non_sum_discriminant",
1667 "`match` was applied to a value that is not a sum type.",
1668 &["match_expr"],
1669 ),
1670 dg(
1671 "bynk.types.method_arity",
1672 "A method was called with the wrong number of arguments.",
1673 &["method_call"],
1674 ),
1675 dg(
1676 "bynk.types.method_not_found",
1677 "Called a method the type does not have.",
1678 &["method_call"],
1679 ),
1680 dg(
1681 "bynk.types.method_on_non_named_type",
1682 "A method was called on a built-in type that has no methods.",
1683 &["method_call"],
1684 ),
1685 dg(
1686 "bynk.types.mixed_pattern_bindings",
1687 "A pattern mixes named and positional bindings.",
1688 &["variant_pattern"],
1689 ),
1690 dg(
1691 "bynk.types.negative_length",
1692 "A length predicate was given a negative value.",
1693 &["refinement"],
1694 ),
1695 dg(
1696 "bynk.types.no_numeric_coercion",
1697 "`Int` and `Float` were mixed without an explicit conversion — in an operation or in refinement bounds.",
1698 &["binary_expr", "refinement"],
1699 ),
1700 dg(
1701 "bynk.types.non_exhaustive_match",
1702 "A `match` does not cover every variant.",
1703 &["match_expr"],
1704 ),
1705 dg(
1706 "bynk.types.ok_value_mismatch",
1707 "An `Ok` payload has the wrong type.",
1708 &["ok_expr"],
1709 ),
1710 dg(
1711 "bynk.types.opaque_raw_outside",
1712 "`.raw` on an opaque type was used outside its defining commons.",
1713 &["field_access"],
1714 ),
1715 dg(
1716 "bynk.types.opaque_record_construction",
1717 "An opaque type was constructed with record syntax.",
1718 &["record_construction"],
1719 ),
1720 dg(
1721 "bynk.types.opaque_unsafe_outside",
1722 "`.unsafe` on an opaque type was used outside its defining context.",
1723 &["field_access"],
1724 ),
1725 dg(
1726 "bynk.types.pattern_arity",
1727 "A pattern binds the wrong number of payload fields.",
1728 &["variant_pattern"],
1729 ),
1730 dg(
1731 "bynk.types.pattern_type_mismatch",
1732 "A pattern's type does not match the matched value.",
1733 &["variant_pattern"],
1734 ),
1735 dg(
1736 "bynk.types.predicate_base_mismatch",
1737 "A predicate does not apply to the type's base (e.g. a string predicate on an `Int`).",
1738 &["refinement"],
1739 ),
1740 d(
1741 "bynk.types.query_at_boundary",
1742 "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).",
1743 ),
1744 dg(
1745 "bynk.types.question_error_mismatch",
1746 "`?` propagates an error type incompatible with the function's.",
1747 &["question_expr"],
1748 ),
1749 dg(
1750 "bynk.types.question_on_non_result",
1751 "`?` was applied to a non-`Result` value.",
1752 &["question_expr"],
1753 ),
1754 dg(
1755 "bynk.types.question_option_outside_http",
1756 "`?` lifts an `Option` only inside a handler returning `HttpResult` (`None` becomes `NotFound`); elsewhere use `.okOr(err)`.",
1757 &["question_expr"],
1758 ),
1759 dg(
1760 "bynk.types.question_outside_result",
1761 "`?` used in a function that does not return a `Result`.",
1762 &["question_expr"],
1763 ),
1764 d(
1765 "bynk.types.return_mismatch",
1766 "A returned value does not match the declared return type.",
1767 ),
1768 dg(
1769 "bynk.types.some_value_mismatch",
1770 "A `Some` payload has the wrong type.",
1771 &["some_expr"],
1772 ),
1773 d(
1774 "bynk.types.stream_at_boundary",
1775 "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).",
1776 ),
1777 d(
1778 "bynk.types.stream_not_comparable",
1779 "A `Stream` value is compared with `==`/`!=` — a stream is a live value-over-time source, not a comparable value (real-time track slice 0).",
1780 ),
1781 d(
1782 "bynk.types.type_mismatch",
1783 "Two types that were required to match did not.",
1784 ),
1785 dg(
1786 "bynk.types.uninferable_element_type",
1787 "An empty `[]` (or `List.empty()` / `Map.empty()`) has no expected type to infer its element type from.",
1788 &["list_literal"],
1789 ),
1790 dg(
1791 "bynk.types.unkeyable_distinct",
1792 "A `distinct`/`distinctBy` element or key is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
1793 &[],
1794 ),
1795 dg(
1796 "bynk.types.unkeyable_map_key",
1797 "A `Map` key type is not value-keyable (`String`, `Int`, or a refined/opaque type over them).",
1798 &["generic_type_ref"],
1799 ),
1800 dg(
1801 "bynk.types.unknown_field",
1802 "Referenced a field the record type does not declare.",
1803 &["field_access"],
1804 ),
1805 dg(
1806 "bynk.types.unknown_pattern_field",
1807 "A pattern names a field the variant does not have.",
1808 &["variant_pattern"],
1809 ),
1810 dg(
1811 "bynk.types.unknown_static_member",
1812 "Referenced an unknown static member on a type.",
1813 &["field_access"],
1814 ),
1815 dg(
1816 "bynk.types.unknown_variant_in_pattern",
1817 "A pattern names a variant the sum type does not have.",
1818 &["variant_pattern"],
1819 ),
1820 dg(
1821 "bynk.types.unreachable_arm",
1822 "A `match` arm is unreachable.",
1823 &["match_arm"],
1824 ),
1825 d(
1826 "bynk.types.variant_arity",
1827 "A variant constructor got the wrong number of payload values.",
1828 ),
1829 d(
1830 "bynk.types.variant_missing_payload",
1831 "A variant requiring a payload was used without one.",
1832 ),
1833 d(
1834 "bynk.types.variant_payload_mismatch",
1835 "A variant payload has the wrong type.",
1836 ),
1837 dg(
1838 "bynk.uses.name_conflict",
1839 "A `uses` name collides with another name.",
1840 &["uses_decl"],
1841 ),
1842 dg(
1843 "bynk.uses.self_reference",
1844 "A commons `uses` itself.",
1845 &["uses_decl"],
1846 ),
1847 dg(
1848 "bynk.uses.target_is_context",
1849 "`uses` targets a context instead of a commons.",
1850 &["uses_decl"],
1851 ),
1852 dg(
1853 "bynk.uses.unknown_commons",
1854 "`uses` names a commons that does not exist.",
1855 &["uses_decl"],
1856 ),
1857 dg(
1858 "bynk.val.agent_not_generable",
1859 "A `for all`/`Val` cannot generate an agent — fabricated agent states need not be reachable.",
1860 &["for_all"],
1861 ),
1862 dg(
1863 "bynk.val.arity",
1864 "`Val[T]` was given the wrong number of pin arguments.",
1865 &["val_expr"],
1866 ),
1867 dg(
1868 "bynk.val.literal_violates",
1869 "A pinned `Val[T]` value violates the type's refinement.",
1870 &["val_expr"],
1871 ),
1872 dg(
1873 "bynk.val.needs_pin",
1874 "A bare `Val[T]` cannot generate a value (e.g. a `Matches` string); pin one.",
1875 &["val_expr"],
1876 ),
1877 dg(
1878 "bynk.val.outside_test",
1879 "`Val[T]` was used outside a test case body.",
1880 &["val_expr"],
1881 ),
1882 dg(
1883 "bynk.val.pin_not_literal",
1884 "A `Val[T]` pin argument is not a compile-time literal.",
1885 &["val_expr"],
1886 ),
1887 dg(
1888 "bynk.val.pin_unsupported",
1889 "A pin was given for a type kind that does not support pinning.",
1890 &["val_expr"],
1891 ),
1892 dg(
1893 "bynk.val.unknown_type",
1894 "`Val[T]` names a type that does not resolve.",
1895 &["val_expr"],
1896 ),
1897 dg(
1898 "bynk.val.unsupported_kind",
1899 "`Val[T]` cannot fabricate a value for this kind of type.",
1900 &["val_expr"],
1901 ),
1902 d(
1903 "bynk.ws.message_frame_param",
1904 "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).",
1905 ),
1906 d(
1907 "bynk.ws.open_given_unsupported",
1908 "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).",
1909 ),
1910 d(
1911 "bynk.ws.open_transfer_shape",
1912 "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).",
1913 ),
1914 d(
1915 "bynk.ws.route_param_mismatch",
1916 "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).",
1917 ),
1918];
1919
1920const fn d(code: &'static str, summary: &'static str) -> DiagnosticInfo {
1922 DiagnosticInfo {
1923 code,
1924 summary,
1925 grammar_symbol: &[],
1926 }
1927}
1928
1929const fn dg(
1931 code: &'static str,
1932 summary: &'static str,
1933 grammar_symbol: &'static [&'static str],
1934) -> DiagnosticInfo {
1935 DiagnosticInfo {
1936 code,
1937 summary,
1938 grammar_symbol,
1939 }
1940}
1941
1942pub fn category(code: &str) -> &str {
1945 code.split('.').nth(1).unwrap_or("")
1946}
1947
1948fn category_title(cat: &str) -> &'static str {
1950 match cat {
1951 "agent" | "agents" => "Agents",
1952 "boundary" => "Boundaries",
1953 "capability" => "Capabilities",
1954 "consumes" => "Consumes",
1955 "context" => "Contexts",
1956 "contract" => "Contracts",
1957 "cron" => "Cron",
1958 "effect" => "Effects",
1959 "expect" => "Expectations",
1960 "exports" => "Exports",
1961 "given" => "Given capabilities",
1962 "http" => "HTTP",
1963 "lex" => "Lexer",
1964 "mock" => "Mocks (collaborators)",
1965 "observe" => "Observation",
1966 "parse" => "Parser",
1967 "project" => "Project",
1968 "property" => "Properties (generative tests)",
1969 "provider" => "Providers",
1970 "queue" => "Queue",
1971 "record_spread" => "Record spread",
1972 "refine" => "Refinement",
1973 "resolve" => "Resolution",
1974 "service" => "Services",
1975 "suite" => "Suites and cases",
1976 "transition" => "Transitions (step invariants)",
1977 "types" => "Type checking",
1978 "uses" => "Uses",
1979 "val" => "Value fabrication",
1980 _ => "Other",
1981 }
1982}
1983
1984pub fn render_markdown() -> String {
1988 use std::collections::BTreeMap;
1989
1990 let mut by_category: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
1992 for info in REGISTRY {
1993 by_category
1994 .entry(category_title(category(info.code)))
1995 .or_default()
1996 .push(info);
1997 }
1998
1999 let mut out = String::new();
2000 out.push_str("# Diagnostic index\n\n");
2001 out.push_str(
2002 "<!-- GENERATED FILE — do not edit by hand.\n \
2003 Source: bynkc/src/diagnostics.rs (`render_markdown`).\n \
2004 Regenerate with: BYNK_BLESS=1 cargo test -p bynkc --test diagnostics_registry -->\n\n",
2005 );
2006 out.push_str(
2007 "Every diagnostic code the compiler can emit, with a one-line summary of \
2008 the cause, grouped by category. For step-by-step cause-and-fix guidance \
2009 on the most common ones, see the [troubleshooting guides](../troubleshooting/index.md).\n\n",
2010 );
2011 out.push_str(&format!(
2012 "There are **{}** codes in total.\n",
2013 REGISTRY.len()
2014 ));
2015
2016 for (title, infos) in &by_category {
2017 out.push_str(&format!("\n## {title}\n\n"));
2018 out.push_str("| Code | Summary | Construct |\n|---|---|---|\n");
2019 for info in infos {
2020 let construct = info
2025 .grammar_symbol
2026 .iter()
2027 .map(|sym| format!("[`{sym}`](grammar.md#rule-{sym})"))
2028 .collect::<Vec<_>>()
2029 .join(", ");
2030 out.push_str(&format!(
2031 "| `{}` | {} | {} |\n",
2032 info.code, info.summary, construct
2033 ));
2034 }
2035 }
2036
2037 out
2038}
2039
2040pub fn render_grammar_semantics_json() -> String {
2046 use std::collections::BTreeMap;
2047
2048 let mut by_symbol: BTreeMap<&str, Vec<&DiagnosticInfo>> = BTreeMap::new();
2051 for info in REGISTRY {
2052 for sym in info.grammar_symbol {
2053 by_symbol.entry(sym).or_default().push(info);
2054 }
2055 }
2056
2057 let mut map = serde_json::Map::new();
2058 map.insert(
2059 "_generated".to_string(),
2060 serde_json::Value::String(
2061 "Generated from the grammar_symbol field of bynkc/src/diagnostics.rs. \
2062 Do not edit by hand. Regenerate with: BYNK_BLESS=1 cargo test -p \
2063 bynkc --test diagnostics_registry"
2064 .to_string(),
2065 ),
2066 );
2067 for (sym, infos) in by_symbol {
2068 let arr: Vec<serde_json::Value> = infos
2069 .iter()
2070 .map(|info| serde_json::json!({ "code": info.code, "summary": info.summary }))
2071 .collect();
2072 map.insert(sym.to_string(), serde_json::Value::Array(arr));
2073 }
2074
2075 let mut s =
2076 serde_json::to_string_pretty(&serde_json::Value::Object(map)).expect("serialise semantics");
2077 s.push('\n');
2078 s
2079}