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